Allow drag-and-drop to be cancelled (Esc or Inventory key)

This commit is contained in:
scrawl 2017-09-22 23:25:20 +02:00
parent 269094ba8d
commit 531e7ac586
3 changed files with 18 additions and 4 deletions

View file

@ -125,6 +125,8 @@ void DragAndDrop::finish()
{ {
mIsOnDragAndDrop = false; mIsOnDragAndDrop = false;
mSourceSortModel->clearDragItems(); mSourceSortModel->clearDragItems();
// since mSourceView doesn't get updated in drag()
MWBase::Environment::get().getWindowManager()->getInventoryWindow()->updateItemView();
MyGUI::Gui::getInstance().destroyWidget(mDraggedWidget); MyGUI::Gui::getInstance().destroyWidget(mDraggedWidget);
mDraggedWidget = 0; mDraggedWidget = 0;

View file

@ -755,7 +755,14 @@ namespace MWGui
mGarbageDialogs.push_back(dialog); mGarbageDialogs.push_back(dialog);
} }
void WindowManager::exitCurrentGuiMode() { void WindowManager::exitCurrentGuiMode()
{
if (mDragAndDrop && mDragAndDrop->mIsOnDragAndDrop)
{
mDragAndDrop->finish();
return;
}
switch(mGuiModes.back()) { switch(mGuiModes.back()) {
case GM_QuickKeysMenu: case GM_QuickKeysMenu:
mQuickKeysMenu->exit(); mQuickKeysMenu->exit();
@ -1247,6 +1254,11 @@ namespace MWGui
void WindowManager::popGuiMode() void WindowManager::popGuiMode()
{ {
if (mDragAndDrop && mDragAndDrop->mIsOnDragAndDrop)
{
mDragAndDrop->finish();
}
if (!mGuiModes.empty()) if (!mGuiModes.empty())
{ {
mGuiModeStates[mGuiModes.back()].update(false); mGuiModeStates[mGuiModes.back()].update(false);

View file

@ -177,13 +177,13 @@ namespace MWInput
void InputManager::channelChanged(ICS::Channel* channel, float currentValue, float previousValue) void InputManager::channelChanged(ICS::Channel* channel, float currentValue, float previousValue)
{ {
if (mDragDrop)
return;
resetIdleTime (); resetIdleTime ();
int action = channel->getNumber(); int action = channel->getNumber();
if (mDragDrop && action != A_GameMenu && action != A_Inventory)
return;
if((previousValue == 1 || previousValue == 0) && (currentValue==1 || currentValue==0)) if((previousValue == 1 || previousValue == 0) && (currentValue==1 || currentValue==0))
{ {
//Is a normal button press, so don't change it at all //Is a normal button press, so don't change it at all