From 2527fe92a76860af29643a522a3a1100cc7fa01c Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Wed, 15 Sep 2010 15:32:35 +0200 Subject: [PATCH] implemented creature/NPC level --- apps/openmw/mwclass/creature.cpp | 2 ++ apps/openmw/mwclass/npc.cpp | 2 ++ apps/openmw/mwgui/layouts.hpp | 19 +++++++++++++------ apps/openmw/mwgui/window_manager.cpp | 5 +++++ apps/openmw/mwgui/window_manager.hpp | 3 +++ apps/openmw/mwmechanics/creaturestats.hpp | 2 +- apps/openmw/mwmechanics/mechanicsmanager.cpp | 6 ++++-- 7 files changed, 30 insertions(+), 9 deletions(-) diff --git a/apps/openmw/mwclass/creature.cpp b/apps/openmw/mwclass/creature.cpp index 2e16ac6a43..7a50fcb2a6 100644 --- a/apps/openmw/mwclass/creature.cpp +++ b/apps/openmw/mwclass/creature.cpp @@ -78,6 +78,8 @@ namespace MWClass stats->mDynamic[1].set (ref->base->data.mana); stats->mDynamic[2].set (ref->base->data.fatigue); + stats->mLevel = ref->base->data.level; + ptr.getRefData().getCreatureStats() = stats; } diff --git a/apps/openmw/mwclass/npc.cpp b/apps/openmw/mwclass/npc.cpp index 04ae468e42..699d518b84 100644 --- a/apps/openmw/mwclass/npc.cpp +++ b/apps/openmw/mwclass/npc.cpp @@ -94,6 +94,8 @@ namespace MWClass stats->mDynamic[1].set (ref->base->npdt52.mana); stats->mDynamic[2].set (ref->base->npdt52.fatigue); + stats->mLevel = ref->base->npdt52.level; + ptr.getRefData().getCreatureStats() = stats; } diff --git a/apps/openmw/mwgui/layouts.hpp b/apps/openmw/mwgui/layouts.hpp index dd59410540..45b207f94d 100644 --- a/apps/openmw/mwgui/layouts.hpp +++ b/apps/openmw/mwgui/layouts.hpp @@ -7,6 +7,8 @@ #include +#include + /* This file contains classes corresponding to all the window layouts defined in resources/mygui/ *.xml. @@ -211,11 +213,6 @@ namespace MWGui { setText (names[i][0], store.gameSettings.find (names[i][1])->str); } - - // These are just demo values, you should replace these with - // real calls from outside the class later. - setText("LevelText", "5"); - setText("ClassText", "Pilgrim"); } void setPlayerName(const std::string& playerName) @@ -274,7 +271,17 @@ namespace MWGui else if (id=="race") setText ("RaceText", value); else if (id=="class") - setText ("ClassText", value); + setText ("ClassText", value); + } + + void setValue (const std::string& id, int value) + { + if (id=="level") + { + std::ostringstream text; + text << value; + setText("LevelText", text.str()); + } } }; diff --git a/apps/openmw/mwgui/window_manager.cpp b/apps/openmw/mwgui/window_manager.cpp index cee739ead1..c01a70bb4c 100644 --- a/apps/openmw/mwgui/window_manager.cpp +++ b/apps/openmw/mwgui/window_manager.cpp @@ -145,6 +145,11 @@ void WindowManager::setValue (const std::string& id, const std::string& value) stats->setValue (id, value); } +void WindowManager::setValue (const std::string& id, int value) +{ + stats->setValue (id, value); +} + void WindowManager::messageBox (const std::string& message, const std::vector& buttons) { std::cout << "message box: " << message << std::endl; diff --git a/apps/openmw/mwgui/window_manager.hpp b/apps/openmw/mwgui/window_manager.hpp index fe2aa16eb6..04fe5c7c99 100644 --- a/apps/openmw/mwgui/window_manager.hpp +++ b/apps/openmw/mwgui/window_manager.hpp @@ -167,6 +167,9 @@ namespace MWGui void setValue (const std::string& id, const std::string& value); ///< set value for the given ID. + void setValue (const std::string& id, int value); + ///< set value for the given ID. + void messageBox (const std::string& message, const std::vector& buttons); private: diff --git a/apps/openmw/mwmechanics/creaturestats.hpp b/apps/openmw/mwmechanics/creaturestats.hpp index ee3631c909..c1eae578fa 100644 --- a/apps/openmw/mwmechanics/creaturestats.hpp +++ b/apps/openmw/mwmechanics/creaturestats.hpp @@ -9,8 +9,8 @@ namespace MWMechanics { Stat mAttributes[8]; DynamicStat mDynamic[3]; // health, magicka, fatigue + int mLevel; }; } #endif - diff --git a/apps/openmw/mwmechanics/mechanicsmanager.cpp b/apps/openmw/mwmechanics/mechanicsmanager.cpp index b4f543039c..c41ec9cba1 100644 --- a/apps/openmw/mwmechanics/mechanicsmanager.cpp +++ b/apps/openmw/mwmechanics/mechanicsmanager.cpp @@ -18,10 +18,10 @@ namespace MWMechanics MWMechanics::CreatureStats& creatureStats = MWWorld::Class::get (ptr).getCreatureStats (ptr); // MWMechanics::NpcStats& npcStats = MWWorld::Class::get (ptr).getNpcStats (ptr); -// const ESM::NPC *player = ptr.get()->base; + const ESM::NPC *player = ptr.get()->base; // reset - + creatureStats.mLevel = player->npdt52.level; // race const ESM::Race *race = @@ -153,6 +153,8 @@ namespace MWMechanics mEnvironment.mWindowManager->setValue (dynamicNames[i], stats.mDynamic[i]); } } + + mEnvironment.mWindowManager->setValue ("level", stats.mLevel); } if (mUpdatePlayer)