summaryrefslogtreecommitdiffstats
path: root/src/UI/Window.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/UI/Window.h')
-rw-r--r--src/UI/Window.h101
1 files changed, 64 insertions, 37 deletions
diff --git a/src/UI/Window.h b/src/UI/Window.h
index 3b69b2da4..cbb783cb4 100644
--- a/src/UI/Window.h
+++ b/src/UI/Window.h
@@ -32,7 +32,7 @@ class cWorld;
typedef std::list<cPlayer *> cPlayerList;
typedef std::vector<cSlotArea *> cSlotAreas;
-using cPlayerListCallback = cFunctionRef<bool(cPlayer &)>;
+using cPlayerListCallback = cFunctionRef<bool(cPlayer &)>;
using cClientHandleCallback = cFunctionRef<bool(cClientHandle &)>;
@@ -52,21 +52,21 @@ Inventory painting, introduced in 1.5, is handled by the window, too
*/
class cWindow
{
-public:
+ public:
enum WindowType
{
- wtInventory = -1, // This value is never actually sent to a client
- wtChest = 0,
- wtWorkbench = 1,
- wtFurnace = 2,
+ wtInventory = -1, // This value is never actually sent to a client
+ wtChest = 0,
+ wtWorkbench = 1,
+ wtFurnace = 2,
wtDropSpenser = 3, // Dropper or Dispenser
wtEnchantment = 4,
- wtBrewery = 5,
- wtNPCTrade = 6,
- wtBeacon = 7,
- wtAnvil = 8,
- wtHopper = 9,
- wtDropper = 10,
+ wtBrewery = 5,
+ wtNPCTrade = 6,
+ wtBeacon = 7,
+ wtAnvil = 8,
+ wtHopper = 9,
+ wtDropper = 10,
wtAnimalChest = 11,
};
@@ -84,7 +84,7 @@ public:
const AString GetWindowTypeName(void) const; // tolua_export
cWindowOwner * GetOwner(void) { return m_Owner; }
- void SetOwner( cWindowOwner * a_Owner) { m_Owner = a_Owner; }
+ void SetOwner(cWindowOwner * a_Owner) { m_Owner = a_Owner; }
/** Returns the total number of slots */
int GetNumSlots(void) const;
@@ -106,7 +106,8 @@ public:
/** Returns true if the specified slot is in the Player Hotbar slotarea */
bool IsSlotInPlayerHotbar(int a_SlotNum) const;
- /** Returns true if the specified slot is in the Player Main Inventory or Hotbar slotareas. Note that returns false for Armor. */
+ /** Returns true if the specified slot is in the Player Main Inventory or Hotbar slotareas. Note that returns false
+ * for Armor. */
bool IsSlotInPlayerInventory(int a_SlotNum) const;
// tolua_end
@@ -116,8 +117,10 @@ public:
/** Handles a click event from a player */
virtual void Clicked(
- cPlayer & a_Player, int a_WindowID,
- short a_SlotNum, eClickAction a_ClickAction,
+ cPlayer & a_Player,
+ int a_WindowID,
+ short a_SlotNum,
+ eClickAction a_ClickAction,
const cItem & a_ClickedItem
);
@@ -148,22 +151,36 @@ public:
void OwnerDestroyed(void);
- /** Calls the callback safely for each player that has this window open; returns true if all players have been enumerated */
+ /** Calls the callback safely for each player that has this window open; returns true if all players have been
+ * enumerated */
bool ForEachPlayer(cPlayerListCallback a_Callback);
- /** Calls the callback safely for each client that has this window open; returns true if all clients have been enumerated */
+ /** Calls the callback safely for each client that has this window open; returns true if all clients have been
+ * enumerated */
bool ForEachClient(cClientHandleCallback a_Callback);
/** 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) = 0;
-
- /** Called from DistributeStack() to distribute the stack into a_AreasInOrder; 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)
- 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);
+ virtual void DistributeStack(
+ cItem & a_ItemStack,
+ int a_Slot,
+ cPlayer & a_Player,
+ cSlotArea * a_ClickedArea,
+ bool a_ShouldApply
+ ) = 0;
+
+ /** Called from DistributeStack() to distribute the stack into a_AreasInOrder; 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) 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.
The items are accumulated in a_Dragging and removed from the SlotAreas immediately.
@@ -171,19 +188,19 @@ public:
Returns true if full stack has been collected, false if there's space remaining to fill. */
bool CollectItemsToHand(cItem & a_Dragging, cSlotArea & a_Area, cPlayer & a_Player, bool a_CollectFullStacks);
- /** Used by cSlotAreas to send individual slots to clients, a_RelativeSlotNum is the slot number relative to a_SlotArea */
+ /** Used by cSlotAreas to send individual slots to clients, a_RelativeSlotNum is the slot number relative to
+ * a_SlotArea */
void SendSlot(cPlayer & a_Player, cSlotArea * a_SlotArea, int a_RelativeSlotNum);
-protected:
-
+ protected:
cSlotAreas m_SlotAreas;
- char m_WindowID;
- int m_WindowType;
+ char m_WindowID;
+ int m_WindowType;
AString m_WindowTitle;
cCriticalSection m_CS;
- cPlayerList m_OpenedBy;
+ cPlayerList m_OpenedBy;
bool m_IsDestroyed;
@@ -211,16 +228,26 @@ protected:
/** Adds the slot to the internal structures for inventory painting by the specified player */
void OnPaintProgress(cPlayer & a_Player, int a_SlotNum);
- /** Processes the entire action stored in the internal structures for inventory painting; distributes as many items as possible */
+ /** Processes the entire action stored in the internal structures for inventory painting; distributes as many items
+ * as possible */
void OnLeftPaintEnd(cPlayer & a_Player);
- /** Processes the entire action stored in the internal structures for inventory painting; distributes one item into each slot */
+ /** Processes the entire action stored in the internal structures for inventory painting; distributes one item into
+ * each slot */
void OnRightPaintEnd(cPlayer & a_Player);
- /** Processes the entire action stored in the internal structures for inventory painting; distributes a full stack into each slot */
+ /** Processes the entire action stored in the internal structures for inventory painting; distributes a full stack
+ * into each slot */
void OnMiddlePaintEnd(cPlayer & a_Player);
- /** Distributes a_NumToEachSlot items into the slots specified in a_SlotNums; returns the total number of items distributed.
+ /** Distributes a_NumToEachSlot items into the slots specified in a_SlotNums; returns the total number of items
+ distributed.
@param a_LimitItems if false, no checks are performed on a_Item.m_ItemCount. */
- char DistributeItemToSlots(cPlayer & a_Player, const cItem & a_Item, char a_NumToEachSlot, const cSlotNums & a_SlotNums, bool a_LimitItems = true);
-} ; // tolua_export
+ char DistributeItemToSlots(
+ cPlayer & a_Player,
+ const cItem & a_Item,
+ char a_NumToEachSlot,
+ const cSlotNums & a_SlotNums,
+ bool a_LimitItems = true
+ );
+}; // tolua_export