1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-03-03 10:19:41 +00:00

[Client] Finish drag and drops when arrested or teleported by server

This commit is contained in:
David Cernat 2017-12-16 07:21:02 +02:00
parent ebf88d12a3
commit 535fba0cb3
6 changed files with 53 additions and 12 deletions

View file

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

View file

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

View file

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

View file

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

View file

@ -1,7 +1,3 @@
//
// Created by koncord on 14.01.16.
//
#include <components/esm/esmwriter.hpp>
#include <components/openmw-mp/Log.hpp>
@ -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);

View file

@ -47,6 +47,8 @@ namespace mwmp
void removeItems();
void removeSpells();
void closeInventoryWindows();
void setDynamicStats();
void setAttributes();
void setSkills();