Latest commit before switching to git for the whole Extension directory.

git-svn-id: svn://localhost@1118 8062f311-0dae-4547-b526-b8ab9ac864a5
This commit is contained in:
Florian
2013-07-01 22:03:08 +00:00
parent e7775754fc
commit eed60d7caa
8 changed files with 261 additions and 5386 deletions
+45 -121
View File
@@ -1,7 +1,7 @@
/**
Game Develop - TextEntry Object Extension
Copyright (c) 2011-2012 Florian Rival (Florian.Rival@gmail.com)
Copyright (c) 2011-2013 Florian Rival (Florian.Rival@gmail.com)
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
@@ -24,60 +24,45 @@ freely, subject to the following restrictions:
*/
#if defined(GD_IDE_ONLY)
#include <wx/wx.h> //Must be placed first, otherwise we get errors relative to "cannot convert 'const TCHAR*'..." in wx/msw/winundef.h
#endif
#include <SFML/Graphics.hpp>
#include <string>
#include "GDL/Object.h"
#include "GDL/ImageManager.h"
#include "GDL/tinyxml/tinyxml.h"
#include "GDL/Position.h"
#include "GDL/RuntimeScene.h"
#include "GDCpp/Object.h"
#include "GDCpp/ImageManager.h"
#include "GDCpp/tinyxml/tinyxml.h"
#include "GDCpp/Position.h"
#include "GDCpp/Project.h"
#include "GDCpp/RuntimeScene.h"
#include "TextEntryObject.h"
#if defined(GD_IDE_ONLY)
#include "GDCore/IDE/ArbitraryResourceWorker.h"
#include "GDL/CommonTools.h"
#include "GDCpp/CommonTools.h"
#include "GDCore/IDE/Dialogs/MainFrameWrapper.h"
#include "TextEntryObjectEditor.h"
#endif
using namespace std;
#if defined(GD_IDE_ONLY)
sf::Texture TextEntryObject::edittimeIconImage;
sf::Sprite TextEntryObject::edittimeIcon;
#endif
TextEntryObject::TextEntryObject(std::string name_) :
Object(name_),
scene(NULL),
Object(name_)
{
}
RuntimeTextEntryObject::RuntimeTextEntryObject(RuntimeScene & scene_, const gd::Object & object) :
RuntimeObject(scene_, object),
scene(&scene_),
activated(true)
{
}
bool TextEntryObject::LoadRuntimeResources(const RuntimeScene & scene_, const ImageManager & imageMgr )
{
scene = &scene_;
return true;
}
bool TextEntryObject::InitializeFromInitialPosition(const InitialPosition & position)
{
return true;
}
/**
* Does not render anything
* \brief Used to update input
*/
bool TextEntryObject::Draw( sf::RenderTarget& renderTarget )
{
return true;
}
/**
* Used to update input
*/
void TextEntryObject::UpdateTime(float)
void RuntimeTextEntryObject::UpdateTime(float)
{
if (!activated || scene == NULL) return;
@@ -87,64 +72,47 @@ void TextEntryObject::UpdateTime(float)
const std::vector<sf::Event> & events = scene->GetRenderTargetEvents();
for (unsigned int i = 0;i<events.size();++i)
{
if (events[i].Type == sf::Event::TextEntered )
if (events[i].type == sf::Event::TextEntered )
{
//Skip some non displayable characters
if (events[i].Text.Unicode > 30 && (events[i].Text.Unicode < 127 || events[i].Text.Unicode > 159))
text += events[i].Text.Unicode;
else if (events[i].Text.Unicode == 8) //Backspace
if ( !text.empty() ) text.erase(text.end()-1);
if (events[i].text.unicode > 30 && (events[i].text.unicode < 127 || events[i].text.unicode > 159))
text += events[i].text.unicode;
else if (events[i].text.unicode == 8)
{
//Backspace
if ( !text.empty() ) text.erase(text.end()-1);
}
}
}
}
#if defined(GD_IDE_ONLY)
/**
* Does not render anything
*/
bool TextEntryObject::DrawEdittime( sf::RenderTarget& renderTarget )
void TextEntryObject::DrawInitialInstance(gd::InitialInstance & instance, sf::RenderTarget & renderTarget, gd::Project & project, gd::Layout & layout)
{
edittimeIcon.SetPosition(GetX(), GetY());
renderTarget.Draw(edittimeIcon);
return true;
edittimeIcon.setPosition(instance.GetX(), instance.GetY());
renderTarget.draw(edittimeIcon);
}
void TextEntryObject::LoadEdittimeIcon()
{
edittimeIconImage.LoadFromFile("Extensions/textentry.png");
edittimeIcon.SetTexture(edittimeIconImage);
edittimeIconImage.loadFromFile("CppPlatform/Extensions/textentry.png");
edittimeIcon.setTexture(edittimeIconImage);
}
bool TextEntryObject::GenerateThumbnail(const gd::Project & project, wxBitmap & thumbnail)
{
thumbnail = wxBitmap("Extensions/textentry.png", wxBITMAP_TYPE_ANY);
thumbnail = wxBitmap("CppPlatform/Extensions/textentry.png", wxBITMAP_TYPE_ANY);
return true;
}
void TextEntryObject::EditObject( wxWindow* parent, Game & game, gd::MainFrameWrapper & mainFrameWrapper )
void RuntimeTextEntryObject::GetPropertyForDebugger(unsigned int propertyNb, string & name, string & value) const
{
/*TextEntryObjectEditor dialog(parent, game, *this, mainFrameWrapper);
dialog.ShowModal();*/
if ( propertyNb == 0 ) {name = _("Text in memory"); value = GetString();}
else if ( propertyNb == 1 ) {name = _("Activated \?"); value = activated ? _("Yes") : _("No");}
}
wxPanel * TextEntryObject::CreateInitialPositionPanel( wxWindow* parent, const Game & game_, const Scene & scene_, const InitialPosition & position )
{
return NULL;
}
void TextEntryObject::UpdateInitialPositionFromPanel(wxPanel * panel, InitialPosition & position)
{
}
void TextEntryObject::GetPropertyForDebugger(unsigned int propertyNb, string & name, string & value) const
{
if ( propertyNb == 0 ) {name = _("Text in memory"); value = GetString();}
else if ( propertyNb == 1 ) {name = _("Activated \?"); value = activated ? _("Yes") : _("No");}
}
bool TextEntryObject::ChangeProperty(unsigned int propertyNb, string newValue)
bool RuntimeTextEntryObject::ChangeProperty(unsigned int propertyNb, string newValue)
{
if ( propertyNb == 0 ) { SetString(newValue); return true; }
else if ( propertyNb == 1 ) { activated = (newValue != _("No")); return true; }
@@ -152,64 +120,20 @@ bool TextEntryObject::ChangeProperty(unsigned int propertyNb, string newValue)
return true;
}
unsigned int TextEntryObject::GetNumberOfProperties() const
unsigned int RuntimeTextEntryObject::GetNumberOfProperties() const
{
return 1;
return 2;
}
#endif
/**
* Get the real X position of the sprite
*/
float TextEntryObject::GetDrawableX() const
void DestroyRuntimeTextEntryObject(RuntimeObject * object)
{
return GetX();
delete object;
}
/**
* Get the real Y position of the text
*/
float TextEntryObject::GetDrawableY() const
RuntimeObject * CreateRuntimeTextEntryObject(RuntimeScene & scene, const gd::Object & object)
{
return GetY();
}
/**
* Width is the width of the current sprite.
*/
float TextEntryObject::GetWidth() const
{
return 32;
}
/**
* Height is the height of the current sprite.
*/
float TextEntryObject::GetHeight() const
{
return 32;
}
/**
* X center is computed with text rectangle
*/
float TextEntryObject::GetCenterX() const
{
return 16;
}
const std::string & TextEntryObject::GetString() const
{
return text;
};
/**
* Y center is computed with text rectangle
*/
float TextEntryObject::GetCenterY() const
{
return 16;
return new RuntimeTextEntryObject(scene, object);
}
/**
@@ -217,7 +141,7 @@ float TextEntryObject::GetCenterY() const
* Game Develop does not delete directly extension object
* to avoid overloaded new/delete conflicts.
*/
void DestroyTextEntryObject(Object * object)
void DestroyTextEntryObject(gd::Object * object)
{
delete object;
}
@@ -226,7 +150,7 @@ void DestroyTextEntryObject(Object * object)
* Function creating an extension Object.
* Game Develop can not directly create an extension object
*/
Object * CreateTextEntryObject(std::string name)
gd::Object * CreateTextEntryObject(std::string name)
{
return new TextEntryObject(name);
}