Merge branch 'msgboxvanillastyle' into 'master'

Vanilla style encumbrance messagebox

Closes #6191

See merge request OpenMW/openmw!1437
pull/3225/head
psi29a 3 years ago
commit dc4d73e76c

@ -57,6 +57,7 @@
Bug #6174: Spellmaking and Enchanting sliders differences from vanilla
Bug #6177: Followers of player follower stop following after waiting for a day
Bug #6184: Command and Calm and Demoralize and Frenzy and Rally magic effects inconsistencies with vanilla
Bug #6191: Encumbrance messagebox timer works incorrectly
Bug #6197: Infinite Casting Loop
Bug #6253: Multiple instances of Reflect stack additively
Bug #6255: Reflect is different from vanilla

@ -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 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;

@ -145,7 +145,6 @@ namespace MWGui
return mInterMessageBoxe != nullptr;
}
bool MessageBoxManager::removeMessageBox (MessageBox *msgbox)
{
std::vector<MessageBox*>::iterator it;
@ -161,6 +160,11 @@ namespace MWGui
return false;
}
const std::vector<MessageBox*> MessageBoxManager::getActiveMessageBoxes()
{
return mMessageBoxes;
}
int MessageBoxManager::readPressedButton (bool reset)
{
int pressed = mLastButtonPressed;

@ -49,6 +49,8 @@ namespace MWGui
void setVisible(bool value);
const std::vector<MessageBox*> getActiveMessageBoxes();
private:
std::vector<MessageBox*> mMessageBoxes;
InteractiveMessageBox* mInterMessageBoxe;
@ -63,6 +65,7 @@ namespace MWGui
public:
MessageBox (MessageBoxManager& parMessageBoxManager, const std::string& message);
void setMessage (const std::string& message);
const std::string& getMessage() { return mMessage; };
int getHeight ();
void update (int height);
void setVisible(bool value);
@ -72,7 +75,7 @@ namespace MWGui
protected:
MessageBoxManager& mMessageBoxManager;
const std::string& mMessage;
std::string mMessage;
MyGUI::EditBox* mMessageWidget;
int mBottomPadding;
int mNextBoxPadding;

@ -773,6 +773,11 @@ namespace MWGui
mMessageBoxManager->removeStaticMessageBox();
}
const std::vector<MWGui::MessageBox*> WindowManager::getActiveMessageBoxes()
{
return mMessageBoxManager->getActiveMessageBoxes();
}
int WindowManager::readPressedButton ()
{
return mMessageBoxManager->readPressedButton();

@ -187,6 +187,7 @@ namespace MWGui
MWGui::CountDialog* getCountDialog() override;
MWGui::ConfirmationDialog* getConfirmationDialog() override;
MWGui::TradeWindow* getTradeWindow() 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;

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

@ -67,7 +67,6 @@ namespace MWInput
bool mSneaking;
bool mAttemptJump;
float mOverencumberedMessageDelay;
float mTimeIdle;
};
}

Loading…
Cancel
Save