From 4f296896e184d9e65bee355903b5a023347e98b5 Mon Sep 17 00:00:00 2001 From: Jan Borsodi Date: Sat, 18 Sep 2010 21:34:49 +0200 Subject: [PATCH] Moved code for the stats window from the header file and to the cpp file. --- apps/openmw/mwgui/layouts.cpp | 80 +++++++++++++++++++++++++++++++++ apps/openmw/mwgui/layouts.hpp | 84 +++-------------------------------- 2 files changed, 86 insertions(+), 78 deletions(-) diff --git a/apps/openmw/mwgui/layouts.cpp b/apps/openmw/mwgui/layouts.cpp index 8f67d2904..b5af8454a 100644 --- a/apps/openmw/mwgui/layouts.cpp +++ b/apps/openmw/mwgui/layouts.cpp @@ -80,6 +80,23 @@ void StatsWindow::onWindowResize(MyGUI::WidgetPtr window) updateScroller(); } +void StatsWindow::setBar(const std::string& name, const std::string& tname, int val, int max) +{ + MyGUI::ProgressPtr pt; + getWidget(pt, name); + pt->setProgressRange(max); + pt->setProgressPosition(val); + + std::stringstream out; + out << val << "/" << max; + setText(tname, out.str().c_str()); +} + +void StatsWindow::setPlayerName(const std::string& playerName) +{ + mMainWidget->setCaption(playerName); +} + void StatsWindow::setStyledText(MyGUI::WidgetPtr widget, ColorStyle style, const std::string &value) { widget->setCaption(value); @@ -91,6 +108,69 @@ void StatsWindow::setStyledText(MyGUI::WidgetPtr widget, ColorStyle style, const widget->setTextColour(MyGUI::Colour(1, 1, 1)); } +void StatsWindow::setValue (const std::string& id, const MWMechanics::Stat& value) +{ + static const char *ids[] = + { + "AttribVal1", "AttribVal2", "AttribVal3", "AttribVal4", "AttribVal5", + "AttribVal6", "AttribVal7", "AttribVal8", + 0 + }; + + for (int i=0; ids[i]; ++i) + if (ids[i]==id) + { + std::ostringstream valueString; + valueString << value.getModified(); + setText (id, valueString.str()); + + if (value.getModified()>value.getBase()) + setTextColor (id, 0, 1, 0); + else if (value.getModified()& value) +{ + static const char *ids[] = + { + "HBar", "MBar", "FBar", + 0 + }; + + for (int i=0; ids[i]; ++i) + if (ids[i]==id) + { + std::string id (ids[i]); + setBar (id, id + "T", value.getCurrent(), value.getModified()); + } +} + +void StatsWindow::setValue (const std::string& id, const std::string& value) +{ + if (id=="name") + setPlayerName (value); + else if (id=="race") + setText ("RaceText", value); + else if (id=="class") + setText ("ClassText", value); +} + +void StatsWindow::setValue (const std::string& id, int value) +{ + if (id=="level") + { + std::ostringstream text; + text << value; + setText("LevelText", text.str()); + } +} + void StatsWindow::setValue (const std::string& id, const MWMechanics::Stat& value) { static struct {const char *id; ESM::Skill::SkillEnum skillId; } skillMap[] = diff --git a/apps/openmw/mwgui/layouts.hpp b/apps/openmw/mwgui/layouts.hpp index 6615aba42..5f9cb297c 100644 --- a/apps/openmw/mwgui/layouts.hpp +++ b/apps/openmw/mwgui/layouts.hpp @@ -185,88 +185,16 @@ namespace MWGui typedef std::vector SkillList; - void setBar(const std::string& name, const std::string& tname, int val, int max) - { - MyGUI::ProgressPtr pt; - getWidget(pt, name); - pt->setProgressRange(max); - pt->setProgressPosition(val); - - std::stringstream out; - out << val << "/" << max; - setText(tname, out.str().c_str()); - } - StatsWindow (MWWorld::Environment& environment); - void setPlayerName(const std::string& playerName) - { - mMainWidget->setCaption(playerName); - } + void setBar(const std::string& name, const std::string& tname, int val, int max); + void setPlayerName(const std::string& playerName); /// Set value for the given ID. - void setValue (const std::string& id, const MWMechanics::Stat& value) - { - static const char *ids[] = - { - "AttribVal1", "AttribVal2", "AttribVal3", "AttribVal4", "AttribVal5", - "AttribVal6", "AttribVal7", "AttribVal8", - 0 - }; - - for (int i=0; ids[i]; ++i) - if (ids[i]==id) - { - std::ostringstream valueString; - valueString << value.getModified(); - setText (id, valueString.str()); - - if (value.getModified()>value.getBase()) - setTextColor (id, 0, 1, 0); - else if (value.getModified()& value) - { - static const char *ids[] = - { - "HBar", "MBar", "FBar", - 0 - }; - - for (int i=0; ids[i]; ++i) - if (ids[i]==id) - { - std::string id (ids[i]); - setBar (id, id + "T", value.getCurrent(), value.getModified()); - } - } - - void setValue (const std::string& id, const std::string& value) - { - if (id=="name") - setPlayerName (value); - else if (id=="race") - setText ("RaceText", value); - else if (id=="class") - setText ("ClassText", value); - } - - void setValue (const std::string& id, int value) - { - if (id=="level") - { - std::ostringstream text; - text << value; - setText("LevelText", text.str()); - } - } + void setValue (const std::string& id, const MWMechanics::Stat& value); + void setValue (const std::string& id, const MWMechanics::DynamicStat& value); + void setValue (const std::string& id, const std::string& value); + void setValue (const std::string& id, int value); void setValue (const std::string& id, const MWMechanics::Stat& value);