summaryrefslogtreecommitdiffstats
path: root/src/UI
diff options
context:
space:
mode:
authorTiger Wang <ziwei.tiger@hotmail.co.uk>2014-09-27 20:19:28 +0200
committerTiger Wang <ziwei.tiger@hotmail.co.uk>2014-09-27 20:19:28 +0200
commit7ce09a9113d693b85fdda13b3c04a8b8eb900153 (patch)
tree49c3c3742cff4c38a33bd5014dd9c57c0dcea71c /src/UI
parentMerge remote-tracking branch 'origin/master' into chestcarts (diff)
downloadcuberite-7ce09a9113d693b85fdda13b3c04a8b8eb900153.tar
cuberite-7ce09a9113d693b85fdda13b3c04a8b8eb900153.tar.gz
cuberite-7ce09a9113d693b85fdda13b3c04a8b8eb900153.tar.bz2
cuberite-7ce09a9113d693b85fdda13b3c04a8b8eb900153.tar.lz
cuberite-7ce09a9113d693b85fdda13b3c04a8b8eb900153.tar.xz
cuberite-7ce09a9113d693b85fdda13b3c04a8b8eb900153.tar.zst
cuberite-7ce09a9113d693b85fdda13b3c04a8b8eb900153.zip
Diffstat (limited to 'src/UI')
-rw-r--r--src/UI/WindowOwner.h68
1 files changed, 57 insertions, 11 deletions
diff --git a/src/UI/WindowOwner.h b/src/UI/WindowOwner.h
index a8be3e6cb..6845a161b 100644
--- a/src/UI/WindowOwner.h
+++ b/src/UI/WindowOwner.h
@@ -1,4 +1,3 @@
-
#pragma once
#include "../BlockEntities/BlockEntity.h"
@@ -16,12 +15,6 @@ for entities / players in motion to close their windows when they get too far aw
-// class cWindow;
-
-
-
-
-
/**
Base class for the window owning
*/
@@ -32,16 +25,16 @@ public:
m_Window(NULL)
{
}
-
+
virtual ~cWindowOwner()
{
}
-
+
void CloseWindow(void)
{
m_Window = NULL;
}
-
+
void OpenWindow(cWindow * a_Window)
{
m_Window = a_Window;
@@ -52,7 +45,10 @@ public:
{
return m_Window;
}
-
+
+ /// Returns the block position at which the element owning the window is
+ virtual Vector3i GetBlockPos(void) = 0;
+
private:
cWindow * m_Window;
};
@@ -60,3 +56,53 @@ private:
+
+/**
+Window owner that is associated with a block entity (chest, furnace, ...)
+*/
+class cBlockEntityWindowOwner :
+ public cWindowOwner
+{
+public:
+ cBlockEntityWindowOwner(cBlockEntity * a_BlockEntity) :
+ m_BlockEntity(a_BlockEntity)
+ {
+ }
+
+ virtual Vector3i GetBlockPos(void) override
+ {
+ return Vector3i(m_BlockEntity->GetPosX(), m_BlockEntity->GetPosY(), m_BlockEntity->GetPosZ());
+ }
+
+private:
+ cBlockEntity * m_BlockEntity;
+};
+
+
+
+
+
+/**
+Window owner that is associated with an entity (chest minecart)
+*/
+class cEntityWindowOwner :
+ public cWindowOwner
+{
+public:
+ cEntityWindowOwner(cEntity * a_Entity) :
+ m_Entity(a_Entity)
+ {
+ }
+
+ virtual Vector3i GetBlockPos(void) override
+ {
+ return m_Entity->GetPosition().Floor();
+ }
+
+private:
+ cEntity * m_Entity;
+};
+
+
+
+