diff --git a/apps/openmw/mwbase/windowmanager.hpp b/apps/openmw/mwbase/windowmanager.hpp index 4ae470a1c..f77134b68 100644 --- a/apps/openmw/mwbase/windowmanager.hpp +++ b/apps/openmw/mwbase/windowmanager.hpp @@ -198,6 +198,17 @@ namespace MWBase virtual void getMousePosition(int &x, int &y) = 0; virtual void getMousePosition(float &x, float &y) = 0; virtual void setDragDrop(bool dragDrop) = 0; + + /* + Start of tes3mp addition + + Allow the completion of a drag and drop from elsewhere in the code + */ + virtual void finishDragDrop() = 0; + /* + End of tes3mp addition + */ + virtual bool getWorldMouseOver() = 0; virtual bool toggleFogOfWar() = 0; diff --git a/apps/openmw/mwgui/windowmanagerimp.cpp b/apps/openmw/mwgui/windowmanagerimp.cpp index 87476f2a3..19ef989eb 100644 --- a/apps/openmw/mwgui/windowmanagerimp.cpp +++ b/apps/openmw/mwgui/windowmanagerimp.cpp @@ -1204,6 +1204,20 @@ namespace MWGui MWBase::Environment::get().getInputManager()->setDragDrop(dragDrop); } + /* + Start of tes3mp addition + + Allow the completion of a drag and drop from elsewhere in the code + */ + void WindowManager::finishDragDrop() + { + if (mDragAndDrop->mIsOnDragAndDrop) + mDragAndDrop->finish(); + } + /* + End of tes3mp addition + */ + void WindowManager::setCursorVisible(bool visible) { mCursorVisible = visible; diff --git a/apps/openmw/mwgui/windowmanagerimp.hpp b/apps/openmw/mwgui/windowmanagerimp.hpp index 3eab95587..82df6534c 100644 --- a/apps/openmw/mwgui/windowmanagerimp.hpp +++ b/apps/openmw/mwgui/windowmanagerimp.hpp @@ -231,6 +231,17 @@ namespace MWGui virtual void getMousePosition(int &x, int &y); virtual void getMousePosition(float &x, float &y); virtual void setDragDrop(bool dragDrop); + + /* + Start of tes3mp addition + + Allow the completion of a drag and drop from elsewhere in the code + */ + virtual void finishDragDrop(); + /* + End of tes3mp addition + */ + virtual bool getWorldMouseOver(); virtual bool toggleFogOfWar(); diff --git a/apps/openmw/mwmechanics/aipursue.cpp b/apps/openmw/mwmechanics/aipursue.cpp index 50a68c8e6..f7e529cfe 100644 --- a/apps/openmw/mwmechanics/aipursue.cpp +++ b/apps/openmw/mwmechanics/aipursue.cpp @@ -83,18 +83,20 @@ bool AiPursue::execute (const MWWorld::Ptr& actor, CharacterController& characte if (pathTo(actor, dest, duration, 100)) { - target.getClass().activate(target,actor).get()->execute(actor); //Arrest player when reached - /* Start of tes3mp addition Record that the player has not died since the last attempt to arrest them + + Close the player's inventory or open container and cancel any drag and drops */ LOG_MESSAGE_SIMPLE(Log::LOG_INFO, "After being pursued by %s, diedSinceArrestAttempt is now false", actor.getCellRef().getRefId().c_str()); mwmp::Main::get().getLocalPlayer()->diedSinceArrestAttempt = false; + mwmp::Main::get().getLocalPlayer()->closeInventoryWindows(); /* End of tes3mp addition */ + target.getClass().activate(target,actor).get()->execute(actor); //Arrest player when reached return true; } diff --git a/apps/openmw/mwmp/LocalPlayer.cpp b/apps/openmw/mwmp/LocalPlayer.cpp index 696bb9155..9cf6c1df4 100644 --- a/apps/openmw/mwmp/LocalPlayer.cpp +++ b/apps/openmw/mwmp/LocalPlayer.cpp @@ -1,7 +1,3 @@ -// -// Created by koncord on 14.01.16. -// - #include #include @@ -765,6 +761,15 @@ void LocalPlayer::removeSpells() } } +void LocalPlayer::closeInventoryWindows() +{ + if (MWBase::Environment::get().getWindowManager()->containsMode(MWGui::GM_Container) || + MWBase::Environment::get().getWindowManager()->containsMode(MWGui::GM_Inventory)) + MWBase::Environment::get().getWindowManager()->popGuiMode(); + + MWBase::Environment::get().getWindowManager()->cancelDragDrop(); +} + void LocalPlayer::setDynamicStats() { MWBase::World *world = MWBase::Environment::get().getWorld(); @@ -877,12 +882,8 @@ void LocalPlayer::setCell() MWWorld::Ptr ptrPlayer = world->getPlayerPtr(); ESM::Position pos; - // To avoid crashes, close any container menus this player may be in - if (MWBase::Environment::get().getWindowManager()->containsMode(MWGui::GM_Container)) - { - MWBase::Environment::get().getWindowManager()->removeGuiMode(MWGui::GM_Container); - MWBase::Environment::get().getWindowManager()->setDragDrop(false); - } + // To avoid crashes, close container windows this player may be in + closeInventoryWindows(); world->getPlayer().setTeleported(true); diff --git a/apps/openmw/mwmp/LocalPlayer.hpp b/apps/openmw/mwmp/LocalPlayer.hpp index 558d45f1c..b39ffab01 100644 --- a/apps/openmw/mwmp/LocalPlayer.hpp +++ b/apps/openmw/mwmp/LocalPlayer.hpp @@ -47,6 +47,8 @@ namespace mwmp void removeItems(); void removeSpells(); + void closeInventoryWindows(); + void setDynamicStats(); void setAttributes(); void setSkills();