Cuberite
A lightweight, fast and extensible game server for Minecraft
SlotArea.h
Go to the documentation of this file.
1 
2 // SlotArea.h
3 
4 // Interfaces to the cSlotArea class representing a contiguous area of slots in a UI window
5 
6 
7 
8 
9 #pragma once
10 
11 #include "../Inventory.h"
12 
13 
14 
15 
16 
17 class cHorse;
18 class cWindow;
19 class cPlayer;
20 class cBeaconEntity;
22 class cChestEntity;
23 class cEnderChestEntity;
24 class cFurnaceEntity;
25 class cMinecartWithChest;
26 class cCraftingRecipe;
27 class cWorld;
28 
29 
30 
31 
32 
33 class cSlotArea
34 {
35 public:
36  cSlotArea(int a_NumSlots, cWindow & a_ParentWindow);
37  virtual ~cSlotArea() {} // force a virtual destructor in all subclasses
38 
39  int GetNumSlots(void) const { return m_NumSlots; }
40 
42  virtual const cItem * GetSlot(int a_SlotNum, cPlayer & a_Player) const = 0;
43 
45  virtual void SetSlot(int a_SlotNum, cPlayer & a_Player, const cItem & a_Item) = 0;
46 
48  virtual void Clicked(cPlayer & a_Player, int a_SlotNum, eClickAction a_ClickAction, const cItem & a_ClickedItem);
49 
51  virtual void ShiftClicked(cPlayer & a_Player, int a_SlotNum, const cItem & a_ClickedItem);
52 
54  virtual void DblClicked(cPlayer & a_Player, int a_SlotNum);
55 
57  virtual void MiddleClicked(cPlayer & a_Player, int a_SlotNum);
58 
60  virtual void DropClicked(cPlayer & a_Player, int a_SlotNum, bool a_DropStack);
61 
63  virtual void NumberClicked(cPlayer & a_Player, int a_SlotNum, eClickAction a_ClickAction);
64 
66  virtual void OnPlayerAdded(cPlayer & a_Player);
67 
69  virtual void OnPlayerRemoved(cPlayer & a_Player);
70 
76  virtual void DistributeStack(cItem & a_ItemStack, cPlayer & a_Player, bool a_ShouldApply, bool a_KeepEmptySlots, bool a_BackFill);
77 
82  virtual bool CollectItemsToHand(cItem & a_Dragging, cPlayer & a_Player, bool a_CollectFullStacks);
83 
84 protected:
87 } ;
88 
89 
90 
91 
92 
95  public cSlotArea
96 {
97  using Super = cSlotArea;
98 
99 public:
100 
101  cSlotAreaInventoryBase(int a_NumSlots, int a_SlotOffset, cWindow & a_ParentWindow);
102 
103  // Creative inventory's click handling is somewhat different from survival inventory's, handle that here:
104  virtual void Clicked(cPlayer & a_Player, int a_SlotNum, eClickAction a_ClickAction, const cItem & a_ClickedItem) override;
105 
106  virtual const cItem * GetSlot(int a_SlotNum, cPlayer & a_Player) const override;
107  virtual void SetSlot(int a_SlotNum, cPlayer & a_Player, const cItem & a_Item) override;
108 
109 protected:
110  int m_SlotOffset; // Index that this area's slot 0 has in the underlying cInventory
111 } ;
112 
113 
114 
115 
116 
120 {
122 
123 public:
124 
125  cSlotAreaInventory(cWindow & a_ParentWindow):
126  Super(cInventory::invInventoryCount, cInventory::invInventoryOffset, a_ParentWindow)
127  {
128  }
129 } ;
130 
131 
132 
133 
134 
138 {
140 
141 public:
142  cSlotAreaHotBar(cWindow & a_ParentWindow):
143  Super(cInventory::invHotbarCount, cInventory::invHotbarOffset, a_ParentWindow)
144  {
145  }
146 } ;
147 
148 
149 
150 
151 
155 {
157 
158 public:
159 
160  cSlotAreaShield(cWindow & a_ParentWindow):
161  Super(cInventory::invShieldCount, cInventory::invShieldOffset, a_ParentWindow)
162  {
163  }
164 };
165 
166 
167 
168 
169 
173 {
175 
176 public:
177 
178  cSlotAreaArmor(cWindow & a_ParentWindow):
179  Super(cInventory::invArmorCount, cInventory::invArmorOffset, a_ParentWindow)
180  {
181  }
182 
184  virtual void DistributeStack(cItem & a_ItemStack, cPlayer & a_Player, bool a_ShouldApply, bool a_KeepEmptySlots, bool a_BackFill) override;
185 
187  virtual void Clicked(cPlayer & a_Player, int a_SlotNum, eClickAction a_ClickAction, const cItem & a_ClickedItem) override;
188 
189  static bool CanPlaceArmorInSlot(int a_SlotNum, const cItem & a_Item);
190 } ;
191 
192 
193 
194 
195 
198  public cSlotArea,
199  public cItemGrid::cListener
200 {
201  using Super = cSlotArea;
202 
203 public:
204 
205  cSlotAreaItemGrid(cItemGrid & a_ItemGrid, cWindow & a_ParentWindow);
206 
207  virtual ~cSlotAreaItemGrid() override;
208 
209  virtual const cItem * GetSlot(int a_SlotNum, cPlayer & a_Player) const override;
210  virtual void SetSlot(int a_SlotNum, cPlayer & a_Player, const cItem & a_Item) override;
211 
212 protected:
214 
215  // cItemGrid::cListener overrides:
216  virtual void OnSlotChanged(cItemGrid * a_ItemGrid, int a_SlotNum) override;
217 } ;
218 
219 
220 
221 
222 
227  public cSlotArea
228 {
229  using Super = cSlotArea;
230 
231 public:
232 
233  cSlotAreaTemporary(int a_NumSlots, cWindow & a_ParentWindow);
234 
235  // cSlotArea overrides:
236  virtual const cItem * GetSlot (int a_SlotNum, cPlayer & a_Player) const override;
237  virtual void SetSlot (int a_SlotNum, cPlayer & a_Player, const cItem & a_Item) override;
238  virtual void OnPlayerAdded (cPlayer & a_Player) override;
239  virtual void OnPlayerRemoved(cPlayer & a_Player) override;
240 
242  void TossItems(cPlayer & a_Player, int a_Begin, int a_End);
243 
244 protected:
245  using cItemMap = std::map<UInt32, std::vector<cItem> >; // Maps EntityID -> items
246 
248 
250  cItem * GetPlayerSlots(cPlayer & a_Player);
251 } ;
252 
253 
254 
255 
256 
258  public cSlotAreaTemporary
259 {
261 
262 public:
263 
265  cSlotAreaCrafting(int a_GridSize, cWindow & a_ParentWindow);
266 
267  // cSlotAreaTemporary overrides:
268  virtual void Clicked (cPlayer & a_Player, int a_SlotNum, eClickAction a_ClickAction, const cItem & a_ClickedItem) override;
269  virtual void DblClicked (cPlayer & a_Player, int a_SlotNum) override;
270  virtual void OnPlayerRemoved(cPlayer & a_Player) override;
271  virtual void SetSlot (int a_SlotNum, cPlayer & a_Player, const cItem & a_Item) override;
272 
273  // Distributing items into this area is completely disabled
274  virtual void DistributeStack(cItem & a_ItemStack, cPlayer & a_Player, bool a_ShouldApply, bool a_KeepEmptySlots, bool a_BackFill) override;
275 
277  void ClearCraftingGrid(cPlayer & a_Player);
278 
280  void LoadRecipe(cPlayer & a_Player, UInt32 a_RecipeId);
281 
282 protected:
285  typedef std::list<std::pair<UInt32, cCraftingRecipe> > cRecipeMap;
286 
289 
292  void ClickedResult(cPlayer & a_Player);
293 
296  void ShiftClickedResult(cPlayer & a_Player);
297 
299  void DropClickedResult(cPlayer & a_Player);
300 
302  void UpdateRecipe(cPlayer & a_Player);
303 
306 
308  void HandleCraftItem(const cItem & a_Result, cPlayer & a_Player);
309 } ;
310 
311 
312 
313 
314 
316  public cSlotAreaTemporary
317 {
319 
320 public:
321 
322  cSlotAreaAnvil(cWindow & a_ParentWindow);
323 
324  // cSlotArea overrides:
325  virtual void Clicked(cPlayer & a_Player, int a_SlotNum, eClickAction a_ClickAction, const cItem & a_ClickedItem) override;
326  virtual void ShiftClicked(cPlayer & a_Player, int a_SlotNum, const cItem & a_ClickedItem) override;
327  virtual void DistributeStack(cItem & a_ItemStack, cPlayer & a_Player, bool a_ShouldApply, bool a_KeepEmptySlots, bool a_BackFill) override;
328 
329  // cSlotAreaTemporary overrides:
330  virtual void OnPlayerRemoved(cPlayer & a_Player) override;
331 
333  bool CanTakeResultItem(cPlayer & a_Player);
334 
336  void OnTakeResult(cPlayer & a_Player);
337 
339  void UpdateResult(cPlayer & a_Player);
340 
341 protected:
344 
347 } ;
348 
349 
350 
351 
352 
354  public cSlotArea,
355  public cItemGrid::cListener
356 {
357  using Super = cSlotArea;
358 
359 public:
360 
361  cSlotAreaBeacon(cBeaconEntity * a_Beacon, cWindow & a_ParentWindow);
362  virtual ~cSlotAreaBeacon() override;
363 
364  static bool IsPlaceableItem(short a_ItemType);
365 
366  virtual void Clicked(cPlayer & a_Player, int a_SlotNum, eClickAction a_ClickAction, const cItem & a_ClickedItem) override;
367  virtual void DistributeStack(cItem & a_ItemStack, cPlayer & a_Player, bool a_ShouldApply, bool a_KeepEmptySlots, bool a_BackFill) override;
368  virtual const cItem * GetSlot(int a_SlotNum, cPlayer & a_Player) const override;
369  virtual void SetSlot(int a_SlotNum, cPlayer & a_Player, const cItem & a_Item) override;
370 
371 protected:
373 
374  // cItemGrid::cListener overrides:
375  virtual void OnSlotChanged(cItemGrid * a_ItemGrid, int a_SlotNum) override;
376 } ;
377 
378 
379 
380 
381 
382 class cSlotAreaEnchanting final :
383  public cSlotAreaTemporary
384 {
386 
387 public:
388 
389  cSlotAreaEnchanting(cWindow & a_ParentWindow, Vector3i a_BlockPos);
390 
391  // cSlotArea overrides:
392  virtual void Clicked(cPlayer & a_Player, int a_SlotNum, eClickAction a_ClickAction, const cItem & a_ClickedItem) override;
393  virtual void DistributeStack(cItem & a_ItemStack, cPlayer & a_Player, bool a_ShouldApply, bool a_KeepEmptySlots, bool a_BackFill) override;
394  virtual void SetSlot(int a_SlotNum, cPlayer & a_Player, const cItem & a_Item) override;
395 
396  // cSlotAreaTemporary overrides:
397  virtual void OnPlayerAdded (cPlayer & a_Player) override;
398  virtual void OnPlayerRemoved(cPlayer & a_Player) override;
399 
400  /* Get the number of bookshelves which are near the enchanting table */
401  unsigned GetBookshelvesCount(cWorld & a_World);
402 
403  /* Return the enchanted item matching the chosen option (0, 1, 2)
404  Ownership of the cItem is transferred to the caller. */
405  cItem SelectEnchantedOption(size_t a_EnchantOption);
406 
407 protected:
408 
410  void UpdateResult(cPlayer & a_Player);
411 
413  std::array<cItem, 3> m_EnchantedItemOptions;
414 };
415 
416 
417 
418 
419 
421  public cSlotArea
422 {
423 public:
424  cSlotAreaChest(cChestEntity * a_Chest, cWindow & a_ParentWindow);
425 
426  virtual const cItem * GetSlot(int a_SlotNum, cPlayer & a_Player) const override;
427  virtual void SetSlot(int a_SlotNum, cPlayer & a_Player, const cItem & a_Item) override;
428 
429 protected:
431 } ;
432 
433 
434 
435 
436 
438  public cSlotArea
439 {
440 public:
441  cSlotAreaDoubleChest(cChestEntity * a_TopChest, cChestEntity * a_BottomChest, cWindow & a_ParentWindow);
442 
443  virtual const cItem * GetSlot(int a_SlotNum, cPlayer & a_Player) const override;
444  virtual void SetSlot(int a_SlotNum, cPlayer & a_Player, const cItem & a_Item) override;
445 
446 protected:
449 } ;
450 
451 
452 
453 
454 
456  public cSlotArea
457 {
458 public:
459  cSlotAreaEnderChest(cEnderChestEntity * a_EnderChest, cWindow & a_ParentWindow);
460 
461  virtual const cItem * GetSlot(int a_SlotNum, cPlayer & a_Player) const override;
462  virtual void SetSlot(int a_SlotNum, cPlayer & a_Player, const cItem & a_Item) override;
463 
464 protected:
466 };
467 
468 
469 
470 
471 
473  public cSlotArea,
474  public cItemGrid::cListener
475 {
476  using Super = cSlotArea;
477 
478 public:
479 
480  cSlotAreaFurnace(cFurnaceEntity * a_Furnace, cWindow & a_ParentWindow);
481 
482  virtual ~cSlotAreaFurnace() override;
483 
484  virtual void Clicked(cPlayer & a_Player, int a_SlotNum, eClickAction a_ClickAction, const cItem & a_ClickedItem) override;
485  virtual void DistributeStack(cItem & a_ItemStack, cPlayer & a_Player, bool a_ShouldApply, bool a_KeepEmptySlots, bool a_BackFill) override;
486  virtual const cItem * GetSlot(int a_SlotNum, cPlayer & a_Player) const override;
487  virtual void SetSlot(int a_SlotNum, cPlayer & a_Player, const cItem & a_Item) override;
488 
489 protected:
491 
492  // cItemGrid::cListener overrides:
493  virtual void OnSlotChanged(cItemGrid * a_ItemGrid, int a_SlotNum) override;
494 
496  void HandleSmeltItem(const cItem & a_Result, cPlayer & a_Player);
497 } ;
498 
499 
500 
501 
502 
504  public cSlotArea,
505  public cItemGrid::cListener
506 {
507  using Super = cSlotArea;
508 
509 public:
510 
511  cSlotAreaBrewingstand(cBrewingstandEntity * a_Brewingstand, cWindow & a_ParentWindow);
512 
513  virtual ~cSlotAreaBrewingstand() override;
514 
515  virtual void Clicked(cPlayer & a_Player, int a_SlotNum, eClickAction a_ClickAction, const cItem & a_ClickedItem) override;
516  virtual void DistributeStack(cItem & a_ItemStack, cPlayer & a_Player, bool a_ShouldApply, bool a_KeepEmptySlots, bool a_BackFill) override;
517  virtual const cItem * GetSlot(int a_SlotNum, cPlayer & a_Player) const override;
518  virtual void SetSlot(int a_SlotNum, cPlayer & a_Player, const cItem & a_Item) override;
519 protected:
521 
522  // cItemGrid::cListener overrides:
523  virtual void OnSlotChanged(cItemGrid * a_ItemGrid, int a_SlotNum) override;
524 
526  void HandleBrewedItem(cPlayer & a_Player, const cItem & a_ClickedItem);
527 } ;
528 
529 
530 
531 
532 
534  public cSlotArea
535 {
536 public:
537  cSlotAreaMinecartWithChest(cMinecartWithChest * a_ChestCart, cWindow & a_ParentWindow);
538 
539  virtual const cItem * GetSlot(int a_SlotNum, cPlayer & a_Player) const override;
540  virtual void SetSlot(int a_SlotNum, cPlayer & a_Player, const cItem & a_Item) override;
541 
542 protected:
544 };
545 
546 
547 
548 
549 
552  public cSlotArea
553 {
554 public:
555  enum
556  {
559  };
560 
561  cSlotAreaHorse(cHorse & a_Horse, cWindow & a_ParentWindow);
562  virtual void Clicked(cPlayer & a_Player, int a_SlotNum, eClickAction a_ClickAction, const cItem & a_ClickedItem) override;
563  virtual const cItem * GetSlot(int a_SlotNum, cPlayer & a_Player) const override;
564  virtual void SetSlot(int a_SlotNum, cPlayer & a_Player, const cItem & a_Item) override;
565  virtual void DistributeStack(cItem & a_ItemStack, cPlayer & a_Player, bool a_ShouldApply, bool a_KeepEmptySlots, bool a_BackFill) override;
566 private:
568 };
cSlotAreaMinecartWithChest::m_Chest
cMinecartWithChest * m_Chest
Definition: SlotArea.h:543
cSlotAreaBrewingstand::m_Brewingstand
cBrewingstandEntity * m_Brewingstand
Definition: SlotArea.h:520
cSlotAreaHorse::SaddleSlot
@ SaddleSlot
Definition: SlotArea.h:557
cSlotAreaItemGrid::SetSlot
virtual void SetSlot(int a_SlotNum, cPlayer &a_Player, const cItem &a_Item) override
Called to set an item in the specified slot for the specified player.
Definition: SlotArea.cpp:2633
cSlotAreaFurnace::OnSlotChanged
virtual void OnSlotChanged(cItemGrid *a_ItemGrid, int a_SlotNum) override
Called whenever a slot changes.
Definition: SlotArea.cpp:2092
cSlotArea::m_ParentWindow
cWindow & m_ParentWindow
Definition: SlotArea.h:86
cSlotAreaEnchanting::DistributeStack
virtual void DistributeStack(cItem &a_ItemStack, cPlayer &a_Player, bool a_ShouldApply, bool a_KeepEmptySlots, bool a_BackFill) override
Called to store as much of a_ItemStack in the area as possible.
Definition: SlotArea.cpp:1614
cSlotAreaAnvil::UpdateResult
void UpdateResult(cPlayer &a_Player)
Handles a click in the item slot.
Definition: SlotArea.cpp:1125
cSlotArea::DblClicked
virtual void DblClicked(cPlayer &a_Player, int a_SlotNum)
Called from Clicked when the action is a caDblClick.
Definition: SlotArea.cpp:235
cSlotAreaEnchanting::m_BlockPos
Vector3i m_BlockPos
Definition: SlotArea.h:412
cSlotAreaInventoryBase::cSlotAreaInventoryBase
cSlotAreaInventoryBase(int a_NumSlots, int a_SlotOffset, cWindow &a_ParentWindow)
Definition: SlotArea.cpp:2407
eClickAction
eClickAction
Individual actions sent in the WindowClick packet.
Definition: Defines.h:81
cSlotAreaCrafting::ClearCraftingGrid
void ClearCraftingGrid(cPlayer &a_Player)
Clear the crafting grid.
Definition: SlotArea.cpp:833
cSlotAreaInventoryBase::Clicked
virtual void Clicked(cPlayer &a_Player, int a_SlotNum, eClickAction a_ClickAction, const cItem &a_ClickedItem) override
Called when a player clicks in the window.
Definition: SlotArea.cpp:2417
cSlotAreaAnvil::m_StackSizeToBeUsedInRepair
char m_StackSizeToBeUsedInRepair
The stack size of the second item where was used for repair.
Definition: SlotArea.h:346
cSlotAreaArmor::cSlotAreaArmor
cSlotAreaArmor(cWindow &a_ParentWindow)
Definition: SlotArea.h:178
cSlotAreaFurnace::GetSlot
virtual const cItem * GetSlot(int a_SlotNum, cPlayer &a_Player) const override
Called to retrieve an item in the specified slot for the specified player.
Definition: SlotArea.cpp:2072
cSlotAreaEnderChest::GetSlot
virtual const cItem * GetSlot(int a_SlotNum, cPlayer &a_Player) const override
Called to retrieve an item in the specified slot for the specified player.
Definition: SlotArea.cpp:1844
cSlotAreaTemporary::m_Items
cItemMap m_Items
Definition: SlotArea.h:247
cSlotAreaItemGrid::OnSlotChanged
virtual void OnSlotChanged(cItemGrid *a_ItemGrid, int a_SlotNum) override
Called whenever a slot changes.
Definition: SlotArea.cpp:2642
cSlotAreaMinecartWithChest::SetSlot
virtual void SetSlot(int a_SlotNum, cPlayer &a_Player, const cItem &a_Item) override
Called to set an item in the specified slot for the specified player.
Definition: SlotArea.cpp:2394
cSlotAreaFurnace
Definition: SlotArea.h:472
cInventory
This class represents the player's inventory The slots are divided into three areas:
Definition: Inventory.h:32
cBeaconEntity
Definition: BeaconEntity.h:19
cSlotAreaBrewingstand::SetSlot
virtual void SetSlot(int a_SlotNum, cPlayer &a_Player, const cItem &a_Item) override
Called to set an item in the specified slot for the specified player.
Definition: SlotArea.cpp:2347
cSlotArea::MiddleClicked
virtual void MiddleClicked(cPlayer &a_Player, int a_SlotNum)
Called from Clicked when the action is a middleclick.
Definition: SlotArea.cpp:265
cHorse
Definition: Horse.h:11
cWindow
Represents a UI window.
Definition: Window.h:53
cSlotAreaFurnace::m_Furnace
cFurnaceEntity * m_Furnace
Definition: SlotArea.h:490
cSlotAreaCrafting
Definition: SlotArea.h:257
cSlotAreaMinecartWithChest::GetSlot
virtual const cItem * GetSlot(int a_SlotNum, cPlayer &a_Player) const override
Called to retrieve an item in the specified slot for the specified player.
Definition: SlotArea.cpp:2383
cSlotAreaEnderChest::SetSlot
virtual void SetSlot(int a_SlotNum, cPlayer &a_Player, const cItem &a_Item) override
Called to set an item in the specified slot for the specified player.
Definition: SlotArea.cpp:1853
cSlotArea::cSlotArea
cSlotArea(int a_NumSlots, cWindow &a_ParentWindow)
Definition: SlotArea.cpp:33
cItemGrid::cListener
This class is used as a callback for when a slot changes.
Definition: ItemGrid.h:25
cSlotAreaHorse::Clicked
virtual void Clicked(cPlayer &a_Player, int a_SlotNum, eClickAction a_ClickAction, const cItem &a_ClickedItem) override
Called when a player clicks in the window.
Definition: SlotArea.cpp:2790
cSlotArea::GetNumSlots
int GetNumSlots(void) const
Definition: SlotArea.h:39
cSlotArea::ShiftClicked
virtual void ShiftClicked(cPlayer &a_Player, int a_SlotNum, const cItem &a_ClickedItem)
Called from Clicked when the action is a shiftclick (left or right)
Definition: SlotArea.cpp:215
cSlotAreaHorse::ArmorSlot
@ ArmorSlot
Definition: SlotArea.h:558
cSlotAreaEnderChest::cSlotAreaEnderChest
cSlotAreaEnderChest(cEnderChestEntity *a_EnderChest, cWindow &a_ParentWindow)
Definition: SlotArea.cpp:1834
cSlotAreaMinecartWithChest
Definition: SlotArea.h:533
cSlotAreaDoubleChest::SetSlot
virtual void SetSlot(int a_SlotNum, cPlayer &a_Player, const cItem &a_Item) override
Called to set an item in the specified slot for the specified player.
Definition: SlotArea.cpp:488
cSlotAreaHotBar::cSlotAreaHotBar
cSlotAreaHotBar(cWindow &a_ParentWindow)
Definition: SlotArea.h:142
cSlotAreaEnderChest
Definition: SlotArea.h:455
cSlotArea::OnPlayerAdded
virtual void OnPlayerAdded(cPlayer &a_Player)
Called when a new player opens the same parent window.
Definition: SlotArea.cpp:336
cSlotArea::SetSlot
virtual void SetSlot(int a_SlotNum, cPlayer &a_Player, const cItem &a_Item)=0
Called to set an item in the specified slot for the specified player.
cSlotAreaItemGrid::~cSlotAreaItemGrid
virtual ~cSlotAreaItemGrid() override
Definition: SlotArea.cpp:2615
cSlotAreaBeacon::OnSlotChanged
virtual void OnSlotChanged(cItemGrid *a_ItemGrid, int a_SlotNum) override
Called whenever a slot changes.
Definition: SlotArea.cpp:1474
cSlotAreaFurnace::cSlotAreaFurnace
cSlotAreaFurnace(cFurnaceEntity *a_Furnace, cWindow &a_ParentWindow)
Definition: SlotArea.cpp:1865
cSlotAreaHotBar
Handles the hotbar of each player.
Definition: SlotArea.h:136
cSlotAreaEnchanting::UpdateResult
void UpdateResult(cPlayer &a_Player)
Handles a click in the item slot.
Definition: SlotArea.cpp:1691
cSlotAreaChest::GetSlot
virtual const cItem * GetSlot(int a_SlotNum, cPlayer &a_Player) const override
Called to retrieve an item in the specified slot for the specified player.
Definition: SlotArea.cpp:438
UInt32
unsigned int UInt32
Definition: Globals.h:154
cSlotAreaEnchanting::OnPlayerRemoved
virtual void OnPlayerRemoved(cPlayer &a_Player) override
Called when one of the players closes the parent window.
Definition: SlotArea.cpp:1669
cSlotAreaEnchanting::SetSlot
virtual void SetSlot(int a_SlotNum, cPlayer &a_Player, const cItem &a_Item) override
Called to set an item in the specified slot for the specified player.
Definition: SlotArea.cpp:1681
cSlotAreaFurnace::SetSlot
virtual void SetSlot(int a_SlotNum, cPlayer &a_Player, const cItem &a_Item) override
Called to set an item in the specified slot for the specified player.
Definition: SlotArea.cpp:2083
cSlotAreaFurnace::DistributeStack
virtual void DistributeStack(cItem &a_ItemStack, cPlayer &a_Player, bool a_ShouldApply, bool a_KeepEmptySlots, bool a_BackFill) override
Called to store as much of a_ItemStack in the area as possible.
Definition: SlotArea.cpp:2022
cSlotAreaDoubleChest::m_BottomChest
cChestEntity * m_BottomChest
Definition: SlotArea.h:448
cSlotAreaTemporary::GetPlayerSlots
cItem * GetPlayerSlots(cPlayer &a_Player)
Returns the pointer to the slot array for the player specified.
Definition: SlotArea.cpp:2763
cSlotAreaCrafting::DblClicked
virtual void DblClicked(cPlayer &a_Player, int a_SlotNum) override
Called from Clicked when the action is a caDblClick.
Definition: SlotArea.cpp:552
cSlotAreaDoubleChest::cSlotAreaDoubleChest
cSlotAreaDoubleChest(cChestEntity *a_TopChest, cChestEntity *a_BottomChest, cWindow &a_ParentWindow)
Definition: SlotArea.cpp:460
cSlotAreaBeacon::Clicked
virtual void Clicked(cPlayer &a_Player, int a_SlotNum, eClickAction a_ClickAction, const cItem &a_ClickedItem) override
Called when a player clicks in the window.
Definition: SlotArea.cpp:1333
cSlotAreaCrafting::cRecipeMap
std::list< std::pair< UInt32, cCraftingRecipe > > cRecipeMap
Maps player's EntityID -> current recipe.
Definition: SlotArea.h:285
cSlotArea::CollectItemsToHand
virtual bool CollectItemsToHand(cItem &a_Dragging, cPlayer &a_Player, bool a_CollectFullStacks)
Called on DblClicking to collect all stackable items into hand.
Definition: SlotArea.cpp:392
cSlotAreaAnvil::ShiftClicked
virtual void ShiftClicked(cPlayer &a_Player, int a_SlotNum, const cItem &a_ClickedItem) override
Called from Clicked when the action is a shiftclick (left or right)
Definition: SlotArea.cpp:959
cSlotAreaBrewingstand::cSlotAreaBrewingstand
cSlotAreaBrewingstand(cBrewingstandEntity *a_Brewingstand, cWindow &a_ParentWindow)
Definition: SlotArea.cpp:2128
cSlotArea::NumberClicked
virtual void NumberClicked(cPlayer &a_Player, int a_SlotNum, eClickAction a_ClickAction)
Called from Clicked when the action is a number click.
Definition: SlotArea.cpp:311
cSlotAreaChest::SetSlot
virtual void SetSlot(int a_SlotNum, cPlayer &a_Player, const cItem &a_Item) override
Called to set an item in the specified slot for the specified player.
Definition: SlotArea.cpp:448
cSlotAreaCrafting::ClickedResult
void ClickedResult(cPlayer &a_Player)
Handles a click in the result slot.
Definition: SlotArea.cpp:615
cSlotAreaBeacon::GetSlot
virtual const cItem * GetSlot(int a_SlotNum, cPlayer &a_Player) const override
Called to retrieve an item in the specified slot for the specified player.
Definition: SlotArea.cpp:1454
cSlotAreaCrafting::DistributeStack
virtual void DistributeStack(cItem &a_ItemStack, cPlayer &a_Player, bool a_ShouldApply, bool a_KeepEmptySlots, bool a_BackFill) override
Called to store as much of a_ItemStack in the area as possible.
Definition: SlotArea.cpp:602
cSlotAreaBeacon
Definition: SlotArea.h:353
cWorld
Definition: World.h:47
cSlotAreaCrafting::Clicked
virtual void Clicked(cPlayer &a_Player, int a_SlotNum, eClickAction a_ClickAction, const cItem &a_ClickedItem) override
Called when a player clicks in the window.
Definition: SlotArea.cpp:518
cFurnaceEntity
Definition: FurnaceEntity.h:18
cSlotAreaCrafting::SetSlot
virtual void SetSlot(int a_SlotNum, cPlayer &a_Player, const cItem &a_Item) override
Called to set an item in the specified slot for the specified player.
Definition: SlotArea.cpp:588
cSlotArea::DropClicked
virtual void DropClicked(cPlayer &a_Player, int a_SlotNum, bool a_DropStack)
Called from Clicked when the action is a drop click.
Definition: SlotArea.cpp:283
cSlotAreaCrafting::LoadRecipe
void LoadRecipe(cPlayer &a_Player, UInt32 a_RecipeId)
Loads the given Recipe into the crafting grid.
Definition: SlotArea.cpp:784
cSlotAreaCrafting::GetRecipeForPlayer
cCraftingRecipe & GetRecipeForPlayer(cPlayer &a_Player)
Retrieves the recipe for the specified player from the map, or creates one if not found.
Definition: SlotArea.cpp:740
cSlotAreaShield::cSlotAreaShield
cSlotAreaShield(cWindow &a_ParentWindow)
Definition: SlotArea.h:160
cSlotAreaItemGrid::m_ItemGrid
cItemGrid & m_ItemGrid
Definition: SlotArea.h:213
cSlotAreaArmor::Clicked
virtual void Clicked(cPlayer &a_Player, int a_SlotNum, eClickAction a_ClickAction, const cItem &a_ClickedItem) override
Called when a player clicks in the window.
Definition: SlotArea.cpp:2502
cSlotAreaBeacon::~cSlotAreaBeacon
virtual ~cSlotAreaBeacon() override
Definition: SlotArea.cpp:1302
cSlotAreaArmor::CanPlaceArmorInSlot
static bool CanPlaceArmorInSlot(int a_SlotNum, const cItem &a_Item)
Definition: SlotArea.cpp:2585
cSlotAreaBrewingstand::GetSlot
virtual const cItem * GetSlot(int a_SlotNum, cPlayer &a_Player) const override
Called to retrieve an item in the specified slot for the specified player.
Definition: SlotArea.cpp:2336
cSlotAreaEnchanting::GetBookshelvesCount
unsigned GetBookshelvesCount(cWorld &a_World)
Definition: SlotArea.cpp:1755
cSlotAreaHorse::DistributeStack
virtual void DistributeStack(cItem &a_ItemStack, cPlayer &a_Player, bool a_ShouldApply, bool a_KeepEmptySlots, bool a_BackFill) override
Called to store as much of a_ItemStack in the area as possible.
Definition: SlotArea.cpp:2873
cSlotAreaBeacon::cSlotAreaBeacon
cSlotAreaBeacon(cBeaconEntity *a_Beacon, cWindow &a_ParentWindow)
Definition: SlotArea.cpp:1291
cSlotAreaArmor
Handles the armor area of the player's inventory.
Definition: SlotArea.h:171
cSlotAreaEnchanting::m_EnchantedItemOptions
std::array< cItem, 3 > m_EnchantedItemOptions
Definition: SlotArea.h:413
cSlotAreaTemporary::SetSlot
virtual void SetSlot(int a_SlotNum, cPlayer &a_Player, const cItem &a_Item) override
Called to set an item in the specified slot for the specified player.
Definition: SlotArea.cpp:2690
cItem
Definition: Item.h:36
cSlotAreaBrewingstand::~cSlotAreaBrewingstand
virtual ~cSlotAreaBrewingstand() override
Definition: SlotArea.cpp:2139
cSlotAreaChest
Definition: SlotArea.h:420
cSlotAreaEnchanting::OnPlayerAdded
virtual void OnPlayerAdded(cPlayer &a_Player) override
Called when a new player opens the same parent window.
Definition: SlotArea.cpp:1659
cSlotAreaDoubleChest::GetSlot
virtual const cItem * GetSlot(int a_SlotNum, cPlayer &a_Player) const override
Called to retrieve an item in the specified slot for the specified player.
Definition: SlotArea.cpp:471
cSlotAreaHorse::m_Horse
cHorse & m_Horse
Definition: SlotArea.h:567
cSlotAreaBeacon::m_Beacon
cBeaconEntity * m_Beacon
Definition: SlotArea.h:372
cSlotAreaInventory::cSlotAreaInventory
cSlotAreaInventory(cWindow &a_ParentWindow)
Definition: SlotArea.h:125
cSlotAreaAnvil
Definition: SlotArea.h:315
cSlotAreaBrewingstand
Definition: SlotArea.h:503
cSlotAreaBrewingstand::Clicked
virtual void Clicked(cPlayer &a_Player, int a_SlotNum, eClickAction a_ClickAction, const cItem &a_ClickedItem) override
Called when a player clicks in the window.
Definition: SlotArea.cpp:2148
cSlotAreaFurnace::Clicked
virtual void Clicked(cPlayer &a_Player, int a_SlotNum, eClickAction a_ClickAction, const cItem &a_ClickedItem) override
Called when a player clicks in the window.
Definition: SlotArea.cpp:1885
cSlotAreaArmor::DistributeStack
virtual void DistributeStack(cItem &a_ItemStack, cPlayer &a_Player, bool a_ShouldApply, bool a_KeepEmptySlots, bool a_BackFill) override
Distributing the stack is allowed only for compatible items (helmets into helmet slot etc....
Definition: SlotArea.cpp:2462
cSlotAreaItemGrid::GetSlot
virtual const cItem * GetSlot(int a_SlotNum, cPlayer &a_Player) const override
Called to retrieve an item in the specified slot for the specified player.
Definition: SlotArea.cpp:2624
cSlotAreaBeacon::DistributeStack
virtual void DistributeStack(cItem &a_ItemStack, cPlayer &a_Player, bool a_ShouldApply, bool a_KeepEmptySlots, bool a_BackFill) override
Called to store as much of a_ItemStack in the area as possible.
Definition: SlotArea.cpp:1435
cSlotAreaHorse::cSlotAreaHorse
cSlotAreaHorse(cHorse &a_Horse, cWindow &a_ParentWindow)
Definition: SlotArea.cpp:2780
cSlotAreaTemporary
A cSlotArea with items layout that is private to each player and is temporary, such as a crafting gri...
Definition: SlotArea.h:226
cSlotAreaTemporary::cSlotAreaTemporary
cSlotAreaTemporary(int a_NumSlots, cWindow &a_ParentWindow)
Definition: SlotArea.cpp:2655
cSlotAreaAnvil::OnTakeResult
void OnTakeResult(cPlayer &a_Player)
This function will call, when the player take the item from the slot.
Definition: SlotArea.cpp:1032
cSlotAreaShield
Handles the shield of each player.
Definition: SlotArea.h:153
cSlotAreaBeacon::SetSlot
virtual void SetSlot(int a_SlotNum, cPlayer &a_Player, const cItem &a_Item) override
Called to set an item in the specified slot for the specified player.
Definition: SlotArea.cpp:1464
cSlotAreaHorse::SetSlot
virtual void SetSlot(int a_SlotNum, cPlayer &a_Player, const cItem &a_Item) override
Called to set an item in the specified slot for the specified player.
Definition: SlotArea.cpp:2856
cSlotAreaInventoryBase::GetSlot
virtual const cItem * GetSlot(int a_SlotNum, cPlayer &a_Player) const override
Called to retrieve an item in the specified slot for the specified player.
Definition: SlotArea.cpp:2440
cSlotAreaEnchanting
Definition: SlotArea.h:382
cSlotAreaCrafting::HandleCraftItem
void HandleCraftItem(const cItem &a_Result, cPlayer &a_Player)
Called after an item has been crafted to handle statistics e.t.c.
Definition: SlotArea.cpp:762
cSlotAreaCrafting::m_GridSize
int m_GridSize
Definition: SlotArea.h:287
cSlotAreaTemporary::cItemMap
std::map< UInt32, std::vector< cItem > > cItemMap
Definition: SlotArea.h:245
cSlotAreaCrafting::ShiftClickedResult
void ShiftClickedResult(cPlayer &a_Player)
Handles a shift-click in the result slot.
Definition: SlotArea.cpp:658
cSlotArea::OnPlayerRemoved
virtual void OnPlayerRemoved(cPlayer &a_Player)
Called when one of the players closes the parent window.
Definition: SlotArea.cpp:345
cSlotAreaHorse
Slot area holding horse saddle and armor.
Definition: SlotArea.h:551
cSlotAreaMinecartWithChest::cSlotAreaMinecartWithChest
cSlotAreaMinecartWithChest(cMinecartWithChest *a_ChestCart, cWindow &a_ParentWindow)
Definition: SlotArea.cpp:2373
cSlotAreaInventory
Handles the main inventory of each player, excluding the armor and hotbar.
Definition: SlotArea.h:118
cSlotAreaCrafting::DropClickedResult
void DropClickedResult(cPlayer &a_Player)
Handles a drop-click in the result slot.
Definition: SlotArea.cpp:707
cChestEntity
Definition: ChestEntity.h:18
cSlotAreaEnchanting::cSlotAreaEnchanting
cSlotAreaEnchanting(cWindow &a_ParentWindow, Vector3i a_BlockPos)
Definition: SlotArea.cpp:1490
cSlotAreaChest::m_Chest
cChestEntity * m_Chest
Definition: SlotArea.h:430
cSlotAreaBrewingstand::DistributeStack
virtual void DistributeStack(cItem &a_ItemStack, cPlayer &a_Player, bool a_ShouldApply, bool a_KeepEmptySlots, bool a_BackFill) override
Called to store as much of a_ItemStack in the area as possible.
Definition: SlotArea.cpp:2274
cSlotAreaCrafting::m_Recipes
cRecipeMap m_Recipes
Definition: SlotArea.h:288
cSlotAreaTemporary::OnPlayerRemoved
virtual void OnPlayerRemoved(cPlayer &a_Player) override
Called when one of the players closes the parent window.
Definition: SlotArea.cpp:2725
cSlotAreaAnvil::cSlotAreaAnvil
cSlotAreaAnvil(cWindow &a_ParentWindow)
Definition: SlotArea.cpp:851
cSlotAreaTemporary::GetSlot
virtual const cItem * GetSlot(int a_SlotNum, cPlayer &a_Player) const override
Called to retrieve an item in the specified slot for the specified player.
Definition: SlotArea.cpp:2664
cSlotAreaItemGrid
Handles any slot area that is representing a cItemGrid; same items for all the players.
Definition: SlotArea.h:197
cSlotArea::GetSlot
virtual const cItem * GetSlot(int a_SlotNum, cPlayer &a_Player) const =0
Called to retrieve an item in the specified slot for the specified player.
cSlotAreaInventoryBase::SetSlot
virtual void SetSlot(int a_SlotNum, cPlayer &a_Player, const cItem &a_Item) override
Called to set an item in the specified slot for the specified player.
Definition: SlotArea.cpp:2450
cPlayer
Definition: Player.h:27
cItemGrid
Definition: ItemGrid.h:19
cSlotAreaEnchanting::Clicked
virtual void Clicked(cPlayer &a_Player, int a_SlotNum, eClickAction a_ClickAction, const cItem &a_ClickedItem) override
Called when a player clicks in the window.
Definition: SlotArea.cpp:1500
cSlotAreaTemporary::TossItems
void TossItems(cPlayer &a_Player, int a_Begin, int a_End)
Tosses the player's items in slots [a_Begin, a_End) (ie.
Definition: SlotArea.cpp:2736
cSlotAreaTemporary::OnPlayerAdded
virtual void OnPlayerAdded(cPlayer &a_Player) override
Called when a new player opens the same parent window.
Definition: SlotArea.cpp:2715
cSlotAreaCrafting::UpdateRecipe
void UpdateRecipe(cPlayer &a_Player)
Updates the current recipe and result slot based on the ingredients currently in the crafting grid of...
Definition: SlotArea.cpp:728
cSlotAreaDoubleChest
Definition: SlotArea.h:437
cSlotAreaEnchanting::SelectEnchantedOption
cItem SelectEnchantedOption(size_t a_EnchantOption)
Definition: SlotArea.cpp:1821
cSlotAreaItemGrid::cSlotAreaItemGrid
cSlotAreaItemGrid(cItemGrid &a_ItemGrid, cWindow &a_ParentWindow)
Definition: SlotArea.cpp:2604
cSlotAreaChest::cSlotAreaChest
cSlotAreaChest(cChestEntity *a_Chest, cWindow &a_ParentWindow)
Definition: SlotArea.cpp:428
cSlotAreaEnderChest::m_EnderChest
cEnderChestEntity * m_EnderChest
Definition: SlotArea.h:465
cSlotAreaFurnace::~cSlotAreaFurnace
virtual ~cSlotAreaFurnace() override
Definition: SlotArea.cpp:1876
cSlotAreaAnvil::OnPlayerRemoved
virtual void OnPlayerRemoved(cPlayer &a_Player) override
Called when one of the players closes the parent window.
Definition: SlotArea.cpp:1115
cSlotAreaInventoryBase::m_SlotOffset
int m_SlotOffset
Definition: SlotArea.h:110
cSlotArea::m_NumSlots
int m_NumSlots
Definition: SlotArea.h:85
cSlotAreaBeacon::IsPlaceableItem
static bool IsPlaceableItem(short a_ItemType)
Definition: SlotArea.cpp:1311
cSlotArea::DistributeStack
virtual void DistributeStack(cItem &a_ItemStack, cPlayer &a_Player, bool a_ShouldApply, bool a_KeepEmptySlots, bool a_BackFill)
Called to store as much of a_ItemStack in the area as possible.
Definition: SlotArea.cpp:354
cSlotAreaInventoryBase
Handles any part of the inventory, using parameters in constructor to distinguish between the parts.
Definition: SlotArea.h:94
cCraftingRecipe
Definition: CraftingRecipes.h:60
cSlotAreaAnvil::Clicked
virtual void Clicked(cPlayer &a_Player, int a_SlotNum, eClickAction a_ClickAction, const cItem &a_ClickedItem) override
Called when a player clicks in the window.
Definition: SlotArea.cpp:862
cBrewingstandEntity
Definition: BrewingstandEntity.h:19
cSlotAreaBrewingstand::OnSlotChanged
virtual void OnSlotChanged(cItemGrid *a_ItemGrid, int a_SlotNum) override
Called whenever a slot changes.
Definition: SlotArea.cpp:2357
cSlotAreaDoubleChest::m_TopChest
cChestEntity * m_TopChest
Definition: SlotArea.h:447
cSlotArea
Definition: SlotArea.h:33
cSlotArea::~cSlotArea
virtual ~cSlotArea()
Definition: SlotArea.h:37
cEnderChestEntity
Definition: EnderChestEntity.h:12
Vector3< int >
cMinecartWithChest
Definition: Minecart.h:127
cSlotAreaCrafting::OnPlayerRemoved
virtual void OnPlayerRemoved(cPlayer &a_Player) override
Called when one of the players closes the parent window.
Definition: SlotArea.cpp:566
cSlotArea::Clicked
virtual void Clicked(cPlayer &a_Player, int a_SlotNum, eClickAction a_ClickAction, const cItem &a_ClickedItem)
Called when a player clicks in the window.
Definition: SlotArea.cpp:43
cSlotAreaFurnace::HandleSmeltItem
void HandleSmeltItem(const cItem &a_Result, cPlayer &a_Player)
Called after an item has been smelted to handle statistics etc.
Definition: SlotArea.cpp:2105
cSlotAreaHorse::GetSlot
virtual const cItem * GetSlot(int a_SlotNum, cPlayer &a_Player) const override
Called to retrieve an item in the specified slot for the specified player.
Definition: SlotArea.cpp:2837
cSlotAreaCrafting::cSlotAreaCrafting
cSlotAreaCrafting(int a_GridSize, cWindow &a_ParentWindow)
a_GridSize is allowed to be only 2 or 3
Definition: SlotArea.cpp:507
cSlotAreaAnvil::CanTakeResultItem
bool CanTakeResultItem(cPlayer &a_Player)
Can the player take the item from the slot?
Definition: SlotArea.cpp:1099
cSlotAreaAnvil::m_MaximumCost
int m_MaximumCost
The maximum cost of repairing / renaming in the anvil.
Definition: SlotArea.h:343
cSlotAreaBrewingstand::HandleBrewedItem
void HandleBrewedItem(cPlayer &a_Player, const cItem &a_ClickedItem)
Called after an item has been brewed to handle statistics etc.
Definition: SlotArea.cpp:2261
cSlotAreaAnvil::DistributeStack
virtual void DistributeStack(cItem &a_ItemStack, cPlayer &a_Player, bool a_ShouldApply, bool a_KeepEmptySlots, bool a_BackFill) override
Called to store as much of a_ItemStack in the area as possible.
Definition: SlotArea.cpp:992