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