summaryrefslogtreecommitdiffstats
path: root/source/UI/Window.cpp
diff options
context:
space:
mode:
authormadmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2013-06-13 09:36:43 +0200
committermadmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2013-06-13 09:36:43 +0200
commit03c6bb9f85b929a99df2c800b8ba7d8ef4a8ec43 (patch)
tree8027076867da60f62e52362059717c94084bcfd9 /source/UI/Window.cpp
parentProtectionAreas: Added proper ignored files (diff)
downloadcuberite-03c6bb9f85b929a99df2c800b8ba7d8ef4a8ec43.tar
cuberite-03c6bb9f85b929a99df2c800b8ba7d8ef4a8ec43.tar.gz
cuberite-03c6bb9f85b929a99df2c800b8ba7d8ef4a8ec43.tar.bz2
cuberite-03c6bb9f85b929a99df2c800b8ba7d8ef4a8ec43.tar.lz
cuberite-03c6bb9f85b929a99df2c800b8ba7d8ef4a8ec43.tar.xz
cuberite-03c6bb9f85b929a99df2c800b8ba7d8ef4a8ec43.tar.zst
cuberite-03c6bb9f85b929a99df2c800b8ba7d8ef4a8ec43.zip
Diffstat (limited to '')
-rw-r--r--source/UI/Window.cpp53
1 files changed, 53 insertions, 0 deletions
diff --git a/source/UI/Window.cpp b/source/UI/Window.cpp
index 3c28f33b0..161145d50 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/HopperEntity.h"
@@ -607,6 +608,40 @@ int cWindow::DistributeItemToSlots(cPlayer & a_Player, const cItem & a_Item, int
+void cWindow::BroadcastSlot(cSlotArea * a_Area, int a_LocalSlotNum)
+{
+ // Translate local slot num into global slot num:
+ int SlotNum = 0;
+ bool HasFound = false;
+ for (cSlotAreas::const_iterator itr = m_SlotAreas.begin(), end = m_SlotAreas.end(); itr != end; ++itr)
+ {
+ if (a_Area == *itr)
+ {
+ SlotNum += a_LocalSlotNum;
+ HasFound = true;
+ break;
+ }
+ SlotNum += (*itr)->GetNumSlots();
+ } // for itr - m_SlotAreas[]
+ if (!HasFound)
+ {
+ LOGWARNING("%s: Invalid slot area parameter", __FUNCTION__);
+ ASSERT(!"Invalid slot area");
+ return;
+ }
+
+ // Broadcast the update packet:
+ cCSLock Lock(m_CS);
+ for (cPlayerList::iterator itr = m_OpenedBy.begin(); itr != m_OpenedBy.end(); ++itr)
+ {
+ (*itr)->GetClientHandle()->SendInventorySlot(m_WindowID, SlotNum, *a_Area->GetSlot(a_LocalSlotNum, **itr));
+ } // for itr - m_OpenedBy[]
+}
+
+
+
+
+
void cWindow::SendWholeWindow(cClientHandle & a_Client)
{
a_Client.SendWholeInventory(*this);
@@ -741,6 +776,7 @@ cChestWindow::~cChestWindow()
cDropSpenserWindow::cDropSpenserWindow(int a_BlockX, int a_BlockY, int a_BlockZ, cDropSpenserEntity * a_DropSpenser) :
cWindow(cWindow::DropSpenser, "MCS-DropSpenser")
{
+ m_ShouldDistributeToHotbarFirst = false;
m_SlotAreas.push_back(new cSlotAreaDropSpenser(a_DropSpenser, *this));
m_SlotAreas.push_back(new cSlotAreaInventory(*this));
m_SlotAreas.push_back(new cSlotAreaHotBar(*this));
@@ -751,11 +787,28 @@ cDropSpenserWindow::cDropSpenserWindow(int a_BlockX, int a_BlockY, int a_BlockZ,
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+// cHopperWindow:
+
+cHopperWindow::cHopperWindow(int a_BlockX, int a_BlockY, int a_BlockZ, cHopperEntity * a_Hopper) :
+ super(cWindow::Hopper, "MCS-Hopper")
+{
+ m_ShouldDistributeToHotbarFirst = false;
+ m_SlotAreas.push_back(new cSlotAreaItemGrid(a_Hopper->GetContents(), *this));
+ m_SlotAreas.push_back(new cSlotAreaInventory(*this));
+ m_SlotAreas.push_back(new cSlotAreaHotBar(*this));
+}
+
+
+
+
+
+///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// cFurnaceWindow:
cFurnaceWindow::cFurnaceWindow(int a_BlockX, int a_BlockY, int a_BlockZ, cFurnaceEntity * a_Furnace) :
cWindow(cWindow::Furnace, "MCS-Furnace")
{
+ m_ShouldDistributeToHotbarFirst = false;
m_SlotAreas.push_back(new cSlotAreaFurnace(a_Furnace, *this));
m_SlotAreas.push_back(new cSlotAreaInventory(*this));
m_SlotAreas.push_back(new cSlotAreaHotBar(*this));