From 283e0df3a0702e47e6fa5e40e720333cd15d70f4 Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Tue, 21 Sep 2010 17:42:07 +0200 Subject: [PATCH] send skill updates to GUI sub-system --- apps/openmw/mwmechanics/mechanicsmanager.cpp | 43 ++++++++++++++++++++ apps/openmw/mwmechanics/mechanicsmanager.hpp | 2 + 2 files changed, 45 insertions(+) diff --git a/apps/openmw/mwmechanics/mechanicsmanager.cpp b/apps/openmw/mwmechanics/mechanicsmanager.cpp index 75418ffbd..b417b34b9 100644 --- a/apps/openmw/mwmechanics/mechanicsmanager.cpp +++ b/apps/openmw/mwmechanics/mechanicsmanager.cpp @@ -137,6 +137,9 @@ namespace MWMechanics MWMechanics::CreatureStats& stats = MWWorld::Class::get (mWatched).getCreatureStats (mWatched); + MWMechanics::NpcStats& npcStats = + MWWorld::Class::get (mWatched).getNpcStats (mWatched); + static const char *attributeNames[8] = { "AttribVal1", "AttribVal2", "AttribVal3", "AttribVal4", "AttribVal5", @@ -148,6 +151,17 @@ namespace MWMechanics "HBar", "MBar", "FBar" }; + static const char *skillNames[27] = + { + "SkillBlock", "SkillArmorer", "SkillMediumArmor", "SkillHeavyArmor", + "SkillBluntWeapon", "SkillLongBlade", "SkillAxe", "SkillSpear", + "SkillAthletics", "SkillEnchant", "SkillDestruction", "SkillAlteration", + "SkillIllusion", "SkillConjuration", "SkillMysticism", "SkillRestoration", + "SkillAlchemy", "SkillUnarmored", "SkillSecurity", "SkillSneak", + "SkillAcrobatics", "SkillLightArmor", "SkillShortBlade", "SkillMarksman", + "SkillMercantile", "SkillSpeechcraft", "SkillHandToHand", + }; + for (int i=0; i<8; ++i) { if (stats.mAttributes[i]!=mWatchedCreature.mAttributes[i]) @@ -168,6 +182,24 @@ namespace MWMechanics } } + bool update = false; + + for (int i=0; i<27; ++i) + { + if (npcStats.mSkill[i]!=mWatchedNpc.mSkill[i]) + { + update = true; + + mWatchedNpc.mSkill[i] = npcStats.mSkill[i]; + + mEnvironment.mWindowManager->setValue (skillNames[i], npcStats.mSkill[i]); + + } + } + + if (update) + mEnvironment.mWindowManager->updateSkillArea(); + mEnvironment.mWindowManager->setValue ("level", stats.mLevel); } @@ -181,6 +213,17 @@ namespace MWMechanics mEnvironment.mWindowManager->setValue ("class", mEnvironment.mWorld->getPlayerPos().getClass().name); mUpdatePlayer = false; + + MWGui::WindowManager::SkillList majorSkills (5); + MWGui::WindowManager::SkillList minorSkills (5); + + for (int i=0; i<5; ++i) + { + minorSkills[i] = mEnvironment.mWorld->getPlayerPos().getClass().data.skills[i][0]; + majorSkills[i] = mEnvironment.mWorld->getPlayerPos().getClass().data.skills[i][1]; + } + + mEnvironment.mWindowManager->configureSkills (majorSkills, minorSkills); } } diff --git a/apps/openmw/mwmechanics/mechanicsmanager.hpp b/apps/openmw/mwmechanics/mechanicsmanager.hpp index 96ba00dd6..96c3188bd 100644 --- a/apps/openmw/mwmechanics/mechanicsmanager.hpp +++ b/apps/openmw/mwmechanics/mechanicsmanager.hpp @@ -6,6 +6,7 @@ #include "../mwworld/ptr.hpp" #include "creaturestats.hpp" +#include "npcstats.hpp" namespace MWWorld { @@ -20,6 +21,7 @@ namespace MWMechanics std::set mActors; MWWorld::Ptr mWatched; CreatureStats mWatchedCreature; + NpcStats mWatchedNpc; bool mUpdatePlayer; void buildPlayer();