From 98a7d90ee258ceef9c70b0b2955d0458ec46f048 Mon Sep 17 00:00:00 2001 From: elsid Date: Fri, 24 Sep 2021 19:40:29 +0200 Subject: [PATCH 1/9] Assume SIGSTKSZ is not a constant SIGSTKSZ is not defined as constant since glibc 2.34: https://sourceware.org/git/?p=glibc.git;a=commit;h=6c57d320484988e87e446e2e60ce42816bf51d53 --- components/crashcatcher/crashcatcher.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/components/crashcatcher/crashcatcher.cpp b/components/crashcatcher/crashcatcher.cpp index 86571e1e3a..c828e1ca81 100644 --- a/components/crashcatcher/crashcatcher.cpp +++ b/components/crashcatcher/crashcatcher.cpp @@ -56,8 +56,6 @@ static const char exec_err[] = "!!! Failed to exec debug process\n"; static char argv0[PATH_MAX]; -static char altstack[SIGSTKSZ]; - static struct { int signum; @@ -475,9 +473,10 @@ int crashCatcherInstallHandlers(int argc, char **argv, int num_signals, int *sig /* Set an alternate signal stack so SIGSEGVs caused by stack overflows * still run */ + static char* altstack = new char [SIGSTKSZ]; altss.ss_sp = altstack; altss.ss_flags = 0; - altss.ss_size = sizeof(altstack); + altss.ss_size = SIGSTKSZ; sigaltstack(&altss, nullptr); memset(&sa, 0, sizeof(sa)); From 1b1de86b4a984b888669eb9017362f67fbe99d7a Mon Sep 17 00:00:00 2001 From: kuyondo Date: Tue, 23 Nov 2021 04:07:10 +0800 Subject: [PATCH 2/9] Validate Quick Keys --- apps/openmw/mwgui/quickkeysmenu.cpp | 69 ++++++++++++++++------------- apps/openmw/mwgui/quickkeysmenu.hpp | 1 + 2 files changed, 39 insertions(+), 31 deletions(-) diff --git a/apps/openmw/mwgui/quickkeysmenu.cpp b/apps/openmw/mwgui/quickkeysmenu.cpp index ad61f63b90..5bf5a4df63 100644 --- a/apps/openmw/mwgui/quickkeysmenu.cpp +++ b/apps/openmw/mwgui/quickkeysmenu.cpp @@ -79,42 +79,47 @@ namespace MWGui delete mMagicSelectionDialog; } + // Check if quick keys are still valid + void QuickKeysMenu::validate(MWWorld::Ptr player) + { + MWWorld::InventoryStore& store = player.getClass().getInventoryStore(player); + + for (int i = 0; i < 10; ++i) + { + switch (mKey[i].type) + { + case Type_Unassigned: + case Type_HandToHand: + case Type_Magic: + break; + case Type_Item: + case Type_MagicItem: + { + MWWorld::Ptr item = *mKey[i].button->getUserData(); + // Make sure the item is available and is not broken + if (!item || item.getRefData().getCount() < 1 || + (item.getClass().hasItemHealth(item) && + item.getClass().getItemHealth(item) <= 0)) + { + // Try searching for a compatible replacement + item = store.findReplacement(mKey[i].id); + + if (item) + mKey[i].button->setUserData(MWWorld::Ptr(item)); + + break; + } + } + } + } + } + void QuickKeysMenu::onOpen() { WindowBase::onOpen(); MWWorld::Ptr player = MWMechanics::getPlayer(); - MWWorld::InventoryStore& store = player.getClass().getInventoryStore(player); - - // Check if quick keys are still valid - for (int i=0; i<10; ++i) - { - switch (mKey[i].type) - { - case Type_Unassigned: - case Type_HandToHand: - case Type_Magic: - break; - case Type_Item: - case Type_MagicItem: - { - MWWorld::Ptr item = *mKey[i].button->getUserData(); - // Make sure the item is available and is not broken - if (!item || item.getRefData().getCount() < 1 || - (item.getClass().hasItemHealth(item) && - item.getClass().getItemHealth(item) <= 0)) - { - // Try searching for a compatible replacement - item = store.findReplacement(mKey[i].id); - - if (item) - mKey[i].button->setUserData(MWWorld::Ptr(item)); - - break; - } - } - } - } + validate(player); } void QuickKeysMenu::unassign(keyData* key) @@ -334,6 +339,8 @@ namespace MWGui MWWorld::InventoryStore& store = player.getClass().getInventoryStore(player); const MWMechanics::CreatureStats &playerStats = player.getClass().getCreatureStats(player); + validate(player); + // Delay action executing, // if player is busy for now (casting a spell, attacking someone, etc.) bool isDelayNeeded = MWBase::Environment::get().getMechanicsManager()->isAttackingOrSpell(player) diff --git a/apps/openmw/mwgui/quickkeysmenu.hpp b/apps/openmw/mwgui/quickkeysmenu.hpp index b2742df796..bfb54e5d16 100644 --- a/apps/openmw/mwgui/quickkeysmenu.hpp +++ b/apps/openmw/mwgui/quickkeysmenu.hpp @@ -32,6 +32,7 @@ namespace MWGui void onAssignMagicItem (MWWorld::Ptr item); void onAssignMagic (const std::string& spellId); void onAssignMagicCancel (); + void validate(MWWorld::Ptr player); void onOpen() override; void activateQuickKey(int index); From fd58e5ba778124469c91ddfec0669bb6cf649b3a Mon Sep 17 00:00:00 2001 From: Alexei Dobrohotov Date: Tue, 23 Nov 2021 04:39:17 +0300 Subject: [PATCH 3/9] Use the anim source to find mAccumRoot (bug #6417) --- CHANGELOG.md | 1 + apps/openmw/mwrender/animation.cpp | 35 ++++++++++++++++++++++-------- 2 files changed, 27 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6d2a67349b..5bf298a457 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -80,6 +80,7 @@ Bug #6386: Artifacts in water reflection due to imprecise screen-space coordinate computation Bug #6396: Inputting certain Unicode characters triggers an assertion Bug #6416: Morphs are applied to the wrong target + Bug #6417: OpenMW doesn't always use the right node to accumulate movement Bug #6429: Wyrmhaven: Can't add AI packages to player Feature #890: OpenMW-CS: Column filtering Feature #1465: "Reset" argument for AI functions diff --git a/apps/openmw/mwrender/animation.cpp b/apps/openmw/mwrender/animation.cpp index ecfe65c575..bf0ed04055 100644 --- a/apps/openmw/mwrender/animation.cpp +++ b/apps/openmw/mwrender/animation.cpp @@ -624,9 +624,8 @@ namespace MWRender return; const NodeMap& nodeMap = getNodeMap(); - - for (SceneUtil::KeyframeHolder::KeyframeControllerMap::const_iterator it = animsrc->mKeyframes->mKeyframeControllers.begin(); - it != animsrc->mKeyframes->mKeyframeControllers.end(); ++it) + const auto& controllerMap = animsrc->mKeyframes->mKeyframeControllers; + for (SceneUtil::KeyframeHolder::KeyframeControllerMap::const_iterator it = controllerMap.begin(); it != controllerMap.end(); ++it) { std::string bonename = Misc::StringUtils::lowerCase(it->first); NodeMap::const_iterator found = nodeMap.find(bonename); @@ -652,14 +651,32 @@ namespace MWRender SceneUtil::AssignControllerSourcesVisitor assignVisitor(mAnimationTimePtr[0]); mObjectRoot->accept(assignVisitor); + // Determine the movement accumulation bone if necessary if (!mAccumRoot) { - NodeMap::const_iterator found = nodeMap.find("bip01"); - if (found == nodeMap.end()) - found = nodeMap.find("root bone"); - - if (found != nodeMap.end()) - mAccumRoot = found->second; + // Priority matters! bip01 is preferred. + static const std::array accumRootNames = + { + "bip01", + "root bone" + }; + NodeMap::const_iterator found = nodeMap.end(); + for (const std::string& name : accumRootNames) + { + found = nodeMap.find(name); + if (found == nodeMap.end()) + continue; + for (SceneUtil::KeyframeHolder::KeyframeControllerMap::const_iterator it = controllerMap.begin(); it != controllerMap.end(); ++it) + { + if (Misc::StringUtils::lowerCase(it->first) == name) + { + mAccumRoot = found->second; + break; + } + } + if (mAccumRoot) + break; + } } } From 503f0e62e7482c4fa4770e4f7d906187c070c2d9 Mon Sep 17 00:00:00 2001 From: kuyondo Date: Tue, 23 Nov 2021 14:55:50 +0800 Subject: [PATCH 4/9] Validate Argument is Index instead of Player --- apps/openmw/mwgui/quickkeysmenu.cpp | 28 ++++++++++++++-------------- apps/openmw/mwgui/quickkeysmenu.hpp | 4 ++-- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/apps/openmw/mwgui/quickkeysmenu.cpp b/apps/openmw/mwgui/quickkeysmenu.cpp index 5bf5a4df63..1ada078ab6 100644 --- a/apps/openmw/mwgui/quickkeysmenu.cpp +++ b/apps/openmw/mwgui/quickkeysmenu.cpp @@ -79,14 +79,11 @@ namespace MWGui delete mMagicSelectionDialog; } - // Check if quick keys are still valid - void QuickKeysMenu::validate(MWWorld::Ptr player) + inline void QuickKeysMenu::validate(int index) { + MWWorld::Ptr player = MWMechanics::getPlayer(); MWWorld::InventoryStore& store = player.getClass().getInventoryStore(player); - - for (int i = 0; i < 10; ++i) - { - switch (mKey[i].type) + switch (mKey[index].type) { case Type_Unassigned: case Type_HandToHand: @@ -95,31 +92,34 @@ namespace MWGui case Type_Item: case Type_MagicItem: { - MWWorld::Ptr item = *mKey[i].button->getUserData(); + MWWorld::Ptr item = *mKey[index].button->getUserData(); // Make sure the item is available and is not broken + std::cout << item << std::endl; if (!item || item.getRefData().getCount() < 1 || (item.getClass().hasItemHealth(item) && item.getClass().getItemHealth(item) <= 0)) { // Try searching for a compatible replacement - item = store.findReplacement(mKey[i].id); + item = store.findReplacement(mKey[index].id); if (item) - mKey[i].button->setUserData(MWWorld::Ptr(item)); + mKey[index].button->setUserData(MWWorld::Ptr(item)); break; } } } - } } void QuickKeysMenu::onOpen() { WindowBase::onOpen(); - MWWorld::Ptr player = MWMechanics::getPlayer(); - validate(player); + // Quick key index + for (int index = 0; index < 10; ++index) + { + validate(index); + } } void QuickKeysMenu::unassign(keyData* key) @@ -334,12 +334,12 @@ namespace MWGui assert(index >= 1 && index <= 10); keyData *key = &mKey[index-1]; - + MWWorld::Ptr player = MWMechanics::getPlayer(); MWWorld::InventoryStore& store = player.getClass().getInventoryStore(player); const MWMechanics::CreatureStats &playerStats = player.getClass().getCreatureStats(player); - validate(player); + validate(index-1); // Delay action executing, // if player is busy for now (casting a spell, attacking someone, etc.) diff --git a/apps/openmw/mwgui/quickkeysmenu.hpp b/apps/openmw/mwgui/quickkeysmenu.hpp index bfb54e5d16..4761c98ceb 100644 --- a/apps/openmw/mwgui/quickkeysmenu.hpp +++ b/apps/openmw/mwgui/quickkeysmenu.hpp @@ -32,7 +32,6 @@ namespace MWGui void onAssignMagicItem (MWWorld::Ptr item); void onAssignMagic (const std::string& spellId); void onAssignMagicCancel (); - void validate(MWWorld::Ptr player); void onOpen() override; void activateQuickKey(int index); @@ -77,7 +76,8 @@ namespace MWGui void onQuickKeyButtonClicked(MyGUI::Widget* sender); void onOkButtonClicked(MyGUI::Widget* sender); - + // Check if quick key is still valid + inline void validate(int index); void unassign(keyData* key); }; From d55682f8331508411d277d04e374c7ea7c6abad7 Mon Sep 17 00:00:00 2001 From: kuyondo Date: Tue, 23 Nov 2021 15:14:59 +0800 Subject: [PATCH 5/9] remove debug code --- apps/openmw/mwgui/quickkeysmenu.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/apps/openmw/mwgui/quickkeysmenu.cpp b/apps/openmw/mwgui/quickkeysmenu.cpp index 1ada078ab6..a581a52cc0 100644 --- a/apps/openmw/mwgui/quickkeysmenu.cpp +++ b/apps/openmw/mwgui/quickkeysmenu.cpp @@ -94,7 +94,6 @@ namespace MWGui { MWWorld::Ptr item = *mKey[index].button->getUserData(); // Make sure the item is available and is not broken - std::cout << item << std::endl; if (!item || item.getRefData().getCount() < 1 || (item.getClass().hasItemHealth(item) && item.getClass().getItemHealth(item) <= 0)) From 60a345f5ccf59bfe6485f12f9e201cb6f87fbcb0 Mon Sep 17 00:00:00 2001 From: kuyondo Date: Wed, 24 Nov 2021 01:44:14 +0800 Subject: [PATCH 6/9] Better indentation --- apps/openmw/mwgui/quickkeysmenu.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/apps/openmw/mwgui/quickkeysmenu.cpp b/apps/openmw/mwgui/quickkeysmenu.cpp index a581a52cc0..e55b9b4878 100644 --- a/apps/openmw/mwgui/quickkeysmenu.cpp +++ b/apps/openmw/mwgui/quickkeysmenu.cpp @@ -83,8 +83,8 @@ namespace MWGui { MWWorld::Ptr player = MWMechanics::getPlayer(); MWWorld::InventoryStore& store = player.getClass().getInventoryStore(player); - switch (mKey[index].type) - { + switch (mKey[index].type) + { case Type_Unassigned: case Type_HandToHand: case Type_Magic: @@ -107,7 +107,7 @@ namespace MWGui break; } } - } + } } void QuickKeysMenu::onOpen() From 5ffd077f9ec8fba5fba51ad5cb3a9e645ddfffc1 Mon Sep 17 00:00:00 2001 From: kuyondo Date: Wed, 24 Nov 2021 01:51:03 +0800 Subject: [PATCH 7/9] Update changelog.md --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6d2a67349b..87b2d72770 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -81,6 +81,7 @@ Bug #6396: Inputting certain Unicode characters triggers an assertion Bug #6416: Morphs are applied to the wrong target Bug #6429: Wyrmhaven: Can't add AI packages to player + Bug #6433: Items bound to Quick Keys sometimes do not appear until the Quick Key menu is opened. Feature #890: OpenMW-CS: Column filtering Feature #1465: "Reset" argument for AI functions Feature #2554: Modifying an object triggers the instances table to scroll to the corresponding record From 1f2311538dc344cd418ef682cbe2806bf342b110 Mon Sep 17 00:00:00 2001 From: kuyondo Date: Fri, 26 Nov 2021 05:20:58 +0800 Subject: [PATCH 8/9] vanilla style messagebox 2 --- apps/openmw/mwbase/windowmanager.hpp | 2 ++ apps/openmw/mwgui/messagebox.cpp | 11 +++++++++++ apps/openmw/mwgui/messagebox.hpp | 5 ++++- apps/openmw/mwgui/windowmanagerimp.cpp | 5 +++++ apps/openmw/mwgui/windowmanagerimp.hpp | 1 + apps/openmw/mwinput/actionmanager.cpp | 17 +++++++++++------ apps/openmw/mwinput/actionmanager.hpp | 1 - 7 files changed, 34 insertions(+), 8 deletions(-) diff --git a/apps/openmw/mwbase/windowmanager.hpp b/apps/openmw/mwbase/windowmanager.hpp index 961a63ac79..6a05a71703 100644 --- a/apps/openmw/mwbase/windowmanager.hpp +++ b/apps/openmw/mwbase/windowmanager.hpp @@ -69,6 +69,7 @@ namespace MWGui class DialogueWindow; class WindowModal; class JailScreen; + class MessageBox; enum ShowInDialogueMode { ShowInDialogueMode_IfPossible, @@ -145,6 +146,7 @@ namespace MWBase virtual MWGui::CountDialog* getCountDialog() = 0; virtual MWGui::ConfirmationDialog* getConfirmationDialog() = 0; virtual MWGui::TradeWindow* getTradeWindow() = 0; + virtual std::vector getActiveMessageBoxes() = 0; /// Make the player use an item, while updating GUI state accordingly virtual void useItem(const MWWorld::Ptr& item, bool force=false) = 0; diff --git a/apps/openmw/mwgui/messagebox.cpp b/apps/openmw/mwgui/messagebox.cpp index ed6633c983..738d28e189 100644 --- a/apps/openmw/mwgui/messagebox.cpp +++ b/apps/openmw/mwgui/messagebox.cpp @@ -161,6 +161,12 @@ namespace MWGui return false; } + std::vector MessageBoxManager::getActiveMessageBoxes() + { + return mMessageBoxes; + } + + int MessageBoxManager::readPressedButton (bool reset) { int pressed = mLastButtonPressed; @@ -202,6 +208,11 @@ namespace MWGui mMainWidget->setPosition(pos); } + std::string MessageBox::getMessage() + { + return mMessage; + } + int MessageBox::getHeight () { return mMainWidget->getHeight()+mNextBoxPadding; diff --git a/apps/openmw/mwgui/messagebox.hpp b/apps/openmw/mwgui/messagebox.hpp index 26d26bac56..746d558e6a 100644 --- a/apps/openmw/mwgui/messagebox.hpp +++ b/apps/openmw/mwgui/messagebox.hpp @@ -49,6 +49,8 @@ namespace MWGui void setVisible(bool value); + std::vector getActiveMessageBoxes(); + private: std::vector mMessageBoxes; InteractiveMessageBox* mInterMessageBoxe; @@ -63,6 +65,7 @@ namespace MWGui public: MessageBox (MessageBoxManager& parMessageBoxManager, const std::string& message); void setMessage (const std::string& message); + std::string getMessage(); int getHeight (); void update (int height); void setVisible(bool value); @@ -72,7 +75,7 @@ namespace MWGui protected: MessageBoxManager& mMessageBoxManager; - const std::string& mMessage; + const std::string mMessage; MyGUI::EditBox* mMessageWidget; int mBottomPadding; int mNextBoxPadding; diff --git a/apps/openmw/mwgui/windowmanagerimp.cpp b/apps/openmw/mwgui/windowmanagerimp.cpp index a935d7f900..28a19a63ef 100644 --- a/apps/openmw/mwgui/windowmanagerimp.cpp +++ b/apps/openmw/mwgui/windowmanagerimp.cpp @@ -771,6 +771,11 @@ namespace MWGui mMessageBoxManager->removeStaticMessageBox(); } + std::vector WindowManager::getActiveMessageBoxes() + { + return mMessageBoxManager->getActiveMessageBoxes(); + } + int WindowManager::readPressedButton () { return mMessageBoxManager->readPressedButton(); diff --git a/apps/openmw/mwgui/windowmanagerimp.hpp b/apps/openmw/mwgui/windowmanagerimp.hpp index 9ec79e0c82..a4bc266a86 100644 --- a/apps/openmw/mwgui/windowmanagerimp.hpp +++ b/apps/openmw/mwgui/windowmanagerimp.hpp @@ -187,6 +187,7 @@ namespace MWGui MWGui::CountDialog* getCountDialog() override; MWGui::ConfirmationDialog* getConfirmationDialog() override; MWGui::TradeWindow* getTradeWindow() override; + std::vector getActiveMessageBoxes() override; /// Make the player use an item, while updating GUI state accordingly void useItem(const MWWorld::Ptr& item, bool bypassBeastRestrictions=false) override; diff --git a/apps/openmw/mwinput/actionmanager.cpp b/apps/openmw/mwinput/actionmanager.cpp index 59bdc37bb8..180f3aa2fb 100644 --- a/apps/openmw/mwinput/actionmanager.cpp +++ b/apps/openmw/mwinput/actionmanager.cpp @@ -22,6 +22,8 @@ #include "../mwmechanics/npcstats.hpp" #include "../mwmechanics/actorutil.hpp" +#include "../mwgui/messagebox.hpp" + #include "actions.hpp" #include "bindingsmanager.hpp" @@ -39,7 +41,6 @@ namespace MWInput , mAlwaysRunActive(Settings::Manager::getBool("always run", "Input")) , mSneaking(false) , mAttemptJump(false) - , mOverencumberedMessageDelay(0.f) , mTimeIdle(0.f) { } @@ -88,22 +89,26 @@ namespace MWInput { player.setUpDown(1); triedToMove = true; - mOverencumberedMessageDelay = 0.f; } // if player tried to start moving, but can't (due to being overencumbered), display a notification. if (triedToMove) { MWWorld::Ptr playerPtr = MWBase::Environment::get().getWorld ()->getPlayerPtr(); - mOverencumberedMessageDelay -= dt; if (playerPtr.getClass().getEncumbrance(playerPtr) > playerPtr.getClass().getCapacity(playerPtr)) { player.setAutoMove (false); - if (mOverencumberedMessageDelay <= 0) + std::vector msgboxs = MWBase::Environment::get().getWindowManager()->getActiveMessageBoxes(); + std::vector::iterator it = std::find_if(msgboxs.begin(), msgboxs.end(), [](MWGui::MessageBox*& msg) { + return (msg->getMessage() == "#{sNotifyMessage59}"); + }); + + // if an overencumbered messagebox is already present, reset its expiry timer, otherwise create new one. + if (it != msgboxs.end()) + (*it)->mCurrentTime = 0; + else MWBase::Environment::get().getWindowManager()->messageBox("#{sNotifyMessage59}"); - mOverencumberedMessageDelay = 1.0; - } } } diff --git a/apps/openmw/mwinput/actionmanager.hpp b/apps/openmw/mwinput/actionmanager.hpp index 4141767bcc..4c51139d46 100644 --- a/apps/openmw/mwinput/actionmanager.hpp +++ b/apps/openmw/mwinput/actionmanager.hpp @@ -67,7 +67,6 @@ namespace MWInput bool mSneaking; bool mAttemptJump; - float mOverencumberedMessageDelay; float mTimeIdle; }; } From df9f601ed74aef143b1487da34906e685e530a5b Mon Sep 17 00:00:00 2001 From: kuyondo Date: Sun, 28 Nov 2021 02:22:34 +0800 Subject: [PATCH 9/9] initialize constants --- apps/openmw/mwbase/windowmanager.hpp | 2 +- apps/openmw/mwgui/messagebox.cpp | 4 ++-- apps/openmw/mwgui/messagebox.hpp | 4 ++-- apps/openmw/mwgui/windowmanagerimp.cpp | 2 +- apps/openmw/mwgui/windowmanagerimp.hpp | 2 +- apps/openmw/mwinput/actionmanager.cpp | 7 ++++--- apps/openmw/mwinput/actionmanager.hpp | 2 ++ 7 files changed, 13 insertions(+), 10 deletions(-) diff --git a/apps/openmw/mwbase/windowmanager.hpp b/apps/openmw/mwbase/windowmanager.hpp index 6a05a71703..e7d22bef92 100644 --- a/apps/openmw/mwbase/windowmanager.hpp +++ b/apps/openmw/mwbase/windowmanager.hpp @@ -146,7 +146,7 @@ namespace MWBase virtual MWGui::CountDialog* getCountDialog() = 0; virtual MWGui::ConfirmationDialog* getConfirmationDialog() = 0; virtual MWGui::TradeWindow* getTradeWindow() = 0; - virtual std::vector getActiveMessageBoxes() = 0; + virtual const std::vector getActiveMessageBoxes() = 0; /// Make the player use an item, while updating GUI state accordingly virtual void useItem(const MWWorld::Ptr& item, bool force=false) = 0; diff --git a/apps/openmw/mwgui/messagebox.cpp b/apps/openmw/mwgui/messagebox.cpp index 738d28e189..fa9a8007b7 100644 --- a/apps/openmw/mwgui/messagebox.cpp +++ b/apps/openmw/mwgui/messagebox.cpp @@ -161,7 +161,7 @@ namespace MWGui return false; } - std::vector MessageBoxManager::getActiveMessageBoxes() + const std::vector MessageBoxManager::getActiveMessageBoxes() { return mMessageBoxes; } @@ -208,7 +208,7 @@ namespace MWGui mMainWidget->setPosition(pos); } - std::string MessageBox::getMessage() + const std::string MessageBox::getMessage() { return mMessage; } diff --git a/apps/openmw/mwgui/messagebox.hpp b/apps/openmw/mwgui/messagebox.hpp index 746d558e6a..e01c54b9a5 100644 --- a/apps/openmw/mwgui/messagebox.hpp +++ b/apps/openmw/mwgui/messagebox.hpp @@ -49,7 +49,7 @@ namespace MWGui void setVisible(bool value); - std::vector getActiveMessageBoxes(); + const std::vector getActiveMessageBoxes(); private: std::vector mMessageBoxes; @@ -65,7 +65,7 @@ namespace MWGui public: MessageBox (MessageBoxManager& parMessageBoxManager, const std::string& message); void setMessage (const std::string& message); - std::string getMessage(); + const std::string getMessage(); int getHeight (); void update (int height); void setVisible(bool value); diff --git a/apps/openmw/mwgui/windowmanagerimp.cpp b/apps/openmw/mwgui/windowmanagerimp.cpp index 28a19a63ef..2eff1f6c84 100644 --- a/apps/openmw/mwgui/windowmanagerimp.cpp +++ b/apps/openmw/mwgui/windowmanagerimp.cpp @@ -771,7 +771,7 @@ namespace MWGui mMessageBoxManager->removeStaticMessageBox(); } - std::vector WindowManager::getActiveMessageBoxes() + const std::vector WindowManager::getActiveMessageBoxes() { return mMessageBoxManager->getActiveMessageBoxes(); } diff --git a/apps/openmw/mwgui/windowmanagerimp.hpp b/apps/openmw/mwgui/windowmanagerimp.hpp index a4bc266a86..10577c8485 100644 --- a/apps/openmw/mwgui/windowmanagerimp.hpp +++ b/apps/openmw/mwgui/windowmanagerimp.hpp @@ -187,7 +187,7 @@ namespace MWGui MWGui::CountDialog* getCountDialog() override; MWGui::ConfirmationDialog* getConfirmationDialog() override; MWGui::TradeWindow* getTradeWindow() override; - std::vector getActiveMessageBoxes() override; + const std::vector getActiveMessageBoxes() override; /// Make the player use an item, while updating GUI state accordingly void useItem(const MWWorld::Ptr& item, bool bypassBeastRestrictions=false) override; diff --git a/apps/openmw/mwinput/actionmanager.cpp b/apps/openmw/mwinput/actionmanager.cpp index 180f3aa2fb..84bdc7d12b 100644 --- a/apps/openmw/mwinput/actionmanager.cpp +++ b/apps/openmw/mwinput/actionmanager.cpp @@ -42,6 +42,7 @@ namespace MWInput , mSneaking(false) , mAttemptJump(false) , mTimeIdle(0.f) + , mOverencumberedMessage("#{sNotifyMessage59}") { } @@ -99,16 +100,16 @@ namespace MWInput { player.setAutoMove (false); std::vector msgboxs = MWBase::Environment::get().getWindowManager()->getActiveMessageBoxes(); - std::vector::iterator it = std::find_if(msgboxs.begin(), msgboxs.end(), [](MWGui::MessageBox*& msg) + const std::vector::iterator it = std::find_if(msgboxs.begin(), msgboxs.end(), [=](MWGui::MessageBox*& msgbox) { - return (msg->getMessage() == "#{sNotifyMessage59}"); + return (msgbox->getMessage() == mOverencumberedMessage); }); // if an overencumbered messagebox is already present, reset its expiry timer, otherwise create new one. if (it != msgboxs.end()) (*it)->mCurrentTime = 0; else - MWBase::Environment::get().getWindowManager()->messageBox("#{sNotifyMessage59}"); + MWBase::Environment::get().getWindowManager()->messageBox(mOverencumberedMessage); } } diff --git a/apps/openmw/mwinput/actionmanager.hpp b/apps/openmw/mwinput/actionmanager.hpp index 4c51139d46..b3deaed20e 100644 --- a/apps/openmw/mwinput/actionmanager.hpp +++ b/apps/openmw/mwinput/actionmanager.hpp @@ -67,6 +67,8 @@ namespace MWInput bool mSneaking; bool mAttemptJump; + const std::string mOverencumberedMessage; + float mTimeIdle; }; }