7 #include "../Entities/Player.h"
8 #include "../UI/SlotArea.h"
12 #include "lua/src/lauxlib.h"
15 #include "../ClientHandle.h"
24 Super(a_WindowType, a_Title),
25 m_Contents(a_SlotsX, a_SlotsY),
26 m_LuaState(a_LuaState.QueryCanonLuaState())
64 a_Player.CloseWindow(false);
187 if (Area != a_ClickedArea)
189 Areas.push_back(Area);
230 cWindow::Clicked(a_Player, a_WindowID, a_SlotNum, a_ClickAction, a_ClickedItem);
eClickAction
Individual actions sent in the WindowClick packet.
std::vector< cSlotArea * > cSlotAreas
Encapsulates a Lua state and provides some syntactic sugar for common operations.
std::unique_ptr< cCallback > cCallbackPtr
void CreateFromObject(cLuaState &a_LuaState, T &&a_Object)
Creates a Lua reference to the specified object instance in the specified Lua state.
void UnRef(void)
Removes the bound reference, resets the object to Unbound state.
std::atomic< int > m_PlayerCount
Number of players that are currently using the window.
virtual void OnSlotChanged(cItemGrid *a_ItemGrid, int a_SlotNum) override
Called whenever a slot changes.
void SetOnClicked(cLuaState::cCallbackPtr &&a_OnClicked)
Sets the Lua callback to call when the player clicks on the window.
cLuaWindow(cLuaState &a_LuaState, cWindow::WindowType a_WindowType, int a_SlotsX, int a_SlotsY, const AString &a_Title)
Create a window of the specified type, with a slot grid of a_SlotsX * a_SlotsY size.
void SetOnClosing(cLuaState::cCallbackPtr &&a_OnClosing)
Sets the Lua callback function to call when the window is about to close.
virtual void Clicked(cPlayer &a_Player, int a_WindowID, short a_SlotNum, eClickAction a_ClickAction, const cItem &a_ClickedItem) override
Handles a click event from a player.
virtual ~cLuaWindow() override
void SetOnSlotChanged(cLuaState::cCallbackPtr &&a_OnSlotChanged)
Sets the Lua callback function to call when a slot is changed.
cItemGrid m_Contents
Contents of the non-inventory part.
virtual bool ClosedByPlayer(cPlayer &a_Player, bool a_CanRefuse) override
Called when a player closes this window; notifies all slot areas.
virtual void Destroy(void) override
Sets the internal flag as "destroyed"; notifies the owner that the window is destroying.
cLuaState::cCallbackPtr m_OnSlotChanged
The Lua callback to call when a slot has changed.
cLuaState::cCallbackPtr m_OnClicked
The Lua callback to call when the player clicked on a slot.
virtual void OpenedByPlayer(cPlayer &a_Player) override
cLuaState::cRef m_LuaRef
Reference to self, to keep Lua from GCing the object while a player is still using it.
cLuaState * m_LuaState
The canon Lua state that has opened the window and owns the m_LuaRef.
cLuaState::cCallbackPtr m_OnClosing
The Lua callback to call when the window is closing for any player.
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...
void SendInventorySlot(char a_WindowID, short a_SlotNum, const cItem &a_Item)
cClientHandle * GetClientHandle(void) const
cItem & GetDraggingItem(void)
In UI windows, get the item that the player is dragging.
cWindow * GetWindow(void)
void AddListener(cListener &a_Listener)
Adds a callback that gets called whenever a slot changes.
void RemoveListener(cListener &a_Listener)
Removes a slot-change-callback.
bool ForEachPlayer(cPlayerListCallback a_Callback)
Calls the callback for each player in all worlds.
Handles the main inventory of each player, excluding the armor and hotbar.
Handles the hotbar of each player.
Handles the armor area of the player's inventory.
Handles any slot area that is representing a cItemGrid; same items for all the players.
virtual void OpenedByPlayer(cPlayer &a_Player)
virtual bool ClosedByPlayer(cPlayer &a_Player, bool a_CanRefuse)
Called when a player closes this window; notifies all slot areas.
void BroadcastWholeWindow(void)
Sends the contents of the whole window to all clients of this window.
virtual void Destroy(void)
Sets the internal flag as "destroyed"; notifies the owner that the window is destroying.
virtual void Clicked(cPlayer &a_Player, int a_WindowID, short a_SlotNum, eClickAction a_ClickAction, const cItem &a_ClickedItem)
Handles a click event from a player.
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...