mirror of
https://github.com/4ian/GDevelop.git
synced 2025-10-15 10:19:04 +00:00
Replace std::string by gd::String in TextEntryObject
This commit is contained in:
@@ -33,7 +33,7 @@ sf::Texture TextEntryObject::edittimeIconImage;
|
||||
sf::Sprite TextEntryObject::edittimeIcon;
|
||||
#endif
|
||||
|
||||
TextEntryObject::TextEntryObject(std::string name_) :
|
||||
TextEntryObject::TextEntryObject(gd::String name_) :
|
||||
Object(name_)
|
||||
{
|
||||
}
|
||||
@@ -59,17 +59,18 @@ void RuntimeTextEntryObject::UpdateTime(float)
|
||||
{
|
||||
//Skip some non displayable characters
|
||||
if (characters[i] > 30 && (characters[i] < 127 || characters[i] > 159))
|
||||
text += gd::utf8::FromSfString(sf::String(characters[i]));
|
||||
{
|
||||
std::cout << characters[i] << std::endl;
|
||||
text += static_cast<char32_t>(characters[i]);
|
||||
}
|
||||
else if (characters[i] == 8)
|
||||
{
|
||||
std::cout << "Backspace" << std::endl;
|
||||
//Backspace : find the previous codepoint and remove it
|
||||
if(text.empty())
|
||||
continue;
|
||||
|
||||
std::string::iterator it = text.end();
|
||||
utf8::prior(it, text.begin());
|
||||
|
||||
text.erase(it, text.end());
|
||||
text.pop_back();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -96,13 +97,13 @@ bool TextEntryObject::GenerateThumbnail(const gd::Project & project, wxBitmap &
|
||||
return true;
|
||||
}
|
||||
|
||||
void RuntimeTextEntryObject::GetPropertyForDebugger(unsigned int propertyNb, string & name, string & value) const
|
||||
void RuntimeTextEntryObject::GetPropertyForDebugger(unsigned int propertyNb, gd::String & name, gd::String & value) const
|
||||
{
|
||||
if ( propertyNb == 0 ) {name = _("Text in memory"); value = GetString();}
|
||||
else if ( propertyNb == 1 ) {name = _("Activated \?"); value = activated ? _("Yes") : _("No");}
|
||||
}
|
||||
|
||||
bool RuntimeTextEntryObject::ChangeProperty(unsigned int propertyNb, string newValue)
|
||||
bool RuntimeTextEntryObject::ChangeProperty(unsigned int propertyNb, gd::String newValue)
|
||||
{
|
||||
if ( propertyNb == 0 ) { SetString(newValue); return true; }
|
||||
else if ( propertyNb == 1 ) { activated = (newValue != _("No")); return true; }
|
||||
@@ -121,9 +122,7 @@ RuntimeObject * CreateRuntimeTextEntryObject(RuntimeScene & scene, const gd::Obj
|
||||
return new RuntimeTextEntryObject(scene, object);
|
||||
}
|
||||
|
||||
gd::Object * CreateTextEntryObject(std::string name)
|
||||
gd::Object * CreateTextEntryObject(gd::String name)
|
||||
{
|
||||
return new TextEntryObject(name);
|
||||
}
|
||||
|
||||
|
||||
|
@@ -30,7 +30,7 @@ class wxBitmap;
|
||||
class GD_EXTENSION_API TextEntryObject : public gd::Object
|
||||
{
|
||||
public :
|
||||
TextEntryObject(std::string name_);
|
||||
TextEntryObject(gd::String name_);
|
||||
virtual ~TextEntryObject() {};
|
||||
virtual gd::Object * Clone() const { return new TextEntryObject(*this); }
|
||||
|
||||
@@ -57,28 +57,27 @@ public :
|
||||
virtual RuntimeObject * Clone() const { return new RuntimeTextEntryObject(*this);}
|
||||
|
||||
#if defined(GD_IDE_ONLY)
|
||||
virtual void GetPropertyForDebugger (unsigned int propertyNb, std::string & name, std::string & value) const;
|
||||
virtual bool ChangeProperty(unsigned int propertyNb, std::string newValue);
|
||||
virtual void GetPropertyForDebugger (unsigned int propertyNb, gd::String & name, gd::String & value) const;
|
||||
virtual bool ChangeProperty(unsigned int propertyNb, gd::String newValue);
|
||||
virtual unsigned int GetNumberOfProperties() const;
|
||||
#endif
|
||||
|
||||
virtual void UpdateTime(float);
|
||||
|
||||
inline void SetString(std::string str) { text = str; };
|
||||
const std::string & GetString() const { return text; };
|
||||
inline void SetString(gd::String str) { text = str; };
|
||||
const gd::String & GetString() const { return text; };
|
||||
|
||||
void Activate( bool activate = true ) { activated = activate; };
|
||||
bool IsActivated() const { return activated; };
|
||||
|
||||
private:
|
||||
|
||||
std::string text;
|
||||
gd::String text;
|
||||
const RuntimeScene * scene; ///< Pointer to the scene. Initialized during LoadRuntimeResources call.
|
||||
bool activated;
|
||||
};
|
||||
|
||||
gd::Object * CreateTextEntryObject(std::string name);
|
||||
gd::Object * CreateTextEntryObject(gd::String name);
|
||||
RuntimeObject * CreateRuntimeTextEntryObject(RuntimeScene & scene, const gd::Object & object);
|
||||
|
||||
#endif // TEXTENTRYOBJECT_H
|
||||
|
||||
|
Reference in New Issue
Block a user