diff --git a/apps/openmw/mwgui/hud.cpp b/apps/openmw/mwgui/hud.cpp index 6076c1c10..de85f296d 100644 --- a/apps/openmw/mwgui/hud.cpp +++ b/apps/openmw/mwgui/hud.cpp @@ -417,8 +417,7 @@ namespace MWGui icon.insert(slashPos+1, "b_"); icon = MWBase::Environment::get().getWindowManager()->correctIconPath(icon); - mSpellImage->setItem(MWWorld::Ptr()); - mSpellImage->setIcon(icon); + mSpellImage->setSpellIcon(icon); } void HUD::setSelectedEnchantItem(const MWWorld::Ptr& item, int chargePercent) diff --git a/apps/openmw/mwgui/hud.hpp b/apps/openmw/mwgui/hud.hpp index 73428c034..c33c4efad 100644 --- a/apps/openmw/mwgui/hud.hpp +++ b/apps/openmw/mwgui/hud.hpp @@ -15,6 +15,7 @@ namespace MWGui class DragAndDrop; class SpellIcons; class ItemWidget; + class SpellWidget; class HUD : public WindowBase, public LocalMapBase { @@ -64,7 +65,8 @@ namespace MWGui MyGUI::ProgressBar *mHealth, *mMagicka, *mStamina, *mEnemyHealth, *mDrowning; MyGUI::Widget* mHealthFrame; MyGUI::Widget *mWeapBox, *mSpellBox, *mSneakBox; - ItemWidget *mWeapImage, *mSpellImage; + ItemWidget *mWeapImage; + SpellWidget *mSpellImage; MyGUI::ProgressBar *mWeapStatus, *mSpellStatus; MyGUI::Widget *mEffectBox, *mMinimapBox; MyGUI::Button* mMinimapButton; diff --git a/apps/openmw/mwgui/itemwidget.cpp b/apps/openmw/mwgui/itemwidget.cpp index 223bced4f..ba3039a16 100644 --- a/apps/openmw/mwgui/itemwidget.cpp +++ b/apps/openmw/mwgui/itemwidget.cpp @@ -43,6 +43,7 @@ namespace MWGui void ItemWidget::registerComponents() { MyGUI::FactoryManager::getInstance().registerFactory("Widget"); + MyGUI::FactoryManager::getInstance().registerFactory("Widget"); } void ItemWidget::initialiseOverride() @@ -153,4 +154,14 @@ namespace MWGui setIcon(ptr); } + void SpellWidget::setSpellIcon(const std::string& icon) + { + if (mFrame) + mFrame->setImageTexture(""); + if (mItemShadow) + mItemShadow->setImageTexture(icon); + if (mItem) + mItem->setImageTexture(icon); + } + } diff --git a/apps/openmw/mwgui/itemwidget.hpp b/apps/openmw/mwgui/itemwidget.hpp index dd1717d11..e9b9ba1d5 100644 --- a/apps/openmw/mwgui/itemwidget.hpp +++ b/apps/openmw/mwgui/itemwidget.hpp @@ -40,7 +40,7 @@ namespace MWGui void setIcon (const MWWorld::Ptr& ptr); void setFrame (const std::string& frame, const MyGUI::IntCoord& coord); - private: + protected: virtual void initialiseOverride(); MyGUI::ImageBox* mItem; @@ -52,6 +52,14 @@ namespace MWGui std::string mCurrentFrame; }; + class SpellWidget : public ItemWidget + { + MYGUI_RTTI_DERIVED(SpellWidget) + public: + + void setSpellIcon (const std::string& icon); + }; + } #endif diff --git a/apps/openmw/mwgui/layout.cpp b/apps/openmw/mwgui/layout.cpp index 6bdb1a9f4..3035adebb 100644 --- a/apps/openmw/mwgui/layout.cpp +++ b/apps/openmw/mwgui/layout.cpp @@ -58,7 +58,10 @@ namespace MWGui void Layout::setTitle(const std::string& title) { - static_cast(mMainWidget)->setCaptionWithReplacing(title); + MyGUI::Window* window = static_cast(mMainWidget); + + if (window->getCaption() != title) + window->setCaptionWithReplacing(title); } MyGUI::Widget* Layout::getWidget(const std::string &_name) diff --git a/apps/openmw/mwmechanics/mechanicsmanagerimp.cpp b/apps/openmw/mwmechanics/mechanicsmanagerimp.cpp index 0a4486928..9be0326e7 100644 --- a/apps/openmw/mwmechanics/mechanicsmanagerimp.cpp +++ b/apps/openmw/mwmechanics/mechanicsmanagerimp.cpp @@ -236,7 +236,7 @@ namespace MWMechanics // mWatchedTimeToStartDrowning = -1 for correct drowning state check, // if stats.getTimeToStartDrowning() == 0 already on game start MechanicsManager::MechanicsManager() - : mWatchedTimeToStartDrowning(-1), mWatchedStatsEmpty (true), mUpdatePlayer (true), mClassSelected (false), + : mWatchedLevel(-1), mWatchedTimeToStartDrowning(-1), mWatchedStatsEmpty (true), mUpdatePlayer (true), mClassSelected (false), mRaceSelected (false), mAI(true) { //buildPlayer no longer here, needs to be done explicitly after all subsystems are up and running @@ -361,7 +361,11 @@ namespace MWMechanics } } - winMgr->setValue("level", stats.getLevel()); + if(stats.getLevel() != mWatchedLevel) + { + mWatchedLevel = stats.getLevel(); + winMgr->setValue("level", mWatchedLevel); + } mWatchedStatsEmpty = false; @@ -377,10 +381,15 @@ namespace MWMechanics MWWorld::ContainerStoreIterator enchantItem = inv.getSelectedEnchantItem(); if (enchantItem != inv.end()) winMgr->setSelectedEnchantItem(*enchantItem); - else if (!winMgr->getSelectedSpell().empty()) - winMgr->setSelectedSpell(winMgr->getSelectedSpell(), int(MWMechanics::getSpellSuccessChance(winMgr->getSelectedSpell(), mWatched))); else - winMgr->unsetSelectedSpell(); + { + const std::string& spell = winMgr->getSelectedSpell(); + if (!spell.empty()) + winMgr->setSelectedSpell(spell, int(MWMechanics::getSpellSuccessChance(spell, mWatched))); + else + winMgr->unsetSelectedSpell(); + } + } if (mUpdatePlayer) diff --git a/apps/openmw/mwmechanics/mechanicsmanagerimp.hpp b/apps/openmw/mwmechanics/mechanicsmanagerimp.hpp index a1fce4fa9..2dda376f5 100644 --- a/apps/openmw/mwmechanics/mechanicsmanagerimp.hpp +++ b/apps/openmw/mwmechanics/mechanicsmanagerimp.hpp @@ -30,6 +30,8 @@ namespace MWMechanics DynamicStat mWatchedMagicka; DynamicStat mWatchedFatigue; + int mWatchedLevel; + float mWatchedTimeToStartDrowning; bool mWatchedStatsEmpty; diff --git a/files/mygui/openmw_hud.layout b/files/mygui/openmw_hud.layout index cee3f4682..b3e3cfb9d 100644 --- a/files/mygui/openmw_hud.layout +++ b/files/mygui/openmw_hud.layout @@ -72,7 +72,7 @@ - +