From df9f601ed74aef143b1487da34906e685e530a5b Mon Sep 17 00:00:00 2001 From: kuyondo Date: Sun, 28 Nov 2021 02:22:34 +0800 Subject: [PATCH] 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; }; }