Adds getInt to AtlasObject
Uses this instead of wxAtoi for consistency, and adds brief comment about why wxAtof should be avoided This was SVN commit r9643.
This commit is contained in:
parent
ef4df42895
commit
abdc846a65
@ -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; }
|
||||
|
||||
|
@ -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)
|
||||
|
@ -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();
|
||||
|
Loading…
Reference in New Issue
Block a user