summaryrefslogtreecommitdiffstats
path: root/source/UI
diff options
context:
space:
mode:
authormadmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2013-06-16 22:24:07 +0200
committermadmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2013-06-16 22:24:07 +0200
commit97eda34a9437abe732cf6b60711828bbe4f0cb2e (patch)
treef06f2a5bb2ad7efd0d09d9cba0b2f8fe586a53e0 /source/UI
parentCore: fixed a warning message when using the /item command (diff)
downloadcuberite-97eda34a9437abe732cf6b60711828bbe4f0cb2e.tar
cuberite-97eda34a9437abe732cf6b60711828bbe4f0cb2e.tar.gz
cuberite-97eda34a9437abe732cf6b60711828bbe4f0cb2e.tar.bz2
cuberite-97eda34a9437abe732cf6b60711828bbe4f0cb2e.tar.lz
cuberite-97eda34a9437abe732cf6b60711828bbe4f0cb2e.tar.xz
cuberite-97eda34a9437abe732cf6b60711828bbe4f0cb2e.tar.zst
cuberite-97eda34a9437abe732cf6b60711828bbe4f0cb2e.zip
Diffstat (limited to '')
-rw-r--r--source/UI/SlotArea.cpp61
-rw-r--r--source/UI/SlotArea.h27
-rw-r--r--source/UI/Window.cpp3
3 files changed, 29 insertions, 62 deletions
diff --git a/source/UI/SlotArea.cpp b/source/UI/SlotArea.cpp
index feeeb4add..fc3f248f5 100644
--- a/source/UI/SlotArea.cpp
+++ b/source/UI/SlotArea.cpp
@@ -475,43 +475,22 @@ cCraftingRecipe & cSlotAreaCrafting::GetRecipeForPlayer(cPlayer & a_Player)
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-// cSlotAreaDropSpenser:
-
-cSlotAreaDropSpenser::cSlotAreaDropSpenser(cDropSpenserEntity * a_DropSpenser, cWindow & a_ParentWindow) :
- cSlotArea(9, a_ParentWindow),
- m_DropSpenser(a_DropSpenser)
-{
-}
-
-
-
-
-
-const cItem * cSlotAreaDropSpenser::GetSlot(int a_SlotNum, cPlayer & a_Player) const
-{
- return &(m_DropSpenser->GetSlot(a_SlotNum));
-}
-
-
-
-
+// cSlotAreaFurnace:
-void cSlotAreaDropSpenser::SetSlot(int a_SlotNum, cPlayer & a_Player, const cItem & a_Item)
+cSlotAreaFurnace::cSlotAreaFurnace(cFurnaceEntity * a_Furnace, cWindow & a_ParentWindow) :
+ cSlotArea(3, a_ParentWindow),
+ m_Furnace(a_Furnace)
{
- m_DropSpenser->SetSlot(a_SlotNum, a_Item);
+ m_Furnace->GetContents().AddListener(*this);
}
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-// cSlotAreaFurnace:
-
-cSlotAreaFurnace::cSlotAreaFurnace(cFurnaceEntity * a_Furnace, cWindow & a_ParentWindow) :
- cSlotArea(3, a_ParentWindow),
- m_Furnace(a_Furnace)
+cSlotAreaFurnace::~cSlotAreaFurnace()
{
+ m_Furnace->GetContents().RemoveListener(*this);
}
@@ -520,8 +499,6 @@ cSlotAreaFurnace::cSlotAreaFurnace(cFurnaceEntity * a_Furnace, cWindow & a_Paren
void cSlotAreaFurnace::Clicked(cPlayer & a_Player, int a_SlotNum, eClickAction a_ClickAction, const cItem & a_ClickedItem)
{
- cItem Fuel = *GetSlot(0, a_Player);
-
super::Clicked(a_Player, a_SlotNum, a_ClickAction, a_ClickedItem);
if (m_Furnace == NULL)
@@ -530,16 +507,6 @@ void cSlotAreaFurnace::Clicked(cPlayer & a_Player, int a_SlotNum, eClickAction a
ASSERT(!"cSlotAreaFurnace::Clicked(): m_Furnace == NULL");
return;
}
-
- if (Fuel.m_ItemType != GetSlot(0, a_Player)->m_ItemType)
- {
- m_Furnace->ResetCookTimer();
- }
-
- if (m_Furnace->StartCooking())
- {
- m_ParentWindow.SendWholeWindow(*(a_Player.GetClientHandle()));
- }
}
@@ -549,7 +516,7 @@ void cSlotAreaFurnace::Clicked(cPlayer & a_Player, int a_SlotNum, eClickAction a
const cItem * cSlotAreaFurnace::GetSlot(int a_SlotNum, cPlayer & a_Player) const
{
// a_SlotNum ranges from 0 to 2, query the items from the underlying furnace:
- return m_Furnace->GetSlot(a_SlotNum);
+ return &(m_Furnace->GetSlot(a_SlotNum));
}
@@ -565,6 +532,18 @@ void cSlotAreaFurnace::SetSlot(int a_SlotNum, cPlayer & a_Player, const cItem &
+void cSlotAreaFurnace::OnSlotChanged(cItemGrid * a_ItemGrid, int a_SlotNum)
+{
+ // Something has changed in the window, broadcast the entire window to all clients
+ ASSERT(a_ItemGrid == &(m_Furnace->GetContents()));
+
+ m_ParentWindow.BroadcastWholeWindow();
+}
+
+
+
+
+
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// cSlotAreaInventoryBase:
diff --git a/source/UI/SlotArea.h b/source/UI/SlotArea.h
index 2666f5209..516e6d644 100644
--- a/source/UI/SlotArea.h
+++ b/source/UI/SlotArea.h
@@ -276,39 +276,26 @@ protected:
-class cSlotAreaDropSpenser :
- public cSlotArea
-{
- typedef cSlotArea super;
-
-public:
- cSlotAreaDropSpenser(cDropSpenserEntity * a_DropSpenser, 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:
- cDropSpenserEntity * m_DropSpenser;
-} ;
-
-
-
-
-
class cSlotAreaFurnace :
- public cSlotArea
+ public cSlotArea,
+ public cItemGrid::cListener
{
typedef cSlotArea super;
public:
cSlotAreaFurnace(cFurnaceEntity * a_Furnace, cWindow & a_ParentWindow);
+ virtual ~cSlotAreaFurnace();
+
virtual void Clicked(cPlayer & a_Player, int a_SlotNum, eClickAction a_ClickAction, const cItem & a_ClickedItem) override;
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:
cFurnaceEntity * m_Furnace;
+
+ // cItemGrid::cListener overrides:
+ virtual void OnSlotChanged(cItemGrid * a_ItemGrid, int a_SlotNum) override;
} ;
diff --git a/source/UI/Window.cpp b/source/UI/Window.cpp
index 161145d50..d09c57337 100644
--- a/source/UI/Window.cpp
+++ b/source/UI/Window.cpp
@@ -11,6 +11,7 @@
#include "../Inventory.h"
#include "../Items/ItemHandler.h"
#include "../BlockEntities/ChestEntity.h"
+#include "../BlockEntities/DropSpenserEntity.h"
#include "../BlockEntities/HopperEntity.h"
@@ -777,7 +778,7 @@ cDropSpenserWindow::cDropSpenserWindow(int a_BlockX, int a_BlockY, int a_BlockZ,
cWindow(cWindow::DropSpenser, "MCS-DropSpenser")
{
m_ShouldDistributeToHotbarFirst = false;
- m_SlotAreas.push_back(new cSlotAreaDropSpenser(a_DropSpenser, *this));
+ m_SlotAreas.push_back(new cSlotAreaItemGrid(a_DropSpenser->GetContents(), *this));
m_SlotAreas.push_back(new cSlotAreaInventory(*this));
m_SlotAreas.push_back(new cSlotAreaHotBar(*this));
}