summaryrefslogtreecommitdiffstats
path: root/source
diff options
context:
space:
mode:
Diffstat (limited to 'source')
-rw-r--r--source/cCraftingWindow.cpp79
-rw-r--r--source/cCraftingWindow.h33
2 files changed, 107 insertions, 5 deletions
diff --git a/source/cCraftingWindow.cpp b/source/cCraftingWindow.cpp
index 03102123b..a41eede70 100644
--- a/source/cCraftingWindow.cpp
+++ b/source/cCraftingWindow.cpp
@@ -32,8 +32,19 @@ cCraftingWindow::cCraftingWindow( cWindowOwner* a_Owner, bool a_bInventoryVisibl
void cCraftingWindow::Clicked( cPacket_WindowClick* a_ClickPacket, cPlayer & a_Player )
{
bool bDontCook = false;
+
+ cItem * DraggingItem = GetDraggingItem(&a_Player);
+ if (
+ a_ClickPacket->m_IsShiftPressed &&
+ ((DraggingItem == NULL) || DraggingItem->IsEmpty())
+ )
+ {
+ ShiftClicked(a_ClickPacket, a_Player);
+ return;
+ }
+
// Override for craft result slot
- if( a_ClickPacket->m_SlotNum == 0 )
+ if (a_ClickPacket->m_SlotNum == 0)
{
LOG("In craft slot: %i x %i !!", GetSlot(0)->m_ItemID, GetSlot(0)->m_ItemCount );
cItem* DraggingItem = GetDraggingItem( &a_Player );
@@ -126,3 +137,69 @@ void cCraftingWindow::Close(cPlayer & a_Player)
+
+void cCraftingWindow::ShiftClicked(cPacket_WindowClick * a_ClickPacket, cPlayer & a_Player)
+{
+ short Slot = a_ClickPacket->m_SlotNum;
+ if (Slot == SLOT_CRAFTING_RESULT)
+ {
+ ShiftClickedCraftingResult(Slot, a_Player);
+ }
+ else if ((Slot >= SLOT_CRAFTING_MIN) && (Slot <= SLOT_CRAFTING_MAX))
+ {
+ ShiftClickedCraftingGrid(Slot, a_Player);
+ }
+ else
+ {
+ // No need to handle inventory shift-click, it is handled by the underlying cSurvivalInventory, surprise surprise ;)
+ }
+ SendWholeWindow(a_Player.GetClientHandle());
+}
+
+
+
+
+
+void cCraftingWindow::ShiftClickedCraftingResult(short a_Slot, cPlayer & a_Player)
+{
+ // TODO
+}
+
+
+
+
+
+void cCraftingWindow::ShiftClickedCraftingGrid(short a_Slot, cPlayer & a_Player)
+{
+ enum
+ {
+ SLOT_INVENTORY_MIN = 9,
+ SLOT_INVENTORY_MAX = 35,
+ SLOT_HOTBAR_MIN = 36,
+ SLOT_HOTBAR_MAX = 44
+ } ;
+
+ cInventory & Inventory = a_Player.GetInventory();
+ cItem * Item = GetSlot(a_Slot);
+ if ((Item == NULL) || Item->IsEmpty())
+ {
+ return;
+ }
+
+ // First try the main inventory:
+ Item->m_ItemCount -= Inventory.MoveItem(Item->m_ItemID, Item->m_ItemHealth, Item->m_ItemCount, SLOT_INVENTORY_MIN, SLOT_INVENTORY_MAX);
+
+ // If anything left, try the hotbar:
+ if (Item->m_ItemCount > 0)
+ {
+ Item->m_ItemCount -= Inventory.MoveItem(Item->m_ItemID, Item->m_ItemHealth, Item->m_ItemCount, SLOT_HOTBAR_MIN, SLOT_HOTBAR_MAX);
+ }
+ if (Item->m_ItemCount == 0)
+ {
+ Item->Empty();
+ }
+}
+
+
+
+
diff --git a/source/cCraftingWindow.h b/source/cCraftingWindow.h
index 16fe3bb23..70a731a65 100644
--- a/source/cCraftingWindow.h
+++ b/source/cCraftingWindow.h
@@ -1,13 +1,38 @@
+
#pragma once
#include "cWindow.h"
+
+
+
+// fwd:
class cWindowOwner;
+
+
+
+
+
class cCraftingWindow : public cWindow
{
public:
- cCraftingWindow( cWindowOwner* a_Owner, bool a_bInventoryVisible );
+ enum
+ {
+ SLOT_CRAFTING_RESULT = 0,
+ SLOT_CRAFTING_MIN = 1,
+ SLOT_CRAFTING_MAX = 9,
+ } ;
+
+ cCraftingWindow(cWindowOwner * a_Owner, bool a_bInventoryVisible);
+
+ virtual void Clicked(cPacket_WindowClick * a_ClickPacket, cPlayer & a_Player);
+ virtual void Close(cPlayer & a_Player);
+
+ void ShiftClicked(cPacket_WindowClick * a_ClickPacket, cPlayer & a_Player);
+ void ShiftClickedCraftingResult(short a_Slot, cPlayer & a_Player);
+ void ShiftClickedCraftingGrid (short a_Slot, cPlayer & a_Player);
+};
+
+
+
- virtual void Clicked( cPacket_WindowClick* a_ClickPacket, cPlayer & a_Player );
- virtual void Close( cPlayer & a_Player );
-}; \ No newline at end of file