summaryrefslogtreecommitdiffstats
path: root/src/UI
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/UI/SlotArea.cpp79
-rw-r--r--src/UI/SlotArea.h20
-rw-r--r--src/UI/Window.cpp91
-rw-r--r--src/UI/Window.h36
-rw-r--r--src/UI/WindowOwner.h63
5 files changed, 175 insertions, 114 deletions
diff --git a/src/UI/SlotArea.cpp b/src/UI/SlotArea.cpp
index b4facb2d3..9113ec343 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"
@@ -47,9 +48,9 @@ void cSlotArea::Clicked(cPlayer & a_Player, int a_SlotNum, eClickAction a_ClickA
ASSERT((a_SlotNum >= 0) && (a_SlotNum < GetNumSlots()));
bool bAsync = false;
- if (GetSlot(a_SlotNum, a_Player) == NULL)
+ if (GetSlot(a_SlotNum, a_Player) == nullptr)
{
- LOGWARNING("GetSlot(%d) returned NULL! Ignoring click", a_SlotNum);
+ LOGWARNING("GetSlot(%d) returned nullptr! Ignoring click", a_SlotNum);
return;
}
@@ -713,7 +714,7 @@ void cSlotAreaCrafting::UpdateRecipe(cPlayer & a_Player)
{
cCraftingGrid Grid(GetPlayerSlots(a_Player) + 1, m_GridSize, m_GridSize);
cCraftingRecipe & Recipe = GetRecipeForPlayer(a_Player);
- cRoot::Get()->GetCraftingRecipes()->GetRecipe(&a_Player, Grid, Recipe);
+ cRoot::Get()->GetCraftingRecipes()->GetRecipe(a_Player, Grid, Recipe);
SetSlot(0, a_Player, Recipe.GetResult());
m_ParentWindow.SendSlot(a_Player, this, 0);
}
@@ -735,7 +736,7 @@ cCraftingRecipe & cSlotAreaCrafting::GetRecipeForPlayer(cPlayer & a_Player)
// Not found. Add a new one:
cCraftingGrid Grid(GetPlayerSlots(a_Player) + 1, m_GridSize, m_GridSize);
cCraftingRecipe Recipe(Grid);
- cRoot::Get()->GetCraftingRecipes()->GetRecipe(&a_Player, Grid, Recipe);
+ cRoot::Get()->GetCraftingRecipes()->GetRecipe(a_Player, Grid, Recipe);
m_Recipes.push_back(std::make_pair(a_Player.GetUniqueID(), Recipe));
return m_Recipes.back().second;
}
@@ -790,9 +791,9 @@ void cSlotAreaAnvil::Clicked(cPlayer & a_Player, int a_SlotNum, eClickAction a_C
}
bool bAsync = false;
- if (GetSlot(a_SlotNum, a_Player) == NULL)
+ if (GetSlot(a_SlotNum, a_Player) == nullptr)
{
- LOGWARNING("GetSlot(%d) returned NULL! Ignoring click", a_SlotNum);
+ LOGWARNING("GetSlot(%d) returned nullptr! Ignoring click", a_SlotNum);
return;
}
@@ -979,7 +980,7 @@ void cSlotAreaAnvil::OnTakeResult(cPlayer & a_Player)
m_ParentWindow.SetProperty(0, m_MaximumCost, a_Player);
m_MaximumCost = 0;
- ((cAnvilWindow*)&m_ParentWindow)->SetRepairedItemName("", NULL);
+ ((cAnvilWindow*)&m_ParentWindow)->SetRepairedItemName("", nullptr);
int PosX, PosY, PosZ;
((cAnvilWindow*)&m_ParentWindow)->GetBlockPos(PosX, PosY, PosZ);
@@ -1237,9 +1238,9 @@ void cSlotAreaBeacon::Clicked(cPlayer & a_Player, int a_SlotNum, eClickAction a_
ASSERT((a_SlotNum >= 0) && (a_SlotNum < GetNumSlots()));
bool bAsync = false;
- if (GetSlot(a_SlotNum, a_Player) == NULL)
+ if (GetSlot(a_SlotNum, a_Player) == nullptr)
{
- LOGWARNING("GetSlot(%d) returned NULL! Ignoring click", a_SlotNum);
+ LOGWARNING("GetSlot(%d) returned nullptr! Ignoring click", a_SlotNum);
return;
}
@@ -1407,9 +1408,9 @@ void cSlotAreaEnchanting::Clicked(cPlayer & a_Player, int a_SlotNum, eClickActio
ASSERT((a_SlotNum >= 0) && (a_SlotNum < GetNumSlots()));
bool bAsync = false;
- if (GetSlot(a_SlotNum, a_Player) == NULL)
+ if (GetSlot(a_SlotNum, a_Player) == nullptr)
{
- LOGWARNING("GetSlot(%d) returned NULL! Ignoring click", a_SlotNum);
+ LOGWARNING("GetSlot(%d) returned nullptr! Ignoring click", a_SlotNum);
return;
}
@@ -1708,19 +1709,19 @@ cSlotAreaFurnace::~cSlotAreaFurnace()
void cSlotAreaFurnace::Clicked(cPlayer & a_Player, int a_SlotNum, eClickAction a_ClickAction, const cItem & a_ClickedItem)
{
- if (m_Furnace == NULL)
+ if (m_Furnace == nullptr)
{
- LOGERROR("cSlotAreaFurnace::Clicked(): m_Furnace == NULL");
- ASSERT(!"cSlotAreaFurnace::Clicked(): m_Furnace == NULL");
+ LOGERROR("cSlotAreaFurnace::Clicked(): m_Furnace == nullptr");
+ ASSERT(!"cSlotAreaFurnace::Clicked(): m_Furnace == nullptr");
return;
}
if (a_SlotNum == 2)
{
bool bAsync = false;
- if (GetSlot(a_SlotNum, a_Player) == NULL)
+ if (GetSlot(a_SlotNum, a_Player) == nullptr)
{
- LOGWARNING("GetSlot(%d) returned NULL! Ignoring click", a_SlotNum);
+ LOGWARNING("GetSlot(%d) returned nullptr! Ignoring click", a_SlotNum);
return;
}
@@ -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) :
@@ -2036,9 +2071,9 @@ void cSlotAreaArmor::Clicked(cPlayer & a_Player, int a_SlotNum, eClickAction a_C
}
bool bAsync = false;
- if (GetSlot(a_SlotNum, a_Player) == NULL)
+ if (GetSlot(a_SlotNum, a_Player) == nullptr)
{
- LOGWARNING("GetSlot(%d) returned NULL! Ignoring click", a_SlotNum);
+ LOGWARNING("GetSlot(%d) returned nullptr! Ignoring click", a_SlotNum);
return;
}
@@ -2188,15 +2223,15 @@ const cItem * cSlotAreaTemporary::GetSlot(int a_SlotNum, cPlayer & a_Player) con
LOGERROR("cSlotAreaTemporary: player \"%s\" not found for slot %d!", a_Player.GetName().c_str(), a_SlotNum);
ASSERT(!"cSlotAreaTemporary: player not found!");
- // Player not found, this should not happen, ever! Return NULL, but things may break by this.
- return NULL;
+ // Player not found, this should not happen, ever! Return nullptr, but things may break by this.
+ return nullptr;
}
if (a_SlotNum >= (int)(itr->second.size()))
{
LOGERROR("cSlotAreaTemporary: asking for more slots than actually stored!");
ASSERT(!"cSlotAreaTemporary: asking for more slots than actually stored!");
- return NULL;
+ return nullptr;
}
return &(itr->second[a_SlotNum]);
@@ -2285,7 +2320,7 @@ cItem * cSlotAreaTemporary::GetPlayerSlots(cPlayer & a_Player)
cItemMap::iterator itr = m_Items.find(a_Player.GetUniqueID());
if (itr == m_Items.end())
{
- return NULL;
+ return nullptr;
}
return &(itr->second[0]);
}
diff --git a/src/UI/SlotArea.h b/src/UI/SlotArea.h
index 6bbc87b76..1eeeb9836 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;
@@ -448,10 +449,27 @@ protected:
// cItemGrid::cListener overrides:
virtual void OnSlotChanged(cItemGrid * a_ItemGrid, int a_SlotNum) override;
- /// Called after an item has been smelted to handle statistics e.t.c.
+ /// Called after an item has been smelted to handle statistics etc.
void HandleSmeltItem(const cItem & a_Result, cPlayer & a_Player);
} ;
+
+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;
+};
+
+
+
+
diff --git a/src/UI/Window.cpp b/src/UI/Window.cpp
index 1b7b07f77..1598dd3e7 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"
@@ -32,7 +33,7 @@ cWindow::cWindow(WindowType a_WindowType, const AString & a_WindowTitle) :
m_WindowTitle(a_WindowTitle),
m_IsDestroyed(false),
m_ShouldDistributeToHotbarFirst(true),
- m_Owner(NULL)
+ m_Owner(nullptr)
{
if (a_WindowType == wtInventory)
{
@@ -104,10 +105,10 @@ const cItem * cWindow::GetSlot(cPlayer & a_Player, int a_SlotNum) const
// Return the item at the specified slot for the specified player
int LocalSlotNum = 0;
const cSlotArea * Area = GetSlotArea(a_SlotNum, LocalSlotNum);
- if (Area == NULL)
+ if (Area == nullptr)
{
- LOGWARNING("%s: requesting item from an invalid SlotArea (SlotNum %d), returning NULL.", __FUNCTION__, a_SlotNum);
- return NULL;
+ LOGWARNING("%s: requesting item from an invalid SlotArea (SlotNum %d), returning nullptr.", __FUNCTION__, a_SlotNum);
+ return nullptr;
}
return Area->GetSlot(LocalSlotNum, a_Player);
}
@@ -121,7 +122,7 @@ void cWindow::SetSlot(cPlayer & a_Player, int a_SlotNum, const cItem & a_Item)
// Set the item to the specified slot for the specified player
int LocalSlotNum = 0;
cSlotArea * Area = GetSlotArea(a_SlotNum, LocalSlotNum);
- if (Area == NULL)
+ if (Area == nullptr)
{
LOGWARNING("%s: requesting write to an invalid SlotArea (SlotNum %d), ignoring.", __FUNCTION__, a_SlotNum);
return;
@@ -176,7 +177,7 @@ void cWindow::GetSlots(cPlayer & a_Player, cItems & a_Slots) const
for (int i = 0; i < NumSlots; i++)
{
const cItem * Item = (*itr)->GetSlot(i, a_Player);
- if (Item == NULL)
+ if (Item == nullptr)
{
a_Slots.push_back(cItem());
}
@@ -310,7 +311,7 @@ bool cWindow::ClosedByPlayer(cPlayer & a_Player, bool a_CanRefuse)
}
cClientHandle * ClientHandle = a_Player.GetClientHandle();
- if (ClientHandle != NULL)
+ if (ClientHandle != nullptr)
{
ClientHandle->SendWindowClose(*this);
}
@@ -344,7 +345,7 @@ bool cWindow::ClosedByPlayer(cPlayer & a_Player, bool a_CanRefuse)
void cWindow::OwnerDestroyed()
{
- m_Owner = NULL;
+ m_Owner = nullptr;
// Close window for each player. Note that the last one needs special handling
while (m_OpenedBy.size() > 1)
{
@@ -510,10 +511,10 @@ void cWindow::SendSlot(cPlayer & a_Player, cSlotArea * a_SlotArea, int a_Relativ
void cWindow::Destroy(void)
{
- if (m_Owner != NULL)
+ if (m_Owner != nullptr)
{
m_Owner->CloseWindow();
- m_Owner = NULL;
+ m_Owner = nullptr;
}
m_IsDestroyed = true;
}
@@ -528,7 +529,7 @@ cSlotArea * cWindow::GetSlotArea(int a_GlobalSlotNum, int & a_LocalSlotNum)
{
LOGWARNING("%s: requesting an invalid SlotNum: %d out of %d slots", __FUNCTION__, a_GlobalSlotNum, GetNumSlots() - 1);
ASSERT(!"Invalid SlotNum");
- return NULL;
+ return nullptr;
}
// Iterate through all the SlotAreas, find the correct one
@@ -546,7 +547,7 @@ cSlotArea * cWindow::GetSlotArea(int a_GlobalSlotNum, int & a_LocalSlotNum)
// We shouldn't be here - the check at the beginnning should prevent this. Log and assert
LOGWARNING("%s: GetNumSlots() is out of sync: %d; LocalSlotNum = %d", __FUNCTION__, GetNumSlots(), LocalSlotNum);
ASSERT(!"Invalid GetNumSlots");
- return NULL;
+ return nullptr;
}
@@ -559,7 +560,7 @@ const cSlotArea * cWindow::GetSlotArea(int a_GlobalSlotNum, int & a_LocalSlotNum
{
LOGWARNING("%s: requesting an invalid SlotNum: %d out of %d slots", __FUNCTION__, a_GlobalSlotNum, GetNumSlots() - 1);
ASSERT(!"Invalid SlotNum");
- return NULL;
+ return nullptr;
}
// Iterate through all the SlotAreas, find the correct one
@@ -577,7 +578,7 @@ const cSlotArea * cWindow::GetSlotArea(int a_GlobalSlotNum, int & a_LocalSlotNum
// We shouldn't be here - the check at the beginnning should prevent this. Log and assert
LOGWARNING("%s: GetNumSlots() is out of sync: %d; LocalSlotNum = %d", __FUNCTION__, GetNumSlots(), LocalSlotNum);
ASSERT(!"Invalid GetNumSlots");
- return NULL;
+ return nullptr;
}
@@ -668,7 +669,7 @@ int cWindow::DistributeItemToSlots(cPlayer & a_Player, const cItem & a_Item, int
{
int LocalSlotNum = 0;
cSlotArea * Area = GetSlotArea(*itr, LocalSlotNum);
- if (Area == NULL)
+ if (Area == nullptr)
{
LOGWARNING("%s: Bad SlotArea for slot %d", __FUNCTION__, *itr);
continue;
@@ -757,20 +758,7 @@ void cWindow::BroadcastWholeWindow(void)
-void cWindow::BroadcastProgress(int a_Progressbar, int a_Value)
-{
- cCSLock Lock(m_CS);
- for (cPlayerList::iterator itr = m_OpenedBy.begin(); itr != m_OpenedBy.end(); ++itr)
- {
- (*itr)->GetClientHandle()->SendWindowProperty(*this, a_Progressbar, a_Value);
- } // for itr - m_OpenedBy[]
-}
-
-
-
-
-
-void cWindow::SetProperty(int a_Property, int a_Value)
+void cWindow::SetProperty(short a_Property, short a_Value)
{
cCSLock Lock(m_CS);
for (cPlayerList::iterator itr = m_OpenedBy.begin(), end = m_OpenedBy.end(); itr != end; ++itr)
@@ -783,7 +771,7 @@ void cWindow::SetProperty(int a_Property, int a_Value)
-void cWindow::SetProperty(int a_Property, int a_Value, cPlayer & a_Player)
+void cWindow::SetProperty(short a_Property, short a_Value, cPlayer & a_Player)
{
a_Player.GetClientHandle()->SendWindowProperty(*this, a_Property, a_Value);
}
@@ -848,7 +836,7 @@ void cAnvilWindow::SetRepairedItemName(const AString & a_Name, cPlayer * a_Playe
{
m_RepairedItemName = a_Name;
- if (a_Player != NULL)
+ if (a_Player != nullptr)
{
m_AnvilSlotArea->UpdateResult(*a_Player);
}
@@ -918,7 +906,7 @@ cEnchantingWindow::cEnchantingWindow(int a_BlockX, int a_BlockY, int a_BlockZ) :
-void cEnchantingWindow::SetProperty(int a_Property, int a_Value)
+void cEnchantingWindow::SetProperty(short a_Property, short a_Value)
{
if ((a_Property < 0) || ((size_t)a_Property >= ARRAYCOUNT(m_PropertyValue)))
{
@@ -934,7 +922,7 @@ void cEnchantingWindow::SetProperty(int a_Property, int a_Value)
-void cEnchantingWindow::SetProperty(int a_Property, int a_Value, cPlayer & a_Player)
+void cEnchantingWindow::SetProperty(short a_Property, short a_Value, cPlayer & a_Player)
{
if ((a_Property < 0) || ((size_t)a_Property >= ARRAYCOUNT(m_PropertyValue)))
{
@@ -950,7 +938,7 @@ void cEnchantingWindow::SetProperty(int a_Property, int a_Value, cPlayer & a_Pla
-int cEnchantingWindow::GetPropertyValue(int a_Property)
+short cEnchantingWindow::GetPropertyValue(short a_Property)
{
if ((a_Property < 0) || ((size_t)a_Property >= ARRAYCOUNT(m_PropertyValue)))
{
@@ -975,7 +963,7 @@ cChestWindow::cChestWindow(cChestEntity * a_Chest) :
m_BlockY(a_Chest->GetPosY()),
m_BlockZ(a_Chest->GetPosZ()),
m_PrimaryChest(a_Chest),
- m_SecondaryChest(NULL)
+ m_SecondaryChest(nullptr)
{
m_SlotAreas.push_back(new cSlotAreaChest(a_Chest, *this));
m_SlotAreas.push_back(new cSlotAreaInventory(*this));
@@ -1026,7 +1014,7 @@ void cChestWindow::OpenedByPlayer(cPlayer & a_Player)
cChunkDef::BlockToChunk(m_PrimaryChest->GetPosX(), m_PrimaryChest->GetPosZ(), ChunkX, ChunkZ);
m_PrimaryChest->GetWorld()->MarkRedstoneDirty(ChunkX, ChunkZ);
- if (m_SecondaryChest != NULL)
+ if (m_SecondaryChest != nullptr)
{
m_SecondaryChest->SetNumberOfPlayers(m_SecondaryChest->GetNumberOfPlayers() + 1);
cChunkDef::BlockToChunk(m_SecondaryChest->GetPosX(), m_SecondaryChest->GetPosZ(), ChunkX, ChunkZ);
@@ -1048,7 +1036,7 @@ bool cChestWindow::ClosedByPlayer(cPlayer & a_Player, bool a_CanRefuse)
cChunkDef::BlockToChunk(m_PrimaryChest->GetPosX(), m_PrimaryChest->GetPosZ(), ChunkX, ChunkZ);
m_PrimaryChest->GetWorld()->MarkRedstoneDirty(ChunkX, ChunkZ);
- if (m_SecondaryChest != NULL)
+ if (m_SecondaryChest != nullptr)
{
m_SecondaryChest->SetNumberOfPlayers(m_SecondaryChest->GetNumberOfPlayers() - 1);
cChunkDef::BlockToChunk(m_SecondaryChest->GetPosX(), m_SecondaryChest->GetPosZ(), ChunkX, ChunkZ);
@@ -1076,6 +1064,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) :
@@ -1101,6 +1117,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 bc5becf11..e62176d50 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;
@@ -89,7 +90,7 @@ public:
// tolua_begin
- /// Returns the item at the specified slot for the specified player. Returns NULL if invalid SlotNum requested
+ /// Returns the item at the specified slot for the specified player. Returns nullptr if invalid SlotNum requested
const cItem * GetSlot(cPlayer & a_Player, int a_SlotNum) const;
/// Sets the item to the specified slot for the specified player
@@ -129,9 +130,6 @@ public:
/// Sends the contents of the whole window to all clients of this window.
void BroadcastWholeWindow(void);
-
- /// Sends the progressbar to all clients of this window (same as SetProperty)
- void BroadcastProgress(int a_Progressbar, int a_Value);
// tolua_begin
@@ -139,10 +137,10 @@ public:
void SetWindowTitle(const AString & a_WindowTitle) { m_WindowTitle = a_WindowTitle; }
/// Sends the UpdateWindowProperty (0x69) packet to all clients of the window
- virtual void SetProperty(int a_Property, int a_Value);
+ virtual void SetProperty(short a_Property, short a_Value);
/// Sends the UpdateWindowPropert(0x69) packet to the specified player
- virtual void SetProperty(int a_Property, int a_Value, cPlayer & a_Player);
+ virtual void SetProperty(short a_Property, short a_Value, cPlayer & a_Player);
// tolua_end
@@ -191,13 +189,13 @@ protected:
/** Returns the correct slot area for the specified window-global SlotNum
Also returns the area-local SlotNum corresponding to the GlobalSlotNum
- If the global SlotNum is out of range, returns NULL
+ If the global SlotNum is out of range, returns nullptr
*/
cSlotArea * GetSlotArea(int a_GlobalSlotNum, int & a_LocalSlotNum);
/** Returns the correct slot area for the specified window-global SlotNum
Also returns the area-local SlotNum corresponding to the GlobalSlotNum
- If the global SlotNum is out of range, returns NULL.
+ If the global SlotNum is out of range, returns nullptr.
Const version.
*/
const cSlotArea * GetSlotArea(int a_GlobalSlotNum, int & a_LocalSlotNum) const;
@@ -286,16 +284,16 @@ class cEnchantingWindow :
typedef cWindow super;
public:
cEnchantingWindow(int a_BlockX, int a_BlockY, int a_BlockZ);
- virtual void SetProperty(int a_Property, int a_Value, cPlayer & a_Player) override;
- virtual void SetProperty(int a_Property, int a_Value) override;
+ virtual void SetProperty(short a_Property, short a_Value, cPlayer & a_Player) override;
+ virtual void SetProperty(short a_Property, short a_Value) override;
/** Return the Value of a Property */
- int GetPropertyValue(int a_Property);
+ short GetPropertyValue(short a_Property);
cSlotArea * m_SlotArea;
protected:
- int m_PropertyValue[3];
+ short m_PropertyValue[3];
int m_BlockX, m_BlockY, m_BlockZ;
};
@@ -361,6 +359,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..4dc3cf080 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
*/
@@ -29,19 +22,19 @@ class cWindowOwner
{
public:
cWindowOwner() :
- m_Window(NULL)
+ m_Window(nullptr)
{
}
-
+
virtual ~cWindowOwner()
{
}
-
+
void CloseWindow(void)
{
- m_Window = NULL;
+ m_Window = nullptr;
}
-
+
void OpenWindow(cWindow * a_Window)
{
m_Window = a_Window;
@@ -54,11 +47,11 @@ public:
}
/// 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;
-
+ virtual Vector3i GetBlockPos(void) = 0;
+
private:
cWindow * m_Window;
-} ;
+};
@@ -71,26 +64,19 @@ class cBlockEntityWindowOwner :
public cWindowOwner
{
public:
- cBlockEntityWindowOwner(void) :
- m_BlockEntity(NULL)
- {
- }
-
- void SetBlockEntity(cBlockEntity * a_BlockEntity)
+ cBlockEntityWindowOwner(cBlockEntity * a_BlockEntity) :
+ m_BlockEntity(a_BlockEntity)
{
- m_BlockEntity = a_BlockEntity;
}
-
- virtual void GetBlockPos(int & a_BlockX, int & a_BlockY, int & a_BlockZ) override
+
+ virtual Vector3i GetBlockPos(void) override
{
- a_BlockX = m_BlockEntity->GetPosX();
- a_BlockY = m_BlockEntity->GetPosY();
- a_BlockZ = m_BlockEntity->GetPosZ();
+ return Vector3i(m_BlockEntity->GetPosX(), m_BlockEntity->GetPosY(), m_BlockEntity->GetPosZ());
}
-
+
private:
cBlockEntity * m_BlockEntity;
-} ;
+};
@@ -103,26 +89,19 @@ class cEntityWindowOwner :
public cWindowOwner
{
public:
- cEntityWindowOwner(void) :
- m_Entity(NULL)
- {
- }
-
- void SetEntity(cEntity * a_Entity)
+ cEntityWindowOwner(cEntity * a_Entity) :
+ m_Entity(a_Entity)
{
- m_Entity = a_Entity;
}
- virtual void GetBlockPos(int & a_BlockX, int & a_BlockY, int & a_BlockZ) override
+ virtual Vector3i GetBlockPos(void) 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);
+ return m_Entity->GetPosition().Floor();
}
-
+
private:
cEntity * m_Entity;
-} ;
+};