Own classes for all windows.
This commit is contained in:
parent
b8072cbd62
commit
b6fd400276
|
@ -4,6 +4,7 @@
|
||||||
#include "BeaconEntity.h"
|
#include "BeaconEntity.h"
|
||||||
#include "../BlockArea.h"
|
#include "../BlockArea.h"
|
||||||
#include "../Entities/Player.h"
|
#include "../Entities/Player.h"
|
||||||
|
#include "../UI/BeaconWindow.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
#include "ChestEntity.h"
|
#include "ChestEntity.h"
|
||||||
#include "../Item.h"
|
#include "../Item.h"
|
||||||
#include "../Entities/Player.h"
|
#include "../Entities/Player.h"
|
||||||
#include "../UI/Window.h"
|
#include "../UI/ChestWindow.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
#include "DropSpenserEntity.h"
|
#include "DropSpenserEntity.h"
|
||||||
#include "../Entities/Player.h"
|
#include "../Entities/Player.h"
|
||||||
#include "../Chunk.h"
|
#include "../Chunk.h"
|
||||||
|
#include "../UI/DropSpenserWindow.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
#include "EnderChestEntity.h"
|
#include "EnderChestEntity.h"
|
||||||
#include "../Item.h"
|
#include "../Item.h"
|
||||||
#include "../Entities/Player.h"
|
#include "../Entities/Player.h"
|
||||||
#include "../UI/Window.h"
|
#include "../UI/EnderChestWindow.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules
|
#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules
|
||||||
|
|
||||||
#include "FurnaceEntity.h"
|
#include "FurnaceEntity.h"
|
||||||
#include "../UI/Window.h"
|
#include "../UI/FurnaceWindow.h"
|
||||||
#include "../Entities/Player.h"
|
#include "../Entities/Player.h"
|
||||||
#include "../Root.h"
|
#include "../Root.h"
|
||||||
#include "../Chunk.h"
|
#include "../Chunk.h"
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
#include "../Entities/Player.h"
|
#include "../Entities/Player.h"
|
||||||
#include "../Entities/Pickup.h"
|
#include "../Entities/Pickup.h"
|
||||||
#include "../Bindings/PluginManager.h"
|
#include "../Bindings/PluginManager.h"
|
||||||
|
#include "../UI/HopperWindow.h"
|
||||||
#include "ChestEntity.h"
|
#include "ChestEntity.h"
|
||||||
#include "FurnaceEntity.h"
|
#include "FurnaceEntity.h"
|
||||||
|
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
#include "BlockHandler.h"
|
#include "BlockHandler.h"
|
||||||
#include "../World.h"
|
#include "../World.h"
|
||||||
#include "../Entities/Player.h"
|
#include "../Entities/Player.h"
|
||||||
|
#include "../UI/AnvilWindow.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "BlockHandler.h"
|
#include "BlockHandler.h"
|
||||||
#include "../UI/Window.h"
|
#include "../UI/EnchantingWindow.h"
|
||||||
#include "../Entities/Player.h"
|
#include "../Entities/Player.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "BlockHandler.h"
|
#include "BlockHandler.h"
|
||||||
#include "../UI/Window.h"
|
#include "../UI/CraftingWindow.h"
|
||||||
#include "../Entities/Player.h"
|
#include "../Entities/Player.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -12,6 +12,9 @@
|
||||||
#include "BlockEntities/CommandBlockEntity.h"
|
#include "BlockEntities/CommandBlockEntity.h"
|
||||||
#include "BlockEntities/SignEntity.h"
|
#include "BlockEntities/SignEntity.h"
|
||||||
#include "UI/Window.h"
|
#include "UI/Window.h"
|
||||||
|
#include "UI/AnvilWindow.h"
|
||||||
|
#include "UI/BeaconWindow.h"
|
||||||
|
#include "UI/EnchantingWindow.h"
|
||||||
#include "Item.h"
|
#include "Item.h"
|
||||||
#include "Mobs/Monster.h"
|
#include "Mobs/Monster.h"
|
||||||
#include "ChatColor.h"
|
#include "ChatColor.h"
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
#include "../Chunk.h"
|
#include "../Chunk.h"
|
||||||
#include "Player.h"
|
#include "Player.h"
|
||||||
#include "../BoundingBox.h"
|
#include "../BoundingBox.h"
|
||||||
|
#include "../UI/MinecartWithChestWindow.h"
|
||||||
|
|
||||||
#define NO_SPEED 0.0
|
#define NO_SPEED 0.0
|
||||||
#define MAX_SPEED 8
|
#define MAX_SPEED 8
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
#include "Player.h"
|
#include "Player.h"
|
||||||
#include "../ChatColor.h"
|
#include "../ChatColor.h"
|
||||||
#include "../Server.h"
|
#include "../Server.h"
|
||||||
#include "../UI/Window.h"
|
#include "../UI/InventoryWindow.h"
|
||||||
#include "../UI/WindowOwner.h"
|
#include "../UI/WindowOwner.h"
|
||||||
#include "../World.h"
|
#include "../World.h"
|
||||||
#include "../Bindings/PluginManager.h"
|
#include "../Bindings/PluginManager.h"
|
||||||
|
|
|
@ -0,0 +1,66 @@
|
||||||
|
|
||||||
|
// AnvilWindow.h
|
||||||
|
|
||||||
|
// Representing the UI window for the anvil block
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "Window.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
class cAnvilWindow :
|
||||||
|
public cWindow
|
||||||
|
{
|
||||||
|
typedef cWindow super;
|
||||||
|
|
||||||
|
public:
|
||||||
|
cAnvilWindow(int a_BlockX, int a_BlockY, int a_BlockZ) :
|
||||||
|
cWindow(wtAnvil, "Repair"),
|
||||||
|
m_RepairedItemName(""),
|
||||||
|
m_BlockX(a_BlockX),
|
||||||
|
m_BlockY(a_BlockY),
|
||||||
|
m_BlockZ(a_BlockZ)
|
||||||
|
{
|
||||||
|
m_AnvilSlotArea = new cSlotAreaAnvil(*this);
|
||||||
|
m_SlotAreas.push_back(m_AnvilSlotArea);
|
||||||
|
m_SlotAreas.push_back(new cSlotAreaInventory(*this));
|
||||||
|
m_SlotAreas.push_back(new cSlotAreaHotBar(*this));
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Gets the repaired item name. */
|
||||||
|
AString GetRepairedItemName(void) const { return m_RepairedItemName; }
|
||||||
|
|
||||||
|
/** Set the repaired item name. */
|
||||||
|
void SetRepairedItemName(const AString & a_Name, cPlayer * a_Player)
|
||||||
|
{
|
||||||
|
m_RepairedItemName = a_Name;
|
||||||
|
if (a_Player != nullptr)
|
||||||
|
{
|
||||||
|
m_AnvilSlotArea->UpdateResult(*a_Player);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Gets the Position from the Anvil */
|
||||||
|
void GetBlockPos(int & a_PosX, int & a_PosY, int & a_PosZ)
|
||||||
|
{
|
||||||
|
a_PosX = m_BlockX;
|
||||||
|
a_PosY = m_BlockY;
|
||||||
|
a_PosZ = m_BlockZ;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected:
|
||||||
|
cSlotAreaAnvil * m_AnvilSlotArea;
|
||||||
|
AString m_RepairedItemName;
|
||||||
|
int m_BlockX, m_BlockY, m_BlockZ;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,53 @@
|
||||||
|
|
||||||
|
// BeaconWindow.h
|
||||||
|
|
||||||
|
// Representing the UI window for the beacon block
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "Window.h"
|
||||||
|
#include "../Entities/Player.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
class cBeaconWindow :
|
||||||
|
public cWindow
|
||||||
|
{
|
||||||
|
typedef cWindow super;
|
||||||
|
|
||||||
|
public:
|
||||||
|
cBeaconWindow(int a_BlockX, int a_BlockY, int a_BlockZ, cBeaconEntity * a_Beacon) :
|
||||||
|
cWindow(wtBeacon, "Beacon"),
|
||||||
|
m_Beacon(a_Beacon)
|
||||||
|
{
|
||||||
|
m_ShouldDistributeToHotbarFirst = true;
|
||||||
|
m_SlotAreas.push_back(new cSlotAreaBeacon(m_Beacon, *this));
|
||||||
|
m_SlotAreas.push_back(new cSlotAreaInventory(*this));
|
||||||
|
m_SlotAreas.push_back(new cSlotAreaHotBar(*this));
|
||||||
|
}
|
||||||
|
|
||||||
|
cBeaconEntity * GetBeaconEntity(void) const { return m_Beacon; }
|
||||||
|
|
||||||
|
// cWindow Overrides:
|
||||||
|
virtual void OpenedByPlayer(cPlayer & a_Player) override
|
||||||
|
{
|
||||||
|
super::OpenedByPlayer(a_Player);
|
||||||
|
|
||||||
|
a_Player.GetClientHandle()->SendWindowProperty(*this, 0, m_Beacon->GetBeaconLevel());
|
||||||
|
a_Player.GetClientHandle()->SendWindowProperty(*this, 1, m_Beacon->GetPrimaryEffect());
|
||||||
|
a_Player.GetClientHandle()->SendWindowProperty(*this, 2, m_Beacon->GetSecondaryEffect());
|
||||||
|
}
|
||||||
|
|
||||||
|
protected:
|
||||||
|
cBeaconEntity * m_Beacon;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -11,6 +11,17 @@ SET (SRCS
|
||||||
SET (HDRS
|
SET (HDRS
|
||||||
SlotArea.h
|
SlotArea.h
|
||||||
Window.h
|
Window.h
|
||||||
|
AnvilWindow.h
|
||||||
|
BeaconWindow.h
|
||||||
|
ChestWindow.h
|
||||||
|
CraftingWindow.h
|
||||||
|
DropSpenserWindow.h
|
||||||
|
EnchantingWindow.h
|
||||||
|
EnderChestWindow.h
|
||||||
|
FurnaceWindow.h
|
||||||
|
HopperWindow.h
|
||||||
|
InventoryWindow.h
|
||||||
|
MinecartWithChestWindow.h
|
||||||
WindowOwner.h)
|
WindowOwner.h)
|
||||||
|
|
||||||
if(NOT MSVC)
|
if(NOT MSVC)
|
||||||
|
|
|
@ -0,0 +1,122 @@
|
||||||
|
|
||||||
|
// ChestWindow.h
|
||||||
|
|
||||||
|
// Representing the UI window for the chest block
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "Window.h"
|
||||||
|
#include "../BlockEntities/ChestEntity.h"
|
||||||
|
#include "../Entities/Player.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
class cChestWindow :
|
||||||
|
public cWindow
|
||||||
|
{
|
||||||
|
typedef cWindow super;
|
||||||
|
|
||||||
|
public:
|
||||||
|
cChestWindow(cChestEntity * a_Chest) :
|
||||||
|
cWindow(wtChest, (a_Chest->GetBlockType() == E_BLOCK_CHEST) ? "Chest" : "Trapped Chest"),
|
||||||
|
m_World(a_Chest->GetWorld()),
|
||||||
|
m_BlockX(a_Chest->GetPosX()),
|
||||||
|
m_BlockY(a_Chest->GetPosY()),
|
||||||
|
m_BlockZ(a_Chest->GetPosZ()),
|
||||||
|
m_PrimaryChest(a_Chest),
|
||||||
|
m_SecondaryChest(nullptr)
|
||||||
|
{
|
||||||
|
m_SlotAreas.push_back(new cSlotAreaChest(a_Chest, *this));
|
||||||
|
m_SlotAreas.push_back(new cSlotAreaInventory(*this));
|
||||||
|
m_SlotAreas.push_back(new cSlotAreaHotBar(*this));
|
||||||
|
|
||||||
|
// Play the opening sound:
|
||||||
|
m_World->BroadcastSoundEffect("random.chestopen", (double)m_BlockX, (double)m_BlockY, (double)m_BlockZ, 1, 1);
|
||||||
|
|
||||||
|
// Send out the chest-open packet:
|
||||||
|
m_World->BroadcastBlockAction(m_BlockX, m_BlockY, m_BlockZ, 1, 1, a_Chest->GetBlockType());
|
||||||
|
}
|
||||||
|
|
||||||
|
cChestWindow(cChestEntity * a_PrimaryChest, cChestEntity * a_SecondaryChest) :
|
||||||
|
cWindow(wtChest, (a_PrimaryChest->GetBlockType() == E_BLOCK_CHEST) ? "Double Chest" : "Double Trapped Chest"),
|
||||||
|
m_World(a_PrimaryChest->GetWorld()),
|
||||||
|
m_BlockX(a_PrimaryChest->GetPosX()),
|
||||||
|
m_BlockY(a_PrimaryChest->GetPosY()),
|
||||||
|
m_BlockZ(a_PrimaryChest->GetPosZ()),
|
||||||
|
m_PrimaryChest(a_PrimaryChest),
|
||||||
|
m_SecondaryChest(a_SecondaryChest)
|
||||||
|
{
|
||||||
|
m_SlotAreas.push_back(new cSlotAreaDoubleChest(a_PrimaryChest, a_SecondaryChest, *this));
|
||||||
|
m_SlotAreas.push_back(new cSlotAreaInventory(*this));
|
||||||
|
m_SlotAreas.push_back(new cSlotAreaHotBar(*this));
|
||||||
|
|
||||||
|
m_ShouldDistributeToHotbarFirst = false;
|
||||||
|
|
||||||
|
// Play the opening sound:
|
||||||
|
m_World->BroadcastSoundEffect("random.chestopen", (double)m_BlockX, (double)m_BlockY, (double)m_BlockZ, 1, 1);
|
||||||
|
|
||||||
|
// Send out the chest-open packet:
|
||||||
|
m_World->BroadcastBlockAction(m_BlockX, m_BlockY, m_BlockZ, 1, 1, a_PrimaryChest->GetBlockType());
|
||||||
|
}
|
||||||
|
|
||||||
|
~cChestWindow()
|
||||||
|
{
|
||||||
|
// Send out the chest-close packet:
|
||||||
|
m_World->BroadcastBlockAction(m_BlockX, m_BlockY, m_BlockZ, 1, 0, m_PrimaryChest->GetBlockType());
|
||||||
|
|
||||||
|
m_World->BroadcastSoundEffect("random.chestclosed", (double)m_BlockX, (double)m_BlockY, (double)m_BlockZ, 1, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual bool ClosedByPlayer(cPlayer & a_Player, bool a_CanRefuse) override
|
||||||
|
{
|
||||||
|
int ChunkX, ChunkZ;
|
||||||
|
|
||||||
|
m_PrimaryChest->SetNumberOfPlayers(m_PrimaryChest->GetNumberOfPlayers() - 1);
|
||||||
|
cChunkDef::BlockToChunk(m_PrimaryChest->GetPosX(), m_PrimaryChest->GetPosZ(), ChunkX, ChunkZ);
|
||||||
|
m_PrimaryChest->GetWorld()->MarkRedstoneDirty(ChunkX, ChunkZ);
|
||||||
|
|
||||||
|
if (m_SecondaryChest != nullptr)
|
||||||
|
{
|
||||||
|
m_SecondaryChest->SetNumberOfPlayers(m_SecondaryChest->GetNumberOfPlayers() - 1);
|
||||||
|
cChunkDef::BlockToChunk(m_SecondaryChest->GetPosX(), m_SecondaryChest->GetPosZ(), ChunkX, ChunkZ);
|
||||||
|
m_SecondaryChest->GetWorld()->MarkRedstoneDirty(ChunkX, ChunkZ);
|
||||||
|
}
|
||||||
|
|
||||||
|
cWindow::ClosedByPlayer(a_Player, a_CanRefuse);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual void OpenedByPlayer(cPlayer & a_Player) override
|
||||||
|
{
|
||||||
|
int ChunkX, ChunkZ;
|
||||||
|
|
||||||
|
m_PrimaryChest->SetNumberOfPlayers(m_PrimaryChest->GetNumberOfPlayers() + 1);
|
||||||
|
cChunkDef::BlockToChunk(m_PrimaryChest->GetPosX(), m_PrimaryChest->GetPosZ(), ChunkX, ChunkZ);
|
||||||
|
m_PrimaryChest->GetWorld()->MarkRedstoneDirty(ChunkX, ChunkZ);
|
||||||
|
|
||||||
|
if (m_SecondaryChest != nullptr)
|
||||||
|
{
|
||||||
|
m_SecondaryChest->SetNumberOfPlayers(m_SecondaryChest->GetNumberOfPlayers() + 1);
|
||||||
|
cChunkDef::BlockToChunk(m_SecondaryChest->GetPosX(), m_SecondaryChest->GetPosZ(), ChunkX, ChunkZ);
|
||||||
|
m_SecondaryChest->GetWorld()->MarkRedstoneDirty(ChunkX, ChunkZ);
|
||||||
|
}
|
||||||
|
|
||||||
|
cWindow::OpenedByPlayer(a_Player);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected:
|
||||||
|
cWorld * m_World;
|
||||||
|
int m_BlockX, m_BlockY, m_BlockZ; // Position of the chest, for the window-close packet
|
||||||
|
cChestEntity * m_PrimaryChest;
|
||||||
|
cChestEntity * m_SecondaryChest;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,35 @@
|
||||||
|
|
||||||
|
// CraftingWindow.h
|
||||||
|
|
||||||
|
// Representing the UI window for the crafting block
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "Window.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
class cCraftingWindow :
|
||||||
|
public cWindow
|
||||||
|
{
|
||||||
|
typedef cWindow super;
|
||||||
|
|
||||||
|
public:
|
||||||
|
cCraftingWindow(int a_BlockX, int a_BlockY, int a_BlockZ) :
|
||||||
|
cWindow(wtWorkbench, "Crafting Table")
|
||||||
|
{
|
||||||
|
m_SlotAreas.push_back(new cSlotAreaCrafting(3, *this));
|
||||||
|
m_SlotAreas.push_back(new cSlotAreaInventory(*this));
|
||||||
|
m_SlotAreas.push_back(new cSlotAreaHotBar(*this));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,37 @@
|
||||||
|
|
||||||
|
// DropSpenserWindow.h
|
||||||
|
|
||||||
|
// Representing the UI window for the dropper/dispenser block
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "Window.h"
|
||||||
|
#include "../BlockEntities/DropSpenserEntity.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
class cDropSpenserWindow :
|
||||||
|
public cWindow
|
||||||
|
{
|
||||||
|
typedef cWindow super;
|
||||||
|
|
||||||
|
public:
|
||||||
|
cDropSpenserWindow(int a_BlockX, int a_BlockY, int a_BlockZ, cDropSpenserEntity * a_DropSpenser) :
|
||||||
|
cWindow(wtDropSpenser, (a_DropSpenser->GetBlockType() == E_BLOCK_DISPENSER) ? "Dispenser" : "Dropper")
|
||||||
|
{
|
||||||
|
m_ShouldDistributeToHotbarFirst = false;
|
||||||
|
m_SlotAreas.push_back(new cSlotAreaItemGrid(a_DropSpenser->GetContents(), *this));
|
||||||
|
m_SlotAreas.push_back(new cSlotAreaInventory(*this));
|
||||||
|
m_SlotAreas.push_back(new cSlotAreaHotBar(*this));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,82 @@
|
||||||
|
|
||||||
|
// EnchantingWindow.h
|
||||||
|
|
||||||
|
// Representing the UI window for the enchanting block
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "Window.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
class cEnchantingWindow :
|
||||||
|
public cWindow
|
||||||
|
{
|
||||||
|
typedef cWindow super;
|
||||||
|
|
||||||
|
public:
|
||||||
|
cEnchantingWindow(int a_BlockX, int a_BlockY, int a_BlockZ) :
|
||||||
|
cWindow(wtEnchantment, "Enchant"),
|
||||||
|
m_SlotArea(),
|
||||||
|
m_BlockX(a_BlockX),
|
||||||
|
m_BlockY(a_BlockY),
|
||||||
|
m_BlockZ(a_BlockZ)
|
||||||
|
{
|
||||||
|
m_SlotArea = new cSlotAreaEnchanting(*this, m_BlockX, m_BlockY, m_BlockZ);
|
||||||
|
m_SlotAreas.push_back(m_SlotArea);
|
||||||
|
m_SlotAreas.push_back(new cSlotAreaInventory(*this));
|
||||||
|
m_SlotAreas.push_back(new cSlotAreaHotBar(*this));
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual void SetProperty(short a_Property, short a_Value, cPlayer & a_Player) override
|
||||||
|
{
|
||||||
|
if ((a_Property < 0) || ((size_t)a_Property >= ARRAYCOUNT(m_PropertyValue)))
|
||||||
|
{
|
||||||
|
ASSERT(!"a_Property is invalid");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
m_PropertyValue[a_Property] = a_Value;
|
||||||
|
super::SetProperty(a_Property, a_Value, a_Player);
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual void SetProperty(short a_Property, short a_Value) override
|
||||||
|
{
|
||||||
|
if ((a_Property < 0) || ((size_t)a_Property >= ARRAYCOUNT(m_PropertyValue)))
|
||||||
|
{
|
||||||
|
ASSERT(!"a_Property is invalid");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
m_PropertyValue[a_Property] = a_Value;
|
||||||
|
super::SetProperty(a_Property, a_Value);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Return the Value of a Property */
|
||||||
|
short GetPropertyValue(short a_Property)
|
||||||
|
{
|
||||||
|
if ((a_Property < 0) || ((size_t)a_Property >= ARRAYCOUNT(m_PropertyValue)))
|
||||||
|
{
|
||||||
|
ASSERT(!"a_Property is invalid");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return m_PropertyValue[a_Property];
|
||||||
|
}
|
||||||
|
|
||||||
|
cSlotArea * m_SlotArea;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
short m_PropertyValue[3];
|
||||||
|
int m_BlockX, m_BlockY, m_BlockZ;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,60 @@
|
||||||
|
|
||||||
|
// EnderChestWindow.h
|
||||||
|
|
||||||
|
// Representing the UI window for the enderchest block
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "Window.h"
|
||||||
|
#include "../BlockEntities/EnderChestEntity.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
class cEnderChestWindow :
|
||||||
|
public cWindow
|
||||||
|
{
|
||||||
|
typedef cWindow super;
|
||||||
|
|
||||||
|
public:
|
||||||
|
cEnderChestWindow(cEnderChestEntity * a_EnderChest) :
|
||||||
|
cWindow(wtChest, "Ender Chest"),
|
||||||
|
m_World(a_EnderChest->GetWorld()),
|
||||||
|
m_BlockX(a_EnderChest->GetPosX()),
|
||||||
|
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));
|
||||||
|
|
||||||
|
// Play the opening sound:
|
||||||
|
m_World->BroadcastSoundEffect("random.chestopen", (double)m_BlockX, (double)m_BlockY, (double)m_BlockZ, 1, 1);
|
||||||
|
|
||||||
|
// Send out the chest-open packet:
|
||||||
|
m_World->BroadcastBlockAction(m_BlockX, m_BlockY, m_BlockZ, 1, 1, E_BLOCK_ENDER_CHEST);
|
||||||
|
}
|
||||||
|
|
||||||
|
~cEnderChestWindow()
|
||||||
|
{
|
||||||
|
// Send out the chest-close packet:
|
||||||
|
m_World->BroadcastBlockAction(m_BlockX, m_BlockY, m_BlockZ, 1, 0, E_BLOCK_ENDER_CHEST);
|
||||||
|
|
||||||
|
// Play the closing sound
|
||||||
|
m_World->BroadcastSoundEffect("random.chestclosed", (double)m_BlockX, (double)m_BlockY, (double)m_BlockZ, 1, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected:
|
||||||
|
cWorld * m_World;
|
||||||
|
int m_BlockX, m_BlockY, m_BlockZ; // Position of the enderchest, for the window-close packet
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,36 @@
|
||||||
|
|
||||||
|
// FurnaceWindow.h
|
||||||
|
|
||||||
|
// Representing the UI window for the furnace block
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "Window.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
class cFurnaceWindow :
|
||||||
|
public cWindow
|
||||||
|
{
|
||||||
|
typedef cWindow super;
|
||||||
|
|
||||||
|
public:
|
||||||
|
cFurnaceWindow(int a_BlockX, int a_BlockY, int a_BlockZ, cFurnaceEntity * a_Furnace) :
|
||||||
|
cWindow(wtFurnace, "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));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,37 @@
|
||||||
|
|
||||||
|
// HopperWindow.h
|
||||||
|
|
||||||
|
// Representing the UI window for the hopper block
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "Window.h"
|
||||||
|
#include "../BlockEntities/DropperEntity.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
class cHopperWindow :
|
||||||
|
public cWindow
|
||||||
|
{
|
||||||
|
typedef cWindow super;
|
||||||
|
|
||||||
|
public:
|
||||||
|
cHopperWindow(int a_BlockX, int a_BlockY, int a_BlockZ, cHopperEntity * a_Hopper) :
|
||||||
|
super(wtHopper, "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));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,40 @@
|
||||||
|
|
||||||
|
// InventoryWindow.h
|
||||||
|
|
||||||
|
// Representing the UI window for the player inventory
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "Window.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
class cInventoryWindow :
|
||||||
|
public cWindow
|
||||||
|
{
|
||||||
|
typedef cWindow super;
|
||||||
|
|
||||||
|
public:
|
||||||
|
cInventoryWindow(cPlayer & a_Player) :
|
||||||
|
cWindow(wtInventory, "Inventory"),
|
||||||
|
m_Player(a_Player)
|
||||||
|
{
|
||||||
|
m_SlotAreas.push_back(new cSlotAreaCrafting(2, *this)); // The creative inventory doesn't display it, but it's still counted into slot numbers
|
||||||
|
m_SlotAreas.push_back(new cSlotAreaArmor(*this));
|
||||||
|
m_SlotAreas.push_back(new cSlotAreaInventory(*this));
|
||||||
|
m_SlotAreas.push_back(new cSlotAreaHotBar(*this));
|
||||||
|
}
|
||||||
|
|
||||||
|
protected:
|
||||||
|
cPlayer & m_Player;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,48 @@
|
||||||
|
|
||||||
|
// MinecartWithChestWindow.h
|
||||||
|
|
||||||
|
// Representing the UI window for the minecart chest entity
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "Window.h"
|
||||||
|
#include "../Entities/Minecart.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
class cMinecartWithChestWindow :
|
||||||
|
public cWindow
|
||||||
|
{
|
||||||
|
typedef cWindow super;
|
||||||
|
|
||||||
|
public:
|
||||||
|
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()
|
||||||
|
{
|
||||||
|
m_ChestCart->GetWorld()->BroadcastSoundEffect("random.chestclosed", m_ChestCart->GetPosX(), m_ChestCart->GetPosY(), m_ChestCart->GetPosZ(), 1, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
cMinecartWithChest * m_ChestCart;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
|
||||||
// SlotArea.cpp
|
// SlotArea.cpp
|
||||||
|
|
||||||
// Implements the cSlotArea class and its descendants
|
// Implements the cSlotArea class and its descendants
|
||||||
|
@ -12,6 +13,7 @@
|
||||||
#include "../BlockEntities/FurnaceEntity.h"
|
#include "../BlockEntities/FurnaceEntity.h"
|
||||||
#include "../Entities/Minecart.h"
|
#include "../Entities/Minecart.h"
|
||||||
#include "../Items/ItemHandler.h"
|
#include "../Items/ItemHandler.h"
|
||||||
|
#include "AnvilWindow.h"
|
||||||
#include "Window.h"
|
#include "Window.h"
|
||||||
#include "../CraftingRecipes.h"
|
#include "../CraftingRecipes.h"
|
||||||
#include "../Root.h"
|
#include "../Root.h"
|
||||||
|
@ -769,7 +771,7 @@ void cSlotAreaCrafting::HandleCraftItem(const cItem & a_Result, cPlayer & a_Play
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
// cSlotAreaAnvil:
|
// cSlotAreaAnvil:
|
||||||
|
|
||||||
cSlotAreaAnvil::cSlotAreaAnvil(cAnvilWindow & a_ParentWindow) :
|
cSlotAreaAnvil::cSlotAreaAnvil(cWindow & a_ParentWindow) :
|
||||||
cSlotAreaTemporary(3, a_ParentWindow),
|
cSlotAreaTemporary(3, a_ParentWindow),
|
||||||
m_MaximumCost(0),
|
m_MaximumCost(0),
|
||||||
m_StackSizeToBeUsedInRepair(0)
|
m_StackSizeToBeUsedInRepair(0)
|
||||||
|
@ -1390,13 +1392,12 @@ void cSlotAreaBeacon::OnSlotChanged(cItemGrid * a_ItemGrid, int a_SlotNum)
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
// cSlotAreaEnchanting:
|
// cSlotAreaEnchanting:
|
||||||
|
|
||||||
cSlotAreaEnchanting::cSlotAreaEnchanting(cEnchantingWindow & a_ParentWindow, int a_BlockX, int a_BlockY, int a_BlockZ) :
|
cSlotAreaEnchanting::cSlotAreaEnchanting(cWindow & a_ParentWindow, int a_BlockX, int a_BlockY, int a_BlockZ) :
|
||||||
cSlotAreaTemporary(1, a_ParentWindow),
|
cSlotAreaTemporary(1, a_ParentWindow),
|
||||||
m_BlockX(a_BlockX),
|
m_BlockX(a_BlockX),
|
||||||
m_BlockY(a_BlockY),
|
m_BlockY(a_BlockY),
|
||||||
m_BlockZ(a_BlockZ)
|
m_BlockZ(a_BlockZ)
|
||||||
{
|
{
|
||||||
a_ParentWindow.m_SlotArea = this;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -17,12 +17,10 @@ class cWindow;
|
||||||
class cPlayer;
|
class cPlayer;
|
||||||
class cBeaconEntity;
|
class cBeaconEntity;
|
||||||
class cChestEntity;
|
class cChestEntity;
|
||||||
class cDropSpenserEntity;
|
|
||||||
class cEnderChestEntity;
|
class cEnderChestEntity;
|
||||||
class cFurnaceEntity;
|
class cFurnaceEntity;
|
||||||
class cMinecartWithChest;
|
class cMinecartWithChest;
|
||||||
class cCraftingRecipe;
|
class cCraftingRecipe;
|
||||||
class cEnchantingWindow;
|
|
||||||
class cWorld;
|
class cWorld;
|
||||||
|
|
||||||
|
|
||||||
|
@ -285,7 +283,7 @@ class cSlotAreaAnvil :
|
||||||
typedef cSlotAreaTemporary super;
|
typedef cSlotAreaTemporary super;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
cSlotAreaAnvil(cAnvilWindow & a_ParentWindow);
|
cSlotAreaAnvil(cWindow & a_ParentWindow);
|
||||||
|
|
||||||
// cSlotArea overrides:
|
// cSlotArea overrides:
|
||||||
virtual void Clicked(cPlayer & a_Player, int a_SlotNum, eClickAction a_ClickAction, const cItem & a_ClickedItem) override;
|
virtual void Clicked(cPlayer & a_Player, int a_SlotNum, eClickAction a_ClickAction, const cItem & a_ClickedItem) override;
|
||||||
|
@ -350,7 +348,7 @@ class cSlotAreaEnchanting :
|
||||||
typedef cSlotAreaTemporary super;
|
typedef cSlotAreaTemporary super;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
cSlotAreaEnchanting(cEnchantingWindow & a_ParentWindow, int a_BlockX, int a_BlockY, int a_BlockZ);
|
cSlotAreaEnchanting(cWindow & a_ParentWindow, int a_BlockX, int a_BlockY, int a_BlockZ);
|
||||||
|
|
||||||
// cSlotArea overrides:
|
// cSlotArea overrides:
|
||||||
virtual void Clicked(cPlayer & a_Player, int a_SlotNum, eClickAction a_ClickAction, const cItem & a_ClickedItem) override;
|
virtual void Clicked(cPlayer & a_Player, int a_SlotNum, eClickAction a_ClickAction, const cItem & a_ClickedItem) override;
|
||||||
|
|
|
@ -779,401 +779,3 @@ void cWindow::SetProperty(short a_Property, short a_Value, cPlayer & a_Player)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// cInventoryWindow:
|
|
||||||
|
|
||||||
cInventoryWindow::cInventoryWindow(cPlayer & a_Player) :
|
|
||||||
cWindow(wtInventory, "Inventory"),
|
|
||||||
m_Player(a_Player)
|
|
||||||
{
|
|
||||||
m_SlotAreas.push_back(new cSlotAreaCrafting(2, *this)); // The creative inventory doesn't display it, but it's still counted into slot numbers
|
|
||||||
m_SlotAreas.push_back(new cSlotAreaArmor(*this));
|
|
||||||
m_SlotAreas.push_back(new cSlotAreaInventory(*this));
|
|
||||||
m_SlotAreas.push_back(new cSlotAreaHotBar(*this));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// cCraftingWindow:
|
|
||||||
|
|
||||||
cCraftingWindow::cCraftingWindow(int a_BlockX, int a_BlockY, int a_BlockZ) :
|
|
||||||
cWindow(wtWorkbench, "Crafting Table")
|
|
||||||
{
|
|
||||||
m_SlotAreas.push_back(new cSlotAreaCrafting(3, *this));
|
|
||||||
m_SlotAreas.push_back(new cSlotAreaInventory(*this));
|
|
||||||
m_SlotAreas.push_back(new cSlotAreaHotBar(*this));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// cAnvilWindow:
|
|
||||||
|
|
||||||
cAnvilWindow::cAnvilWindow(int a_BlockX, int a_BlockY, int a_BlockZ) :
|
|
||||||
cWindow(wtAnvil, "Repair"),
|
|
||||||
m_RepairedItemName(""),
|
|
||||||
m_BlockX(a_BlockX),
|
|
||||||
m_BlockY(a_BlockY),
|
|
||||||
m_BlockZ(a_BlockZ)
|
|
||||||
{
|
|
||||||
m_AnvilSlotArea = new cSlotAreaAnvil(*this);
|
|
||||||
m_SlotAreas.push_back(m_AnvilSlotArea);
|
|
||||||
m_SlotAreas.push_back(new cSlotAreaInventory(*this));
|
|
||||||
m_SlotAreas.push_back(new cSlotAreaHotBar(*this));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void cAnvilWindow::SetRepairedItemName(const AString & a_Name, cPlayer * a_Player)
|
|
||||||
{
|
|
||||||
m_RepairedItemName = a_Name;
|
|
||||||
|
|
||||||
if (a_Player != nullptr)
|
|
||||||
{
|
|
||||||
m_AnvilSlotArea->UpdateResult(*a_Player);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void cAnvilWindow::GetBlockPos(int & a_PosX, int & a_PosY, int & a_PosZ)
|
|
||||||
{
|
|
||||||
a_PosX = m_BlockX;
|
|
||||||
a_PosY = m_BlockY;
|
|
||||||
a_PosZ = m_BlockZ;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// cBeaconWindow:
|
|
||||||
|
|
||||||
cBeaconWindow::cBeaconWindow(int a_BlockX, int a_BlockY, int a_BlockZ, cBeaconEntity * a_Beacon) :
|
|
||||||
cWindow(wtBeacon, "Beacon"),
|
|
||||||
m_Beacon(a_Beacon)
|
|
||||||
{
|
|
||||||
m_ShouldDistributeToHotbarFirst = true;
|
|
||||||
m_SlotAreas.push_back(new cSlotAreaBeacon(m_Beacon, *this));
|
|
||||||
m_SlotAreas.push_back(new cSlotAreaInventory(*this));
|
|
||||||
m_SlotAreas.push_back(new cSlotAreaHotBar(*this));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void cBeaconWindow::OpenedByPlayer(cPlayer & a_Player)
|
|
||||||
{
|
|
||||||
super::OpenedByPlayer(a_Player);
|
|
||||||
|
|
||||||
a_Player.GetClientHandle()->SendWindowProperty(*this, 0, m_Beacon->GetBeaconLevel());
|
|
||||||
a_Player.GetClientHandle()->SendWindowProperty(*this, 1, m_Beacon->GetPrimaryEffect());
|
|
||||||
a_Player.GetClientHandle()->SendWindowProperty(*this, 2, m_Beacon->GetSecondaryEffect());
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// cEnchantingWindow:
|
|
||||||
|
|
||||||
cEnchantingWindow::cEnchantingWindow(int a_BlockX, int a_BlockY, int a_BlockZ) :
|
|
||||||
cWindow(wtEnchantment, "Enchant"),
|
|
||||||
m_SlotArea(),
|
|
||||||
m_BlockX(a_BlockX),
|
|
||||||
m_BlockY(a_BlockY),
|
|
||||||
m_BlockZ(a_BlockZ)
|
|
||||||
{
|
|
||||||
m_SlotAreas.push_back(new cSlotAreaEnchanting(*this, m_BlockX, m_BlockY, m_BlockZ));
|
|
||||||
m_SlotAreas.push_back(new cSlotAreaInventory(*this));
|
|
||||||
m_SlotAreas.push_back(new cSlotAreaHotBar(*this));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void cEnchantingWindow::SetProperty(short a_Property, short a_Value)
|
|
||||||
{
|
|
||||||
if ((a_Property < 0) || ((size_t)a_Property >= ARRAYCOUNT(m_PropertyValue)))
|
|
||||||
{
|
|
||||||
ASSERT(!"a_Property is invalid");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
m_PropertyValue[a_Property] = a_Value;
|
|
||||||
super::SetProperty(a_Property, a_Value);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void cEnchantingWindow::SetProperty(short a_Property, short a_Value, cPlayer & a_Player)
|
|
||||||
{
|
|
||||||
if ((a_Property < 0) || ((size_t)a_Property >= ARRAYCOUNT(m_PropertyValue)))
|
|
||||||
{
|
|
||||||
ASSERT(!"a_Property is invalid");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
m_PropertyValue[a_Property] = a_Value;
|
|
||||||
super::SetProperty(a_Property, a_Value, a_Player);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
short cEnchantingWindow::GetPropertyValue(short a_Property)
|
|
||||||
{
|
|
||||||
if ((a_Property < 0) || ((size_t)a_Property >= ARRAYCOUNT(m_PropertyValue)))
|
|
||||||
{
|
|
||||||
ASSERT(!"a_Property is invalid");
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
return m_PropertyValue[a_Property];
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// cChestWindow:
|
|
||||||
|
|
||||||
cChestWindow::cChestWindow(cChestEntity * a_Chest) :
|
|
||||||
cWindow(wtChest, (a_Chest->GetBlockType() == E_BLOCK_CHEST) ? "Chest" : "Trapped Chest"),
|
|
||||||
m_World(a_Chest->GetWorld()),
|
|
||||||
m_BlockX(a_Chest->GetPosX()),
|
|
||||||
m_BlockY(a_Chest->GetPosY()),
|
|
||||||
m_BlockZ(a_Chest->GetPosZ()),
|
|
||||||
m_PrimaryChest(a_Chest),
|
|
||||||
m_SecondaryChest(nullptr)
|
|
||||||
{
|
|
||||||
m_SlotAreas.push_back(new cSlotAreaChest(a_Chest, *this));
|
|
||||||
m_SlotAreas.push_back(new cSlotAreaInventory(*this));
|
|
||||||
m_SlotAreas.push_back(new cSlotAreaHotBar(*this));
|
|
||||||
|
|
||||||
// Play the opening sound:
|
|
||||||
m_World->BroadcastSoundEffect("random.chestopen", (double)m_BlockX, (double)m_BlockY, (double)m_BlockZ, 1, 1);
|
|
||||||
|
|
||||||
// Send out the chest-open packet:
|
|
||||||
m_World->BroadcastBlockAction(m_BlockX, m_BlockY, m_BlockZ, 1, 1, a_Chest->GetBlockType());
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
cChestWindow::cChestWindow(cChestEntity * a_PrimaryChest, cChestEntity * a_SecondaryChest) :
|
|
||||||
cWindow(wtChest, (a_PrimaryChest->GetBlockType() == E_BLOCK_CHEST) ? "Double Chest" : "Double Trapped Chest"),
|
|
||||||
m_World(a_PrimaryChest->GetWorld()),
|
|
||||||
m_BlockX(a_PrimaryChest->GetPosX()),
|
|
||||||
m_BlockY(a_PrimaryChest->GetPosY()),
|
|
||||||
m_BlockZ(a_PrimaryChest->GetPosZ()),
|
|
||||||
m_PrimaryChest(a_PrimaryChest),
|
|
||||||
m_SecondaryChest(a_SecondaryChest)
|
|
||||||
{
|
|
||||||
m_SlotAreas.push_back(new cSlotAreaDoubleChest(a_PrimaryChest, a_SecondaryChest, *this));
|
|
||||||
m_SlotAreas.push_back(new cSlotAreaInventory(*this));
|
|
||||||
m_SlotAreas.push_back(new cSlotAreaHotBar(*this));
|
|
||||||
|
|
||||||
m_ShouldDistributeToHotbarFirst = false;
|
|
||||||
|
|
||||||
// Play the opening sound:
|
|
||||||
m_World->BroadcastSoundEffect("random.chestopen", (double)m_BlockX, (double)m_BlockY, (double)m_BlockZ, 1, 1);
|
|
||||||
|
|
||||||
// Send out the chest-open packet:
|
|
||||||
m_World->BroadcastBlockAction(m_BlockX, m_BlockY, m_BlockZ, 1, 1, a_PrimaryChest->GetBlockType());
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void cChestWindow::OpenedByPlayer(cPlayer & a_Player)
|
|
||||||
{
|
|
||||||
int ChunkX, ChunkZ;
|
|
||||||
|
|
||||||
m_PrimaryChest->SetNumberOfPlayers(m_PrimaryChest->GetNumberOfPlayers() + 1);
|
|
||||||
cChunkDef::BlockToChunk(m_PrimaryChest->GetPosX(), m_PrimaryChest->GetPosZ(), ChunkX, ChunkZ);
|
|
||||||
m_PrimaryChest->GetWorld()->MarkRedstoneDirty(ChunkX, ChunkZ);
|
|
||||||
|
|
||||||
if (m_SecondaryChest != nullptr)
|
|
||||||
{
|
|
||||||
m_SecondaryChest->SetNumberOfPlayers(m_SecondaryChest->GetNumberOfPlayers() + 1);
|
|
||||||
cChunkDef::BlockToChunk(m_SecondaryChest->GetPosX(), m_SecondaryChest->GetPosZ(), ChunkX, ChunkZ);
|
|
||||||
m_SecondaryChest->GetWorld()->MarkRedstoneDirty(ChunkX, ChunkZ);
|
|
||||||
}
|
|
||||||
|
|
||||||
cWindow::OpenedByPlayer(a_Player);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
bool cChestWindow::ClosedByPlayer(cPlayer & a_Player, bool a_CanRefuse)
|
|
||||||
{
|
|
||||||
int ChunkX, ChunkZ;
|
|
||||||
|
|
||||||
m_PrimaryChest->SetNumberOfPlayers(m_PrimaryChest->GetNumberOfPlayers() - 1);
|
|
||||||
cChunkDef::BlockToChunk(m_PrimaryChest->GetPosX(), m_PrimaryChest->GetPosZ(), ChunkX, ChunkZ);
|
|
||||||
m_PrimaryChest->GetWorld()->MarkRedstoneDirty(ChunkX, ChunkZ);
|
|
||||||
|
|
||||||
if (m_SecondaryChest != nullptr)
|
|
||||||
{
|
|
||||||
m_SecondaryChest->SetNumberOfPlayers(m_SecondaryChest->GetNumberOfPlayers() - 1);
|
|
||||||
cChunkDef::BlockToChunk(m_SecondaryChest->GetPosX(), m_SecondaryChest->GetPosZ(), ChunkX, ChunkZ);
|
|
||||||
m_SecondaryChest->GetWorld()->MarkRedstoneDirty(ChunkX, ChunkZ);
|
|
||||||
}
|
|
||||||
|
|
||||||
cWindow::ClosedByPlayer(a_Player, a_CanRefuse);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
cChestWindow::~cChestWindow()
|
|
||||||
{
|
|
||||||
// Send out the chest-close packet:
|
|
||||||
m_World->BroadcastBlockAction(m_BlockX, m_BlockY, m_BlockZ, 1, 0, m_PrimaryChest->GetBlockType());
|
|
||||||
|
|
||||||
m_World->BroadcastSoundEffect("random.chestclosed", (double)m_BlockX, (double)m_BlockY, (double)m_BlockZ, 1, 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// 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) :
|
|
||||||
cWindow(wtDropSpenser, (a_DropSpenser->GetBlockType() == E_BLOCK_DISPENSER) ? "Dispenser" : "Dropper")
|
|
||||||
{
|
|
||||||
m_ShouldDistributeToHotbarFirst = false;
|
|
||||||
m_SlotAreas.push_back(new cSlotAreaItemGrid(a_DropSpenser->GetContents(), *this));
|
|
||||||
m_SlotAreas.push_back(new cSlotAreaInventory(*this));
|
|
||||||
m_SlotAreas.push_back(new cSlotAreaHotBar(*this));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// cEnderChestWindow:
|
|
||||||
|
|
||||||
cEnderChestWindow::cEnderChestWindow(cEnderChestEntity * a_EnderChest) :
|
|
||||||
cWindow(wtChest, "Ender Chest"),
|
|
||||||
m_World(a_EnderChest->GetWorld()),
|
|
||||||
m_BlockX(a_EnderChest->GetPosX()),
|
|
||||||
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));
|
|
||||||
|
|
||||||
// Play the opening sound:
|
|
||||||
m_World->BroadcastSoundEffect("random.chestopen", (double)m_BlockX, (double)m_BlockY, (double)m_BlockZ, 1, 1);
|
|
||||||
|
|
||||||
// Send out the chest-open packet:
|
|
||||||
m_World->BroadcastBlockAction(m_BlockX, m_BlockY, m_BlockZ, 1, 1, E_BLOCK_ENDER_CHEST);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
cEnderChestWindow::~cEnderChestWindow()
|
|
||||||
{
|
|
||||||
// Send out the chest-close packet:
|
|
||||||
m_World->BroadcastBlockAction(m_BlockX, m_BlockY, m_BlockZ, 1, 0, E_BLOCK_ENDER_CHEST);
|
|
||||||
|
|
||||||
// Play the closing sound
|
|
||||||
m_World->BroadcastSoundEffect("random.chestclosed", (double)m_BlockX, (double)m_BlockY, (double)m_BlockZ, 1, 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// cHopperWindow:
|
|
||||||
|
|
||||||
cHopperWindow::cHopperWindow(int a_BlockX, int a_BlockY, int a_BlockZ, cHopperEntity * a_Hopper) :
|
|
||||||
super(wtHopper, "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(wtFurnace, "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));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
186
src/UI/Window.h
186
src/UI/Window.h
|
@ -19,7 +19,6 @@ class cPlayer;
|
||||||
class cWindowOwner;
|
class cWindowOwner;
|
||||||
class cClientHandle;
|
class cClientHandle;
|
||||||
class cChestEntity;
|
class cChestEntity;
|
||||||
class cDropSpenserEntity;
|
|
||||||
class cEnderChestEntity;
|
class cEnderChestEntity;
|
||||||
class cFurnaceEntity;
|
class cFurnaceEntity;
|
||||||
class cHopperEntity;
|
class cHopperEntity;
|
||||||
|
@ -219,188 +218,3 @@ protected:
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class cCraftingWindow :
|
|
||||||
public cWindow
|
|
||||||
{
|
|
||||||
typedef cWindow super;
|
|
||||||
public:
|
|
||||||
cCraftingWindow(int a_BlockX, int a_BlockY, int a_BlockZ);
|
|
||||||
} ;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class cAnvilWindow :
|
|
||||||
public cWindow
|
|
||||||
{
|
|
||||||
typedef cWindow super;
|
|
||||||
public:
|
|
||||||
cAnvilWindow(int a_BlockX, int a_BlockY, int a_BlockZ);
|
|
||||||
|
|
||||||
/** Gets the repaired item name. */
|
|
||||||
AString GetRepairedItemName(void) const { return m_RepairedItemName; }
|
|
||||||
|
|
||||||
/** Set the repaired item name. */
|
|
||||||
void SetRepairedItemName(const AString & a_Name, cPlayer * a_Player);
|
|
||||||
|
|
||||||
/** Gets the Position from the Anvil */
|
|
||||||
void GetBlockPos(int & a_PosX, int & a_PosY, int & a_PosZ);
|
|
||||||
|
|
||||||
protected:
|
|
||||||
cSlotAreaAnvil * m_AnvilSlotArea;
|
|
||||||
AString m_RepairedItemName;
|
|
||||||
int m_BlockX, m_BlockY, m_BlockZ;
|
|
||||||
} ;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class cBeaconWindow :
|
|
||||||
public cWindow
|
|
||||||
{
|
|
||||||
typedef cWindow super;
|
|
||||||
public:
|
|
||||||
cBeaconWindow(int a_BlockX, int a_BlockY, int a_BlockZ, cBeaconEntity * a_Beacon);
|
|
||||||
|
|
||||||
cBeaconEntity * GetBeaconEntity(void) const { return m_Beacon; }
|
|
||||||
|
|
||||||
// cWindow Overrides:
|
|
||||||
virtual void OpenedByPlayer(cPlayer & a_Player) override;
|
|
||||||
|
|
||||||
protected:
|
|
||||||
cBeaconEntity * m_Beacon;
|
|
||||||
} ;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class cEnchantingWindow :
|
|
||||||
public cWindow
|
|
||||||
{
|
|
||||||
typedef cWindow super;
|
|
||||||
public:
|
|
||||||
cEnchantingWindow(int a_BlockX, int a_BlockY, int a_BlockZ);
|
|
||||||
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 */
|
|
||||||
short GetPropertyValue(short a_Property);
|
|
||||||
|
|
||||||
cSlotArea * m_SlotArea;
|
|
||||||
|
|
||||||
protected:
|
|
||||||
short m_PropertyValue[3];
|
|
||||||
int m_BlockX, m_BlockY, m_BlockZ;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class cFurnaceWindow :
|
|
||||||
public cWindow
|
|
||||||
{
|
|
||||||
typedef cWindow super;
|
|
||||||
public:
|
|
||||||
cFurnaceWindow(int a_BlockX, int a_BlockY, int a_BlockZ, cFurnaceEntity * a_Furnace);
|
|
||||||
} ;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class cDropSpenserWindow :
|
|
||||||
public cWindow
|
|
||||||
{
|
|
||||||
typedef cWindow super;
|
|
||||||
public:
|
|
||||||
cDropSpenserWindow(int a_BlockX, int a_BlockY, int a_BlockZ, cDropSpenserEntity * a_Dispenser);
|
|
||||||
} ;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class cHopperWindow :
|
|
||||||
public cWindow
|
|
||||||
{
|
|
||||||
typedef cWindow super;
|
|
||||||
public:
|
|
||||||
cHopperWindow(int a_BlockX, int a_BlockY, int a_BlockZ, cHopperEntity * a_Hopper);
|
|
||||||
} ;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class cChestWindow :
|
|
||||||
public cWindow
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
cChestWindow(cChestEntity * a_Chest);
|
|
||||||
cChestWindow(cChestEntity * a_PrimaryChest, cChestEntity * a_SecondaryChest);
|
|
||||||
~cChestWindow();
|
|
||||||
|
|
||||||
virtual bool ClosedByPlayer(cPlayer & a_Player, bool a_CanRefuse) override;
|
|
||||||
virtual void OpenedByPlayer(cPlayer & a_Player) override;
|
|
||||||
|
|
||||||
protected:
|
|
||||||
cWorld * m_World;
|
|
||||||
int m_BlockX, m_BlockY, m_BlockZ; // Position of the chest, for the window-close packet
|
|
||||||
cChestEntity * m_PrimaryChest;
|
|
||||||
cChestEntity * m_SecondaryChest;
|
|
||||||
} ;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class cMinecartWithChestWindow :
|
|
||||||
public cWindow
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
cMinecartWithChestWindow(cMinecartWithChest * a_ChestCart);
|
|
||||||
~cMinecartWithChestWindow();
|
|
||||||
private:
|
|
||||||
cMinecartWithChest * m_ChestCart;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class cEnderChestWindow :
|
|
||||||
public cWindow
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
cEnderChestWindow(cEnderChestEntity * a_EnderChest);
|
|
||||||
~cEnderChestWindow();
|
|
||||||
|
|
||||||
protected:
|
|
||||||
cWorld * m_World;
|
|
||||||
int m_BlockX, m_BlockY, m_BlockZ; // Position of the enderchest, for the window-close packet
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class cInventoryWindow :
|
|
||||||
public cWindow
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
cInventoryWindow(cPlayer & a_Player);
|
|
||||||
|
|
||||||
protected:
|
|
||||||
cPlayer & m_Player;
|
|
||||||
|
|
||||||
} ;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue