summaryrefslogtreecommitdiffstats
path: root/src/UI
diff options
context:
space:
mode:
Diffstat (limited to 'src/UI')
-rw-r--r--src/UI/SlotArea.cpp30
-rw-r--r--src/UI/SlotArea.h6
-rw-r--r--src/UI/Window.cpp33
-rw-r--r--src/UI/WindowOwner.h4
4 files changed, 65 insertions, 8 deletions
diff --git a/src/UI/SlotArea.cpp b/src/UI/SlotArea.cpp
index 03bfd275a..9463bc593 100644
--- a/src/UI/SlotArea.cpp
+++ b/src/UI/SlotArea.cpp
@@ -226,6 +226,24 @@ void cSlotArea::DblClicked(cPlayer & a_Player, int a_SlotNum)
+void cSlotArea::OnPlayerAdded(cPlayer & a_Player)
+{
+ UNUSED(a_Player);
+}
+
+
+
+
+
+void cSlotArea::OnPlayerRemoved(cPlayer & a_Player)
+{
+ UNUSED(a_Player);
+}
+
+
+
+
+
void cSlotArea::DistributeStack(cItem & a_ItemStack, cPlayer & a_Player, bool a_Apply, bool a_KeepEmptySlots)
{
for (int i = 0; i < m_NumSlots; i++)
@@ -449,6 +467,18 @@ void cSlotAreaCrafting::OnPlayerRemoved(cPlayer & a_Player)
+
+void cSlotAreaCrafting::DistributeStack(cItem & a_ItemStack, cPlayer & a_Player, bool a_ShouldApply, bool a_KeepEmptySlots)
+{
+ UNUSED(a_ItemStack);
+ UNUSED(a_Player);
+ UNUSED(a_ShouldApply);
+ UNUSED(a_KeepEmptySlots);
+}
+
+
+
+
void cSlotAreaCrafting::ClickedResult(cPlayer & a_Player)
{
cItem & DraggingItem = a_Player.GetDraggingItem();
diff --git a/src/UI/SlotArea.h b/src/UI/SlotArea.h
index bd5c66c77..82360ffbe 100644
--- a/src/UI/SlotArea.h
+++ b/src/UI/SlotArea.h
@@ -48,10 +48,10 @@ public:
virtual void DblClicked(cPlayer & a_Player, int a_SlotNum);
/// Called when a new player opens the same parent window. The window already tracks the player. CS-locked.
- virtual void OnPlayerAdded(cPlayer & a_Player) {} ;
+ virtual void OnPlayerAdded(cPlayer & a_Player);
/// Called when one of the players closes the parent window. The window already doesn't track the player. CS-locked.
- virtual void OnPlayerRemoved(cPlayer & a_Player) {} ;
+ virtual void OnPlayerRemoved(cPlayer & a_Player);
/** Called to store as much of a_ItemStack in the area as possible. a_ItemStack is modified to reflect the change.
The default implementation searches each slot for available space and distributes the stack there.
@@ -226,7 +226,7 @@ public:
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 {}
+ virtual void DistributeStack(cItem & a_ItemStack, cPlayer & a_Player, bool a_ShouldApply, bool a_KeepEmptySlots) override;
protected:
/// Maps player's EntityID -> current recipe; not a std::map because cCraftingGrid needs proper constructor params
diff --git a/src/UI/Window.cpp b/src/UI/Window.cpp
index 9188b47a7..5d89534dd 100644
--- a/src/UI/Window.cpp
+++ b/src/UI/Window.cpp
@@ -13,7 +13,8 @@
#include "../BlockEntities/DropSpenserEntity.h"
#include "../BlockEntities/EnderChestEntity.h"
#include "../BlockEntities/HopperEntity.h"
-
+#include "../Root.h"
+#include "../Bindings/PluginManager.h"
@@ -169,6 +170,7 @@ void cWindow::Clicked(
const cItem & a_ClickedItem
)
{
+ cPluginManager * PlgMgr = cRoot::Get()->GetPluginManager();
if (a_WindowID != m_WindowID)
{
LOGWARNING("%s: Wrong window ID (exp %d, got %d) received from \"%s\"; ignoring click.", __FUNCTION__, m_WindowID, a_WindowID, a_Player.GetName().c_str());
@@ -179,14 +181,35 @@ void cWindow::Clicked(
{
case caRightClickOutside:
{
+ if (PlgMgr->CallHookPlayerTossingItem(a_Player))
+ {
+ // A plugin doesn't agree with the tossing. The plugin itself is responsible for handling the consequences (possible inventory mismatch)
+ return;
+ }
+ if (a_Player.IsGameModeCreative())
+ {
+ a_Player.TossPickup(a_ClickedItem);
+ }
+
// Toss one of the dragged items:
- a_Player.TossItem(true);
+ a_Player.TossHeldItem();
return;
}
case caLeftClickOutside:
{
+ if (PlgMgr->CallHookPlayerTossingItem(a_Player))
+ {
+ // A plugin doesn't agree with the tossing. The plugin itself is responsible for handling the consequences (possible inventory mismatch)
+ return;
+ }
+
+ if (a_Player.IsGameModeCreative())
+ {
+ a_Player.TossPickup(a_ClickedItem);
+ }
+
// Toss all dragged items:
- a_Player.TossItem(true, a_Player.GetDraggingItem().m_ItemCount);
+ a_Player.TossHeldItem(a_Player.GetDraggingItem().m_ItemCount);
return;
}
case caLeftClickOutsideHoldNothing:
@@ -263,7 +286,7 @@ bool cWindow::ClosedByPlayer(cPlayer & a_Player, bool a_CanRefuse)
if (a_Player.IsDraggingItem())
{
LOGD("Player holds item! Dropping it...");
- a_Player.TossItem(true, a_Player.GetDraggingItem().m_ItemCount);
+ a_Player.TossHeldItem(a_Player.GetDraggingItem().m_ItemCount);
}
cClientHandle * ClientHandle = a_Player.GetClientHandle();
@@ -614,7 +637,7 @@ int cWindow::DistributeItemToSlots(cPlayer & a_Player, const cItem & a_Item, int
{
if ((size_t)(a_Item.m_ItemCount) < a_SlotNums.size())
{
- LOGWARNING("%s: Distributing less items (%d) than slots (%u)", __FUNCTION__, (int)a_Item.m_ItemCount, a_SlotNums.size());
+ LOGWARNING("%s: Distributing less items (%d) than slots (" SIZE_T_FMT ")", __FUNCTION__, (int)a_Item.m_ItemCount, a_SlotNums.size());
// This doesn't seem to happen with the 1.5.1 client, so we don't worry about it for now
return 0;
}
diff --git a/src/UI/WindowOwner.h b/src/UI/WindowOwner.h
index d41abf66d..e3c73edc4 100644
--- a/src/UI/WindowOwner.h
+++ b/src/UI/WindowOwner.h
@@ -33,6 +33,10 @@ public:
{
}
+ virtual ~cWindowOwner()
+ {
+ }
+
void CloseWindow(void)
{
m_Window = NULL;