summaryrefslogtreecommitdiffstats
path: root/source/UI/WindowOwner.h
diff options
context:
space:
mode:
authormadmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2012-09-23 19:19:34 +0200
committermadmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2012-09-23 19:19:34 +0200
commitf58c3f2e81e5cef689cf4b60a2616d062ee8edf6 (patch)
tree5ac538e5995f4f70aec73b77a220d4696651132a /source/UI/WindowOwner.h
parentFixed position confirming for 1.3.2 (FS #245) (diff)
downloadcuberite-f58c3f2e81e5cef689cf4b60a2616d062ee8edf6.tar
cuberite-f58c3f2e81e5cef689cf4b60a2616d062ee8edf6.tar.gz
cuberite-f58c3f2e81e5cef689cf4b60a2616d062ee8edf6.tar.bz2
cuberite-f58c3f2e81e5cef689cf4b60a2616d062ee8edf6.tar.lz
cuberite-f58c3f2e81e5cef689cf4b60a2616d062ee8edf6.tar.xz
cuberite-f58c3f2e81e5cef689cf4b60a2616d062ee8edf6.tar.zst
cuberite-f58c3f2e81e5cef689cf4b60a2616d062ee8edf6.zip
Diffstat (limited to 'source/UI/WindowOwner.h')
-rw-r--r--source/UI/WindowOwner.h125
1 files changed, 125 insertions, 0 deletions
diff --git a/source/UI/WindowOwner.h b/source/UI/WindowOwner.h
new file mode 100644
index 000000000..e0cc8da8a
--- /dev/null
+++ b/source/UI/WindowOwner.h
@@ -0,0 +1,125 @@
+
+#pragma once
+
+#include "../cBlockEntity.h"
+#include "../cEntity.h"
+#include "Window.h"
+
+/*
+Being a descendant of cWindowOwner means that the class can own one window. That window can be
+queried, opened by other players, closed by players and finally destroyed.
+Also, a cWindowOwner can be queried for the block coords where the window is displayed. That will be used
+for entities / players in motion to close their windows when they get too far away from the window "source".
+*/
+
+
+
+
+
+// class cWindow;
+
+
+
+
+
+/**
+Base class for the window owning
+*/
+class cWindowOwner
+{
+public:
+ cWindowOwner() :
+ m_Window(NULL)
+ {
+ }
+
+ void CloseWindow(void)
+ {
+ m_Window = NULL;
+ }
+
+ void OpenWindow(cWindow * a_Window)
+ {
+ m_Window = a_Window;
+ m_Window->SetOwner(this);
+ }
+
+ cWindow * GetWindow(void) const
+ {
+ return m_Window;
+ }
+
+ /// Returns the block position at which the element owning the window is
+ virtual void GetBlockPos(int & a_BlockX, int & a_BlockY, int & a_BlockZ) = 0;
+
+private:
+ cWindow * m_Window;
+} ;
+
+
+
+
+
+/**
+Window owner that is associated with a block entity (chest, furnace, ...)
+*/
+class cBlockEntityWindowOwner :
+ public cWindowOwner
+{
+public:
+ cBlockEntityWindowOwner(void) :
+ m_BlockEntity(NULL)
+ {
+ }
+
+ void SetBlockEntity(cBlockEntity * a_BlockEntity)
+ {
+ m_BlockEntity = a_BlockEntity;
+ }
+
+ virtual void GetBlockPos(int & a_BlockX, int & a_BlockY, int & a_BlockZ) override
+ {
+ a_BlockX = m_BlockEntity->GetPosX();
+ a_BlockY = m_BlockEntity->GetPosY();
+ a_BlockZ = m_BlockEntity->GetPosZ();
+ }
+
+private:
+ cBlockEntity * m_BlockEntity;
+} ;
+
+
+
+
+
+/**
+Window owner that is associated with an entity (chest minecart)
+*/
+class cEntityWindowOwner :
+ public cWindowOwner
+{
+public:
+ cEntityWindowOwner(void) :
+ m_Entity(NULL)
+ {
+ }
+
+ void SetEntity(cEntity * a_Entity)
+ {
+ m_Entity = a_Entity;
+ }
+
+ virtual void GetBlockPos(int & a_BlockX, int & a_BlockY, int & a_BlockZ) override
+ {
+ a_BlockX = (int)(m_Entity->GetPosX());
+ a_BlockY = (int)(m_Entity->GetPosY());
+ a_BlockZ = (int)(m_Entity->GetPosZ());
+ }
+
+private:
+ cEntity * m_Entity;
+} ;
+
+
+
+