diff --git a/source/tools/atlas/AtlasObject/AtlasObject.h b/source/tools/atlas/AtlasObject/AtlasObject.h index b6fdfa4e82..bb2702a4e5 100644 --- a/source/tools/atlas/AtlasObject/AtlasObject.h +++ b/source/tools/atlas/AtlasObject/AtlasObject.h @@ -139,6 +139,9 @@ public: // Return the floating point value of this object double getDouble() const; + // Return the integer value of this object + int getInt() const; + // Check whether the object contains anything (even if those things are empty) bool defined() const { return (bool)p; } diff --git a/source/tools/atlas/AtlasObject/AtlasObjectImpl.cpp b/source/tools/atlas/AtlasObject/AtlasObjectImpl.cpp index 1096716e2b..11e580cd91 100644 --- a/source/tools/atlas/AtlasObject/AtlasObjectImpl.cpp +++ b/source/tools/atlas/AtlasObject/AtlasObjectImpl.cpp @@ -140,6 +140,18 @@ double AtObj::getDouble() const return val; } +int AtObj::getInt() const +{ + int val = 0; + if (p) + { + std::wstringstream s; + s << p->value; + s >> val; + } + return val; +} + void AtObj::add(const char* key, AtObj& data) { if (!p) diff --git a/source/tools/atlas/AtlasUI/ScenarioEditor/Sections/Player/Player.cpp b/source/tools/atlas/AtlasUI/ScenarioEditor/Sections/Player/Player.cpp index d14727c173..ea5f9a4dd8 100644 --- a/source/tools/atlas/AtlasUI/ScenarioEditor/Sections/Player/Player.cpp +++ b/source/tools/atlas/AtlasUI/ScenarioEditor/Sections/Player/Player.cpp @@ -552,12 +552,12 @@ void PlayerSettingsControl::ReadFromEngine() AtObj clrObj = *player["Colour"]; if (clrObj.defined()) { - colour = wxColor(wxAtoi(*clrObj["r"]), wxAtoi(*clrObj["g"]), wxAtoi(*clrObj["b"])); + colour = wxColor((*clrObj["r"]).getInt(), (*clrObj["g"]).getInt(), (*clrObj["b"]).getInt()); } else { clrObj = *playerDefs["Colour"]; - colour = wxColor(wxAtoi(*clrObj["r"]), wxAtoi(*clrObj["g"]), wxAtoi(*clrObj["b"])); + colour = wxColor((*clrObj["r"]).getInt(), (*clrObj["g"]).getInt(), (*clrObj["b"]).getInt()); } controls.colour->SetBackgroundColour(colour); @@ -616,7 +616,7 @@ void PlayerSettingsControl::ReadFromEngine() // team if (player["Team"].defined()) - controls.team->SetSelection(wxAtoi(*player["Team"])); + controls.team->SetSelection((*player["Team"]).getInt()); else controls.team->SetSelection(0); @@ -624,6 +624,9 @@ void PlayerSettingsControl::ReadFromEngine() if (player["StartingCamera"].defined()) { sCameraInfo info; + // Don't use wxAtof because it depends on locales which + // may cause problems with decimal points + // see: http://www.wxwidgets.org/docs/faqgtk.htm#locale AtObj camPos = *player["StartingCamera"]["Position"]; info.pX = (float)(*camPos["x"]).getDouble(); info.pY = (float)(*camPos["y"]).getDouble();