This Trac instance is not used for development anymore!

We migrated our development workflow to git and Gitea.
To test the future redirection, replace trac by ariadne in the page URL.

Changeset 9643 for ps


Ignore:
Timestamp:
06/21/11 04:56:49 (14 years ago)
Author:
ben
Message:

Adds getInt to AtlasObject
Uses this instead of wxAtoi for consistency, and adds brief comment about why wxAtof should be avoided

Location:
ps/trunk/source/tools/atlas
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • ps/trunk/source/tools/atlas/AtlasObject/AtlasObject.h

    r9639 r9643  
    140140    double getDouble() const;
    141141
     142    // Return the integer value of this object
     143    int getInt() const;
     144
    142145    // Check whether the object contains anything (even if those things are empty)
    143146    bool defined() const { return (bool)p; }
  • ps/trunk/source/tools/atlas/AtlasObject/AtlasObjectImpl.cpp

    r9639 r9643  
    141141}
    142142
     143int AtObj::getInt() const
     144{
     145    int val = 0;
     146    if (p)
     147    {
     148        std::wstringstream s;
     149        s << p->value;
     150        s >> val;
     151    }
     152    return val;
     153}
     154
    143155void AtObj::add(const char* key, AtObj& data)
    144156{
  • ps/trunk/source/tools/atlas/AtlasUI/ScenarioEditor/Sections/Player/Player.cpp

    r9639 r9643  
    553553        if (clrObj.defined())
    554554        {
    555             colour = wxColor(wxAtoi(*clrObj["r"]), wxAtoi(*clrObj["g"]), wxAtoi(*clrObj["b"]));
     555            colour = wxColor((*clrObj["r"]).getInt(), (*clrObj["g"]).getInt(), (*clrObj["b"]).getInt());
    556556        }
    557557        else
    558558        {
    559559            clrObj = *playerDefs["Colour"];
    560             colour = wxColor(wxAtoi(*clrObj["r"]), wxAtoi(*clrObj["g"]), wxAtoi(*clrObj["b"]));
     560            colour = wxColor((*clrObj["r"]).getInt(), (*clrObj["g"]).getInt(), (*clrObj["b"]).getInt());
    561561        }
    562562        controls.colour->SetBackgroundColour(colour);
     
    617617        // team
    618618        if (player["Team"].defined())
    619             controls.team->SetSelection(wxAtoi(*player["Team"]));
     619            controls.team->SetSelection((*player["Team"]).getInt());
    620620        else
    621621            controls.team->SetSelection(0);
     
    625625        {
    626626            sCameraInfo info;
     627            // Don't use wxAtof because it depends on locales which
     628            //  may cause problems with decimal points
     629            //  see: http://www.wxwidgets.org/docs/faqgtk.htm#locale
    627630            AtObj camPos = *player["StartingCamera"]["Position"];
    628631            info.pX = (float)(*camPos["x"]).getDouble();
Note: See TracChangeset for help on using the changeset viewer.