From 7cbf36bf17df70d325d03e4cd40859ac31b4c2e2 Mon Sep 17 00:00:00 2001 From: "madmaxoft@gmail.com" Date: Wed, 8 May 2013 09:45:07 +0000 Subject: Refactored window clicking code to use different click actions First part of solving FS #371; should fix #370. git-svn-id: http://mc-server.googlecode.com/svn/trunk@1459 0a769ca7-a7f5-676a-18bf-c427514a06d6 --- source/UI/Window.cpp | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) (limited to 'source/UI/Window.cpp') diff --git a/source/UI/Window.cpp b/source/UI/Window.cpp index 12c3e7350..bb80a7ce7 100644 --- a/source/UI/Window.cpp +++ b/source/UI/Window.cpp @@ -96,7 +96,7 @@ void cWindow::GetSlots(cPlayer & a_Player, cItems & a_Slots) const void cWindow::Clicked( cPlayer & a_Player, - int a_WindowID, short a_SlotNum, bool a_IsRightClick, bool a_IsShiftPressed, + int a_WindowID, short a_SlotNum, eClickAction a_ClickAction, const cItem & a_ClickedItem ) { @@ -106,16 +106,31 @@ void cWindow::Clicked( return; } - if (a_SlotNum < 0) // Outside window click + switch (a_ClickAction) { - if (a_IsRightClick) + case caRightClickOutside: { + // Toss one of the dragged items: a_Player.TossItem(true); + return; } - else + case caLeftClickOutside: { + // Toss all dragged items: a_Player.TossItem(true, a_Player.GetDraggingItem().m_ItemCount); + return; + } + case caLeftClickOutsideHoldNothing: + case caRightClickOutsideHoldNothing: + { + // Nothing needed + return; } + } + + if (a_SlotNum < 0) + { + // TODO: Other click actions with irrelevant slot number (FS #371) return; } @@ -125,7 +140,7 @@ void cWindow::Clicked( { if (LocalSlotNum < (*itr)->GetNumSlots()) { - (*itr)->Clicked(a_Player, LocalSlotNum, a_IsRightClick, a_IsShiftPressed, a_ClickedItem); + (*itr)->Clicked(a_Player, LocalSlotNum, a_ClickAction, a_ClickedItem); return; } LocalSlotNum -= (*itr)->GetNumSlots(); -- cgit v1.2.3