diff options
Diffstat (limited to 'src/UI')
-rw-r--r-- | src/UI/SlotArea.cpp | 86 | ||||
-rw-r--r-- | src/UI/SlotArea.h | 28 | ||||
-rw-r--r-- | src/UI/Window.cpp | 15 | ||||
-rw-r--r-- | src/UI/Window.h | 12 |
4 files changed, 141 insertions, 0 deletions
diff --git a/src/UI/SlotArea.cpp b/src/UI/SlotArea.cpp index bfcad3d92..ae6bfccb5 100644 --- a/src/UI/SlotArea.cpp +++ b/src/UI/SlotArea.cpp @@ -563,6 +563,92 @@ 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) +{ + LOG("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) +{ + LOG("Click!"); + + if (a_Player.GetDraggingItem().IsEmpty()) + { + LOG("EMPTY"); + this->m_ParentWindow.SetProperty(0, NULL); + this->m_ParentWindow.SetProperty(1, NULL); + this->m_ParentWindow.SetProperty(2, NULL); + } + else if (a_Player.GetDraggingItem().IsEnchantable) + { + LOG("Enchantable"); + this->m_ParentWindow.SetProperty(0, 30); + this->m_ParentWindow.SetProperty(1, 20); + this->m_ParentWindow.SetProperty(2, 10); + } + else + { + LOG("Not Enchantable"); + this->m_ParentWindow.SetProperty(0, NULL); + this->m_ParentWindow.SetProperty(1, NULL); + this->m_ParentWindow.SetProperty(2, NULL); + } +} + + + + + +void cSlotAreaEnchanting::ShiftClickedResult(cPlayer & a_Player) +{ + LOG("Shift Click!"); +} + + + + + +/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // cSlotAreaEnderChest: cSlotAreaEnderChest::cSlotAreaEnderChest(cEnderChestEntity * a_EnderChest, cWindow & a_ParentWindow) : diff --git a/src/UI/SlotArea.h b/src/UI/SlotArea.h index d31c87e0c..bd5c66c77 100644 --- a/src/UI/SlotArea.h +++ b/src/UI/SlotArea.h @@ -252,6 +252,34 @@ protected: +class cSlotAreaEnchanting : + public cSlotAreaTemporary +{ + typedef cSlotAreaTemporary super; + +public: + /// a_GridSize is allowed to be only 2 or 3 + cSlotAreaEnchanting(int a_NumSlots, cWindow & a_ParentWindow); + + // cSlotAreaTemporary overrides: + virtual void Clicked(cPlayer & a_Player, int a_SlotNum, eClickAction a_ClickAction, const cItem & a_ClickedItem) override; + virtual void OnPlayerRemoved(cPlayer & a_Player) override; + + // Distributing items into this area is completely disabled + virtual void DistributeStack(cItem & a_ItemStack, cPlayer & a_Player, bool a_ShouldApply, bool a_KeepEmptySlots) override {} + +protected: + /// Handles a click in the result slot. Crafts using the current recipe, if possible + void ClickedResult(cPlayer & a_Player); + + /// Handles a shift-click in the result slot. Crafts using the current recipe until it changes or no more space for result. + void ShiftClickedResult(cPlayer & a_Player); +}; + + + + + class cSlotAreaChest : public cSlotArea { diff --git a/src/UI/Window.cpp b/src/UI/Window.cpp index 3ffeff7a0..fcfe6faf3 100644 --- a/src/UI/Window.cpp +++ b/src/UI/Window.cpp @@ -782,6 +782,21 @@ 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, "Enchantment Table") +{ + m_SlotAreas.push_back(new cSlotAreaEnchanting(1, *this)); + m_SlotAreas.push_back(new cSlotAreaInventory(*this)); + m_SlotAreas.push_back(new cSlotAreaHotBar(*this)); +} + + + + + +/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // cChestWindow: cChestWindow::cChestWindow(cChestEntity * a_Chest) : diff --git a/src/UI/Window.h b/src/UI/Window.h index 030182888..cdaec5aaa 100644 --- a/src/UI/Window.h +++ b/src/UI/Window.h @@ -231,6 +231,18 @@ public: +class cEnchantingWindow : + public cWindow +{ + typedef cWindow super; +public: + cEnchantingWindow(int a_BlockX, int a_BlockY, int a_BlockZ); +}; + + + + + class cFurnaceWindow : public cWindow { |