summaryrefslogtreecommitdiffstats
path: root/src/UI
diff options
context:
space:
mode:
authordaniel0916 <theschokolps@gmail.com>2014-04-12 14:58:46 +0200
committerdaniel0916 <theschokolps@gmail.com>2014-04-12 14:58:46 +0200
commite6e702e7fdbc8b7475d3dbecc0f81a08304997ae (patch)
tree1764949b84b4ae7a9da2330a90513c301d707820 /src/UI
parentModified comment (diff)
downloadcuberite-e6e702e7fdbc8b7475d3dbecc0f81a08304997ae.tar
cuberite-e6e702e7fdbc8b7475d3dbecc0f81a08304997ae.tar.gz
cuberite-e6e702e7fdbc8b7475d3dbecc0f81a08304997ae.tar.bz2
cuberite-e6e702e7fdbc8b7475d3dbecc0f81a08304997ae.tar.lz
cuberite-e6e702e7fdbc8b7475d3dbecc0f81a08304997ae.tar.xz
cuberite-e6e702e7fdbc8b7475d3dbecc0f81a08304997ae.tar.zst
cuberite-e6e702e7fdbc8b7475d3dbecc0f81a08304997ae.zip
Diffstat (limited to 'src/UI')
-rw-r--r--src/UI/SlotArea.cpp49
-rw-r--r--src/UI/Window.cpp86
-rw-r--r--src/UI/Window.h20
3 files changed, 135 insertions, 20 deletions
diff --git a/src/UI/SlotArea.cpp b/src/UI/SlotArea.cpp
index 9463bc593..f76b11380 100644
--- a/src/UI/SlotArea.cpp
+++ b/src/UI/SlotArea.cpp
@@ -608,7 +608,6 @@ cSlotAreaTemporary(a_NumSlots, a_ParentWindow)
void cSlotAreaEnchanting::Clicked(cPlayer & a_Player, int a_SlotNum, eClickAction a_ClickAction, const cItem & a_ClickedItem)
{
- LOGWARN("Clicked");
// Check if Slot is in the Enchantment Table
if (a_SlotNum == 0)
{
@@ -642,17 +641,39 @@ void cSlotAreaEnchanting::OnPlayerRemoved(cPlayer & a_Player)
void cSlotAreaEnchanting::ClickedResult(cPlayer & a_Player)
{
- LOGWARN("Click!");
-
if (a_Player.GetDraggingItem().IsEmpty())
{
- LOGWARN("EMPTY");
- m_ParentWindow.SetProperty(0, 0);
- m_ParentWindow.SetProperty(1, 0);
- m_ParentWindow.SetProperty(2, 0);
+ m_ParentWindow.SetProperty(0, 0, a_Player);
+ m_ParentWindow.SetProperty(1, 0, a_Player);
+ m_ParentWindow.SetProperty(2, 0, a_Player);
}
else if (a_Player.GetDraggingItem().IsEnchantable)
{
+ int PosX = 0;
+ int PosY = 0;
+ int PosZ = 0;
+ cEnchantingWindow * Window = (cEnchantingWindow*)&m_ParentWindow;
+ Window->GetBlockPos(PosX, PosY, PosZ);
+
+ cBlockArea Area;
+ Area.Read(a_Player.GetWorld(), PosX - 2, PosX + 2, PosY, PosY + 1, PosZ - 2, PosZ + 2);
+
+ for (int x = 0; x < 7; x++)
+ {
+ for (int y = 0; y < 2; y++)
+ {
+ for (int z = 0; z < 7; z++)
+ {
+ LOG(Printf("%i", Area.GetBlockType(x, y, z)).c_str());
+
+ if (Area.GetBlockType(x, y, z) == E_BLOCK_BOOKCASE)
+ {
+ LOG("BookShelf");
+ }
+ }
+ }
+ }
+
int bookshelves = 15; // TODO: Check Bookshelves
cFastRandom Random;
@@ -661,17 +682,15 @@ void cSlotAreaEnchanting::ClickedResult(cPlayer & a_Player)
int middleSlot = (base * 2) / 3 + 1;
int bottomSlot = std::max(base, bookshelves * 2);
- LOGWARN("Enchantable");
- m_ParentWindow.SetProperty(0, topSlot);
- m_ParentWindow.SetProperty(1, middleSlot);
- m_ParentWindow.SetProperty(2, bottomSlot);
+ m_ParentWindow.SetProperty(0, topSlot, a_Player);
+ m_ParentWindow.SetProperty(1, middleSlot, a_Player);
+ m_ParentWindow.SetProperty(2, bottomSlot, a_Player);
}
else
{
- LOGWARN("Not Enchantable");
- m_ParentWindow.SetProperty(0, 0);
- m_ParentWindow.SetProperty(1, 0);
- m_ParentWindow.SetProperty(2, 0);
+ m_ParentWindow.SetProperty(0, 0, a_Player);
+ m_ParentWindow.SetProperty(1, 0, a_Player);
+ m_ParentWindow.SetProperty(2, 0, a_Player);
}
}
diff --git a/src/UI/Window.cpp b/src/UI/Window.cpp
index 5d89534dd..c514e76e7 100644
--- a/src/UI/Window.cpp
+++ b/src/UI/Window.cpp
@@ -808,7 +808,10 @@ cCraftingWindow::cCraftingWindow(int a_BlockX, int a_BlockY, int a_BlockZ) :
// cEnchantingWindow:
cEnchantingWindow::cEnchantingWindow(int a_BlockX, int a_BlockY, int a_BlockZ) :
-cWindow(wtEnchantment, "Enchant")
+ cWindow(wtEnchantment, "Enchant"),
+ m_BlockX(a_BlockX),
+ m_BlockY(a_BlockY),
+ m_BlockZ(a_BlockZ)
{
m_SlotAreas.push_back(new cSlotAreaEnchanting(1, *this));
m_SlotAreas.push_back(new cSlotAreaInventory(*this));
@@ -819,6 +822,87 @@ cWindow(wtEnchantment, "Enchant")
+void cEnchantingWindow::SetProperty(int a_Property, int a_Value)
+{
+ if (a_Property == 0)
+ {
+ m_PropertyValue0 = a_Value;
+ }
+ else if (a_Property == 1)
+ {
+ m_PropertyValue1 = a_Value;
+ }
+ else if (a_Property == 2)
+ {
+ m_PropertyValue2 = a_Value;
+ }
+
+ cCSLock Lock(m_CS);
+ for (cPlayerList::iterator itr = m_OpenedBy.begin(), end = m_OpenedBy.end(); itr != end; ++itr)
+ {
+ (*itr)->GetClientHandle()->SendWindowProperty(*this, a_Property, a_Value);
+ } // for itr - m_OpenedBy[]
+}
+
+
+
+
+
+void cEnchantingWindow::SetProperty(int a_Property, int a_Value, cPlayer & a_Player)
+{
+ if (a_Property == 0)
+ {
+ m_PropertyValue0 = a_Value;
+ }
+ else if (a_Property == 1)
+ {
+ m_PropertyValue1 = a_Value;
+ }
+ else if (a_Property == 2)
+ {
+ m_PropertyValue2 = a_Value;
+ }
+
+ a_Player.GetClientHandle()->SendWindowProperty(*this, a_Property, a_Value);
+}
+
+
+
+
+
+int cEnchantingWindow::GetPropertyValue(int a_Property)
+{
+ if (a_Property == 0)
+ {
+ return m_PropertyValue0;
+ }
+ else if (a_Property == 1)
+ {
+ return m_PropertyValue1;
+ }
+ else if (a_Property == 2)
+ {
+ return m_PropertyValue2;
+ }
+
+ return -1;
+}
+
+
+
+
+
+void cEnchantingWindow::GetBlockPos(int & a_PosX, int & a_PosY, int & a_PosZ)
+{
+ a_PosX = m_BlockX;
+ a_PosY = m_BlockY;
+ a_PosZ = m_BlockZ;
+}
+
+
+
+
+
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// cChestWindow:
diff --git a/src/UI/Window.h b/src/UI/Window.h
index cdaec5aaa..52ab6c3ae 100644
--- a/src/UI/Window.h
+++ b/src/UI/Window.h
@@ -136,11 +136,11 @@ public:
void SetWindowTitle(const AString & a_WindowTitle ) { m_WindowTitle = a_WindowTitle; }
/// Sends the UpdateWindowProperty (0x69) packet to all clients of the window
- void SetProperty(int a_Property, int a_Value);
+ virtual void SetProperty(int a_Property, int a_Value);
/// Sends the UpdateWindowPropert(0x69) packet to the specified player
- void SetProperty(int a_Property, int a_Value, cPlayer & a_Player);
-
+ virtual void SetProperty(int a_Property, int a_Value, cPlayer & a_Player);
+
// tolua_end
void OwnerDestroyed(void);
@@ -165,7 +165,7 @@ public:
/// Used by cSlotAreas to send individual slots to clients, a_RelativeSlotNum is the slot number relative to a_SlotArea
void SendSlot(cPlayer & a_Player, cSlotArea * a_SlotArea, int a_RelativeSlotNum);
-
+
protected:
cSlotAreas m_SlotAreas;
@@ -237,6 +237,18 @@ 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;
+
+ /** Return the Value of a Property */
+ int GetPropertyValue(int a_Property);
+
+ /** Set the Position Values to the Position of the Enchantment Table */
+ void GetBlockPos(int & a_PosX, int & a_PosY, int & a_PosZ);
+
+protected:
+ int m_PropertyValue0, m_PropertyValue1, m_PropertyValue2;
+ int m_BlockX, m_BlockY, m_BlockZ;
};