summaryrefslogtreecommitdiffstats
path: root/src/UI/SlotArea.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/UI/SlotArea.cpp')
-rw-r--r--src/UI/SlotArea.cpp96
1 files changed, 96 insertions, 0 deletions
diff --git a/src/UI/SlotArea.cpp b/src/UI/SlotArea.cpp
index 88977e005..9463bc593 100644
--- a/src/UI/SlotArea.cpp
+++ b/src/UI/SlotArea.cpp
@@ -13,6 +13,8 @@
#include "Window.h"
#include "../CraftingRecipes.h"
#include "../Root.h"
+#include "../FastRandom.h"
+#include "../BlockArea.h"
@@ -593,6 +595,100 @@ cCraftingRecipe & cSlotAreaCrafting::GetRecipeForPlayer(cPlayer & a_Player)
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+// cSlotAreaEnchanting:
+
+cSlotAreaEnchanting::cSlotAreaEnchanting(int a_NumSlots, cWindow & a_ParentWindow) :
+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)
+ {
+ if ((a_ClickAction == caShiftLeftClick) || (a_ClickAction == caShiftRightClick))
+ {
+ ShiftClickedResult(a_Player);
+ }
+ else
+ {
+ ClickedResult(a_Player);
+ }
+ return;
+ }
+ super::Clicked(a_Player, a_SlotNum, a_ClickAction, a_ClickedItem);
+}
+
+
+
+
+
+void cSlotAreaEnchanting::OnPlayerRemoved(cPlayer & a_Player)
+{
+ // Toss the item in the enchanting slot
+ TossItems(a_Player, 0, 0);
+ // Player not found - that is acceptable
+}
+
+
+
+
+
+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);
+ }
+ else if (a_Player.GetDraggingItem().IsEnchantable)
+ {
+ int bookshelves = 15; // TODO: Check Bookshelves
+
+ cFastRandom Random;
+ int base = (Random.GenerateRandomInteger(1, 8) + floor(bookshelves / 2) + Random.GenerateRandomInteger(0, bookshelves));
+ int topSlot = std::max(base / 3, 1);
+ 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);
+ }
+ else
+ {
+ LOGWARN("Not Enchantable");
+ m_ParentWindow.SetProperty(0, 0);
+ m_ParentWindow.SetProperty(1, 0);
+ m_ParentWindow.SetProperty(2, 0);
+ }
+}
+
+
+
+
+
+void cSlotAreaEnchanting::ShiftClickedResult(cPlayer & a_Player)
+{
+ LOGWARN("Shift Click!");
+}
+
+
+
+
+
+///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// cSlotAreaEnderChest:
cSlotAreaEnderChest::cSlotAreaEnderChest(cEnderChestEntity * a_EnderChest, cWindow & a_ParentWindow) :