Cuberite
A lightweight, fast and extensible game server for Minecraft
DropSpenserWindow.cpp
Go to the documentation of this file.
1 
2 // DropSpenserWindow.cpp
3 
4 // Representing the UI window for the dropper / dispenser block
5 
6 #include "Globals.h"
7 #include "DropSpenserWindow.h"
8 #include "SlotArea.h"
9 
10 
11 
12 
13 
15  Super(wtDropSpenser, (a_DropSpenser->GetBlockType() == E_BLOCK_DISPENSER) ? "Dispenser" : "Dropper")
16 {
17  m_SlotAreas.push_back(new cSlotAreaItemGrid(a_DropSpenser->GetContents(), *this));
18  m_SlotAreas.push_back(new cSlotAreaInventory(*this));
19  m_SlotAreas.push_back(new cSlotAreaHotBar(*this));
20 }
21 
22 
23 
24 
25 
26 void cDropSpenserWindow::DistributeStack(cItem & a_ItemStack, int a_Slot, cPlayer & a_Player, cSlotArea * a_ClickedArea, bool a_ShouldApply)
27 {
28  cSlotAreas AreasInOrder;
29 
30  if (a_ClickedArea == m_SlotAreas[0])
31  {
32  // DropSpenser Area
33  AreasInOrder.push_back(m_SlotAreas[2]); /* Hotbar */
34  AreasInOrder.push_back(m_SlotAreas[1]); /* Inventory */
35  Super::DistributeStackToAreas(a_ItemStack, a_Player, AreasInOrder, a_ShouldApply, true);
36  }
37  else
38  {
39  // Inventory or Hotbar
40  AreasInOrder.push_back(m_SlotAreas[0]); /* DropSpenser */
41  Super::DistributeStackToAreas(a_ItemStack, a_Player, AreasInOrder, a_ShouldApply, false);
42  }
43 }
44 
45 
46 
47 
@ E_BLOCK_DISPENSER
Definition: BlockType.h:33
std::vector< cSlotArea * > cSlotAreas
Definition: Window.h:34
cItemGrid & GetContents(void)
Returns the ItemGrid used for storing the contents.
Definition: Player.h:29
Definition: Item.h:37
virtual void DistributeStack(cItem &a_ItemStack, int a_Slot, cPlayer &a_Player, cSlotArea *a_ClickedArea, bool a_ShouldApply) override
Called on shift-clicking to distribute the stack into other areas; Modifies a_ItemStack as it is dist...
cDropSpenserWindow(cDropSpenserEntity *a_DropSpenser)
Handles the main inventory of each player, excluding the armor and hotbar.
Definition: SlotArea.h:120
Handles the hotbar of each player.
Definition: SlotArea.h:138
Handles any slot area that is representing a cItemGrid; same items for all the players.
Definition: SlotArea.h:200
Represents a UI window.
Definition: Window.h:54
void DistributeStackToAreas(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...
Definition: Window.cpp:467
cSlotAreas m_SlotAreas
Definition: Window.h:179