Added ItemPlaceCount in SlotArea
Thanks to Howaner for helping
This commit is contained in:
parent
55224d25ef
commit
b5401ec03a
@ -135,6 +135,12 @@ void cSlotArea::Clicked(cPlayer & a_Player, int a_SlotNum, eClickAction a_ClickA
|
|||||||
cItem tmp(DraggingItem);
|
cItem tmp(DraggingItem);
|
||||||
DraggingItem = Slot;
|
DraggingItem = Slot;
|
||||||
Slot = tmp;
|
Slot = tmp;
|
||||||
|
int ItemPlaceCount = GetItemPlaceCount(Slot);
|
||||||
|
if (Slot.m_ItemCount > ItemPlaceCount)
|
||||||
|
{
|
||||||
|
DraggingItem.m_ItemCount += Slot.m_ItemCount - ItemPlaceCount;
|
||||||
|
Slot.m_ItemCount = ItemPlaceCount;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -147,6 +153,13 @@ void cSlotArea::Clicked(cPlayer & a_Player, int a_SlotNum, eClickAction a_ClickA
|
|||||||
FreeSlots = 0;
|
FreeSlots = 0;
|
||||||
}
|
}
|
||||||
int Filling = (FreeSlots > DraggingItem.m_ItemCount) ? DraggingItem.m_ItemCount : FreeSlots;
|
int Filling = (FreeSlots > DraggingItem.m_ItemCount) ? DraggingItem.m_ItemCount : FreeSlots;
|
||||||
|
|
||||||
|
int ItemPlaceCount = GetItemPlaceCount(DraggingItem);
|
||||||
|
if (Filling > ItemPlaceCount)
|
||||||
|
{
|
||||||
|
Filling = ItemPlaceCount;
|
||||||
|
}
|
||||||
|
|
||||||
Slot.m_ItemCount += (char)Filling;
|
Slot.m_ItemCount += (char)Filling;
|
||||||
DraggingItem.m_ItemCount -= (char)Filling;
|
DraggingItem.m_ItemCount -= (char)Filling;
|
||||||
if (DraggingItem.m_ItemCount <= 0)
|
if (DraggingItem.m_ItemCount <= 0)
|
||||||
@ -315,6 +328,16 @@ bool cSlotArea::CollectItemsToHand(cItem & a_Dragging, cPlayer & a_Player, bool
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
int cSlotArea::GetItemPlaceCount(cItem & a_Item)
|
||||||
|
{
|
||||||
|
cItemHandler * Handler = ItemHandler(a_Item.m_ItemType);
|
||||||
|
return Handler->GetMaxStackSize();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
// cSlotAreaChest:
|
// cSlotAreaChest:
|
||||||
|
|
||||||
@ -718,6 +741,15 @@ void cSlotAreaEnchanting::ShiftClickedSlot(cPlayer & a_Player)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
int cSlotAreaEnchanting::GetItemPlaceCount(cItem & a_Item)
|
||||||
|
{
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
// cSlotAreaEnderChest:
|
// cSlotAreaEnderChest:
|
||||||
|
|
||||||
|
@ -67,6 +67,8 @@ public:
|
|||||||
/// Returns true if full stack has been collected in a_Dragging, false if there's space remaining to fill.
|
/// 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 bool CollectItemsToHand(cItem & a_Dragging, cPlayer & a_Player, bool a_CollectFullStacks);
|
||||||
|
|
||||||
|
virtual int GetItemPlaceCount(cItem & a_Item);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
int m_NumSlots;
|
int m_NumSlots;
|
||||||
cWindow & m_ParentWindow;
|
cWindow & m_ParentWindow;
|
||||||
@ -263,6 +265,7 @@ public:
|
|||||||
// cSlotAreaTemporary overrides:
|
// cSlotAreaTemporary overrides:
|
||||||
virtual void Clicked(cPlayer & a_Player, int a_SlotNum, eClickAction a_ClickAction, const cItem & a_ClickedItem) override;
|
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 void OnPlayerRemoved(cPlayer & a_Player) override;
|
||||||
|
virtual int GetItemPlaceCount(cItem & a_Item) override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
/// Handles a click in the item slot.
|
/// Handles a click in the item slot.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user