summaryrefslogtreecommitdiffstats
path: root/source/cWindowOwner.h
diff options
context:
space:
mode:
authormadmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2012-08-07 14:05:35 +0200
committermadmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2012-08-07 14:05:35 +0200
commitb53b40b5610c456176f4b7962e1af1cc49562930 (patch)
treef3e24c0f4d063d9c8c59f8b3c56745fd0da041c8 /source/cWindowOwner.h
parentRemoved the build folder (diff)
downloadcuberite-b53b40b5610c456176f4b7962e1af1cc49562930.tar
cuberite-b53b40b5610c456176f4b7962e1af1cc49562930.tar.gz
cuberite-b53b40b5610c456176f4b7962e1af1cc49562930.tar.bz2
cuberite-b53b40b5610c456176f4b7962e1af1cc49562930.tar.lz
cuberite-b53b40b5610c456176f4b7962e1af1cc49562930.tar.xz
cuberite-b53b40b5610c456176f4b7962e1af1cc49562930.tar.zst
cuberite-b53b40b5610c456176f4b7962e1af1cc49562930.zip
Diffstat (limited to '')
-rw-r--r--source/cWindowOwner.h99
1 files changed, 86 insertions, 13 deletions
diff --git a/source/cWindowOwner.h b/source/cWindowOwner.h
index ef08bbe44..6c9a15a45 100644
--- a/source/cWindowOwner.h
+++ b/source/cWindowOwner.h
@@ -2,6 +2,7 @@
#pragma once
#include "cBlockEntity.h"
+#include "cEntity.h"
@@ -14,29 +15,101 @@ class cWindow;
/**
-Implements the base behavior expected from a class that can handle UI windows for block entities.
+Base class for the behavior expected from a class that can handle UI windows for block entities.
*/
class cWindowOwner
{
public:
- cWindowOwner() : m_Window( NULL ) {}
- void CloseWindow() { m_Window = NULL; }
- void OpenWindow( cWindow* a_Window ) { m_Window = a_Window; }
+ cWindowOwner() :
+ m_Window(NULL)
+ {
+ }
+
+ void CloseWindow(void)
+ {
+ m_Window = NULL;
+ }
+
+ void OpenWindow(cWindow * a_Window)
+ {
+ m_Window = a_Window;
+ }
+
+ 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;
+} ;
+
+
- cWindow* GetWindow() { return m_Window; }
- void SetEntity(cBlockEntity * a_Entity) { m_Entity = a_Entity; }
- void GetBlockPos(int & a_BlockX, int & a_BlockY, int & a_BlockZ)
+
+/**
+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 = m_Entity->GetPosX();
- a_BlockY = m_Entity->GetPosY();
- a_BlockZ = m_Entity->GetPosZ();
+ a_BlockX = (int)(m_Entity->GetPosX());
+ a_BlockY = (int)(m_Entity->GetPosY());
+ a_BlockZ = (int)(m_Entity->GetPosZ());
}
private:
- cWindow * m_Window;
- cBlockEntity * m_Entity;
-};
+ cEntity * m_Entity;
+} ;