diff options
Diffstat (limited to 'src/UI/SlotArea.h')
-rw-r--r-- | src/UI/SlotArea.h | 78 |
1 files changed, 39 insertions, 39 deletions
diff --git a/src/UI/SlotArea.h b/src/UI/SlotArea.h index 0ff36ce50..b5809b872 100644 --- a/src/UI/SlotArea.h +++ b/src/UI/SlotArea.h @@ -33,18 +33,18 @@ class cSlotArea public: cSlotArea(int a_NumSlots, cWindow & a_ParentWindow); virtual ~cSlotArea() {} // force a virtual destructor in all subclasses - + int GetNumSlots(void) const { return m_NumSlots; } - + /** Called to retrieve an item in the specified slot for the specified player. Must return a valid cItem. */ virtual const cItem * GetSlot(int a_SlotNum, cPlayer & a_Player) const = 0; - + /** Called to set an item in the specified slot for the specified player */ virtual void SetSlot(int a_SlotNum, cPlayer & a_Player, const cItem & a_Item) = 0; - + /** Called when a player clicks in the window. Parameters taken from the click packet. */ virtual void Clicked(cPlayer & a_Player, int a_SlotNum, eClickAction a_ClickAction, const cItem & a_ClickedItem); - + /** Called from Clicked when the action is a shiftclick (left or right) */ virtual void ShiftClicked(cPlayer & a_Player, int a_SlotNum, const cItem & a_ClickedItem); @@ -62,17 +62,17 @@ public: /** Called when a new player opens the same parent window. The window already tracks the player. CS-locked. */ virtual void OnPlayerAdded(cPlayer & a_Player); - + /** Called when one of the players closes the parent window. The window already doesn't track the player. CS-locked. */ virtual void OnPlayerRemoved(cPlayer & a_Player); - + /** Called to store as much of a_ItemStack in the area as possible. a_ItemStack is modified to reflect the change. The default implementation searches each slot for available space and distributes the stack there. 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) If a_KeepEmptySlots is true, empty slots will be skipped and won't be filled */ virtual void DistributeStack(cItem & a_ItemStack, cPlayer & a_Player, bool a_ShouldApply, bool a_KeepEmptySlots, bool a_BackFill); - + /** Called on DblClicking to collect all stackable items into hand. The items are accumulated in a_Dragging and removed from the slots immediately. If a_CollectFullStacks is false, slots with full stacks are skipped while collecting. @@ -93,16 +93,16 @@ class cSlotAreaInventoryBase : public cSlotArea { typedef cSlotArea super; - + public: cSlotAreaInventoryBase(int a_NumSlots, int a_SlotOffset, cWindow & a_ParentWindow); - + // Creative inventory's click handling is somewhat different from survival inventory's, handle that here: virtual void Clicked(cPlayer & a_Player, int a_SlotNum, eClickAction a_ClickAction, const cItem & a_ClickedItem) override; virtual const cItem * GetSlot(int a_SlotNum, cPlayer & a_Player) const override; virtual void SetSlot(int a_SlotNum, cPlayer & a_Player, const cItem & a_Item) override; - + protected: int m_SlotOffset; // Index that this area's slot 0 has in the underlying cInventory } ; @@ -116,7 +116,7 @@ class cSlotAreaInventory : public cSlotAreaInventoryBase { typedef cSlotAreaInventoryBase super; - + public: cSlotAreaInventory(cWindow & a_ParentWindow) : cSlotAreaInventoryBase(cInventory::invInventoryCount, cInventory::invInventoryOffset, a_ParentWindow) @@ -133,7 +133,7 @@ class cSlotAreaHotBar : public cSlotAreaInventoryBase { typedef cSlotAreaInventoryBase super; - + public: cSlotAreaHotBar(cWindow & a_ParentWindow) : cSlotAreaInventoryBase(cInventory::invHotbarCount, cInventory::invHotbarOffset, a_ParentWindow) @@ -174,18 +174,18 @@ class cSlotAreaItemGrid : public cItemGrid::cListener { typedef cSlotArea super; - + public: cSlotAreaItemGrid(cItemGrid & a_ItemGrid, cWindow & a_ParentWindow); - + virtual ~cSlotAreaItemGrid(); - + virtual const cItem * GetSlot(int a_SlotNum, cPlayer & a_Player) const override; virtual void SetSlot(int a_SlotNum, cPlayer & a_Player, const cItem & a_Item) override; protected: cItemGrid & m_ItemGrid; - + // cItemGrid::cListener overrides: virtual void OnSlotChanged(cItemGrid * a_ItemGrid, int a_SlotNum) override; } ; @@ -201,24 +201,24 @@ class cSlotAreaTemporary : public cSlotArea { typedef cSlotArea super; - + public: cSlotAreaTemporary(int a_NumSlots, cWindow & a_ParentWindow); - + // cSlotArea overrides: virtual const cItem * GetSlot (int a_SlotNum, cPlayer & a_Player) const override; virtual void SetSlot (int a_SlotNum, cPlayer & a_Player, const cItem & a_Item) override; virtual void OnPlayerAdded (cPlayer & a_Player) override; virtual void OnPlayerRemoved(cPlayer & a_Player) override; - + /** Tosses the player's items in slots [a_Begin, a_End) (ie. incl. a_Begin, but excl. a_End) */ void TossItems(cPlayer & a_Player, int a_Begin, int a_End); - + protected: typedef std::map<UInt32, std::vector<cItem> > cItemMap; // Maps EntityID -> items - + cItemMap m_Items; - + /** Returns the pointer to the slot array for the player specified. */ cItem * GetPlayerSlots(cPlayer & a_Player); } ; @@ -231,7 +231,7 @@ class cSlotAreaCrafting : public cSlotAreaTemporary { typedef cSlotAreaTemporary super; - + public: /** a_GridSize is allowed to be only 2 or 3 */ cSlotAreaCrafting(int a_GridSize, cWindow & a_ParentWindow); @@ -241,7 +241,7 @@ public: virtual void DblClicked (cPlayer & a_Player, int a_SlotNum) override; virtual void OnPlayerRemoved(cPlayer & a_Player) override; virtual void SetSlot (int a_SlotNum, cPlayer & a_Player, const cItem & a_Item) override; - + // Distributing items into this area is completely disabled virtual void DistributeStack(cItem & a_ItemStack, cPlayer & a_Player, bool a_ShouldApply, bool a_KeepEmptySlots, bool a_BackFill) override; @@ -250,14 +250,14 @@ protected: /** Maps player's EntityID -> current recipe. Not a std::map because cCraftingGrid needs proper constructor params. */ typedef std::list<std::pair<UInt32, cCraftingRecipe> > cRecipeMap; - + int m_GridSize; cRecipeMap m_Recipes; - + /** Handles a click in the result slot. Crafts using the current recipe, if possible. */ void ClickedResult(cPlayer & a_Player); - + /** Handles a shift-click in the result slot. Crafts using the current recipe until it changes or no more space for result. */ void ShiftClickedResult(cPlayer & a_Player); @@ -267,7 +267,7 @@ protected: /** Updates the current recipe and result slot based on the ingredients currently in the crafting grid of the specified player. */ void UpdateRecipe(cPlayer & a_Player); - + /** Retrieves the recipe for the specified player from the map, or creates one if not found. */ cCraftingRecipe & GetRecipeForPlayer(cPlayer & a_Player); @@ -321,13 +321,13 @@ class cSlotAreaBeacon : public cItemGrid::cListener { typedef cSlotArea super; - + public: cSlotAreaBeacon(cBeaconEntity * a_Beacon, cWindow & a_ParentWindow); virtual ~cSlotAreaBeacon(); static bool IsPlaceableItem(short a_ItemType); - + virtual void Clicked(cPlayer & a_Player, int a_SlotNum, eClickAction a_ClickAction, const cItem & a_ClickedItem) override; virtual void DistributeStack(cItem & a_ItemStack, cPlayer & a_Player, bool a_ShouldApply, bool a_KeepEmptySlots, bool a_BackFill) override; virtual const cItem * GetSlot(int a_SlotNum, cPlayer & a_Player) const override; @@ -380,10 +380,10 @@ class cSlotAreaChest : { public: cSlotAreaChest(cChestEntity * a_Chest, cWindow & a_ParentWindow); - + virtual const cItem * GetSlot(int a_SlotNum, cPlayer & a_Player) const override; virtual void SetSlot(int a_SlotNum, cPlayer & a_Player, const cItem & a_Item) override; - + protected: cChestEntity * m_Chest; } ; @@ -397,10 +397,10 @@ class cSlotAreaDoubleChest : { public: cSlotAreaDoubleChest(cChestEntity * a_TopChest, cChestEntity * a_BottomChest, cWindow & a_ParentWindow); - + virtual const cItem * GetSlot(int a_SlotNum, cPlayer & a_Player) const override; virtual void SetSlot(int a_SlotNum, cPlayer & a_Player, const cItem & a_Item) override; - + protected: cChestEntity * m_TopChest; cChestEntity * m_BottomChest; @@ -432,17 +432,17 @@ class cSlotAreaFurnace : public cItemGrid::cListener { typedef cSlotArea super; - + public: cSlotAreaFurnace(cFurnaceEntity * a_Furnace, cWindow & a_ParentWindow); - + virtual ~cSlotAreaFurnace(); - + virtual void Clicked(cPlayer & a_Player, int a_SlotNum, eClickAction a_ClickAction, const cItem & a_ClickedItem) override; virtual void DistributeStack(cItem & a_ItemStack, cPlayer & a_Player, bool a_ShouldApply, bool a_KeepEmptySlots, bool a_BackFill) override; virtual const cItem * GetSlot(int a_SlotNum, cPlayer & a_Player) const override; virtual void SetSlot(int a_SlotNum, cPlayer & a_Player, const cItem & a_Item) override; - + protected: cFurnaceEntity * m_Furnace; |