From 0c2b307eab67b7f37d82a7862a6acbcd96b45adb Mon Sep 17 00:00:00 2001 From: daniel0916 Date: Mon, 20 Jan 2014 18:22:08 +0100 Subject: first changes for enchanting (not finished) - added enchanting table block handler and added it to the blockhandler - added enchanting window - drop item in the slot 0 when the player close the window - added enchanting packet (1.7 only) - some more... --- src/UI/SlotArea.h | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'src/UI/SlotArea.h') 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 { -- cgit v1.2.3 From 856e900bf8e74cb478904d6322dcb6310ff7a3b2 Mon Sep 17 00:00:00 2001 From: daniel0916 Date: Mon, 14 Apr 2014 11:48:12 +0200 Subject: Bug fixes --- src/UI/SlotArea.h | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) (limited to 'src/UI/SlotArea.h') diff --git a/src/UI/SlotArea.h b/src/UI/SlotArea.h index 82360ffbe..7feb74aa1 100644 --- a/src/UI/SlotArea.h +++ b/src/UI/SlotArea.h @@ -258,21 +258,17 @@ class cSlotAreaEnchanting : 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 + /// Handles a click in the item slot. 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. + /// Handles a shift-click in the item slot. void ShiftClickedResult(cPlayer & a_Player); }; -- cgit v1.2.3 From a51a099c81f34f875c76d560e6729889b2fdd4fa Mon Sep 17 00:00:00 2001 From: daniel0916 Date: Mon, 14 Apr 2014 13:39:44 +0200 Subject: Blocked enchanting a item twice --- src/UI/SlotArea.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/UI/SlotArea.h') diff --git a/src/UI/SlotArea.h b/src/UI/SlotArea.h index 7feb74aa1..a6af72273 100644 --- a/src/UI/SlotArea.h +++ b/src/UI/SlotArea.h @@ -266,10 +266,10 @@ public: protected: /// Handles a click in the item slot. - void ClickedResult(cPlayer & a_Player); + void ClickedSlot(cPlayer & a_Player); /// Handles a shift-click in the item slot. - void ShiftClickedResult(cPlayer & a_Player); + void ShiftClickedSlot(cPlayer & a_Player); }; -- cgit v1.2.3 From b5401ec03ad74782129e6a68eac3e9c0ccb573e2 Mon Sep 17 00:00:00 2001 From: daniel0916 Date: Mon, 14 Apr 2014 22:05:04 +0200 Subject: Added ItemPlaceCount in SlotArea Thanks to Howaner for helping --- src/UI/SlotArea.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/UI/SlotArea.h') diff --git a/src/UI/SlotArea.h b/src/UI/SlotArea.h index a6af72273..431ad753c 100644 --- a/src/UI/SlotArea.h +++ b/src/UI/SlotArea.h @@ -66,6 +66,8 @@ public: /// If a_CollectFullStacks is false, slots with full stacks are skipped while collecting. /// Returns true if full stack has been collected in a_Dragging, false if there's space remaining to fill. virtual bool CollectItemsToHand(cItem & a_Dragging, cPlayer & a_Player, bool a_CollectFullStacks); + + virtual int GetItemPlaceCount(cItem & a_Item); protected: int m_NumSlots; @@ -263,6 +265,7 @@ public: // 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; + virtual int GetItemPlaceCount(cItem & a_Item) override; protected: /// Handles a click in the item slot. -- cgit v1.2.3 From e81fc2779e4b9a8ce847d63864537259033c9cb9 Mon Sep 17 00:00:00 2001 From: Howaner Date: Tue, 15 Apr 2014 21:10:44 +0200 Subject: Add more checks to cSlotAreaEnchanting --- src/UI/SlotArea.h | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) (limited to 'src/UI/SlotArea.h') diff --git a/src/UI/SlotArea.h b/src/UI/SlotArea.h index 431ad753c..bab1098bb 100644 --- a/src/UI/SlotArea.h +++ b/src/UI/SlotArea.h @@ -19,6 +19,8 @@ class cDropSpenserEntity; class cEnderChestEntity; class cFurnaceEntity; class cCraftingRecipe; +class cEnchantingWindow; +class cWorld; @@ -67,8 +69,6 @@ public: /// Returns true if full stack has been collected in a_Dragging, false if there's space remaining to fill. virtual bool CollectItemsToHand(cItem & a_Dragging, cPlayer & a_Player, bool a_CollectFullStacks); - virtual int GetItemPlaceCount(cItem & a_Item); - protected: int m_NumSlots; cWindow & m_ParentWindow; @@ -260,19 +260,22 @@ class cSlotAreaEnchanting : typedef cSlotAreaTemporary super; public: - cSlotAreaEnchanting(int a_NumSlots, cWindow & a_ParentWindow); + cSlotAreaEnchanting(cEnchantingWindow & a_ParentWindow); - // cSlotAreaTemporary overrides: + // cSlotArea overrides: virtual void Clicked(cPlayer & a_Player, int a_SlotNum, eClickAction a_ClickAction, const cItem & a_ClickedItem) override; + virtual void DblClicked(cPlayer & a_Player, int a_SlotNum) override; + virtual void DistributeStack(cItem & a_ItemStack, cPlayer & a_Player, bool a_ShouldApply, bool a_KeepEmptySlots) override; + + // cSlotAreaTemporary overrides: virtual void OnPlayerRemoved(cPlayer & a_Player) override; - virtual int GetItemPlaceCount(cItem & a_Item) override; -protected: - /// Handles a click in the item slot. - void ClickedSlot(cPlayer & a_Player); + /* Get the count of bookshelves who stand in the near of the enchanting table */ + int GetBookshelvesCount(cWorld * a_World); - /// Handles a shift-click in the item slot. - void ShiftClickedSlot(cPlayer & a_Player); +protected: + /** Handles a click in the item slot. */ + void UpdateResult(cPlayer & a_Player); }; -- cgit v1.2.3 From 9cbb3a339f98f1737ea78af7f40e1ae7d25027e8 Mon Sep 17 00:00:00 2001 From: Howaner Date: Thu, 24 Apr 2014 20:41:25 +0200 Subject: Fix armor in survival mode. --- src/UI/SlotArea.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'src/UI/SlotArea.h') diff --git a/src/UI/SlotArea.h b/src/UI/SlotArea.h index bab1098bb..254722822 100644 --- a/src/UI/SlotArea.h +++ b/src/UI/SlotArea.h @@ -145,8 +145,13 @@ public: { } - // Distributing the stack is allowed only for compatible items (helmets into helmet slot etc.) + /** Distributing the stack is allowed only for compatible items (helmets into helmet slot etc.) */ virtual void DistributeStack(cItem & a_ItemStack, cPlayer & a_Player, bool a_ShouldApply, bool a_KeepEmptySlots) override; + + /** Called when a player clicks in the window. Parameters taken from the click packet. */ + virtual void Clicked(cPlayer & a_Player, int a_SlotNum, eClickAction a_ClickAction, const cItem & a_ClickedItem) override; + + bool CanPlaceInSlot(int a_SlotNum, const cItem & a_Item); } ; -- cgit v1.2.3