diff --git a/apps/openmw/mwbase/windowmanager.hpp b/apps/openmw/mwbase/windowmanager.hpp index 11d96f16c..2a332e94c 100644 --- a/apps/openmw/mwbase/windowmanager.hpp +++ b/apps/openmw/mwbase/windowmanager.hpp @@ -145,6 +145,17 @@ namespace MWBase virtual MWGui::ConfirmationDialog* getConfirmationDialog() = 0; virtual MWGui::TradeWindow* getTradeWindow() = 0; + /* + Start of tes3mp addition + + Make it possible to get the ContainerWindow from elsewhere + in the code + */ + virtual MWGui::ContainerWindow* getContainerWindow() = 0; + /* + End of tes3mp addition + */ + /// Make the player use an item, while updating GUI state accordingly virtual void useItem(const MWWorld::Ptr& item) = 0; diff --git a/apps/openmw/mwgui/windowmanagerimp.cpp b/apps/openmw/mwgui/windowmanagerimp.cpp index 6b7bf2e9d..20d30cdf1 100644 --- a/apps/openmw/mwgui/windowmanagerimp.cpp +++ b/apps/openmw/mwgui/windowmanagerimp.cpp @@ -384,10 +384,19 @@ namespace MWGui mGuiModeStates[GM_Dialogue] = GuiModeState(mDialogueWindow); mTradeWindow->eventTradeDone += MyGUI::newDelegate(mDialogueWindow, &DialogueWindow::onTradeComplete); - ContainerWindow* containerWindow = new ContainerWindow(mDragAndDrop); - mWindows.push_back(containerWindow); - trackWindow(containerWindow, "container"); - mGuiModeStates[GM_Container] = GuiModeState({containerWindow, mInventoryWindow}); + /* + Start of tes3mp change (major) + + Use a member variable (mContainerWIndow) instead of a local one so + we can access it from elsewhere + */ + mContainerWindow = new ContainerWindow(mDragAndDrop); + mWindows.push_back(mContainerWindow); + trackWindow(mContainerWindow, "container"); + mGuiModeStates[GM_Container] = GuiModeState({mContainerWindow, mInventoryWindow}); + /* + End of tes3mp change (major) + */ mHud = new HUD(mCustomMarkers, mDragAndDrop, mLocalMapRender); mWindows.push_back(mHud); @@ -1399,6 +1408,17 @@ namespace MWGui MWGui::ConfirmationDialog* WindowManager::getConfirmationDialog() { return mConfirmationDialog; } MWGui::TradeWindow* WindowManager::getTradeWindow() { return mTradeWindow; } + /* + Start of tes3mp addition + + Make it possible to get the ContainerWindow from elsewhere + in the code + */ + MWGui::ContainerWindow* WindowManager::getContainerWindow() { return mContainerWindow; } + /* + End of tes3mp addition + */ + void WindowManager::useItem(const MWWorld::Ptr &item) { if (mInventoryWindow) diff --git a/apps/openmw/mwgui/windowmanagerimp.hpp b/apps/openmw/mwgui/windowmanagerimp.hpp index f1fa3e7c5..0c5d93e5b 100644 --- a/apps/openmw/mwgui/windowmanagerimp.hpp +++ b/apps/openmw/mwgui/windowmanagerimp.hpp @@ -184,6 +184,17 @@ namespace MWGui virtual MWGui::ConfirmationDialog* getConfirmationDialog(); virtual MWGui::TradeWindow* getTradeWindow(); + /* + Start of tes3mp addition + + Make it possible to get the ContainerWindow from elsewhere + in the code + */ + virtual MWGui::ContainerWindow* getContainerWindow(); + /* + End of tes3mp addition + */ + /// Make the player use an item, while updating GUI state accordingly virtual void useItem(const MWWorld::Ptr& item); @@ -510,6 +521,17 @@ namespace MWGui DebugWindow* mDebugWindow; JailScreen* mJailScreen; + /* + Start of tes3mp addition + + Keep a pointer to the container window because of its usefulness + in multiplayer for container sync + */ + ContainerWindow* mContainerWindow; + /* + End of tes3mp addition + */ + std::vector mWindows; Translation::Storage& mTranslationDataStorage;