13 #include "../UI/Window.h"
14 #include "../ItemGrid.h"
91 cPlayer & a_Player,
int a_WindowID,
93 const cItem & a_ClickedItem
96 virtual void Destroy(
void)
override;
cFunctionRef< bool(cPlayer &)> cPlayerListCallback
eClickAction
Individual actions sent in the WindowClick packet.
Encapsulates a Lua state and provides some syntactic sugar for common operations.
std::unique_ptr< cCallback > cCallbackPtr
Used for storing references to object in the global registry.
A window that has been created by a Lua plugin and is handled entirely by that plugin This object nee...
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.
cItemGrid & GetContents(void)
Returns the internal representation of the contents that are manipulated by Lua.
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...
This class is used as a callback for when a slot changes.
cWindow(WindowType a_WindowType, const AString &a_WindowTitle)