summaryrefslogtreecommitdiffstats
path: root/src/UI
diff options
context:
space:
mode:
authorTiger Wang <ziwei.tiger@hotmail.co.uk>2014-09-13 00:18:02 +0200
committerTiger Wang <ziwei.tiger@hotmail.co.uk>2014-09-13 00:18:02 +0200
commit3e741134279e02d204a8d4638f2d46dfbf814d0c (patch)
treea6781315a66a2fb6f8c16ab21f9f36ea7741fb6d /src/UI
parentFixed friction being applied whilst airborne (diff)
downloadcuberite-3e741134279e02d204a8d4638f2d46dfbf814d0c.tar
cuberite-3e741134279e02d204a8d4638f2d46dfbf814d0c.tar.gz
cuberite-3e741134279e02d204a8d4638f2d46dfbf814d0c.tar.bz2
cuberite-3e741134279e02d204a8d4638f2d46dfbf814d0c.tar.lz
cuberite-3e741134279e02d204a8d4638f2d46dfbf814d0c.tar.xz
cuberite-3e741134279e02d204a8d4638f2d46dfbf814d0c.tar.zst
cuberite-3e741134279e02d204a8d4638f2d46dfbf814d0c.zip
Diffstat (limited to 'src/UI')
-rw-r--r--src/UI/SlotArea.cpp35
-rw-r--r--src/UI/SlotArea.h14
-rw-r--r--src/UI/Window.cpp30
-rw-r--r--src/UI/Window.h15
-rw-r--r--src/UI/WindowOwner.h69
5 files changed, 95 insertions, 68 deletions
diff --git a/src/UI/SlotArea.cpp b/src/UI/SlotArea.cpp
index b4facb2d3..999bed989 100644
--- a/src/UI/SlotArea.cpp
+++ b/src/UI/SlotArea.cpp
@@ -10,6 +10,7 @@
#include "../BlockEntities/DropSpenserEntity.h"
#include "../BlockEntities/EnderChestEntity.h"
#include "../BlockEntities/FurnaceEntity.h"
+#include "../Entities/Minecart.h"
#include "../Items/ItemHandler.h"
#include "Window.h"
#include "../CraftingRecipes.h"
@@ -1920,6 +1921,40 @@ void cSlotAreaFurnace::HandleSmeltItem(const cItem & a_Result, cPlayer & a_Playe
////////////////////////////////////////////////////////////////////////////////
+// cSlotAreaMinecartWithChest:
+
+cSlotAreaMinecartWithChest::cSlotAreaMinecartWithChest(cMinecartWithChest * a_Chest, cWindow & a_ParentWindow) :
+ cSlotArea(27, a_ParentWindow),
+ m_Chest(a_Chest)
+{
+}
+
+
+
+
+
+const cItem * cSlotAreaMinecartWithChest::GetSlot(int a_SlotNum, cPlayer & a_Player) const
+{
+ // a_SlotNum ranges from 0 to 26, use that to index the minecart chest entity's inventory directly:
+ UNUSED(a_Player);
+ return &(m_Chest->GetSlot(a_SlotNum));
+}
+
+
+
+
+
+void cSlotAreaMinecartWithChest::SetSlot(int a_SlotNum, cPlayer & a_Player, const cItem & a_Item)
+{
+ UNUSED(a_Player);
+ m_Chest->SetSlot(a_SlotNum, a_Item);
+}
+
+
+
+
+
+////////////////////////////////////////////////////////////////////////////////
// cSlotAreaInventoryBase:
cSlotAreaInventoryBase::cSlotAreaInventoryBase(int a_NumSlots, int a_SlotOffset, cWindow & a_ParentWindow) :
diff --git a/src/UI/SlotArea.h b/src/UI/SlotArea.h
index 6bbc87b76..0a35527d1 100644
--- a/src/UI/SlotArea.h
+++ b/src/UI/SlotArea.h
@@ -20,6 +20,7 @@ class cChestEntity;
class cDropSpenserEntity;
class cEnderChestEntity;
class cFurnaceEntity;
+class cMinecartWithChest;
class cCraftingRecipe;
class cEnchantingWindow;
class cWorld;
@@ -455,3 +456,16 @@ protected:
+
+class cSlotAreaMinecartWithChest :
+ public cSlotArea
+{
+public:
+ cSlotAreaMinecartWithChest(cMinecartWithChest * a_ChestCart, cWindow & a_ParentWindow);
+
+ virtual const cItem * GetSlot(int a_SlotNum, cPlayer & a_Player) const override;
+ virtual void SetSlot(int a_SlotNum, cPlayer & a_Player, const cItem & a_Item) override;
+
+protected:
+ cMinecartWithChest * m_Chest;
+}; \ No newline at end of file
diff --git a/src/UI/Window.cpp b/src/UI/Window.cpp
index 66900269f..fd80a017d 100644
--- a/src/UI/Window.cpp
+++ b/src/UI/Window.cpp
@@ -14,6 +14,7 @@
#include "../BlockEntities/DropSpenserEntity.h"
#include "../BlockEntities/EnderChestEntity.h"
#include "../BlockEntities/HopperEntity.h"
+#include "../Entities/Minecart.h"
#include "../Root.h"
#include "../Bindings/PluginManager.h"
@@ -1048,6 +1049,34 @@ cChestWindow::~cChestWindow()
////////////////////////////////////////////////////////////////////////////////
+// cMinecartWithChestWindow:
+
+cMinecartWithChestWindow::cMinecartWithChestWindow(cMinecartWithChest * a_ChestCart) :
+ cWindow(wtChest, "Minecart with Chest"),
+ m_ChestCart(a_ChestCart)
+{
+ m_ShouldDistributeToHotbarFirst = false;
+ m_SlotAreas.push_back(new cSlotAreaMinecartWithChest(a_ChestCart, *this));
+ m_SlotAreas.push_back(new cSlotAreaInventory(*this));
+ m_SlotAreas.push_back(new cSlotAreaHotBar(*this));
+
+ a_ChestCart->GetWorld()->BroadcastSoundEffect("random.chestopen", a_ChestCart->GetPosX(), a_ChestCart->GetPosY(), a_ChestCart->GetPosZ(), 1, 1);
+}
+
+
+
+
+
+cMinecartWithChestWindow::~cMinecartWithChestWindow()
+{
+ m_ChestCart->GetWorld()->BroadcastSoundEffect("random.chestclosed", m_ChestCart->GetPosX(), m_ChestCart->GetPosY(), m_ChestCart->GetPosZ(), 1, 1);
+}
+
+
+
+
+
+////////////////////////////////////////////////////////////////////////////////
// cDropSpenserWindow:
cDropSpenserWindow::cDropSpenserWindow(int a_BlockX, int a_BlockY, int a_BlockZ, cDropSpenserEntity * a_DropSpenser) :
@@ -1073,6 +1102,7 @@ cEnderChestWindow::cEnderChestWindow(cEnderChestEntity * a_EnderChest) :
m_BlockY(a_EnderChest->GetPosY()),
m_BlockZ(a_EnderChest->GetPosZ())
{
+ m_ShouldDistributeToHotbarFirst = false;
m_SlotAreas.push_back(new cSlotAreaEnderChest(a_EnderChest, *this));
m_SlotAreas.push_back(new cSlotAreaInventory(*this));
m_SlotAreas.push_back(new cSlotAreaHotBar(*this));
diff --git a/src/UI/Window.h b/src/UI/Window.h
index 3d860407f..f47cf4b99 100644
--- a/src/UI/Window.h
+++ b/src/UI/Window.h
@@ -23,6 +23,7 @@ class cDropSpenserEntity;
class cEnderChestEntity;
class cFurnaceEntity;
class cHopperEntity;
+class cMinecartWithChest;
class cBeaconEntity;
class cSlotArea;
class cSlotAreaAnvil;
@@ -360,6 +361,20 @@ protected:
+class cMinecartWithChestWindow :
+ public cWindow
+{
+public:
+ cMinecartWithChestWindow(cMinecartWithChest * a_ChestCart);
+ ~cMinecartWithChestWindow();
+private:
+ cMinecartWithChest * m_ChestCart;
+};
+
+
+
+
+
class cEnderChestWindow :
public cWindow
{
diff --git a/src/UI/WindowOwner.h b/src/UI/WindowOwner.h
index 7a7941e37..a8be3e6cb 100644
--- a/src/UI/WindowOwner.h
+++ b/src/UI/WindowOwner.h
@@ -52,77 +52,10 @@ public:
{
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)floor(m_Entity->GetPosX() + 0.5);
- a_BlockY = (int)floor(m_Entity->GetPosY() + 0.5);
- a_BlockZ = (int)floor(m_Entity->GetPosZ() + 0.5);
- }
-
-private:
- cEntity * m_Entity;
-} ;
+};