summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/Defines.h6
-rw-r--r--src/Protocol/Protocol_1_8.cpp3
-rw-r--r--src/Protocol/Protocol_1_9.cpp3
-rw-r--r--src/UI/Window.cpp43
-rw-r--r--src/UI/Window.h8
5 files changed, 53 insertions, 10 deletions
diff --git a/src/Defines.h b/src/Defines.h
index 172d5e30d..35afd003c 100644
--- a/src/Defines.h
+++ b/src/Defines.h
@@ -99,10 +99,13 @@ enum eClickAction
caRightClickOutsideHoldNothing,
caLeftPaintBegin,
caRightPaintBegin,
+ caMiddlePaintBegin,
caLeftPaintProgress,
caRightPaintProgress,
+ caMiddlePaintProgress,
caLeftPaintEnd,
caRightPaintEnd,
+ caMiddlePaintEnd,
caDblClick,
// Add new actions here
caUnknown = 255,
@@ -266,10 +269,13 @@ inline const char * ClickActionToString(int a_ClickAction)
case caRightClickOutsideHoldNothing: return "caRightClickOutsideHoldNothing";
case caLeftPaintBegin: return "caLeftPaintBegin";
case caRightPaintBegin: return "caRightPaintBegin";
+ case caMiddlePaintBegin: return "caMiddlePaintBegin";
case caLeftPaintProgress: return "caLeftPaintProgress";
case caRightPaintProgress: return "caRightPaintProgress";
+ case caMiddlePaintProgress: return "caMiddlePaintProgress";
case caLeftPaintEnd: return "caLeftPaintEnd";
case caRightPaintEnd: return "caRightPaintEnd";
+ case caMiddlePaintEnd: return "caMiddlePaintEnd";
case caDblClick: return "caDblClick";
case caUnknown: return "caUnknown";
diff --git a/src/Protocol/Protocol_1_8.cpp b/src/Protocol/Protocol_1_8.cpp
index ee2172eaf..aa5af83e1 100644
--- a/src/Protocol/Protocol_1_8.cpp
+++ b/src/Protocol/Protocol_1_8.cpp
@@ -2690,6 +2690,9 @@ void cProtocol_1_8_0::HandlePacketWindowClick(cByteBuffer & a_ByteBuffer)
case 0x0504: Action = (SlotNum == SLOT_NUM_OUTSIDE) ? caRightPaintBegin : caUnknown; break;
case 0x0505: Action = (SlotNum != SLOT_NUM_OUTSIDE) ? caRightPaintProgress : caUnknown; break;
case 0x0506: Action = (SlotNum == SLOT_NUM_OUTSIDE) ? caRightPaintEnd : caUnknown; break;
+ case 0x0508: Action = (SlotNum == SLOT_NUM_OUTSIDE) ? caMiddlePaintBegin : caUnknown; break;
+ case 0x0509: Action = (SlotNum != SLOT_NUM_OUTSIDE) ? caMiddlePaintProgress : caUnknown; break;
+ case 0x050a: Action = (SlotNum == SLOT_NUM_OUTSIDE) ? caMiddlePaintEnd : caUnknown; break;
case 0x0600: Action = caDblClick; break;
default:
{
diff --git a/src/Protocol/Protocol_1_9.cpp b/src/Protocol/Protocol_1_9.cpp
index 5c3be674f..665a1f457 100644
--- a/src/Protocol/Protocol_1_9.cpp
+++ b/src/Protocol/Protocol_1_9.cpp
@@ -2788,6 +2788,9 @@ void cProtocol_1_9_0::HandlePacketWindowClick(cByteBuffer & a_ByteBuffer)
case 0x0504: Action = (SlotNum == SLOT_NUM_OUTSIDE) ? caRightPaintBegin : caUnknown; break;
case 0x0505: Action = (SlotNum != SLOT_NUM_OUTSIDE) ? caRightPaintProgress : caUnknown; break;
case 0x0506: Action = (SlotNum == SLOT_NUM_OUTSIDE) ? caRightPaintEnd : caUnknown; break;
+ case 0x0508: Action = (SlotNum == SLOT_NUM_OUTSIDE) ? caMiddlePaintBegin : caUnknown; break;
+ case 0x0509: Action = (SlotNum != SLOT_NUM_OUTSIDE) ? caMiddlePaintProgress : caUnknown; break;
+ case 0x050a: Action = (SlotNum == SLOT_NUM_OUTSIDE) ? caMiddlePaintEnd : caUnknown; break;
case 0x0600: Action = caDblClick; break;
default:
{
diff --git a/src/UI/Window.cpp b/src/UI/Window.cpp
index 4582d6cf4..8bbc4f482 100644
--- a/src/UI/Window.cpp
+++ b/src/UI/Window.cpp
@@ -242,12 +242,15 @@ void cWindow::Clicked(
// Nothing needed
return;
}
- case caLeftPaintBegin: OnPaintBegin (a_Player); return;
- case caRightPaintBegin: OnPaintBegin (a_Player); return;
- case caLeftPaintProgress: OnPaintProgress(a_Player, a_SlotNum); return;
- case caRightPaintProgress: OnPaintProgress(a_Player, a_SlotNum); return;
- case caLeftPaintEnd: OnLeftPaintEnd (a_Player); return;
- case caRightPaintEnd: OnRightPaintEnd(a_Player); return;
+ case caLeftPaintBegin: OnPaintBegin (a_Player); return;
+ case caRightPaintBegin: OnPaintBegin (a_Player); return;
+ case caMiddlePaintBegin: OnPaintBegin (a_Player); return;
+ case caLeftPaintProgress: OnPaintProgress (a_Player, a_SlotNum); return;
+ case caRightPaintProgress: OnPaintProgress (a_Player, a_SlotNum); return;
+ case caMiddlePaintProgress: OnPaintProgress (a_Player, a_SlotNum); return;
+ case caLeftPaintEnd: OnLeftPaintEnd (a_Player); return;
+ case caRightPaintEnd: OnRightPaintEnd (a_Player); return;
+ case caMiddlePaintEnd: OnMiddlePaintEnd(a_Player); return;
default:
{
break;
@@ -643,9 +646,33 @@ void cWindow::OnRightPaintEnd(cPlayer & a_Player)
-int cWindow::DistributeItemToSlots(cPlayer & a_Player, const cItem & a_Item, int a_NumToEachSlot, const cSlotNums & a_SlotNums)
+void cWindow::OnMiddlePaintEnd(cPlayer & a_Player)
{
- if (static_cast<size_t>(a_Item.m_ItemCount) < a_SlotNums.size())
+ if (!a_Player.IsGameModeCreative())
+ {
+ // Midle click paint is only valid for creative mode
+ return;
+ }
+
+ // Fill available slots with full stacks of the dragging item
+ const auto & DraggingItem = a_Player.GetDraggingItem();
+ auto StackSize = ItemHandler(DraggingItem.m_ItemType)->GetMaxStackSize();
+ if (0 < DistributeItemToSlots(a_Player, DraggingItem, StackSize, a_Player.GetInventoryPaintSlots(), false))
+ {
+ // If any items were distibuted, set dragging item empty
+ a_Player.GetDraggingItem().Empty();
+ }
+
+ SendWholeWindow(*a_Player.GetClientHandle());
+}
+
+
+
+
+
+int cWindow::DistributeItemToSlots(cPlayer & a_Player, const cItem & a_Item, int a_NumToEachSlot, const cSlotNums & a_SlotNums, bool a_LimitItems)
+{
+ if (a_LimitItems && (static_cast<size_t>(a_Item.m_ItemCount) < a_SlotNums.size()))
{
LOGWARNING("%s: Distributing less items (%d) than slots (" SIZE_T_FMT ")", __FUNCTION__, static_cast<int>(a_Item.m_ItemCount), a_SlotNums.size());
// This doesn't seem to happen with the 1.5.1 client, so we don't worry about it for now
diff --git a/src/UI/Window.h b/src/UI/Window.h
index e1b91ccc7..5bb90a75e 100644
--- a/src/UI/Window.h
+++ b/src/UI/Window.h
@@ -218,8 +218,12 @@ protected:
/** Processes the entire action stored in the internal structures for inventory painting; distributes one item into each slot */
void OnRightPaintEnd(cPlayer & a_Player);
- /** Distributes a_NumToEachSlot items into the slots specified in a_SlotNums; returns the total number of items distributed */
- int DistributeItemToSlots(cPlayer & a_Player, const cItem & a_Item, int a_NumToEachSlot, const cSlotNums & a_SlotNums);
+ /** Processes the entire action stored in the internal structures for inventory painting; distributes a full stack into each slot */
+ void OnMiddlePaintEnd(cPlayer & a_Player);
+
+ /** Distributes a_NumToEachSlot items into the slots specified in a_SlotNums; returns the total number of items distributed.
+ @param a_LimitItems if false, no checks are performed on a_Item.m_ItemCount. */
+ int DistributeItemToSlots(cPlayer & a_Player, const cItem & a_Item, int a_NumToEachSlot, const cSlotNums & a_SlotNums, bool a_LimitItems = true);
} ; // tolua_export