From 1440bcaf2adf62909fa72ab4e0f24b5f559af2e4 Mon Sep 17 00:00:00 2001 From: Andrei Kortunov Date: Thu, 16 Nov 2023 16:35:54 +0400 Subject: [PATCH 1/3] Fix HUD cleanup from main menu --- apps/openmw/mwgui/hud.cpp | 25 ++++++++++++++++++------- apps/openmw/mwgui/hud.hpp | 1 - 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/apps/openmw/mwgui/hud.cpp b/apps/openmw/mwgui/hud.cpp index d6eb07e8aa..f52228e280 100644 --- a/apps/openmw/mwgui/hud.cpp +++ b/apps/openmw/mwgui/hud.cpp @@ -650,17 +650,28 @@ namespace MWGui updateEnemyHealthBar(); } - void HUD::resetEnemy() + void HUD::clear() { mEnemyActorId = -1; mEnemyHealthTimer = -1; - } - void HUD::clear() - { - unsetSelectedSpell(); - unsetSelectedWeapon(); - resetEnemy(); + mWeaponSpellTimer = 0.f; + mWeaponName = std::string(); + mSpellName = std::string(); + mWeaponSpellBox->setVisible(false); + + mWeapStatus->setProgressRange(100); + mWeapStatus->setProgressPosition(0); + mSpellStatus->setProgressRange(100); + mSpellStatus->setProgressPosition(0); + + mWeapImage->setItem(MWWorld::Ptr()); + mWeapImage->setIcon(std::string()); + mSpellImage->setItem(MWWorld::Ptr()); + mSpellImage->setIcon(std::string()); + + mWeapBox->clearUserStrings(); + mSpellBox->clearUserStrings(); } void HUD::customMarkerCreated(MyGUI::Widget* marker) diff --git a/apps/openmw/mwgui/hud.hpp b/apps/openmw/mwgui/hud.hpp index 1dd9cdb521..8dd98628c4 100644 --- a/apps/openmw/mwgui/hud.hpp +++ b/apps/openmw/mwgui/hud.hpp @@ -58,7 +58,6 @@ namespace MWGui MyGUI::Widget* getEffectBox() { return mEffectBox; } void setEnemy(const MWWorld::Ptr& enemy); - void resetEnemy(); void clear() override; From fa8f92b5ab2d39e6101a662656871c447962e132 Mon Sep 17 00:00:00 2001 From: Andrei Kortunov Date: Fri, 17 Nov 2023 10:59:44 +0400 Subject: [PATCH 2/3] Do not keep outdated references in the UserData --- apps/openmw/mwgui/hud.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/apps/openmw/mwgui/hud.cpp b/apps/openmw/mwgui/hud.cpp index f52228e280..d3c1762b4f 100644 --- a/apps/openmw/mwgui/hud.cpp +++ b/apps/openmw/mwgui/hud.cpp @@ -421,6 +421,7 @@ namespace MWGui mSpellBox->setUserString("ToolTipType", "Spell"); mSpellBox->setUserString("Spell", spellId.serialize()); + mSpellBox->setUserData(MyGUI::Any::Null); // use the icon of the first effect const ESM::MagicEffect* effect = MWBase::Environment::get().getESMStore()->get().find( @@ -491,6 +492,7 @@ namespace MWGui mSpellStatus->setProgressPosition(0); mSpellImage->setItem(MWWorld::Ptr()); mSpellBox->clearUserStrings(); + mSpellBox->setUserData(MyGUI::Any::Null); } void HUD::unsetSelectedWeapon() @@ -520,6 +522,7 @@ namespace MWGui mWeapBox->setUserString("ToolTipLayout", "HandToHandToolTip"); mWeapBox->setUserString("Caption_HandToHandText", itemName); mWeapBox->setUserString("ImageTexture_HandToHandImage", icon); + mWeapBox->setUserData(MyGUI::Any::Null); } void HUD::setCrosshairVisible(bool visible) @@ -671,7 +674,9 @@ namespace MWGui mSpellImage->setIcon(std::string()); mWeapBox->clearUserStrings(); + mWeapBox->setUserData(MyGUI::Any::Null); mSpellBox->clearUserStrings(); + mSpellBox->setUserData(MyGUI::Any::Null); } void HUD::customMarkerCreated(MyGUI::Widget* marker) From 99939022bde4f98ccb63c4416cb5a970c3073065 Mon Sep 17 00:00:00 2001 From: Andrei Kortunov Date: Fri, 17 Nov 2023 11:18:59 +0400 Subject: [PATCH 3/3] Remove redundant code --- apps/openmw/mwgui/hud.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/apps/openmw/mwgui/hud.cpp b/apps/openmw/mwgui/hud.cpp index d3c1762b4f..bd38174183 100644 --- a/apps/openmw/mwgui/hud.cpp +++ b/apps/openmw/mwgui/hud.cpp @@ -669,9 +669,7 @@ namespace MWGui mSpellStatus->setProgressPosition(0); mWeapImage->setItem(MWWorld::Ptr()); - mWeapImage->setIcon(std::string()); mSpellImage->setItem(MWWorld::Ptr()); - mSpellImage->setIcon(std::string()); mWeapBox->clearUserStrings(); mWeapBox->setUserData(MyGUI::Any::Null);