From aa827442e86e5baa2239b78542adde22a36b0535 Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Sun, 24 Jun 2012 11:39:21 +0200 Subject: [PATCH 01/32] Issue #314: Generalised ActiveSpells class so that it can handle lasting effects from potions too --- apps/openmw/mwmechanics/activespells.cpp | 36 ++++++++++++++++-------- apps/openmw/mwmechanics/activespells.hpp | 6 ++++ 2 files changed, 31 insertions(+), 11 deletions(-) diff --git a/apps/openmw/mwmechanics/activespells.cpp b/apps/openmw/mwmechanics/activespells.cpp index ced2a5c3f..f456a0e51 100644 --- a/apps/openmw/mwmechanics/activespells.cpp +++ b/apps/openmw/mwmechanics/activespells.cpp @@ -3,6 +3,9 @@ #include +#include +#include + #include "../mwbase/environment.hpp" #include "../mwworld/world.hpp" @@ -42,14 +45,13 @@ namespace MWMechanics for (TIterator iter (begin()); iter!=end(); ++iter) { - const ESM::Spell& spell = - *MWBase::Environment::get().getWorld()->getStore().spells.find (iter->first); + const ESM::EffectList& effects = getEffectList (iter->first); const MWWorld::TimeStamp& start = iter->second.first; float magnitude = iter->second.second; - for (std::vector::const_iterator iter (spell.effects.list.begin()); - iter!=spell.effects.list.end(); ++iter) + for (std::vector::const_iterator iter (effects.list.begin()); + iter!=effects.list.end(); ++iter) { if (iter->duration) { @@ -70,18 +72,31 @@ namespace MWMechanics } } + const ESM::EffectList& ActiveSpells::getEffectList (const std::string& id) const + { + if (const ESM::Spell *spell = + MWBase::Environment::get().getWorld()->getStore().spells.search (id)) + return spell->effects; + + if (const ESM::Potion *potion = + MWBase::Environment::get().getWorld()->getStore().potions.search (id)) + return potion->effects; + + throw std::runtime_error ("ID " + id + " can not produce lasting effects"); + } + ActiveSpells::ActiveSpells() : mSpellsChanged (false), mLastUpdate (MWBase::Environment::get().getWorld()->getTimeStamp()) {} void ActiveSpells::addSpell (const std::string& id) { - const ESM::Spell& spell = *MWBase::Environment::get().getWorld()->getStore().spells.find (id); + const ESM::EffectList& effects = getEffectList (id); bool found = false; - for (std::vector::const_iterator iter (spell.effects.list.begin()); - iter!=spell.effects.list.end(); ++iter) + for (std::vector::const_iterator iter (effects.list.begin()); + iter!=effects.list.end(); ++iter) { if (iter->duration) { @@ -137,13 +152,12 @@ namespace MWMechanics double ActiveSpells::timeToExpire (const TIterator& iterator) const { - const ESM::Spell& spell = - *MWBase::Environment::get().getWorld()->getStore().spells.find (iterator->first); + const ESM::EffectList& effects = getEffectList (iterator->first); int duration = 0; - for (std::vector::const_iterator iter (spell.effects.list.begin()); - iter!=spell.effects.list.end(); ++iter) + for (std::vector::const_iterator iter (effects.list.begin()); + iter!=effects.list.end(); ++iter) { if (iter->duration>duration) duration = iter->duration; diff --git a/apps/openmw/mwmechanics/activespells.hpp b/apps/openmw/mwmechanics/activespells.hpp index 179321c58..91c528587 100644 --- a/apps/openmw/mwmechanics/activespells.hpp +++ b/apps/openmw/mwmechanics/activespells.hpp @@ -12,11 +12,15 @@ namespace ESM { struct Spell; + struct EffectList; } namespace MWMechanics { /// \brief Lasting spell effects + /// + /// \note The name of this class is slightly misleading, since it also handels lasting potion + /// effects. class ActiveSpells { public: @@ -33,6 +37,8 @@ namespace MWMechanics void update() const; + const ESM::EffectList& getEffectList (const std::string& id) const; + public: ActiveSpells(); From 83c3972a89d78cddee8c12b7616bd862fb6c30fa Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Sun, 24 Jun 2012 16:23:43 +0200 Subject: [PATCH 02/32] Issue #314: added return value to addSpell function --- apps/openmw/mwmechanics/activespells.cpp | 6 ++++-- apps/openmw/mwmechanics/activespells.hpp | 4 +++- apps/openmw/mwworld/class.cpp | 5 +++++ apps/openmw/mwworld/class.hpp | 6 ++++++ 4 files changed, 18 insertions(+), 3 deletions(-) diff --git a/apps/openmw/mwmechanics/activespells.cpp b/apps/openmw/mwmechanics/activespells.cpp index f456a0e51..e9215ec57 100644 --- a/apps/openmw/mwmechanics/activespells.cpp +++ b/apps/openmw/mwmechanics/activespells.cpp @@ -89,7 +89,7 @@ namespace MWMechanics : mSpellsChanged (false), mLastUpdate (MWBase::Environment::get().getWorld()->getTimeStamp()) {} - void ActiveSpells::addSpell (const std::string& id) + bool ActiveSpells::addSpell (const std::string& id) { const ESM::EffectList& effects = getEffectList (id); @@ -106,7 +106,7 @@ namespace MWMechanics } if (!found) - return; + return false; TContainer::iterator iter = mSpells.find (id); @@ -119,6 +119,8 @@ namespace MWMechanics iter->second = std::make_pair (MWBase::Environment::get().getWorld()->getTimeStamp(), random); mSpellsChanged = true; + + return true; } void ActiveSpells::removeSpell (const std::string& id) diff --git a/apps/openmw/mwmechanics/activespells.hpp b/apps/openmw/mwmechanics/activespells.hpp index 91c528587..2226cea84 100644 --- a/apps/openmw/mwmechanics/activespells.hpp +++ b/apps/openmw/mwmechanics/activespells.hpp @@ -43,9 +43,11 @@ namespace MWMechanics ActiveSpells(); - void addSpell (const std::string& id); + bool addSpell (const std::string& id); ///< Overwrites an existing spell with the same ID. If the spell does not have any /// non-instant effects, it is ignored. + /// + /// \return Has the spell been added? void removeSpell (const std::string& id); diff --git a/apps/openmw/mwworld/class.cpp b/apps/openmw/mwworld/class.cpp index fe39406fe..dde3afbbb 100644 --- a/apps/openmw/mwworld/class.cpp +++ b/apps/openmw/mwworld/class.cpp @@ -32,6 +32,11 @@ namespace MWWorld } + bool Class::apply (const MWWorld::Ptr& ptr, const std::string& id) const + { + return false; + } + MWMechanics::CreatureStats& Class::getCreatureStats (const Ptr& ptr) const { throw std::runtime_error ("class does not have creature stats"); diff --git a/apps/openmw/mwworld/class.hpp b/apps/openmw/mwworld/class.hpp index 46781d516..8dd427bde 100644 --- a/apps/openmw/mwworld/class.hpp +++ b/apps/openmw/mwworld/class.hpp @@ -164,6 +164,12 @@ namespace MWWorld /// effects). Throws an exception, if the object can't hold other objects. /// (default implementation: throws an exception) + virtual bool apply (const MWWorld::Ptr& ptr, const std::string& id) const; + ///< Apply \a id on \a ptr. + /// \return Any effect? + /// + /// (default implementation: ignore and return false) + static const Class& get (const std::string& key); ///< If there is no class for this \a key, an exception is thrown. From 771863e73bb3d2c68392851daaac630fdc4b078d Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Fri, 6 Jul 2012 15:50:26 +0200 Subject: [PATCH 03/32] Issue #324: Started turning NpcStats into a proper class; fixed a cmake script bug; fixed a namespace issue --- apps/openmw/CMakeLists.txt | 2 +- apps/openmw/mwclass/npc.cpp | 5 +++-- apps/openmw/mwinput/inputmanager.cpp | 18 +++++++++--------- apps/openmw/mwmechanics/drawstate.hpp | 13 ++++++++----- apps/openmw/mwmechanics/npcstats.cpp | 17 +++++++++++++++++ apps/openmw/mwmechanics/npcstats.hpp | 20 +++++++++++++------- apps/openmw/mwworld/player.cpp | 8 ++++---- apps/openmw/mwworld/player.hpp | 4 ++-- 8 files changed, 57 insertions(+), 30 deletions(-) create mode 100644 apps/openmw/mwmechanics/npcstats.cpp diff --git a/apps/openmw/CMakeLists.txt b/apps/openmw/CMakeLists.txt index 9534ecc90..36e59f6bd 100644 --- a/apps/openmw/CMakeLists.txt +++ b/apps/openmw/CMakeLists.txt @@ -60,7 +60,7 @@ add_openmw_dir (mwclass add_openmw_dir (mwmechanics mechanicsmanager stat creaturestats magiceffects movement actors drawstate spells - activespells + activespells npcstats ) add_openmw_dir (mwbase diff --git a/apps/openmw/mwclass/npc.cpp b/apps/openmw/mwclass/npc.cpp index d4f711885..3a91ec63f 100644 --- a/apps/openmw/mwclass/npc.cpp +++ b/apps/openmw/mwclass/npc.cpp @@ -233,7 +233,8 @@ namespace MWClass case Combat: - stats.mCombat = set; + // Combat stance ignored for now; need to be determined based on draw state instead of + // being maunally set. break; } } @@ -260,7 +261,7 @@ namespace MWClass case Combat: - return stats.mCombat; + return false; } return false; diff --git a/apps/openmw/mwinput/inputmanager.cpp b/apps/openmw/mwinput/inputmanager.cpp index a2bafcbf7..73cadacd0 100644 --- a/apps/openmw/mwinput/inputmanager.cpp +++ b/apps/openmw/mwinput/inputmanager.cpp @@ -102,15 +102,15 @@ private: { if (windows.isGuiMode()) return; - DrawState state = player.getDrawState(); - if (state == DrawState_Weapon || state == DrawState_Nothing) + MWMechanics::DrawState state = player.getDrawState(); + if (state == MWMechanics::DrawState_Weapon || state == MWMechanics::DrawState_Nothing) { - player.setDrawState(DrawState_Spell); + player.setDrawState(MWMechanics::DrawState_Spell); std::cout << "Player has now readied his hands for spellcasting!\n"; } else { - player.setDrawState(DrawState_Nothing); + player.setDrawState(MWMechanics::DrawState_Nothing); std::cout << "Player does not have any kind of attack ready now.\n"; } } @@ -119,15 +119,15 @@ private: { if (windows.isGuiMode()) return; - DrawState state = player.getDrawState(); - if (state == DrawState_Spell || state == DrawState_Nothing) + MWMechanics::DrawState state = player.getDrawState(); + if (state == MWMechanics::DrawState_Spell || state == MWMechanics::DrawState_Nothing) { - player.setDrawState(DrawState_Weapon); + player.setDrawState(MWMechanics::DrawState_Weapon); std::cout << "Player is now drawing his weapon.\n"; } else { - player.setDrawState(DrawState_Nothing); + player.setDrawState(MWMechanics::DrawState_Nothing); std::cout << "Player does not have any kind of attack ready now.\n"; } } @@ -336,7 +336,7 @@ private: poller.bind(A_MoveRight, KC_D); poller.bind(A_MoveForward, KC_W); poller.bind(A_MoveBackward, KC_S); - + poller.bind(A_Jump, KC_E); poller.bind(A_Crouch, KC_LCONTROL); } diff --git a/apps/openmw/mwmechanics/drawstate.hpp b/apps/openmw/mwmechanics/drawstate.hpp index 772086d90..94b48fdd8 100644 --- a/apps/openmw/mwmechanics/drawstate.hpp +++ b/apps/openmw/mwmechanics/drawstate.hpp @@ -3,11 +3,14 @@ #undef DrawState -enum DrawState +namespace MWMechanics { - DrawState_Weapon = 0, - DrawState_Spell = 1, - DrawState_Nothing = 2, -}; + enum DrawState + { + DrawState_Weapon = 0, + DrawState_Spell = 1, + DrawState_Nothing = 2, + }; +} #endif diff --git a/apps/openmw/mwmechanics/npcstats.cpp b/apps/openmw/mwmechanics/npcstats.cpp new file mode 100644 index 000000000..70db00bb7 --- /dev/null +++ b/apps/openmw/mwmechanics/npcstats.cpp @@ -0,0 +1,17 @@ + +#include "npcstats.hpp" + +MWMechanics::NpcStats::NpcStats() +: mForceRun (false), mForceSneak (false), mRun (false), mSneak (false), + mDrawState (DrawState_Nothing) +{} + +MWMechanics::DrawState MWMechanics::NpcStats::getDrawState() const +{ + return mDrawState; +} + +void MWMechanics::NpcStats::setDrawState (DrawState state) +{ + mDrawState = state; +} diff --git a/apps/openmw/mwmechanics/npcstats.hpp b/apps/openmw/mwmechanics/npcstats.hpp index 972863b72..c2907ccb5 100644 --- a/apps/openmw/mwmechanics/npcstats.hpp +++ b/apps/openmw/mwmechanics/npcstats.hpp @@ -3,6 +3,7 @@ #include #include +#include #include "stat.hpp" #include "drawstate.hpp" @@ -16,10 +17,14 @@ namespace MWMechanics /// \note For technical reasons the spell list and the currently selected spell is also handled by /// CreatureStats, even though they are actually NPC stats. - struct NpcStats + class NpcStats { - // NPCs other than the player can only have one faction. But for the sake of consistency - // we use the same data structure for the PC and the NPCs. + DrawState mDrawState; + + public: + + /// NPCs other than the player can only have one faction. But for the sake of consistency + /// we use the same data structure for the PC and the NPCs. /// \note the faction key must be in lowercase std::map mFactionRank; @@ -29,11 +34,12 @@ namespace MWMechanics bool mForceSneak; bool mRun; bool mSneak; - bool mCombat; - DrawState mDrawState; - NpcStats() : mForceRun (false), mForceSneak (false), mRun (false), mSneak (false), - mCombat (false) , mDrawState(DrawState_Nothing) {} + NpcStats(); + + DrawState getDrawState() const; + + void setDrawState (DrawState state); }; } diff --git a/apps/openmw/mwworld/player.cpp b/apps/openmw/mwworld/player.cpp index 0eeebad4e..d8b3285ef 100644 --- a/apps/openmw/mwworld/player.cpp +++ b/apps/openmw/mwworld/player.cpp @@ -56,10 +56,10 @@ namespace MWWorld mClass = new_class; } - void Player::setDrawState(const DrawState& value) + void Player::setDrawState (MWMechanics::DrawState state) { MWWorld::Ptr ptr = getPlayer(); - MWWorld::Class::get(ptr).getNpcStats(ptr).mDrawState = value; + MWWorld::Class::get(ptr).getNpcStats(ptr).setDrawState (state); } void Player::setAutoMove (bool enable) @@ -111,10 +111,10 @@ namespace MWWorld MWWorld::Class::get (ptr).setStance (ptr, MWWorld::Class::Run, !running); } - DrawState Player::getDrawState() + MWMechanics::DrawState Player::getDrawState() { MWWorld::Ptr ptr = getPlayer(); - return MWWorld::Class::get(ptr).getNpcStats(ptr).mDrawState; + return MWWorld::Class::get(ptr).getNpcStats(ptr).getDrawState(); } } diff --git a/apps/openmw/mwworld/player.hpp b/apps/openmw/mwworld/player.hpp index b1692bd81..2c87cf91b 100644 --- a/apps/openmw/mwworld/player.hpp +++ b/apps/openmw/mwworld/player.hpp @@ -83,7 +83,7 @@ namespace MWWorld void setClass (const ESM::Class& class_); - void setDrawState(const DrawState& state); + void setDrawState (MWMechanics::DrawState state); std::string getName() const { @@ -115,7 +115,7 @@ namespace MWWorld return mAutoMove; } - DrawState getDrawState(); + MWMechanics::DrawState getDrawState(); /// \todo constness void setAutoMove (bool enable); From d30ba14a176956757610206f2231ec15bd222243 Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Fri, 6 Jul 2012 18:23:48 +0200 Subject: [PATCH 04/32] Issue #324: Finished turning NpcStats into a proper class --- apps/openmw/mwclass/npc.cpp | 22 ++++---- apps/openmw/mwdialogue/dialoguemanager.cpp | 18 +++--- apps/openmw/mwgui/stats_window.cpp | 2 +- apps/openmw/mwmechanics/mechanicsmanager.cpp | 20 +++---- apps/openmw/mwmechanics/npcstats.cpp | 44 ++++++++++++++- apps/openmw/mwmechanics/npcstats.hpp | 41 ++++++++++---- apps/openmw/mwmechanics/spellsuccess.hpp | 4 +- apps/openmw/mwscript/controlextensions.cpp | 58 ++++++++------------ apps/openmw/mwscript/statsextensions.cpp | 30 +++++----- apps/openmw/mwworld/inventorystore.cpp | 4 +- 10 files changed, 144 insertions(+), 99 deletions(-) diff --git a/apps/openmw/mwclass/npc.cpp b/apps/openmw/mwclass/npc.cpp index 3a91ec63f..d54b9441d 100644 --- a/apps/openmw/mwclass/npc.cpp +++ b/apps/openmw/mwclass/npc.cpp @@ -67,11 +67,11 @@ namespace MWClass boost::algorithm::to_lower(faction); if(ref->base->npdt52.gold != -10) { - data->mNpcStats.mFactionRank[faction] = (int)ref->base->npdt52.rank; + data->mNpcStats.getFactionRanks()[faction] = (int)ref->base->npdt52.rank; } else { - data->mNpcStats.mFactionRank[faction] = (int)ref->base->npdt12.rank; + data->mNpcStats.getFactionRanks()[faction] = (int)ref->base->npdt12.rank; } } @@ -79,7 +79,7 @@ namespace MWClass if(ref->base->npdt52.gold != -10) { for (int i=0; i<27; ++i) - data->mNpcStats.mSkill[i].setBase (ref->base->npdt52.skills[i]); + data->mNpcStats.getSkill (i).setBase (ref->base->npdt52.skills[i]); data->mCreatureStats.mAttributes[0].set (ref->base->npdt52.strength); data->mCreatureStats.mAttributes[1].set (ref->base->npdt52.intelligence); @@ -201,12 +201,12 @@ namespace MWClass { case Run: - stats.mForceRun = force; + stats.setMovementFlag (MWMechanics::NpcStats::Flag_ForceRun, force); break; case Sneak: - stats.mForceSneak = force; + stats.setMovementFlag (MWMechanics::NpcStats::Flag_ForceSneak, force); break; case Combat: @@ -223,12 +223,12 @@ namespace MWClass { case Run: - stats.mRun = set; + stats.setMovementFlag (MWMechanics::NpcStats::Flag_Run, set); break; case Sneak: - stats.mSneak = set; + stats.setMovementFlag (MWMechanics::NpcStats::Flag_Sneak, set); break; case Combat: @@ -247,17 +247,17 @@ namespace MWClass { case Run: - if (!ignoreForce && stats.mForceRun) + if (!ignoreForce && stats.getMovementFlag (MWMechanics::NpcStats::Flag_ForceRun)) return true; - return stats.mRun; + return stats.getMovementFlag (MWMechanics::NpcStats::Flag_Run); case Sneak: - if (!ignoreForce && stats.mForceSneak) + if (!ignoreForce && stats.getMovementFlag (MWMechanics::NpcStats::Flag_ForceSneak)) return true; - return stats.mSneak; + return stats.getMovementFlag (MWMechanics::NpcStats::Flag_Sneak); case Combat: diff --git a/apps/openmw/mwdialogue/dialoguemanager.cpp b/apps/openmw/mwdialogue/dialoguemanager.cpp index 98562c053..64a976d40 100644 --- a/apps/openmw/mwdialogue/dialoguemanager.cpp +++ b/apps/openmw/mwdialogue/dialoguemanager.cpp @@ -203,10 +203,10 @@ namespace MWDialogue MWMechanics::NpcStats PCstats = MWWorld::Class::get(MWBase::Environment::get().getWorld()->getPlayer().getPlayer()).getNpcStats(MWBase::Environment::get().getWorld()->getPlayer().getPlayer()); MWMechanics::NpcStats NPCstats = MWWorld::Class::get(actor).getNpcStats(actor); int sameFaction = 0; - if(!NPCstats.mFactionRank.empty()) + if(!NPCstats.getFactionRanks().empty()) { - std::string NPCFaction = NPCstats.mFactionRank.begin()->first; - if(PCstats.mFactionRank.find(toLower(NPCFaction)) != PCstats.mFactionRank.end()) sameFaction = 1; + std::string NPCFaction = NPCstats.getFactionRanks().begin()->first; + if(PCstats.getFactionRanks().find(toLower(NPCFaction)) != PCstats.getFactionRanks().end()) sameFaction = 1; } if(!selectCompare(comp,sameFaction,select.i)) return false; } @@ -525,8 +525,8 @@ namespace MWDialogue //MWWorld::Class npcClass = MWWorld::Class::get(actor); MWMechanics::NpcStats stats = MWWorld::Class::get(actor).getNpcStats(actor); - std::map::iterator it = stats.mFactionRank.find(toLower(info.npcFaction)); - if(it!=stats.mFactionRank.end()) + std::map::iterator it = stats.getFactionRanks().find(toLower(info.npcFaction)); + if(it!=stats.getFactionRanks().end()) { //check rank if(it->second < (int)info.data.rank) return false; @@ -542,8 +542,8 @@ namespace MWDialogue if(!info.pcFaction.empty()) { MWMechanics::NpcStats stats = MWWorld::Class::get(MWBase::Environment::get().getWorld()->getPlayer().getPlayer()).getNpcStats(MWBase::Environment::get().getWorld()->getPlayer().getPlayer()); - std::map::iterator it = stats.mFactionRank.find(toLower(info.pcFaction)); - if(it!=stats.mFactionRank.end()) + std::map::iterator it = stats.getFactionRanks().find(toLower(info.pcFaction)); + if(it!=stats.getFactionRanks().end()) { //check rank if(it->second < (int)info.data.PCrank) return false; @@ -903,13 +903,13 @@ namespace MWDialogue std::string factionID(""); MWMechanics::NpcStats stats = MWWorld::Class::get(mActor).getNpcStats(mActor); - if(stats.mFactionRank.empty()) + if(stats.getFactionRanks().empty()) { std::cout << "No faction for this actor!"; } else { - factionID = stats.mFactionRank.begin()->first; + factionID = stats.getFactionRanks().begin()->first; } return factionID; } diff --git a/apps/openmw/mwgui/stats_window.cpp b/apps/openmw/mwgui/stats_window.cpp index 0f8b41b28..be99982d9 100644 --- a/apps/openmw/mwgui/stats_window.cpp +++ b/apps/openmw/mwgui/stats_window.cpp @@ -270,7 +270,7 @@ void StatsWindow::onFrame () MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayer().getPlayer(); MWMechanics::NpcStats PCstats = MWWorld::Class::get(player).getNpcStats(player); - setFactions(PCstats.mFactionRank); + setFactions(PCstats.getFactionRanks()); setBirthSign(MWBase::Environment::get().getWorld()->getPlayer().getBirthsign()); diff --git a/apps/openmw/mwmechanics/mechanicsmanager.cpp b/apps/openmw/mwmechanics/mechanicsmanager.cpp index 13052d064..ada05a11b 100644 --- a/apps/openmw/mwmechanics/mechanicsmanager.cpp +++ b/apps/openmw/mwmechanics/mechanicsmanager.cpp @@ -28,7 +28,7 @@ namespace MWMechanics creatureStats.mMagicEffects = MagicEffects(); for (int i=0; i<27; ++i) - npcStats.mSkill[i].setBase (player->npdt52.skills[i]); + npcStats.getSkill (i).setBase (player->npdt52.skills[i]); creatureStats.mAttributes[0].setBase (player->npdt52.strength); creatureStats.mAttributes[1].setBase (player->npdt52.intelligence); @@ -73,8 +73,8 @@ namespace MWMechanics if (index>=0 && index<27) { - npcStats.mSkill[index].setBase ( - npcStats.mSkill[index].getBase() + race->data.bonus[i].bonus); + npcStats.getSkill (index).setBase ( + npcStats.getSkill (index).getBase() + race->data.bonus[i].bonus); } } @@ -124,8 +124,8 @@ namespace MWMechanics if (index>=0 && index<27) { - npcStats.mSkill[index].setBase ( - npcStats.mSkill[index].getBase() + bonus); + npcStats.getSkill (index).setBase ( + npcStats.getSkill (index).getBase() + bonus); } } } @@ -141,8 +141,8 @@ namespace MWMechanics if (index>=0 && index<27) { - npcStats.mSkill[index].setBase ( - npcStats.mSkill[index].getBase() + 5); + npcStats.getSkill (index).setBase ( + npcStats.getSkill (index).getBase() + 5); } } } @@ -236,11 +236,11 @@ namespace MWMechanics //Loop over ESM::Skill::SkillEnum for(int i = 0; i < 27; ++i) { - if(npcStats.mSkill[i] != mWatchedNpc.mSkill[i]) + if(npcStats.getSkill (i) != mWatchedNpc.getSkill (i)) { update = true; - mWatchedNpc.mSkill[i] = npcStats.mSkill[i]; - MWBase::Environment::get().getWindowManager()->setValue((ESM::Skill::SkillEnum)i, npcStats.mSkill[i]); + mWatchedNpc.getSkill (i) = npcStats.getSkill (i); + MWBase::Environment::get().getWindowManager()->setValue((ESM::Skill::SkillEnum)i, npcStats.getSkill (i)); } } diff --git a/apps/openmw/mwmechanics/npcstats.cpp b/apps/openmw/mwmechanics/npcstats.cpp index 70db00bb7..cdb977029 100644 --- a/apps/openmw/mwmechanics/npcstats.cpp +++ b/apps/openmw/mwmechanics/npcstats.cpp @@ -1,9 +1,10 @@ #include "npcstats.hpp" +#include + MWMechanics::NpcStats::NpcStats() -: mForceRun (false), mForceSneak (false), mRun (false), mSneak (false), - mDrawState (DrawState_Nothing) +: mMovementFlags (0), mDrawState (DrawState_Nothing) {} MWMechanics::DrawState MWMechanics::NpcStats::getDrawState() const @@ -15,3 +16,42 @@ void MWMechanics::NpcStats::setDrawState (DrawState state) { mDrawState = state; } + +bool MWMechanics::NpcStats::getMovementFlag (Flag flag) const +{ + return mMovementFlags & flag; +} + +void MWMechanics::NpcStats::setMovementFlag (Flag flag, bool state) +{ + if (state) + mMovementFlags |= flag; + else + mMovementFlags &= ~flag; +} + +const MWMechanics::Stat& MWMechanics::NpcStats::getSkill (int index) const +{ + if (index<0 || index>=27) + throw std::runtime_error ("skill index out of range"); + + return mSkill[index]; +} + +MWMechanics::Stat& MWMechanics::NpcStats::getSkill (int index) +{ + if (index<0 || index>=27) + throw std::runtime_error ("skill index out of range"); + + return mSkill[index]; +} + +std::map& MWMechanics::NpcStats::getFactionRanks() +{ + return mFactionRank; +} + +const std::map& MWMechanics::NpcStats::getFactionRanks() const +{ + return mFactionRank; +} diff --git a/apps/openmw/mwmechanics/npcstats.hpp b/apps/openmw/mwmechanics/npcstats.hpp index c2907ccb5..16a777b71 100644 --- a/apps/openmw/mwmechanics/npcstats.hpp +++ b/apps/openmw/mwmechanics/npcstats.hpp @@ -19,27 +19,46 @@ namespace MWMechanics class NpcStats { - DrawState mDrawState; - public: - /// NPCs other than the player can only have one faction. But for the sake of consistency - /// we use the same data structure for the PC and the NPCs. - /// \note the faction key must be in lowercase - std::map mFactionRank; + enum Flag + { + Flag_ForceRun = 1, + Flag_ForceSneak = 2, + Flag_Run = 4, + Flag_Sneak = 8 + }; + + private: - Stat mSkill[27]; + /// NPCs other than the player can only have one faction. But for the sake of consistency + /// we use the same data structure for the PC and the NPCs. + /// \note the faction key must be in lowercase + std::map mFactionRank; - bool mForceRun; - bool mForceSneak; - bool mRun; - bool mSneak; + DrawState mDrawState; + unsigned int mMovementFlags; + Stat mSkill[27]; + + public: NpcStats(); DrawState getDrawState() const; void setDrawState (DrawState state); + + bool getMovementFlag (Flag flag) const; + + void setMovementFlag (Flag flag, bool state); + + const Stat& getSkill (int index) const; + + Stat& getSkill (int index); + + std::map& getFactionRanks(); + + const std::map& getFactionRanks() const; }; } diff --git a/apps/openmw/mwmechanics/spellsuccess.hpp b/apps/openmw/mwmechanics/spellsuccess.hpp index 54172a72a..42a7d5bba 100644 --- a/apps/openmw/mwmechanics/spellsuccess.hpp +++ b/apps/openmw/mwmechanics/spellsuccess.hpp @@ -41,7 +41,7 @@ namespace MWMechanics { const ESM::MagicEffect* effect = MWBase::Environment::get().getWorld()->getStore().magicEffects.find(it->effectID); int _school = effect->data.school; - int _skillLevel = stats.mSkill[spellSchoolToSkill(_school)].getModified(); + int _skillLevel = stats.getSkill (spellSchoolToSkill(_school)).getModified(); if (school == -1) { @@ -78,7 +78,7 @@ namespace MWMechanics NpcStats& stats = MWWorld::Class::get(actor).getNpcStats(actor); CreatureStats& creatureStats = MWWorld::Class::get(actor).getCreatureStats(actor); - int skillLevel = stats.mSkill[getSpellSchool(spellId, actor)].getModified(); + int skillLevel = stats.getSkill (getSpellSchool(spellId, actor)).getModified(); // Sound magic effect (reduces spell casting chance) int soundMagnitude = creatureStats.mMagicEffects.get (MWMechanics::EffectKey (48)).mMagnitude; diff --git a/apps/openmw/mwscript/controlextensions.cpp b/apps/openmw/mwscript/controlextensions.cpp index 1f5bdcafb..24d8bcf1e 100644 --- a/apps/openmw/mwscript/controlextensions.cpp +++ b/apps/openmw/mwscript/controlextensions.cpp @@ -59,54 +59,36 @@ namespace MWScript }; template - class OpClearForceRun : public Interpreter::Opcode0 + class OpClearMovementFlag : public Interpreter::Opcode0 { - public: - - virtual void execute (Interpreter::Runtime& runtime) - { - MWWorld::Ptr ptr = R()(runtime); + MWMechanics::NpcStats::Flag mFlag; - MWWorld::Class::get (ptr).getNpcStats (ptr).mForceRun = false; - } - }; - - template - class OpForceRun : public Interpreter::Opcode0 - { public: - virtual void execute (Interpreter::Runtime& runtime) - { - MWWorld::Ptr ptr = R()(runtime); - - MWWorld::Class::get (ptr).getNpcStats (ptr).mForceRun = true; - } - }; - - template - class OpClearForceSneak : public Interpreter::Opcode0 - { - public: + OpClearMovementFlag (MWMechanics::NpcStats::Flag flag) : mFlag (flag) {} virtual void execute (Interpreter::Runtime& runtime) { MWWorld::Ptr ptr = R()(runtime); - MWWorld::Class::get (ptr).getNpcStats (ptr).mForceSneak = false; + MWWorld::Class::get (ptr).getNpcStats (ptr).setMovementFlag (mFlag, false); } }; template - class OpForceSneak : public Interpreter::Opcode0 + class OpSetMovementFlag : public Interpreter::Opcode0 { + MWMechanics::NpcStats::Flag mFlag; + public: + OpSetMovementFlag (MWMechanics::NpcStats::Flag flag) : mFlag (flag) {} + virtual void execute (Interpreter::Runtime& runtime) { MWWorld::Ptr ptr = R()(runtime); - MWWorld::Class::get (ptr).getNpcStats (ptr).mForceSneak = true; + MWWorld::Class::get (ptr).getNpcStats (ptr).setMovementFlag (mFlag, true); } }; @@ -165,19 +147,23 @@ namespace MWScript interpreter.installSegment5 (opcodeToggleCollision, new OpToggleCollision); - interpreter.installSegment5 (opcodeClearForceRun, new OpClearForceRun); - interpreter.installSegment5 (opcodeForceRun, new OpForceRun); - interpreter.installSegment5 (opcodeClearForceSneak, new OpClearForceSneak); - interpreter.installSegment5 (opcodeForceSneak, new OpForceSneak); + interpreter.installSegment5 (opcodeClearForceRun, + new OpClearMovementFlag (MWMechanics::NpcStats::Flag_ForceRun)); + interpreter.installSegment5 (opcodeForceRun, + new OpSetMovementFlag (MWMechanics::NpcStats::Flag_ForceRun)); + interpreter.installSegment5 (opcodeClearForceSneak, + new OpClearMovementFlag (MWMechanics::NpcStats::Flag_ForceSneak)); + interpreter.installSegment5 (opcodeForceSneak, + new OpSetMovementFlag (MWMechanics::NpcStats::Flag_ForceSneak)); interpreter.installSegment5 (opcodeClearForceRunExplicit, - new OpClearForceRun); + new OpClearMovementFlag (MWMechanics::NpcStats::Flag_ForceRun)); interpreter.installSegment5 (opcodeForceRunExplicit, - new OpForceRun); + new OpSetMovementFlag (MWMechanics::NpcStats::Flag_ForceRun)); interpreter.installSegment5 (opcodeClearForceSneakExplicit, - new OpClearForceSneak); + new OpClearMovementFlag (MWMechanics::NpcStats::Flag_ForceSneak)); interpreter.installSegment5 (opcodeForceSneakExplicit, - new OpForceSneak); + new OpSetMovementFlag (MWMechanics::NpcStats::Flag_ForceSneak)); } } } diff --git a/apps/openmw/mwscript/statsextensions.cpp b/apps/openmw/mwscript/statsextensions.cpp index 15519b3a6..42781d766 100644 --- a/apps/openmw/mwscript/statsextensions.cpp +++ b/apps/openmw/mwscript/statsextensions.cpp @@ -237,7 +237,7 @@ namespace MWScript MWWorld::Ptr ptr = R()(runtime); Interpreter::Type_Integer value = - MWWorld::Class::get (ptr).getNpcStats (ptr).mSkill[mIndex]. + MWWorld::Class::get (ptr).getNpcStats (ptr).getSkill (mIndex). getModified(); runtime.push (value); @@ -260,7 +260,7 @@ namespace MWScript Interpreter::Type_Integer value = runtime[0].mInteger; runtime.pop(); - MWWorld::Class::get (ptr).getNpcStats (ptr).mSkill[mIndex]. + MWWorld::Class::get (ptr).getNpcStats (ptr).getSkill (mIndex). setModified (value, 0); } }; @@ -281,10 +281,10 @@ namespace MWScript Interpreter::Type_Integer value = runtime[0].mInteger; runtime.pop(); - value += MWWorld::Class::get (ptr).getNpcStats (ptr).mSkill[mIndex]. + value += MWWorld::Class::get (ptr).getNpcStats (ptr).getSkill (mIndex). getModified(); - MWWorld::Class::get (ptr).getNpcStats (ptr).mSkill[mIndex]. + MWWorld::Class::get (ptr).getNpcStats (ptr).getSkill (mIndex). setModified (value, 0, 100); } }; @@ -373,9 +373,9 @@ namespace MWScript if(factionID != "") { MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayer().getPlayer(); - if(MWWorld::Class::get(player).getNpcStats(player).mFactionRank.find(factionID) == MWWorld::Class::get(player).getNpcStats(player).mFactionRank.end()) + if(MWWorld::Class::get(player).getNpcStats(player).getFactionRanks().find(factionID) == MWWorld::Class::get(player).getNpcStats(player).getFactionRanks().end()) { - MWWorld::Class::get(player).getNpcStats(player).mFactionRank[factionID] = 0; + MWWorld::Class::get(player).getNpcStats(player).getFactionRanks()[factionID] = 0; } } } @@ -402,13 +402,13 @@ namespace MWScript if(factionID != "") { MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayer().getPlayer(); - if(MWWorld::Class::get(player).getNpcStats(player).mFactionRank.find(factionID) == MWWorld::Class::get(player).getNpcStats(player).mFactionRank.end()) + if(MWWorld::Class::get(player).getNpcStats(player).getFactionRanks().find(factionID) == MWWorld::Class::get(player).getNpcStats(player).getFactionRanks().end()) { - MWWorld::Class::get(player).getNpcStats(player).mFactionRank[factionID] = 0; + MWWorld::Class::get(player).getNpcStats(player).getFactionRanks()[factionID] = 0; } else { - MWWorld::Class::get(player).getNpcStats(player).mFactionRank[factionID] = MWWorld::Class::get(player).getNpcStats(player).mFactionRank[factionID] +1; + MWWorld::Class::get(player).getNpcStats(player).getFactionRanks()[factionID] = MWWorld::Class::get(player).getNpcStats(player).getFactionRanks()[factionID] +1; } } } @@ -435,9 +435,9 @@ namespace MWScript if(factionID != "") { MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayer().getPlayer(); - if(MWWorld::Class::get(player).getNpcStats(player).mFactionRank.find(factionID) != MWWorld::Class::get(player).getNpcStats(player).mFactionRank.end()) + if(MWWorld::Class::get(player).getNpcStats(player).getFactionRanks().find(factionID) != MWWorld::Class::get(player).getNpcStats(player).getFactionRanks().end()) { - MWWorld::Class::get(player).getNpcStats(player).mFactionRank[factionID] = MWWorld::Class::get(player).getNpcStats(player).mFactionRank[factionID] -1; + MWWorld::Class::get(player).getNpcStats(player).getFactionRanks()[factionID] = MWWorld::Class::get(player).getNpcStats(player).getFactionRanks()[factionID] -1; } } } @@ -460,22 +460,22 @@ namespace MWScript } else { - if(MWWorld::Class::get(ptr).getNpcStats(ptr).mFactionRank.empty()) + if(MWWorld::Class::get(ptr).getNpcStats(ptr).getFactionRanks().empty()) { //throw exception? } else { - factionID = MWWorld::Class::get(ptr).getNpcStats(ptr).mFactionRank.begin()->first; + factionID = MWWorld::Class::get(ptr).getNpcStats(ptr).getFactionRanks().begin()->first; } } boost::algorithm::to_lower(factionID); MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayer().getPlayer(); if(factionID!="") { - if(MWWorld::Class::get(player).getNpcStats(player).mFactionRank.find(factionID) != MWWorld::Class::get(player).getNpcStats(player).mFactionRank.end()) + if(MWWorld::Class::get(player).getNpcStats(player).getFactionRanks().find(factionID) != MWWorld::Class::get(player).getNpcStats(player).getFactionRanks().end()) { - runtime.push(MWWorld::Class::get(player).getNpcStats(player).mFactionRank[factionID]); + runtime.push(MWWorld::Class::get(player).getNpcStats(player).getFactionRanks()[factionID]); } else { diff --git a/apps/openmw/mwworld/inventorystore.cpp b/apps/openmw/mwworld/inventorystore.cpp index 9d99227ed..2fd702f6d 100644 --- a/apps/openmw/mwworld/inventorystore.cpp +++ b/apps/openmw/mwworld/inventorystore.cpp @@ -161,10 +161,10 @@ void MWWorld::InventoryStore::autoEquip (const MWMechanics::NpcStats& stats) if (testSkill!=-1 || oldSkill!=-1 || testSkill!=oldSkill) { - if (stats.mSkill[oldSkill].getModified()>stats.mSkill[testSkill].getModified()) + if (stats.getSkill (oldSkill).getModified()>stats.getSkill (testSkill).getModified()) continue; // rejected, because old item better matched the NPC's skills. - if (stats.mSkill[oldSkill].getModified() Date: Fri, 6 Jul 2012 18:25:16 +0200 Subject: [PATCH 05/32] Issue #324: Change a forward declartion to avoid potential problems with pesky MSVC --- apps/openmw/mwworld/class.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/openmw/mwworld/class.hpp b/apps/openmw/mwworld/class.hpp index fe7b5dc80..8f2d19b1c 100644 --- a/apps/openmw/mwworld/class.hpp +++ b/apps/openmw/mwworld/class.hpp @@ -22,7 +22,7 @@ namespace MWRender namespace MWMechanics { struct CreatureStats; - struct NpcStats; + class NpcStats; struct Movement; } From 0f41cc499dba44f07c8d92877f81f761ed8c824b Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Fri, 6 Jul 2012 21:07:04 +0200 Subject: [PATCH 06/32] Issue #324: Added skill gain calculation function --- apps/openmw/mwmechanics/npcstats.cpp | 68 ++++++++++++++++++++++++++++ apps/openmw/mwmechanics/npcstats.hpp | 11 +++++ 2 files changed, 79 insertions(+) diff --git a/apps/openmw/mwmechanics/npcstats.cpp b/apps/openmw/mwmechanics/npcstats.cpp index cdb977029..6c95c5372 100644 --- a/apps/openmw/mwmechanics/npcstats.cpp +++ b/apps/openmw/mwmechanics/npcstats.cpp @@ -3,6 +3,15 @@ #include +#include +#include +#include + +#include + +#include "../mwbase/environment.hpp" +#include "../mwbase/world.hpp" + MWMechanics::NpcStats::NpcStats() : mMovementFlags (0), mDrawState (DrawState_Nothing) {} @@ -55,3 +64,62 @@ const std::map& MWMechanics::NpcStats::getFactionRanks() const { return mFactionRank; } + +float MWMechanics::NpcStats::getSkillGain (int skillIndex, const ESM::Class& class_, int usageType, + int level) const +{ + if (level<0) + level = static_cast (getSkill (skillIndex).getBase()); + + const ESM::Skill *skill = MWBase::Environment::get().getWorld()->getStore().skills.find (skillIndex); + + float skillFactor = 1; + + if (usageType>=4) + throw std::runtime_error ("skill usage type out of range"); + + if (usageType>0) + { + skillFactor = skill->data.useValue[usageType]; + + if (skillFactor<=0) + throw std::runtime_error ("invalid skill gain factor"); + } + + float typeFactor = + MWBase::Environment::get().getWorld()->getStore().gameSettings.find ("fMiscSkillBonus")->f; + + for (int i=0; i<5; ++i) + if (class_.data.skills[i][0]==skillIndex) + { + typeFactor = + MWBase::Environment::get().getWorld()->getStore().gameSettings.find ("fMinorSkillBonus")->f; + + break; + } + + for (int i=0; i<5; ++i) + if (class_.data.skills[i][1]==skillIndex) + { + typeFactor = + MWBase::Environment::get().getWorld()->getStore().gameSettings.find ("fMajorSkillBonus")->f; + + break; + } + + if (typeFactor<=0) + throw std::runtime_error ("invalid skill type factor"); + + float specialisationFactor = 1; + + if (skill->data.specialization==class_.data.specialization) + { + specialisationFactor = + MWBase::Environment::get().getWorld()->getStore().gameSettings.find ("fSpecialSkillBonus")->f; + + if (specialisationFactor<=0) + throw std::runtime_error ("invalid skill specialisation factor"); + } + + return 1.0 / (level +1) * (1.0 / skillFactor) * typeFactor * specialisationFactor; +} diff --git a/apps/openmw/mwmechanics/npcstats.hpp b/apps/openmw/mwmechanics/npcstats.hpp index 16a777b71..026404272 100644 --- a/apps/openmw/mwmechanics/npcstats.hpp +++ b/apps/openmw/mwmechanics/npcstats.hpp @@ -8,6 +8,11 @@ #include "stat.hpp" #include "drawstate.hpp" +namespace ESM +{ + struct Class; +} + namespace MWMechanics { /// \brief Additional stats for NPCs @@ -59,6 +64,12 @@ namespace MWMechanics std::map& getFactionRanks(); const std::map& getFactionRanks() const; + + float getSkillGain (int skillIndex, const ESM::Class& class_, int usageType = -1, + int level = -1) const; + ///< \param usageType: Usage specific factor, specified in the respective skill record; + /// -1: use a factor of 1.0 instead. + /// \param level Level to base calculation on; -1: use current level. }; } From fe86ce5a2c263b72c85a592e2e8f47dfa613fc80 Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Sat, 7 Jul 2012 20:53:19 +0200 Subject: [PATCH 07/32] DrawState workaround --- apps/openmw/mwinput/inputmanager.cpp | 4 ++-- apps/openmw/mwmechanics/drawstate.hpp | 5 ++--- apps/openmw/mwmechanics/npcstats.cpp | 4 ++-- apps/openmw/mwmechanics/npcstats.hpp | 6 +++--- apps/openmw/mwworld/player.cpp | 4 ++-- apps/openmw/mwworld/player.hpp | 7 ++----- 6 files changed, 13 insertions(+), 17 deletions(-) diff --git a/apps/openmw/mwinput/inputmanager.cpp b/apps/openmw/mwinput/inputmanager.cpp index 73cadacd0..3a8315b71 100644 --- a/apps/openmw/mwinput/inputmanager.cpp +++ b/apps/openmw/mwinput/inputmanager.cpp @@ -102,7 +102,7 @@ private: { if (windows.isGuiMode()) return; - MWMechanics::DrawState state = player.getDrawState(); + MWMechanics::DrawState_ state = player.getDrawState(); if (state == MWMechanics::DrawState_Weapon || state == MWMechanics::DrawState_Nothing) { player.setDrawState(MWMechanics::DrawState_Spell); @@ -119,7 +119,7 @@ private: { if (windows.isGuiMode()) return; - MWMechanics::DrawState state = player.getDrawState(); + MWMechanics::DrawState_ state = player.getDrawState(); if (state == MWMechanics::DrawState_Spell || state == MWMechanics::DrawState_Nothing) { player.setDrawState(MWMechanics::DrawState_Weapon); diff --git a/apps/openmw/mwmechanics/drawstate.hpp b/apps/openmw/mwmechanics/drawstate.hpp index 94b48fdd8..112b6e4f9 100644 --- a/apps/openmw/mwmechanics/drawstate.hpp +++ b/apps/openmw/mwmechanics/drawstate.hpp @@ -1,11 +1,10 @@ #ifndef GAME_MWMECHANICS_DRAWSTATE_H #define GAME_MWMECHANICS_DRAWSTATE_H -#undef DrawState - namespace MWMechanics { - enum DrawState + /// \note The _ suffix is required to avoid a collision with a Windoze macro. Die, Microsoft! Die! + enum DrawState_ { DrawState_Weapon = 0, DrawState_Spell = 1, diff --git a/apps/openmw/mwmechanics/npcstats.cpp b/apps/openmw/mwmechanics/npcstats.cpp index 6c95c5372..08ac12374 100644 --- a/apps/openmw/mwmechanics/npcstats.cpp +++ b/apps/openmw/mwmechanics/npcstats.cpp @@ -16,12 +16,12 @@ MWMechanics::NpcStats::NpcStats() : mMovementFlags (0), mDrawState (DrawState_Nothing) {} -MWMechanics::DrawState MWMechanics::NpcStats::getDrawState() const +MWMechanics::DrawState_ MWMechanics::NpcStats::getDrawState() const { return mDrawState; } -void MWMechanics::NpcStats::setDrawState (DrawState state) +void MWMechanics::NpcStats::setDrawState (DrawState_ state) { mDrawState = state; } diff --git a/apps/openmw/mwmechanics/npcstats.hpp b/apps/openmw/mwmechanics/npcstats.hpp index 026404272..1dccdd0d6 100644 --- a/apps/openmw/mwmechanics/npcstats.hpp +++ b/apps/openmw/mwmechanics/npcstats.hpp @@ -41,7 +41,7 @@ namespace MWMechanics /// \note the faction key must be in lowercase std::map mFactionRank; - DrawState mDrawState; + DrawState_ mDrawState; unsigned int mMovementFlags; Stat mSkill[27]; @@ -49,9 +49,9 @@ namespace MWMechanics NpcStats(); - DrawState getDrawState() const; + DrawState_ getDrawState() const; - void setDrawState (DrawState state); + void setDrawState (DrawState_ state); bool getMovementFlag (Flag flag) const; diff --git a/apps/openmw/mwworld/player.cpp b/apps/openmw/mwworld/player.cpp index d8b3285ef..4d508c3e9 100644 --- a/apps/openmw/mwworld/player.cpp +++ b/apps/openmw/mwworld/player.cpp @@ -56,7 +56,7 @@ namespace MWWorld mClass = new_class; } - void Player::setDrawState (MWMechanics::DrawState state) + void Player::setDrawState (MWMechanics::DrawState_ state) { MWWorld::Ptr ptr = getPlayer(); MWWorld::Class::get(ptr).getNpcStats(ptr).setDrawState (state); @@ -111,7 +111,7 @@ namespace MWWorld MWWorld::Class::get (ptr).setStance (ptr, MWWorld::Class::Run, !running); } - MWMechanics::DrawState Player::getDrawState() + MWMechanics::DrawState_ Player::getDrawState() { MWWorld::Ptr ptr = getPlayer(); return MWWorld::Class::get(ptr).getNpcStats(ptr).getDrawState(); diff --git a/apps/openmw/mwworld/player.hpp b/apps/openmw/mwworld/player.hpp index 2a02635b4..ee7c030a5 100644 --- a/apps/openmw/mwworld/player.hpp +++ b/apps/openmw/mwworld/player.hpp @@ -9,9 +9,6 @@ #include "../mwmechanics/drawstate.hpp" -#undef DrawState // How did this get defined again? - // Maybe it's defined by default in every file for windows? - namespace MWBase { class World; @@ -86,7 +83,7 @@ namespace MWWorld void setClass (const ESM::Class& class_); - void setDrawState (MWMechanics::DrawState state); + void setDrawState (MWMechanics::DrawState_ state); std::string getName() const { @@ -118,7 +115,7 @@ namespace MWWorld return mAutoMove; } - MWMechanics::DrawState getDrawState(); /// \todo constness + MWMechanics::DrawState_ getDrawState(); /// \todo constness void setAutoMove (bool enable); From 25a5657d80b09c6a878a8cd7f92c57181ce15ebb Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Mon, 9 Jul 2012 18:26:00 +0200 Subject: [PATCH 08/32] Issue #324: Modified the interface for modified stats --- apps/openmw/mwmechanics/stat.hpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/apps/openmw/mwmechanics/stat.hpp b/apps/openmw/mwmechanics/stat.hpp index 2449075a8..996036fc1 100644 --- a/apps/openmw/mwmechanics/stat.hpp +++ b/apps/openmw/mwmechanics/stat.hpp @@ -31,6 +31,11 @@ namespace MWMechanics return mModified; } + T getModifier() const + { + return mModified-mBase; + } + /// Set base and modified to \a value. void set (const T& value) { @@ -65,10 +70,9 @@ namespace MWMechanics mBase += diff; } - /// Change modified relatively. - void modify (const T& diff) + void setModifier (const T& modifier) { - mModified += diff; + mModified = mBase + modifier; } }; From 67c1c5ce1811271a15d93b8e0be906432cfe8a06 Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Mon, 9 Jul 2012 20:42:45 +0200 Subject: [PATCH 09/32] Issue #324: adjusted setSkill script instructions according to the recent research --- apps/openmw/mwscript/statsextensions.cpp | 30 ++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/apps/openmw/mwscript/statsextensions.cpp b/apps/openmw/mwscript/statsextensions.cpp index 42781d766..c720e2c6a 100644 --- a/apps/openmw/mwscript/statsextensions.cpp +++ b/apps/openmw/mwscript/statsextensions.cpp @@ -1,8 +1,12 @@ #include "statsextensions.hpp" +#include + #include +#include + #include #include @@ -260,8 +264,30 @@ namespace MWScript Interpreter::Type_Integer value = runtime[0].mInteger; runtime.pop(); - MWWorld::Class::get (ptr).getNpcStats (ptr).getSkill (mIndex). - setModified (value, 0); + MWMechanics::NpcStats& stats = MWWorld::Class::get (ptr).getNpcStats (ptr); + + MWWorld::LiveCellRef *ref = ptr.get(); + + assert (ref); + + const ESM::Class& class_ = + *MWBase::Environment::get().getWorld()->getStore().classes.find (ref->base->cls); + + float level = 0; + float progress = std::modf (stats.getSkill (mIndex).getBase(), &level); + + float modifier = stats.getSkill (mIndex).getModifier(); + + int newLevel = static_cast (value-modifier); + + progress = (progress / stats.getSkillGain (mIndex, class_, -1, level)) + * stats.getSkillGain (mIndex, class_, -1, newLevel); + + if (progress>=1) + progress = 0.999999999; + + stats.getSkill (mIndex).set (newLevel + progress); + stats.getSkill (mIndex).setModifier (modifier); } }; From a207c86fd14a69fd2ee8d7ba17278aa7127df96c Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Mon, 9 Jul 2012 21:14:11 +0200 Subject: [PATCH 10/32] Issue #324: added some range checks --- apps/openmw/mwscript/statsextensions.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/apps/openmw/mwscript/statsextensions.cpp b/apps/openmw/mwscript/statsextensions.cpp index c720e2c6a..33f086c6f 100644 --- a/apps/openmw/mwscript/statsextensions.cpp +++ b/apps/openmw/mwscript/statsextensions.cpp @@ -280,6 +280,11 @@ namespace MWScript int newLevel = static_cast (value-modifier); + if (newLevel<0) + newLevel = 0; + else if (newLevel>100) + newLevel = 100; + progress = (progress / stats.getSkillGain (mIndex, class_, -1, level)) * stats.getSkillGain (mIndex, class_, -1, newLevel); From 0d8150f4bd8782304c1ca297dd14633a4fe8627a Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Mon, 9 Jul 2012 21:15:52 +0200 Subject: [PATCH 11/32] Issue #324: added useSkill function to NpcStats (adjust skill level according to use) --- apps/openmw/mwmechanics/npcstats.cpp | 15 +++++++++++++++ apps/openmw/mwmechanics/npcstats.hpp | 3 +++ 2 files changed, 18 insertions(+) diff --git a/apps/openmw/mwmechanics/npcstats.cpp b/apps/openmw/mwmechanics/npcstats.cpp index 08ac12374..d2908e26e 100644 --- a/apps/openmw/mwmechanics/npcstats.cpp +++ b/apps/openmw/mwmechanics/npcstats.cpp @@ -1,6 +1,7 @@ #include "npcstats.hpp" +#include #include #include @@ -123,3 +124,17 @@ float MWMechanics::NpcStats::getSkillGain (int skillIndex, const ESM::Class& cla return 1.0 / (level +1) * (1.0 / skillFactor) * typeFactor * specialisationFactor; } + +void MWMechanics::NpcStats::useSkill (int skillIndex, const ESM::Class& class_, int usageType) +{ + float base = getSkill (skillIndex).getBase(); + + int level = static_cast (base); + + base += getSkillGain (skillIndex, class_, usageType); + + if (static_cast (base)!=level) + base = level+1; + + getSkill (skillIndex).setBase (base); +} diff --git a/apps/openmw/mwmechanics/npcstats.hpp b/apps/openmw/mwmechanics/npcstats.hpp index 1dccdd0d6..364dab03f 100644 --- a/apps/openmw/mwmechanics/npcstats.hpp +++ b/apps/openmw/mwmechanics/npcstats.hpp @@ -70,6 +70,9 @@ namespace MWMechanics ///< \param usageType: Usage specific factor, specified in the respective skill record; /// -1: use a factor of 1.0 instead. /// \param level Level to base calculation on; -1: use current level. + + void useSkill (int skillIndex, const ESM::Class& class_, int usageType = -1); + ///< Increase skill by usage. }; } From 7a2d61304310abbdf081c34c12a300dffbf316bb Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Fri, 13 Jul 2012 08:50:46 +0200 Subject: [PATCH 12/32] Issue #314: extended Class::apply function to cover the actor --- apps/openmw/mwworld/class.cpp | 2 +- apps/openmw/mwworld/class.hpp | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/apps/openmw/mwworld/class.cpp b/apps/openmw/mwworld/class.cpp index f51aa401c..2ae6cb695 100644 --- a/apps/openmw/mwworld/class.cpp +++ b/apps/openmw/mwworld/class.cpp @@ -34,7 +34,7 @@ namespace MWWorld } - bool Class::apply (const MWWorld::Ptr& ptr, const std::string& id) const + bool Class::apply (const MWWorld::Ptr& ptr, const std::string& id, const MWWorld::Ptr& actor) const { return false; } diff --git a/apps/openmw/mwworld/class.hpp b/apps/openmw/mwworld/class.hpp index 1a3113f7c..968ae7917 100644 --- a/apps/openmw/mwworld/class.hpp +++ b/apps/openmw/mwworld/class.hpp @@ -165,8 +165,10 @@ namespace MWWorld /// effects). Throws an exception, if the object can't hold other objects. /// (default implementation: throws an exception) - virtual bool apply (const MWWorld::Ptr& ptr, const std::string& id) const; + virtual bool apply (const MWWorld::Ptr& ptr, const std::string& id, + const MWWorld::Ptr& actor) const; ///< Apply \a id on \a ptr. + /// \param actor Actor that is resposible for the ID being applied to \a ptr. /// \return Any effect? /// /// (default implementation: ignore and return false) From 805b81bf6e61b65f096d7a127538fa46e384ef6a Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Fri, 13 Jul 2012 09:03:17 +0200 Subject: [PATCH 13/32] Issue #314: added skillUsageSucceeded function to Class --- apps/openmw/mwworld/class.cpp | 5 +++++ apps/openmw/mwworld/class.hpp | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/apps/openmw/mwworld/class.cpp b/apps/openmw/mwworld/class.cpp index 2ae6cb695..356eef9a9 100644 --- a/apps/openmw/mwworld/class.cpp +++ b/apps/openmw/mwworld/class.cpp @@ -39,6 +39,11 @@ namespace MWWorld return false; } + void Class::skillUsageSucceeded (const MWWorld::Ptr& ptr, int skill, int usageType) const + { + throw std::runtime_error ("class does not represent an actor"); + } + MWMechanics::CreatureStats& Class::getCreatureStats (const Ptr& ptr) const { throw std::runtime_error ("class does not have creature stats"); diff --git a/apps/openmw/mwworld/class.hpp b/apps/openmw/mwworld/class.hpp index 968ae7917..352c7bda1 100644 --- a/apps/openmw/mwworld/class.hpp +++ b/apps/openmw/mwworld/class.hpp @@ -173,6 +173,11 @@ namespace MWWorld /// /// (default implementation: ignore and return false) + virtual void skillUsageSucceeded (const MWWorld::Ptr& ptr, int skill, int usageType) const; + ///< Inform actor \a ptr that a skill use has succeeded. + /// + /// (default implementations: throws an exception) + static const Class& get (const std::string& key); ///< If there is no class for this \a key, an exception is thrown. From 84d846cf07c75dc13f3fdf488a1d4dee87ee4865 Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Fri, 13 Jul 2012 09:16:27 +0200 Subject: [PATCH 14/32] Issue #314: implemented apply and skillUsageSucceeded functions for MWClass::Npc --- apps/openmw/mwclass/npc.cpp | 22 ++++++++++++++++++++++ apps/openmw/mwclass/npc.hpp | 9 +++++++++ 2 files changed, 31 insertions(+) diff --git a/apps/openmw/mwclass/npc.cpp b/apps/openmw/mwclass/npc.cpp index d54b9441d..2570408f7 100644 --- a/apps/openmw/mwclass/npc.cpp +++ b/apps/openmw/mwclass/npc.cpp @@ -343,4 +343,26 @@ namespace MWClass return weight; } + + bool Npc::apply (const MWWorld::Ptr& ptr, const std::string& id, + const MWWorld::Ptr& actor) const + { + MWMechanics::CreatureStats& stats = getCreatureStats (ptr); + + /// \todo consider instant effects + + return stats.mActiveSpells.addSpell (id); + } + + void Npc::skillUsageSucceeded (const MWWorld::Ptr& ptr, int skill, int usageType) const + { + MWMechanics::NpcStats& stats = getNpcStats (ptr); + + MWWorld::LiveCellRef *ref = ptr.get(); + + const ESM::Class *class_ = MWBase::Environment::get().getWorld()->getStore().classes.find ( + ref->base->cls); + + stats.useSkill (skill, *class_, usageType); + } } diff --git a/apps/openmw/mwclass/npc.hpp b/apps/openmw/mwclass/npc.hpp index 4cb733977..74a80c085 100644 --- a/apps/openmw/mwclass/npc.hpp +++ b/apps/openmw/mwclass/npc.hpp @@ -76,6 +76,15 @@ namespace MWClass ///< Returns total weight of objects inside this object (including modifications from magic /// effects). Throws an exception, if the object can't hold other objects. + virtual bool apply (const MWWorld::Ptr& ptr, const std::string& id, + const MWWorld::Ptr& actor) const; + ///< Apply \a id on \a ptr. + /// \param actor Actor that is resposible for the ID being applied to \a ptr. + /// \return Any effect? + + virtual void skillUsageSucceeded (const MWWorld::Ptr& ptr, int skill, int usageType) const; + ///< Inform actor \a ptr that a skill use has succeeded. + static void registerSelf(); }; } From 29b4a5e5f7e1611b7854d06a7c205a7615e06e20 Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Fri, 13 Jul 2012 09:41:38 +0200 Subject: [PATCH 15/32] Issue #314: added apply actions --- apps/openmw/CMakeLists.txt | 2 +- apps/openmw/mwworld/actionapply.cpp | 28 +++++++++++++++++++ apps/openmw/mwworld/actionapply.hpp | 42 +++++++++++++++++++++++++++++ 3 files changed, 71 insertions(+), 1 deletion(-) create mode 100644 apps/openmw/mwworld/actionapply.cpp create mode 100644 apps/openmw/mwworld/actionapply.hpp diff --git a/apps/openmw/CMakeLists.txt b/apps/openmw/CMakeLists.txt index 36e59f6bd..bb3f76f3c 100644 --- a/apps/openmw/CMakeLists.txt +++ b/apps/openmw/CMakeLists.txt @@ -50,7 +50,7 @@ add_openmw_dir (mwworld refdata worldimp physicssystem scene globals class action nullaction actionteleport containerstore actiontalk actiontake manualref player cellfunctors cells localscripts customdata weather inventorystore ptr actionopen actionread - actionequip timestamp actionalchemy cellstore + actionequip timestamp actionalchemy cellstore actionapply ) add_openmw_dir (mwclass diff --git a/apps/openmw/mwworld/actionapply.cpp b/apps/openmw/mwworld/actionapply.cpp new file mode 100644 index 000000000..c5228d798 --- /dev/null +++ b/apps/openmw/mwworld/actionapply.cpp @@ -0,0 +1,28 @@ + +#include "actionapply.hpp" + +#include "class.hpp" + +namespace MWWorld +{ + ActionApply::ActionApply (const Ptr& target, const std::string& id, const Ptr& actor) + : mTarget (target), mId (id), mActor (actor) + {} + + void ActionApply::execute() + { + MWWorld::Class::get (mTarget).apply (mTarget, mId, mActor); + } + + + ActionApplyWithSkill::ActionApplyWithSkill (const Ptr& target, const std::string& id, + const Ptr& actor, int skillIndex, int usageType) + : mTarget (target), mId (id), mActor (actor), mSkillIndex (skillIndex), mUsageType (usageType) + {} + + void ActionApplyWithSkill::execute() + { + if (MWWorld::Class::get (mTarget).apply (mTarget, mId, mActor)) + MWWorld::Class::get (mTarget).skillUsageSucceeded (mActor, mSkillIndex, mUsageType); + } +} diff --git a/apps/openmw/mwworld/actionapply.hpp b/apps/openmw/mwworld/actionapply.hpp new file mode 100644 index 000000000..972417e02 --- /dev/null +++ b/apps/openmw/mwworld/actionapply.hpp @@ -0,0 +1,42 @@ + +#ifndef GAME_MWWORLD_ACTIONAPPLY_H +#define GAME_MWWORLD_ACTIONAPPLY_H + +#include + +#include "action.hpp" +#include "ptr.hpp" + +namespace MWWorld +{ + class ActionApply : public Action + { + Ptr mTarget; + std::string mId; + Ptr mActor; + + public: + + ActionApply (const Ptr& target, const std::string& id, const Ptr& actor); + + virtual void execute(); + }; + + class ActionApplyWithSkill : public Action + { + Ptr mTarget; + std::string mId; + Ptr mActor; + int mSkillIndex; + int mUsageType; + + public: + + ActionApplyWithSkill (const Ptr& target, const std::string& id, const Ptr& actor, + int skillIndex, int usageType); + + virtual void execute(); + }; +} + +#endif From e4d046f69c79145d7ce46173184065a5877f12d2 Mon Sep 17 00:00:00 2001 From: Carl Maxwell Date: Fri, 13 Jul 2012 03:51:58 -0700 Subject: [PATCH 16/32] Prepending m to the name of every member variable. I made a bunch of changes in apps/openmw/mwrender/animation.cpp because the scope brackets didn't line up in a bunch of places npcanimations.cpp & creatureanimations.cpp were the same kind of thing --- apps/openmw/mwclass/misc.hpp | 2 +- apps/openmw/mwclass/npc.hpp | 2 +- apps/openmw/mwclass/potion.hpp | 2 +- apps/openmw/mwclass/static.hpp | 2 +- apps/openmw/mwdialogue/dialoguemanager.cpp | 18 +- apps/openmw/mwdialogue/dialoguemanager.hpp | 4 +- apps/openmw/mwgui/birth.cpp | 60 +- apps/openmw/mwgui/birth.hpp | 12 +- apps/openmw/mwgui/class.cpp | 466 ++++---- apps/openmw/mwgui/class.hpp | 98 +- apps/openmw/mwgui/dialogue.cpp | 80 +- apps/openmw/mwgui/dialogue.hpp | 8 +- apps/openmw/mwgui/hud.cpp | 172 +-- apps/openmw/mwgui/hud.hpp | 20 +- apps/openmw/mwgui/journalwindow.cpp | 24 +- apps/openmw/mwgui/journalwindow.hpp | 12 +- apps/openmw/mwgui/messagebox.cpp | 4 +- apps/openmw/mwgui/messagebox.hpp | 2 +- apps/openmw/mwgui/race.cpp | 100 +- apps/openmw/mwgui/race.hpp | 26 +- apps/openmw/mwgui/review.cpp | 188 +-- apps/openmw/mwgui/review.hpp | 26 +- apps/openmw/mwgui/stats_window.cpp | 200 ++-- apps/openmw/mwgui/stats_window.hpp | 26 +- apps/openmw/mwgui/text_input.cpp | 8 +- apps/openmw/mwgui/text_input.hpp | 6 +- apps/openmw/mwgui/widgets.cpp | 166 +-- apps/openmw/mwgui/widgets.hpp | 66 +- apps/openmw/mwgui/window_manager.cpp | 206 ++-- apps/openmw/mwgui/window_manager.hpp | 52 +- apps/openmw/mwrender/animation.cpp | 751 ++++++------ apps/openmw/mwrender/animation.hpp | 45 +- apps/openmw/mwrender/creatureanimation.cpp | 81 +- apps/openmw/mwrender/creatureanimation.hpp | 3 +- apps/openmw/mwrender/npcanimation.cpp | 1227 +++++++++++--------- apps/openmw/mwrender/npcanimation.hpp | 101 +- 36 files changed, 2163 insertions(+), 2103 deletions(-) diff --git a/apps/openmw/mwclass/misc.hpp b/apps/openmw/mwclass/misc.hpp index 46b5b9662..da5f0df96 100644 --- a/apps/openmw/mwclass/misc.hpp +++ b/apps/openmw/mwclass/misc.hpp @@ -9,7 +9,7 @@ namespace MWClass { public: - virtual void insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const; + virtual void insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const; ///< Add reference into a cell for rendering virtual void insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const; diff --git a/apps/openmw/mwclass/npc.hpp b/apps/openmw/mwclass/npc.hpp index 4cb733977..dcb9eaee0 100644 --- a/apps/openmw/mwclass/npc.hpp +++ b/apps/openmw/mwclass/npc.hpp @@ -48,7 +48,7 @@ namespace MWClass virtual std::string getScript (const MWWorld::Ptr& ptr) const; ///< Return name of the script attached to ptr - virtual void setForceStance (const MWWorld::Ptr& ptr, Stance stance, bool force) const; + virtual void setForceStance (const MWWorld::Ptr& ptr, Stance stance, bool force) const; ///< Force or unforce a stance. virtual void setStance (const MWWorld::Ptr& ptr, Stance stance, bool set) const; diff --git a/apps/openmw/mwclass/potion.hpp b/apps/openmw/mwclass/potion.hpp index 74779864a..97a4ab80a 100644 --- a/apps/openmw/mwclass/potion.hpp +++ b/apps/openmw/mwclass/potion.hpp @@ -9,7 +9,7 @@ namespace MWClass { public: - virtual void insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const; + virtual void insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const; ///< Add reference into a cell for rendering virtual void insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const; diff --git a/apps/openmw/mwclass/static.hpp b/apps/openmw/mwclass/static.hpp index cd1626c19..c223df1ac 100644 --- a/apps/openmw/mwclass/static.hpp +++ b/apps/openmw/mwclass/static.hpp @@ -9,7 +9,7 @@ namespace MWClass { public: - virtual void insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const; + virtual void insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const; ///< Add reference into a cell for rendering virtual void insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const; diff --git a/apps/openmw/mwdialogue/dialoguemanager.cpp b/apps/openmw/mwdialogue/dialoguemanager.cpp index 41ffd1e93..f6a17baa5 100644 --- a/apps/openmw/mwdialogue/dialoguemanager.cpp +++ b/apps/openmw/mwdialogue/dialoguemanager.cpp @@ -591,7 +591,7 @@ namespace MWDialogue mIsInChoice = false; mCompilerContext.setExtensions (&extensions); mDialogueMap.clear(); - actorKnownTopics.clear(); + mActorKnownTopics.clear(); ESMS::RecListCaseT::MapType dialogueList = MWBase::Environment::get().getWorld()->getStore().dialogs.list; for(ESMS::RecListCaseT::MapType::iterator it = dialogueList.begin(); it!=dialogueList.end();it++) { @@ -601,24 +601,24 @@ namespace MWDialogue void DialogueManager::addTopic(std::string topic) { - knownTopics[toLower(topic)] = true; + mKnownTopics[toLower(topic)] = true; } void DialogueManager::parseText(std::string text) { std::list::iterator it; - for(it = actorKnownTopics.begin();it != actorKnownTopics.end();++it) + for(it = mActorKnownTopics.begin();it != mActorKnownTopics.end();++it) { size_t pos = find_str_ci(text,*it,0); if(pos !=std::string::npos) { if(pos==0) { - knownTopics[*it] = true; + mKnownTopics[*it] = true; } else if(text.substr(pos -1,1) == " ") { - knownTopics[*it] = true; + mKnownTopics[*it] = true; } } } @@ -632,7 +632,7 @@ namespace MWDialogue mActor = actor; - actorKnownTopics.clear(); + mActorKnownTopics.clear(); //initialise the GUI MWBase::Environment::get().getWindowManager()->pushGuiMode(MWGui::GM_Dialogue); @@ -742,7 +742,7 @@ namespace MWDialogue std::list keywordList; int choice = mChoice; mChoice = -1; - actorKnownTopics.clear(); + mActorKnownTopics.clear(); MWGui::DialogueWindow* win = MWBase::Environment::get().getWindowManager()->getDialogueWindow(); ESMS::RecListCaseT::MapType dialogueList = MWBase::Environment::get().getWorld()->getStore().dialogs.list; for(ESMS::RecListCaseT::MapType::iterator it = dialogueList.begin(); it!=dialogueList.end();it++) @@ -755,9 +755,9 @@ namespace MWDialogue { if (isMatching (mActor, *iter) && functionFilter(mActor,*iter,true)) { - actorKnownTopics.push_back(toLower(it->first)); + mActorKnownTopics.push_back(toLower(it->first)); //does the player know the topic? - if(knownTopics.find(toLower(it->first)) != knownTopics.end()) + if(mKnownTopics.find(toLower(it->first)) != mKnownTopics.end()) { keywordList.push_back(it->first); break; diff --git a/apps/openmw/mwdialogue/dialoguemanager.hpp b/apps/openmw/mwdialogue/dialoguemanager.hpp index 992175c0c..d139ddc01 100644 --- a/apps/openmw/mwdialogue/dialoguemanager.hpp +++ b/apps/openmw/mwdialogue/dialoguemanager.hpp @@ -26,8 +26,8 @@ namespace MWDialogue void updateTopics(); std::map mDialogueMap; - std::map knownTopics;// Those are the topics the player knows. - std::list actorKnownTopics; + std::map mKnownTopics;// Those are the topics the player knows. + std::list mActorKnownTopics; MWScript::CompilerContext mCompilerContext; std::ostream mErrorStream; diff --git a/apps/openmw/mwgui/birth.cpp b/apps/openmw/mwgui/birth.cpp index 69056759d..0f1a04c27 100644 --- a/apps/openmw/mwgui/birth.cpp +++ b/apps/openmw/mwgui/birth.cpp @@ -15,15 +15,15 @@ BirthDialog::BirthDialog(WindowManager& parWindowManager) // Centre dialog center(); - getWidget(spellArea, "SpellArea"); + getWidget(mSpellArea, "SpellArea"); - getWidget(birthImage, "BirthsignImage"); + getWidget(mBirthImage, "BirthsignImage"); - getWidget(birthList, "BirthsignList"); - birthList->setScrollVisible(true); - birthList->eventListSelectAccept += MyGUI::newDelegate(this, &BirthDialog::onSelectBirth); - birthList->eventListMouseItemActivate += MyGUI::newDelegate(this, &BirthDialog::onSelectBirth); - birthList->eventListChangePosition += MyGUI::newDelegate(this, &BirthDialog::onSelectBirth); + getWidget(mBirthList, "BirthsignList"); + mBirthList->setScrollVisible(true); + mBirthList->eventListSelectAccept += MyGUI::newDelegate(this, &BirthDialog::onSelectBirth); + mBirthList->eventListMouseItemActivate += MyGUI::newDelegate(this, &BirthDialog::onSelectBirth); + mBirthList->eventListChangePosition += MyGUI::newDelegate(this, &BirthDialog::onSelectBirth); MyGUI::ButtonPtr backButton; getWidget(backButton, "BackButton"); @@ -68,14 +68,14 @@ void BirthDialog::open() void BirthDialog::setBirthId(const std::string &birthId) { - currentBirthId = birthId; - birthList->setIndexSelected(MyGUI::ITEM_NONE); - size_t count = birthList->getItemCount(); + mCurrentBirthId = birthId; + mBirthList->setIndexSelected(MyGUI::ITEM_NONE); + size_t count = mBirthList->getItemCount(); for (size_t i = 0; i < count; ++i) { - if (boost::iequals(*birthList->getItemDataAt(i), birthId)) + if (boost::iequals(*mBirthList->getItemDataAt(i), birthId)) { - birthList->setIndexSelected(i); + mBirthList->setIndexSelected(i); break; } } @@ -100,11 +100,11 @@ void BirthDialog::onSelectBirth(MyGUI::ListBox* _sender, size_t _index) if (_index == MyGUI::ITEM_NONE) return; - const std::string *birthId = birthList->getItemDataAt(_index); - if (boost::iequals(currentBirthId, *birthId)) + const std::string *birthId = mBirthList->getItemDataAt(_index); + if (boost::iequals(mCurrentBirthId, *birthId)) return; - currentBirthId = *birthId; + mCurrentBirthId = *birthId; updateSpells(); } @@ -112,7 +112,7 @@ void BirthDialog::onSelectBirth(MyGUI::ListBox* _sender, size_t _index) void BirthDialog::updateBirths() { - birthList->removeAllItems(); + mBirthList->removeAllItems(); const ESMS::ESMStore &store = mWindowManager.getStore(); @@ -122,34 +122,34 @@ void BirthDialog::updateBirths() for (; it != end; ++it) { const ESM::BirthSign &birth = it->second; - birthList->addItem(birth.name, it->first); - if (boost::iequals(it->first, currentBirthId)) - birthList->setIndexSelected(index); + mBirthList->addItem(birth.name, it->first); + if (boost::iequals(it->first, mCurrentBirthId)) + mBirthList->setIndexSelected(index); ++index; } } void BirthDialog::updateSpells() { - for (std::vector::iterator it = spellItems.begin(); it != spellItems.end(); ++it) + for (std::vector::iterator it = mSpellItems.begin(); it != mSpellItems.end(); ++it) { MyGUI::Gui::getInstance().destroyWidget(*it); } - spellItems.clear(); + mSpellItems.clear(); - if (currentBirthId.empty()) + if (mCurrentBirthId.empty()) return; MWSpellPtr spellWidget; const int lineHeight = 18; - MyGUI::IntCoord coord(0, 0, spellArea->getWidth(), 18); + MyGUI::IntCoord coord(0, 0, mSpellArea->getWidth(), 18); const ESMS::ESMStore &store = mWindowManager.getStore(); - const ESM::BirthSign *birth = store.birthSigns.find(currentBirthId); + const ESM::BirthSign *birth = store.birthSigns.find(mCurrentBirthId); std::string texturePath = std::string("textures\\") + birth->texture; fixTexturePath(texturePath); - birthImage->setImageTexture(texturePath); + mBirthImage->setImageTexture(texturePath); std::vector abilities, powers, spells; @@ -183,25 +183,25 @@ void BirthDialog::updateSpells() { if (!categories[category].spells.empty()) { - MyGUI::TextBox* label = spellArea->createWidget("SandBrightText", coord, MyGUI::Align::Default, std::string("Label")); + MyGUI::TextBox* label = mSpellArea->createWidget("SandBrightText", coord, MyGUI::Align::Default, std::string("Label")); label->setCaption(mWindowManager.getGameSettingString(categories[category].label, "")); - spellItems.push_back(label); + mSpellItems.push_back(label); coord.top += lineHeight; std::vector::const_iterator end = categories[category].spells.end(); for (std::vector::const_iterator it = categories[category].spells.begin(); it != end; ++it) { const std::string &spellId = *it; - spellWidget = spellArea->createWidget("MW_StatName", coord, MyGUI::Align::Default, std::string("Spell") + boost::lexical_cast(i)); + spellWidget = mSpellArea->createWidget("MW_StatName", coord, MyGUI::Align::Default, std::string("Spell") + boost::lexical_cast(i)); spellWidget->setWindowManager(&mWindowManager); spellWidget->setSpellId(spellId); - spellItems.push_back(spellWidget); + mSpellItems.push_back(spellWidget); coord.top += lineHeight; MyGUI::IntCoord spellCoord = coord; spellCoord.height = 24; // TODO: This should be fetched from the skin somehow, or perhaps a widget in the layout as a template? - spellWidget->createEffectWidgets(spellItems, spellArea, spellCoord, (category == 0) ? MWEffectList::EF_Constant : 0); + spellWidget->createEffectWidgets(mSpellItems, mSpellArea, spellCoord, (category == 0) ? MWEffectList::EF_Constant : 0); coord.top = spellCoord.top; ++i; diff --git a/apps/openmw/mwgui/birth.hpp b/apps/openmw/mwgui/birth.hpp index e61be736a..770e4ba36 100644 --- a/apps/openmw/mwgui/birth.hpp +++ b/apps/openmw/mwgui/birth.hpp @@ -25,7 +25,7 @@ namespace MWGui GM_Female }; - const std::string &getBirthId() const { return currentBirthId; } + const std::string &getBirthId() const { return mCurrentBirthId; } void setBirthId(const std::string &raceId); void setNextButtonShow(bool shown); @@ -49,12 +49,12 @@ namespace MWGui void updateBirths(); void updateSpells(); - MyGUI::ListBox* birthList; - MyGUI::WidgetPtr spellArea; - MyGUI::ImageBox* birthImage; - std::vector spellItems; + MyGUI::ListBox* mBirthList; + MyGUI::WidgetPtr mSpellArea; + MyGUI::ImageBox* mBirthImage; + std::vector mSpellItems; - std::string currentBirthId; + std::string mCurrentBirthId; }; } #endif diff --git a/apps/openmw/mwgui/class.cpp b/apps/openmw/mwgui/class.cpp index d0f21f945..8ec1331ad 100644 --- a/apps/openmw/mwgui/class.cpp +++ b/apps/openmw/mwgui/class.cpp @@ -26,8 +26,8 @@ GenerateClassResultDialog::GenerateClassResultDialog(WindowManager& parWindowMan setText("ReflectT", mWindowManager.getGameSettingString("sMessageQuestionAnswer1", "")); - getWidget(classImage, "ClassImage"); - getWidget(className, "ClassName"); + getWidget(mClassImage, "ClassImage"); + getWidget(mClassName, "ClassName"); MyGUI::ButtonPtr backButton; getWidget(backButton, "BackButton"); @@ -51,15 +51,15 @@ void GenerateClassResultDialog::open() std::string GenerateClassResultDialog::getClassId() const { - return className->getCaption(); + return mClassName->getCaption(); } void GenerateClassResultDialog::setClassId(const std::string &classId) { - currentClassId = classId; - classImage->setImageTexture(std::string("textures\\levelup\\") + currentClassId + ".dds"); + mCurrentClassId = classId; + mClassImage->setImageTexture(std::string("textures\\levelup\\") + mCurrentClassId + ".dds"); const ESMS::ESMStore &store = mWindowManager.getStore(); - className->setCaption(store.classes.find(currentClassId)->name); + mClassName->setCaption(store.classes.find(mCurrentClassId)->name); } // widget controls @@ -82,29 +82,29 @@ PickClassDialog::PickClassDialog(WindowManager& parWindowManager) // Centre dialog center(); - getWidget(specializationName, "SpecializationName"); + getWidget(mSpecializationName, "SpecializationName"); - getWidget(favoriteAttribute[0], "FavoriteAttribute0"); - getWidget(favoriteAttribute[1], "FavoriteAttribute1"); - favoriteAttribute[0]->setWindowManager(&mWindowManager); - favoriteAttribute[1]->setWindowManager(&mWindowManager); + getWidget(mFavoriteAttribute[0], "FavoriteAttribute0"); + getWidget(mFavoriteAttribute[1], "FavoriteAttribute1"); + mFavoriteAttribute[0]->setWindowManager(&mWindowManager); + mFavoriteAttribute[1]->setWindowManager(&mWindowManager); for(int i = 0; i < 5; i++) { char theIndex = '0'+i; - getWidget(majorSkill[i], std::string("MajorSkill").append(1, theIndex)); - getWidget(minorSkill[i], std::string("MinorSkill").append(1, theIndex)); - majorSkill[i]->setWindowManager(&mWindowManager); - minorSkill[i]->setWindowManager(&mWindowManager); + getWidget(mMajorSkill[i], std::string("MajorSkill").append(1, theIndex)); + getWidget(mMinorSkill[i], std::string("MinorSkill").append(1, theIndex)); + mMajorSkill[i]->setWindowManager(&mWindowManager); + mMinorSkill[i]->setWindowManager(&mWindowManager); } - getWidget(classList, "ClassList"); - classList->setScrollVisible(true); - classList->eventListSelectAccept += MyGUI::newDelegate(this, &PickClassDialog::onSelectClass); - classList->eventListMouseItemActivate += MyGUI::newDelegate(this, &PickClassDialog::onSelectClass); - classList->eventListChangePosition += MyGUI::newDelegate(this, &PickClassDialog::onSelectClass); + getWidget(mClassList, "ClassList"); + mClassList->setScrollVisible(true); + mClassList->eventListSelectAccept += MyGUI::newDelegate(this, &PickClassDialog::onSelectClass); + mClassList->eventListMouseItemActivate += MyGUI::newDelegate(this, &PickClassDialog::onSelectClass); + mClassList->eventListChangePosition += MyGUI::newDelegate(this, &PickClassDialog::onSelectClass); - getWidget(classImage, "ClassImage"); + getWidget(mClassImage, "ClassImage"); MyGUI::ButtonPtr backButton; getWidget(backButton, "BackButton"); @@ -148,14 +148,14 @@ void PickClassDialog::open() void PickClassDialog::setClassId(const std::string &classId) { - currentClassId = classId; - classList->setIndexSelected(MyGUI::ITEM_NONE); - size_t count = classList->getItemCount(); + mCurrentClassId = classId; + mClassList->setIndexSelected(MyGUI::ITEM_NONE); + size_t count = mClassList->getItemCount(); for (size_t i = 0; i < count; ++i) { - if (boost::iequals(*classList->getItemDataAt(i), classId)) + if (boost::iequals(*mClassList->getItemDataAt(i), classId)) { - classList->setIndexSelected(i); + mClassList->setIndexSelected(i); break; } } @@ -180,11 +180,11 @@ void PickClassDialog::onSelectClass(MyGUI::ListBox* _sender, size_t _index) if (_index == MyGUI::ITEM_NONE) return; - const std::string *classId = classList->getItemDataAt(_index); - if (boost::iequals(currentClassId, *classId)) + const std::string *classId = mClassList->getItemDataAt(_index); + if (boost::iequals(mCurrentClassId, *classId)) return; - currentClassId = *classId; + mCurrentClassId = *classId; updateStats(); } @@ -192,7 +192,7 @@ void PickClassDialog::onSelectClass(MyGUI::ListBox* _sender, size_t _index) void PickClassDialog::updateClasses() { - classList->removeAllItems(); + mClassList->removeAllItems(); const ESMS::ESMStore &store = mWindowManager.getStore(); @@ -207,19 +207,19 @@ void PickClassDialog::updateClasses() continue; const std::string &id = it->first; - classList->addItem(klass.name, id); - if (boost::iequals(id, currentClassId)) - classList->setIndexSelected(index); + mClassList->addItem(klass.name, id); + if (boost::iequals(id, mCurrentClassId)) + mClassList->setIndexSelected(index); ++index; } } void PickClassDialog::updateStats() { - if (currentClassId.empty()) + if (mCurrentClassId.empty()) return; const ESMS::ESMStore &store = mWindowManager.getStore(); - const ESM::Class *klass = store.classes.search(currentClassId); + const ESM::Class *klass = store.classes.search(mCurrentClassId); if (!klass) return; @@ -231,23 +231,23 @@ void PickClassDialog::updateStats() "sSpecializationStealth" }; std::string specName = mWindowManager.getGameSettingString(specIds[specialization], specIds[specialization]); - specializationName->setCaption(specName); - ToolTips::createSpecializationToolTip(specializationName, specName, specialization); + mSpecializationName->setCaption(specName); + ToolTips::createSpecializationToolTip(mSpecializationName, specName, specialization); - favoriteAttribute[0]->setAttributeId(klass->data.attribute[0]); - favoriteAttribute[1]->setAttributeId(klass->data.attribute[1]); - ToolTips::createAttributeToolTip(favoriteAttribute[0], favoriteAttribute[0]->getAttributeId()); - ToolTips::createAttributeToolTip(favoriteAttribute[1], favoriteAttribute[1]->getAttributeId()); + mFavoriteAttribute[0]->setAttributeId(klass->data.attribute[0]); + mFavoriteAttribute[1]->setAttributeId(klass->data.attribute[1]); + ToolTips::createAttributeToolTip(mFavoriteAttribute[0], mFavoriteAttribute[0]->getAttributeId()); + ToolTips::createAttributeToolTip(mFavoriteAttribute[1], mFavoriteAttribute[1]->getAttributeId()); for (int i = 0; i < 5; ++i) { - minorSkill[i]->setSkillNumber(klass->data.skills[i][0]); - majorSkill[i]->setSkillNumber(klass->data.skills[i][1]); - ToolTips::createSkillToolTip(minorSkill[i], klass->data.skills[i][0]); - ToolTips::createSkillToolTip(majorSkill[i], klass->data.skills[i][1]); + mMinorSkill[i]->setSkillNumber(klass->data.skills[i][0]); + mMajorSkill[i]->setSkillNumber(klass->data.skills[i][1]); + ToolTips::createSkillToolTip(mMinorSkill[i], klass->data.skills[i][0]); + ToolTips::createSkillToolTip(mMajorSkill[i], klass->data.skills[i][1]); } - classImage->setImageTexture(std::string("textures\\levelup\\") + currentClassId + ".dds"); + mClassImage->setImageTexture(std::string("textures\\levelup\\") + mCurrentClassId + ".dds"); } /* InfoBoxDialog */ @@ -284,59 +284,59 @@ void InfoBoxDialog::layoutVertically(MyGUI::WidgetPtr widget, int margin) InfoBoxDialog::InfoBoxDialog(WindowManager& parWindowManager) : WindowBase("openmw_infobox.layout", parWindowManager) - , currentButton(-1) + , mCurrentButton(-1) { - getWidget(textBox, "TextBox"); - getWidget(text, "Text"); - text->getSubWidgetText()->setWordWrap(true); - getWidget(buttonBar, "ButtonBar"); + getWidget(mTextBox, "TextBox"); + getWidget(mText, "Text"); + mText->getSubWidgetText()->setWordWrap(true); + getWidget(mButtonBar, "ButtonBar"); center(); } void InfoBoxDialog::setText(const std::string &str) { - text->setCaption(str); - textBox->setVisible(!str.empty()); - fitToText(text); + mText->setCaption(str); + mTextBox->setVisible(!str.empty()); + fitToText(mText); } std::string InfoBoxDialog::getText() const { - return text->getCaption(); + return mText->getCaption(); } void InfoBoxDialog::setButtons(ButtonList &buttons) { - for (std::vector::iterator it = this->buttons.begin(); it != this->buttons.end(); ++it) + for (std::vector::iterator it = this->mButtons.begin(); it != this->mButtons.end(); ++it) { MyGUI::Gui::getInstance().destroyWidget(*it); } - this->buttons.clear(); - currentButton = -1; + this->mButtons.clear(); + mCurrentButton = -1; // TODO: The buttons should be generated from a template in the layout file, ie. cloning an existing widget MyGUI::ButtonPtr button; - MyGUI::IntCoord coord = MyGUI::IntCoord(0, 0, buttonBar->getWidth(), 10); + MyGUI::IntCoord coord = MyGUI::IntCoord(0, 0, mButtonBar->getWidth(), 10); ButtonList::const_iterator end = buttons.end(); for (ButtonList::const_iterator it = buttons.begin(); it != end; ++it) { const std::string &text = *it; - button = buttonBar->createWidget("MW_Button", coord, MyGUI::Align::Top | MyGUI::Align::HCenter, ""); + button = mButtonBar->createWidget("MW_Button", coord, MyGUI::Align::Top | MyGUI::Align::HCenter, ""); button->getSubWidgetText()->setWordWrap(true); button->setCaption(text); fitToText(button); button->eventMouseButtonClick += MyGUI::newDelegate(this, &InfoBoxDialog::onButtonClicked); coord.top += button->getHeight(); - this->buttons.push_back(button); + this->mButtons.push_back(button); } } void InfoBoxDialog::open() { // Fix layout - layoutVertically(textBox, 4); - layoutVertically(buttonBar, 6); + layoutVertically(mTextBox, 4); + layoutVertically(mButtonBar, 6); layoutVertically(mMainWidget, 4 + 6); center(); @@ -345,18 +345,18 @@ void InfoBoxDialog::open() int InfoBoxDialog::getChosenButton() const { - return currentButton; + return mCurrentButton; } void InfoBoxDialog::onButtonClicked(MyGUI::WidgetPtr _sender) { - std::vector::const_iterator end = buttons.end(); + std::vector::const_iterator end = mButtons.end(); int i = 0; - for (std::vector::const_iterator it = buttons.begin(); it != end; ++it) + for (std::vector::const_iterator it = mButtons.begin(); it != end; ++it) { if (*it == _sender) { - currentButton = i; + mCurrentButton = i; eventButtonSelected(i); return; } @@ -382,49 +382,49 @@ ClassChoiceDialog::ClassChoiceDialog(WindowManager& parWindowManager) CreateClassDialog::CreateClassDialog(WindowManager& parWindowManager) : WindowBase("openmw_chargen_create_class.layout", parWindowManager) - , specDialog(nullptr) - , attribDialog(nullptr) - , skillDialog(nullptr) - , descDialog(nullptr) + , mSpecDialog(nullptr) + , mAttribDialog(nullptr) + , mSkillDialog(nullptr) + , mDescDialog(nullptr) { // Centre dialog center(); setText("SpecializationT", mWindowManager.getGameSettingString("sChooseClassMenu1", "Specialization")); - getWidget(specializationName, "SpecializationName"); - specializationName->eventMouseButtonClick += MyGUI::newDelegate(this, &CreateClassDialog::onSpecializationClicked); + getWidget(mSpecializationName, "SpecializationName"); + mSpecializationName->eventMouseButtonClick += MyGUI::newDelegate(this, &CreateClassDialog::onSpecializationClicked); setText("FavoriteAttributesT", mWindowManager.getGameSettingString("sChooseClassMenu2", "Favorite Attributes:")); - getWidget(favoriteAttribute0, "FavoriteAttribute0"); - getWidget(favoriteAttribute1, "FavoriteAttribute1"); - favoriteAttribute0->setWindowManager(&mWindowManager); - favoriteAttribute1->setWindowManager(&mWindowManager); - favoriteAttribute0->eventClicked += MyGUI::newDelegate(this, &CreateClassDialog::onAttributeClicked); - favoriteAttribute1->eventClicked += MyGUI::newDelegate(this, &CreateClassDialog::onAttributeClicked); + getWidget(mFavoriteAttribute0, "FavoriteAttribute0"); + getWidget(mFavoriteAttribute1, "FavoriteAttribute1"); + mFavoriteAttribute0->setWindowManager(&mWindowManager); + mFavoriteAttribute1->setWindowManager(&mWindowManager); + mFavoriteAttribute0->eventClicked += MyGUI::newDelegate(this, &CreateClassDialog::onAttributeClicked); + mFavoriteAttribute1->eventClicked += MyGUI::newDelegate(this, &CreateClassDialog::onAttributeClicked); setText("MajorSkillT", mWindowManager.getGameSettingString("sSkillClassMajor", "")); setText("MinorSkillT", mWindowManager.getGameSettingString("sSkillClassMinor", "")); for(int i = 0; i < 5; i++) { char theIndex = '0'+i; - getWidget(majorSkill[i], std::string("MajorSkill").append(1, theIndex)); - getWidget(minorSkill[i], std::string("MinorSkill").append(1, theIndex)); - skills.push_back(majorSkill[i]); - skills.push_back(minorSkill[i]); + getWidget(mMajorSkill[i], std::string("MajorSkill").append(1, theIndex)); + getWidget(mMinorSkill[i], std::string("MinorSkill").append(1, theIndex)); + mSkills.push_back(mMajorSkill[i]); + mSkills.push_back(mMinorSkill[i]); } - std::vector::const_iterator end = skills.end(); - for (std::vector::const_iterator it = skills.begin(); it != end; ++it) + std::vector::const_iterator end = mSkills.end(); + for (std::vector::const_iterator it = mSkills.begin(); it != end; ++it) { (*it)->setWindowManager(&mWindowManager); (*it)->eventClicked += MyGUI::newDelegate(this, &CreateClassDialog::onSkillClicked); } setText("LabelT", mWindowManager.getGameSettingString("sName", "")); - getWidget(editName, "EditName"); + getWidget(mEditName, "EditName"); // Make sure the edit box has focus - MyGUI::InputManager::getInstance().setKeyFocusWidget(editName); + MyGUI::InputManager::getInstance().setKeyFocusWidget(mEditName); MyGUI::ButtonPtr descriptionButton; getWidget(descriptionButton, "DescriptionButton"); @@ -441,20 +441,20 @@ CreateClassDialog::CreateClassDialog(WindowManager& parWindowManager) // Set default skills, attributes - favoriteAttribute0->setAttributeId(ESM::Attribute::Strength); - favoriteAttribute1->setAttributeId(ESM::Attribute::Agility); + mFavoriteAttribute0->setAttributeId(ESM::Attribute::Strength); + mFavoriteAttribute1->setAttributeId(ESM::Attribute::Agility); - majorSkill[0]->setSkillId(ESM::Skill::Block); - majorSkill[1]->setSkillId(ESM::Skill::Armorer); - majorSkill[2]->setSkillId(ESM::Skill::MediumArmor); - majorSkill[3]->setSkillId(ESM::Skill::HeavyArmor); - majorSkill[4]->setSkillId(ESM::Skill::BluntWeapon); + mMajorSkill[0]->setSkillId(ESM::Skill::Block); + mMajorSkill[1]->setSkillId(ESM::Skill::Armorer); + mMajorSkill[2]->setSkillId(ESM::Skill::MediumArmor); + mMajorSkill[3]->setSkillId(ESM::Skill::HeavyArmor); + mMajorSkill[4]->setSkillId(ESM::Skill::BluntWeapon); - minorSkill[0]->setSkillId(ESM::Skill::LongBlade); - minorSkill[1]->setSkillId(ESM::Skill::Axe); - minorSkill[2]->setSkillId(ESM::Skill::Spear); - minorSkill[3]->setSkillId(ESM::Skill::Athletics); - minorSkill[4]->setSkillId(ESM::Skill::Enchant); + mMinorSkill[0]->setSkillId(ESM::Skill::LongBlade); + mMinorSkill[1]->setSkillId(ESM::Skill::Axe); + mMinorSkill[2]->setSkillId(ESM::Skill::Spear); + mMinorSkill[3]->setSkillId(ESM::Skill::Athletics); + mMinorSkill[4]->setSkillId(ESM::Skill::Enchant); setSpecialization(0); update(); @@ -462,44 +462,44 @@ CreateClassDialog::CreateClassDialog(WindowManager& parWindowManager) CreateClassDialog::~CreateClassDialog() { - delete specDialog; - delete attribDialog; - delete skillDialog; - delete descDialog; + delete mSpecDialog; + delete mAttribDialog; + delete mSkillDialog; + delete mDescDialog; } void CreateClassDialog::update() { for (int i = 0; i < 5; ++i) { - ToolTips::createSkillToolTip(majorSkill[i], majorSkill[i]->getSkillId()); - ToolTips::createSkillToolTip(minorSkill[i], minorSkill[i]->getSkillId()); + ToolTips::createSkillToolTip(mMajorSkill[i], mMajorSkill[i]->getSkillId()); + ToolTips::createSkillToolTip(mMinorSkill[i], mMinorSkill[i]->getSkillId()); } - ToolTips::createAttributeToolTip(favoriteAttribute0, favoriteAttribute0->getAttributeId()); - ToolTips::createAttributeToolTip(favoriteAttribute1, favoriteAttribute1->getAttributeId()); + ToolTips::createAttributeToolTip(mFavoriteAttribute0, mFavoriteAttribute0->getAttributeId()); + ToolTips::createAttributeToolTip(mFavoriteAttribute1, mFavoriteAttribute1->getAttributeId()); } std::string CreateClassDialog::getName() const { - return editName->getOnlyText(); + return mEditName->getOnlyText(); } std::string CreateClassDialog::getDescription() const { - return description; + return mDescription; } ESM::Class::Specialization CreateClassDialog::getSpecializationId() const { - return specializationId; + return mSpecializationId; } std::vector CreateClassDialog::getFavoriteAttributes() const { std::vector v; - v.push_back(favoriteAttribute0->getAttributeId()); - v.push_back(favoriteAttribute1->getAttributeId()); + v.push_back(mFavoriteAttribute0->getAttributeId()); + v.push_back(mFavoriteAttribute1->getAttributeId()); return v; } @@ -508,7 +508,7 @@ std::vector CreateClassDialog::getMajorSkills() const std::vector v; for(int i = 0; i < 5; i++) { - v.push_back(majorSkill[i]->getSkillId()); + v.push_back(mMajorSkill[i]->getSkillId()); } return v; } @@ -518,7 +518,7 @@ std::vector CreateClassDialog::getMinorSkills() const std::vector v; for(int i=0; i < 5; i++) { - v.push_back(minorSkill[i]->getSkillId()); + v.push_back(mMinorSkill[i]->getSkillId()); } return v; } @@ -557,108 +557,108 @@ void CreateClassDialog::open() void CreateClassDialog::onDialogCancel() { - if (specDialog) + if (mSpecDialog) { - mWindowManager.removeDialog(specDialog); - specDialog = 0; + mWindowManager.removeDialog(mSpecDialog); + mSpecDialog = 0; } - if (attribDialog) + if (mAttribDialog) { - mWindowManager.removeDialog(attribDialog); - attribDialog = 0; + mWindowManager.removeDialog(mAttribDialog); + mAttribDialog = 0; } - if (skillDialog) + if (mSkillDialog) { - mWindowManager.removeDialog(skillDialog); - skillDialog = 0; + mWindowManager.removeDialog(mSkillDialog); + mSkillDialog = 0; } - if (descDialog) + if (mDescDialog) { - mWindowManager.removeDialog(descDialog); - descDialog = 0; + mWindowManager.removeDialog(mDescDialog); + mDescDialog = 0; } } void CreateClassDialog::onSpecializationClicked(MyGUI::WidgetPtr _sender) { - delete specDialog; - specDialog = new SelectSpecializationDialog(mWindowManager); - specDialog->eventCancel += MyGUI::newDelegate(this, &CreateClassDialog::onDialogCancel); - specDialog->eventItemSelected += MyGUI::newDelegate(this, &CreateClassDialog::onSpecializationSelected); - specDialog->setVisible(true); + delete mSpecDialog; + mSpecDialog = new SelectSpecializationDialog(mWindowManager); + mSpecDialog->eventCancel += MyGUI::newDelegate(this, &CreateClassDialog::onDialogCancel); + mSpecDialog->eventItemSelected += MyGUI::newDelegate(this, &CreateClassDialog::onSpecializationSelected); + mSpecDialog->setVisible(true); } void CreateClassDialog::onSpecializationSelected() { - specializationId = specDialog->getSpecializationId(); - setSpecialization(specializationId); + mSpecializationId = mSpecDialog->getSpecializationId(); + setSpecialization(mSpecializationId); - mWindowManager.removeDialog(specDialog); - specDialog = 0; + mWindowManager.removeDialog(mSpecDialog); + mSpecDialog = 0; } void CreateClassDialog::setSpecialization(int id) { - specializationId = (ESM::Class::Specialization) id; + mSpecializationId = (ESM::Class::Specialization) id; static const char *specIds[3] = { "sSpecializationCombat", "sSpecializationMagic", "sSpecializationStealth" }; - std::string specName = mWindowManager.getGameSettingString(specIds[specializationId], specIds[specializationId]); - specializationName->setCaption(specName); - ToolTips::createSpecializationToolTip(specializationName, specName, specializationId); + std::string specName = mWindowManager.getGameSettingString(specIds[mSpecializationId], specIds[mSpecializationId]); + mSpecializationName->setCaption(specName); + ToolTips::createSpecializationToolTip(mSpecializationName, specName, mSpecializationId); } void CreateClassDialog::onAttributeClicked(Widgets::MWAttributePtr _sender) { - delete attribDialog; - attribDialog = new SelectAttributeDialog(mWindowManager); - attribDialog->setAffectedWidget(_sender); - attribDialog->eventCancel += MyGUI::newDelegate(this, &CreateClassDialog::onDialogCancel); - attribDialog->eventItemSelected += MyGUI::newDelegate(this, &CreateClassDialog::onAttributeSelected); - attribDialog->setVisible(true); + delete mAttribDialog; + mAttribDialog = new SelectAttributeDialog(mWindowManager); + mAttribDialog->setAffectedWidget(_sender); + mAttribDialog->eventCancel += MyGUI::newDelegate(this, &CreateClassDialog::onDialogCancel); + mAttribDialog->eventItemSelected += MyGUI::newDelegate(this, &CreateClassDialog::onAttributeSelected); + mAttribDialog->setVisible(true); } void CreateClassDialog::onAttributeSelected() { - ESM::Attribute::AttributeID id = attribDialog->getAttributeId(); - Widgets::MWAttributePtr attribute = attribDialog->getAffectedWidget(); - if (attribute == favoriteAttribute0) + ESM::Attribute::AttributeID id = mAttribDialog->getAttributeId(); + Widgets::MWAttributePtr attribute = mAttribDialog->getAffectedWidget(); + if (attribute == mFavoriteAttribute0) { - if (favoriteAttribute1->getAttributeId() == id) - favoriteAttribute1->setAttributeId(favoriteAttribute0->getAttributeId()); + if (mFavoriteAttribute1->getAttributeId() == id) + mFavoriteAttribute1->setAttributeId(mFavoriteAttribute0->getAttributeId()); } - else if (attribute == favoriteAttribute1) + else if (attribute == mFavoriteAttribute1) { - if (favoriteAttribute0->getAttributeId() == id) - favoriteAttribute0->setAttributeId(favoriteAttribute1->getAttributeId()); + if (mFavoriteAttribute0->getAttributeId() == id) + mFavoriteAttribute0->setAttributeId(mFavoriteAttribute1->getAttributeId()); } attribute->setAttributeId(id); - mWindowManager.removeDialog(attribDialog); - attribDialog = 0; + mWindowManager.removeDialog(mAttribDialog); + mAttribDialog = 0; update(); } void CreateClassDialog::onSkillClicked(Widgets::MWSkillPtr _sender) { - delete skillDialog; - skillDialog = new SelectSkillDialog(mWindowManager); - skillDialog->setAffectedWidget(_sender); - skillDialog->eventCancel += MyGUI::newDelegate(this, &CreateClassDialog::onDialogCancel); - skillDialog->eventItemSelected += MyGUI::newDelegate(this, &CreateClassDialog::onSkillSelected); - skillDialog->setVisible(true); + delete mSkillDialog; + mSkillDialog = new SelectSkillDialog(mWindowManager); + mSkillDialog->setAffectedWidget(_sender); + mSkillDialog->eventCancel += MyGUI::newDelegate(this, &CreateClassDialog::onDialogCancel); + mSkillDialog->eventItemSelected += MyGUI::newDelegate(this, &CreateClassDialog::onSkillSelected); + mSkillDialog->setVisible(true); } void CreateClassDialog::onSkillSelected() { - ESM::Skill::SkillEnum id = skillDialog->getSkillId(); - Widgets::MWSkillPtr skill = skillDialog->getAffectedWidget(); + ESM::Skill::SkillEnum id = mSkillDialog->getSkillId(); + Widgets::MWSkillPtr skill = mSkillDialog->getAffectedWidget(); // Avoid duplicate skills by swapping any skill field that matches the selected one - std::vector::const_iterator end = skills.end(); - for (std::vector::const_iterator it = skills.begin(); it != end; ++it) + std::vector::const_iterator end = mSkills.end(); + for (std::vector::const_iterator it = mSkills.begin(); it != end; ++it) { if (*it == skill) continue; @@ -669,25 +669,25 @@ void CreateClassDialog::onSkillSelected() } } - skill->setSkillId(skillDialog->getSkillId()); - mWindowManager.removeDialog(skillDialog); - skillDialog = 0; + skill->setSkillId(mSkillDialog->getSkillId()); + mWindowManager.removeDialog(mSkillDialog); + mSkillDialog = 0; update(); } void CreateClassDialog::onDescriptionClicked(MyGUI::Widget* _sender) { - descDialog = new DescriptionDialog(mWindowManager); - descDialog->setTextInput(description); - descDialog->eventDone += MyGUI::newDelegate(this, &CreateClassDialog::onDescriptionEntered); - descDialog->setVisible(true); + mDescDialog = new DescriptionDialog(mWindowManager); + mDescDialog->setTextInput(mDescription); + mDescDialog->eventDone += MyGUI::newDelegate(this, &CreateClassDialog::onDescriptionEntered); + mDescDialog->setVisible(true); } void CreateClassDialog::onDescriptionEntered(WindowBase* parWindow) { - description = descDialog->getTextInput(); - mWindowManager.removeDialog(descDialog); - descDialog = 0; + mDescription = mDescDialog->getTextInput(); + mWindowManager.removeDialog(mDescDialog); + mDescDialog = 0; } void CreateClassDialog::onOkClicked(MyGUI::Widget* _sender) @@ -710,24 +710,24 @@ SelectSpecializationDialog::SelectSpecializationDialog(WindowManager& parWindowM setText("LabelT", mWindowManager.getGameSettingString("sSpecializationMenu1", "")); - getWidget(specialization0, "Specialization0"); - getWidget(specialization1, "Specialization1"); - getWidget(specialization2, "Specialization2"); + getWidget(mSpecialization0, "Specialization0"); + getWidget(mSpecialization1, "Specialization1"); + getWidget(mSpecialization2, "Specialization2"); std::string combat = mWindowManager.getGameSettingString(ESM::Class::gmstSpecializationIds[ESM::Class::Combat], ""); std::string magic = mWindowManager.getGameSettingString(ESM::Class::gmstSpecializationIds[ESM::Class::Magic], ""); std::string stealth = mWindowManager.getGameSettingString(ESM::Class::gmstSpecializationIds[ESM::Class::Stealth], ""); - specialization0->setCaption(combat); - specialization0->eventMouseButtonClick += MyGUI::newDelegate(this, &SelectSpecializationDialog::onSpecializationClicked); - specialization1->setCaption(magic); - specialization1->eventMouseButtonClick += MyGUI::newDelegate(this, &SelectSpecializationDialog::onSpecializationClicked); - specialization2->setCaption(stealth); - specialization2->eventMouseButtonClick += MyGUI::newDelegate(this, &SelectSpecializationDialog::onSpecializationClicked); - specializationId = ESM::Class::Combat; + mSpecialization0->setCaption(combat); + mSpecialization0->eventMouseButtonClick += MyGUI::newDelegate(this, &SelectSpecializationDialog::onSpecializationClicked); + mSpecialization1->setCaption(magic); + mSpecialization1->eventMouseButtonClick += MyGUI::newDelegate(this, &SelectSpecializationDialog::onSpecializationClicked); + mSpecialization2->setCaption(stealth); + mSpecialization2->eventMouseButtonClick += MyGUI::newDelegate(this, &SelectSpecializationDialog::onSpecializationClicked); + mSpecializationId = ESM::Class::Combat; - ToolTips::createSpecializationToolTip(specialization0, combat, ESM::Class::Combat); - ToolTips::createSpecializationToolTip(specialization1, magic, ESM::Class::Magic); - ToolTips::createSpecializationToolTip(specialization2, stealth, ESM::Class::Stealth); + ToolTips::createSpecializationToolTip(mSpecialization0, combat, ESM::Class::Combat); + ToolTips::createSpecializationToolTip(mSpecialization1, magic, ESM::Class::Magic); + ToolTips::createSpecializationToolTip(mSpecialization2, stealth, ESM::Class::Stealth); MyGUI::ButtonPtr cancelButton; getWidget(cancelButton, "CancelButton"); @@ -748,12 +748,12 @@ SelectSpecializationDialog::~SelectSpecializationDialog() void SelectSpecializationDialog::onSpecializationClicked(MyGUI::WidgetPtr _sender) { - if (_sender == specialization0) - specializationId = ESM::Class::Combat; - else if (_sender == specialization1) - specializationId = ESM::Class::Magic; - else if (_sender == specialization2) - specializationId = ESM::Class::Stealth; + if (_sender == mSpecialization0) + mSpecializationId = ESM::Class::Combat; + else if (_sender == mSpecialization1) + mSpecializationId = ESM::Class::Magic; + else if (_sender == mSpecialization2) + mSpecializationId = ESM::Class::Stealth; else return; @@ -807,7 +807,7 @@ SelectAttributeDialog::~SelectAttributeDialog() void SelectAttributeDialog::onAttributeClicked(Widgets::MWAttributePtr _sender) { // TODO: Change MWAttribute to set and get AttributeID enum instead of int - attributeId = static_cast(_sender->getAttributeId()); + mAttributeId = static_cast(_sender->getAttributeId()); eventItemSelected(); } @@ -833,44 +833,44 @@ SelectSkillDialog::SelectSkillDialog(WindowManager& parWindowManager) for(int i = 0; i < 9; i++) { char theIndex = '0'+i; - getWidget(combatSkill[i], std::string("CombatSkill").append(1, theIndex)); - getWidget(magicSkill[i], std::string("MagicSkill").append(1, theIndex)); - getWidget(stealthSkill[i], std::string("StealthSkill").append(1, theIndex)); + getWidget(mCombatSkill[i], std::string("CombatSkill").append(1, theIndex)); + getWidget(mMagicSkill[i], std::string("MagicSkill").append(1, theIndex)); + getWidget(mStealthSkill[i], std::string("StealthSkill").append(1, theIndex)); } - struct {Widgets::MWSkillPtr widget; ESM::Skill::SkillEnum skillId;} skills[3][9] = { + struct {Widgets::MWSkillPtr widget; ESM::Skill::SkillEnum skillId;} mSkills[3][9] = { { - {combatSkill[0], ESM::Skill::Block}, - {combatSkill[1], ESM::Skill::Armorer}, - {combatSkill[2], ESM::Skill::MediumArmor}, - {combatSkill[3], ESM::Skill::HeavyArmor}, - {combatSkill[4], ESM::Skill::BluntWeapon}, - {combatSkill[5], ESM::Skill::LongBlade}, - {combatSkill[6], ESM::Skill::Axe}, - {combatSkill[7], ESM::Skill::Spear}, - {combatSkill[8], ESM::Skill::Athletics} + {mCombatSkill[0], ESM::Skill::Block}, + {mCombatSkill[1], ESM::Skill::Armorer}, + {mCombatSkill[2], ESM::Skill::MediumArmor}, + {mCombatSkill[3], ESM::Skill::HeavyArmor}, + {mCombatSkill[4], ESM::Skill::BluntWeapon}, + {mCombatSkill[5], ESM::Skill::LongBlade}, + {mCombatSkill[6], ESM::Skill::Axe}, + {mCombatSkill[7], ESM::Skill::Spear}, + {mCombatSkill[8], ESM::Skill::Athletics} }, { - {magicSkill[0], ESM::Skill::Enchant}, - {magicSkill[1], ESM::Skill::Destruction}, - {magicSkill[2], ESM::Skill::Alteration}, - {magicSkill[3], ESM::Skill::Illusion}, - {magicSkill[4], ESM::Skill::Conjuration}, - {magicSkill[5], ESM::Skill::Mysticism}, - {magicSkill[6], ESM::Skill::Restoration}, - {magicSkill[7], ESM::Skill::Alchemy}, - {magicSkill[8], ESM::Skill::Unarmored} + {mMagicSkill[0], ESM::Skill::Enchant}, + {mMagicSkill[1], ESM::Skill::Destruction}, + {mMagicSkill[2], ESM::Skill::Alteration}, + {mMagicSkill[3], ESM::Skill::Illusion}, + {mMagicSkill[4], ESM::Skill::Conjuration}, + {mMagicSkill[5], ESM::Skill::Mysticism}, + {mMagicSkill[6], ESM::Skill::Restoration}, + {mMagicSkill[7], ESM::Skill::Alchemy}, + {mMagicSkill[8], ESM::Skill::Unarmored} }, { - {stealthSkill[0], ESM::Skill::Security}, - {stealthSkill[1], ESM::Skill::Sneak}, - {stealthSkill[2], ESM::Skill::Acrobatics}, - {stealthSkill[3], ESM::Skill::LightArmor}, - {stealthSkill[4], ESM::Skill::ShortBlade}, - {stealthSkill[5] ,ESM::Skill::Marksman}, - {stealthSkill[6] ,ESM::Skill::Mercantile}, - {stealthSkill[7] ,ESM::Skill::Speechcraft}, - {stealthSkill[8] ,ESM::Skill::HandToHand} + {mStealthSkill[0], ESM::Skill::Security}, + {mStealthSkill[1], ESM::Skill::Sneak}, + {mStealthSkill[2], ESM::Skill::Acrobatics}, + {mStealthSkill[3], ESM::Skill::LightArmor}, + {mStealthSkill[4], ESM::Skill::ShortBlade}, + {mStealthSkill[5] ,ESM::Skill::Marksman}, + {mStealthSkill[6] ,ESM::Skill::Mercantile}, + {mStealthSkill[7] ,ESM::Skill::Speechcraft}, + {mStealthSkill[8] ,ESM::Skill::HandToHand} } }; @@ -878,10 +878,10 @@ SelectSkillDialog::SelectSkillDialog(WindowManager& parWindowManager) { for (int i = 0; i < 9; ++i) { - skills[spec][i].widget->setWindowManager(&mWindowManager); - skills[spec][i].widget->setSkillId(skills[spec][i].skillId); - skills[spec][i].widget->eventClicked += MyGUI::newDelegate(this, &SelectSkillDialog::onSkillClicked); - ToolTips::createSkillToolTip(skills[spec][i].widget, skills[spec][i].widget->getSkillId()); + mSkills[spec][i].widget->setWindowManager(&mWindowManager); + mSkills[spec][i].widget->setSkillId(mSkills[spec][i].skillId); + mSkills[spec][i].widget->eventClicked += MyGUI::newDelegate(this, &SelectSkillDialog::onSkillClicked); + ToolTips::createSkillToolTip(mSkills[spec][i].widget, mSkills[spec][i].widget->getSkillId()); } } @@ -904,7 +904,7 @@ SelectSkillDialog::~SelectSkillDialog() void SelectSkillDialog::onSkillClicked(Widgets::MWSkillPtr _sender) { - skillId = _sender->getSkillId(); + mSkillId = _sender->getSkillId(); eventItemSelected(); } @@ -921,7 +921,7 @@ DescriptionDialog::DescriptionDialog(WindowManager& parWindowManager) // Centre dialog center(); - getWidget(textEdit, "TextEdit"); + getWidget(mTextEdit, "TextEdit"); MyGUI::ButtonPtr okButton; getWidget(okButton, "OKButton"); @@ -931,7 +931,7 @@ DescriptionDialog::DescriptionDialog(WindowManager& parWindowManager) okButton->setCoord(234 - buttonWidth, 214, buttonWidth, 24); // Make sure the edit box has focus - MyGUI::InputManager::getInstance().setKeyFocusWidget(textEdit); + MyGUI::InputManager::getInstance().setKeyFocusWidget(mTextEdit); MyGUI::InputManager::getInstance().addWidgetModal(mMainWidget); } diff --git a/apps/openmw/mwgui/class.hpp b/apps/openmw/mwgui/class.hpp index c9e7aef7b..4d8d9fa23 100644 --- a/apps/openmw/mwgui/class.hpp +++ b/apps/openmw/mwgui/class.hpp @@ -45,11 +45,11 @@ namespace MWGui void fitToText(MyGUI::TextBox* widget); void layoutVertically(MyGUI::WidgetPtr widget, int margin); - int currentButton; - MyGUI::WidgetPtr textBox; - MyGUI::TextBox* text; - MyGUI::WidgetPtr buttonBar; - std::vector buttons; + int mCurrentButton; + MyGUI::WidgetPtr mTextBox; + MyGUI::TextBox* mText; + MyGUI::WidgetPtr mButtonBar; + std::vector mButtons; }; // Lets the player choose between 3 ways of creating a class @@ -90,10 +90,10 @@ namespace MWGui void onBackClicked(MyGUI::Widget* _sender); private: - MyGUI::ImageBox* classImage; - MyGUI::TextBox* className; + MyGUI::ImageBox* mClassImage; + MyGUI::TextBox* mClassName; - std::string currentClassId; + std::string mCurrentClassId; }; class PickClassDialog : public WindowBase @@ -101,7 +101,7 @@ namespace MWGui public: PickClassDialog(WindowManager& parWindowManager); - const std::string &getClassId() const { return currentClassId; } + const std::string &getClassId() const { return mCurrentClassId; } void setClassId(const std::string &classId); void setNextButtonShow(bool shown); @@ -125,14 +125,14 @@ namespace MWGui void updateClasses(); void updateStats(); - MyGUI::ImageBox* classImage; - MyGUI::ListBox* classList; - MyGUI::TextBox* specializationName; - Widgets::MWAttributePtr favoriteAttribute[2]; - Widgets::MWSkillPtr majorSkill[5]; - Widgets::MWSkillPtr minorSkill[5]; + MyGUI::ImageBox* mClassImage; + MyGUI::ListBox* mClassList; + MyGUI::TextBox* mSpecializationName; + Widgets::MWAttributePtr mFavoriteAttribute[2]; + Widgets::MWSkillPtr mMajorSkill[5]; + Widgets::MWSkillPtr mMinorSkill[5]; - std::string currentClassId; + std::string mCurrentClassId; }; class SelectSpecializationDialog : public WindowBase @@ -141,7 +141,7 @@ namespace MWGui SelectSpecializationDialog(WindowManager& parWindowManager); ~SelectSpecializationDialog(); - ESM::Class::Specialization getSpecializationId() const { return specializationId; } + ESM::Class::Specialization getSpecializationId() const { return mSpecializationId; } // Events typedef delegates::CMultiDelegate0 EventHandle_Void; @@ -161,9 +161,9 @@ namespace MWGui void onCancelClicked(MyGUI::Widget* _sender); private: - MyGUI::TextBox *specialization0, *specialization1, *specialization2; + MyGUI::TextBox *mSpecialization0, *mSpecialization1, *mSpecialization2; - ESM::Class::Specialization specializationId; + ESM::Class::Specialization mSpecializationId; }; class SelectAttributeDialog : public WindowBase @@ -172,9 +172,9 @@ namespace MWGui SelectAttributeDialog(WindowManager& parWindowManager); ~SelectAttributeDialog(); - ESM::Attribute::AttributeID getAttributeId() const { return attributeId; } - Widgets::MWAttributePtr getAffectedWidget() const { return affectedWidget; } - void setAffectedWidget(Widgets::MWAttributePtr widget) { affectedWidget = widget; } + ESM::Attribute::AttributeID getAttributeId() const { return mAttributeId; } + Widgets::MWAttributePtr getAffectedWidget() const { return mAffectedWidget; } + void setAffectedWidget(Widgets::MWAttributePtr widget) { mAffectedWidget = widget; } // Events typedef delegates::CMultiDelegate0 EventHandle_Void; @@ -194,9 +194,9 @@ namespace MWGui void onCancelClicked(MyGUI::Widget* _sender); private: - Widgets::MWAttributePtr affectedWidget; + Widgets::MWAttributePtr mAffectedWidget; - ESM::Attribute::AttributeID attributeId; + ESM::Attribute::AttributeID mAttributeId; }; class SelectSkillDialog : public WindowBase @@ -205,9 +205,9 @@ namespace MWGui SelectSkillDialog(WindowManager& parWindowManager); ~SelectSkillDialog(); - ESM::Skill::SkillEnum getSkillId() const { return skillId; } - Widgets::MWSkillPtr getAffectedWidget() const { return affectedWidget; } - void setAffectedWidget(Widgets::MWSkillPtr widget) { affectedWidget = widget; } + ESM::Skill::SkillEnum getSkillId() const { return mSkillId; } + Widgets::MWSkillPtr getAffectedWidget() const { return mAffectedWidget; } + void setAffectedWidget(Widgets::MWSkillPtr widget) { mAffectedWidget = widget; } // Events typedef delegates::CMultiDelegate0 EventHandle_Void; @@ -227,12 +227,12 @@ namespace MWGui void onCancelClicked(MyGUI::Widget* _sender); private: - Widgets::MWSkillPtr combatSkill[9]; - Widgets::MWSkillPtr magicSkill[9]; - Widgets::MWSkillPtr stealthSkill[9]; - Widgets::MWSkillPtr affectedWidget; + Widgets::MWSkillPtr mCombatSkill[9]; + Widgets::MWSkillPtr mMagicSkill[9]; + Widgets::MWSkillPtr mStealthSkill[9]; + Widgets::MWSkillPtr mAffectedWidget; - ESM::Skill::SkillEnum skillId; + ESM::Skill::SkillEnum mSkillId; }; class DescriptionDialog : public WindowBase @@ -241,14 +241,14 @@ namespace MWGui DescriptionDialog(WindowManager& parWindowManager); ~DescriptionDialog(); - std::string getTextInput() const { return textEdit ? textEdit->getOnlyText() : ""; } - void setTextInput(const std::string &text) { if (textEdit) textEdit->setOnlyText(text); } + std::string getTextInput() const { return mTextEdit ? mTextEdit->getOnlyText() : ""; } + void setTextInput(const std::string &text) { if (mTextEdit) mTextEdit->setOnlyText(text); } protected: void onOkClicked(MyGUI::Widget* _sender); private: - MyGUI::EditPtr textEdit; + MyGUI::EditPtr mTextEdit; }; class CreateClassDialog : public WindowBase @@ -294,20 +294,20 @@ namespace MWGui void update(); private: - MyGUI::EditPtr editName; - MyGUI::TextBox* specializationName; - Widgets::MWAttributePtr favoriteAttribute0, favoriteAttribute1; - Widgets::MWSkillPtr majorSkill[5]; - Widgets::MWSkillPtr minorSkill[5]; - std::vector skills; - std::string description; - - SelectSpecializationDialog *specDialog; - SelectAttributeDialog *attribDialog; - SelectSkillDialog *skillDialog; - DescriptionDialog *descDialog; - - ESM::Class::Specialization specializationId; + MyGUI::EditPtr mEditName; + MyGUI::TextBox* mSpecializationName; + Widgets::MWAttributePtr mFavoriteAttribute0, mFavoriteAttribute1; + Widgets::MWSkillPtr mMajorSkill[5]; + Widgets::MWSkillPtr mMinorSkill[5]; + std::vector mSkills; + std::string mDescription; + + SelectSpecializationDialog *mSpecDialog; + SelectAttributeDialog *mAttribDialog; + SelectSkillDialog *mSkillDialog; + DescriptionDialog *mDescDialog; + + ESM::Class::Specialization mSpecializationId; }; } #endif diff --git a/apps/openmw/mwgui/dialogue.cpp b/apps/openmw/mwgui/dialogue.cpp index acf0bf130..efb6dc036 100644 --- a/apps/openmw/mwgui/dialogue.cpp +++ b/apps/openmw/mwgui/dialogue.cpp @@ -51,9 +51,9 @@ DialogueWindow::DialogueWindow(WindowManager& parWindowManager) center(); //History view - getWidget(history, "History"); - history->setOverflowToTheLeft(true); - history->setMaxTextLength(1000000); + getWidget(mHistory, "History"); + mHistory->setOverflowToTheLeft(true); + mHistory->setMaxTextLength(1000000); Widget* eventbox; //An EditBox cannot receive mouse click events, so we use an @@ -63,36 +63,36 @@ DialogueWindow::DialogueWindow(WindowManager& parWindowManager) eventbox->eventMouseWheel += MyGUI::newDelegate(this, &DialogueWindow::onMouseWheel); //Topics list - getWidget(topicsList, "TopicsList"); - topicsList->eventItemSelected += MyGUI::newDelegate(this, &DialogueWindow::onSelectTopic); + getWidget(mTopicsList, "TopicsList"); + mTopicsList->eventItemSelected += MyGUI::newDelegate(this, &DialogueWindow::onSelectTopic); MyGUI::ButtonPtr byeButton; getWidget(byeButton, "ByeButton"); byeButton->eventMouseButtonClick += MyGUI::newDelegate(this, &DialogueWindow::onByeClicked); - getWidget(pDispositionBar, "Disposition"); - getWidget(pDispositionText,"DispositionText"); + getWidget(mDispositionBar, "Disposition"); + getWidget(mDispositionText,"DispositionText"); static_cast(mMainWidget)->eventWindowChangeCoord += MyGUI::newDelegate(this, &DialogueWindow::onWindowResize); } void DialogueWindow::onHistoryClicked(MyGUI::Widget* _sender) { - ISubWidgetText* t = history->getClient()->getSubWidgetText(); + ISubWidgetText* t = mHistory->getClient()->getSubWidgetText(); if(t == nullptr) return; const IntPoint& lastPressed = InputManager::getInstance().getLastPressedPosition(MyGUI::MouseButton::Left); size_t cursorPosition = t->getCursorPosition(lastPressed); - MyGUI::UString color = history->getColorAtPos(cursorPosition); + MyGUI::UString color = mHistory->getColorAtPos(cursorPosition); if (!mEnabled && color == "#572D21") MWBase::Environment::get().getDialogueManager()->goodbyeSelected(); if(color != "#B29154") { - UString key = history->getColorTextAt(cursorPosition); + UString key = mHistory->getColorTextAt(cursorPosition); if(color == "#686EBA") MWBase::Environment::get().getDialogueManager()->keywordSelected(lower_string(key)); if(color == "#572D21") MWBase::Environment::get().getDialogueManager()->questionAnswered(lower_string(key)); @@ -101,15 +101,15 @@ void DialogueWindow::onHistoryClicked(MyGUI::Widget* _sender) void DialogueWindow::onWindowResize(MyGUI::Window* _sender) { - topicsList->adjustSize(); + mTopicsList->adjustSize(); } void DialogueWindow::onMouseWheel(MyGUI::Widget* _sender, int _rel) { - if (history->getVScrollPosition() - _rel*0.3 < 0) - history->setVScrollPosition(0); + if (mHistory->getVScrollPosition() - _rel*0.3 < 0) + mHistory->setVScrollPosition(0); else - history->setVScrollPosition(history->getVScrollPosition() - _rel*0.3); + mHistory->setVScrollPosition(mHistory->getVScrollPosition() - _rel*0.3); } void DialogueWindow::onByeClicked(MyGUI::Widget* _sender) @@ -136,40 +136,40 @@ void DialogueWindow::startDialogue(MWWorld::Ptr actor, std::string npcName) { mEnabled = true; mPtr = actor; - topicsList->setEnabled(true); + mTopicsList->setEnabled(true); setTitle(npcName); - topicsList->clear(); - history->eraseText(0,history->getTextLength()); + mTopicsList->clear(); + mHistory->eraseText(0,mHistory->getTextLength()); updateOptions(); } void DialogueWindow::setKeywords(std::list keyWords) { - topicsList->clear(); + mTopicsList->clear(); bool anyService = mShowTrade; if (mShowTrade) - topicsList->addItem(MWBase::Environment::get().getWorld()->getStore().gameSettings.search("sBarter")->str); + mTopicsList->addItem(MWBase::Environment::get().getWorld()->getStore().gameSettings.search("sBarter")->str); if (anyService) - topicsList->addSeparator(); + mTopicsList->addSeparator(); for(std::list::iterator it = keyWords.begin(); it != keyWords.end(); ++it) { - topicsList->addItem(*it); + mTopicsList->addItem(*it); } - topicsList->adjustSize(); + mTopicsList->adjustSize(); } void DialogueWindow::removeKeyword(std::string keyWord) { - if(topicsList->hasItem(keyWord)) + if(mTopicsList->hasItem(keyWord)) { - topicsList->removeItem(keyWord); + mTopicsList->removeItem(keyWord); } - topicsList->adjustSize(); + mTopicsList->adjustSize(); } void addColorInString(std::string& str, const std::string& keyword,std::string color1, std::string color2) @@ -206,9 +206,9 @@ void addColorInString(std::string& str, const std::string& keyword,std::string c std::string DialogueWindow::parseText(std::string text) { bool separatorReached = false; // only parse topics that are below the separator (this prevents actions like "Barter" that are not topics from getting blue-colored) - for(unsigned int i = 0;igetItemCount();i++) + for(unsigned int i = 0;igetItemCount();i++) { - std::string keyWord = topicsList->getItemNameAt(i); + std::string keyWord = mTopicsList->getItemNameAt(i); if (separatorReached && keyWord != "") addColorInString(text,keyWord,"#686EBA","#B29154"); else @@ -219,7 +219,7 @@ std::string DialogueWindow::parseText(std::string text) void DialogueWindow::addText(std::string text) { - history->addDialogText("#B29154"+parseText(text)+"#B29154"); + mHistory->addDialogText("#B29154"+parseText(text)+"#B29154"); } void DialogueWindow::addTitle(std::string text) @@ -227,37 +227,37 @@ void DialogueWindow::addTitle(std::string text) // This is called from the dialogue manager, so text is // case-smashed - thus we have to retrieve the correct case // of the text through the topic list. - for (size_t i=0; igetItemCount(); ++i) + for (size_t i=0; igetItemCount(); ++i) { - std::string item = topicsList->getItemNameAt(i); + std::string item = mTopicsList->getItemNameAt(i); if (lower_string(item) == text) text = item; } - history->addDialogHeading(text); + mHistory->addDialogHeading(text); } void DialogueWindow::askQuestion(std::string question) { - history->addDialogText("#572D21"+question+"#B29154"+" "); + mHistory->addDialogText("#572D21"+question+"#B29154"+" "); } void DialogueWindow::updateOptions() { //Clear the list of topics - topicsList->clear(); - history->eraseText(0,history->getTextLength()); + mTopicsList->clear(); + mHistory->eraseText(0, mHistory->getTextLength()); - pDispositionBar->setProgressRange(100); - pDispositionBar->setProgressPosition(40); - pDispositionText->eraseText(0,pDispositionText->getTextLength()); - pDispositionText->addText("#B29154"+std::string("40/100")+"#B29154"); + mDispositionBar->setProgressRange(100); + mDispositionBar->setProgressPosition(40); + mDispositionText->eraseText(0, mDispositionText->getTextLength()); + mDispositionText->addText("#B29154"+std::string("40/100")+"#B29154"); } void DialogueWindow::goodbye() { - history->addDialogText("\n#572D21" + MWBase::Environment::get().getWorld()->getStore().gameSettings.search("sGoodbye")->str); - topicsList->setEnabled(false); + mHistory->addDialogText("\n#572D21" + MWBase::Environment::get().getWorld()->getStore().gameSettings.search("sGoodbye")->str); + mTopicsList->setEnabled(false); mEnabled = false; } diff --git a/apps/openmw/mwgui/dialogue.hpp b/apps/openmw/mwgui/dialogue.hpp index 5d808b5a7..e2824bead 100644 --- a/apps/openmw/mwgui/dialogue.hpp +++ b/apps/openmw/mwgui/dialogue.hpp @@ -73,10 +73,10 @@ namespace MWGui bool mEnabled; - DialogueHistory* history; - Widgets::MWList* topicsList; - MyGUI::ProgressPtr pDispositionBar; - MyGUI::EditPtr pDispositionText; + DialogueHistory* mHistory; + Widgets::MWList* mTopicsList; + MyGUI::ProgressPtr mDispositionBar; + MyGUI::EditPtr mDispositionText; }; } #endif diff --git a/apps/openmw/mwgui/hud.cpp b/apps/openmw/mwgui/hud.cpp index 78eefa338..d2eef26ac 100644 --- a/apps/openmw/mwgui/hud.cpp +++ b/apps/openmw/mwgui/hud.cpp @@ -28,24 +28,24 @@ HUD::HUD(int width, int height, int fpsLevel, DragAndDrop* dragAndDrop) , health(NULL) , magicka(NULL) , stamina(NULL) - , weapImage(NULL) - , spellImage(NULL) - , weapStatus(NULL) - , spellStatus(NULL) - , effectBox(NULL) - , effect1(NULL) - , minimap(NULL) - , compass(NULL) - , crosshair(NULL) + , mWeapImage(NULL) + , mSpellImage(NULL) + , mWeapStatus(NULL) + , mSpellStatus(NULL) + , mEffectBox(NULL) + , mEffect1(NULL) + , mMinimap(NULL) + , mCompass(NULL) + , mCrosshair(NULL) , fpsbox(NULL) , fpscounter(NULL) , trianglecounter(NULL) , batchcounter(NULL) - , hmsBaseLeft(0) - , weapBoxBaseLeft(0) - , spellBoxBaseLeft(0) - , effectBoxBaseRight(0) - , minimapBoxBaseRight(0) + , mHealthManaStaminaBaseLeft(0) + , mWeapBoxBaseLeft(0) + , mSpellBoxBaseLeft(0) + , mEffectBoxBaseRight(0) + , mMinimapBoxBaseRight(0) , mDragAndDrop(dragAndDrop) , mCellNameTimer(0.0f) , mCellNameBox(NULL) @@ -62,7 +62,7 @@ HUD::HUD(int width, int height, int fpsLevel, DragAndDrop* dragAndDrop) getWidget(magicka, "Magicka"); getWidget(stamina, "Stamina"); - hmsBaseLeft = mHealthFrame->getLeft(); + mHealthManaStaminaBaseLeft = mHealthFrame->getLeft(); MyGUI::Widget *healthFrame, *magickaFrame, *fatigueFrame; getWidget(healthFrame, "HealthFrame"); @@ -75,33 +75,33 @@ HUD::HUD(int width, int height, int fpsLevel, DragAndDrop* dragAndDrop) const MyGUI::IntSize& viewSize = MyGUI::RenderManager::getInstance().getViewSize(); // Item and spell images and status bars - getWidget(weapBox, "WeapBox"); - getWidget(weapImage, "WeapImage"); - getWidget(weapStatus, "WeapStatus"); - weapBoxBaseLeft = weapBox->getLeft(); - weapBox->eventMouseButtonClick += MyGUI::newDelegate(this, &HUD::onWeaponClicked); - - getWidget(spellBox, "SpellBox"); - getWidget(spellImage, "SpellImage"); - getWidget(spellStatus, "SpellStatus"); - spellBoxBaseLeft = spellBox->getLeft(); - spellBox->eventMouseButtonClick += MyGUI::newDelegate(this, &HUD::onMagicClicked); - - getWidget(effectBox, "EffectBox"); - getWidget(effect1, "Effect1"); - effectBoxBaseRight = viewSize.width - effectBox->getRight(); - effectBox->eventMouseButtonClick += MyGUI::newDelegate(this, &HUD::onMagicClicked); - - getWidget(minimapBox, "MiniMapBox"); - minimapBoxBaseRight = viewSize.width - minimapBox->getRight(); - minimapBox->eventMouseButtonClick += MyGUI::newDelegate(this, &HUD::onMapClicked); - getWidget(minimap, "MiniMap"); - getWidget(compass, "Compass"); + getWidget(mWeapBox, "WeapBox"); + getWidget(mWeapImage, "WeapImage"); + getWidget(mWeapStatus, "WeapStatus"); + mWeapBoxBaseLeft = mWeapBox->getLeft(); + mWeapBox->eventMouseButtonClick += MyGUI::newDelegate(this, &HUD::onWeaponClicked); + + getWidget(mSpellBox, "SpellBox"); + getWidget(mSpellImage, "SpellImage"); + getWidget(mSpellStatus, "SpellStatus"); + mSpellBoxBaseLeft = mSpellBox->getLeft(); + mSpellBox->eventMouseButtonClick += MyGUI::newDelegate(this, &HUD::onMagicClicked); + + getWidget(mEffectBox, "EffectBox"); + getWidget(mEffect1, "Effect1"); + mEffectBoxBaseRight = viewSize.width - mEffectBox->getRight(); + mEffectBox->eventMouseButtonClick += MyGUI::newDelegate(this, &HUD::onMagicClicked); + + getWidget(mMinimapBox, "MiniMapBox"); + mMinimapBoxBaseRight = viewSize.width - mMinimapBox->getRight(); + mMinimapBox->eventMouseButtonClick += MyGUI::newDelegate(this, &HUD::onMapClicked); + getWidget(mMinimap, "MiniMap"); + getWidget(mCompass, "Compass"); getWidget(mCellNameBox, "CellName"); getWidget(mWeaponSpellBox, "WeaponSpellName"); - getWidget(crosshair, "Crosshair"); + getWidget(mCrosshair, "Crosshair"); setFpsLevel(fpsLevel); @@ -110,7 +110,7 @@ HUD::HUD(int width, int height, int fpsLevel, DragAndDrop* dragAndDrop) setEffect("icons\\s\\tx_s_chameleon.dds"); - LocalMapBase::init(minimap, compass, this); + LocalMapBase::init(mMinimap, mCompass, this); mMainWidget->eventMouseButtonClick += MyGUI::newDelegate(this, &HUD::onWorldClicked); mMainWidget->eventMouseMove += MyGUI::newDelegate(this, &HUD::onWorldMouseOver); @@ -159,7 +159,7 @@ void HUD::setBatchCount(unsigned int count) void HUD::setEffect(const char *img) { - effect1->setImageTexture(img); + mEffect1->setImageTexture(img); } void HUD::setValue(const std::string& id, const MWMechanics::DynamicStat& value) @@ -202,10 +202,10 @@ void HUD::setBottomLeftVisibility(bool hmsVisible, bool weapVisible, bool spellV { int weapDx = 0, spellDx = 0; if (!hmsVisible) - spellDx = weapDx = weapBoxBaseLeft - hmsBaseLeft; + spellDx = weapDx = mWeapBoxBaseLeft - mHealthManaStaminaBaseLeft; if (!weapVisible) - spellDx += spellBoxBaseLeft - weapBoxBaseLeft; + spellDx += mSpellBoxBaseLeft - mWeapBoxBaseLeft; mWeaponVisible = weapVisible; mSpellVisible = spellVisible; @@ -215,10 +215,10 @@ void HUD::setBottomLeftVisibility(bool hmsVisible, bool weapVisible, bool spellV health->setVisible(hmsVisible); stamina->setVisible(hmsVisible); magicka->setVisible(hmsVisible); - weapBox->setPosition(weapBoxBaseLeft - weapDx, weapBox->getTop()); - weapBox->setVisible(weapVisible); - spellBox->setPosition(spellBoxBaseLeft - spellDx, spellBox->getTop()); - spellBox->setVisible(spellVisible); + mWeapBox->setPosition(mWeapBoxBaseLeft - weapDx, mWeapBox->getTop()); + mWeapBox->setVisible(weapVisible); + mSpellBox->setPosition(mSpellBoxBaseLeft - spellDx, mSpellBox->getTop()); + mSpellBox->setVisible(spellVisible); } void HUD::setBottomRightVisibility(bool effectBoxVisible, bool minimapBoxVisible) @@ -228,12 +228,12 @@ void HUD::setBottomRightVisibility(bool effectBoxVisible, bool minimapBoxVisible // effect box can have variable width -> variable left coordinate int effectsDx = 0; if (!minimapBoxVisible) - effectsDx = (viewSize.width - minimapBoxBaseRight) - (viewSize.width - effectBoxBaseRight); + effectsDx = (viewSize.width - mMinimapBoxBaseRight) - (viewSize.width - mEffectBoxBaseRight); mMapVisible = minimapBoxVisible; - minimapBox->setVisible(minimapBoxVisible); - effectBox->setPosition((viewSize.width - effectBoxBaseRight) - effectBox->getWidth() + effectsDx, effectBox->getTop()); - effectBox->setVisible(effectBoxVisible); + mMinimapBox->setVisible(minimapBoxVisible); + mEffectBox->setPosition((viewSize.width - mEffectBoxBaseRight) - mEffectBox->getWidth() + effectsDx, mEffectBox->getTop()); + mEffectBox->setVisible(effectBoxVisible); } void HUD::onWorldClicked(MyGUI::Widget* _sender) @@ -395,14 +395,14 @@ void HUD::setSelectedSpell(const std::string& spellId, int successChancePercent) mWeaponSpellBox->setVisible(true); } - spellStatus->setProgressRange(100); - spellStatus->setProgressPosition(successChancePercent); + mSpellStatus->setProgressRange(100); + mSpellStatus->setProgressPosition(successChancePercent); - if (spellImage->getChildCount()) - MyGUI::Gui::getInstance().destroyWidget(spellImage->getChildAt(0)); + if (mSpellImage->getChildCount()) + MyGUI::Gui::getInstance().destroyWidget(mSpellImage->getChildAt(0)); - spellBox->setUserString("ToolTipType", "Spell"); - spellBox->setUserString("Spell", spellId); + mSpellBox->setUserString("ToolTipType", "Spell"); + mSpellBox->setUserString("Spell", spellId); // use the icon of the first effect const ESM::MagicEffect* effect = MWBase::Environment::get().getWorld()->getStore().magicEffects.find(spell->effects.list.front().effectID); @@ -411,7 +411,7 @@ void HUD::setSelectedSpell(const std::string& spellId, int successChancePercent) icon.insert(slashPos+1, "b_"); icon = std::string("icons\\") + icon; Widgets::fixTexturePath(icon); - spellImage->setImageTexture(icon); + mSpellImage->setImageTexture(icon); } void HUD::setSelectedEnchantItem(const MWWorld::Ptr& item, int chargePercent) @@ -425,17 +425,17 @@ void HUD::setSelectedEnchantItem(const MWWorld::Ptr& item, int chargePercent) mWeaponSpellBox->setVisible(true); } - spellStatus->setProgressRange(100); - spellStatus->setProgressPosition(chargePercent); + mSpellStatus->setProgressRange(100); + mSpellStatus->setProgressPosition(chargePercent); - if (spellImage->getChildCount()) - MyGUI::Gui::getInstance().destroyWidget(spellImage->getChildAt(0)); + if (mSpellImage->getChildCount()) + MyGUI::Gui::getInstance().destroyWidget(mSpellImage->getChildAt(0)); - spellBox->setUserString("ToolTipType", "ItemPtr"); - spellBox->setUserData(item); + mSpellBox->setUserString("ToolTipType", "ItemPtr"); + mSpellBox->setUserData(item); - spellImage->setImageTexture("textures\\menu_icon_magic_mini.dds"); - MyGUI::ImageBox* itemBox = spellImage->createWidgetReal("ImageBox", MyGUI::FloatCoord(0,0,1,1) + mSpellImage->setImageTexture("textures\\menu_icon_magic_mini.dds"); + MyGUI::ImageBox* itemBox = mSpellImage->createWidgetReal("ImageBox", MyGUI::FloatCoord(0,0,1,1) , MyGUI::Align::Stretch); std::string path = std::string("icons\\"); @@ -456,14 +456,14 @@ void HUD::setSelectedWeapon(const MWWorld::Ptr& item, int durabilityPercent) mWeaponSpellBox->setVisible(true); } - weapBox->setUserString("ToolTipType", "ItemPtr"); - weapBox->setUserData(item); + mWeapBox->setUserString("ToolTipType", "ItemPtr"); + mWeapBox->setUserData(item); - weapStatus->setProgressRange(100); - weapStatus->setProgressPosition(durabilityPercent); + mWeapStatus->setProgressRange(100); + mWeapStatus->setProgressPosition(durabilityPercent); - if (weapImage->getChildCount()) - MyGUI::Gui::getInstance().destroyWidget(weapImage->getChildAt(0)); + if (mWeapImage->getChildCount()) + MyGUI::Gui::getInstance().destroyWidget(mWeapImage->getChildAt(0)); std::string path = std::string("icons\\"); path+=MWWorld::Class::get(item).getInventoryIcon(item); @@ -471,14 +471,14 @@ void HUD::setSelectedWeapon(const MWWorld::Ptr& item, int durabilityPercent) if (MWWorld::Class::get(item).getEnchantment(item) != "") { - weapImage->setImageTexture("textures\\menu_icon_magic_mini.dds"); - MyGUI::ImageBox* itemBox = weapImage->createWidgetReal("ImageBox", MyGUI::FloatCoord(0,0,1,1) + mWeapImage->setImageTexture("textures\\menu_icon_magic_mini.dds"); + MyGUI::ImageBox* itemBox = mWeapImage->createWidgetReal("ImageBox", MyGUI::FloatCoord(0,0,1,1) , MyGUI::Align::Stretch); itemBox->setImageTexture(path); itemBox->setNeedMouseFocus(false); } else - weapImage->setImageTexture(path); + mWeapImage->setImageTexture(path); } void HUD::unsetSelectedSpell() @@ -492,12 +492,12 @@ void HUD::unsetSelectedSpell() mWeaponSpellBox->setVisible(true); } - if (spellImage->getChildCount()) - MyGUI::Gui::getInstance().destroyWidget(spellImage->getChildAt(0)); - spellStatus->setProgressRange(100); - spellStatus->setProgressPosition(0); - spellImage->setImageTexture(""); - spellBox->clearUserStrings(); + if (mSpellImage->getChildCount()) + MyGUI::Gui::getInstance().destroyWidget(mSpellImage->getChildAt(0)); + mSpellStatus->setProgressRange(100); + mSpellStatus->setProgressPosition(0); + mSpellImage->setImageTexture(""); + mSpellBox->clearUserStrings(); } void HUD::unsetSelectedWeapon() @@ -511,10 +511,10 @@ void HUD::unsetSelectedWeapon() mWeaponSpellBox->setVisible(true); } - if (weapImage->getChildCount()) - MyGUI::Gui::getInstance().destroyWidget(weapImage->getChildAt(0)); - weapStatus->setProgressRange(100); - weapStatus->setProgressPosition(0); - weapImage->setImageTexture("icons\\k\\stealth_handtohand.dds"); - weapBox->clearUserStrings(); + if (mWeapImage->getChildCount()) + MyGUI::Gui::getInstance().destroyWidget(mWeapImage->getChildAt(0)); + mWeapStatus->setProgressRange(100); + mWeapStatus->setProgressPosition(0); + mWeapImage->setImageTexture("icons\\k\\stealth_handtohand.dds"); + mWeapBox->clearUserStrings(); } diff --git a/apps/openmw/mwgui/hud.hpp b/apps/openmw/mwgui/hud.hpp index c6bcdd4e9..485c788fc 100644 --- a/apps/openmw/mwgui/hud.hpp +++ b/apps/openmw/mwgui/hud.hpp @@ -37,14 +37,14 @@ namespace MWGui MyGUI::ProgressPtr health, magicka, stamina; MyGUI::Widget* mHealthFrame; - MyGUI::Widget *weapBox, *spellBox; - MyGUI::ImageBox *weapImage, *spellImage; - MyGUI::ProgressPtr weapStatus, spellStatus; - MyGUI::Widget *effectBox, *minimapBox; - MyGUI::ImageBox* effect1; - MyGUI::ScrollView* minimap; - MyGUI::ImageBox* compass; - MyGUI::ImageBox* crosshair; + MyGUI::Widget *mWeapBox, *mSpellBox; + MyGUI::ImageBox *mWeapImage, *mSpellImage; + MyGUI::ProgressPtr mWeapStatus, mSpellStatus; + MyGUI::Widget *mEffectBox, *mMinimapBox; + MyGUI::ImageBox* mEffect1; + MyGUI::ScrollView* mMinimap; + MyGUI::ImageBox* mCompass; + MyGUI::ImageBox* mCrosshair; MyGUI::TextBox* mCellNameBox; MyGUI::TextBox* mWeaponSpellBox; @@ -55,9 +55,9 @@ namespace MWGui private: // bottom left elements - int hmsBaseLeft, weapBoxBaseLeft, spellBoxBaseLeft; + int mHealthManaStaminaBaseLeft, mWeapBoxBaseLeft, mSpellBoxBaseLeft; // bottom right elements - int minimapBoxBaseRight, effectBoxBaseRight; + int mMinimapBoxBaseRight, mEffectBoxBaseRight; DragAndDrop* mDragAndDrop; diff --git a/apps/openmw/mwgui/journalwindow.cpp b/apps/openmw/mwgui/journalwindow.cpp index 75b546c7b..8b50c9ef1 100644 --- a/apps/openmw/mwgui/journalwindow.cpp +++ b/apps/openmw/mwgui/journalwindow.cpp @@ -84,7 +84,7 @@ book formatText(std::string text,book mBook,int maxLine, int lineSize) MWGui::JournalWindow::JournalWindow (WindowManager& parWindowManager) : WindowBase("openmw_journal.layout", parWindowManager) - , lastPos(0) + , mLastPos(0) , mVisible(false) { //setCoord(0,0,498, 342); @@ -148,19 +148,19 @@ void MWGui::JournalWindow::open() { if(left) { - leftPages.push_back(*it); + mLeftPages.push_back(*it); } else { - rightPages.push_back(*it); + mRightPages.push_back(*it); } left = !left; } - if(!left) rightPages.push_back(""); + if(!left) mRightPages.push_back(""); - mPageNumber = leftPages.size()-1; - displayLeftText(leftPages[mPageNumber]); - displayRightText(rightPages[mPageNumber]); + mPageNumber = mLeftPages.size()-1; + displayLeftText(mLeftPages[mPageNumber]); + displayRightText(mRightPages[mPageNumber]); } else @@ -184,13 +184,13 @@ void MWGui::JournalWindow::displayRightText(std::string text) void MWGui::JournalWindow::notifyNextPage(MyGUI::WidgetPtr _sender) { - if(mPageNumber < int(leftPages.size())-1) + if(mPageNumber < int(mLeftPages.size())-1) { std::string nextSound = "book page2"; MWBase::Environment::get().getSoundManager()->playSound (nextSound, 1.0, 1.0); mPageNumber = mPageNumber + 1; - displayLeftText(leftPages[mPageNumber]); - displayRightText(rightPages[mPageNumber]); + displayLeftText(mLeftPages[mPageNumber]); + displayRightText(mRightPages[mPageNumber]); } } @@ -201,7 +201,7 @@ void MWGui::JournalWindow::notifyPrevPage(MyGUI::WidgetPtr _sender) std::string prevSound = "book page"; MWBase::Environment::get().getSoundManager()->playSound (prevSound, 1.0, 1.0); mPageNumber = mPageNumber - 1; - displayLeftText(leftPages[mPageNumber]); - displayRightText(rightPages[mPageNumber]); + displayLeftText(mLeftPages[mPageNumber]); + displayRightText(mRightPages[mPageNumber]); } } diff --git a/apps/openmw/mwgui/journalwindow.hpp b/apps/openmw/mwgui/journalwindow.hpp index cacdb9414..0c85ebf08 100644 --- a/apps/openmw/mwgui/journalwindow.hpp +++ b/apps/openmw/mwgui/journalwindow.hpp @@ -31,17 +31,17 @@ namespace MWGui void notifyNextPage(MyGUI::WidgetPtr _sender); void notifyPrevPage(MyGUI::WidgetPtr _sender); - static const int lineHeight; + static const int sLineHeight; - MyGUI::WidgetPtr skillAreaWidget, skillClientWidget; - MyGUI::ScrollBar* skillScrollerWidget; - int lastPos, clientHeight; + MyGUI::WidgetPtr mSkillAreaWidget, mSkillClientWidget; + MyGUI::ScrollBar* mSkillScrollerWidget; + int mLastPos, mClientHeight; MyGUI::EditPtr mLeftTextWidget; MyGUI::EditPtr mRightTextWidget; MyGUI::ButtonPtr mPrevBtn; MyGUI::ButtonPtr mNextBtn; - std::vector leftPages; - std::vector rightPages; + std::vector mLeftPages; + std::vector mRightPages; int mPageNumber; //store the number of the current left page bool mVisible; }; diff --git a/apps/openmw/mwgui/messagebox.cpp b/apps/openmw/mwgui/messagebox.cpp index 68326a3c3..2b00ca05c 100644 --- a/apps/openmw/mwgui/messagebox.cpp +++ b/apps/openmw/mwgui/messagebox.cpp @@ -149,7 +149,7 @@ int MessageBoxManager::readPressedButton () MessageBox::MessageBox(MessageBoxManager& parMessageBoxManager, const std::string& message) : Layout("openmw_messagebox.layout") , mMessageBoxManager(parMessageBoxManager) - , cMessage(message) + , mMessage(message) { // defines mFixedWidth = 300; @@ -160,7 +160,7 @@ MessageBox::MessageBox(MessageBoxManager& parMessageBoxManager, const std::strin getWidget(mMessageWidget, "message"); mMessageWidget->setOverflowToTheLeft(true); - mMessageWidget->setCaptionWithReplacing(cMessage); + mMessageWidget->setCaptionWithReplacing(mMessage); MyGUI::IntSize size; size.width = mFixedWidth; diff --git a/apps/openmw/mwgui/messagebox.hpp b/apps/openmw/mwgui/messagebox.hpp index 33155b2a0..75393ec94 100644 --- a/apps/openmw/mwgui/messagebox.hpp +++ b/apps/openmw/mwgui/messagebox.hpp @@ -59,7 +59,7 @@ namespace MWGui protected: MessageBoxManager& mMessageBoxManager; int mHeight; - const std::string& cMessage; + const std::string& mMessage; MyGUI::EditPtr mMessageWidget; int mFixedWidth; int mBottomPadding; diff --git a/apps/openmw/mwgui/race.cpp b/apps/openmw/mwgui/race.cpp index 9ae453016..dd11ec011 100644 --- a/apps/openmw/mwgui/race.cpp +++ b/apps/openmw/mwgui/race.cpp @@ -18,11 +18,11 @@ using namespace Widgets; RaceDialog::RaceDialog(WindowManager& parWindowManager) : WindowBase("openmw_chargen_race.layout", parWindowManager) - , genderIndex(0) - , faceIndex(0) - , hairIndex(0) - , faceCount(10) - , hairCount(14) + , mGenderIndex(0) + , mFaceIndex(0) + , mHairIndex(0) + , mFaceCount(10) + , mHairCount(14) { // Centre dialog center(); @@ -31,13 +31,13 @@ RaceDialog::RaceDialog(WindowManager& parWindowManager) // real calls from outside the class later. setText("AppearanceT", mWindowManager.getGameSettingString("sRaceMenu1", "Appearance")); - getWidget(appearanceBox, "AppearanceBox"); + getWidget(mAppearanceBox, "AppearanceBox"); - getWidget(headRotate, "HeadRotate"); - headRotate->setScrollRange(50); - headRotate->setScrollPosition(20); - headRotate->setScrollViewPage(10); - headRotate->eventScrollChangePosition += MyGUI::newDelegate(this, &RaceDialog::onHeadRotate); + getWidget(mHeadRotate, "HeadRotate"); + mHeadRotate->setScrollRange(50); + mHeadRotate->setScrollPosition(20); + mHeadRotate->setScrollViewPage(10); + mHeadRotate->eventScrollChangePosition += MyGUI::newDelegate(this, &RaceDialog::onHeadRotate); // Set up next/previous buttons MyGUI::ButtonPtr prevButton, nextButton; @@ -61,16 +61,16 @@ RaceDialog::RaceDialog(WindowManager& parWindowManager) nextButton->eventMouseButtonClick += MyGUI::newDelegate(this, &RaceDialog::onSelectNextHair); setText("RaceT", mWindowManager.getGameSettingString("sRaceMenu4", "Race")); - getWidget(raceList, "RaceList"); - raceList->setScrollVisible(true); - raceList->eventListSelectAccept += MyGUI::newDelegate(this, &RaceDialog::onSelectRace); - raceList->eventListMouseItemActivate += MyGUI::newDelegate(this, &RaceDialog::onSelectRace); - raceList->eventListChangePosition += MyGUI::newDelegate(this, &RaceDialog::onSelectRace); + getWidget(mRaceList, "RaceList"); + mRaceList->setScrollVisible(true); + mRaceList->eventListSelectAccept += MyGUI::newDelegate(this, &RaceDialog::onSelectRace); + mRaceList->eventListMouseItemActivate += MyGUI::newDelegate(this, &RaceDialog::onSelectRace); + mRaceList->eventListChangePosition += MyGUI::newDelegate(this, &RaceDialog::onSelectRace); setText("SkillsT", mWindowManager.getGameSettingString("sBonusSkillTitle", "Skill Bonus")); - getWidget(skillList, "SkillList"); + getWidget(mSkillList, "SkillList"); setText("SpellPowerT", mWindowManager.getGameSettingString("sRaceMenu7", "Specials")); - getWidget(spellPowerList, "SpellPowerList"); + getWidget(mSpellPowerList, "SpellPowerList"); MyGUI::ButtonPtr backButton; getWidget(backButton, "BackButton"); @@ -117,14 +117,14 @@ void RaceDialog::open() void RaceDialog::setRaceId(const std::string &raceId) { - currentRaceId = raceId; - raceList->setIndexSelected(MyGUI::ITEM_NONE); - size_t count = raceList->getItemCount(); + mCurrentRaceId = raceId; + mRaceList->setIndexSelected(MyGUI::ITEM_NONE); + size_t count = mRaceList->getItemCount(); for (size_t i = 0; i < count; ++i) { - if (boost::iequals(*raceList->getItemDataAt(i), raceId)) + if (boost::iequals(*mRaceList->getItemDataAt(i), raceId)) { - raceList->setIndexSelected(i); + mRaceList->setIndexSelected(i); break; } } @@ -162,32 +162,32 @@ void RaceDialog::onHeadRotate(MyGUI::ScrollBar*, size_t _position) void RaceDialog::onSelectPreviousGender(MyGUI::Widget*) { - genderIndex = wrap(genderIndex - 1, 2); + mGenderIndex = wrap(mGenderIndex - 1, 2); } void RaceDialog::onSelectNextGender(MyGUI::Widget*) { - genderIndex = wrap(genderIndex + 1, 2); + mGenderIndex = wrap(mGenderIndex + 1, 2); } void RaceDialog::onSelectPreviousFace(MyGUI::Widget*) { - faceIndex = wrap(faceIndex - 1, faceCount); + mFaceIndex = wrap(mFaceIndex - 1, mFaceCount); } void RaceDialog::onSelectNextFace(MyGUI::Widget*) { - faceIndex = wrap(faceIndex + 1, faceCount); + mFaceIndex = wrap(mFaceIndex + 1, mFaceCount); } void RaceDialog::onSelectPreviousHair(MyGUI::Widget*) { - hairIndex = wrap(hairIndex - 1, hairCount); + mHairIndex = wrap(mHairIndex - 1, mHairCount); } void RaceDialog::onSelectNextHair(MyGUI::Widget*) { - hairIndex = wrap(hairIndex - 1, hairCount); + mHairIndex = wrap(mHairIndex - 1, mHairCount); } void RaceDialog::onSelectRace(MyGUI::ListBox* _sender, size_t _index) @@ -195,11 +195,11 @@ void RaceDialog::onSelectRace(MyGUI::ListBox* _sender, size_t _index) if (_index == MyGUI::ITEM_NONE) return; - const std::string *raceId = raceList->getItemDataAt(_index); - if (boost::iequals(currentRaceId, *raceId)) + const std::string *raceId = mRaceList->getItemDataAt(_index); + if (boost::iequals(mCurrentRaceId, *raceId)) return; - currentRaceId = *raceId; + mCurrentRaceId = *raceId; updateSkills(); updateSpellPowers(); } @@ -208,7 +208,7 @@ void RaceDialog::onSelectRace(MyGUI::ListBox* _sender, size_t _index) void RaceDialog::updateRaces() { - raceList->removeAllItems(); + mRaceList->removeAllItems(); const ESMS::ESMStore &store = mWindowManager.getStore(); @@ -222,30 +222,30 @@ void RaceDialog::updateRaces() if (!playable) // Only display playable races continue; - raceList->addItem(race.name, it->first); - if (boost::iequals(it->first, currentRaceId)) - raceList->setIndexSelected(index); + mRaceList->addItem(race.name, it->first); + if (boost::iequals(it->first, mCurrentRaceId)) + mRaceList->setIndexSelected(index); ++index; } } void RaceDialog::updateSkills() { - for (std::vector::iterator it = skillItems.begin(); it != skillItems.end(); ++it) + for (std::vector::iterator it = mSkillItems.begin(); it != mSkillItems.end(); ++it) { MyGUI::Gui::getInstance().destroyWidget(*it); } - skillItems.clear(); + mSkillItems.clear(); - if (currentRaceId.empty()) + if (mCurrentRaceId.empty()) return; MWSkillPtr skillWidget; const int lineHeight = 18; - MyGUI::IntCoord coord1(0, 0, skillList->getWidth(), 18); + MyGUI::IntCoord coord1(0, 0, mSkillList->getWidth(), 18); const ESMS::ESMStore &store = mWindowManager.getStore(); - const ESM::Race *race = store.races.find(currentRaceId); + const ESM::Race *race = store.races.find(mCurrentRaceId); int count = sizeof(race->data.bonus)/sizeof(race->data.bonus[0]); // TODO: Find a portable macro for this ARRAYSIZE? for (int i = 0; i < count; ++i) { @@ -253,7 +253,7 @@ void RaceDialog::updateSkills() if (skillId < 0 || skillId > ESM::Skill::Length) // Skip unknown skill indexes continue; - skillWidget = skillList->createWidget("MW_StatNameValue", coord1, MyGUI::Align::Default, + skillWidget = mSkillList->createWidget("MW_StatNameValue", coord1, MyGUI::Align::Default, std::string("Skill") + boost::lexical_cast(i)); skillWidget->setWindowManager(&mWindowManager); skillWidget->setSkillNumber(skillId); @@ -261,7 +261,7 @@ void RaceDialog::updateSkills() ToolTips::createSkillToolTip(skillWidget, skillId); - skillItems.push_back(skillWidget); + mSkillItems.push_back(skillWidget); coord1.top += lineHeight; } @@ -269,34 +269,34 @@ void RaceDialog::updateSkills() void RaceDialog::updateSpellPowers() { - for (std::vector::iterator it = spellPowerItems.begin(); it != spellPowerItems.end(); ++it) + for (std::vector::iterator it = mSpellPowerItems.begin(); it != mSpellPowerItems.end(); ++it) { MyGUI::Gui::getInstance().destroyWidget(*it); } - spellPowerItems.clear(); + mSpellPowerItems.clear(); - if (currentRaceId.empty()) + if (mCurrentRaceId.empty()) return; MWSpellPtr spellPowerWidget; const int lineHeight = 18; - MyGUI::IntCoord coord(0, 0, spellPowerList->getWidth(), 18); + MyGUI::IntCoord coord(0, 0, mSpellPowerList->getWidth(), 18); const ESMS::ESMStore &store = mWindowManager.getStore(); - const ESM::Race *race = store.races.find(currentRaceId); + const ESM::Race *race = store.races.find(mCurrentRaceId); std::vector::const_iterator it = race->powers.list.begin(); std::vector::const_iterator end = race->powers.list.end(); for (int i = 0; it != end; ++it) { const std::string &spellpower = *it; - spellPowerWidget = spellPowerList->createWidget("MW_StatName", coord, MyGUI::Align::Default, std::string("SpellPower") + boost::lexical_cast(i)); + spellPowerWidget = mSpellPowerList->createWidget("MW_StatName", coord, MyGUI::Align::Default, std::string("SpellPower") + boost::lexical_cast(i)); spellPowerWidget->setWindowManager(&mWindowManager); spellPowerWidget->setSpellId(spellpower); spellPowerWidget->setUserString("ToolTipType", "Spell"); spellPowerWidget->setUserString("Spell", spellpower); - spellPowerItems.push_back(spellPowerWidget); + mSpellPowerItems.push_back(spellPowerWidget); coord.top += lineHeight; ++i; diff --git a/apps/openmw/mwgui/race.hpp b/apps/openmw/mwgui/race.hpp index 217ce15aa..b523b8690 100644 --- a/apps/openmw/mwgui/race.hpp +++ b/apps/openmw/mwgui/race.hpp @@ -32,13 +32,13 @@ namespace MWGui GM_Female }; - const std::string &getRaceId() const { return currentRaceId; } - Gender getGender() const { return genderIndex == 0 ? GM_Male : GM_Female; } + const std::string &getRaceId() const { return mCurrentRaceId; } + Gender getGender() const { return mGenderIndex == 0 ? GM_Male : GM_Female; } // getFace() // getHair() void setRaceId(const std::string &raceId); - void setGender(Gender gender) { genderIndex = gender == GM_Male ? 0 : 1; } + void setGender(Gender gender) { mGenderIndex = gender == GM_Male ? 0 : 1; } // setFace() // setHair() @@ -75,20 +75,20 @@ namespace MWGui void updateSkills(); void updateSpellPowers(); - MyGUI::CanvasPtr appearanceBox; - MyGUI::ListBox* raceList; - MyGUI::ScrollBar* headRotate; + MyGUI::CanvasPtr mAppearanceBox; + MyGUI::ListBox* mRaceList; + MyGUI::ScrollBar* mHeadRotate; - MyGUI::WidgetPtr skillList; - std::vector skillItems; + MyGUI::WidgetPtr mSkillList; + std::vector mSkillItems; - MyGUI::WidgetPtr spellPowerList; - std::vector spellPowerItems; + MyGUI::WidgetPtr mSpellPowerList; + std::vector mSpellPowerItems; - int genderIndex, faceIndex, hairIndex; - int faceCount, hairCount; + int mGenderIndex, mFaceIndex, mHairIndex; + int mFaceCount, mHairCount; - std::string currentRaceId; + std::string mCurrentRaceId; }; } #endif diff --git a/apps/openmw/mwgui/review.cpp b/apps/openmw/mwgui/review.cpp index f9792ea34..7061f65c1 100644 --- a/apps/openmw/mwgui/review.cpp +++ b/apps/openmw/mwgui/review.cpp @@ -17,49 +17,49 @@ using namespace MWGui; using namespace Widgets; -const int ReviewDialog::lineHeight = 18; +const int ReviewDialog::sLineHeight = 18; ReviewDialog::ReviewDialog(WindowManager& parWindowManager) : WindowBase("openmw_chargen_review.layout", parWindowManager) - , lastPos(0) + , mLastPos(0) { // Centre dialog center(); // Setup static stats ButtonPtr button; - getWidget(nameWidget, "NameText"); + getWidget(mNameWidget, "NameText"); getWidget(button, "NameButton"); adjustButtonSize(button); button->eventMouseButtonClick += MyGUI::newDelegate(this, &ReviewDialog::onNameClicked);; - getWidget(raceWidget, "RaceText"); + getWidget(mRaceWidget, "RaceText"); getWidget(button, "RaceButton"); adjustButtonSize(button); button->eventMouseButtonClick += MyGUI::newDelegate(this, &ReviewDialog::onRaceClicked);; - getWidget(classWidget, "ClassText"); + getWidget(mClassWidget, "ClassText"); getWidget(button, "ClassButton"); adjustButtonSize(button); button->eventMouseButtonClick += MyGUI::newDelegate(this, &ReviewDialog::onClassClicked);; - getWidget(birthSignWidget, "SignText"); + getWidget(mBirthSignWidget, "SignText"); getWidget(button, "SignButton"); adjustButtonSize(button); button->eventMouseButtonClick += MyGUI::newDelegate(this, &ReviewDialog::onBirthSignClicked);; // Setup dynamic stats - getWidget(health, "Health"); - health->setTitle(mWindowManager.getGameSettingString("sHealth", "")); - health->setValue(45, 45); + getWidget(mHealth, "Health"); + mHealth->setTitle(mWindowManager.getGameSettingString("sHealth", "")); + mHealth->setValue(45, 45); - getWidget(magicka, "Magicka"); - magicka->setTitle(mWindowManager.getGameSettingString("sMagic", "")); - magicka->setValue(50, 50); + getWidget(mMagicka, "Magicka"); + mMagicka->setTitle(mWindowManager.getGameSettingString("sMagic", "")); + mMagicka->setValue(50, 50); - getWidget(fatigue, "Fatigue"); - fatigue->setTitle(mWindowManager.getGameSettingString("sFatigue", "")); - fatigue->setValue(160, 160); + getWidget(mFatigue, "Fatigue"); + mFatigue->setTitle(mWindowManager.getGameSettingString("sFatigue", "")); + mFatigue->setValue(160, 160); // Setup attributes @@ -67,24 +67,24 @@ ReviewDialog::ReviewDialog(WindowManager& parWindowManager) for (int idx = 0; idx < ESM::Attribute::Length; ++idx) { getWidget(attribute, std::string("Attribute") + boost::lexical_cast(idx)); - attributeWidgets.insert(std::make_pair(static_cast(ESM::Attribute::attributeIds[idx]), attribute)); + mAttributeWidgets.insert(std::make_pair(static_cast(ESM::Attribute::attributeIds[idx]), attribute)); attribute->setWindowManager(&mWindowManager); attribute->setAttributeId(ESM::Attribute::attributeIds[idx]); attribute->setAttributeValue(MWAttribute::AttributeValue(0, 0)); } // Setup skills - getWidget(skillAreaWidget, "Skills"); - getWidget(skillClientWidget, "SkillClient"); - getWidget(skillScrollerWidget, "SkillScroller"); - skillClientWidget->eventMouseWheel += MyGUI::newDelegate(this, &ReviewDialog::onMouseWheel); - skillScrollerWidget->eventScrollChangePosition += MyGUI::newDelegate(this, &ReviewDialog::onScrollChangePosition); + getWidget(mSkillAreaWidget, "Skills"); + getWidget(mSkillClientWidget, "SkillClient"); + getWidget(mSkillScrollerWidget, "SkillScroller"); + mSkillClientWidget->eventMouseWheel += MyGUI::newDelegate(this, &ReviewDialog::onMouseWheel); + mSkillScrollerWidget->eventScrollChangePosition += MyGUI::newDelegate(this, &ReviewDialog::onScrollChangePosition); updateScroller(); for (int i = 0; i < ESM::Skill::Length; ++i) { - skillValues.insert(std::make_pair(i, MWMechanics::Stat())); - skillWidgetMap.insert(std::make_pair(i, static_cast (0))); + mSkillValues.insert(std::make_pair(i, MWMechanics::Stat())); + mSkillWidgetMap.insert(std::make_pair(i, static_cast (0))); } static_cast(mMainWidget)->eventWindowChangeCoord += MyGUI::newDelegate(this, &ReviewDialog::onWindowResize); @@ -112,14 +112,14 @@ void ReviewDialog::open() void ReviewDialog::onScrollChangePosition(MyGUI::ScrollBar* scroller, size_t pos) { - int diff = lastPos - pos; + int diff = mLastPos - pos; // Adjust position of all widget according to difference if (diff == 0) return; - lastPos = pos; + mLastPos = pos; - std::vector::const_iterator end = skillWidgets.end(); - for (std::vector::const_iterator it = skillWidgets.begin(); it != end; ++it) + std::vector::const_iterator end = mSkillWidgets.end(); + for (std::vector::const_iterator it = mSkillWidgets.begin(); it != end; ++it) { (*it)->setCoord((*it)->getCoord() + MyGUI::IntPoint(0, diff)); } @@ -132,63 +132,63 @@ void ReviewDialog::onWindowResize(MyGUI::Window* window) void ReviewDialog::setPlayerName(const std::string &name) { - nameWidget->setCaption(name); + mNameWidget->setCaption(name); } -void ReviewDialog::setRace(const std::string &raceId_) +void ReviewDialog::setRace(const std::string &raceId) { - raceId = raceId_; - const ESM::Race *race = mWindowManager.getStore().races.search(raceId); + mRaceId = raceId; + const ESM::Race *race = mWindowManager.getStore().races.search(mRaceId); if (race) { - ToolTips::createRaceToolTip(raceWidget, race); - raceWidget->setCaption(race->name); + ToolTips::createRaceToolTip(mRaceWidget, race); + mRaceWidget->setCaption(race->name); } } void ReviewDialog::setClass(const ESM::Class& class_) { - klass = class_; - classWidget->setCaption(klass.name); - ToolTips::createClassToolTip(classWidget, klass); + mKlass = class_; + mClassWidget->setCaption(mKlass.name); + ToolTips::createClassToolTip(mClassWidget, mKlass); } void ReviewDialog::setBirthSign(const std::string& signId) { - birthSignId = signId; - const ESM::BirthSign *sign = mWindowManager.getStore().birthSigns.search(birthSignId); + mBirthSignId = signId; + const ESM::BirthSign *sign = mWindowManager.getStore().birthSigns.search(mBirthSignId); if (sign) { - birthSignWidget->setCaption(sign->name); - ToolTips::createBirthsignToolTip(birthSignWidget, birthSignId); + mBirthSignWidget->setCaption(sign->name); + ToolTips::createBirthsignToolTip(mBirthSignWidget, mBirthSignId); } } void ReviewDialog::setHealth(const MWMechanics::DynamicStat& value) { - health->setValue(value.getCurrent(), value.getModified()); + mHealth->setValue(value.getCurrent(), value.getModified()); std::string valStr = boost::lexical_cast(value.getCurrent()) + "/" + boost::lexical_cast(value.getModified()); - health->setUserString("Caption_HealthDescription", "#{sHealthDesc}\n" + valStr); + mHealth->setUserString("Caption_HealthDescription", "#{sHealthDesc}\n" + valStr); } void ReviewDialog::setMagicka(const MWMechanics::DynamicStat& value) { - magicka->setValue(value.getCurrent(), value.getModified()); + mMagicka->setValue(value.getCurrent(), value.getModified()); std::string valStr = boost::lexical_cast(value.getCurrent()) + "/" + boost::lexical_cast(value.getModified()); - magicka->setUserString("Caption_HealthDescription", "#{sIntDesc}\n" + valStr); + mMagicka->setUserString("Caption_HealthDescription", "#{sIntDesc}\n" + valStr); } void ReviewDialog::setFatigue(const MWMechanics::DynamicStat& value) { - fatigue->setValue(value.getCurrent(), value.getModified()); + mFatigue->setValue(value.getCurrent(), value.getModified()); std::string valStr = boost::lexical_cast(value.getCurrent()) + "/" + boost::lexical_cast(value.getModified()); - fatigue->setUserString("Caption_HealthDescription", "#{sFatDesc}\n" + valStr); + mFatigue->setUserString("Caption_HealthDescription", "#{sFatDesc}\n" + valStr); } void ReviewDialog::setAttribute(ESM::Attribute::AttributeID attributeId, const MWMechanics::Stat& value) { - std::map::iterator attr = attributeWidgets.find(static_cast(attributeId)); - if (attr == attributeWidgets.end()) + std::map::iterator attr = mAttributeWidgets.find(static_cast(attributeId)); + if (attr == mAttributeWidgets.end()) return; attr->second->setAttributeValue(value); @@ -196,8 +196,8 @@ void ReviewDialog::setAttribute(ESM::Attribute::AttributeID attributeId, const M void ReviewDialog::setSkillValue(ESM::Skill::SkillEnum skillId, const MWMechanics::Stat& value) { - skillValues[skillId] = value; - MyGUI::TextBox* widget = skillWidgetMap[skillId]; + mSkillValues[skillId] = value; + MyGUI::TextBox* widget = mSkillWidgetMap[skillId]; if (widget) { float modified = value.getModified(), base = value.getBase(); @@ -216,20 +216,20 @@ void ReviewDialog::setSkillValue(ESM::Skill::SkillEnum skillId, const MWMechanic void ReviewDialog::configureSkills(const std::vector& major, const std::vector& minor) { - majorSkills = major; - minorSkills = minor; + mMajorSkills = major; + mMinorSkills = minor; // Update misc skills with the remaining skills not in major or minor std::set skillSet; std::copy(major.begin(), major.end(), std::inserter(skillSet, skillSet.begin())); std::copy(minor.begin(), minor.end(), std::inserter(skillSet, skillSet.begin())); boost::array::const_iterator end = ESM::Skill::skillIds.end(); - miscSkills.clear(); + mMiscSkills.clear(); for (boost::array::const_iterator it = ESM::Skill::skillIds.begin(); it != end; ++it) { int skill = *it; if (skillSet.find(skill) == skillSet.end()) - miscSkills.push_back(skill); + mMiscSkills.push_back(skill); } updateSkillArea(); @@ -237,10 +237,10 @@ void ReviewDialog::configureSkills(const std::vector& major, const std::vec void ReviewDialog::addSeparator(MyGUI::IntCoord &coord1, MyGUI::IntCoord &coord2) { - MyGUI::ImageBox* separator = skillClientWidget->createWidget("MW_HLine", MyGUI::IntCoord(10, coord1.top, coord1.width + coord2.width - 4, 18), MyGUI::Align::Default); + MyGUI::ImageBox* separator = mSkillClientWidget->createWidget("MW_HLine", MyGUI::IntCoord(10, coord1.top, coord1.width + coord2.width - 4, 18), MyGUI::Align::Default); separator->eventMouseWheel += MyGUI::newDelegate(this, &ReviewDialog::onMouseWheel); - skillWidgets.push_back(separator); + mSkillWidgets.push_back(separator); coord1.top += separator->getHeight(); coord2.top += separator->getHeight(); @@ -248,13 +248,13 @@ void ReviewDialog::addSeparator(MyGUI::IntCoord &coord1, MyGUI::IntCoord &coord2 void ReviewDialog::addGroup(const std::string &label, MyGUI::IntCoord &coord1, MyGUI::IntCoord &coord2) { - MyGUI::TextBox* groupWidget = skillClientWidget->createWidget("SandBrightText", MyGUI::IntCoord(0, coord1.top, coord1.width + coord2.width, coord1.height), MyGUI::Align::Default); + MyGUI::TextBox* groupWidget = mSkillClientWidget->createWidget("SandBrightText", MyGUI::IntCoord(0, coord1.top, coord1.width + coord2.width, coord1.height), MyGUI::Align::Default); groupWidget->eventMouseWheel += MyGUI::newDelegate(this, &ReviewDialog::onMouseWheel); groupWidget->setCaption(label); - skillWidgets.push_back(groupWidget); + mSkillWidgets.push_back(groupWidget); - coord1.top += lineHeight; - coord2.top += lineHeight; + coord1.top += sLineHeight; + coord2.top += sLineHeight; } MyGUI::TextBox* ReviewDialog::addValueItem(const std::string& text, const std::string &value, const std::string& state, MyGUI::IntCoord &coord1, MyGUI::IntCoord &coord2) @@ -262,20 +262,20 @@ MyGUI::TextBox* ReviewDialog::addValueItem(const std::string& text, const std::s MyGUI::TextBox* skillNameWidget; MyGUI::TextBox* skillValueWidget; - skillNameWidget = skillClientWidget->createWidget("SandText", coord1, MyGUI::Align::Default); + skillNameWidget = mSkillClientWidget->createWidget("SandText", coord1, MyGUI::Align::Default); skillNameWidget->setCaption(text); skillNameWidget->eventMouseWheel += MyGUI::newDelegate(this, &ReviewDialog::onMouseWheel); - skillValueWidget = skillClientWidget->createWidget("SandTextRight", coord2, MyGUI::Align::Top | MyGUI::Align::Right); + skillValueWidget = mSkillClientWidget->createWidget("SandTextRight", coord2, MyGUI::Align::Top | MyGUI::Align::Right); skillValueWidget->setCaption(value); skillValueWidget->_setWidgetState(state); skillValueWidget->eventMouseWheel += MyGUI::newDelegate(this, &ReviewDialog::onMouseWheel); - skillWidgets.push_back(skillNameWidget); - skillWidgets.push_back(skillValueWidget); + mSkillWidgets.push_back(skillNameWidget); + mSkillWidgets.push_back(skillValueWidget); - coord1.top += lineHeight; - coord2.top += lineHeight; + coord1.top += sLineHeight; + coord2.top += sLineHeight; return skillValueWidget; } @@ -284,20 +284,20 @@ void ReviewDialog::addItem(const std::string& text, MyGUI::IntCoord &coord1, MyG { MyGUI::TextBox* skillNameWidget; - skillNameWidget = skillClientWidget->createWidget("SandText", coord1 + MyGUI::IntSize(coord2.width, 0), MyGUI::Align::Default); + skillNameWidget = mSkillClientWidget->createWidget("SandText", coord1 + MyGUI::IntSize(coord2.width, 0), MyGUI::Align::Default); skillNameWidget->setCaption(text); skillNameWidget->eventMouseWheel += MyGUI::newDelegate(this, &ReviewDialog::onMouseWheel); - skillWidgets.push_back(skillNameWidget); + mSkillWidgets.push_back(skillNameWidget); - coord1.top += lineHeight; - coord2.top += lineHeight; + coord1.top += sLineHeight; + coord2.top += sLineHeight; } void ReviewDialog::addSkills(const SkillList &skills, const std::string &titleId, const std::string &titleDefault, MyGUI::IntCoord &coord1, MyGUI::IntCoord &coord2) { // Add a line separator if there are items above - if (!skillWidgets.empty()) + if (!mSkillWidgets.empty()) { addSeparator(coord1, coord2); } @@ -312,7 +312,7 @@ void ReviewDialog::addSkills(const SkillList &skills, const std::string &titleId continue; assert(skillId >= 0 && skillId < ESM::Skill::Length); const std::string &skillNameId = ESMS::Skill::sSkillNameIds[skillId]; - const MWMechanics::Stat &stat = skillValues.find(skillId)->second; + const MWMechanics::Stat &stat = mSkillValues.find(skillId)->second; float base = stat.getBase(); float modified = stat.getModified(); @@ -325,44 +325,44 @@ void ReviewDialog::addSkills(const SkillList &skills, const std::string &titleId for (int i=0; i<2; ++i) { - ToolTips::createSkillToolTip(skillWidgets[skillWidgets.size()-1-i], skillId); + ToolTips::createSkillToolTip(mSkillWidgets[mSkillWidgets.size()-1-i], skillId); } - skillWidgetMap[skillId] = widget; + mSkillWidgetMap[skillId] = widget; } } void ReviewDialog::updateSkillArea() { - for (std::vector::iterator it = skillWidgets.begin(); it != skillWidgets.end(); ++it) + for (std::vector::iterator it = mSkillWidgets.begin(); it != mSkillWidgets.end(); ++it) { MyGUI::Gui::getInstance().destroyWidget(*it); } - skillWidgets.clear(); + mSkillWidgets.clear(); const int valueSize = 40; - MyGUI::IntCoord coord1(10, 0, skillClientWidget->getWidth() - (10 + valueSize), 18); + MyGUI::IntCoord coord1(10, 0, mSkillClientWidget->getWidth() - (10 + valueSize), 18); MyGUI::IntCoord coord2(coord1.left + coord1.width, coord1.top, valueSize, coord1.height); - if (!majorSkills.empty()) - addSkills(majorSkills, "sSkillClassMajor", "Major Skills", coord1, coord2); + if (!mMajorSkills.empty()) + addSkills(mMajorSkills, "sSkillClassMajor", "Major Skills", coord1, coord2); - if (!minorSkills.empty()) - addSkills(minorSkills, "sSkillClassMinor", "Minor Skills", coord1, coord2); + if (!mMinorSkills.empty()) + addSkills(mMinorSkills, "sSkillClassMinor", "Minor Skills", coord1, coord2); - if (!miscSkills.empty()) - addSkills(miscSkills, "sSkillClassMisc", "Misc Skills", coord1, coord2); + if (!mMiscSkills.empty()) + addSkills(mMiscSkills, "sSkillClassMisc", "Misc Skills", coord1, coord2); - clientHeight = coord1.top; + mClientHeight = coord1.top; updateScroller(); } void ReviewDialog::updateScroller() { - skillScrollerWidget->setScrollRange(std::max(clientHeight - skillClientWidget->getHeight(), 0)); - skillScrollerWidget->setScrollPage(std::max(skillClientWidget->getHeight() - lineHeight, 0)); - if (clientHeight != 0) - skillScrollerWidget->setTrackSize( (skillAreaWidget->getHeight() / float(clientHeight)) * skillScrollerWidget->getLineSize() ); + mSkillScrollerWidget->setScrollRange(std::max(mClientHeight - mSkillClientWidget->getHeight(), 0)); + mSkillScrollerWidget->setScrollPage(std::max(mSkillClientWidget->getHeight() - sLineHeight, 0)); + if (mClientHeight != 0) + mSkillScrollerWidget->setTrackSize( (mSkillAreaWidget->getHeight() / float(mClientHeight)) * mSkillScrollerWidget->getLineSize() ); } // widget controls @@ -399,12 +399,12 @@ void ReviewDialog::onBirthSignClicked(MyGUI::Widget* _sender) void ReviewDialog::onMouseWheel(MyGUI::Widget* _sender, int _rel) { - if (skillScrollerWidget->getScrollPosition() - _rel*0.3 < 0) - skillScrollerWidget->setScrollPosition(0); - else if (skillScrollerWidget->getScrollPosition() - _rel*0.3 > skillScrollerWidget->getScrollRange()-1) - skillScrollerWidget->setScrollPosition(skillScrollerWidget->getScrollRange()-1); + if (mSkillScrollerWidget->getScrollPosition() - _rel*0.3 < 0) + mSkillScrollerWidget->setScrollPosition(0); + else if (mSkillScrollerWidget->getScrollPosition() - _rel*0.3 > mSkillScrollerWidget->getScrollRange()-1) + mSkillScrollerWidget->setScrollPosition(mSkillScrollerWidget->getScrollRange()-1); else - skillScrollerWidget->setScrollPosition(skillScrollerWidget->getScrollPosition() - _rel*0.3); + mSkillScrollerWidget->setScrollPosition(mSkillScrollerWidget->getScrollPosition() - _rel*0.3); - onScrollChangePosition(skillScrollerWidget, skillScrollerWidget->getScrollPosition()); + onScrollChangePosition(mSkillScrollerWidget, mSkillScrollerWidget->getScrollPosition()); } diff --git a/apps/openmw/mwgui/review.hpp b/apps/openmw/mwgui/review.hpp index 454a6c5a5..27b167033 100644 --- a/apps/openmw/mwgui/review.hpp +++ b/apps/openmw/mwgui/review.hpp @@ -82,23 +82,23 @@ namespace MWGui void onScrollChangePosition(MyGUI::ScrollBar* scroller, size_t pos); void onWindowResize(MyGUI::Window* window); - static const int lineHeight; + static const int sLineHeight; - MyGUI::TextBox *nameWidget, *raceWidget, *classWidget, *birthSignWidget; - MyGUI::WidgetPtr skillAreaWidget, skillClientWidget; - MyGUI::ScrollBar* skillScrollerWidget; - int lastPos, clientHeight; + MyGUI::TextBox *mNameWidget, *mRaceWidget, *mClassWidget, *mBirthSignWidget; + MyGUI::WidgetPtr mSkillAreaWidget, mSkillClientWidget; + MyGUI::ScrollBar* mSkillScrollerWidget; + int mLastPos, mClientHeight; - Widgets::MWDynamicStatPtr health, magicka, fatigue; + Widgets::MWDynamicStatPtr mHealth, mMagicka, mFatigue; - std::map attributeWidgets; + std::map mAttributeWidgets; - SkillList majorSkills, minorSkills, miscSkills; - std::map > skillValues; - std::map skillWidgetMap; - std::string name, raceId, birthSignId; - ESM::Class klass; - std::vector skillWidgets; //< Skills and other information + SkillList mMajorSkills, mMinorSkills, mMiscSkills; + std::map > mSkillValues; + std::map mSkillWidgetMap; + std::string mName, mRaceId, mBirthSignId; + ESM::Class mKlass; + std::vector mSkillWidgets; //< Skills and other information }; } #endif diff --git a/apps/openmw/mwgui/stats_window.cpp b/apps/openmw/mwgui/stats_window.cpp index 0f8b41b28..e7a74a9e1 100644 --- a/apps/openmw/mwgui/stats_window.cpp +++ b/apps/openmw/mwgui/stats_window.cpp @@ -19,26 +19,26 @@ using namespace MWGui; -const int StatsWindow::lineHeight = 18; +const int StatsWindow::sLineHeight = 18; StatsWindow::StatsWindow (WindowManager& parWindowManager) : WindowPinnableBase("openmw_stats_window.layout", parWindowManager) - , skillAreaWidget(NULL) - , skillClientWidget(NULL) - , skillScrollerWidget(NULL) - , lastPos(0) - , clientHeight(0) - , majorSkills() - , minorSkills() - , miscSkills() - , skillValues() - , skillWidgetMap() - , factionWidgetMap() + , mSkillAreaWidget(NULL) + , mSkillClientWidget(NULL) + , mSkillScrollerWidget(NULL) + , mLastPos(0) + , mClientHeight(0) + , mMajorSkills() + , mMinorSkills() + , mMiscSkills() + , mSkillValues() + , mSkillWidgetMap() + , mFactionWidgetMap() , mFactions() - , birthSignId() - , reputation(0) - , bounty(0) - , skillWidgets() + , mBirthSignId() + , mReputation(0) + , mBounty(0) + , mSkillWidgets() , mChanged(true) { setCoord(0,0,498, 342); @@ -62,21 +62,21 @@ StatsWindow::StatsWindow (WindowManager& parWindowManager) setText (names[i][0], store.gameSettings.find (names[i][1])->str); } - getWidget(skillAreaWidget, "Skills"); - getWidget(skillClientWidget, "SkillClient"); - getWidget(skillScrollerWidget, "SkillScroller"); + getWidget(mSkillAreaWidget, "Skills"); + getWidget(mSkillClientWidget, "SkillClient"); + getWidget(mSkillScrollerWidget, "SkillScroller"); getWidget(mLeftPane, "LeftPane"); getWidget(mRightPane, "RightPane"); - skillClientWidget->eventMouseWheel += MyGUI::newDelegate(this, &StatsWindow::onMouseWheel); + mSkillClientWidget->eventMouseWheel += MyGUI::newDelegate(this, &StatsWindow::onMouseWheel); - skillScrollerWidget->eventScrollChangePosition += MyGUI::newDelegate(this, &StatsWindow::onScrollChangePosition); + mSkillScrollerWidget->eventScrollChangePosition += MyGUI::newDelegate(this, &StatsWindow::onScrollChangePosition); updateScroller(); for (int i = 0; i < ESM::Skill::Length; ++i) { - skillValues.insert(std::pair >(i, MWMechanics::Stat())); - skillWidgetMap.insert(std::pair(i, nullptr)); + mSkillValues.insert(std::pair >(i, MWMechanics::Stat())); + mSkillWidgetMap.insert(std::pair(i, nullptr)); } MyGUI::WindowPtr t = static_cast(mMainWidget); @@ -85,14 +85,14 @@ StatsWindow::StatsWindow (WindowManager& parWindowManager) void StatsWindow::onScrollChangePosition(MyGUI::ScrollBar* scroller, size_t pos) { - int diff = lastPos - pos; + int diff = mLastPos - pos; // Adjust position of all widget according to difference if (diff == 0) return; - lastPos = pos; + mLastPos = pos; - std::vector::const_iterator end = skillWidgets.end(); - for (std::vector::const_iterator it = skillWidgets.begin(); it != end; ++it) + std::vector::const_iterator end = mSkillWidgets.end(); + for (std::vector::const_iterator it = mSkillWidgets.begin(); it != end; ++it) { (*it)->setCoord((*it)->getCoord() + MyGUI::IntPoint(0, diff)); } @@ -100,14 +100,14 @@ void StatsWindow::onScrollChangePosition(MyGUI::ScrollBar* scroller, size_t pos) void StatsWindow::onMouseWheel(MyGUI::Widget* _sender, int _rel) { - if (skillScrollerWidget->getScrollPosition() - _rel*0.3 < 0) - skillScrollerWidget->setScrollPosition(0); - else if (skillScrollerWidget->getScrollPosition() - _rel*0.3 > skillScrollerWidget->getScrollRange()-1) - skillScrollerWidget->setScrollPosition(skillScrollerWidget->getScrollRange()-1); + if (mSkillScrollerWidget->getScrollPosition() - _rel*0.3 < 0) + mSkillScrollerWidget->setScrollPosition(0); + else if (mSkillScrollerWidget->getScrollPosition() - _rel*0.3 > mSkillScrollerWidget->getScrollRange()-1) + mSkillScrollerWidget->setScrollPosition(mSkillScrollerWidget->getScrollRange()-1); else - skillScrollerWidget->setScrollPosition(skillScrollerWidget->getScrollPosition() - _rel*0.3); + mSkillScrollerWidget->setScrollPosition(mSkillScrollerWidget->getScrollPosition() - _rel*0.3); - onScrollChangePosition(skillScrollerWidget, skillScrollerWidget->getScrollPosition()); + onScrollChangePosition(mSkillScrollerWidget, mSkillScrollerWidget->getScrollPosition()); } void StatsWindow::onWindowResize(MyGUI::Window* window) @@ -224,8 +224,8 @@ void StatsWindow::setValue (const std::string& id, int value) void StatsWindow::setValue(const ESM::Skill::SkillEnum parSkill, const MWMechanics::Stat& value) { - skillValues[parSkill] = value; - MyGUI::TextBox* widget = skillWidgetMap[(int)parSkill]; + mSkillValues[parSkill] = value; + MyGUI::TextBox* widget = mSkillWidgetMap[(int)parSkill]; if (widget) { float modified = value.getModified(), base = value.getBase(); @@ -243,20 +243,20 @@ void StatsWindow::setValue(const ESM::Skill::SkillEnum parSkill, const MWMechani void StatsWindow::configureSkills (const std::vector& major, const std::vector& minor) { - majorSkills = major; - minorSkills = minor; + mMajorSkills = major; + mMinorSkills = minor; // Update misc skills with the remaining skills not in major or minor std::set skillSet; std::copy(major.begin(), major.end(), std::inserter(skillSet, skillSet.begin())); std::copy(minor.begin(), minor.end(), std::inserter(skillSet, skillSet.begin())); boost::array::const_iterator end = ESM::Skill::skillIds.end(); - miscSkills.clear(); + mMiscSkills.clear(); for (boost::array::const_iterator it = ESM::Skill::skillIds.begin(); it != end; ++it) { int skill = *it; if (skillSet.find(skill) == skillSet.end()) - miscSkills.push_back(skill); + mMiscSkills.push_back(skill); } updateSkillArea(); @@ -289,20 +289,20 @@ void StatsWindow::setFactions (const FactionList& factions) void StatsWindow::setBirthSign (const std::string& signId) { - if (signId != birthSignId) + if (signId != mBirthSignId) { - birthSignId = signId; + mBirthSignId = signId; mChanged = true; } } void StatsWindow::addSeparator(MyGUI::IntCoord &coord1, MyGUI::IntCoord &coord2) { - MyGUI::ImageBox* separator = skillClientWidget->createWidget("MW_HLine", + MyGUI::ImageBox* separator = mSkillClientWidget->createWidget("MW_HLine", MyGUI::IntCoord(10, coord1.top, coord1.width + coord2.width - 4, 18), MyGUI::Align::Left | MyGUI::Align::Top | MyGUI::Align::HStretch); separator->eventMouseWheel += MyGUI::newDelegate(this, &StatsWindow::onMouseWheel); - skillWidgets.push_back(separator); + mSkillWidgets.push_back(separator); coord1.top += separator->getHeight(); coord2.top += separator->getHeight(); @@ -310,35 +310,35 @@ void StatsWindow::addSeparator(MyGUI::IntCoord &coord1, MyGUI::IntCoord &coord2) void StatsWindow::addGroup(const std::string &label, MyGUI::IntCoord &coord1, MyGUI::IntCoord &coord2) { - MyGUI::TextBox* groupWidget = skillClientWidget->createWidget("SandBrightText", + MyGUI::TextBox* groupWidget = mSkillClientWidget->createWidget("SandBrightText", MyGUI::IntCoord(0, coord1.top, coord1.width + coord2.width, coord1.height), MyGUI::Align::Left | MyGUI::Align::Top | MyGUI::Align::HStretch); groupWidget->setCaption(label); groupWidget->eventMouseWheel += MyGUI::newDelegate(this, &StatsWindow::onMouseWheel); - skillWidgets.push_back(groupWidget); + mSkillWidgets.push_back(groupWidget); - coord1.top += lineHeight; - coord2.top += lineHeight; + coord1.top += sLineHeight; + coord2.top += sLineHeight; } MyGUI::TextBox* StatsWindow::addValueItem(const std::string& text, const std::string &value, const std::string& state, MyGUI::IntCoord &coord1, MyGUI::IntCoord &coord2) { MyGUI::TextBox *skillNameWidget, *skillValueWidget; - skillNameWidget = skillClientWidget->createWidget("SandText", coord1, MyGUI::Align::Left | MyGUI::Align::Top | MyGUI::Align::HStretch); + skillNameWidget = mSkillClientWidget->createWidget("SandText", coord1, MyGUI::Align::Left | MyGUI::Align::Top | MyGUI::Align::HStretch); skillNameWidget->setCaption(text); skillNameWidget->eventMouseWheel += MyGUI::newDelegate(this, &StatsWindow::onMouseWheel); - skillValueWidget = skillClientWidget->createWidget("SandTextRight", coord2, MyGUI::Align::Right | MyGUI::Align::Top); + skillValueWidget = mSkillClientWidget->createWidget("SandTextRight", coord2, MyGUI::Align::Right | MyGUI::Align::Top); skillValueWidget->setCaption(value); skillValueWidget->_setWidgetState(state); skillValueWidget->eventMouseWheel += MyGUI::newDelegate(this, &StatsWindow::onMouseWheel); - skillWidgets.push_back(skillNameWidget); - skillWidgets.push_back(skillValueWidget); + mSkillWidgets.push_back(skillNameWidget); + mSkillWidgets.push_back(skillValueWidget); - coord1.top += lineHeight; - coord2.top += lineHeight; + coord1.top += sLineHeight; + coord2.top += sLineHeight; return skillValueWidget; } @@ -347,14 +347,14 @@ MyGUI::Widget* StatsWindow::addItem(const std::string& text, MyGUI::IntCoord &co { MyGUI::TextBox* skillNameWidget; - skillNameWidget = skillClientWidget->createWidget("SandText", coord1 + MyGUI::IntSize(coord2.width, 0), MyGUI::Align::Default); + skillNameWidget = mSkillClientWidget->createWidget("SandText", coord1 + MyGUI::IntSize(coord2.width, 0), MyGUI::Align::Default); skillNameWidget->setCaption(text); skillNameWidget->eventMouseWheel += MyGUI::newDelegate(this, &StatsWindow::onMouseWheel); - skillWidgets.push_back(skillNameWidget); + mSkillWidgets.push_back(skillNameWidget); - coord1.top += lineHeight; - coord2.top += lineHeight; + coord1.top += sLineHeight; + coord2.top += sLineHeight; return skillNameWidget; } @@ -362,7 +362,7 @@ MyGUI::Widget* StatsWindow::addItem(const std::string& text, MyGUI::IntCoord &co void StatsWindow::addSkills(const SkillList &skills, const std::string &titleId, const std::string &titleDefault, MyGUI::IntCoord &coord1, MyGUI::IntCoord &coord2) { // Add a line separator if there are items above - if (!skillWidgets.empty()) + if (!mSkillWidgets.empty()) { addSeparator(coord1, coord2); } @@ -377,7 +377,7 @@ void StatsWindow::addSkills(const SkillList &skills, const std::string &titleId, continue; assert(skillId >= 0 && skillId < ESM::Skill::Length); const std::string &skillNameId = ESMS::Skill::sSkillNameIds[skillId]; - const MWMechanics::Stat &stat = skillValues.find(skillId)->second; + const MWMechanics::Stat &stat = mSkillValues.find(skillId)->second; float base = stat.getBase(); float modified = stat.getModified(); int progressPercent = (modified - float(static_cast(modified))) * 100; @@ -400,18 +400,18 @@ void StatsWindow::addSkills(const SkillList &skills, const std::string &titleId, for (int i=0; i<2; ++i) { - skillWidgets[skillWidgets.size()-1-i]->setUserString("ToolTipType", "Layout"); - skillWidgets[skillWidgets.size()-1-i]->setUserString("ToolTipLayout", "SkillToolTip"); - skillWidgets[skillWidgets.size()-1-i]->setUserString("Caption_SkillName", "#{"+skillNameId+"}"); - skillWidgets[skillWidgets.size()-1-i]->setUserString("Caption_SkillDescription", skill->description); - skillWidgets[skillWidgets.size()-1-i]->setUserString("Caption_SkillAttribute", "#{sGoverningAttribute}: #{" + attr->name + "}"); - skillWidgets[skillWidgets.size()-1-i]->setUserString("ImageTexture_SkillImage", icon); - skillWidgets[skillWidgets.size()-1-i]->setUserString("Caption_SkillProgressText", boost::lexical_cast(progressPercent)+"/100"); - skillWidgets[skillWidgets.size()-1-i]->setUserString("Range_SkillProgress", "100"); - skillWidgets[skillWidgets.size()-1-i]->setUserString("RangePosition_SkillProgress", boost::lexical_cast(progressPercent)); + mSkillWidgets[mSkillWidgets.size()-1-i]->setUserString("ToolTipType", "Layout"); + mSkillWidgets[mSkillWidgets.size()-1-i]->setUserString("ToolTipLayout", "SkillToolTip"); + mSkillWidgets[mSkillWidgets.size()-1-i]->setUserString("Caption_SkillName", "#{"+skillNameId+"}"); + mSkillWidgets[mSkillWidgets.size()-1-i]->setUserString("Caption_SkillDescription", skill->description); + mSkillWidgets[mSkillWidgets.size()-1-i]->setUserString("Caption_SkillAttribute", "#{sGoverningAttribute}: #{" + attr->name + "}"); + mSkillWidgets[mSkillWidgets.size()-1-i]->setUserString("ImageTexture_SkillImage", icon); + mSkillWidgets[mSkillWidgets.size()-1-i]->setUserString("Caption_SkillProgressText", boost::lexical_cast(progressPercent)+"/100"); + mSkillWidgets[mSkillWidgets.size()-1-i]->setUserString("Range_SkillProgress", "100"); + mSkillWidgets[mSkillWidgets.size()-1-i]->setUserString("RangePosition_SkillProgress", boost::lexical_cast(progressPercent)); } - skillWidgetMap[skillId] = widget; + mSkillWidgetMap[skillId] = widget; } } @@ -419,28 +419,28 @@ void StatsWindow::updateSkillArea() { mChanged = false; - for (std::vector::iterator it = skillWidgets.begin(); it != skillWidgets.end(); ++it) + for (std::vector::iterator it = mSkillWidgets.begin(); it != mSkillWidgets.end(); ++it) { MyGUI::Gui::getInstance().destroyWidget(*it); } - skillWidgets.clear(); + mSkillWidgets.clear(); - skillScrollerWidget->setScrollPosition(0); - onScrollChangePosition(skillScrollerWidget, 0); - clientHeight = 0; + mSkillScrollerWidget->setScrollPosition(0); + onScrollChangePosition(mSkillScrollerWidget, 0); + mClientHeight = 0; const int valueSize = 40; - MyGUI::IntCoord coord1(10, 0, skillClientWidget->getWidth() - (10 + valueSize), 18); + MyGUI::IntCoord coord1(10, 0, mSkillClientWidget->getWidth() - (10 + valueSize), 18); MyGUI::IntCoord coord2(coord1.left + coord1.width, coord1.top, valueSize, coord1.height); - if (!majorSkills.empty()) - addSkills(majorSkills, "sSkillClassMajor", "Major Skills", coord1, coord2); + if (!mMajorSkills.empty()) + addSkills(mMajorSkills, "sSkillClassMajor", "Major Skills", coord1, coord2); - if (!minorSkills.empty()) - addSkills(minorSkills, "sSkillClassMinor", "Minor Skills", coord1, coord2); + if (!mMinorSkills.empty()) + addSkills(mMinorSkills, "sSkillClassMinor", "Minor Skills", coord1, coord2); - if (!miscSkills.empty()) - addSkills(miscSkills, "sSkillClassMisc", "Misc Skills", coord1, coord2); + if (!mMiscSkills.empty()) + addSkills(mMiscSkills, "sSkillClassMisc", "Misc Skills", coord1, coord2); const ESMS::ESMStore &store = mWindowManager.getStore(); @@ -463,7 +463,7 @@ void StatsWindow::updateSkillArea() if (!mFactions.empty()) { // Add a line separator if there are items above - if (!skillWidgets.empty()) + if (!mSkillWidgets.empty()) addSeparator(coord1, coord2); addGroup(mWindowManager.getGameSettingString("sFaction", "Faction"), coord1, coord2); @@ -516,53 +516,53 @@ void StatsWindow::updateSkillArea() } } - if (!birthSignId.empty()) + if (!mBirthSignId.empty()) { // Add a line separator if there are items above - if (!skillWidgets.empty()) + if (!mSkillWidgets.empty()) addSeparator(coord1, coord2); addGroup(mWindowManager.getGameSettingString("sBirthSign", "Sign"), coord1, coord2); - const ESM::BirthSign *sign = store.birthSigns.find(birthSignId); + const ESM::BirthSign *sign = store.birthSigns.find(mBirthSignId); MyGUI::Widget* w = addItem(sign->name, coord1, coord2); - ToolTips::createBirthsignToolTip(w, birthSignId); + ToolTips::createBirthsignToolTip(w, mBirthSignId); } // Add a line separator if there are items above - if (!skillWidgets.empty()) + if (!mSkillWidgets.empty()) addSeparator(coord1, coord2); addValueItem(mWindowManager.getGameSettingString("sReputation", "Reputation"), - boost::lexical_cast(static_cast(reputation)), "normal", coord1, coord2); + boost::lexical_cast(static_cast(mReputation)), "normal", coord1, coord2); for (int i=0; i<2; ++i) { - skillWidgets[skillWidgets.size()-1-i]->setUserString("ToolTipType", "Layout"); - skillWidgets[skillWidgets.size()-1-i]->setUserString("ToolTipLayout", "TextToolTip"); - skillWidgets[skillWidgets.size()-1-i]->setUserString("Caption_Text", "#{sSkillsMenuReputationHelp}"); + mSkillWidgets[mSkillWidgets.size()-1-i]->setUserString("ToolTipType", "Layout"); + mSkillWidgets[mSkillWidgets.size()-1-i]->setUserString("ToolTipLayout", "TextToolTip"); + mSkillWidgets[mSkillWidgets.size()-1-i]->setUserString("Caption_Text", "#{sSkillsMenuReputationHelp}"); } addValueItem(mWindowManager.getGameSettingString("sBounty", "Bounty"), - boost::lexical_cast(static_cast(bounty)), "normal", coord1, coord2); + boost::lexical_cast(static_cast(mBounty)), "normal", coord1, coord2); for (int i=0; i<2; ++i) { - skillWidgets[skillWidgets.size()-1-i]->setUserString("ToolTipType", "Layout"); - skillWidgets[skillWidgets.size()-1-i]->setUserString("ToolTipLayout", "TextToolTip"); - skillWidgets[skillWidgets.size()-1-i]->setUserString("Caption_Text", "#{sCrimeHelp}"); + mSkillWidgets[mSkillWidgets.size()-1-i]->setUserString("ToolTipType", "Layout"); + mSkillWidgets[mSkillWidgets.size()-1-i]->setUserString("ToolTipLayout", "TextToolTip"); + mSkillWidgets[mSkillWidgets.size()-1-i]->setUserString("Caption_Text", "#{sCrimeHelp}"); } - clientHeight = coord1.top; + mClientHeight = coord1.top; updateScroller(); } void StatsWindow::updateScroller() { - skillScrollerWidget->setScrollRange(std::max(clientHeight - skillClientWidget->getHeight(), 0)); - skillScrollerWidget->setScrollPage(std::max(skillClientWidget->getHeight() - lineHeight, 0)); - if (clientHeight != 0) - skillScrollerWidget->setTrackSize( (skillAreaWidget->getHeight() / float(clientHeight)) * skillScrollerWidget->getLineSize() ); + mSkillScrollerWidget->setScrollRange(std::max(mClientHeight - mSkillClientWidget->getHeight(), 0)); + mSkillScrollerWidget->setScrollPage(std::max(mSkillClientWidget->getHeight() - sLineHeight, 0)); + if (mClientHeight != 0) + mSkillScrollerWidget->setTrackSize( (mSkillAreaWidget->getHeight() / float(mClientHeight)) * mSkillScrollerWidget->getLineSize() ); } void StatsWindow::onPinToggled() diff --git a/apps/openmw/mwgui/stats_window.hpp b/apps/openmw/mwgui/stats_window.hpp index 10b794cc0..2469c12e9 100644 --- a/apps/openmw/mwgui/stats_window.hpp +++ b/apps/openmw/mwgui/stats_window.hpp @@ -38,8 +38,8 @@ namespace MWGui void setValue(const ESM::Skill::SkillEnum parSkill, const MWMechanics::Stat& value); void configureSkills (const SkillList& major, const SkillList& minor); - void setReputation (int reputation) { this->reputation = reputation; } - void setBounty (int bounty) { this->bounty = bounty; } + void setReputation (int reputation) { this->mReputation = reputation; } + void setBounty (int bounty) { this->mBounty = bounty; } void updateSkillArea(); private: @@ -57,23 +57,23 @@ namespace MWGui void onWindowResize(MyGUI::Window* window); void onMouseWheel(MyGUI::Widget* _sender, int _rel); - static const int lineHeight; + static const int sLineHeight; MyGUI::Widget* mLeftPane; MyGUI::Widget* mRightPane; - MyGUI::WidgetPtr skillAreaWidget, skillClientWidget; - MyGUI::ScrollBar* skillScrollerWidget; - int lastPos, clientHeight; + MyGUI::WidgetPtr mSkillAreaWidget, mSkillClientWidget; + MyGUI::ScrollBar* mSkillScrollerWidget; + int mLastPos, mClientHeight; - SkillList majorSkills, minorSkills, miscSkills; - std::map > skillValues; - std::map skillWidgetMap; - std::map factionWidgetMap; + SkillList mMajorSkills, mMinorSkills, mMiscSkills; + std::map > mSkillValues; + std::map mSkillWidgetMap; + std::map mFactionWidgetMap; FactionList mFactions; ///< Stores a list of factions and the current rank - std::string birthSignId; - int reputation, bounty; - std::vector skillWidgets; //< Skills and other information + std::string mBirthSignId; + int mReputation, mBounty; + std::vector mSkillWidgets; //< Skills and other information bool mChanged; diff --git a/apps/openmw/mwgui/text_input.cpp b/apps/openmw/mwgui/text_input.cpp index 17852ba5a..7d5b0cc6d 100644 --- a/apps/openmw/mwgui/text_input.cpp +++ b/apps/openmw/mwgui/text_input.cpp @@ -9,15 +9,15 @@ TextInputDialog::TextInputDialog(WindowManager& parWindowManager) // Centre dialog center(); - getWidget(textEdit, "TextEdit"); - textEdit->eventEditSelectAccept += newDelegate(this, &TextInputDialog::onTextAccepted); + getWidget(mTextEdit, "TextEdit"); + mTextEdit->eventEditSelectAccept += newDelegate(this, &TextInputDialog::onTextAccepted); MyGUI::ButtonPtr okButton; getWidget(okButton, "OKButton"); okButton->eventMouseButtonClick += MyGUI::newDelegate(this, &TextInputDialog::onOkClicked); // Make sure the edit box has focus - MyGUI::InputManager::getInstance().setKeyFocusWidget(textEdit); + MyGUI::InputManager::getInstance().setKeyFocusWidget(mTextEdit); } void TextInputDialog::setNextButtonShow(bool shown) @@ -43,7 +43,7 @@ void TextInputDialog::setTextLabel(const std::string &label) void TextInputDialog::open() { // Make sure the edit box has focus - MyGUI::InputManager::getInstance().setKeyFocusWidget(textEdit); + MyGUI::InputManager::getInstance().setKeyFocusWidget(mTextEdit); setVisible(true); } diff --git a/apps/openmw/mwgui/text_input.hpp b/apps/openmw/mwgui/text_input.hpp index fe355655f..835d5deaa 100644 --- a/apps/openmw/mwgui/text_input.hpp +++ b/apps/openmw/mwgui/text_input.hpp @@ -20,8 +20,8 @@ namespace MWGui public: TextInputDialog(WindowManager& parWindowManager); - std::string getTextInput() const { return textEdit ? textEdit->getOnlyText() : ""; } - void setTextInput(const std::string &text) { if (textEdit) textEdit->setOnlyText(text); } + std::string getTextInput() const { return mTextEdit ? mTextEdit->getOnlyText() : ""; } + void setTextInput(const std::string &text) { if (mTextEdit) mTextEdit->setOnlyText(text); } void setNextButtonShow(bool shown); void setTextLabel(const std::string &label); @@ -32,7 +32,7 @@ namespace MWGui void onTextAccepted(MyGUI::Edit* _sender); private: - MyGUI::EditPtr textEdit; + MyGUI::EditPtr mTextEdit; }; } #endif diff --git a/apps/openmw/mwgui/widgets.cpp b/apps/openmw/mwgui/widgets.cpp index 65de7ce0a..c54ac6e38 100644 --- a/apps/openmw/mwgui/widgets.cpp +++ b/apps/openmw/mwgui/widgets.cpp @@ -27,16 +27,16 @@ void MWGui::Widgets::fixTexturePath(std::string &path) /* MWSkill */ MWSkill::MWSkill() - : manager(nullptr) - , skillId(ESM::Skill::Length) - , skillNameWidget(nullptr) - , skillValueWidget(nullptr) + : mManager(nullptr) + , mSkillId(ESM::Skill::Length) + , mSkillNameWidget(nullptr) + , mSkillValueWidget(nullptr) { } void MWSkill::setSkillId(ESM::Skill::SkillEnum skill) { - skillId = skill; + mSkillId = skill; updateWidgets(); } @@ -50,36 +50,36 @@ void MWSkill::setSkillNumber(int skill) throw new std::runtime_error("Skill number out of range"); } -void MWSkill::setSkillValue(const SkillValue& value_) +void MWSkill::setSkillValue(const SkillValue& value) { - value = value_; + mValue = value; updateWidgets(); } void MWSkill::updateWidgets() { - if (skillNameWidget && manager) + if (mSkillNameWidget && mManager) { - if (skillId == ESM::Skill::Length) + if (mSkillId == ESM::Skill::Length) { - static_cast(skillNameWidget)->setCaption(""); + static_cast(mSkillNameWidget)->setCaption(""); } else { - const std::string &name = manager->getGameSettingString(ESM::Skill::sSkillNameIds[skillId], ""); - static_cast(skillNameWidget)->setCaption(name); + const std::string &name = mManager->getGameSettingString(ESM::Skill::sSkillNameIds[mSkillId], ""); + static_cast(mSkillNameWidget)->setCaption(name); } } - if (skillValueWidget) + if (mSkillValueWidget) { - SkillValue::Type modified = value.getModified(), base = value.getBase(); - static_cast(skillValueWidget)->setCaption(boost::lexical_cast(modified)); + SkillValue::Type modified = mValue.getModified(), base = mValue.getBase(); + static_cast(mSkillValueWidget)->setCaption(boost::lexical_cast(modified)); if (modified > base) - skillValueWidget->_setWidgetState("increased"); + mSkillValueWidget->_setWidgetState("increased"); else if (modified < base) - skillValueWidget->_setWidgetState("decreased"); + mSkillValueWidget->_setWidgetState("decreased"); else - skillValueWidget->_setWidgetState("normal"); + mSkillValueWidget->_setWidgetState("normal"); } } @@ -96,14 +96,14 @@ void MWSkill::initialiseOverride() { Base::initialiseOverride(); - assignWidget(skillNameWidget, "StatName"); - assignWidget(skillValueWidget, "StatValue"); + assignWidget(mSkillNameWidget, "StatName"); + assignWidget(mSkillValueWidget, "StatValue"); MyGUI::ButtonPtr button; assignWidget(button, "StatNameButton"); if (button) { - skillNameWidget = button; + mSkillNameWidget = button; button->eventMouseButtonClick += MyGUI::newDelegate(this, &MWSkill::onClicked); } @@ -111,7 +111,7 @@ void MWSkill::initialiseOverride() assignWidget(button, "StatValueButton"); if (button) { - skillNameWidget = button; + mSkillNameWidget = button; button->eventMouseButtonClick += MyGUI::newDelegate(this, &MWSkill::onClicked); } } @@ -119,22 +119,22 @@ void MWSkill::initialiseOverride() /* MWAttribute */ MWAttribute::MWAttribute() - : manager(nullptr) - , id(-1) - , attributeNameWidget(nullptr) - , attributeValueWidget(nullptr) + : mManager(nullptr) + , mId(-1) + , mAttributeNameWidget(nullptr) + , mAttributeValueWidget(nullptr) { } void MWAttribute::setAttributeId(int attributeId) { - id = attributeId; + mId = attributeId; updateWidgets(); } -void MWAttribute::setAttributeValue(const AttributeValue& value_) +void MWAttribute::setAttributeValue(const AttributeValue& value) { - value = value_; + mValue = value; updateWidgets(); } @@ -145,11 +145,11 @@ void MWAttribute::onClicked(MyGUI::Widget* _sender) void MWAttribute::updateWidgets() { - if (attributeNameWidget && manager) + if (mAttributeNameWidget && mManager) { - if (id < 0 || id >= 8) + if (mId < 0 || mId >= 8) { - static_cast(attributeNameWidget)->setCaption(""); + static_cast(mAttributeNameWidget)->setCaption(""); } else { @@ -163,20 +163,20 @@ void MWAttribute::updateWidgets() "sAttributePersonality", "sAttributeLuck" }; - const std::string &name = manager->getGameSettingString(attributes[id], ""); - static_cast(attributeNameWidget)->setCaption(name); + const std::string &name = mManager->getGameSettingString(attributes[mId], ""); + static_cast(mAttributeNameWidget)->setCaption(name); } } - if (attributeValueWidget) + if (mAttributeValueWidget) { - AttributeValue::Type modified = value.getModified(), base = value.getBase(); - static_cast(attributeValueWidget)->setCaption(boost::lexical_cast(modified)); + AttributeValue::Type modified = mValue.getModified(), base = mValue.getBase(); + static_cast(mAttributeValueWidget)->setCaption(boost::lexical_cast(modified)); if (modified > base) - attributeValueWidget->_setWidgetState("increased"); + mAttributeValueWidget->_setWidgetState("increased"); else if (modified < base) - attributeValueWidget->_setWidgetState("decreased"); + mAttributeValueWidget->_setWidgetState("decreased"); else - attributeValueWidget->_setWidgetState("normal"); + mAttributeValueWidget->_setWidgetState("normal"); } } @@ -188,14 +188,14 @@ void MWAttribute::initialiseOverride() { Base::initialiseOverride(); - assignWidget(attributeNameWidget, "StatName"); - assignWidget(attributeValueWidget, "StatValue"); + assignWidget(mAttributeNameWidget, "StatName"); + assignWidget(mAttributeValueWidget, "StatValue"); MyGUI::ButtonPtr button; assignWidget(button, "StatNameButton"); if (button) { - attributeNameWidget = button; + mAttributeNameWidget = button; button->eventMouseButtonClick += MyGUI::newDelegate(this, &MWAttribute::onClicked); } @@ -203,7 +203,7 @@ void MWAttribute::initialiseOverride() assignWidget(button, "StatValueButton"); if (button) { - attributeValueWidget = button; + mAttributeValueWidget = button; button->eventMouseButtonClick += MyGUI::newDelegate(this, &MWAttribute::onClicked); } } @@ -212,21 +212,21 @@ void MWAttribute::initialiseOverride() MWSpell::MWSpell() : mWindowManager(nullptr) - , spellNameWidget(nullptr) + , mSpellNameWidget(nullptr) { } void MWSpell::setSpellId(const std::string &spellId) { - id = spellId; + mId = spellId; updateWidgets(); } void MWSpell::createEffectWidgets(std::vector &effects, MyGUI::WidgetPtr creator, MyGUI::IntCoord &coord, int flags) { const ESMS::ESMStore &store = mWindowManager->getStore(); - const ESM::Spell *spell = store.spells.search(id); - MYGUI_ASSERT(spell, "spell with id '" << id << "' not found"); + const ESM::Spell *spell = store.spells.search(mId); + MYGUI_ASSERT(spell, "spell with id '" << mId << "' not found"); MWSpellEffectPtr effect = nullptr; std::vector::const_iterator end = spell->effects.list.end(); @@ -253,14 +253,14 @@ void MWSpell::createEffectWidgets(std::vector &effects, MyGUI: void MWSpell::updateWidgets() { - if (spellNameWidget && mWindowManager) + if (mSpellNameWidget && mWindowManager) { const ESMS::ESMStore &store = mWindowManager->getStore(); - const ESM::Spell *spell = store.spells.search(id); + const ESM::Spell *spell = store.spells.search(mId); if (spell) - static_cast(spellNameWidget)->setCaption(spell->name); + static_cast(mSpellNameWidget)->setCaption(spell->name); else - static_cast(spellNameWidget)->setCaption(""); + static_cast(mSpellNameWidget)->setCaption(""); } } @@ -268,7 +268,7 @@ void MWSpell::initialiseOverride() { Base::initialiseOverride(); - assignWidget(spellNameWidget, "StatName"); + assignWidget(mSpellNameWidget, "StatName"); } MWSpell::~MWSpell() @@ -367,8 +367,8 @@ SpellEffectList MWEffectList::effectListFromESM(const ESM::EffectList* effects) MWSpellEffect::MWSpellEffect() : mWindowManager(nullptr) - , imageWidget(nullptr) - , textWidget(nullptr) + , mImageWidget(nullptr) + , mTextWidget(nullptr) , mRequestedWidth(0) { } @@ -388,7 +388,7 @@ void MWSpellEffect::updateWidgets() const ESM::MagicEffect *magicEffect = store.magicEffects.search(mEffectParams.mEffectID); if (!magicEffect) return; - if (textWidget) + if (mTextWidget) { std::string pt = mWindowManager->getGameSettingString("spoint", ""); std::string pts = mWindowManager->getGameSettingString("spoints", ""); @@ -448,14 +448,14 @@ void MWSpellEffect::updateWidgets() } } - static_cast(textWidget)->setCaption(spellLine); - mRequestedWidth = textWidget->getTextSize().width + 24; + static_cast(mTextWidget)->setCaption(spellLine); + mRequestedWidth = mTextWidget->getTextSize().width + 24; } - if (imageWidget) + if (mImageWidget) { std::string path = std::string("icons\\") + magicEffect->icon; fixTexturePath(path); - imageWidget->setImageTexture(path); + mImageWidget->setImageTexture(path); } } @@ -728,49 +728,49 @@ void MWSpellEffect::initialiseOverride() { Base::initialiseOverride(); - assignWidget(textWidget, "Text"); - assignWidget(imageWidget, "Image"); + assignWidget(mTextWidget, "Text"); + assignWidget(mImageWidget, "Image"); } /* MWDynamicStat */ MWDynamicStat::MWDynamicStat() -: value(0) -, max(1) -, textWidget(nullptr) -, barWidget(nullptr) -, barTextWidget(nullptr) +: mValue(0) +, mMax(1) +, mTextWidget(nullptr) +, mBarWidget(nullptr) +, mBarTextWidget(nullptr) { } -void MWDynamicStat::setValue(int cur, int max_) +void MWDynamicStat::setValue(int cur, int max) { - value = cur; - max = max_; + mValue = cur; + mMax = max; - if (barWidget) + if (mBarWidget) { - barWidget->setProgressRange(max); - barWidget->setProgressPosition(value); + mBarWidget->setProgressRange(mMax); + mBarWidget->setProgressPosition(mValue); } - if (barTextWidget) + if (mBarTextWidget) { - if (value >= 0 && max > 0) + if (mValue >= 0 && mMax > 0) { std::stringstream out; - out << value << "/" << max; - static_cast(barTextWidget)->setCaption(out.str().c_str()); + out << mValue << "/" << mMax; + static_cast(mBarTextWidget)->setCaption(out.str().c_str()); } else - static_cast(barTextWidget)->setCaption(""); + static_cast(mBarTextWidget)->setCaption(""); } } void MWDynamicStat::setTitle(const std::string& text) { - if (textWidget) - static_cast(textWidget)->setCaption(text); + if (mTextWidget) + static_cast(mTextWidget)->setCaption(text); } MWDynamicStat::~MWDynamicStat() @@ -781,7 +781,7 @@ void MWDynamicStat::initialiseOverride() { Base::initialiseOverride(); - assignWidget(textWidget, "Text"); - assignWidget(barWidget, "Bar"); - assignWidget(barTextWidget, "BarText"); + assignWidget(mTextWidget, "Text"); + assignWidget(mBarWidget, "Bar"); + assignWidget(mBarTextWidget, "BarText"); } diff --git a/apps/openmw/mwgui/widgets.hpp b/apps/openmw/mwgui/widgets.hpp index 5d00baf87..d4947895b 100644 --- a/apps/openmw/mwgui/widgets.hpp +++ b/apps/openmw/mwgui/widgets.hpp @@ -73,7 +73,7 @@ namespace MWGui typedef std::vector SpellEffectList; - class MYGUI_EXPORT MWSkill : public Widget + class MYGUI_EXPORT MWSkill : public MyGUI::Widget { MYGUI_RTTI_DERIVED( MWSkill ); public: @@ -81,14 +81,14 @@ namespace MWGui typedef MWMechanics::Stat SkillValue; - void setWindowManager(WindowManager *m) { manager = m; } + void setWindowManager(WindowManager *m) { mManager = m; } void setSkillId(ESM::Skill::SkillEnum skillId); void setSkillNumber(int skillId); void setSkillValue(const SkillValue& value); - WindowManager *getWindowManager() const { return manager; } - ESM::Skill::SkillEnum getSkillId() const { return skillId; } - const SkillValue& getSkillValue() const { return value; } + WindowManager *getWindowManager() const { return mManager; } + ESM::Skill::SkillEnum getSkillId() const { return mSkillId; } + const SkillValue& getSkillValue() const { return mValue; } // Events typedef delegates::CMultiDelegate1 EventHandle_SkillVoid; @@ -109,14 +109,14 @@ namespace MWGui void updateWidgets(); - WindowManager *manager; - ESM::Skill::SkillEnum skillId; - SkillValue value; - MyGUI::WidgetPtr skillNameWidget, skillValueWidget; + WindowManager *mManager; + ESM::Skill::SkillEnum mSkillId; + SkillValue mValue; + MyGUI::WidgetPtr mSkillNameWidget, mSkillValueWidget; }; typedef MWSkill* MWSkillPtr; - class MYGUI_EXPORT MWAttribute : public Widget + class MYGUI_EXPORT MWAttribute : public MyGUI::Widget { MYGUI_RTTI_DERIVED( MWAttribute ); public: @@ -124,13 +124,13 @@ namespace MWGui typedef MWMechanics::Stat AttributeValue; - void setWindowManager(WindowManager *m) { manager = m; } + void setWindowManager(WindowManager *m) { mManager = m; } void setAttributeId(int attributeId); void setAttributeValue(const AttributeValue& value); - WindowManager *getWindowManager() const { return manager; } - int getAttributeId() const { return id; } - const AttributeValue& getAttributeValue() const { return value; } + WindowManager *getWindowManager() const { return mManager; } + int getAttributeId() const { return mId; } + const AttributeValue& getAttributeValue() const { return mValue; } // Events typedef delegates::CMultiDelegate1 EventHandle_AttributeVoid; @@ -151,10 +151,10 @@ namespace MWGui void updateWidgets(); - WindowManager *manager; - int id; - AttributeValue value; - MyGUI::WidgetPtr attributeNameWidget, attributeValueWidget; + WindowManager *mManager; + int mId; + AttributeValue mValue; + MyGUI::WidgetPtr mAttributeNameWidget, mAttributeValueWidget; }; typedef MWAttribute* MWAttributePtr; @@ -162,7 +162,7 @@ namespace MWGui * @todo remove this class and use MWEffectList instead */ class MWSpellEffect; - class MYGUI_EXPORT MWSpell : public Widget + class MYGUI_EXPORT MWSpell : public MyGUI::Widget { MYGUI_RTTI_DERIVED( MWSpell ); public: @@ -182,7 +182,7 @@ namespace MWGui */ void createEffectWidgets(std::vector &effects, MyGUI::WidgetPtr creator, MyGUI::IntCoord &coord, int flags); - const std::string &getSpellId() const { return id; } + const std::string &getSpellId() const { return mId; } protected: virtual ~MWSpell(); @@ -193,12 +193,12 @@ namespace MWGui void updateWidgets(); WindowManager* mWindowManager; - std::string id; - MyGUI::TextBox* spellNameWidget; + std::string mId; + MyGUI::TextBox* mSpellNameWidget; }; typedef MWSpell* MWSpellPtr; - class MYGUI_EXPORT MWEffectList : public Widget + class MYGUI_EXPORT MWEffectList : public MyGUI::Widget { MYGUI_RTTI_DERIVED( MWEffectList ); public: @@ -239,7 +239,7 @@ namespace MWGui }; typedef MWEffectList* MWEffectListPtr; - class MYGUI_EXPORT MWSpellEffect : public Widget + class MYGUI_EXPORT MWSpellEffect : public MyGUI::Widget { MYGUI_RTTI_DERIVED( MWSpellEffect ); public: @@ -269,13 +269,13 @@ namespace MWGui WindowManager* mWindowManager; SpellEffectParams mEffectParams; - MyGUI::ImageBox* imageWidget; - MyGUI::TextBox* textWidget; + MyGUI::ImageBox* mImageWidget; + MyGUI::TextBox* mTextWidget; int mRequestedWidth; }; typedef MWSpellEffect* MWSpellEffectPtr; - class MYGUI_EXPORT MWDynamicStat : public Widget + class MYGUI_EXPORT MWDynamicStat : public MyGUI::Widget { MYGUI_RTTI_DERIVED( MWDynamicStat ); public: @@ -284,8 +284,8 @@ namespace MWGui void setValue(int value, int max); void setTitle(const std::string& text); - int getValue() const { return value; } - int getMax() const { return max; } + int getValue() const { return mValue; } + int getMax() const { return mMax; } protected: virtual ~MWDynamicStat(); @@ -294,10 +294,10 @@ namespace MWGui private: - int value, max; - MyGUI::TextBox* textWidget; - MyGUI::ProgressPtr barWidget; - MyGUI::TextBox* barTextWidget; + int mValue, mMax; + MyGUI::TextBox* mTextWidget; + MyGUI::ProgressPtr mBarWidget; + MyGUI::TextBox* mBarTextWidget; }; typedef MWDynamicStat* MWDynamicStatPtr; } diff --git a/apps/openmw/mwgui/window_manager.cpp b/apps/openmw/mwgui/window_manager.cpp index 62207d7d7..aa0595b85 100644 --- a/apps/openmw/mwgui/window_manager.cpp +++ b/apps/openmw/mwgui/window_manager.cpp @@ -43,13 +43,13 @@ using namespace MWGui; WindowManager::WindowManager( const Compiler::Extensions& extensions, int fpsLevel, bool newGame, OEngine::Render::OgreRenderer *mOgre, const std::string& logpath) : mGuiManager(NULL) - , hud(NULL) - , map(NULL) - , menu(NULL) + , mHud(NULL) + , mMap(NULL) + , mMenu(NULL) , mStatsWindow(NULL) , mToolTips(NULL) , mMessageBoxManager(NULL) - , console(NULL) + , mConsole(NULL) , mJournal(NULL) , mDialogueWindow(NULL) , mBookWindow(NULL) @@ -61,21 +61,21 @@ WindowManager::WindowManager( , mAlchemyWindow(NULL) , mSpellWindow(NULL) , mCharGen(NULL) - , playerClass() - , playerName() - , playerRaceId() - , playerAttributes() - , playerMajorSkills() - , playerMinorSkills() - , playerSkillValues() - , playerHealth() - , playerMagicka() - , playerFatigue() - , gui(NULL) - , garbageDialogs() - , shown(GW_ALL) - , allowed(newGame ? GW_None : GW_ALL) - , showFPSLevel(fpsLevel) + , mPlayerClass() + , mPlayerName() + , mPlayerRaceId() + , mPlayerAttributes() + , mPlayerMajorSkills() + , mPlayerMinorSkills() + , mPlayerSkillValues() + , mPlayerHealth() + , mPlayerMagicka() + , mPlayerFatigue() + , mGui(NULL) + , mGarbageDialogs() + , mShown(GW_ALL) + , mAllowed(newGame ? GW_None : GW_ALL) + , mShowFPSLevel(fpsLevel) , mFPS(0.0f) , mTriangleCount(0) , mBatchCount(0) @@ -83,7 +83,7 @@ WindowManager::WindowManager( // Set up the GUI system mGuiManager = new OEngine::GUI::MyGUIManager(mOgre->getWindow(), mOgre->getScene(), false, logpath); - gui = mGuiManager->getGui(); + mGui = mGuiManager->getGui(); //Register own widgets with MyGUI MyGUI::FactoryManager::getInstance().registerFactory("Widget"); @@ -98,11 +98,11 @@ WindowManager::WindowManager( MyGUI::LanguageManager::getInstance().eventRequestTag = MyGUI::newDelegate(this, &WindowManager::onRetrieveTag); // Get size info from the Gui object - assert(gui); + assert(mGui); int w = MyGUI::RenderManager::getInstance().getViewSize().width; int h = MyGUI::RenderManager::getInstance().getViewSize().height; - MyGUI::Widget* dragAndDropWidget = gui->createWidgetT("Widget","",0,0,w,h,MyGUI::Align::Default,"DragAndDrop","DragAndDropWidget"); + MyGUI::Widget* dragAndDropWidget = mGui->createWidgetT("Widget","",0,0,w,h,MyGUI::Align::Default,"DragAndDrop","DragAndDropWidget"); dragAndDropWidget->setVisible(false); mDragAndDrop = new DragAndDrop(); @@ -110,17 +110,17 @@ WindowManager::WindowManager( mDragAndDrop->mDraggedWidget = 0; mDragAndDrop->mDragAndDropWidget = dragAndDropWidget; - menu = new MainMenu(w,h); - map = new MapWindow(*this); + mMenu = new MainMenu(w,h); + mMap = new MapWindow(*this); mStatsWindow = new StatsWindow(*this); - console = new Console(w,h, extensions); + mConsole = new Console(w,h, extensions); mJournal = new JournalWindow(*this); mMessageBoxManager = new MessageBoxManager(this); mInventoryWindow = new InventoryWindow(*this,mDragAndDrop); mTradeWindow = new TradeWindow(*this); mDialogueWindow = new DialogueWindow(*this); mContainerWindow = new ContainerWindow(*this,mDragAndDrop); - hud = new HUD(w,h, showFPSLevel, mDragAndDrop); + mHud = new HUD(w,h, mShowFPSLevel, mDragAndDrop); mToolTips = new ToolTips(this); mScrollWindow = new ScrollWindow(*this); mBookWindow = new BookWindow(*this); @@ -131,19 +131,19 @@ WindowManager::WindowManager( mSpellWindow = new SpellWindow(*this); // The HUD is always on - hud->setVisible(true); + mHud->setVisible(true); mCharGen = new CharacterCreation(this); // Setup player stats for (int i = 0; i < ESM::Attribute::Length; ++i) { - playerAttributes.insert(std::make_pair(ESM::Attribute::attributeIds[i], MWMechanics::Stat())); + mPlayerAttributes.insert(std::make_pair(ESM::Attribute::attributeIds[i], MWMechanics::Stat())); } for (int i = 0; i < ESM::Skill::Length; ++i) { - playerSkillValues.insert(std::make_pair(ESM::Skill::skillIds[i], MWMechanics::Stat())); + mPlayerSkillValues.insert(std::make_pair(ESM::Skill::skillIds[i], MWMechanics::Stat())); } unsetSelectedSpell(); @@ -156,11 +156,11 @@ WindowManager::WindowManager( WindowManager::~WindowManager() { delete mGuiManager; - delete console; + delete mConsole; delete mMessageBoxManager; - delete hud; - delete map; - delete menu; + delete mHud; + delete mMap; + delete mMenu; delete mStatsWindow; delete mJournal; delete mDialogueWindow; @@ -183,13 +183,13 @@ WindowManager::~WindowManager() void WindowManager::cleanupGarbage() { // Delete any dialogs which are no longer in use - if (!garbageDialogs.empty()) + if (!mGarbageDialogs.empty()) { - for (std::vector::iterator it = garbageDialogs.begin(); it != garbageDialogs.end(); ++it) + for (std::vector::iterator it = mGarbageDialogs.begin(); it != mGarbageDialogs.end(); ++it) { delete *it; } - garbageDialogs.clear(); + mGarbageDialogs.clear(); } } @@ -197,18 +197,18 @@ void WindowManager::update() { cleanupGarbage(); - hud->setFPS(mFPS); - hud->setTriangleCount(mTriangleCount); - hud->setBatchCount(mBatchCount); + mHud->setFPS(mFPS); + mHud->setTriangleCount(mTriangleCount); + mHud->setBatchCount(mBatchCount); } void WindowManager::updateVisible() { // Start out by hiding everything except the HUD - map->setVisible(false); - menu->setVisible(false); + mMap->setVisible(false); + mMenu->setVisible(false); mStatsWindow->setVisible(false); - console->disable(); + mConsole->disable(); mJournal->setVisible(false); mDialogueWindow->setVisible(false); mContainerWindow->setVisible(false); @@ -230,10 +230,10 @@ void WindowManager::updateVisible() else mToolTips->enterGuiMode(); - setMinimapVisibility((allowed & GW_Map) && !map->pinned()); - setWeaponVisibility((allowed & GW_Inventory) && !mInventoryWindow->pinned()); - setSpellVisibility((allowed & GW_Magic) && !mSpellWindow->pinned()); - setHMSVisibility((allowed & GW_Stats) && !mStatsWindow->pinned()); + setMinimapVisibility((mAllowed & GW_Map) && !mMap->pinned()); + setWeaponVisibility((mAllowed & GW_Inventory) && !mInventoryWindow->pinned()); + setSpellVisibility((mAllowed & GW_Magic) && !mSpellWindow->pinned()); + setHMSVisibility((mAllowed & GW_Stats) && !mStatsWindow->pinned()); // If in game mode, don't show anything. if (gameMode) @@ -243,13 +243,13 @@ void WindowManager::updateVisible() switch(mode) { case GM_MainMenu: - menu->setVisible(true); + mMenu->setVisible(true); break; case GM_Settings: mSettingsWindow->setVisible(true); break; case GM_Console: - console->enable(); + mConsole->enable(); break; case GM_Scroll: mScrollWindow->setVisible(true); @@ -276,13 +276,13 @@ void WindowManager::updateVisible() // This is controlled both by what windows the // user has opened/closed (the 'shown' variable) and by what // windows we are allowed to show (the 'allowed' var.) - int eff = shown & allowed; + int eff = mShown & mAllowed; // Show the windows we want - map -> setVisible(eff & GW_Map); - mStatsWindow -> setVisible(eff & GW_Stats); + mMap ->setVisible(eff & GW_Map); + mStatsWindow ->setVisible(eff & GW_Stats); mInventoryWindow->setVisible(eff & GW_Inventory); - mSpellWindow->setVisible(eff & GW_Magic); + mSpellWindow ->setVisible(eff & GW_Magic); break; } case GM_Container: @@ -333,7 +333,7 @@ void WindowManager::setValue (const std::string& id, const MWMechanics::StatsetValue(parSkill, value); mCharGen->setValue(parSkill, value); - playerSkillValues[parSkill] = value; + mPlayerSkillValues[parSkill] = value; } void WindowManager::setValue (const std::string& id, const MWMechanics::DynamicStat& value) { mStatsWindow->setValue (id, value); - hud->setValue (id, value); + mHud->setValue (id, value); mCharGen->setValue(id, value); if (id == "HBar") { - playerHealth = value; + mPlayerHealth = value; mCharGen->setPlayerHealth (value); } else if (id == "MBar") { - playerMagicka = value; + mPlayerMagicka = value; mCharGen->setPlayerMagicka (value); } else if (id == "FBar") { - playerFatigue = value; + mPlayerFatigue = value; mCharGen->setPlayerFatigue (value); } } @@ -372,11 +372,11 @@ void WindowManager::setValue (const std::string& id, const MWMechanics::DynamicS MWMechanics::DynamicStat WindowManager::getValue(const std::string& id) { if(id == "HBar") - return playerHealth; + return layerHealth; else if (id == "MBar") - return playerMagicka; + return mPlayerMagicka; else if (id == "FBar") - return playerFatigue; + return mPlayerFatigue; } #endif @@ -384,9 +384,9 @@ void WindowManager::setValue (const std::string& id, const std::string& value) { mStatsWindow->setValue (id, value); if (id=="name") - playerName = value; + mPlayerName = value; else if (id=="race") - playerRaceId = value; + mPlayerRaceId = value; } void WindowManager::setValue (const std::string& id, int value) @@ -396,16 +396,16 @@ void WindowManager::setValue (const std::string& id, int value) void WindowManager::setPlayerClass (const ESM::Class &class_) { - playerClass = class_; - mStatsWindow->setValue("class", playerClass.name); + mPlayerClass = class_; + mStatsWindow->setValue("class", mPlayerClass.name); } void WindowManager::configureSkills (const SkillList& major, const SkillList& minor) { mStatsWindow->configureSkills (major, minor); mCharGen->configureSkills(major, minor); - playerMajorSkills = major; - playerMinorSkills = minor; + mPlayerMajorSkills = major; + mPlayerMinorSkills = minor; } void WindowManager::setReputation (int reputation) @@ -429,7 +429,7 @@ void WindowManager::removeDialog(OEngine::GUI::Layout*dialog) if (!dialog) return; dialog->setVisible(false); - garbageDialogs.push_back(dialog); + mGarbageDialogs.push_back(dialog); } void WindowManager::messageBox (const std::string& message, const std::vector& buttons) @@ -484,12 +484,12 @@ void WindowManager::onFrame (float frameDuration) mStatsWindow->onFrame(); - hud->onFrame(frameDuration); + mHud->onFrame(frameDuration); mDialogueWindow->checkReferenceAvailable(); mTradeWindow->checkReferenceAvailable(); mContainerWindow->checkReferenceAvailable(); - console->checkReferenceAvailable(); + mConsole->checkReferenceAvailable(); } const ESMS::ESMStore& WindowManager::getStore() const @@ -513,56 +513,56 @@ void WindowManager::changeCell(MWWorld::Ptr::CellStore* cell) name = getGameSettingString("sDefaultCellname", "Wilderness"); } - map->setCellName( name ); - hud->setCellName( name ); + mMap->setCellName( name ); + mHud->setCellName( name ); - map->setCellPrefix("Cell"); - hud->setCellPrefix("Cell"); - map->setActiveCell( cell->cell->data.gridX, cell->cell->data.gridY ); - hud->setActiveCell( cell->cell->data.gridX, cell->cell->data.gridY ); + mMap->setCellPrefix("Cell"); + mHud->setCellPrefix("Cell"); + mMap->setActiveCell( cell->cell->data.gridX, cell->cell->data.gridY ); + mHud->setActiveCell( cell->cell->data.gridX, cell->cell->data.gridY ); } else { - map->setCellName( cell->cell->name ); - hud->setCellName( cell->cell->name ); - map->setCellPrefix( cell->cell->name ); - hud->setCellPrefix( cell->cell->name ); + mMap->setCellName( cell->cell->name ); + mHud->setCellName( cell->cell->name ); + mMap->setCellPrefix( cell->cell->name ); + mHud->setCellPrefix( cell->cell->name ); } } void WindowManager::setInteriorMapTexture(const int x, const int y) { - map->setActiveCell(x,y, true); - hud->setActiveCell(x,y, true); + mMap->setActiveCell(x,y, true); + mHud->setActiveCell(x,y, true); } void WindowManager::setPlayerPos(const float x, const float y) { - map->setPlayerPos(x,y); - hud->setPlayerPos(x,y); + mMap->setPlayerPos(x,y); + mHud->setPlayerPos(x,y); } void WindowManager::setPlayerDir(const float x, const float y) { - map->setPlayerDir(x,y); - hud->setPlayerDir(x,y); + mMap->setPlayerDir(x,y); + mHud->setPlayerDir(x,y); } void WindowManager::setHMSVisibility(bool visible) { - hud->setBottomLeftVisibility(visible, hud->weapBox->getVisible(), hud->spellBox->getVisible()); + mHud->setBottomLeftVisibility(visible, mHud->mWeapBox->getVisible(), mHud->mSpellBox->getVisible()); } void WindowManager::setMinimapVisibility(bool visible) { - hud->setBottomRightVisibility(hud->effectBox->getVisible(), visible); + mHud->setBottomRightVisibility(mHud->mEffectBox->getVisible(), visible); } void WindowManager::toggleFogOfWar() { - map->toggleFogOfWar(); - hud->toggleFogOfWar(); + mMap->toggleFogOfWar(); + mHud->toggleFogOfWar(); } void WindowManager::setFocusObject(const MWWorld::Ptr& focus) @@ -587,13 +587,13 @@ bool WindowManager::getFullHelp() const void WindowManager::setWeaponVisibility(bool visible) { - hud->setBottomLeftVisibility(hud->health->getVisible(), visible, hud->spellBox->getVisible()); + mHud->setBottomLeftVisibility(mHud->health->getVisible(), visible, mHud->mSpellBox->getVisible()); } void WindowManager::setSpellVisibility(bool visible) { - hud->setBottomLeftVisibility(hud->health->getVisible(), hud->weapBox->getVisible(), visible); - hud->setBottomRightVisibility(visible, hud->minimapBox->getVisible()); + mHud->setBottomLeftVisibility(mHud->health->getVisible(), mHud->mWeapBox->getVisible(), visible); + mHud->setBottomRightVisibility(visible, mHud->mMinimapBox->getVisible()); } void WindowManager::setMouseVisible(bool visible) @@ -618,7 +618,7 @@ void WindowManager::onRetrieveTag(const MyGUI::UString& _tag, MyGUI::UString& _r void WindowManager::processChangedSettings(const Settings::CategorySettingVector& changed) { - hud->setFpsLevel(Settings::Manager::getInt("fps", "HUD")); + mHud->setFpsLevel(Settings::Manager::getInt("fps", "HUD")); mToolTips->setDelay(Settings::Manager::getFloat("tooltip delay", "GUI")); bool changeRes = false; @@ -637,8 +637,8 @@ void WindowManager::processChangedSettings(const Settings::CategorySettingVector { int x = Settings::Manager::getInt("resolution x", "Video"); int y = Settings::Manager::getInt("resolution y", "Video"); - hud->onResChange(x, y); - console->onResChange(x, y); + mHud->onResChange(x, y); + mConsole->onResChange(x, y); mSettingsWindow->center(); mAlchemyWindow->center(); mScrollWindow->center(); @@ -649,7 +649,7 @@ void WindowManager::processChangedSettings(const Settings::CategorySettingVector void WindowManager::pushGuiMode(GuiMode mode) { - if (mode==GM_Inventory && allowed==GW_None) + if (mode==GM_Inventory && mAllowed==GW_None) return; mGuiModes.push_back(mode); @@ -690,32 +690,32 @@ void WindowManager::removeGuiMode(GuiMode mode) void WindowManager::setSelectedSpell(const std::string& spellId, int successChancePercent) { - hud->setSelectedSpell(spellId, successChancePercent); + mHud->setSelectedSpell(spellId, successChancePercent); const ESM::Spell* spell = MWBase::Environment::get().getWorld()->getStore().spells.find(spellId); mSpellWindow->setTitle(spell->name); } void WindowManager::setSelectedEnchantItem(const MWWorld::Ptr& item, int chargePercent) { - hud->setSelectedEnchantItem(item, chargePercent); + mHud->setSelectedEnchantItem(item, chargePercent); mSpellWindow->setTitle(MWWorld::Class::get(item).getName(item)); } void WindowManager::setSelectedWeapon(const MWWorld::Ptr& item, int durabilityPercent) { - hud->setSelectedWeapon(item, durabilityPercent); + mHud->setSelectedWeapon(item, durabilityPercent); mInventoryWindow->setTitle(MWWorld::Class::get(item).getName(item)); } void WindowManager::unsetSelectedSpell() { - hud->unsetSelectedSpell(); + mHud->unsetSelectedSpell(); mSpellWindow->setTitle("#{sNone}"); } void WindowManager::unsetSelectedWeapon() { - hud->unsetSelectedWeapon(); + mHud->unsetSelectedWeapon(); mInventoryWindow->setTitle("#{sSkillHandtohand}"); } @@ -738,5 +738,5 @@ void WindowManager::getMousePosition(float &x, float &y) bool WindowManager::getWorldMouseOver() { - return hud->getWorldMouseOver(); + return mHud->getWorldMouseOver(); } diff --git a/apps/openmw/mwgui/window_manager.hpp b/apps/openmw/mwgui/window_manager.hpp index 03ffa6b59..db9505493 100644 --- a/apps/openmw/mwgui/window_manager.hpp +++ b/apps/openmw/mwgui/window_manager.hpp @@ -123,27 +123,27 @@ namespace MWGui void toggleVisible(GuiWindow wnd) { - shown = (shown & wnd) ? (GuiWindow) (shown & ~wnd) : (GuiWindow) (shown | wnd); + mShown = (mShown & wnd) ? (GuiWindow) (mShown & ~wnd) : (GuiWindow) (mShown | wnd); updateVisible(); } // Disallow all inventory mode windows void disallowAll() { - allowed = GW_None; + mAllowed = GW_None; updateVisible(); } // Allow one or more windows void allow(GuiWindow wnd) { - allowed = (GuiWindow)(allowed | wnd); + mAllowed = (GuiWindow)(mAllowed | wnd); updateVisible(); } bool isAllowed(GuiWindow wnd) const { - return allowed & wnd; + return mAllowed & wnd; } MWGui::DialogueWindow* getDialogueWindow() {return mDialogueWindow;} @@ -155,9 +155,9 @@ namespace MWGui MWGui::ConfirmationDialog* getConfirmationDialog() {return mConfirmationDialog;} MWGui::TradeWindow* getTradeWindow() {return mTradeWindow;} MWGui::SpellWindow* getSpellWindow() {return mSpellWindow;} - MWGui::Console* getConsole() {return console;} + MWGui::Console* getConsole() {return mConsole;} - MyGUI::Gui* getGui() const { return gui; } + MyGUI::Gui* getGui() const { return mGui; } void wmUpdateFps(float fps, unsigned int triangleCount, unsigned int batchCount) { @@ -223,10 +223,10 @@ namespace MWGui void onFrame (float frameDuration); - std::map > getPlayerSkillValues() { return playerSkillValues; } - std::map > getPlayerAttributeValues() { return playerAttributes; } - SkillList getPlayerMinorSkills() { return playerMinorSkills; } - SkillList getPlayerMajorSkills() { return playerMajorSkills; } + std::map > getPlayerSkillValues() { return mPlayerSkillValues; } + std::map > getPlayerAttributeValues() { return mPlayerAttributes; } + SkillList getPlayerMinorSkills() { return mPlayerMinorSkills; } + SkillList getPlayerMajorSkills() { return mPlayerMajorSkills; } /** * Fetches a GMST string from the store, if there is no setting with the given @@ -243,13 +243,13 @@ namespace MWGui private: OEngine::GUI::MyGUIManager *mGuiManager; - HUD *hud; - MapWindow *map; - MainMenu *menu; + HUD *mHud; + MapWindow *mMap; + MainMenu *mMenu; ToolTips *mToolTips; StatsWindow *mStatsWindow; MessageBoxManager *mMessageBoxManager; - Console *console; + Console *mConsole; JournalWindow* mJournal; DialogueWindow *mDialogueWindow; ContainerWindow *mContainerWindow; @@ -267,33 +267,33 @@ namespace MWGui CharacterCreation* mCharGen; // Various stats about player as needed by window manager - ESM::Class playerClass; - std::string playerName; - std::string playerRaceId; - std::map > playerAttributes; - SkillList playerMajorSkills, playerMinorSkills; - std::map > playerSkillValues; - MWMechanics::DynamicStat playerHealth, playerMagicka, playerFatigue; + ESM::Class mPlayerClass; + std::string mPlayerName; + std::string mPlayerRaceId; + std::map > mPlayerAttributes; + SkillList mPlayerMajorSkills, mPlayerMinorSkills; + std::map > mPlayerSkillValues; + MWMechanics::DynamicStat mPlayerHealth, mPlayerMagicka, mPlayerFatigue; - MyGUI::Gui *gui; // Gui + MyGUI::Gui *mGui; // Gui std::vector mGuiModes; - std::vector garbageDialogs; + std::vector mGarbageDialogs; void cleanupGarbage(); - GuiWindow shown; // Currently shown windows in inventory mode + GuiWindow mShown; // Currently shown windows in inventory mode /* Currently ALLOWED windows in inventory mode. This is used at the start of the game, when windows are enabled one by one through script commands. You can manipulate this through using allow() and disableAll(). */ - GuiWindow allowed; + GuiWindow mAllowed; void updateVisible(); // Update visibility of all windows based on mode, shown and allowed settings - int showFPSLevel; + int mShowFPSLevel; float mFPS; unsigned int mTriangleCount; unsigned int mBatchCount; diff --git a/apps/openmw/mwrender/animation.cpp b/apps/openmw/mwrender/animation.cpp index f0a6ab683..549dbf6b2 100644 --- a/apps/openmw/mwrender/animation.cpp +++ b/apps/openmw/mwrender/animation.cpp @@ -6,25 +6,26 @@ #include #include -namespace MWRender{ - std::map Animation::mUniqueIDs; +namespace MWRender +{ + std::map Animation::sUniqueIDs; Animation::Animation(OEngine::Render::OgreRenderer& _rend) - : insert(NULL) + : mInsert(NULL) , mRend(_rend) - , vecRotPos() - , time(0.0f) - , startTime(0.0f) - , stopTime(0.0f) - , animate(0) - , rindexI() - , tindexI() - , shapeNumber(0) - , shapeIndexI() - , shapes(NULL) - , transformations(NULL) - , textmappings(NULL) - , base(NULL) + , mVecRotPos() + , mTime(0.0f) + , mStartTime(0.0f) + , mStopTime(0.0f) + , mAnimate(0) + , mRindexI() + , mTindexI() + , mShapeNumber(0) + , mShapeIndexI() + , mShapes(NULL) + , mTransformations(NULL) + , mTextmappings(NULL) + , mBase(NULL) { } @@ -32,178 +33,191 @@ namespace MWRender{ { } - std::string Animation::getUniqueID(std::string mesh){ - int counter; - std::string copy = mesh; - std::transform(copy.begin(), copy.end(), copy.begin(), ::tolower); - if(mUniqueIDs.find(copy) == mUniqueIDs.end()){ - counter = mUniqueIDs[copy] = 0; - } - else{ - mUniqueIDs[copy] = mUniqueIDs[copy] + 1; - counter = mUniqueIDs[copy]; - } + std::string Animation::getUniqueID(std::string mesh) + { + int counter; + std::string copy = mesh; + std::transform(copy.begin(), copy.end(), copy.begin(), ::tolower); + + if(sUniqueIDs.find(copy) == sUniqueIDs.end()) + { + counter = sUniqueIDs[copy] = 0; + } + else + { + sUniqueIDs[copy] = sUniqueIDs[copy] + 1; + counter = sUniqueIDs[copy]; + } - std::stringstream out; - if(counter > 99 && counter < 1000) - out << "0"; - else if(counter > 9) - out << "00"; - else - out << "000"; - out << counter; - return out.str(); -} - void Animation::startScript(std::string groupname, int mode, int loops){ - //If groupname is recognized set animate to true - //Set the start time and stop time - //How many times to loop - if(groupname == "all"){ - animate = loops; - time = startTime; + std::stringstream out; + + if(counter > 99 && counter < 1000) + out << "0"; + else if(counter > 9) + out << "00"; + else + out << "000"; + out << counter; + + return out.str(); + } + + void Animation::startScript(std::string groupname, int mode, int loops) + { + //If groupname is recognized set animate to true + //Set the start time and stop time + //How many times to loop + if(groupname == "all") + { + mAnimate = loops; + mTime = mStartTime; } - else if(textmappings){ + else if(mTextmappings) + { std::string startName = groupname + ": loop start"; std::string stopName = groupname + ": loop stop"; bool first = false; - if(loops > 1){ + if(loops > 1) + { startName = groupname + ": loop start"; stopName = groupname + ": loop stop"; - for(std::map::iterator iter = textmappings->begin(); iter != textmappings->end(); iter++){ - - std::string current = iter->first.substr(0, startName.size()); - std::transform(current.begin(), current.end(), current.begin(), ::tolower); - std::string current2 = iter->first.substr(0, stopName.size()); - std::transform(current2.begin(), current2.end(), current2.begin(), ::tolower); + for(std::map::iterator iter = mTextmappings->begin(); iter != mTextmappings->end(); iter++) + { - if(current == startName){ - startTime = iter->second; - animate = loops; - time = startTime; - first = true; - } - if(current2 == stopName){ - stopTime = iter->second; - if(first) - break; - } + std::string current = iter->first.substr(0, startName.size()); + std::transform(current.begin(), current.end(), current.begin(), ::tolower); + std::string current2 = iter->first.substr(0, stopName.size()); + std::transform(current2.begin(), current2.end(), current2.begin(), ::tolower); + + if(current == startName) + { + mStartTime = iter->second; + mAnimate = loops; + mTime = mStartTime; + first = true; + } + if(current2 == stopName) + { + mStopTime = iter->second; + if(first) + break; + } } } - if(!first){ + if(!first) + { startName = groupname + ": start"; stopName = groupname + ": stop"; - for(std::map::iterator iter = textmappings->begin(); iter != textmappings->end(); iter++){ - - std::string current = iter->first.substr(0, startName.size()); - std::transform(current.begin(), current.end(), current.begin(), ::tolower); - std::string current2 = iter->first.substr(0, stopName.size()); - std::transform(current2.begin(), current2.end(), current2.begin(), ::tolower); + for(std::map::iterator iter = mTextmappings->begin(); iter != mTextmappings->end(); iter++) + { - if(current == startName){ - startTime = iter->second; - animate = loops; - time = startTime; - first = true; - } - if(current2 == stopName){ - stopTime = iter->second; - if(first) - break; + std::string current = iter->first.substr(0, startName.size()); + std::transform(current.begin(), current.end(), current.begin(), ::tolower); + std::string current2 = iter->first.substr(0, stopName.size()); + std::transform(current2.begin(), current2.end(), current2.begin(), ::tolower); + + if(current == startName) + { + mStartTime = iter->second; + mAnimate = loops; + mTime = mStartTime; + first = true; + } + if(current2 == stopName) + { + mStopTime = iter->second; + if(first) + break; + } } } - } - } - - } - void Animation::stopScript(){ - animate = 0; } - - void Animation::handleShapes(std::vector* allshapes, Ogre::Entity* creaturemodel, Ogre::SkeletonInstance *skel){ - shapeNumber = 0; + + void Animation::stopScript() + { + mAnimate = 0; + } + + void Animation::handleShapes(std::vector* allshapes, Ogre::Entity* creaturemodel, Ogre::SkeletonInstance *skel) + { + mShapeNumber = 0; if (allshapes == NULL || creaturemodel == NULL || skel == NULL) - { return; - } std::vector::iterator allshapesiter; - for(allshapesiter = allshapes->begin(); allshapesiter != allshapes->end(); allshapesiter++) + for(allshapesiter = allshapes->begin(); allshapesiter != allshapes->end(); allshapesiter++) + { + //std::map vecPosRot; - { - //std::map vecPosRot; + Nif::NiTriShapeCopy& copy = *allshapesiter; + std::vector* allvertices = ©.vertices; - Nif::NiTriShapeCopy& copy = *allshapesiter; - std::vector* allvertices = ©.vertices; + //std::set vertices; + //std::set normals; + //std::vector boneinfovector = copy.boneinfo; + std::map >* verticesToChange = ©.vertsToWeights; + //std::cout << "Name " << copy.sname << "\n"; + Ogre::HardwareVertexBufferSharedPtr vbuf = creaturemodel->getMesh()->getSubMesh(copy.sname)->vertexData->vertexBufferBinding->getBuffer(0); + Ogre::Real* pReal = static_cast(vbuf->lock(Ogre::HardwareBuffer::HBL_NORMAL)); - //std::set vertices; - //std::set normals; - //std::vector boneinfovector = copy.boneinfo; - std::map >* verticesToChange = ©.vertsToWeights; + std::vector initialVertices = copy.morph.getInitialVertices(); + //Each shape has multiple indices + if(initialVertices.size() ) + { + if(copy.vertices.size() == initialVertices.size()) + { + //Create if it doesn't already exist + if(mShapeIndexI.size() == static_cast (mShapeNumber)) + { + std::vector vec; + mShapeIndexI.push_back(vec); + } + if(mTime >= copy.morph.getStartTime() && mTime <= copy.morph.getStopTime()) + { + float x; + for (unsigned int i = 0; i < copy.morph.getAdditionalVertices().size(); i++) + { + int j = 0; + if(mShapeIndexI[mShapeNumber].size() <= i) + mShapeIndexI[mShapeNumber].push_back(0); + + if(timeIndex(mTime,copy.morph.getRelevantTimes()[i],(mShapeIndexI[mShapeNumber])[i], j, x)) + { + int indexI = (mShapeIndexI[mShapeNumber])[i]; + std::vector relevantData = (copy.morph.getRelevantData()[i]); + float v1 = relevantData[indexI].x; + float v2 = relevantData[j].x; + float t = v1 + (v2 - v1) * x; + + if ( t < 0 ) + t = 0; + if ( t > 1 ) + t = 1; + if( t != 0 && initialVertices.size() == copy.morph.getAdditionalVertices()[i].size()) + for (unsigned int v = 0; v < initialVertices.size(); v++) + initialVertices[v] += ((copy.morph.getAdditionalVertices()[i])[v]) * t; + } - //std::cout << "Name " << copy.sname << "\n"; - Ogre::HardwareVertexBufferSharedPtr vbuf = creaturemodel->getMesh()->getSubMesh(copy.sname)->vertexData->vertexBufferBinding->getBuffer(0); - Ogre::Real* pReal = static_cast(vbuf->lock(Ogre::HardwareBuffer::HBL_NORMAL)); - - - std::vector initialVertices = copy.morph.getInitialVertices(); - //Each shape has multiple indices - if(initialVertices.size() ) - { - - if(copy.vertices.size() == initialVertices.size()) - { - //Create if it doesn't already exist - if(shapeIndexI.size() == static_cast (shapeNumber)) - { - std::vector vec; - shapeIndexI.push_back(vec); - } - if(time >= copy.morph.getStartTime() && time <= copy.morph.getStopTime()){ - float x; - for (unsigned int i = 0; i < copy.morph.getAdditionalVertices().size(); i++){ - int j = 0; - if(shapeIndexI[shapeNumber].size() <= i) - shapeIndexI[shapeNumber].push_back(0); - - - if(timeIndex(time,copy.morph.getRelevantTimes()[i],(shapeIndexI[shapeNumber])[i], j, x)){ - int indexI = (shapeIndexI[shapeNumber])[i]; - std::vector relevantData = (copy.morph.getRelevantData()[i]); - float v1 = relevantData[indexI].x; - float v2 = relevantData[j].x; - float t = v1 + (v2 - v1) * x; - if ( t < 0 ) t = 0; - if ( t > 1 ) t = 1; - if( t != 0 && initialVertices.size() == copy.morph.getAdditionalVertices()[i].size()) - { - for (unsigned int v = 0; v < initialVertices.size(); v++){ - initialVertices[v] += ((copy.morph.getAdditionalVertices()[i])[v]) * t; - } - } - - } - - - - } - - allvertices = &initialVertices; } - shapeNumber++; - } - } + + allvertices = &initialVertices; + } + mShapeNumber++; + } + } - if(verticesToChange->size() > 0){ + if(verticesToChange->size() > 0) + { for(std::map >::iterator iter = verticesToChange->begin(); iter != verticesToChange->end(); iter++) @@ -214,26 +228,25 @@ namespace MWRender{ Nif::NiSkinData::BoneInfoCopy* boneinfocopy = &(allshapesiter->boneinfo[inds[0].boneinfocopyindex]); Ogre::Bone *bonePtr = 0; - - Ogre::Vector3 vecPos; Ogre::Quaternion vecRot; - std::map::iterator result = vecRotPos.find(boneinfocopy); + std::map::iterator result = mVecRotPos.find(boneinfocopy); - if(result == vecRotPos.end()){ + if(result == mVecRotPos.end()) + { bonePtr = skel->getBone(boneinfocopy->bonename); vecPos = bonePtr->_getDerivedPosition() + bonePtr->_getDerivedOrientation() * boneinfocopy->trafo.trans; vecRot = bonePtr->_getDerivedOrientation() * boneinfocopy->trafo.rotation; - - PosAndRot both; - both.vecPos = vecPos; - both.vecRot = vecRot; - vecRotPos[boneinfocopy] = both; + PosAndRot both; + both.vecPos = vecPos; + both.vecRot = vecRot; + mVecRotPos[boneinfocopy] = both; } - else{ + else + { PosAndRot both = result->second; vecPos = both.vecPos; vecRot = both.vecRot; @@ -241,263 +254,249 @@ namespace MWRender{ Ogre::Vector3 absVertPos = (vecPos + vecRot * currentVertex) * inds[0].weight; - - - for(std::size_t i = 1; i < inds.size(); i++){ + for(std::size_t i = 1; i < inds.size(); i++) + { boneinfocopy = &(allshapesiter->boneinfo[inds[i].boneinfocopyindex]); - result = vecRotPos.find(boneinfocopy); + result = mVecRotPos.find(boneinfocopy); - - if(result == vecRotPos.end()){ + if(result == mVecRotPos.end()) + { bonePtr = skel->getBone(boneinfocopy->bonename); vecPos = bonePtr->_getDerivedPosition() + bonePtr->_getDerivedOrientation() * boneinfocopy->trafo.trans; vecRot = bonePtr->_getDerivedOrientation() * boneinfocopy->trafo.rotation; - PosAndRot both; - both.vecPos = vecPos; - both.vecRot = vecRot; - vecRotPos[boneinfocopy] = both; + PosAndRot both; + both.vecPos = vecPos; + both.vecRot = vecRot; + mVecRotPos[boneinfocopy] = both; } - else{ - PosAndRot both = result->second; - vecPos = both.vecPos; - vecRot = both.vecRot; + else + { + PosAndRot both = result->second; + vecPos = both.vecPos; + vecRot = both.vecRot; } - absVertPos += (vecPos + vecRot * currentVertex) * inds[i].weight; - } - Ogre::Real* addr = (pReal + 3 * verIndex); - *addr = absVertPos.x; - *(addr+1) = absVertPos.y; - *(addr+2) = absVertPos.z; + Ogre::Real* addr = (pReal + 3 * verIndex); + *addr = absVertPos.x; + *(addr+1) = absVertPos.y; + *(addr+2) = absVertPos.z; } + } + else + { + //Ogre::Bone *bonePtr = creaturemodel->getSkeleton()->getBone(copy.bonename); + Ogre::Quaternion shaperot = copy.trafo.rotation; + Ogre::Vector3 shapetrans = copy.trafo.trans; + float shapescale = copy.trafo.scale; + std::vector boneSequence = copy.boneSequence; + + Ogre::Vector3 transmult; + Ogre::Quaternion rotmult; + float scale; + if(boneSequence.size() > 0) + { + std::vector::iterator boneSequenceIter = boneSequence.begin(); + if(skel->hasBone(*boneSequenceIter)) + { + Ogre::Bone *bonePtr = skel->getBone(*boneSequenceIter); + + transmult = bonePtr->getPosition(); + rotmult = bonePtr->getOrientation(); + scale = bonePtr->getScale().x; + boneSequenceIter++; + + for(; boneSequenceIter != boneSequence.end(); boneSequenceIter++) + { + if(skel->hasBone(*boneSequenceIter)) + { + Ogre::Bone *bonePtr = skel->getBone(*boneSequenceIter); + // Computes C = B + AxC*scale + transmult = transmult + rotmult * bonePtr->getPosition(); + rotmult = rotmult * bonePtr->getOrientation(); + scale = scale * bonePtr->getScale().x; + } + //std::cout << "Bone:" << *boneSequenceIter << " "; + } + transmult = transmult + rotmult * shapetrans; + rotmult = rotmult * shaperot; + scale = shapescale * scale; - - - - } - else - { - //Ogre::Bone *bonePtr = creaturemodel->getSkeleton()->getBone(copy.bonename); - Ogre::Quaternion shaperot = copy.trafo.rotation; - Ogre::Vector3 shapetrans = copy.trafo.trans; - float shapescale = copy.trafo.scale; - std::vector boneSequence = copy.boneSequence; - - Ogre::Vector3 transmult; - Ogre::Quaternion rotmult; - float scale; - if(boneSequence.size() > 0){ - std::vector::iterator boneSequenceIter = boneSequence.begin(); - if(skel->hasBone(*boneSequenceIter)){ - Ogre::Bone *bonePtr = skel->getBone(*boneSequenceIter); - - - - - transmult = bonePtr->getPosition(); - rotmult = bonePtr->getOrientation(); - scale = bonePtr->getScale().x; - boneSequenceIter++; - - for(; boneSequenceIter != boneSequence.end(); boneSequenceIter++) - { - if(skel->hasBone(*boneSequenceIter)){ - Ogre::Bone *bonePtr = skel->getBone(*boneSequenceIter); - // Computes C = B + AxC*scale - transmult = transmult + rotmult * bonePtr->getPosition(); - rotmult = rotmult * bonePtr->getOrientation(); - scale = scale * bonePtr->getScale().x; - } - //std::cout << "Bone:" << *boneSequenceIter << " "; - } - transmult = transmult + rotmult * shapetrans; - rotmult = rotmult * shaperot; - scale = shapescale * scale; - - //std::cout << "Position: " << transmult << "Rotation: " << rotmult << "\n"; - } + //std::cout << "Position: " << transmult << "Rotation: " << rotmult << "\n"; } - else - { - transmult = shapetrans; - rotmult = shaperot; - scale = shapescale; - } - - - - - // Computes C = B + AxC*scale - // final_vector = old_vector + old_rotation*new_vector*old_scale/ - - for(unsigned int i = 0; i < allvertices->size(); i++){ - Ogre::Vector3 current = transmult + rotmult * (*allvertices)[i]; - Ogre::Real* addr = pReal + i * 3; - *addr = current.x; - *(addr+1) = current.y; - *(addr + 2) = current.z; - - }/* - for(int i = 0; i < allnormals.size(); i++){ - Ogre::Vector3 current =rotmult * allnormals[i]; - Ogre::Real* addr = pRealNormal + i * 3; - *addr = current.x; - *(addr+1) = current.y; - *(addr + 2) = current.z; - - }*/ + } + else + { + transmult = shapetrans; + rotmult = shaperot; + scale = shapescale; + } - } - vbuf->unlock(); + // Computes C = B + AxC*scale + // final_vector = old_vector + old_rotation*new_vector*old_scale/ - } + for(unsigned int i = 0; i < allvertices->size(); i++) + { + Ogre::Vector3 current = transmult + rotmult * (*allvertices)[i]; + Ogre::Real* addr = pReal + i * 3; + *addr = current.x; + *(addr+1) = current.y; + *(addr + 2) = current.z; + + }/* + for(int i = 0; i < allnormals.size(); i++){ + Ogre::Vector3 current =rotmult * allnormals[i]; + Ogre::Real* addr = pRealNormal + i * 3; + *addr = current.x; + *(addr+1) = current.y; + *(addr + 2) = current.z; + + }*/ + } + vbuf->unlock(); + } + } - bool Animation::timeIndex( float time, const std::vector & times, int & i, int & j, float & x ){ - int count; - if ( (count = times.size()) > 0 ) - { - if ( time <= times[0] ) - { - i = j = 0; - x = 0.0; - return true; - } - if ( time >= times[count - 1] ) - { - i = j = count - 1; - x = 0.0; - return true; - } - - if ( i < 0 || i >= count ) - i = 0; - - float tI = times[i]; - if ( time > tI ) - { - j = i + 1; - float tJ; - while ( time >= ( tJ = times[j]) ) - { - i = j++; - tI = tJ; - } - x = ( time - tI ) / ( tJ - tI ); - return true; - } - else if ( time < tI ) - { - j = i - 1; - float tJ; - while ( time <= ( tJ = times[j] ) ) - { - i = j--; - tI = tJ; - } - x = ( time - tI ) / ( tJ - tI ); - return true; - } - else - { - j = i; - x = 0.0; - return true; - } - } - else - return false; - -} + + bool Animation::timeIndex( float time, const std::vector & times, int & i, int & j, float & x ) + { + int count; + if ( (count = times.size()) > 0 ) + { + if ( time <= times[0] ) + { + i = j = 0; + x = 0.0; + return true; + } + if ( time >= times[count - 1] ) + { + i = j = count - 1; + x = 0.0; + return true; + } - void Animation::handleAnimationTransforms(){ + if ( i < 0 || i >= count ) + i = 0; + float tI = times[i]; + if ( time > tI ) + { + j = i + 1; + float tJ; + while ( time >= ( tJ = times[j]) ) + { + i = j++; + tI = tJ; + } + x = ( time - tI ) / ( tJ - tI ); + return true; + } + else if ( time < tI ) + { + j = i - 1; + float tJ; + while ( time <= ( tJ = times[j] ) ) + { + i = j--; + tI = tJ; + } + x = ( time - tI ) / ( tJ - tI ); + return true; + } + else + { + j = i; + x = 0.0; + return true; + } + } + else + return false; - Ogre::SkeletonInstance* skel = base->getSkeleton(); + } + void Animation::handleAnimationTransforms() + { + Ogre::SkeletonInstance* skel = mBase->getSkeleton(); - Ogre::Bone* b = skel->getRootBone(); - b->setOrientation(Ogre::Real(.3),Ogre::Real(.3),Ogre::Real(.3), Ogre::Real(.3)); //This is a trick + Ogre::Bone* b = skel->getRootBone(); + b->setOrientation(Ogre::Real(.3),Ogre::Real(.3),Ogre::Real(.3), Ogre::Real(.3)); //This is a trick skel->_updateTransforms(); - //skel->_notifyManualBonesDirty(); - - base->getAllAnimationStates()->_notifyDirty(); - //base->_updateAnimation(); - //base->_notifyMoved(); - - - - - std::vector::iterator iter; - int slot = 0; - if(transformations){ - for(iter = transformations->begin(); iter != transformations->end(); iter++){ - if(time < iter->getStartTime() || time < startTime || time > iter->getStopTime()) - { - slot++; - continue; - } - - float x; - float x2; - - const std::vector & quats = iter->getQuat(); - - const std::vector & ttime = iter->gettTime(); - + //skel->_notifyManualBonesDirty(); - const std::vector & rtime = iter->getrTime(); - int rindexJ = rindexI[slot]; + mBase->getAllAnimationStates()->_notifyDirty(); + //mBase->_updateAnimation(); + //mBase->_notifyMoved(); - timeIndex(time, rtime, rindexI[slot], rindexJ, x2); - int tindexJ = tindexI[slot]; - - - const std::vector & translist1 = iter->getTranslist1(); - - timeIndex(time, ttime, tindexI[slot], tindexJ, x); + std::vector::iterator iter; + int slot = 0; + if(mTransformations) + { + for(iter = mTransformations->begin(); iter != mTransformations->end(); iter++) + { + if(mTime < iter->getStartTime() || mTime < mStartTime || mTime > iter->getStopTime()) + { + slot++; + continue; + } - Ogre::Vector3 t; - Ogre::Quaternion r; + float x; + float x2; - bool bTrans = translist1.size() > 0; + const std::vector & quats = iter->getQuat(); + const std::vector & ttime = iter->gettTime(); + const std::vector & rtime = iter->getrTime(); + int rindexJ = mRindexI[slot]; - bool bQuats = quats.size() > 0; + timeIndex(mTime, rtime, mRindexI[slot], rindexJ, x2); + int tindexJ = mTindexI[slot]; - if(skel->hasBone(iter->getBonename())){ - Ogre::Bone* bone = skel->getBone(iter->getBonename()); - if(bTrans){ - Ogre::Vector3 v1 = translist1[tindexI[slot]]; - Ogre::Vector3 v2 = translist1[tindexJ]; - t = (v1 + (v2 - v1) * x); - bone->setPosition(t); + const std::vector & translist1 = iter->getTranslist1(); - } - if(bQuats){ - r = Ogre::Quaternion::Slerp(x2, quats[rindexI[slot]], quats[rindexJ], true); - bone->setOrientation(r); - } + timeIndex(mTime, ttime, mTindexI[slot], tindexJ, x); + Ogre::Vector3 t; + Ogre::Quaternion r; + bool bTrans = translist1.size() > 0; + bool bQuats = quats.size() > 0; + if(skel->hasBone(iter->getBonename())) + { + Ogre::Bone* bone = skel->getBone(iter->getBonename()); + + if(bTrans) + { + Ogre::Vector3 v1 = translist1[mTindexI[slot]]; + Ogre::Vector3 v2 = translist1[tindexJ]; + t = (v1 + (v2 - v1) * x); + bone->setPosition(t); - } + } + + if(bQuats) + { + r = Ogre::Quaternion::Slerp(x2, quats[mRindexI[slot]], quats[rindexJ], true); + bone->setOrientation(r); + } + } - slot++; + slot++; + } + skel->_updateTransforms(); + mBase->getAllAnimationStates()->_notifyDirty(); + } } - skel->_updateTransforms(); - base->getAllAnimationStates()->_notifyDirty(); -} -} } diff --git a/apps/openmw/mwrender/animation.hpp b/apps/openmw/mwrender/animation.hpp index 4ab60cff4..cebffaaf2 100644 --- a/apps/openmw/mwrender/animation.hpp +++ b/apps/openmw/mwrender/animation.hpp @@ -22,36 +22,30 @@ struct PosAndRot{ class Animation{ protected: - Ogre::SceneNode* insert; + Ogre::SceneNode* mInsert; OEngine::Render::OgreRenderer &mRend; - std::map vecRotPos; - static std::map mUniqueIDs; - - - - - - float time; - float startTime; - float stopTime; - int animate; - //Represents a rotation index for each bone - std::vectorrindexI; + std::map mVecRotPos; + static std::map sUniqueIDs; + + float mTime; + float mStartTime; + float mStopTime; + int mAnimate; + //Represents a rotation index for each bone + std::vectormRindexI; //Represents a translation index for each bone - std::vectortindexI; - - //Only shapes with morphing data will use a shape number - int shapeNumber; - std::vector > shapeIndexI; + std::vectormTindexI; - //Ogre::SkeletonInstance* skel; - std::vector* shapes; //All the NiTriShapeData for a creature + //Only shapes with morphing data will use a shape number + int mShapeNumber; + std::vector > mShapeIndexI; + //Ogre::SkeletonInstance* skel; + std::vector* mShapes; //All the NiTriShapeData for a creature - - std::vector* transformations; - std::map* textmappings; - Ogre::Entity* base; + std::vector* mTransformations; + std::map* mTextmappings; + Ogre::Entity* mBase; void handleShapes(std::vector* allshapes, Ogre::Entity* creaturemodel, Ogre::SkeletonInstance *skel); void handleAnimationTransforms(); bool timeIndex( float time, const std::vector & times, int & i, int & j, float & x ); @@ -63,7 +57,6 @@ class Animation{ void startScript(std::string groupname, int mode, int loops); void stopScript(); - virtual ~Animation(); }; diff --git a/apps/openmw/mwrender/creatureanimation.cpp b/apps/openmw/mwrender/creatureanimation.cpp index e1fa7868c..20037a773 100644 --- a/apps/openmw/mwrender/creatureanimation.cpp +++ b/apps/openmw/mwrender/creatureanimation.cpp @@ -12,26 +12,28 @@ using namespace Ogre; using namespace NifOgre; namespace MWRender{ -CreatureAnimation::~CreatureAnimation(){ +CreatureAnimation::~CreatureAnimation() +{ +} -} -CreatureAnimation::CreatureAnimation(const MWWorld::Ptr& ptr, OEngine::Render::OgreRenderer& _rend): Animation(_rend){ - insert = ptr.getRefData().getBaseNode(); - MWWorld::LiveCellRef *ref = - ptr.get(); +CreatureAnimation::CreatureAnimation(const MWWorld::Ptr& ptr, OEngine::Render::OgreRenderer& _rend): Animation(_rend) +{ + mInsert = ptr.getRefData().getBaseNode(); + MWWorld::LiveCellRef *ref = ptr.get(); assert (ref->base != NULL); - if(!ref->base->model.empty()){ + if(!ref->base->model.empty()) + { const std::string &mesh = "meshes\\" + ref->base->model; std::string meshNumbered = mesh + getUniqueID(mesh) + ">|"; NifOgre::NIFLoader::load(meshNumbered); - base = mRend.getScene()->createEntity(meshNumbered); - base->setVisibilityFlags(RV_Actors); + mBase = mRend.getScene()->createEntity(meshNumbered); + mBase->setVisibilityFlags(RV_Actors); bool transparent = false; - for (unsigned int i=0; igetNumSubEntities(); ++i) + for (unsigned int i=0; i < mBase->getNumSubEntities(); ++i) { - Ogre::MaterialPtr mat = base->getSubEntity(i)->getMaterial(); + Ogre::MaterialPtr mat = mBase->getSubEntity(i)->getMaterial(); Ogre::Material::TechniqueIterator techIt = mat->getTechniqueIterator(); while (techIt.hasMoreElements()) { @@ -46,46 +48,51 @@ CreatureAnimation::CreatureAnimation(const MWWorld::Ptr& ptr, OEngine::Render::O } } } - base->setRenderQueueGroup(transparent ? RQG_Alpha : RQG_Main); + mBase->setRenderQueueGroup(transparent ? RQG_Alpha : RQG_Main); std::string meshZero = mesh + "0000>|"; - if((transformations = (NIFLoader::getSingletonPtr())->getAnim(meshZero))){ - - for(std::size_t init = 0; init < transformations->size(); init++){ - rindexI.push_back(0); - tindexI.push_back(0); - } - stopTime = transformations->begin()->getStopTime(); - startTime = transformations->begin()->getStartTime(); - shapes = (NIFLoader::getSingletonPtr())->getShapes(meshZero); + if((mTransformations = (NIFLoader::getSingletonPtr())->getAnim(meshZero))) + { + for(std::size_t init = 0; init < mTransformations->size(); init++) + { + mRindexI.push_back(0); + mTindexI.push_back(0); + } + mStopTime = mTransformations->begin()->getStopTime(); + mStartTime = mTransformations->begin()->getStartTime(); + mShapes = (NIFLoader::getSingletonPtr())->getShapes(meshZero); } - textmappings = NIFLoader::getSingletonPtr()->getTextIndices(meshZero); - insert->attachObject(base); + mTextmappings = NIFLoader::getSingletonPtr()->getTextIndices(meshZero); + mInsert->attachObject(mBase); } } -void CreatureAnimation::runAnimation(float timepassed){ - vecRotPos.clear(); - if(animate > 0){ - //Add the amount of time passed to time +void CreatureAnimation::runAnimation(float timepassed) +{ + mVecRotPos.clear(); + if(mAnimate > 0) + { + //Add the amount of time passed to time - //Handle the animation transforms dependent on time + //Handle the animation transforms dependent on time - //Handle the shapes dependent on animation transforms - time += timepassed; - if(time >= stopTime){ - animate--; + //Handle the shapes dependent on animation transforms + mTime += timepassed; + if(mTime >= mStopTime) + { + mAnimate--; //std::cout << "Stopping the animation\n"; - if(animate == 0) - time = stopTime; + if(mAnimate == 0) + mTime = mStopTime; else - time = startTime + (time - stopTime); + mTime = mStartTime + (mTime - mStopTime); } handleAnimationTransforms(); - handleShapes(shapes, base, base->getSkeleton()); + handleShapes(mShapes, mBase, mBase->getSkeleton()); - } + } } + } diff --git a/apps/openmw/mwrender/creatureanimation.hpp b/apps/openmw/mwrender/creatureanimation.hpp index f50b7904b..d158eecb4 100644 --- a/apps/openmw/mwrender/creatureanimation.hpp +++ b/apps/openmw/mwrender/creatureanimation.hpp @@ -17,8 +17,7 @@ class CreatureAnimation: public Animation{ public: virtual ~CreatureAnimation(); CreatureAnimation(const MWWorld::Ptr& ptr, OEngine::Render::OgreRenderer& _rend); - virtual void runAnimation(float timepassed); - + virtual void runAnimation(float timepassed); }; } diff --git a/apps/openmw/mwrender/npcanimation.cpp b/apps/openmw/mwrender/npcanimation.cpp index fa88b7277..ef075b12b 100644 --- a/apps/openmw/mwrender/npcanimation.cpp +++ b/apps/openmw/mwrender/npcanimation.cpp @@ -14,118 +14,117 @@ using namespace Ogre; using namespace NifOgre; namespace MWRender{ -NpcAnimation::~NpcAnimation(){ - +NpcAnimation::~NpcAnimation() +{ } -NpcAnimation::NpcAnimation(const MWWorld::Ptr& ptr, OEngine::Render::OgreRenderer& _rend, MWWorld::InventoryStore& _inv): Animation(_rend), mStateID(-1), inv(_inv), timeToChange(0), - robe(inv.end()), helmet(inv.end()), shirt(inv.end()), - cuirass(inv.end()), greaves(inv.end()), - leftpauldron(inv.end()), rightpauldron(inv.end()), - boots(inv.end()), - leftglove(inv.end()), rightglove(inv.end()), skirtiter(inv.end()), - pants(inv.end()), +NpcAnimation::NpcAnimation(const MWWorld::Ptr& ptr, OEngine::Render::OgreRenderer& _rend, MWWorld::InventoryStore& _inv): Animation(_rend), mStateID(-1), mInv(_inv), timeToChange(0), + robe(mInv.end()), helmet(mInv.end()), shirt(mInv.end()), + cuirass(mInv.end()), greaves(mInv.end()), + leftpauldron(mInv.end()), rightpauldron(mInv.end()), + boots(mInv.end()), + leftglove(mInv.end()), rightglove(mInv.end()), skirtiter(mInv.end()), + pants(mInv.end()), lclavicle(0), - rclavicle(0), - rupperArm(0), - lupperArm(0), - rUpperLeg(0), - lUpperLeg(0), - lForearm(0), - rForearm(0), - lWrist(0), - rWrist(0), - rKnee(0), - lKnee(0), - neck(0), - rAnkle(0), - lAnkle(0), - groin(0), - lfoot(0), - rfoot(0) - { - MWWorld::LiveCellRef *ref = - ptr.get(); - Ogre::Entity* blank = 0; - std::vector* blankshape = 0; - zero = std::make_pair(blank, blankshape); - chest = std::make_pair(blank, blankshape); - tail = std::make_pair(blank, blankshape); - lFreeFoot = std::make_pair(blank, blankshape); - rFreeFoot = std::make_pair(blank, blankshape); - rhand = std::make_pair(blank, blankshape); - lhand = std::make_pair(blank, blankshape); - skirt = std::make_pair(blank, blankshape); - for (int init = 0; init < 27; init++){ - partslots[init] = -1; //each slot is empty - partpriorities[init] = 0; - } - - - //Part selection on last character of the file string - // " Tri Chest - // * Tri Tail - // : Tri Left Foot - // < Tri Right Foot - // > Tri Left Hand - // ? Tri Right Hand - // | Normal - - //Mirroring Parts on second to last character - //suffix == '*' - // vector = Ogre::Vector3(-1,1,1); - // suffix == '?' - // vector = Ogre::Vector3(1,-1,1); - // suffix == '<' - // vector = Ogre::Vector3(1,1,-1); - - - std::string hairID = ref->base->hair; - std::string headID = ref->base->head; - headModel = "meshes\\" + - MWBase::Environment::get().getWorld()->getStore().bodyParts.find(headID)->model; - - hairModel = "meshes\\" + - MWBase::Environment::get().getWorld()->getStore().bodyParts.find(hairID)->model; - npcName = ref->base->name; - - //ESMStore::Races r = - const ESM::Race* race = MWBase::Environment::get().getWorld()->getStore().races.find(ref->base->race); - - - bodyRaceID = headID.substr(0, headID.find_last_of("head_") - 4); - char secondtolast = bodyRaceID.at(bodyRaceID.length() - 2); - isFemale = tolower(secondtolast) == 'f'; - std::transform(bodyRaceID.begin(), bodyRaceID.end(), bodyRaceID.begin(), ::tolower); - isBeast = bodyRaceID == "b_n_khajiit_m_" || bodyRaceID == "b_n_khajiit_f_" || bodyRaceID == "b_n_argonian_m_" || bodyRaceID == "b_n_argonian_f_"; - - /*std::cout << "Race: " << ref->base->race ; - if(female){ - std::cout << " Sex: Female" << " Height: " << race->data.height.female << "\n"; - } - else{ - std::cout << " Sex: Male" << " Height: " << race->data.height.male << "\n"; - }*/ - - - - std::string smodel = "meshes\\base_anim.nif"; - if(isBeast) - smodel = "meshes\\base_animkna.nif"; - - insert = ptr.getRefData().getBaseNode(); - assert(insert); - - NifOgre::NIFLoader::load(smodel); - - base = mRend.getScene()->createEntity(smodel); - - base->setVisibilityFlags(RV_Actors); + rclavicle(0), + rupperArm(0), + lupperArm(0), + rUpperLeg(0), + lUpperLeg(0), + lForearm(0), + rForearm(0), + lWrist(0), + rWrist(0), + rKnee(0), + lKnee(0), + neck(0), + rAnkle(0), + lAnkle(0), + groin(0), + lfoot(0), + rfoot(0) +{ + MWWorld::LiveCellRef *ref = ptr.get(); + Ogre::Entity* blank = 0; + std::vector* blankshape = 0; + mZero = std::make_pair(blank, blankshape); + mChest = std::make_pair(blank, blankshape); + mTail = std::make_pair(blank, blankshape); + mLFreeFoot = std::make_pair(blank, blankshape); + mRFreeFoot = std::make_pair(blank, blankshape); + mRhand = std::make_pair(blank, blankshape); + mLhand = std::make_pair(blank, blankshape); + mSkirt = std::make_pair(blank, blankshape); + for (int init = 0; init < 27; init++) + { + mPartslots[init] = -1; //each slot is empty + mPartPriorities[init] = 0; + } + + + //Part selection on last character of the file string + // " Tri Chest + // * Tri Tail + // : Tri Left Foot + // < Tri Right Foot + // > Tri Left Hand + // ? Tri Right Hand + // | Normal + + //Mirroring Parts on second to last character + //suffix == '*' + // vector = Ogre::Vector3(-1,1,1); + // suffix == '?' + // vector = Ogre::Vector3(1,-1,1); + // suffix == '<' + // vector = Ogre::Vector3(1,1,-1); + + + std::string hairID = ref->base->hair; + std::string headID = ref->base->head; + headModel = "meshes\\" + + MWBase::Environment::get().getWorld()->getStore().bodyParts.find(headID)->model; + + hairModel = "meshes\\" + + MWBase::Environment::get().getWorld()->getStore().bodyParts.find(hairID)->model; + npcName = ref->base->name; + + //ESMStore::Races r = + const ESM::Race* race = MWBase::Environment::get().getWorld()->getStore().races.find(ref->base->race); + + + bodyRaceID = headID.substr(0, headID.find_last_of("head_") - 4); + char secondtolast = bodyRaceID.at(bodyRaceID.length() - 2); + isFemale = tolower(secondtolast) == 'f'; + std::transform(bodyRaceID.begin(), bodyRaceID.end(), bodyRaceID.begin(), ::tolower); + isBeast = bodyRaceID == "b_n_khajiit_m_" || bodyRaceID == "b_n_khajiit_f_" || bodyRaceID == "b_n_argonian_m_" || bodyRaceID == "b_n_argonian_f_"; + + /*std::cout << "Race: " << ref->base->race ; + if(female){ + std::cout << " Sex: Female" << " Height: " << race->data.height.female << "\n"; + } + else{ + std::cout << " Sex: Male" << " Height: " << race->data.height.male << "\n"; + }*/ + + + std::string smodel = "meshes\\base_anim.nif"; + if(isBeast) + smodel = "meshes\\base_animkna.nif"; + + mInsert = ptr.getRefData().getBaseNode(); + assert(mInsert); + + NifOgre::NIFLoader::load(smodel); + + mBase = mRend.getScene()->createEntity(smodel); + + mBase->setVisibilityFlags(RV_Actors); bool transparent = false; - for (unsigned int i=0; igetNumSubEntities(); ++i) + for (unsigned int i=0; igetNumSubEntities(); ++i) { - Ogre::MaterialPtr mat = base->getSubEntity(i)->getMaterial(); + Ogre::MaterialPtr mat = mBase->getSubEntity(i)->getMaterial(); Ogre::Material::TechniqueIterator techIt = mat->getTechniqueIterator(); while (techIt.hasMoreElements()) { @@ -140,625 +139,694 @@ NpcAnimation::NpcAnimation(const MWWorld::Ptr& ptr, OEngine::Render::OgreRendere } } } - base->setRenderQueueGroup(transparent ? RQG_Alpha : RQG_Main); + mBase->setRenderQueueGroup(transparent ? RQG_Alpha : RQG_Main); - base->setSkipAnimationStateUpdate(true); //Magical line of code, this makes the bones + mBase->setSkipAnimationStateUpdate(true); //Magical line of code, this makes the bones //stay in the same place when we skipanim, or open a gui window + if((mTransformations = (NIFLoader::getSingletonPtr())->getAnim(smodel))) + { - if((transformations = (NIFLoader::getSingletonPtr())->getAnim(smodel))){ - - for(unsigned int init = 0; init < transformations->size(); init++){ - rindexI.push_back(0); - tindexI.push_back(0); - } + for(unsigned int init = 0; init < mTransformations->size(); init++) + { + mRindexI.push_back(0); + mTindexI.push_back(0); + } - stopTime = transformations->begin()->getStopTime(); - startTime = transformations->begin()->getStartTime(); + mStopTime = mTransformations->begin()->getStopTime(); + mStartTime = mTransformations->begin()->getStartTime(); } - textmappings = NIFLoader::getSingletonPtr()->getTextIndices(smodel); - insert->attachObject(base); + mTextmappings = NIFLoader::getSingletonPtr()->getTextIndices(smodel); + mInsert->attachObject(mBase); - if(isFemale) - insert->scale(race->data.height.female, race->data.height.female, race->data.height.female); - else - insert->scale(race->data.height.male, race->data.height.male, race->data.height.male); - updateParts(); + if(isFemale) + mInsert->scale(race->data.height.female, race->data.height.female, race->data.height.female); + else + mInsert->scale(race->data.height.male, race->data.height.male, race->data.height.male); + updateParts(); } -void NpcAnimation::updateParts(){ +void NpcAnimation::updateParts() +{ + + bool apparelChanged = false; - bool apparelChanged = false; + //mInv.getSlot(MWWorld::InventoryStore::Slot_Robe); + if(robe != mInv.getSlot(MWWorld::InventoryStore::Slot_Robe)) + { + //A robe was added or removed + removePartGroup(MWWorld::InventoryStore::Slot_Robe); + robe = mInv.getSlot(MWWorld::InventoryStore::Slot_Robe); + apparelChanged = true; + } + if(skirtiter != mInv.getSlot(MWWorld::InventoryStore::Slot_Skirt)) + { + //A robe was added or removed + removePartGroup(MWWorld::InventoryStore::Slot_Skirt); + skirtiter = mInv.getSlot(MWWorld::InventoryStore::Slot_Skirt); + apparelChanged = true; + } + if(helmet != mInv.getSlot(MWWorld::InventoryStore::Slot_Helmet)) + { + apparelChanged = true; + helmet = mInv.getSlot(MWWorld::InventoryStore::Slot_Helmet); + removePartGroup(MWWorld::InventoryStore::Slot_Helmet); + + } + if(cuirass != mInv.getSlot(MWWorld::InventoryStore::Slot_Cuirass)) + { + cuirass = mInv.getSlot(MWWorld::InventoryStore::Slot_Cuirass); + removePartGroup(MWWorld::InventoryStore::Slot_Cuirass); + apparelChanged = true; - //inv.getSlot(MWWorld::InventoryStore::Slot_Robe); - if(robe != inv.getSlot(MWWorld::InventoryStore::Slot_Robe)){ - //A robe was added or removed - removePartGroup(MWWorld::InventoryStore::Slot_Robe); - robe = inv.getSlot(MWWorld::InventoryStore::Slot_Robe); - apparelChanged = true; - } - if(skirtiter != inv.getSlot(MWWorld::InventoryStore::Slot_Skirt)){ - //A robe was added or removed - removePartGroup(MWWorld::InventoryStore::Slot_Skirt); - skirtiter = inv.getSlot(MWWorld::InventoryStore::Slot_Skirt); - apparelChanged = true; - } - if(helmet != inv.getSlot(MWWorld::InventoryStore::Slot_Helmet)){ - apparelChanged = true; - helmet = inv.getSlot(MWWorld::InventoryStore::Slot_Helmet); - removePartGroup(MWWorld::InventoryStore::Slot_Helmet); + } + if(greaves != mInv.getSlot(MWWorld::InventoryStore::Slot_Greaves)) + { + greaves = mInv.getSlot(MWWorld::InventoryStore::Slot_Greaves); + removePartGroup(MWWorld::InventoryStore::Slot_Greaves); + apparelChanged = true; + } + if(leftpauldron != mInv.getSlot(MWWorld::InventoryStore::Slot_LeftPauldron)) + { + leftpauldron = mInv.getSlot(MWWorld::InventoryStore::Slot_LeftPauldron); + removePartGroup(MWWorld::InventoryStore::Slot_LeftPauldron); + apparelChanged = true; - } - if(cuirass != inv.getSlot(MWWorld::InventoryStore::Slot_Cuirass)){ - cuirass = inv.getSlot(MWWorld::InventoryStore::Slot_Cuirass); - removePartGroup(MWWorld::InventoryStore::Slot_Cuirass); - apparelChanged = true; + } + if(rightpauldron != mInv.getSlot(MWWorld::InventoryStore::Slot_RightPauldron)) + { + rightpauldron = mInv.getSlot(MWWorld::InventoryStore::Slot_RightPauldron); + removePartGroup(MWWorld::InventoryStore::Slot_RightPauldron); + apparelChanged = true; - } - if(greaves != inv.getSlot(MWWorld::InventoryStore::Slot_Greaves)){ - greaves = inv.getSlot(MWWorld::InventoryStore::Slot_Greaves); - removePartGroup(MWWorld::InventoryStore::Slot_Greaves); - apparelChanged = true; - } - if(leftpauldron != inv.getSlot(MWWorld::InventoryStore::Slot_LeftPauldron)){ - leftpauldron = inv.getSlot(MWWorld::InventoryStore::Slot_LeftPauldron); - removePartGroup(MWWorld::InventoryStore::Slot_LeftPauldron); - apparelChanged = true; + } + if(!isBeast && boots != mInv.getSlot(MWWorld::InventoryStore::Slot_Boots)) + { + boots = mInv.getSlot(MWWorld::InventoryStore::Slot_Boots); + removePartGroup(MWWorld::InventoryStore::Slot_Boots); + apparelChanged = true; - } - if(rightpauldron != inv.getSlot(MWWorld::InventoryStore::Slot_RightPauldron)){ - rightpauldron = inv.getSlot(MWWorld::InventoryStore::Slot_RightPauldron); - removePartGroup(MWWorld::InventoryStore::Slot_RightPauldron); - apparelChanged = true; + } + if(leftglove != mInv.getSlot(MWWorld::InventoryStore::Slot_LeftGauntlet)) + { + leftglove = mInv.getSlot(MWWorld::InventoryStore::Slot_LeftGauntlet); + removePartGroup(MWWorld::InventoryStore::Slot_LeftGauntlet); + apparelChanged = true; - } - if(!isBeast && boots != inv.getSlot(MWWorld::InventoryStore::Slot_Boots)){ - boots = inv.getSlot(MWWorld::InventoryStore::Slot_Boots); - removePartGroup(MWWorld::InventoryStore::Slot_Boots); - apparelChanged = true; + } + if(rightglove != mInv.getSlot(MWWorld::InventoryStore::Slot_RightGauntlet)) + { + rightglove = mInv.getSlot(MWWorld::InventoryStore::Slot_RightGauntlet); + removePartGroup(MWWorld::InventoryStore::Slot_RightGauntlet); + apparelChanged = true; - } - if(leftglove != inv.getSlot(MWWorld::InventoryStore::Slot_LeftGauntlet)){ - leftglove = inv.getSlot(MWWorld::InventoryStore::Slot_LeftGauntlet); - removePartGroup(MWWorld::InventoryStore::Slot_LeftGauntlet); - apparelChanged = true; + } + if(shirt != mInv.getSlot(MWWorld::InventoryStore::Slot_Shirt)) + { + shirt = mInv.getSlot(MWWorld::InventoryStore::Slot_Shirt); + removePartGroup(MWWorld::InventoryStore::Slot_Shirt); + apparelChanged = true; - } - if(rightglove != inv.getSlot(MWWorld::InventoryStore::Slot_RightGauntlet)){ - rightglove = inv.getSlot(MWWorld::InventoryStore::Slot_RightGauntlet); - removePartGroup(MWWorld::InventoryStore::Slot_RightGauntlet); - apparelChanged = true; + } + if(pants != mInv.getSlot(MWWorld::InventoryStore::Slot_Pants)) + { + pants = mInv.getSlot(MWWorld::InventoryStore::Slot_Pants); + removePartGroup(MWWorld::InventoryStore::Slot_Pants); + apparelChanged = true; + } + if(apparelChanged) + { + + if(robe != mInv.end()) + { + MWWorld::Ptr ptr = *robe; + + const ESM::Clothing *clothes = (ptr.get())->base; + std::vector parts = clothes->parts.parts; + addPartGroup(MWWorld::InventoryStore::Slot_Robe, 5, parts); + reserveIndividualPart(ESM::PRT_Groin, MWWorld::InventoryStore::Slot_Robe, 5); + reserveIndividualPart(ESM::PRT_Skirt, MWWorld::InventoryStore::Slot_Robe, 5); + reserveIndividualPart(ESM::PRT_RLeg, MWWorld::InventoryStore::Slot_Robe, 5); + reserveIndividualPart(ESM::PRT_LLeg, MWWorld::InventoryStore::Slot_Robe, 5); + reserveIndividualPart(ESM::PRT_RUpperarm, MWWorld::InventoryStore::Slot_Robe, 5); + reserveIndividualPart(ESM::PRT_LUpperarm, MWWorld::InventoryStore::Slot_Robe, 5); + reserveIndividualPart(ESM::PRT_RKnee, MWWorld::InventoryStore::Slot_Robe, 5); + reserveIndividualPart(ESM::PRT_LKnee, MWWorld::InventoryStore::Slot_Robe, 5); + reserveIndividualPart(ESM::PRT_RForearm, MWWorld::InventoryStore::Slot_Robe, 5); + reserveIndividualPart(ESM::PRT_LForearm, MWWorld::InventoryStore::Slot_Robe, 5); + reserveIndividualPart(ESM::PRT_RPauldron, MWWorld::InventoryStore::Slot_Robe, 5); + reserveIndividualPart(ESM::PRT_LPauldron, MWWorld::InventoryStore::Slot_Robe, 5); + } + if(skirtiter != mInv.end()) + { + MWWorld::Ptr ptr = *skirtiter; + + const ESM::Clothing *clothes = (ptr.get())->base; + std::vector parts = clothes->parts.parts; + addPartGroup(MWWorld::InventoryStore::Slot_Skirt, 4, parts); + reserveIndividualPart(ESM::PRT_Groin, MWWorld::InventoryStore::Slot_Skirt, 4); + reserveIndividualPart(ESM::PRT_RLeg, MWWorld::InventoryStore::Slot_Skirt, 4); + reserveIndividualPart(ESM::PRT_LLeg, MWWorld::InventoryStore::Slot_Skirt, 4); } - if(shirt != inv.getSlot(MWWorld::InventoryStore::Slot_Shirt)){ - shirt = inv.getSlot(MWWorld::InventoryStore::Slot_Shirt); - removePartGroup(MWWorld::InventoryStore::Slot_Shirt); - apparelChanged = true; + + if(helmet != mInv.end()) + { + removeIndividualPart(ESM::PRT_Hair); + const ESM::Armor *armor = (helmet->get())->base; + std::vector parts = armor->parts.parts; + addPartGroup(MWWorld::InventoryStore::Slot_Helmet, 3, parts); } - if(pants != inv.getSlot(MWWorld::InventoryStore::Slot_Pants)){ - pants = inv.getSlot(MWWorld::InventoryStore::Slot_Pants); - removePartGroup(MWWorld::InventoryStore::Slot_Pants); - apparelChanged = true; + if(cuirass != mInv.end()) + { + const ESM::Armor *armor = (cuirass->get())->base; + std::vector parts = armor->parts.parts; + addPartGroup(MWWorld::InventoryStore::Slot_Cuirass, 3, parts); } + if(greaves != mInv.end()) + { + const ESM::Armor *armor = (greaves->get())->base; + std::vector parts = armor->parts.parts; + addPartGroup(MWWorld::InventoryStore::Slot_Greaves, 3, parts); + } - if(apparelChanged){ + if(leftpauldron != mInv.end()) + { + const ESM::Armor *armor = (leftpauldron->get())->base; + std::vector parts = armor->parts.parts; + addPartGroup(MWWorld::InventoryStore::Slot_LeftPauldron, 3, parts); - if(robe != inv.end()) - { - MWWorld::Ptr ptr = *robe; + } + if(rightpauldron != mInv.end()) + { + const ESM::Armor *armor = (rightpauldron->get())->base; + std::vector parts = armor->parts.parts; + addPartGroup(MWWorld::InventoryStore::Slot_RightPauldron, 3, parts); - const ESM::Clothing *clothes = (ptr.get())->base; - std::vector parts = clothes->parts.parts; - addPartGroup(MWWorld::InventoryStore::Slot_Robe, 5, parts); - reserveIndividualPart(ESM::PRT_Groin, MWWorld::InventoryStore::Slot_Robe, 5); - reserveIndividualPart(ESM::PRT_Skirt, MWWorld::InventoryStore::Slot_Robe, 5); - reserveIndividualPart(ESM::PRT_RLeg, MWWorld::InventoryStore::Slot_Robe, 5); - reserveIndividualPart(ESM::PRT_LLeg, MWWorld::InventoryStore::Slot_Robe, 5); - reserveIndividualPart(ESM::PRT_RUpperarm, MWWorld::InventoryStore::Slot_Robe, 5); - reserveIndividualPart(ESM::PRT_LUpperarm, MWWorld::InventoryStore::Slot_Robe, 5); - reserveIndividualPart(ESM::PRT_RKnee, MWWorld::InventoryStore::Slot_Robe, 5); - reserveIndividualPart(ESM::PRT_LKnee, MWWorld::InventoryStore::Slot_Robe, 5); - reserveIndividualPart(ESM::PRT_RForearm, MWWorld::InventoryStore::Slot_Robe, 5); - reserveIndividualPart(ESM::PRT_LForearm, MWWorld::InventoryStore::Slot_Robe, 5); - reserveIndividualPart(ESM::PRT_RPauldron, MWWorld::InventoryStore::Slot_Robe, 5); - reserveIndividualPart(ESM::PRT_LPauldron, MWWorld::InventoryStore::Slot_Robe, 5); - } - if(skirtiter != inv.end()) + } + if(!isBeast && boots != mInv.end()) + { + if(boots->getTypeName() == typeid(ESM::Clothing).name()) { - MWWorld::Ptr ptr = *skirtiter; - - const ESM::Clothing *clothes = (ptr.get())->base; + const ESM::Clothing *clothes = (boots->get())->base; std::vector parts = clothes->parts.parts; - addPartGroup(MWWorld::InventoryStore::Slot_Skirt, 4, parts); - reserveIndividualPart(ESM::PRT_Groin, MWWorld::InventoryStore::Slot_Skirt, 4); - reserveIndividualPart(ESM::PRT_RLeg, MWWorld::InventoryStore::Slot_Skirt, 4); - reserveIndividualPart(ESM::PRT_LLeg, MWWorld::InventoryStore::Slot_Skirt, 4); + addPartGroup(MWWorld::InventoryStore::Slot_Boots, 2, parts); } - - if(helmet != inv.end()){ - removeIndividualPart(ESM::PRT_Hair); - const ESM::Armor *armor = (helmet->get())->base; + else if(boots->getTypeName() == typeid(ESM::Armor).name()) + { + const ESM::Armor *armor = (boots->get())->base; std::vector parts = armor->parts.parts; - addPartGroup(MWWorld::InventoryStore::Slot_Helmet, 3, parts); - + addPartGroup(MWWorld::InventoryStore::Slot_Boots, 3, parts); } - if(cuirass != inv.end()){ - const ESM::Armor *armor = (cuirass->get())->base; - std::vector parts = armor->parts.parts; - addPartGroup(MWWorld::InventoryStore::Slot_Cuirass, 3, parts); + } + if(leftglove != mInv.end()){ + if(leftglove->getTypeName() == typeid(ESM::Clothing).name()) + { + const ESM::Clothing *clothes = (leftglove->get())->base; + std::vector parts = clothes->parts.parts; + addPartGroup(MWWorld::InventoryStore::Slot_LeftGauntlet, 2, parts); } - if(greaves != inv.end()){ - const ESM::Armor *armor = (greaves->get())->base; + else + { + const ESM::Armor *armor = (leftglove->get())->base; std::vector parts = armor->parts.parts; - addPartGroup(MWWorld::InventoryStore::Slot_Greaves, 3, parts); - + addPartGroup(MWWorld::InventoryStore::Slot_LeftGauntlet, 3, parts); } - if(leftpauldron != inv.end()){ - const ESM::Armor *armor = (leftpauldron->get())->base; - std::vector parts = armor->parts.parts; - addPartGroup(MWWorld::InventoryStore::Slot_LeftPauldron, 3, parts); - + } + if(rightglove != mInv.end()){ + if(rightglove->getTypeName() == typeid(ESM::Clothing).name()) + { + const ESM::Clothing *clothes = (rightglove->get())->base; + std::vector parts = clothes->parts.parts; + addPartGroup(MWWorld::InventoryStore::Slot_RightGauntlet, 2, parts); } - if(rightpauldron != inv.end()){ - const ESM::Armor *armor = (rightpauldron->get())->base; + else + { + const ESM::Armor *armor = (rightglove->get())->base; std::vector parts = armor->parts.parts; - addPartGroup(MWWorld::InventoryStore::Slot_RightPauldron, 3, parts); - + addPartGroup(MWWorld::InventoryStore::Slot_RightGauntlet, 3, parts); } - if(!isBeast && boots != inv.end()){ - if(boots->getTypeName() == typeid(ESM::Clothing).name()){ - const ESM::Clothing *clothes = (boots->get())->base; - std::vector parts = clothes->parts.parts; - addPartGroup(MWWorld::InventoryStore::Slot_Boots, 2, parts); - } - else if(boots->getTypeName() == typeid(ESM::Armor).name()) - { - const ESM::Armor *armor = (boots->get())->base; - std::vector parts = armor->parts.parts; - addPartGroup(MWWorld::InventoryStore::Slot_Boots, 3, parts); - } - } - if(leftglove != inv.end()){ - if(leftglove->getTypeName() == typeid(ESM::Clothing).name()){ - const ESM::Clothing *clothes = (leftglove->get())->base; - std::vector parts = clothes->parts.parts; - addPartGroup(MWWorld::InventoryStore::Slot_LeftGauntlet, 2, parts); - } - else - { - const ESM::Armor *armor = (leftglove->get())->base; - std::vector parts = armor->parts.parts; - addPartGroup(MWWorld::InventoryStore::Slot_LeftGauntlet, 3, parts); - } - - } - if(rightglove != inv.end()){ - if(rightglove->getTypeName() == typeid(ESM::Clothing).name()){ - const ESM::Clothing *clothes = (rightglove->get())->base; - std::vector parts = clothes->parts.parts; - addPartGroup(MWWorld::InventoryStore::Slot_RightGauntlet, 2, parts); - } - else - { - const ESM::Armor *armor = (rightglove->get())->base; - std::vector parts = armor->parts.parts; - addPartGroup(MWWorld::InventoryStore::Slot_RightGauntlet, 3, parts); - } - - } - - if(shirt != inv.end()){ - const ESM::Clothing *clothes = (shirt->get())->base; - std::vector parts = clothes->parts.parts; - addPartGroup(MWWorld::InventoryStore::Slot_Shirt, 2, parts); - } - if(pants != inv.end()){ - const ESM::Clothing *clothes = (pants->get())->base; - std::vector parts = clothes->parts.parts; - addPartGroup(MWWorld::InventoryStore::Slot_Pants, 2, parts); - } } - if(partpriorities[ESM::PRT_Head] < 1){ - addOrReplaceIndividualPart(ESM::PRT_Head, -1,1,headModel); - } - if(partpriorities[ESM::PRT_Hair] < 1 && partpriorities[ESM::PRT_Head] <= 1){ - addOrReplaceIndividualPart(ESM::PRT_Hair, -1,1,hairModel); - } - if(partpriorities[ESM::PRT_Neck] < 1){ - const ESM::BodyPart *neckPart = MWBase::Environment::get().getWorld()->getStore().bodyParts.search (bodyRaceID + "neck"); - if(neckPart) - addOrReplaceIndividualPart(ESM::PRT_Neck, -1,1,"meshes\\" + neckPart->model); - } - if(partpriorities[ESM::PRT_Cuirass] < 1){ - const ESM::BodyPart *chestPart = MWBase::Environment::get().getWorld()->getStore().bodyParts.search (bodyRaceID + "chest"); - if(chestPart) - addOrReplaceIndividualPart(ESM::PRT_Cuirass, -1,1,"meshes\\" + chestPart->model); - } - - if(partpriorities[ESM::PRT_Groin] < 1){ - const ESM::BodyPart *groinPart = MWBase::Environment::get().getWorld()->getStore().bodyParts.search (bodyRaceID + "groin"); - if(groinPart) - addOrReplaceIndividualPart(ESM::PRT_Groin, -1,1,"meshes\\" + groinPart->model); - } - if(partpriorities[ESM::PRT_RHand] < 1){ - const ESM::BodyPart *handPart = MWBase::Environment::get().getWorld()->getStore().bodyParts.search (bodyRaceID + "hand"); - if(!handPart) - handPart = MWBase::Environment::get().getWorld()->getStore().bodyParts.search (bodyRaceID + "hands"); - if(handPart) - addOrReplaceIndividualPart(ESM::PRT_RHand, -1,1,"meshes\\" + handPart->model); - } - if(partpriorities[ESM::PRT_LHand] < 1){ - const ESM::BodyPart *handPart = MWBase::Environment::get().getWorld()->getStore().bodyParts.search (bodyRaceID + "hand"); - if(!handPart) - handPart = MWBase::Environment::get().getWorld()->getStore().bodyParts.search (bodyRaceID + "hands"); - if(handPart) - addOrReplaceIndividualPart(ESM::PRT_LHand, -1,1,"meshes\\" + handPart->model); - } - - if(partpriorities[ESM::PRT_RWrist] < 1){ - const ESM::BodyPart *wristPart = MWBase::Environment::get().getWorld()->getStore().bodyParts.search (bodyRaceID + "wrist"); - if(wristPart) - addOrReplaceIndividualPart(ESM::PRT_RWrist, -1,1,"meshes\\" + wristPart->model); - } - if(partpriorities[ESM::PRT_LWrist] < 1){ - const ESM::BodyPart *wristPart = MWBase::Environment::get().getWorld()->getStore().bodyParts.search (bodyRaceID + "wrist"); - if(wristPart) - addOrReplaceIndividualPart(ESM::PRT_LWrist, -1,1,"meshes\\" + wristPart->model); - } - if(partpriorities[ESM::PRT_RForearm] < 1){ - const ESM::BodyPart *forearmPart = MWBase::Environment::get().getWorld()->getStore().bodyParts.search (bodyRaceID + "forearm"); - if(bodyRaceID == "b_n_argonian_f_") - forearmPart = MWBase::Environment::get().getWorld()->getStore().bodyParts.search ("b_n_argonian_m_forearm"); - if(forearmPart) - addOrReplaceIndividualPart(ESM::PRT_RForearm, -1,1,"meshes\\" + forearmPart->model); - } - if(partpriorities[ESM::PRT_LForearm] < 1){ - const ESM::BodyPart *forearmPart = MWBase::Environment::get().getWorld()->getStore().bodyParts.search (bodyRaceID + "forearm"); - if(bodyRaceID == "b_n_argonian_f_") - forearmPart = MWBase::Environment::get().getWorld()->getStore().bodyParts.search ("b_n_argonian_m_forearm"); - if(forearmPart) - addOrReplaceIndividualPart(ESM::PRT_LForearm, -1,1,"meshes\\" + forearmPart->model); - } - if(partpriorities[ESM::PRT_RUpperarm] < 1){ - const ESM::BodyPart *armPart = MWBase::Environment::get().getWorld()->getStore().bodyParts.search (bodyRaceID + "upper arm"); - if(armPart) - addOrReplaceIndividualPart(ESM::PRT_RUpperarm, -1,1,"meshes\\" + armPart->model); - } - if(partpriorities[ESM::PRT_LUpperarm] < 1){ - const ESM::BodyPart *armPart = MWBase::Environment::get().getWorld()->getStore().bodyParts.search (bodyRaceID + "upper arm"); - if(armPart) - addOrReplaceIndividualPart(ESM::PRT_LUpperarm, -1,1,"meshes\\" + armPart->model); - } - if(partpriorities[ESM::PRT_RFoot] < 1){ - const ESM::BodyPart *footPart = MWBase::Environment::get().getWorld()->getStore().bodyParts.search (bodyRaceID + "foot"); - if(isBeast && !footPart) - footPart = MWBase::Environment::get().getWorld()->getStore().bodyParts.search (bodyRaceID + "feet"); - if(footPart) - addOrReplaceIndividualPart(ESM::PRT_RFoot, -1,1,"meshes\\" + footPart->model); - } - if(partpriorities[ESM::PRT_LFoot] < 1){ - const ESM::BodyPart *footPart = MWBase::Environment::get().getWorld()->getStore().bodyParts.search (bodyRaceID + "foot"); - if(isBeast && !footPart) - footPart = MWBase::Environment::get().getWorld()->getStore().bodyParts.search (bodyRaceID + "feet"); - if(footPart) - addOrReplaceIndividualPart(ESM::PRT_LFoot, -1,1,"meshes\\" + footPart->model); - } - if(partpriorities[ESM::PRT_RAnkle] < 1){ - const ESM::BodyPart *anklePart = MWBase::Environment::get().getWorld()->getStore().bodyParts.search (bodyRaceID + "ankle"); - if(anklePart) - addOrReplaceIndividualPart(ESM::PRT_RAnkle, -1,1,"meshes\\" + anklePart->model); - } - if(partpriorities[ESM::PRT_LAnkle] < 1){ - const ESM::BodyPart *anklePart = MWBase::Environment::get().getWorld()->getStore().bodyParts.search (bodyRaceID + "ankle"); - if(anklePart) - addOrReplaceIndividualPart(ESM::PRT_LAnkle, -1,1,"meshes\\" + anklePart->model); - } - if(partpriorities[ESM::PRT_RKnee] < 1){ - const ESM::BodyPart *kneePart = MWBase::Environment::get().getWorld()->getStore().bodyParts.search (bodyRaceID + "knee"); - if(kneePart) - addOrReplaceIndividualPart(ESM::PRT_RKnee, -1,1,"meshes\\" + kneePart->model); - } - if(partpriorities[ESM::PRT_LKnee] < 1){ - const ESM::BodyPart *kneePart = MWBase::Environment::get().getWorld()->getStore().bodyParts.search (bodyRaceID + "knee"); - if(kneePart) - addOrReplaceIndividualPart(ESM::PRT_LKnee, -1,1,"meshes\\" + kneePart->model); - } - if(partpriorities[ESM::PRT_RLeg] < 1){ - const ESM::BodyPart *legPart = MWBase::Environment::get().getWorld()->getStore().bodyParts.search (bodyRaceID + "upper leg"); - if(legPart) - addOrReplaceIndividualPart(ESM::PRT_RLeg, -1,1,"meshes\\" + legPart->model); - } - if(partpriorities[ESM::PRT_LLeg] < 1){ - const ESM::BodyPart *legPart = MWBase::Environment::get().getWorld()->getStore().bodyParts.search (bodyRaceID + "upper leg"); - if(legPart) - addOrReplaceIndividualPart(ESM::PRT_LLeg, -1,1,"meshes\\" + legPart->model); - } - if(partpriorities[ESM::PRT_Tail] < 1){ - const ESM::BodyPart *tailPart = MWBase::Environment::get().getWorld()->getStore().bodyParts.search (bodyRaceID + "tail"); - if(tailPart) - addOrReplaceIndividualPart(ESM::PRT_Tail, -1,1,"meshes\\" + tailPart->model); - } - - - - + if(shirt != mInv.end()) + { + const ESM::Clothing *clothes = (shirt->get())->base; + std::vector parts = clothes->parts.parts; + addPartGroup(MWWorld::InventoryStore::Slot_Shirt, 2, parts); + } + if(pants != mInv.end()) + { + const ESM::Clothing *clothes = (pants->get())->base; + std::vector parts = clothes->parts.parts; + addPartGroup(MWWorld::InventoryStore::Slot_Pants, 2, parts); + } + } + if(mPartPriorities[ESM::PRT_Head] < 1) + { + addOrReplaceIndividualPart(ESM::PRT_Head, -1,1,headModel); + } + if(mPartPriorities[ESM::PRT_Hair] < 1 && mPartPriorities[ESM::PRT_Head] <= 1) + { + addOrReplaceIndividualPart(ESM::PRT_Hair, -1,1,hairModel); + } + if(mPartPriorities[ESM::PRT_Neck] < 1) + { + const ESM::BodyPart *neckPart = MWBase::Environment::get().getWorld()->getStore().bodyParts.search (bodyRaceID + "neck"); + if(neckPart) + addOrReplaceIndividualPart(ESM::PRT_Neck, -1,1,"meshes\\" + neckPart->model); + } + if(mPartPriorities[ESM::PRT_Cuirass] < 1) + { + const ESM::BodyPart *chestPart = MWBase::Environment::get().getWorld()->getStore().bodyParts.search (bodyRaceID + "chest"); + if(chestPart) + addOrReplaceIndividualPart(ESM::PRT_Cuirass, -1,1,"meshes\\" + chestPart->model); + } + if(mPartPriorities[ESM::PRT_Groin] < 1) + { + const ESM::BodyPart *groinPart = MWBase::Environment::get().getWorld()->getStore().bodyParts.search (bodyRaceID + "groin"); + if(groinPart) + addOrReplaceIndividualPart(ESM::PRT_Groin, -1,1,"meshes\\" + groinPart->model); + } + if(mPartPriorities[ESM::PRT_RHand] < 1) + { + const ESM::BodyPart *handPart = MWBase::Environment::get().getWorld()->getStore().bodyParts.search (bodyRaceID + "hand"); + if(!handPart) + handPart = MWBase::Environment::get().getWorld()->getStore().bodyParts.search (bodyRaceID + "hands"); + if(handPart) + addOrReplaceIndividualPart(ESM::PRT_RHand, -1,1,"meshes\\" + handPart->model); + } + if(mPartPriorities[ESM::PRT_LHand] < 1) + { + const ESM::BodyPart *handPart = MWBase::Environment::get().getWorld()->getStore().bodyParts.search (bodyRaceID + "hand"); + if(!handPart) + handPart = MWBase::Environment::get().getWorld()->getStore().bodyParts.search (bodyRaceID + "hands"); + if(handPart) + addOrReplaceIndividualPart(ESM::PRT_LHand, -1,1,"meshes\\" + handPart->model); + } + if(mPartPriorities[ESM::PRT_RWrist] < 1) + { + const ESM::BodyPart *wristPart = MWBase::Environment::get().getWorld()->getStore().bodyParts.search (bodyRaceID + "wrist"); + if(wristPart) + addOrReplaceIndividualPart(ESM::PRT_RWrist, -1,1,"meshes\\" + wristPart->model); + } + if(mPartPriorities[ESM::PRT_LWrist] < 1) + { + const ESM::BodyPart *wristPart = MWBase::Environment::get().getWorld()->getStore().bodyParts.search (bodyRaceID + "wrist"); + if(wristPart) + addOrReplaceIndividualPart(ESM::PRT_LWrist, -1,1,"meshes\\" + wristPart->model); + } + if(mPartPriorities[ESM::PRT_RForearm] < 1) + { + const ESM::BodyPart *forearmPart = MWBase::Environment::get().getWorld()->getStore().bodyParts.search (bodyRaceID + "forearm"); + if(bodyRaceID == "b_n_argonian_f_") + forearmPart = MWBase::Environment::get().getWorld()->getStore().bodyParts.search ("b_n_argonian_m_forearm"); + if(forearmPart) + addOrReplaceIndividualPart(ESM::PRT_RForearm, -1,1,"meshes\\" + forearmPart->model); + } + if(mPartPriorities[ESM::PRT_LForearm] < 1) + { + const ESM::BodyPart *forearmPart = MWBase::Environment::get().getWorld()->getStore().bodyParts.search (bodyRaceID + "forearm"); + if(bodyRaceID == "b_n_argonian_f_") + forearmPart = MWBase::Environment::get().getWorld()->getStore().bodyParts.search ("b_n_argonian_m_forearm"); + if(forearmPart) + addOrReplaceIndividualPart(ESM::PRT_LForearm, -1,1,"meshes\\" + forearmPart->model); + } + if(mPartPriorities[ESM::PRT_RUpperarm] < 1) + { + const ESM::BodyPart *armPart = MWBase::Environment::get().getWorld()->getStore().bodyParts.search (bodyRaceID + "upper arm"); + if(armPart) + addOrReplaceIndividualPart(ESM::PRT_RUpperarm, -1,1,"meshes\\" + armPart->model); + } + if(mPartPriorities[ESM::PRT_LUpperarm] < 1) + { + const ESM::BodyPart *armPart = MWBase::Environment::get().getWorld()->getStore().bodyParts.search (bodyRaceID + "upper arm"); + if(armPart) + addOrReplaceIndividualPart(ESM::PRT_LUpperarm, -1,1,"meshes\\" + armPart->model); + } + if(mPartPriorities[ESM::PRT_RFoot] < 1) + { + const ESM::BodyPart *footPart = MWBase::Environment::get().getWorld()->getStore().bodyParts.search (bodyRaceID + "foot"); + if(isBeast && !footPart) + footPart = MWBase::Environment::get().getWorld()->getStore().bodyParts.search (bodyRaceID + "feet"); + if(footPart) + addOrReplaceIndividualPart(ESM::PRT_RFoot, -1,1,"meshes\\" + footPart->model); + } + if(mPartPriorities[ESM::PRT_LFoot] < 1) + { + const ESM::BodyPart *footPart = MWBase::Environment::get().getWorld()->getStore().bodyParts.search (bodyRaceID + "foot"); + if(isBeast && !footPart) + footPart = MWBase::Environment::get().getWorld()->getStore().bodyParts.search (bodyRaceID + "feet"); + if(footPart) + addOrReplaceIndividualPart(ESM::PRT_LFoot, -1,1,"meshes\\" + footPart->model); + } + if(mPartPriorities[ESM::PRT_RAnkle] < 1) + { + const ESM::BodyPart *anklePart = MWBase::Environment::get().getWorld()->getStore().bodyParts.search (bodyRaceID + "ankle"); + if(anklePart) + addOrReplaceIndividualPart(ESM::PRT_RAnkle, -1,1,"meshes\\" + anklePart->model); + } + if(mPartPriorities[ESM::PRT_LAnkle] < 1) + { + const ESM::BodyPart *anklePart = MWBase::Environment::get().getWorld()->getStore().bodyParts.search (bodyRaceID + "ankle"); + if(anklePart) + addOrReplaceIndividualPart(ESM::PRT_LAnkle, -1,1,"meshes\\" + anklePart->model); + } + if(mPartPriorities[ESM::PRT_RKnee] < 1) + { + const ESM::BodyPart *kneePart = MWBase::Environment::get().getWorld()->getStore().bodyParts.search (bodyRaceID + "knee"); + if(kneePart) + addOrReplaceIndividualPart(ESM::PRT_RKnee, -1,1,"meshes\\" + kneePart->model); + } + if(mPartPriorities[ESM::PRT_LKnee] < 1) + { + const ESM::BodyPart *kneePart = MWBase::Environment::get().getWorld()->getStore().bodyParts.search (bodyRaceID + "knee"); + if(kneePart) + addOrReplaceIndividualPart(ESM::PRT_LKnee, -1,1,"meshes\\" + kneePart->model); + } + if(mPartPriorities[ESM::PRT_RLeg] < 1) + { + const ESM::BodyPart *legPart = MWBase::Environment::get().getWorld()->getStore().bodyParts.search (bodyRaceID + "upper leg"); + if(legPart) + addOrReplaceIndividualPart(ESM::PRT_RLeg, -1,1,"meshes\\" + legPart->model); + } + if(mPartPriorities[ESM::PRT_LLeg] < 1) + { + const ESM::BodyPart *legPart = MWBase::Environment::get().getWorld()->getStore().bodyParts.search (bodyRaceID + "upper leg"); + if(legPart) + addOrReplaceIndividualPart(ESM::PRT_LLeg, -1,1,"meshes\\" + legPart->model); + } + if(mPartPriorities[ESM::PRT_Tail] < 1) + { + const ESM::BodyPart *tailPart = MWBase::Environment::get().getWorld()->getStore().bodyParts.search (bodyRaceID + "tail"); + if(tailPart) + addOrReplaceIndividualPart(ESM::PRT_Tail, -1,1,"meshes\\" + tailPart->model); + } } -Ogre::Entity* NpcAnimation::insertBoundedPart(const std::string &mesh, std::string bonename){ - +Ogre::Entity* NpcAnimation::insertBoundedPart(const std::string &mesh, std::string bonename) +{ NIFLoader::load(mesh); Ogre::Entity* part = mRend.getScene()->createEntity(mesh); part->setVisibilityFlags(RV_Actors); - base->attachObjectToBone(bonename, part); + mBase->attachObjectToBone(bonename, part); return part; } -void NpcAnimation::insertFootPart(int type, const std::string &mesh){ +void NpcAnimation::insertFootPart(int type, const std::string &mesh) +{ std::string meshAndSuffix = mesh; if(type == ESM::PRT_LFoot) meshAndSuffix += "*|"; NIFLoader::load(meshAndSuffix); Ogre::Entity* part = mRend.getScene()->createEntity(meshAndSuffix); std::vector* shape = ((NIFLoader::getSingletonPtr())->getShapes(meshAndSuffix)); - if(shape == 0){ - if(type == ESM::PRT_LFoot){ - base->attachObjectToBone("Left Foot", part); + if(shape == 0) + { + if(type == ESM::PRT_LFoot) + { + mBase->attachObjectToBone("Left Foot", part); lfoot = part; } - else if (type == ESM::PRT_RFoot){ - base->attachObjectToBone("Right Foot", part); + else if (type == ESM::PRT_RFoot) + { + mBase->attachObjectToBone("Right Foot", part); rfoot = part; } } - else{ + else + { if(type == ESM::PRT_LFoot) - lFreeFoot = insertFreePart(mesh, "::"); + mLFreeFoot = insertFreePart(mesh, "::"); else if (type == ESM::PRT_RFoot) - rFreeFoot = insertFreePart(mesh, ":<"); + mRFreeFoot = insertFreePart(mesh, ":<"); } - - } -std::pair*> NpcAnimation::insertFreePart(const std::string &mesh, const std::string& suffix){ +std::pair*> NpcAnimation::insertFreePart(const std::string &mesh, const std::string& suffix) +{ std::string meshNumbered = mesh + getUniqueID(mesh + suffix) + suffix; NIFLoader::load(meshNumbered); Ogre::Entity* part = mRend.getScene()->createEntity(meshNumbered); part->setVisibilityFlags(RV_Actors); - insert->attachObject(part); + mInsert->attachObject(part); std::vector* shape = ((NIFLoader::getSingletonPtr())->getShapes(mesh + "0000" + suffix)); - if(shape){ - handleShapes(shape, part, base->getSkeleton()); - } - std::pair*> pair = std::make_pair(part, shape); - return pair; + if(shape) + handleShapes(shape, part, mBase->getSkeleton()); + std::pair*> pair = std::make_pair(part, shape); + return pair; } +void NpcAnimation::runAnimation(float timepassed) +{ + if(timeToChange > .2){ + timeToChange = 0; + updateParts(); + } - -void NpcAnimation::runAnimation(float timepassed){ - - if(timeToChange > .2){ - - timeToChange = 0; - - updateParts(); - } - - timeToChange += timepassed; + timeToChange += timepassed; //1. Add the amount of time passed to time - //2. Handle the animation transforms dependent on time + //2. Handle the animation transforms dependent on time - //3. Handle the shapes dependent on animation transforms - if(animate > 0){ - time += timepassed; + //3. Handle the shapes dependent on animation transforms + if(mAnimate > 0) + { + mTime += timepassed; - if(time > stopTime){ - animate--; + if(mTime > mStopTime) + { + mAnimate--; - if(animate == 0) - time = stopTime; + if(mAnimate == 0) + mTime = mStopTime; else - time = startTime + (time - stopTime); + mTime = mStartTime + (mTime - mStopTime); } - handleAnimationTransforms(); + handleAnimationTransforms(); + mVecRotPos.clear(); - vecRotPos.clear(); + if(mLFreeFoot.first) + handleShapes(mLFreeFoot.second, mLFreeFoot.first, mBase->getSkeleton()); + if(mRFreeFoot.first) + handleShapes(mRFreeFoot.second, mRFreeFoot.first, mBase->getSkeleton()); + if(mChest.first) + handleShapes(mChest.second, mChest.first, mBase->getSkeleton()); + if(mTail.first) + handleShapes(mTail.second, mTail.first, mBase->getSkeleton()); + if(mSkirt.first) + handleShapes(mSkirt.second, mSkirt.first, mBase->getSkeleton()); + if(mLhand.first) + handleShapes(mLhand.second, mLhand.first, mBase->getSkeleton()); + if(mRhand.first) + handleShapes(mRhand.second, mRhand.first, mBase->getSkeleton()); - if(lFreeFoot.first) - handleShapes(lFreeFoot.second, lFreeFoot.first, base->getSkeleton()); - if(rFreeFoot.first) - handleShapes(rFreeFoot.second, rFreeFoot.first, base->getSkeleton()); - - if(chest.first) - handleShapes(chest.second, chest.first, base->getSkeleton()); - if(tail.first) - handleShapes(tail.second, tail.first, base->getSkeleton()); - if(skirt.first){ - handleShapes(skirt.second, skirt.first, base->getSkeleton()); - } - if(lhand.first) - handleShapes(lhand.second, lhand.first, base->getSkeleton()); - if(rhand.first) - handleShapes(rhand.second, rhand.first, base->getSkeleton()); - -} + } } void NpcAnimation::removeIndividualPart(int type){ - partpriorities[type] = 0; - partslots[type] = -1; + mPartPriorities[type] = 0; + mPartslots[type] = -1; - if(type == ESM::PRT_Head && head){ //0 - base->detachObjectFromBone(head); + if(type == ESM::PRT_Head && head) //0 + { + mBase->detachObjectFromBone(head); head = 0; } - else if(type == ESM::PRT_Hair && hair){//1 - base->detachObjectFromBone(hair); + else if(type == ESM::PRT_Hair && hair) //1 + { + mBase->detachObjectFromBone(hair); hair = 0; } - else if(type == ESM::PRT_Neck && neck){//2 - base->detachObjectFromBone(neck); + else if(type == ESM::PRT_Neck && neck) //2 + { + mBase->detachObjectFromBone(neck); neck = 0; } - else if(type == ESM::PRT_Cuirass && chest.first){//3 - insert->detachObject(chest.first); - chest = zero; + else if(type == ESM::PRT_Cuirass && mChest.first) //3 + { + mInsert->detachObject(mChest.first); + mChest = mZero; } - else if(type == ESM::PRT_Groin && groin){//4 - base->detachObjectFromBone(groin); + else if(type == ESM::PRT_Groin && groin) //4 + { + mBase->detachObjectFromBone(groin); groin = 0; } - else if(type == ESM::PRT_Skirt && skirt.first){//5 - insert->detachObject(skirt.first); - skirt = zero; + else if(type == ESM::PRT_Skirt && mSkirt.first) //5 + { + mInsert->detachObject(mSkirt.first); + mSkirt = mZero; } - else if(type == ESM::PRT_RHand && rhand.first){//6 - insert->detachObject(rhand.first); - rhand = zero; + else if(type == ESM::PRT_RHand && mRhand.first) //6 + { + mInsert->detachObject(mRhand.first); + mRhand = mZero; } - else if(type == ESM::PRT_LHand && lhand.first){//7 - insert->detachObject(lhand.first); - lhand = zero; + else if(type == ESM::PRT_LHand && mLhand.first) //7 + { + mInsert->detachObject(mLhand.first); + mLhand = mZero; } - else if(type == ESM::PRT_RWrist && rWrist){//8 - base->detachObjectFromBone(rWrist); + else if(type == ESM::PRT_RWrist && rWrist) //8 + { + mBase->detachObjectFromBone(rWrist); rWrist = 0; } - else if(type == ESM::PRT_LWrist && lWrist){//9 - base->detachObjectFromBone(lWrist); + else if(type == ESM::PRT_LWrist && lWrist) //9 + { + mBase->detachObjectFromBone(lWrist); lWrist = 0; } - else if(type == ESM::PRT_Shield){//10 + else if(type == ESM::PRT_Shield) //10 + { } - else if(type == ESM::PRT_RForearm && rForearm){//11 - base->detachObjectFromBone(rForearm); + else if(type == ESM::PRT_RForearm && rForearm) //11 + { + mBase->detachObjectFromBone(rForearm); rForearm = 0; } - else if(type == ESM::PRT_LForearm && lForearm){//12 - base->detachObjectFromBone(lForearm); + else if(type == ESM::PRT_LForearm && lForearm) //12 + { + mBase->detachObjectFromBone(lForearm); lForearm = 0; } - else if(type == ESM::PRT_RUpperarm && rupperArm){//13 - base->detachObjectFromBone(rupperArm); + else if(type == ESM::PRT_RUpperarm && rupperArm) //13 + { + mBase->detachObjectFromBone(rupperArm); rupperArm = 0; } - else if(type == ESM::PRT_LUpperarm && lupperArm){//14 - base->detachObjectFromBone(lupperArm); + else if(type == ESM::PRT_LUpperarm && lupperArm) //14 + { + mBase->detachObjectFromBone(lupperArm); lupperArm = 0; } - else if(type == ESM::PRT_RFoot){ //15 - if(rfoot){ - base->detachObjectFromBone(rfoot); + else if(type == ESM::PRT_RFoot) //15 + { + if(rfoot) + { + mBase->detachObjectFromBone(rfoot); rfoot = 0; } - else if(rFreeFoot.first){ - insert->detachObject(rFreeFoot.first); - rFreeFoot = zero; + else if(mRFreeFoot.first) + { + mInsert->detachObject(mRFreeFoot.first); + mRFreeFoot = mZero; } } - else if(type == ESM::PRT_LFoot){ //16 - if(lfoot){ - base->detachObjectFromBone(lfoot); + else if(type == ESM::PRT_LFoot) //16 + { + if(lfoot) + { + mBase->detachObjectFromBone(lfoot); lfoot = 0; } - else if(lFreeFoot.first){ - insert->detachObject(lFreeFoot.first); - lFreeFoot = zero; + else if(mLFreeFoot.first) + { + mInsert->detachObject(mLFreeFoot.first); + mLFreeFoot = mZero; } } - else if(type == ESM::PRT_RAnkle && rAnkle){ //17 - base->detachObjectFromBone(rAnkle); + else if(type == ESM::PRT_RAnkle && rAnkle) //17 + { + mBase->detachObjectFromBone(rAnkle); rAnkle = 0; } - else if(type == ESM::PRT_LAnkle && lAnkle){ //18 - base->detachObjectFromBone(lAnkle); + else if(type == ESM::PRT_LAnkle && lAnkle) //18 + { + mBase->detachObjectFromBone(lAnkle); lAnkle = 0; } - else if(type == ESM::PRT_RKnee && rKnee){ //19 - base->detachObjectFromBone(rKnee); + else if(type == ESM::PRT_RKnee && rKnee) //19 + { + mBase->detachObjectFromBone(rKnee); rKnee = 0; } - else if(type == ESM::PRT_LKnee && lKnee){ //20 - base->detachObjectFromBone(lKnee); + else if(type == ESM::PRT_LKnee && lKnee) //20 + { + mBase->detachObjectFromBone(lKnee); lKnee = 0; } - else if(type == ESM::PRT_RLeg && rUpperLeg){ //21 - base->detachObjectFromBone(rUpperLeg); + else if(type == ESM::PRT_RLeg && rUpperLeg) //21 + { + mBase->detachObjectFromBone(rUpperLeg); rUpperLeg = 0; } - else if(type == ESM::PRT_LLeg && lUpperLeg){ //22 - base->detachObjectFromBone(lUpperLeg); + else if(type == ESM::PRT_LLeg && lUpperLeg) //22 + { + mBase->detachObjectFromBone(lUpperLeg); lUpperLeg = 0; } - else if(type == ESM::PRT_RPauldron && rclavicle){ //23 - base->detachObjectFromBone(rclavicle); + else if(type == ESM::PRT_RPauldron && rclavicle) //23 + { + mBase->detachObjectFromBone(rclavicle); rclavicle = 0; } - else if(type == ESM::PRT_LPauldron && lclavicle){ //24 - base->detachObjectFromBone(lclavicle); + else if(type == ESM::PRT_LPauldron && lclavicle) //24 + { + mBase->detachObjectFromBone(lclavicle); lclavicle = 0; } - else if(type == ESM::PRT_Weapon){ //25 + else if(type == ESM::PRT_Weapon) //25 + { } - else if(type == ESM::PRT_Tail && tail.first){ //26 - insert->detachObject(tail.first); - tail = zero; + else if(type == ESM::PRT_Tail && mTail.first) //26 + { + mInsert->detachObject(mTail.first); + mTail = mZero; } - - - } - void NpcAnimation::reserveIndividualPart(int type, int group, int priority){ - if(priority > partpriorities[type]){ + void NpcAnimation::reserveIndividualPart(int type, int group, int priority) + { + if(priority > mPartPriorities[type]) + { removeIndividualPart(type); - partpriorities[type] = priority; - partslots[type] = group; + mPartPriorities[type] = priority; + mPartslots[type] = group; } } - void NpcAnimation::removePartGroup(int group){ - for(int i = 0; i < 27; i++){ - if(partslots[i] == group){ + void NpcAnimation::removePartGroup(int group) + { + for(int i = 0; i < 27; i++) + if(mPartslots[i] == group) removeIndividualPart(i); - } - } } - bool NpcAnimation::addOrReplaceIndividualPart(int type, int group, int priority, const std::string &mesh){ - if(priority > partpriorities[type]){ + bool NpcAnimation::addOrReplaceIndividualPart(int type, int group, int priority, const std::string &mesh) + { + if(priority > mPartPriorities[type]) + { removeIndividualPart(type); - partslots[type] = group; - partpriorities[type] = priority; - switch(type){ + mPartslots[type] = group; + mPartPriorities[type] = priority; + switch(type) + { case ESM::PRT_Head: //0 head = insertBoundedPart(mesh, "Head"); break; @@ -769,19 +837,19 @@ void NpcAnimation::removeIndividualPart(int type){ neck = insertBoundedPart(mesh, "Neck"); break; case ESM::PRT_Cuirass: //3 - chest = insertFreePart(mesh, ":\""); + mChest = insertFreePart(mesh, ":\""); break; case ESM::PRT_Groin: //4 groin = insertBoundedPart(mesh, "Groin"); break; case ESM::PRT_Skirt: //5 - skirt = insertFreePart(mesh, ":|"); + mSkirt = insertFreePart(mesh, ":|"); break; case ESM::PRT_RHand: //6 - rhand = insertFreePart(mesh, ":?"); + mRhand = insertFreePart(mesh, ":?"); break; case ESM::PRT_LHand: //7 - lhand = insertFreePart(mesh, ":>"); + mLhand = insertFreePart(mesh, ":>"); break; case ESM::PRT_RWrist: //8 rWrist = insertBoundedPart(mesh, "Right Wrist"); @@ -836,33 +904,30 @@ void NpcAnimation::removeIndividualPart(int type){ case ESM::PRT_Weapon: //25 break; case ESM::PRT_Tail: //26 - tail = insertFreePart(mesh, ":*"); + mTail = insertFreePart(mesh, ":*"); break; - - } return true; } return false; } - void NpcAnimation::addPartGroup(int group, int priority, std::vector& parts){ + void NpcAnimation::addPartGroup(int group, int priority, std::vector& parts) + { for(std::size_t i = 0; i < parts.size(); i++) - { - ESM::PartReference part = parts[i]; - - const ESM::BodyPart *bodypart = 0; - - if(isFemale) - bodypart = MWBase::Environment::get().getWorld()->getStore().bodyParts.search (part.female); - if(!bodypart) - bodypart = MWBase::Environment::get().getWorld()->getStore().bodyParts.search (part.male); - if(bodypart){ - addOrReplaceIndividualPart(part.part, group,priority,"meshes\\" + bodypart->model); - } - else - reserveIndividualPart(part.part, group, priority); - - } + { + ESM::PartReference part = parts[i]; + + const ESM::BodyPart *bodypart = 0; + + if(isFemale) + bodypart = MWBase::Environment::get().getWorld()->getStore().bodyParts.search (part.female); + if(!bodypart) + bodypart = MWBase::Environment::get().getWorld()->getStore().bodyParts.search (part.male); + if(bodypart) + addOrReplaceIndividualPart(part.part, group,priority,"meshes\\" + bodypart->model); + else + reserveIndividualPart(part.part, group, priority); + } } } diff --git a/apps/openmw/mwrender/npcanimation.hpp b/apps/openmw/mwrender/npcanimation.hpp index 8f4f8181d..973549619 100644 --- a/apps/openmw/mwrender/npcanimation.hpp +++ b/apps/openmw/mwrender/npcanimation.hpp @@ -20,54 +20,52 @@ namespace MWRender{ class NpcAnimation: public Animation{ private: - MWWorld::InventoryStore& inv; - int mStateID; - //Free Parts - std::pair*> chest; - std::pair*> skirt; - std::pair*> lhand; - std::pair*> rhand; - std::pair*> tail; - std::pair*> lFreeFoot; - std::pair*> rFreeFoot; + MWWorld::InventoryStore& mInv; + int mStateID; + //Free Parts + std::pair*> mChest; + std::pair*> mSkirt; + std::pair*> mLhand; + std::pair*> mRhand; + std::pair*> mTail; + std::pair*> mLFreeFoot; + std::pair*> mRFreeFoot; - int partslots[27]; //Each part slot is taken by clothing, armor, or is empty - int partpriorities[27]; - std::pair*> zero; + int mPartslots[27]; //Each part slot is taken by clothing, armor, or is empty + int mPartPriorities[27]; + std::pair*> mZero; + //Bounded Parts + Ogre::Entity* lclavicle; + Ogre::Entity* rclavicle; + Ogre::Entity* rupperArm; + Ogre::Entity* lupperArm; + Ogre::Entity* rUpperLeg; + Ogre::Entity* lUpperLeg; + Ogre::Entity* lForearm; + Ogre::Entity* rForearm; + Ogre::Entity* lWrist; + Ogre::Entity* rWrist; + Ogre::Entity* rKnee; + Ogre::Entity* lKnee; + Ogre::Entity* neck; + Ogre::Entity* rAnkle; + Ogre::Entity* lAnkle; + Ogre::Entity* groin; + Ogre::Entity* lfoot; + Ogre::Entity* rfoot; + Ogre::Entity* hair; + Ogre::Entity* head; - - //Bounded Parts - Ogre::Entity* lclavicle; - Ogre::Entity* rclavicle; - Ogre::Entity* rupperArm; - Ogre::Entity* lupperArm; - Ogre::Entity* rUpperLeg; - Ogre::Entity* lUpperLeg; - Ogre::Entity* lForearm; - Ogre::Entity* rForearm; - Ogre::Entity* lWrist; - Ogre::Entity* rWrist; - Ogre::Entity* rKnee; - Ogre::Entity* lKnee; - Ogre::Entity* neck; - Ogre::Entity* rAnkle; - Ogre::Entity* lAnkle; - Ogre::Entity* groin; - Ogre::Entity* lfoot; - Ogre::Entity* rfoot; - Ogre::Entity* hair; - Ogre::Entity* head; - - Ogre::SceneNode* insert; + Ogre::SceneNode* insert; bool isBeast; bool isFemale; - std::string headModel; - std::string hairModel; - std::string npcName; - std::string bodyRaceID; - float timeToChange; - MWWorld::ContainerStoreIterator robe; + std::string headModel; + std::string hairModel; + std::string npcName; + std::string bodyRaceID; + float timeToChange; + MWWorld::ContainerStoreIterator robe; MWWorld::ContainerStoreIterator helmet; MWWorld::ContainerStoreIterator shirt; MWWorld::ContainerStoreIterator cuirass; @@ -80,22 +78,21 @@ private: MWWorld::ContainerStoreIterator rightglove; MWWorld::ContainerStoreIterator skirtiter; - public: - NpcAnimation(const MWWorld::Ptr& ptr, OEngine::Render::OgreRenderer& _rend, MWWorld::InventoryStore& _inv); - virtual ~NpcAnimation(); +public: + NpcAnimation(const MWWorld::Ptr& ptr, OEngine::Render::OgreRenderer& _rend, MWWorld::InventoryStore& _inv); + virtual ~NpcAnimation(); Ogre::Entity* insertBoundedPart(const std::string &mesh, std::string bonename); - std::pair*> insertFreePart(const std::string &mesh, const std::string& suffix); - void insertFootPart(int type, const std::string &mesh); - virtual void runAnimation(float timepassed); - void updateParts(); + std::pair*> insertFreePart(const std::string &mesh, const std::string& suffix); + void insertFootPart(int type, const std::string &mesh); + virtual void runAnimation(float timepassed); + void updateParts(); void removeIndividualPart(int type); void reserveIndividualPart(int type, int group, int priority); bool addOrReplaceIndividualPart(int type, int group, int priority, const std::string &mesh); - void removePartGroup(int group); + void removePartGroup(int group); void addPartGroup(int group, int priority, std::vector& parts); - }; } #endif From 182017b8e92c6259bed6ceab4f47b098152a671f Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Fri, 13 Jul 2012 13:01:30 +0200 Subject: [PATCH 17/32] Issue #314: Moved ingredients and potions to a different type of record list --- apps/esmtool/esmtool.cpp | 2 +- components/esm/loadalch.cpp | 4 +++- components/esm/loadalch.hpp | 4 +++- components/esm/loadingr.cpp | 4 +++- components/esm/loadingr.hpp | 4 +++- components/esm_store/store.hpp | 4 ++-- 6 files changed, 15 insertions(+), 7 deletions(-) diff --git a/apps/esmtool/esmtool.cpp b/apps/esmtool/esmtool.cpp index f417d5c60..4888d3ceb 100644 --- a/apps/esmtool/esmtool.cpp +++ b/apps/esmtool/esmtool.cpp @@ -187,7 +187,7 @@ int main(int argc, char**argv) case REC_ALCH: { Potion p; - p.load(esm); + p.load(esm, id); if(quiet) break; cout << " Name: " << p.name << endl; break; diff --git a/components/esm/loadalch.cpp b/components/esm/loadalch.cpp index d3bc36a77..cd36887b0 100644 --- a/components/esm/loadalch.cpp +++ b/components/esm/loadalch.cpp @@ -2,8 +2,10 @@ namespace ESM { -void Potion::load(ESMReader &esm) +void Potion::load(ESMReader &esm, const std::string& id) { + mId = id; + model = esm.getHNString("MODL"); icon = esm.getHNOString("TEXT"); // not ITEX here for some reason script = esm.getHNOString("SCRI"); diff --git a/components/esm/loadalch.hpp b/components/esm/loadalch.hpp index c21e5dea0..6917fb448 100644 --- a/components/esm/loadalch.hpp +++ b/components/esm/loadalch.hpp @@ -24,7 +24,9 @@ struct Potion std::string name, model, icon, script; EffectList effects; - void load(ESMReader &esm); + std::string mId; + + void load(ESMReader &esm, const std::string& id); }; } #endif diff --git a/components/esm/loadingr.cpp b/components/esm/loadingr.cpp index 471f71780..a745ff669 100644 --- a/components/esm/loadingr.cpp +++ b/components/esm/loadingr.cpp @@ -3,8 +3,10 @@ namespace ESM { -void Ingredient::load(ESMReader &esm) +void Ingredient::load(ESMReader &esm, const std::string& id) { + mId = id; + model = esm.getHNString("MODL"); name = esm.getHNString("FNAM"); esm.getHNT(data, "IRDT", 56); diff --git a/components/esm/loadingr.hpp b/components/esm/loadingr.hpp index af9599ed0..5c1c3bd75 100644 --- a/components/esm/loadingr.hpp +++ b/components/esm/loadingr.hpp @@ -24,7 +24,9 @@ struct Ingredient IRDTstruct data; std::string name, model, icon, script; - void load(ESMReader &esm); + std::string mId; + + void load(ESMReader &esm, const std::string& id); }; } #endif diff --git a/components/esm_store/store.hpp b/components/esm_store/store.hpp index 507196a86..991925bd4 100644 --- a/components/esm_store/store.hpp +++ b/components/esm_store/store.hpp @@ -30,7 +30,7 @@ namespace ESMS // Each individual list RecListT activators; - RecListT potions; + RecListWithIDT potions; RecListT appas; RecListT armors; RecListT bodyParts; @@ -47,7 +47,7 @@ namespace ESMS RecListT enchants; RecListT factions; RecListT globals; - RecListT ingreds; + RecListWithIDT ingreds; RecListT creatureLists; RecListT itemLists; RecListT lights; From 782d417d5bd17a45ed202756f9dac795dd6f446a Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Fri, 13 Jul 2012 13:09:22 +0200 Subject: [PATCH 18/32] Issue #314: potion usage --- apps/openmw/mwclass/potion.cpp | 12 ++++++++++++ apps/openmw/mwclass/potion.hpp | 3 +++ 2 files changed, 15 insertions(+) diff --git a/apps/openmw/mwclass/potion.cpp b/apps/openmw/mwclass/potion.cpp index 5b446fbe9..d3d615262 100644 --- a/apps/openmw/mwclass/potion.cpp +++ b/apps/openmw/mwclass/potion.cpp @@ -8,6 +8,7 @@ #include "../mwworld/ptr.hpp" #include "../mwworld/actiontake.hpp" +#include "../mwworld/actionapply.hpp" #include "../mwworld/cellstore.hpp" #include "../mwworld/physicssystem.hpp" @@ -144,4 +145,15 @@ namespace MWClass return info; } + + boost::shared_ptr Potion::use (const MWWorld::Ptr& ptr) const + { + MWWorld::LiveCellRef *ref = + ptr.get(); + + ptr.getRefData().setCount (ptr.getRefData().getCount()-1); + + return boost::shared_ptr ( + new MWWorld::ActionApply (ptr, ref->base->mId, ptr)); + } } diff --git a/apps/openmw/mwclass/potion.hpp b/apps/openmw/mwclass/potion.hpp index 74779864a..ac5d85f23 100644 --- a/apps/openmw/mwclass/potion.hpp +++ b/apps/openmw/mwclass/potion.hpp @@ -34,6 +34,9 @@ namespace MWClass virtual int getValue (const MWWorld::Ptr& ptr) const; ///< Return trade value of the object. Throws an exception, if the object can't be traded. + virtual boost::shared_ptr use (const MWWorld::Ptr& ptr) const; + ///< Generate action for using via inventory menu + static void registerSelf(); virtual std::string getUpSoundId (const MWWorld::Ptr& ptr) const; From 573d7e7e45c2b823a3f471157c917b712e1301a5 Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Fri, 13 Jul 2012 15:51:57 +0200 Subject: [PATCH 19/32] Issue #314: fix to potion use function (was mixing up potion with potion user) --- apps/openmw/mwclass/potion.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/apps/openmw/mwclass/potion.cpp b/apps/openmw/mwclass/potion.cpp index d3d615262..45cb07840 100644 --- a/apps/openmw/mwclass/potion.cpp +++ b/apps/openmw/mwclass/potion.cpp @@ -11,6 +11,7 @@ #include "../mwworld/actionapply.hpp" #include "../mwworld/cellstore.hpp" #include "../mwworld/physicssystem.hpp" +#include "../mwworld/player.hpp" #include "../mwgui/window_manager.hpp" #include "../mwgui/tooltips.hpp" @@ -153,7 +154,9 @@ namespace MWClass ptr.getRefData().setCount (ptr.getRefData().getCount()-1); + MWWorld::Ptr actor = MWBase::Environment::get().getWorld()->getPlayer().getPlayer(); + return boost::shared_ptr ( - new MWWorld::ActionApply (ptr, ref->base->mId, ptr)); + new MWWorld::ActionApply (actor, ref->base->mId, actor)); } } From e862b6b5a5cc7a8a001e3aa5df2983bfc3ef406b Mon Sep 17 00:00:00 2001 From: Dmitry Marakasov Date: Mon, 16 Jul 2012 15:53:02 +0400 Subject: [PATCH 20/32] Fix comparison in cmake --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e3175fa7d..9cc741c67 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -23,7 +23,7 @@ set (OPENMW_VERSION "${OPENMW_VERSION_MAJOR}.${OPENMW_VERSION_MINOR}.${OPENMW_VE # Debug suffix for plugins set(DEBUG_SUFFIX "") if (DEFINED CMAKE_BUILD_TYPE) - if (${CMAKE_BUILD_TYPE} STREQUAL "Debug") + if (CMAKE_BUILD_TYPE STREQUAL "Debug") set(DEBUG_SUFFIX "_d") endif() endif() From 1c53add6c4d3d349b32ac7bb94d9a396142b2c1f Mon Sep 17 00:00:00 2001 From: Dmitry Marakasov Date: Mon, 16 Jul 2012 23:53:33 +0400 Subject: [PATCH 21/32] Include boost/shared_ptr.hpp for boost:shared_ptr --- apps/openmw/mwsound/soundmanager.hpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/apps/openmw/mwsound/soundmanager.hpp b/apps/openmw/mwsound/soundmanager.hpp index ff360122b..83195390c 100644 --- a/apps/openmw/mwsound/soundmanager.hpp +++ b/apps/openmw/mwsound/soundmanager.hpp @@ -5,6 +5,8 @@ #include #include +#include + #include #include From 0e934a52ca765c097b822440cd0d0635ca8e0c8b Mon Sep 17 00:00:00 2001 From: Dmitry Marakasov Date: Mon, 16 Jul 2012 23:54:04 +0400 Subject: [PATCH 22/32] Include soundmanager.hpp for Play_Normal enum --- apps/openmw/mwsound/sound.hpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/apps/openmw/mwsound/sound.hpp b/apps/openmw/mwsound/sound.hpp index a33892548..0cba6abca 100644 --- a/apps/openmw/mwsound/sound.hpp +++ b/apps/openmw/mwsound/sound.hpp @@ -3,6 +3,8 @@ #include +#include "soundmanager.hpp" + namespace MWSound { class Sound From d6bf2b7d294d7298b691677e84ac051c86030397 Mon Sep 17 00:00:00 2001 From: Dmitry Marakasov Date: Tue, 17 Jul 2012 00:11:56 +0400 Subject: [PATCH 23/32] Proper way to find and use libtbb --- CMakeLists.txt | 1 + apps/esmtool/CMakeLists.txt | 1 + apps/launcher/CMakeLists.txt | 3 ++- apps/openmw/CMakeLists.txt | 1 + cmake/FindTBB.cmake | 14 ++++++++++++++ 5 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 cmake/FindTBB.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index 9cc741c67..49684fd7c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -200,6 +200,7 @@ find_package(Boost REQUIRED COMPONENTS system filesystem program_options thread) find_package(OIS REQUIRED) find_package(OpenAL REQUIRED) find_package(Bullet REQUIRED) +find_package(TBB REQUIRED) IF(OGRE_STATIC) find_package(Cg REQUIRED) IF(WIN32) diff --git a/apps/esmtool/CMakeLists.txt b/apps/esmtool/CMakeLists.txt index af3dc090e..eb74aa992 100644 --- a/apps/esmtool/CMakeLists.txt +++ b/apps/esmtool/CMakeLists.txt @@ -10,6 +10,7 @@ add_executable(esmtool target_link_libraries(esmtool ${Boost_LIBRARIES} + ${TBB_LIBRARY} components ) diff --git a/apps/launcher/CMakeLists.txt b/apps/launcher/CMakeLists.txt index ed3559fdc..57b7fb71a 100644 --- a/apps/launcher/CMakeLists.txt +++ b/apps/launcher/CMakeLists.txt @@ -75,8 +75,9 @@ add_executable(omwlauncher target_link_libraries(omwlauncher ${Boost_LIBRARIES} ${OGRE_LIBRARIES} - ${OGRE_STATIC_PLUGINS} + ${OGRE_STATIC_PLUGINS} ${QT_LIBRARIES} + ${TBB_LIBRARY} components ) diff --git a/apps/openmw/CMakeLists.txt b/apps/openmw/CMakeLists.txt index a66cda71e..feefa4fd2 100644 --- a/apps/openmw/CMakeLists.txt +++ b/apps/openmw/CMakeLists.txt @@ -100,6 +100,7 @@ target_link_libraries(openmw ${BULLET_LIBRARIES} ${MYGUI_LIBRARIES} ${MYGUI_PLATFORM_LIBRARIES} + ${TBB_LIBRARY} components ) diff --git a/cmake/FindTBB.cmake b/cmake/FindTBB.cmake new file mode 100644 index 000000000..f84f81f1c --- /dev/null +++ b/cmake/FindTBB.cmake @@ -0,0 +1,14 @@ +# Locate TBB +# This module defines +# TBB_LIBRARY +# TBB_FOUND, if false, do not try to link to TBB +# TBB_INCLUDE_DIR, where to find the headers + +FIND_PATH(TBB_INCLUDE_DIR tbb/tbb.h) + +FIND_LIBRARY(TBB_LIBRARY NAMES tbb) + +SET(TBB_FOUND "NO") +IF(TBB_LIBRARY AND TBB_INCLUDE_DIR) + SET(TBB_FOUND "YES") +ENDIF(TBB_LIBRARY AND TBB_INCLUDE_DIR) From ada88596dc65457a8e4b10e4c1adfc1a45be0b45 Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Mon, 16 Jul 2012 15:30:09 -0700 Subject: [PATCH 24/32] Fix an abort at shutdown Ogre uses a special method to delete the stream object, so it needs to be allocated properly. --- components/esm/esm_reader.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/components/esm/esm_reader.cpp b/components/esm/esm_reader.cpp index 6b8409b45..a2cf69ddc 100644 --- a/components/esm/esm_reader.cpp +++ b/components/esm/esm_reader.cpp @@ -107,15 +107,15 @@ void ESMReader::open(Ogre::DataStreamPtr _esm, const std::string &name) void ESMReader::open(const std::string &file) { - std::ifstream *stream = new std::ifstream(file.c_str(), std::ios_base::binary); - // Ogre will delete the stream for us + std::ifstream *stream = OGRE_NEW_T(std::ifstream, Ogre::MEMCATEGORY_GENERAL)(file.c_str(), std::ios_base::binary); + // Ogre will delete the stream for us open(Ogre::DataStreamPtr(new Ogre::FileStreamDataStream(stream)), file); } void ESMReader::openRaw(const std::string &file) { - std::ifstream *stream = new std::ifstream(file.c_str(), std::ios_base::binary); - // Ogre will delete the stream for us + std::ifstream *stream = OGRE_NEW_T(std::ifstream, Ogre::MEMCATEGORY_GENERAL)(file.c_str(), std::ios_base::binary); + // Ogre will delete the stream for us openRaw(Ogre::DataStreamPtr(new Ogre::FileStreamDataStream(stream)), file); } From 0549e949ba6cab8fb06919ebcc0ee4dee558ef59 Mon Sep 17 00:00:00 2001 From: guidoj Date: Tue, 17 Jul 2012 09:27:12 +0200 Subject: [PATCH 25/32] Mostly removal of unnecessary #include's and a little clean up --- .gitignore | 1 + apps/openmw/engine.cpp | 19 ----------------- apps/openmw/engine.hpp | 4 ---- apps/openmw/main.cpp | 15 -------------- apps/openmw/mwbase/world.hpp | 2 -- apps/openmw/mwclass/creature.hpp | 1 - apps/openmw/mwgui/class.cpp | 1 - apps/openmw/mwgui/dialogue.cpp | 1 - apps/openmw/mwgui/dialogue_history.cpp | 1 - apps/openmw/mwgui/race.cpp | 1 - apps/openmw/mwgui/window_manager.hpp | 4 ---- apps/openmw/mwrender/actors.hpp | 10 --------- apps/openmw/mwrender/animation.hpp | 6 +----- apps/openmw/mwrender/creatureanimation.hpp | 4 ---- apps/openmw/mwrender/npcanimation.hpp | 10 +-------- apps/openmw/mwrender/renderingmanager.hpp | 12 ----------- apps/openmw/mwscript/scriptmanager.hpp | 1 - apps/openmw/mwworld/cells.cpp | 4 ---- apps/openmw/mwworld/cellstore.hpp | 3 --- apps/openmw/mwworld/containerstore.hpp | 2 -- apps/openmw/mwworld/physicssystem.hpp | 2 -- apps/openmw/mwworld/ptr.hpp | 4 ---- apps/openmw/mwworld/refdata.hpp | 2 -- apps/openmw/mwworld/scene.cpp | 2 -- apps/openmw/mwworld/scene.hpp | 8 -------- apps/openmw/mwworld/worldimp.cpp | 9 -------- apps/openmw/mwworld/worldimp.hpp | 15 -------------- components/compiler/streamerrorhandler.cpp | 3 ++- components/esm/esm_reader.hpp | 6 +----- components/files/collections.hpp | 2 -- components/files/configurationmanager.hpp | 1 - components/misc/tests/slice_test.cpp | 2 -- components/nif/nif_file.hpp | 3 +-- components/nifbullet/bullet_nif_loader.hpp | 8 +------- components/nifogre/ogre_nif_loader.hpp | 24 +++++++--------------- components/nifogre/tests/ogre_common.cpp | 1 - libs/openengine/gui/layout.hpp | 1 - libs/openengine/ogre/fader.cpp | 2 -- 38 files changed, 15 insertions(+), 182 deletions(-) diff --git a/.gitignore b/.gitignore index b3bb8d82d..26ba80e1a 100644 --- a/.gitignore +++ b/.gitignore @@ -13,3 +13,4 @@ cmake_install.cmake Makefile makefile data +*.kdev4 diff --git a/apps/openmw/engine.cpp b/apps/openmw/engine.cpp index 45b4ab514..7966639a6 100644 --- a/apps/openmw/engine.cpp +++ b/apps/openmw/engine.cpp @@ -1,25 +1,13 @@ #include "engine.hpp" #include "components/esm/loadcell.hpp" -#include - -#include -#include - #include #include #include -#include -#include - -#include #include -#include -#include #include -#include #include #include @@ -31,16 +19,12 @@ #include "mwgui/cursorreplace.hpp" #include "mwscript/scriptmanager.hpp" -#include "mwscript/compilercontext.hpp" -#include "mwscript/interpretercontext.hpp" #include "mwscript/extensions.hpp" -#include "mwscript/globalscripts.hpp" #include "mwsound/soundmanager.hpp" #include "mwworld/class.hpp" #include "mwworld/player.hpp" -#include "mwworld/cellstore.hpp" #include "mwworld/worldimp.hpp" #include "mwclass/classes.hpp" @@ -50,9 +34,6 @@ #include "mwmechanics/mechanicsmanager.hpp" -#include "mwbase/environment.hpp" -#include "mwbase/world.hpp" - void OMW::Engine::executeLocalScripts() { diff --git a/apps/openmw/engine.hpp b/apps/openmw/engine.hpp index cf1ef3b9c..031cae551 100644 --- a/apps/openmw/engine.hpp +++ b/apps/openmw/engine.hpp @@ -1,10 +1,6 @@ #ifndef ENGINE_H #define ENGINE_H -#include - -#include - #include #include diff --git a/apps/openmw/main.cpp b/apps/openmw/main.cpp index 68aa12fb3..fc905b79d 100644 --- a/apps/openmw/main.cpp +++ b/apps/openmw/main.cpp @@ -1,13 +1,5 @@ #include -#include -#include - -#include - -#include -#include -#include #include #include "engine.hpp" @@ -16,11 +8,6 @@ #include #include -# if !defined(_DEBUG) -# include -# include -# endif - // For OutputDebugString #include // makes __argc and __argv available on windows @@ -52,8 +39,6 @@ inline boost::filesystem::path lexical_cast mMap; }; diff --git a/apps/openmw/mwbase/world.hpp b/apps/openmw/mwbase/world.hpp index 51d0a4f8e..6937cbf3b 100644 --- a/apps/openmw/mwbase/world.hpp +++ b/apps/openmw/mwbase/world.hpp @@ -1,8 +1,6 @@ #ifndef GAME_MWBASE_WORLD_H #define GAME_MWBASE_WORLD_H -#include -#include #include #include diff --git a/apps/openmw/mwclass/creature.hpp b/apps/openmw/mwclass/creature.hpp index 237f54e82..1274be09a 100644 --- a/apps/openmw/mwclass/creature.hpp +++ b/apps/openmw/mwclass/creature.hpp @@ -1,7 +1,6 @@ #ifndef GAME_MWCLASS_CREATURE_H #define GAME_MWCLASS_CREATURE_H -#include "../mwworld/class.hpp" #include "../mwrender/renderinginterface.hpp" #include "../mwrender/actors.hpp" diff --git a/apps/openmw/mwgui/class.cpp b/apps/openmw/mwgui/class.cpp index d0f21f945..9f291bae7 100644 --- a/apps/openmw/mwgui/class.cpp +++ b/apps/openmw/mwgui/class.cpp @@ -1,6 +1,5 @@ #include "class.hpp" -#include #include #include diff --git a/apps/openmw/mwgui/dialogue.cpp b/apps/openmw/mwgui/dialogue.cpp index acf0bf130..018fbb178 100644 --- a/apps/openmw/mwgui/dialogue.cpp +++ b/apps/openmw/mwgui/dialogue.cpp @@ -1,6 +1,5 @@ #include "dialogue.hpp" -#include #include #include diff --git a/apps/openmw/mwgui/dialogue_history.cpp b/apps/openmw/mwgui/dialogue_history.cpp index cd34ee119..009f42044 100644 --- a/apps/openmw/mwgui/dialogue_history.cpp +++ b/apps/openmw/mwgui/dialogue_history.cpp @@ -3,7 +3,6 @@ #include "widgets.hpp" #include "components/esm_store/store.hpp" -#include #include #include diff --git a/apps/openmw/mwgui/race.cpp b/apps/openmw/mwgui/race.cpp index 9ae453016..9f4a4965d 100644 --- a/apps/openmw/mwgui/race.cpp +++ b/apps/openmw/mwgui/race.cpp @@ -1,6 +1,5 @@ #include "race.hpp" -#include #include #include diff --git a/apps/openmw/mwgui/window_manager.hpp b/apps/openmw/mwgui/window_manager.hpp index 03ffa6b59..9d1516ccf 100644 --- a/apps/openmw/mwgui/window_manager.hpp +++ b/apps/openmw/mwgui/window_manager.hpp @@ -10,10 +10,6 @@ this class. **/ -#include -#include -#include - #include "MyGUI_UString.h" #include diff --git a/apps/openmw/mwrender/actors.hpp b/apps/openmw/mwrender/actors.hpp index 63cd3baa1..4b0b2e572 100644 --- a/apps/openmw/mwrender/actors.hpp +++ b/apps/openmw/mwrender/actors.hpp @@ -1,18 +1,8 @@ #ifndef _GAME_RENDER_ACTORS_H #define _GAME_RENDER_ACTORS_H -#include -#include - -#include -#include "components/nifogre/ogre_nif_loader.hpp" - -#include "../mwworld/refdata.hpp" -#include "../mwworld/actiontalk.hpp" - #include "npcanimation.hpp" #include "creatureanimation.hpp" -#include namespace MWWorld { diff --git a/apps/openmw/mwrender/animation.hpp b/apps/openmw/mwrender/animation.hpp index 4ab60cff4..28ef9d706 100644 --- a/apps/openmw/mwrender/animation.hpp +++ b/apps/openmw/mwrender/animation.hpp @@ -1,17 +1,13 @@ #ifndef _GAME_RENDER_ANIMATION_H #define _GAME_RENDER_ANIMATION_H -#include + #include -#include "../mwworld/refdata.hpp" -#include "../mwworld/ptr.hpp" #include "../mwworld/actiontalk.hpp" #include -#include #include - namespace MWRender{ struct PosAndRot{ diff --git a/apps/openmw/mwrender/creatureanimation.hpp b/apps/openmw/mwrender/creatureanimation.hpp index f50b7904b..4fea1a9d9 100644 --- a/apps/openmw/mwrender/creatureanimation.hpp +++ b/apps/openmw/mwrender/creatureanimation.hpp @@ -2,11 +2,7 @@ #define _GAME_RENDER_CREATUREANIMATION_H #include "animation.hpp" -#include - -#include "../mwworld/refdata.hpp" -#include "../mwworld/ptr.hpp" #include "components/nifogre/ogre_nif_loader.hpp" diff --git a/apps/openmw/mwrender/npcanimation.hpp b/apps/openmw/mwrender/npcanimation.hpp index 8f4f8181d..4233d2803 100644 --- a/apps/openmw/mwrender/npcanimation.hpp +++ b/apps/openmw/mwrender/npcanimation.hpp @@ -1,20 +1,12 @@ #ifndef _GAME_RENDER_NPCANIMATION_H #define _GAME_RENDER_NPCANIMATION_H + #include "animation.hpp" -#include -#include -#include -#include -#include -#include -#include "../mwworld/refdata.hpp" -#include "../mwworld/ptr.hpp" #include "components/nifogre/ogre_nif_loader.hpp" #include "../mwworld/inventorystore.hpp" #include "../mwclass/npc.hpp" #include "../mwworld/containerstore.hpp" -#include "components/esm/loadarmo.hpp" namespace MWRender{ diff --git a/apps/openmw/mwrender/renderingmanager.hpp b/apps/openmw/mwrender/renderingmanager.hpp index 9aaba3803..c30f52979 100644 --- a/apps/openmw/mwrender/renderingmanager.hpp +++ b/apps/openmw/mwrender/renderingmanager.hpp @@ -1,25 +1,14 @@ #ifndef _GAME_RENDERING_MANAGER_H #define _GAME_RENDERING_MANAGER_H - #include "sky.hpp" #include "terrain.hpp" #include "debugging.hpp" -#include "../mwworld/class.hpp" - -#include - -#include -#include #include -#include #include -#include -#include - #include #include "renderinginterface.hpp" @@ -45,7 +34,6 @@ namespace MWWorld namespace MWRender { - class Shadows; class ShaderHelper; class LocalMap; diff --git a/apps/openmw/mwscript/scriptmanager.hpp b/apps/openmw/mwscript/scriptmanager.hpp index 34cc0defe..a466f903d 100644 --- a/apps/openmw/mwscript/scriptmanager.hpp +++ b/apps/openmw/mwscript/scriptmanager.hpp @@ -2,7 +2,6 @@ #define GAME_SCRIPT_SCRIPTMANAGER_H #include -#include #include #include diff --git a/apps/openmw/mwworld/cells.cpp b/apps/openmw/mwworld/cells.cpp index cd7ebf79a..cffaf70ea 100644 --- a/apps/openmw/mwworld/cells.cpp +++ b/apps/openmw/mwworld/cells.cpp @@ -1,9 +1,5 @@ #include "cells.hpp" -#include - -#include - #include #include "../mwbase/environment.hpp" diff --git a/apps/openmw/mwworld/cellstore.hpp b/apps/openmw/mwworld/cellstore.hpp index 8253f3f0b..de3ac12ae 100644 --- a/apps/openmw/mwworld/cellstore.hpp +++ b/apps/openmw/mwworld/cellstore.hpp @@ -4,9 +4,6 @@ #include #include -#include -#include -#include #include #include "refdata.hpp" diff --git a/apps/openmw/mwworld/containerstore.hpp b/apps/openmw/mwworld/containerstore.hpp index f71b493bd..ae27fad3d 100644 --- a/apps/openmw/mwworld/containerstore.hpp +++ b/apps/openmw/mwworld/containerstore.hpp @@ -3,8 +3,6 @@ #include -#include "cellstore.hpp" -#include "refdata.hpp" #include "ptr.hpp" namespace ESM diff --git a/apps/openmw/mwworld/physicssystem.hpp b/apps/openmw/mwworld/physicssystem.hpp index b46ce117b..a6b679833 100644 --- a/apps/openmw/mwworld/physicssystem.hpp +++ b/apps/openmw/mwworld/physicssystem.hpp @@ -1,9 +1,7 @@ #ifndef GAME_MWWORLD_PHYSICSSYSTEM_H #define GAME_MWWORLD_PHYSICSSYSTEM_H -#include #include -#include #include "ptr.hpp" #include diff --git a/apps/openmw/mwworld/ptr.hpp b/apps/openmw/mwworld/ptr.hpp index b7469b8f5..f74fdd3ef 100644 --- a/apps/openmw/mwworld/ptr.hpp +++ b/apps/openmw/mwworld/ptr.hpp @@ -1,12 +1,8 @@ #ifndef GAME_MWWORLD_PTR_H #define GAME_MWWORLD_PTR_H -#include - #include -#include - #include "cellstore.hpp" namespace MWWorld diff --git a/apps/openmw/mwworld/refdata.hpp b/apps/openmw/mwworld/refdata.hpp index 41521e47a..3a6e0fc9f 100644 --- a/apps/openmw/mwworld/refdata.hpp +++ b/apps/openmw/mwworld/refdata.hpp @@ -1,8 +1,6 @@ #ifndef GAME_MWWORLD_REFDATA_H #define GAME_MWWORLD_REFDATA_H -#include - #include #include "../mwscript/locals.hpp" diff --git a/apps/openmw/mwworld/scene.cpp b/apps/openmw/mwworld/scene.cpp index 39496def3..33c67aad8 100644 --- a/apps/openmw/mwworld/scene.cpp +++ b/apps/openmw/mwworld/scene.cpp @@ -11,9 +11,7 @@ #include "../mwworld/manualref.hpp" /// FIXME -#include "ptr.hpp" #include "player.hpp" -#include "class.hpp" #include "localscripts.hpp" #include "cellfunctors.hpp" diff --git a/apps/openmw/mwworld/scene.hpp b/apps/openmw/mwworld/scene.hpp index 64a8c9f8e..c0b93796a 100644 --- a/apps/openmw/mwworld/scene.hpp +++ b/apps/openmw/mwworld/scene.hpp @@ -1,15 +1,7 @@ #ifndef GAME_MWWORLD_SCENE_H #define GAME_MWWORLD_SCENE_H -#include -#include - -#include - -#include - #include "../mwrender/renderingmanager.hpp" -#include "../mwrender/renderinginterface.hpp" #include "physicssystem.hpp" #include "globals.hpp" diff --git a/apps/openmw/mwworld/worldimp.cpp b/apps/openmw/mwworld/worldimp.cpp index 24baac144..a68f08e34 100644 --- a/apps/openmw/mwworld/worldimp.cpp +++ b/apps/openmw/mwworld/worldimp.cpp @@ -1,8 +1,5 @@ #include "worldimp.hpp" -#include -#include - #include #include @@ -17,16 +14,10 @@ #include "../mwgui/window_manager.hpp" -#include "ptr.hpp" -#include "class.hpp" #include "player.hpp" -#include "weather.hpp" #include "manualref.hpp" -#include "refdata.hpp" -#include "globals.hpp" #include "cellfunctors.hpp" -#include using namespace Ogre; namespace diff --git a/apps/openmw/mwworld/worldimp.hpp b/apps/openmw/mwworld/worldimp.hpp index 8b39a78f1..43b178fe3 100644 --- a/apps/openmw/mwworld/worldimp.hpp +++ b/apps/openmw/mwworld/worldimp.hpp @@ -1,32 +1,17 @@ #ifndef GAME_MWWORLD_WORLDIMP_H #define GAME_MWWORLD_WORLDIMP_H -#include -#include - -#include - #include -#include - #include "../mwrender/debugging.hpp" -#include "../mwrender/renderingmanager.hpp" -#include "refdata.hpp" #include "ptr.hpp" -#include "globals.hpp" #include "scene.hpp" #include "physicssystem.hpp" #include "cells.hpp" #include "localscripts.hpp" #include "timestamp.hpp" -#include -#include - -#include - #include "../mwbase/world.hpp" namespace Ogre diff --git a/components/compiler/streamerrorhandler.cpp b/components/compiler/streamerrorhandler.cpp index a1d12b708..8a74ad086 100644 --- a/components/compiler/streamerrorhandler.cpp +++ b/components/compiler/streamerrorhandler.cpp @@ -35,4 +35,5 @@ namespace Compiler << " " << message << std::endl; } - StreamErrorHandler::StreamErrorHandler (std::ostream& ErrorStream) : mStream (ErrorStream) {}} + StreamErrorHandler::StreamErrorHandler (std::ostream& ErrorStream) : mStream (ErrorStream) {} +} diff --git a/components/esm/esm_reader.hpp b/components/esm/esm_reader.hpp index 17cca7a91..13f1f4a01 100644 --- a/components/esm/esm_reader.hpp +++ b/components/esm/esm_reader.hpp @@ -1,15 +1,11 @@ #ifndef _ESM_READER_H #define _ESM_READER_H -#include - -#include #include #include -#include +#include #include #include -#include #include diff --git a/components/files/collections.hpp b/components/files/collections.hpp index 70aaec55e..ed4aafa13 100644 --- a/components/files/collections.hpp +++ b/components/files/collections.hpp @@ -1,8 +1,6 @@ #ifndef COMPONENTS_FILES_COLLECTION_HPP #define COMPONENTS_FILES_COLLECTION_HPP -#include -#include #include #include "multidircollection.hpp" diff --git a/components/files/configurationmanager.hpp b/components/files/configurationmanager.hpp index af9d02b91..0c22c6f7d 100644 --- a/components/files/configurationmanager.hpp +++ b/components/files/configurationmanager.hpp @@ -8,7 +8,6 @@ #endif #include -#include #include #include diff --git a/components/misc/tests/slice_test.cpp b/components/misc/tests/slice_test.cpp index a0ea55311..0d9d7b4ab 100644 --- a/components/misc/tests/slice_test.cpp +++ b/components/misc/tests/slice_test.cpp @@ -2,8 +2,6 @@ using namespace std; -#include - #include "../slice_array.hpp" int main() diff --git a/components/nif/nif_file.hpp b/components/nif/nif_file.hpp index 42e312b7f..4072b4307 100644 --- a/components/nif/nif_file.hpp +++ b/components/nif/nif_file.hpp @@ -32,8 +32,7 @@ #include #include -#include -#include +#include #include "record.hpp" #include "nif_types.hpp" diff --git a/components/nifbullet/bullet_nif_loader.hpp b/components/nifbullet/bullet_nif_loader.hpp index b2f023301..88e1ab189 100644 --- a/components/nifbullet/bullet_nif_loader.hpp +++ b/components/nifbullet/bullet_nif_loader.hpp @@ -25,22 +25,16 @@ #define _BULLET_NIF_LOADER_H_ #include -#include +#include #include #include #include #include -#include #include "openengine/bullet/BulletShapeLoader.h" -#include -#include // For warning messages #include -// float infinity -#include - namespace Nif { class Node; diff --git a/components/nifogre/ogre_nif_loader.hpp b/components/nifogre/ogre_nif_loader.hpp index 0620ddf49..7b32d24d1 100644 --- a/components/nifogre/ogre_nif_loader.hpp +++ b/components/nifogre/ogre_nif_loader.hpp @@ -28,31 +28,20 @@ #include #include -#include #include -#include "../nif/nif_file.hpp" #include "../nif/node.hpp" -#include "../nif/data.hpp" -#include "../nif/property.hpp" -#include "../nif/controller.hpp" -#include "../nif/extra.hpp" -#include - -#include -#include -// For warning messages -#include -using namespace boost::algorithm; +#include class BoundsFinder; struct ciLessBoost : std::binary_function { - bool operator() (const std::string & s1, const std::string & s2) const { - //case insensitive version of is_less - return lexicographical_compare(s1, s2, is_iless()); + bool operator() (const std::string & s1, const std::string & s2) const + { + //case insensitive version of is_less + return boost::algorithm::lexicographical_compare(s1, s2, boost::algorithm::is_iless()); } }; @@ -63,7 +52,6 @@ namespace Nif class NiTriShape; } - namespace NifOgre { @@ -177,3 +165,5 @@ class NIFLoader : Ogre::ManualResourceLoader } #endif + + diff --git a/components/nifogre/tests/ogre_common.cpp b/components/nifogre/tests/ogre_common.cpp index 949c91c4f..657913f30 100644 --- a/components/nifogre/tests/ogre_common.cpp +++ b/components/nifogre/tests/ogre_common.cpp @@ -1,6 +1,5 @@ #include #include -#include using namespace std; using namespace Ogre; diff --git a/libs/openengine/gui/layout.hpp b/libs/openengine/gui/layout.hpp index e6feb3d0e..9040dfb90 100644 --- a/libs/openengine/gui/layout.hpp +++ b/libs/openengine/gui/layout.hpp @@ -1,7 +1,6 @@ #ifndef OENGINE_MYGUI_LAYOUT_H #define OENGINE_MYGUI_LAYOUT_H -#include #include namespace OEngine { diff --git a/libs/openengine/ogre/fader.cpp b/libs/openengine/ogre/fader.cpp index 062559e00..41b7773ea 100644 --- a/libs/openengine/ogre/fader.cpp +++ b/libs/openengine/ogre/fader.cpp @@ -8,8 +8,6 @@ #include #include -#include - #define FADE_OVERLAY_NAME "FadeInOutOverlay" #define FADE_OVERLAY_PANEL_NAME "FadeInOutOverlayPanel" #define FADE_MATERIAL_NAME "FadeInOutMaterial" From a021165d9f2cc002a991f4f5abac014d06e229be Mon Sep 17 00:00:00 2001 From: guidoj Date: Tue, 17 Jul 2012 09:44:24 +0200 Subject: [PATCH 26/32] Changed standard C lib includes to C++ format --- apps/openmw/main.cpp | 2 +- components/bsa/bsa_file.cpp | 4 ++-- components/bsa/tests/bsatool_cmd.c | 4 ++-- components/bsa/tests/bsatool_cmd.h | 2 +- components/esm_store/reclists.hpp | 2 +- components/misc/tests/strops_test.cpp | 2 +- components/nifbullet/bullet_nif_loader.cpp | 2 +- components/terrain/heightmapbuf.hpp | 2 +- components/terrain/triangulator.hpp | 2 +- components/to_utf8/gen_iconv.cpp | 2 +- components/to_utf8/to_utf8.cpp | 2 +- libs/mangle/input/servers/ois_driver.cpp | 2 +- libs/mangle/rend2d/servers/sdl_driver.cpp | 2 +- libs/mangle/rend2d/servers/sdl_gl_driver.cpp | 2 +- libs/openengine/gui/events.cpp | 2 +- libs/openengine/gui/manager.cpp | 2 +- libs/openengine/input/dispatch_map.hpp | 2 +- libs/openengine/input/func_binder.hpp | 2 +- libs/openengine/misc/list.hpp | 2 +- libs/openengine/ogre/renderer.cpp | 2 +- 20 files changed, 22 insertions(+), 22 deletions(-) diff --git a/apps/openmw/main.cpp b/apps/openmw/main.cpp index fc905b79d..993ec6623 100644 --- a/apps/openmw/main.cpp +++ b/apps/openmw/main.cpp @@ -11,7 +11,7 @@ // For OutputDebugString #include // makes __argc and __argv available on windows -#include +#include #endif diff --git a/components/bsa/bsa_file.cpp b/components/bsa/bsa_file.cpp index 8f605b8ed..053191c9b 100644 --- a/components/bsa/bsa_file.cpp +++ b/components/bsa/bsa_file.cpp @@ -24,8 +24,8 @@ #include "bsa_file.hpp" #include -#include -#include +#include +#include #include diff --git a/components/bsa/tests/bsatool_cmd.c b/components/bsa/tests/bsatool_cmd.c index f6e10d793..caa8cd720 100644 --- a/components/bsa/tests/bsatool_cmd.c +++ b/components/bsa/tests/bsatool_cmd.c @@ -13,8 +13,8 @@ #include "config.h" #endif -#include -#include +#include +#include #include #ifndef FIX_UNUSED diff --git a/components/bsa/tests/bsatool_cmd.h b/components/bsa/tests/bsatool_cmd.h index 65ebc3e96..98fe2633f 100644 --- a/components/bsa/tests/bsatool_cmd.h +++ b/components/bsa/tests/bsatool_cmd.h @@ -13,7 +13,7 @@ #include "config.h" #endif -#include /* for FILE */ +#include /* for FILE */ #ifdef __cplusplus extern "C" { diff --git a/components/esm_store/reclists.hpp b/components/esm_store/reclists.hpp index 48bf050cd..ffecfc8de 100644 --- a/components/esm_store/reclists.hpp +++ b/components/esm_store/reclists.hpp @@ -7,7 +7,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/components/misc/tests/strops_test.cpp b/components/misc/tests/strops_test.cpp index 2a1fdd77d..24ab8a298 100644 --- a/components/misc/tests/strops_test.cpp +++ b/components/misc/tests/strops_test.cpp @@ -1,4 +1,4 @@ -#include +#include #include "../stringops.hpp" diff --git a/components/nifbullet/bullet_nif_loader.cpp b/components/nifbullet/bullet_nif_loader.cpp index 4105c4c79..ea94e7758 100644 --- a/components/nifbullet/bullet_nif_loader.cpp +++ b/components/nifbullet/bullet_nif_loader.cpp @@ -23,7 +23,7 @@ http://www.gnu.org/licenses/ . #include "bullet_nif_loader.hpp" #include -#include +#include #include "../nif/nif_file.hpp" #include "../nif/node.hpp" diff --git a/components/terrain/heightmapbuf.hpp b/components/terrain/heightmapbuf.hpp index 82154ce88..d147e6015 100644 --- a/components/terrain/heightmapbuf.hpp +++ b/components/terrain/heightmapbuf.hpp @@ -8,7 +8,7 @@ #include "heightmap.hpp" #include "land_factory.hpp" #include -#include +#include namespace Terrain { diff --git a/components/terrain/triangulator.hpp b/components/terrain/triangulator.hpp index cedf0c6a2..c5c0e699b 100644 --- a/components/terrain/triangulator.hpp +++ b/components/terrain/triangulator.hpp @@ -28,7 +28,7 @@ terrains of the same size, once instance can usually be shared. */ -#include +#include namespace Terrain { diff --git a/components/to_utf8/gen_iconv.cpp b/components/to_utf8/gen_iconv.cpp index b7298e304..cc7cc191a 100644 --- a/components/to_utf8/gen_iconv.cpp +++ b/components/to_utf8/gen_iconv.cpp @@ -5,7 +5,7 @@ using namespace std; #include -#include +#include void tab() { cout << " "; } diff --git a/components/to_utf8/to_utf8.cpp b/components/to_utf8/to_utf8.cpp index 3fbbeb733..6bcbbd0e6 100644 --- a/components/to_utf8/to_utf8.cpp +++ b/components/to_utf8/to_utf8.cpp @@ -1,7 +1,7 @@ #include "to_utf8.hpp" #include -#include +#include /* This file contains the code to translate from WINDOWS-1252 (native charset used in English version of Morrowind) to UTF-8. The library diff --git a/libs/mangle/input/servers/ois_driver.cpp b/libs/mangle/input/servers/ois_driver.cpp index b8e4f5eb9..07ba3e83a 100644 --- a/libs/mangle/input/servers/ois_driver.cpp +++ b/libs/mangle/input/servers/ois_driver.cpp @@ -1,6 +1,6 @@ #include "ois_driver.hpp" -#include +#include #include #include #include diff --git a/libs/mangle/rend2d/servers/sdl_driver.cpp b/libs/mangle/rend2d/servers/sdl_driver.cpp index aa1ff6c6d..84a17933f 100644 --- a/libs/mangle/rend2d/servers/sdl_driver.cpp +++ b/libs/mangle/rend2d/servers/sdl_driver.cpp @@ -3,7 +3,7 @@ #include #include #include -#include +#include using namespace Mangle::Rend2D; diff --git a/libs/mangle/rend2d/servers/sdl_gl_driver.cpp b/libs/mangle/rend2d/servers/sdl_gl_driver.cpp index 2bcb1d677..db519e091 100644 --- a/libs/mangle/rend2d/servers/sdl_gl_driver.cpp +++ b/libs/mangle/rend2d/servers/sdl_gl_driver.cpp @@ -4,7 +4,7 @@ #include #include #include -#include +#include using namespace Mangle::Rend2D; diff --git a/libs/openengine/gui/events.cpp b/libs/openengine/gui/events.cpp index bce70704b..35b01158b 100644 --- a/libs/openengine/gui/events.cpp +++ b/libs/openengine/gui/events.cpp @@ -1,6 +1,6 @@ #include #include -#include +#include #include "events.hpp" diff --git a/libs/openengine/gui/manager.cpp b/libs/openengine/gui/manager.cpp index 022c5efb5..9c6ca37eb 100644 --- a/libs/openengine/gui/manager.cpp +++ b/libs/openengine/gui/manager.cpp @@ -1,6 +1,6 @@ #include #include -#include +#include #include "manager.hpp" diff --git a/libs/openengine/input/dispatch_map.hpp b/libs/openengine/input/dispatch_map.hpp index f0d4cabe9..be13e7f01 100644 --- a/libs/openengine/input/dispatch_map.hpp +++ b/libs/openengine/input/dispatch_map.hpp @@ -3,7 +3,7 @@ #include #include -#include +#include namespace OEngine { namespace Input { diff --git a/libs/openengine/input/func_binder.hpp b/libs/openengine/input/func_binder.hpp index 7aa733edf..a815ba0ce 100644 --- a/libs/openengine/input/func_binder.hpp +++ b/libs/openengine/input/func_binder.hpp @@ -4,7 +4,7 @@ #include #include #include -#include +#include namespace OEngine { namespace Input { diff --git a/libs/openengine/misc/list.hpp b/libs/openengine/misc/list.hpp index b08b57494..bda9cb8de 100644 --- a/libs/openengine/misc/list.hpp +++ b/libs/openengine/misc/list.hpp @@ -1,7 +1,7 @@ #ifndef MISC_LIST_H #define MISC_LIST_H -#include +#include namespace Misc{ diff --git a/libs/openengine/ogre/renderer.cpp b/libs/openengine/ogre/renderer.cpp index 275b7385a..f2f4b4c81 100644 --- a/libs/openengine/ogre/renderer.cpp +++ b/libs/openengine/ogre/renderer.cpp @@ -9,7 +9,7 @@ #include "OgreTexture.h" #include "OgreHardwarePixelBuffer.h" -#include +#include #include using namespace Ogre; From e9b95d55cdc0d78c861869c92f31846c047cdc0b Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Tue, 17 Jul 2012 09:49:52 +0200 Subject: [PATCH 27/32] Revert "Proper way to find and use libtbb" This reverts commit d6bf2b7d294d7298b691677e84ac051c86030397. --- CMakeLists.txt | 1 - apps/esmtool/CMakeLists.txt | 1 - apps/launcher/CMakeLists.txt | 3 +-- apps/openmw/CMakeLists.txt | 1 - cmake/FindTBB.cmake | 14 -------------- 5 files changed, 1 insertion(+), 19 deletions(-) delete mode 100644 cmake/FindTBB.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index 49684fd7c..9cc741c67 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -200,7 +200,6 @@ find_package(Boost REQUIRED COMPONENTS system filesystem program_options thread) find_package(OIS REQUIRED) find_package(OpenAL REQUIRED) find_package(Bullet REQUIRED) -find_package(TBB REQUIRED) IF(OGRE_STATIC) find_package(Cg REQUIRED) IF(WIN32) diff --git a/apps/esmtool/CMakeLists.txt b/apps/esmtool/CMakeLists.txt index eb74aa992..af3dc090e 100644 --- a/apps/esmtool/CMakeLists.txt +++ b/apps/esmtool/CMakeLists.txt @@ -10,7 +10,6 @@ add_executable(esmtool target_link_libraries(esmtool ${Boost_LIBRARIES} - ${TBB_LIBRARY} components ) diff --git a/apps/launcher/CMakeLists.txt b/apps/launcher/CMakeLists.txt index 57b7fb71a..ed3559fdc 100644 --- a/apps/launcher/CMakeLists.txt +++ b/apps/launcher/CMakeLists.txt @@ -75,9 +75,8 @@ add_executable(omwlauncher target_link_libraries(omwlauncher ${Boost_LIBRARIES} ${OGRE_LIBRARIES} - ${OGRE_STATIC_PLUGINS} + ${OGRE_STATIC_PLUGINS} ${QT_LIBRARIES} - ${TBB_LIBRARY} components ) diff --git a/apps/openmw/CMakeLists.txt b/apps/openmw/CMakeLists.txt index feefa4fd2..a66cda71e 100644 --- a/apps/openmw/CMakeLists.txt +++ b/apps/openmw/CMakeLists.txt @@ -100,7 +100,6 @@ target_link_libraries(openmw ${BULLET_LIBRARIES} ${MYGUI_LIBRARIES} ${MYGUI_PLATFORM_LIBRARIES} - ${TBB_LIBRARY} components ) diff --git a/cmake/FindTBB.cmake b/cmake/FindTBB.cmake deleted file mode 100644 index f84f81f1c..000000000 --- a/cmake/FindTBB.cmake +++ /dev/null @@ -1,14 +0,0 @@ -# Locate TBB -# This module defines -# TBB_LIBRARY -# TBB_FOUND, if false, do not try to link to TBB -# TBB_INCLUDE_DIR, where to find the headers - -FIND_PATH(TBB_INCLUDE_DIR tbb/tbb.h) - -FIND_LIBRARY(TBB_LIBRARY NAMES tbb) - -SET(TBB_FOUND "NO") -IF(TBB_LIBRARY AND TBB_INCLUDE_DIR) - SET(TBB_FOUND "YES") -ENDIF(TBB_LIBRARY AND TBB_INCLUDE_DIR) From a3652f16ce4fba2cb0bfe304717f5c380e6cb6b2 Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Tue, 17 Jul 2012 12:18:43 +0200 Subject: [PATCH 28/32] Issue #342: factored out dynamic stats calculation into a separate function --- apps/openmw/mwmechanics/actors.cpp | 35 ++++++++++++++++-------------- apps/openmw/mwmechanics/actors.hpp | 2 ++ 2 files changed, 21 insertions(+), 16 deletions(-) diff --git a/apps/openmw/mwmechanics/actors.cpp b/apps/openmw/mwmechanics/actors.cpp index 95747dbbf..60c96e5b9 100644 --- a/apps/openmw/mwmechanics/actors.cpp +++ b/apps/openmw/mwmechanics/actors.cpp @@ -18,22 +18,7 @@ namespace MWMechanics { // magic effects adjustMagicEffects (ptr); - - CreatureStats& creatureStats = MWWorld::Class::get (ptr).getCreatureStats (ptr); - - // calculate dynamic stats - int strength = creatureStats.mAttributes[0].getBase(); - int intelligence = creatureStats.mAttributes[1].getBase(); - int willpower = creatureStats.mAttributes[2].getBase(); - int agility = creatureStats.mAttributes[3].getBase(); - int endurance = creatureStats.mAttributes[5].getBase(); - - double magickaFactor = creatureStats.mMagicEffects.get (EffectKey (84)).mMagnitude*0.1 + 0.5; - - creatureStats.mDynamic[0].setBase (static_cast (0.5 * (strength + endurance))); - creatureStats.mDynamic[1].setBase (static_cast (intelligence + - magickaFactor * intelligence)); - creatureStats.mDynamic[2].setBase (strength+willpower+agility+endurance); + calculateDynamicStats (ptr); } void Actors::updateNpc (const MWWorld::Ptr& ptr, float duration, bool paused) @@ -64,6 +49,24 @@ namespace MWMechanics // TODO apply diff to other stats } + void Actors::calculateDynamicStats (const MWWorld::Ptr& ptr) + { + CreatureStats& creatureStats = MWWorld::Class::get (ptr).getCreatureStats (ptr); + + int strength = creatureStats.mAttributes[0].getBase(); + int intelligence = creatureStats.mAttributes[1].getBase(); + int willpower = creatureStats.mAttributes[2].getBase(); + int agility = creatureStats.mAttributes[3].getBase(); + int endurance = creatureStats.mAttributes[5].getBase(); + + double magickaFactor = creatureStats.mMagicEffects.get (EffectKey (84)).mMagnitude*0.1 + 0.5; + + creatureStats.mDynamic[0].setBase (static_cast (0.5 * (strength + endurance))); + creatureStats.mDynamic[1].setBase (static_cast (intelligence + + magickaFactor * intelligence)); + creatureStats.mDynamic[2].setBase (strength+willpower+agility+endurance); + } + Actors::Actors() : mDuration (0) {} void Actors::addActor (const MWWorld::Ptr& ptr) diff --git a/apps/openmw/mwmechanics/actors.hpp b/apps/openmw/mwmechanics/actors.hpp index 82f8a943c..7458562e1 100644 --- a/apps/openmw/mwmechanics/actors.hpp +++ b/apps/openmw/mwmechanics/actors.hpp @@ -27,6 +27,8 @@ namespace MWMechanics void adjustMagicEffects (const MWWorld::Ptr& creature); + void calculateDynamicStats (const MWWorld::Ptr& ptr); + public: Actors(); From 76de2f73605cf8cf686b95d7cf1536342209766e Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Tue, 17 Jul 2012 15:49:37 +0200 Subject: [PATCH 29/32] Issue #342: handle magic effects 79-82 and 17-20 --- apps/openmw/mwmechanics/actors.cpp | 24 ++++++++++++++++++++++++ apps/openmw/mwmechanics/actors.hpp | 2 ++ apps/openmw/mwmechanics/stat.hpp | 9 ++++++++- 3 files changed, 34 insertions(+), 1 deletion(-) diff --git a/apps/openmw/mwmechanics/actors.cpp b/apps/openmw/mwmechanics/actors.cpp index 60c96e5b9..d4dc5ea00 100644 --- a/apps/openmw/mwmechanics/actors.cpp +++ b/apps/openmw/mwmechanics/actors.cpp @@ -19,6 +19,7 @@ namespace MWMechanics // magic effects adjustMagicEffects (ptr); calculateDynamicStats (ptr); + calculateCreatureStatModifiers (ptr); } void Actors::updateNpc (const MWWorld::Ptr& ptr, float duration, bool paused) @@ -67,6 +68,29 @@ namespace MWMechanics creatureStats.mDynamic[2].setBase (strength+willpower+agility+endurance); } + void Actors::calculateCreatureStatModifiers (const MWWorld::Ptr& ptr) + { + CreatureStats& creatureStats = MWWorld::Class::get (ptr).getCreatureStats (ptr); + + // attributes + for (int i=0; i<5; ++i) + { + int modifier = creatureStats.mMagicEffects.get (EffectKey (79, i)).mMagnitude + - creatureStats.mMagicEffects.get (EffectKey (17, i)).mMagnitude; + + creatureStats.mAttributes[0].setModifier (modifier); + } + + // dynamic stats + for (int i=0; i<3; ++i) + { + int modifier = creatureStats.mMagicEffects.get (EffectKey (80+i)).mMagnitude + - creatureStats.mMagicEffects.get (EffectKey (18+i)).mMagnitude; + + creatureStats.mDynamic[0].setModifier (modifier); + } + } + Actors::Actors() : mDuration (0) {} void Actors::addActor (const MWWorld::Ptr& ptr) diff --git a/apps/openmw/mwmechanics/actors.hpp b/apps/openmw/mwmechanics/actors.hpp index 7458562e1..d5dcef487 100644 --- a/apps/openmw/mwmechanics/actors.hpp +++ b/apps/openmw/mwmechanics/actors.hpp @@ -29,6 +29,8 @@ namespace MWMechanics void calculateDynamicStats (const MWWorld::Ptr& ptr); + void calculateCreatureStatModifiers (const MWWorld::Ptr& ptr); + public: Actors(); diff --git a/apps/openmw/mwmechanics/stat.hpp b/apps/openmw/mwmechanics/stat.hpp index 996036fc1..d576020c5 100644 --- a/apps/openmw/mwmechanics/stat.hpp +++ b/apps/openmw/mwmechanics/stat.hpp @@ -147,7 +147,7 @@ namespace MWMechanics void modify (const T& diff) { mStatic.modify (diff); - modifyCurrent (diff); + setCurrent (getCurrent()+diff); } void setCurrent (const T& value) @@ -159,6 +159,13 @@ namespace MWMechanics else if (mCurrent>getModified()) mCurrent = getModified(); } + + void setModifier (const T& modifier) + { + T diff = modifier - mStatic.getModifier(); + mStatic.setModifier (modifier); + setCurrent (getCurrent()+diff); + } }; template From beb18282bb76f34be8d5113c591dc582e7e7b704 Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Tue, 17 Jul 2012 16:44:55 +0200 Subject: [PATCH 30/32] Issue #342: various fixes --- apps/openmw/mwmechanics/actors.cpp | 6 +++--- apps/openmw/mwworld/actionapply.cpp | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/apps/openmw/mwmechanics/actors.cpp b/apps/openmw/mwmechanics/actors.cpp index d4dc5ea00..72f1be7a8 100644 --- a/apps/openmw/mwmechanics/actors.cpp +++ b/apps/openmw/mwmechanics/actors.cpp @@ -18,8 +18,8 @@ namespace MWMechanics { // magic effects adjustMagicEffects (ptr); - calculateDynamicStats (ptr); calculateCreatureStatModifiers (ptr); + calculateDynamicStats (ptr); } void Actors::updateNpc (const MWWorld::Ptr& ptr, float duration, bool paused) @@ -78,7 +78,7 @@ namespace MWMechanics int modifier = creatureStats.mMagicEffects.get (EffectKey (79, i)).mMagnitude - creatureStats.mMagicEffects.get (EffectKey (17, i)).mMagnitude; - creatureStats.mAttributes[0].setModifier (modifier); + creatureStats.mAttributes[i].setModifier (modifier); } // dynamic stats @@ -87,7 +87,7 @@ namespace MWMechanics int modifier = creatureStats.mMagicEffects.get (EffectKey (80+i)).mMagnitude - creatureStats.mMagicEffects.get (EffectKey (18+i)).mMagnitude; - creatureStats.mDynamic[0].setModifier (modifier); + creatureStats.mDynamic[i].setModifier (modifier); } } diff --git a/apps/openmw/mwworld/actionapply.cpp b/apps/openmw/mwworld/actionapply.cpp index c5228d798..b330a70e7 100644 --- a/apps/openmw/mwworld/actionapply.cpp +++ b/apps/openmw/mwworld/actionapply.cpp @@ -22,7 +22,7 @@ namespace MWWorld void ActionApplyWithSkill::execute() { - if (MWWorld::Class::get (mTarget).apply (mTarget, mId, mActor)) + if (MWWorld::Class::get (mTarget).apply (mTarget, mId, mActor) && mUsageType!=-1) MWWorld::Class::get (mTarget).skillUsageSucceeded (mActor, mSkillIndex, mUsageType); } } From 67443756363ef853f6ebf812f06037cd56ad60cf Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Tue, 17 Jul 2012 18:35:01 +0200 Subject: [PATCH 31/32] fixed a logic error in the auto equip code --- apps/openmw/mwworld/inventorystore.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/apps/openmw/mwworld/inventorystore.cpp b/apps/openmw/mwworld/inventorystore.cpp index 2fd702f6d..9e4381f07 100644 --- a/apps/openmw/mwworld/inventorystore.cpp +++ b/apps/openmw/mwworld/inventorystore.cpp @@ -148,7 +148,7 @@ void MWWorld::InventoryStore::autoEquip (const MWMechanics::NpcStats& stats) bool use = false; if (slots.at (*iter2)==end()) - use = true; // slot was empty before -> skill all further checks + use = true; // slot was empty before -> skip all further checks else { Ptr old = *slots.at (*iter2); @@ -159,7 +159,9 @@ void MWWorld::InventoryStore::autoEquip (const MWMechanics::NpcStats& stats) int oldSkill = MWWorld::Class::get (old).getEquipmentSkill (old); - if (testSkill!=-1 || oldSkill!=-1 || testSkill!=oldSkill) + if (testSkill!=-1 && oldSkill==-1) + use = true; + else if (testSkill!=-1 && oldSkill!=-1 && testSkill!=oldSkill) { if (stats.getSkill (oldSkill).getModified()>stats.getSkill (testSkill).getModified()) continue; // rejected, because old item better matched the NPC's skills. From 483b125aad586b3165537be7a6c55470503fc47c Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Tue, 17 Jul 2012 18:37:20 +0200 Subject: [PATCH 32/32] avoid locking up in case actor updates repeatedly throw exceptions --- apps/openmw/mwmechanics/actors.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/apps/openmw/mwmechanics/actors.cpp b/apps/openmw/mwmechanics/actors.cpp index 72f1be7a8..ff3e91da8 100644 --- a/apps/openmw/mwmechanics/actors.cpp +++ b/apps/openmw/mwmechanics/actors.cpp @@ -126,15 +126,16 @@ namespace MWMechanics if (mDuration>=0.25) { + float totalDuration = mDuration; + mDuration = 0; + for (std::set::iterator iter (mActors.begin()); iter!=mActors.end(); ++iter) { - updateActor (*iter, mDuration); + updateActor (*iter, totalDuration); if (iter->getTypeName()==typeid (ESM::NPC).name()) - updateNpc (*iter, mDuration, paused); + updateNpc (*iter, totalDuration, paused); } - - mDuration = 0; } for (std::set::iterator iter (mActors.begin()); iter!=mActors.end();