1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-01-25 06:35:30 +00:00

initialize constants

This commit is contained in:
kuyondo 2021-11-28 02:22:34 +08:00
parent 1f2311538d
commit df9f601ed7
7 changed files with 13 additions and 10 deletions

View File

@ -146,7 +146,7 @@ namespace MWBase
virtual MWGui::CountDialog* getCountDialog() = 0;
virtual MWGui::ConfirmationDialog* getConfirmationDialog() = 0;
virtual MWGui::TradeWindow* getTradeWindow() = 0;
virtual std::vector<MWGui::MessageBox*> getActiveMessageBoxes() = 0;
virtual const std::vector<MWGui::MessageBox*> getActiveMessageBoxes() = 0;
/// Make the player use an item, while updating GUI state accordingly
virtual void useItem(const MWWorld::Ptr& item, bool force=false) = 0;

View File

@ -161,7 +161,7 @@ namespace MWGui
return false;
}
std::vector<MessageBox*> MessageBoxManager::getActiveMessageBoxes()
const std::vector<MessageBox*> MessageBoxManager::getActiveMessageBoxes()
{
return mMessageBoxes;
}
@ -208,7 +208,7 @@ namespace MWGui
mMainWidget->setPosition(pos);
}
std::string MessageBox::getMessage()
const std::string MessageBox::getMessage()
{
return mMessage;
}

View File

@ -49,7 +49,7 @@ namespace MWGui
void setVisible(bool value);
std::vector<MessageBox*> getActiveMessageBoxes();
const std::vector<MessageBox*> getActiveMessageBoxes();
private:
std::vector<MessageBox*> 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);

View File

@ -771,7 +771,7 @@ namespace MWGui
mMessageBoxManager->removeStaticMessageBox();
}
std::vector<MWGui::MessageBox*> WindowManager::getActiveMessageBoxes()
const std::vector<MWGui::MessageBox*> WindowManager::getActiveMessageBoxes()
{
return mMessageBoxManager->getActiveMessageBoxes();
}

View File

@ -187,7 +187,7 @@ namespace MWGui
MWGui::CountDialog* getCountDialog() override;
MWGui::ConfirmationDialog* getConfirmationDialog() override;
MWGui::TradeWindow* getTradeWindow() override;
std::vector<MWGui::MessageBox*> getActiveMessageBoxes() override;
const std::vector<MWGui::MessageBox*> getActiveMessageBoxes() override;
/// Make the player use an item, while updating GUI state accordingly
void useItem(const MWWorld::Ptr& item, bool bypassBeastRestrictions=false) override;

View File

@ -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<MWGui::MessageBox*> msgboxs = MWBase::Environment::get().getWindowManager()->getActiveMessageBoxes();
std::vector<MWGui::MessageBox*>::iterator it = std::find_if(msgboxs.begin(), msgboxs.end(), [](MWGui::MessageBox*& msg)
const std::vector<MWGui::MessageBox*>::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);
}
}

View File

@ -67,6 +67,8 @@ namespace MWInput
bool mSneaking;
bool mAttemptJump;
const std::string mOverencumberedMessage;
float mTimeIdle;
};
}