diff options
-rw-r--r-- | sword2/mouse.cpp | 24 | ||||
-rw-r--r-- | sword2/sword2.h | 11 |
2 files changed, 25 insertions, 10 deletions
diff --git a/sword2/mouse.cpp b/sword2/mouse.cpp index 0f6f15004c..1e7a42718f 100644 --- a/sword2/mouse.cpp +++ b/sword2/mouse.cpp @@ -117,6 +117,16 @@ void Sword2Engine::mouseEngine(void) { } } +#if RIGHT_CLICK_CLEARS_LUGGAGE +bool Sword2Engine::heldIsInInventory(void) { + for (uint i = 0; i < _totalMasters; i++) { + if ((uint32) _masterMenuList[i].icon_resource == Logic::_scriptVars[OBJECT_HELD]) + return true; + } + return false; +} +#endif + int Sword2Engine::menuClick(int menu_items) { if (_mouseX < RDMENU_ICONSTART) return -1; @@ -283,11 +293,8 @@ void Sword2Engine::dragMouse(void) { if (!me) return; -#if 0 - // If the user right-clicks, cancel drag mode. The original code did - // not do this, but it feels natural to me. - - if (me->buttons & RD_RIGHTBUTTONDOWN) { +#if RIGHT_CLICK_CLEARS_LUGGAGE + if ((me->buttons & RD_RIGHTBUTTONDOWN) && heldIsInInventory()) { Logic::_scriptVars[OBJECT_HELD] = 0; _menuSelectedPos = 0; _mouseMode = MOUSE_menu; @@ -568,11 +575,8 @@ void Sword2Engine::normalMouse(void) { return; } -#if 0 - // If user right-clicks while holding an object, release it. The - // original code did not do this, but it feels natural to me. - - if (Logic::_scriptVars[OBJECT_HELD] && (me->buttons & RD_RIGHTBUTTONDOWN)) { +#if RIGHT_CLICK_CLEARS_LUGGAGE + if (Logic::_scriptVars[OBJECT_HELD] && (me->buttons & RD_RIGHTBUTTONDOWN) && heldIsInInventory()) { Logic::_scriptVars[OBJECT_HELD] = 0; _menuSelectedPos = 0; setLuggage(0); diff --git a/sword2/sword2.h b/sword2/sword2.h index da50953151..29f4267c0b 100644 --- a/sword2/sword2.h +++ b/sword2/sword2.h @@ -20,6 +20,13 @@ #ifndef _SWORD2 #define _SWORD2 +// Enable this to make it possible to clear the mouse cursor luggage by +// right-clicking. The original didn't do this, but it feels natural to me. +// However, I'm afraid that it'll interfer badly with parts of the game, so +// for now I'll keep it disabled. + +#define RIGHT_CLICK_CLEARS_LUGGAGE 0 + #include "base/engine.h" #include "common/util.h" @@ -238,6 +245,10 @@ public: int32 initBackground(int32 res, int32 new_palette); +#if RIGHT_CLICK_CLEARS_LUGGAGE + bool heldIsInInventory(void); +#endif + int menuClick(int menu_items); void addMenuObject(MenuObject *obj); |