summaryrefslogtreecommitdiffstats
path: root/src/UI
diff options
context:
space:
mode:
Diffstat (limited to 'src/UI')
-rw-r--r--src/UI/AnvilWindow.h2
-rw-r--r--src/UI/BeaconWindow.h4
-rw-r--r--src/UI/ChestWindow.h4
-rw-r--r--src/UI/CraftingWindow.h6
-rw-r--r--src/UI/DropSpenserWindow.h4
-rw-r--r--src/UI/EnchantingWindow.h4
-rw-r--r--src/UI/EnderChestWindow.h4
-rw-r--r--src/UI/FurnaceWindow.h6
-rw-r--r--src/UI/HopperWindow.h4
-rw-r--r--src/UI/InventoryWindow.h8
-rw-r--r--src/UI/MinecartWithChestWindow.h20
-rw-r--r--src/UI/Window.cpp24
-rw-r--r--src/UI/Window.h9
13 files changed, 51 insertions, 48 deletions
diff --git a/src/UI/AnvilWindow.h b/src/UI/AnvilWindow.h
index fd5c77871..e1a91bfc6 100644
--- a/src/UI/AnvilWindow.h
+++ b/src/UI/AnvilWindow.h
@@ -70,7 +70,7 @@ public:
// Inventory or Hotbar
AreasInOrder.push_back(m_SlotAreas[0]); /* Anvil */
}
- super::DistributeStack(a_ItemStack, a_Player, AreasInOrder, a_ShouldApply, false);
+ super::DistributeStackToAreas(a_ItemStack, a_Player, AreasInOrder, a_ShouldApply, false);
}
protected:
diff --git a/src/UI/BeaconWindow.h b/src/UI/BeaconWindow.h
index a2ec50f02..c4d337afd 100644
--- a/src/UI/BeaconWindow.h
+++ b/src/UI/BeaconWindow.h
@@ -44,7 +44,7 @@ public:
// Beacon Area
AreasInOrder.push_back(m_SlotAreas[2]); /* Hotbar */
AreasInOrder.push_back(m_SlotAreas[1]); /* Inventory */
- super::DistributeStack(a_ItemStack, a_Player, AreasInOrder, a_ShouldApply, true);
+ super::DistributeStackToAreas(a_ItemStack, a_Player, AreasInOrder, a_ShouldApply, true);
}
else
{
@@ -63,7 +63,7 @@ public:
// Hotbar Area
AreasInOrder.push_back(m_SlotAreas[1]); /* Inventory */
}
- super::DistributeStack(a_ItemStack, a_Player, AreasInOrder, a_ShouldApply, false);
+ super::DistributeStackToAreas(a_ItemStack, a_Player, AreasInOrder, a_ShouldApply, false);
}
}
diff --git a/src/UI/ChestWindow.h b/src/UI/ChestWindow.h
index 852ec28ef..a34edff70 100644
--- a/src/UI/ChestWindow.h
+++ b/src/UI/ChestWindow.h
@@ -117,13 +117,13 @@ public:
// Chest Area
AreasInOrder.push_back(m_SlotAreas[2]); /* Hotbar */
AreasInOrder.push_back(m_SlotAreas[1]); /* Inventory */
- super::DistributeStack(a_ItemStack, a_Player, AreasInOrder, a_ShouldApply, true);
+ super::DistributeStackToAreas(a_ItemStack, a_Player, AreasInOrder, a_ShouldApply, true);
}
else
{
// Hotbar or Inventory
AreasInOrder.push_back(m_SlotAreas[0]); /* Chest */
- super::DistributeStack(a_ItemStack, a_Player, AreasInOrder, a_ShouldApply, false);
+ super::DistributeStackToAreas(a_ItemStack, a_Player, AreasInOrder, a_ShouldApply, false);
}
}
diff --git a/src/UI/CraftingWindow.h b/src/UI/CraftingWindow.h
index f5a0328f2..e6292175e 100644
--- a/src/UI/CraftingWindow.h
+++ b/src/UI/CraftingWindow.h
@@ -48,19 +48,19 @@ public:
AreasInOrder.push_back(m_SlotAreas[1]); /* Inventory */
AreasInOrder.push_back(m_SlotAreas[2]); /* Hotbar */
}
- super::DistributeStack(a_ItemStack, a_Player, AreasInOrder, a_ShouldApply, (a_Slot == 0));
+ super::DistributeStackToAreas(a_ItemStack, a_Player, AreasInOrder, a_ShouldApply, (a_Slot == 0));
}
else if (a_ClickedArea == m_SlotAreas[1])
{
// Inventory Area
AreasInOrder.push_back(m_SlotAreas[2]); /* Hotbar */
- super::DistributeStack(a_ItemStack, a_Player, AreasInOrder, a_ShouldApply, false);
+ super::DistributeStackToAreas(a_ItemStack, a_Player, AreasInOrder, a_ShouldApply, false);
}
else
{
// Hotbar
AreasInOrder.push_back(m_SlotAreas[1]); /* Inventory */
- super::DistributeStack(a_ItemStack, a_Player, AreasInOrder, a_ShouldApply, false);
+ super::DistributeStackToAreas(a_ItemStack, a_Player, AreasInOrder, a_ShouldApply, false);
}
}
};
diff --git a/src/UI/DropSpenserWindow.h b/src/UI/DropSpenserWindow.h
index ef8e2d0cd..8f5d5236c 100644
--- a/src/UI/DropSpenserWindow.h
+++ b/src/UI/DropSpenserWindow.h
@@ -40,13 +40,13 @@ public:
// DropSpenser Area
AreasInOrder.push_back(m_SlotAreas[2]); /* Hotbar */
AreasInOrder.push_back(m_SlotAreas[1]); /* Inventory */
- super::DistributeStack(a_ItemStack, a_Player, AreasInOrder, a_ShouldApply, true);
+ super::DistributeStackToAreas(a_ItemStack, a_Player, AreasInOrder, a_ShouldApply, true);
}
else
{
// Inventory or Hotbar
AreasInOrder.push_back(m_SlotAreas[0]); /* DropSpenser */
- super::DistributeStack(a_ItemStack, a_Player, AreasInOrder, a_ShouldApply, false);
+ super::DistributeStackToAreas(a_ItemStack, a_Player, AreasInOrder, a_ShouldApply, false);
}
}
};
diff --git a/src/UI/EnchantingWindow.h b/src/UI/EnchantingWindow.h
index a6386ffe2..620d8fcef 100644
--- a/src/UI/EnchantingWindow.h
+++ b/src/UI/EnchantingWindow.h
@@ -79,13 +79,13 @@ public:
// Enchanting Area
AreasInOrder.push_back(m_SlotAreas[2]); /* Hotbar */
AreasInOrder.push_back(m_SlotAreas[1]); /* Inventory */
- super::DistributeStack(a_ItemStack, a_Player, AreasInOrder, a_ShouldApply, true);
+ super::DistributeStackToAreas(a_ItemStack, a_Player, AreasInOrder, a_ShouldApply, true);
}
else
{
// Inventory or Hotbar
AreasInOrder.push_back(m_SlotAreas[0]); /* Enchanting */
- super::DistributeStack(a_ItemStack, a_Player, AreasInOrder, a_ShouldApply, false);
+ super::DistributeStackToAreas(a_ItemStack, a_Player, AreasInOrder, a_ShouldApply, false);
}
}
diff --git a/src/UI/EnderChestWindow.h b/src/UI/EnderChestWindow.h
index 4c7dd2495..d63689f54 100644
--- a/src/UI/EnderChestWindow.h
+++ b/src/UI/EnderChestWindow.h
@@ -58,13 +58,13 @@ public:
// Chest Area
AreasInOrder.push_back(m_SlotAreas[2]); /* Hotbar */
AreasInOrder.push_back(m_SlotAreas[1]); /* Inventory */
- super::DistributeStack(a_ItemStack, a_Player, AreasInOrder, a_ShouldApply, true);
+ super::DistributeStackToAreas(a_ItemStack, a_Player, AreasInOrder, a_ShouldApply, true);
}
else
{
// Hotbar or Inventory
AreasInOrder.push_back(m_SlotAreas[0]); /* Chest */
- super::DistributeStack(a_ItemStack, a_Player, AreasInOrder, a_ShouldApply, false);
+ super::DistributeStackToAreas(a_ItemStack, a_Player, AreasInOrder, a_ShouldApply, false);
}
}
diff --git a/src/UI/FurnaceWindow.h b/src/UI/FurnaceWindow.h
index fb0a50656..532f99928 100644
--- a/src/UI/FurnaceWindow.h
+++ b/src/UI/FurnaceWindow.h
@@ -43,14 +43,14 @@ public:
// Result Slot
AreasInOrder.push_back(m_SlotAreas[2]); /* Hotbar */
AreasInOrder.push_back(m_SlotAreas[1]); /* Inventory */
- super::DistributeStack(a_ItemStack, a_Player, AreasInOrder, a_ShouldApply, true);
+ super::DistributeStackToAreas(a_ItemStack, a_Player, AreasInOrder, a_ShouldApply, true);
}
else
{
// Furnace Input/Fuel Slot
AreasInOrder.push_back(m_SlotAreas[1]); /* Inventory */
AreasInOrder.push_back(m_SlotAreas[2]); /* Hotbar */
- super::DistributeStack(a_ItemStack, a_Player, AreasInOrder, a_ShouldApply, false);
+ super::DistributeStackToAreas(a_ItemStack, a_Player, AreasInOrder, a_ShouldApply, false);
}
}
else
@@ -71,7 +71,7 @@ public:
// Hotbar Area
AreasInOrder.push_back(m_SlotAreas[1]); /* Inventory */
}
- super::DistributeStack(a_ItemStack, a_Player, AreasInOrder, a_ShouldApply, false);
+ super::DistributeStackToAreas(a_ItemStack, a_Player, AreasInOrder, a_ShouldApply, false);
}
}
};
diff --git a/src/UI/HopperWindow.h b/src/UI/HopperWindow.h
index 4aa03c605..08e2a2644 100644
--- a/src/UI/HopperWindow.h
+++ b/src/UI/HopperWindow.h
@@ -40,13 +40,13 @@ public:
// Hopper Area
AreasInOrder.push_back(m_SlotAreas[2]); /* Hotbar */
AreasInOrder.push_back(m_SlotAreas[1]); /* Inventory */
- super::DistributeStack(a_ItemStack, a_Player, AreasInOrder, a_ShouldApply, true);
+ super::DistributeStackToAreas(a_ItemStack, a_Player, AreasInOrder, a_ShouldApply, true);
}
else
{
// Inventory or Hotbar
AreasInOrder.push_back(m_SlotAreas[0]); /* Hopper */
- super::DistributeStack(a_ItemStack, a_Player, AreasInOrder, a_ShouldApply, false);
+ super::DistributeStackToAreas(a_ItemStack, a_Player, AreasInOrder, a_ShouldApply, false);
}
}
};
diff --git a/src/UI/InventoryWindow.h b/src/UI/InventoryWindow.h
index a6ea7c793..31b85b1bc 100644
--- a/src/UI/InventoryWindow.h
+++ b/src/UI/InventoryWindow.h
@@ -50,28 +50,28 @@ public:
AreasInOrder.push_back(m_SlotAreas[2]); /* Inventory */
AreasInOrder.push_back(m_SlotAreas[3]); /* Hotbar */
}
- super::DistributeStack(a_ItemStack, a_Player, AreasInOrder, a_ShouldApply, (a_Slot == 0));
+ super::DistributeStackToAreas(a_ItemStack, a_Player, AreasInOrder, a_ShouldApply, (a_Slot == 0));
}
else if (a_ClickedArea == m_SlotAreas[1])
{
// Armor Area
AreasInOrder.push_back(m_SlotAreas[2]); /* Inventory */
AreasInOrder.push_back(m_SlotAreas[3]); /* Hotbar */
- super::DistributeStack(a_ItemStack, a_Player, AreasInOrder, a_ShouldApply, false);
+ super::DistributeStackToAreas(a_ItemStack, a_Player, AreasInOrder, a_ShouldApply, false);
}
else if (a_ClickedArea == m_SlotAreas[2])
{
// Inventory Area
AreasInOrder.push_back(m_SlotAreas[1]); /* Armor */
AreasInOrder.push_back(m_SlotAreas[3]); /* Hotbar */
- super::DistributeStack(a_ItemStack, a_Player, AreasInOrder, a_ShouldApply, false);
+ super::DistributeStackToAreas(a_ItemStack, a_Player, AreasInOrder, a_ShouldApply, false);
}
else
{
// Hotbar
AreasInOrder.push_back(m_SlotAreas[1]); /* Armor */
AreasInOrder.push_back(m_SlotAreas[2]); /* Inventory */
- super::DistributeStack(a_ItemStack, a_Player, AreasInOrder, a_ShouldApply, false);
+ super::DistributeStackToAreas(a_ItemStack, a_Player, AreasInOrder, a_ShouldApply, false);
}
}
diff --git a/src/UI/MinecartWithChestWindow.h b/src/UI/MinecartWithChestWindow.h
index 57e9beedf..a2b5283a6 100644
--- a/src/UI/MinecartWithChestWindow.h
+++ b/src/UI/MinecartWithChestWindow.h
@@ -33,6 +33,26 @@ public:
a_ChestCart->GetWorld()->BroadcastSoundEffect("random.chestopen", a_ChestCart->GetPosX(), a_ChestCart->GetPosY(), a_ChestCart->GetPosZ(), 1, 1);
}
+ virtual void DistributeStack(cItem & a_ItemStack, int a_Slot, cPlayer & a_Player, cSlotArea* a_ClickedArea, bool a_ShouldApply) override
+ {
+ cSlotAreas AreasInOrder;
+
+ if (a_ClickedArea == m_SlotAreas[0])
+ {
+ // Chest Area
+ AreasInOrder.push_back(m_SlotAreas[2]); /* Hotbar */
+ AreasInOrder.push_back(m_SlotAreas[1]); /* Inventory */
+ super::DistributeStackToAreas(a_ItemStack, a_Player, AreasInOrder, a_ShouldApply, true);
+ }
+ else
+ {
+ // Hotbar or Inventory
+ AreasInOrder.push_back(m_SlotAreas[0]); /* Chest */
+ super::DistributeStackToAreas(a_ItemStack, a_Player, AreasInOrder, a_ShouldApply, false);
+ }
+ }
+
+
~cMinecartWithChestWindow()
{
m_ChestCart->GetWorld()->BroadcastSoundEffect("random.chestclosed", m_ChestCart->GetPosX(), m_ChestCart->GetPosY(), m_ChestCart->GetPosZ(), 1, 1);
diff --git a/src/UI/Window.cpp b/src/UI/Window.cpp
index 0cb501a65..8bb7607ff 100644
--- a/src/UI/Window.cpp
+++ b/src/UI/Window.cpp
@@ -391,31 +391,13 @@ bool cWindow::ForEachClient(cItemCallback<cClientHandle> & a_Callback)
-void cWindow::DistributeStack(cItem & a_ItemStack, int a_Slot, cPlayer & a_Player, cSlotArea * a_ClickedArea, bool a_ShouldApply)
-{
- cSlotAreas Areas;
- for (auto Area : m_SlotAreas)
- {
- if (Area != a_ClickedArea)
- {
- Areas.push_back(Area);
- }
- }
-
- DistributeStack(a_ItemStack, a_Player, Areas, a_ShouldApply, false);
-}
-
-
-
-
-
-void cWindow::DistributeStack(cItem & a_ItemStack, cPlayer & a_Player, cSlotAreas & a_AreasInOrder, bool a_ShouldApply, bool a_BackFill)
+void cWindow::DistributeStackToAreas(cItem & a_ItemStack, cPlayer & a_Player, cSlotAreas & a_AreasInOrder, bool a_ShouldApply, bool a_BackFill)
{
for (size_t i = 0; i < 2; i++)
{
- for (cSlotAreas::iterator itr = a_AreasInOrder.begin(); itr != a_AreasInOrder.end(); ++itr)
+ for (auto SlotArea : a_AreasInOrder)
{
- (*itr)->DistributeStack(a_ItemStack, a_Player, a_ShouldApply, (i == 0), a_BackFill);
+ SlotArea->DistributeStack(a_ItemStack, a_Player, a_ShouldApply, (i == 0), a_BackFill);
if (a_ItemStack.IsEmpty())
{
// Distributed it all
diff --git a/src/UI/Window.h b/src/UI/Window.h
index 9d9a5d7e8..811cac812 100644
--- a/src/UI/Window.h
+++ b/src/UI/Window.h
@@ -153,11 +153,12 @@ public:
/** Called on shift-clicking to distribute the stack into other areas; Modifies a_ItemStack as it is distributed!
if a_ShouldApply is true, the changes are written into the slots;
- if a_ShouldApply is false, only a_ItemStack is modified to reflect the number of fits (for fit-testing purposes)
- */
- virtual void DistributeStack(cItem & a_ItemStack, int a_Slot, cPlayer & a_Player, cSlotArea * a_ClickedArea, bool a_ShouldApply);
+ if a_ShouldApply is false, only a_ItemStack is modified to reflect the number of fits (for fit-testing purposes) */
+ virtual void DistributeStack(cItem & a_ItemStack, int a_Slot, cPlayer & a_Player, cSlotArea * a_ClickedArea, bool a_ShouldApply) = 0;
- void DistributeStack(cItem & a_ItemStack, cPlayer & a_Player, cSlotAreas & a_AreasInOrder, bool a_ShouldApply, bool a_BackFill);
+ /** Called from DistributeStack() to distribute the stack into a_AreasInOrder; Modifies a_ItemStack as it is distributed!
+ If a_BackFill is true, the areas will be filled from the back (right side). (Example: Empty Hotbar -> Item get in slot 8, not slot 0) */
+ void DistributeStackToAreas(cItem & a_ItemStack, cPlayer & a_Player, cSlotAreas & a_AreasInOrder, bool a_ShouldApply, bool a_BackFill);
/** Called on DblClicking to collect all stackable items from all areas into hand, starting with the specified area.
The items are accumulated in a_Dragging and removed from the SlotAreas immediately.