summaryrefslogtreecommitdiffstats
path: root/source/UI/Window.h
diff options
context:
space:
mode:
Diffstat (limited to 'source/UI/Window.h')
-rw-r--r--source/UI/Window.h70
1 files changed, 68 insertions, 2 deletions
diff --git a/source/UI/Window.h b/source/UI/Window.h
index 86ea1849b..ae06ecf6a 100644
--- a/source/UI/Window.h
+++ b/source/UI/Window.h
@@ -9,7 +9,7 @@
#pragma once
-#include "../Item.h"
+#include "../ItemGrid.h"
@@ -31,6 +31,8 @@ typedef std::vector<cSlotArea *> cSlotAreas;
+// tolua_begin
+
/**
Represents a UI window.
@@ -39,6 +41,7 @@ When there's no player using a window, it is destroyed.
A window consists of several areas of slots with similar functionality - for example the crafting grid area, or
the inventory area. Each area knows what its slots are (GetSlot() function) and can handle mouse clicks.
The window acts only as a top-level container for those areas, redirecting the click events to the correct areas.
+Inventory painting, introduced in 1.5, is handled by the window, too
*/
class cWindow
{
@@ -58,22 +61,35 @@ public:
Hopper = 9,
};
+ // tolua_end
+
static const int c_NumInventorySlots = 36;
cWindow(WindowType a_WindowType, const AString & a_WindowTitle);
virtual ~cWindow();
char GetWindowID(void) const { return m_WindowID; }
- int GetWindowType(void) const { return m_WindowType; }
+ int GetWindowType(void) const { return m_WindowType; } // tolua_export
cWindowOwner * GetOwner(void) { return m_Owner; }
void SetOwner( cWindowOwner * a_Owner ) { m_Owner = a_Owner; }
int GetNumSlots(void) const;
+ // tolua_begin
+
+ /// Returns the item at the specified slot for the specified player. Returns NULL if invalid SlotNum requested
+ const cItem * GetSlot(cPlayer & a_Player, int a_SlotNum) const;
+
+ /// Sets the item to the specified slot for the specified player
+ void SetSlot(cPlayer & a_Player, int a_SlotNum, const cItem & a_Item);
+
+ // tolua_end
+
/// Fills a_Slots with the slots read from m_SlotAreas[], for the specified player
void GetSlots(cPlayer & a_Player, cItems & a_Slots) const;
+ /// Handles a click event from a player
void Clicked(
cPlayer & a_Player, int a_WindowID,
short a_SlotNum, eClickAction a_ClickAction,
@@ -87,8 +103,12 @@ public:
void BroadcastWholeWindow(void);
void BroadcastInventoryProgress(short a_Progressbar, short a_Value);
+ // tolua_begin
+
const AString & GetWindowTitle() const { return m_WindowTitle; }
void SetWindowTitle(const AString & a_WindowTitle ) { m_WindowTitle = a_WindowTitle; }
+
+ // tolua_end
void OwnerDestroyed(void);
@@ -125,6 +145,31 @@ protected:
static char m_WindowIDCounter;
void Destroy(void);
+
+ /** Returns the correct slot area for the specified window-global SlotNum
+ Also returns the area-local SlotNum corresponding to the GlobalSlotNum
+ If the global SlotNum is out of range, returns NULL
+ */
+ cSlotArea * GetSlotArea(int a_GlobalSlotNum, int & a_LocalSlotNum);
+
+ /** Returns the correct slot area for the specified window-global SlotNum
+ Also returns the area-local SlotNum corresponding to the GlobalSlotNum
+ If the global SlotNum is out of range, returns NULL.
+ Const version.
+ */
+ const cSlotArea * GetSlotArea(int a_GlobalSlotNum, int & a_LocalSlotNum) const;
+
+ /// Prepares the internal structures for inventory painting from the specified player
+ void OnPaintBegin(cPlayer & a_Player);
+
+ /// 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
+ void OnLeftPaintEnd(cPlayer & a_Player);
+
+ /// Processes the entire action stored in the internal structures for inventory painting; distributes one item into each slot
+ void OnRightPaintEnd(cPlayer & a_Player);
} ;
@@ -196,3 +241,24 @@ protected:
+
+// tolua_begin
+
+/// A window that has been created by a Lua plugin and is handled entirely by that plugin
+class cLuaWindow :
+ public cWindow
+{
+public:
+ /// Create a window of the specified type, with a slot grid of a_SlotsX * a_SlotsY size
+ cLuaWindow(cWindow::WindowType a_WindowType, int a_SlotsX, int a_SlotsY, const AString & a_Title);
+
+ // tolua_end
+
+protected:
+ /// Contents of the non-inventory part
+ cItemGrid m_Contents;
+} ;
+
+
+
+