From 708d3723ebd25fd132aa4042e14e7169e8a17f5b Mon Sep 17 00:00:00 2001 From: David Cernat Date: Thu, 13 Jul 2017 18:58:48 +0300 Subject: [PATCH] [Client] Fix client script messagebox buttons that had always broken in tes3mp --- apps/openmw/engine.cpp | 14 +++++++++++--- apps/openmw/mwbase/windowmanager.hpp | 10 ++++++++++ apps/openmw/mwgui/windowmanagerimp.cpp | 13 +++++++++++++ apps/openmw/mwgui/windowmanagerimp.hpp | 10 ++++++++++ apps/openmw/mwmp/GUIController.cpp | 7 ++++--- 5 files changed, 48 insertions(+), 6 deletions(-) diff --git a/apps/openmw/engine.cpp b/apps/openmw/engine.cpp index 15ecd6362..508cff609 100644 --- a/apps/openmw/engine.cpp +++ b/apps/openmw/engine.cpp @@ -29,7 +29,18 @@ #include #include + +/* + Start of tes3mp addition + + Include additional headers for multiplayer purposes +*/ #include +#include "mwmp/Main.hpp" +#include "mwmp/GUIController.hpp" +/* + End of tes3mp addition +*/ #include "mwinput/inputmanagerimp.hpp" @@ -57,9 +68,6 @@ #include "mwstate/statemanagerimp.hpp" -#include "mwmp/Main.hpp" -#include "mwmp/GUIController.hpp" - namespace { void checkSDLError(int ret) diff --git a/apps/openmw/mwbase/windowmanager.hpp b/apps/openmw/mwbase/windowmanager.hpp index 882c54f4f..6e4f5a3e0 100644 --- a/apps/openmw/mwbase/windowmanager.hpp +++ b/apps/openmw/mwbase/windowmanager.hpp @@ -257,6 +257,16 @@ namespace MWBase /// returns the index of the pressed button or -1 if no button was pressed (->MessageBoxmanager->InteractiveMessageBox) virtual int readPressedButton() = 0; + /* + Start of tes3mp addition + + Allow the reading of a pressed button without resetting it + */ + virtual int readPressedButton(bool reset) = 0; + /* + End of tes3mp addition + */ + virtual void onFrame (float frameDuration) = 0; /// \todo get rid of this stuff. Move it to the respective UI element classes, if needed. diff --git a/apps/openmw/mwgui/windowmanagerimp.cpp b/apps/openmw/mwgui/windowmanagerimp.cpp index eb6a8bed2..4c9df08fb 100644 --- a/apps/openmw/mwgui/windowmanagerimp.cpp +++ b/apps/openmw/mwgui/windowmanagerimp.cpp @@ -926,6 +926,19 @@ namespace MWGui return mMessageBoxManager->readPressedButton(); } + /* + Start of tes3mp addition + + Allow the reading of a pressed button without resetting it + */ + int WindowManager::readPressedButton(bool reset) + { + return mMessageBoxManager->readPressedButton(reset); + } + /* + End of tes3mp addition + */ + std::string WindowManager::getGameSettingString(const std::string &id, const std::string &default_) { const ESM::GameSetting *setting = mStore->get().search(id); diff --git a/apps/openmw/mwgui/windowmanagerimp.hpp b/apps/openmw/mwgui/windowmanagerimp.hpp index fa374a078..c0103c3b3 100644 --- a/apps/openmw/mwgui/windowmanagerimp.hpp +++ b/apps/openmw/mwgui/windowmanagerimp.hpp @@ -287,6 +287,16 @@ namespace MWGui virtual int readPressedButton (); ///< returns the index of the pressed button or -1 if no button was pressed (->MessageBoxmanager->InteractiveMessageBox) + /* + Start of tes3mp addition + + Allow the reading of a pressed button without resetting it + */ + virtual int readPressedButton(bool reset); + /* + End of tes3mp addition + */ + virtual void onFrame (float frameDuration); /// \todo get rid of this stuff. Move it to the respective UI element classes, if needed. diff --git a/apps/openmw/mwmp/GUIController.cpp b/apps/openmw/mwmp/GUIController.cpp index af08db6f9..d79236d8d 100644 --- a/apps/openmw/mwmp/GUIController.cpp +++ b/apps/openmw/mwmp/GUIController.cpp @@ -197,13 +197,15 @@ bool mwmp::GUIController::hasFocusedElement() return false; } - void mwmp::GUIController::update(float dt) { if (mChat != nullptr) mChat->Update(dt); - int pressedButton = MWBase::Environment::get().getWindowManager()->readPressedButton(); + // Make sure we read the pressed button without resetting it, because it may also get + // checked somewhere else + int pressedButton = MWBase::Environment::get().getWindowManager()->readPressedButton(false); + if (pressedButton != -1 && calledMessageBox) { LOG_MESSAGE_SIMPLE(Log::LOG_VERBOSE, "Pressed: %d", pressedButton); @@ -214,7 +216,6 @@ void mwmp::GUIController::update(float dt) } blockConsole(); - } void mwmp::GUIController::WM_UpdateVisible(MWGui::GuiMode mode)