Cuberite
A lightweight, fast and extensible game server for Minecraft
Public Member Functions | Protected Attributes | List of all members
cSlotArea Class Referenceabstract

#include <SlotArea.h>

Inheritance diagram for cSlotArea:
Inheritance graph
[legend]
Collaboration diagram for cSlotArea:
Collaboration graph
[legend]

Public Member Functions

virtual void Clicked (cPlayer &a_Player, int a_SlotNum, eClickAction a_ClickAction, const cItem &a_ClickedItem)
 Called when a player clicks in the window. More...
 
virtual bool CollectItemsToHand (cItem &a_Dragging, cPlayer &a_Player, bool a_CollectFullStacks)
 Called on DblClicking to collect all stackable items into hand. More...
 
 cSlotArea (int a_NumSlots, cWindow &a_ParentWindow)
 
virtual void DblClicked (cPlayer &a_Player, int a_SlotNum)
 Called from Clicked when the action is a caDblClick. More...
 
virtual void DistributeStack (cItem &a_ItemStack, cPlayer &a_Player, bool a_ShouldApply, bool a_KeepEmptySlots, bool a_BackFill)
 Called to store as much of a_ItemStack in the area as possible. More...
 
virtual void DropClicked (cPlayer &a_Player, int a_SlotNum, bool a_DropStack)
 Called from Clicked when the action is a drop click. More...
 
int GetNumSlots (void) const
 
virtual const cItemGetSlot (int a_SlotNum, cPlayer &a_Player) const =0
 Called to retrieve an item in the specified slot for the specified player. More...
 
virtual void MiddleClicked (cPlayer &a_Player, int a_SlotNum)
 Called from Clicked when the action is a middleclick. More...
 
virtual void NumberClicked (cPlayer &a_Player, int a_SlotNum, eClickAction a_ClickAction)
 Called from Clicked when the action is a number click. More...
 
virtual void OnPlayerAdded (cPlayer &a_Player)
 Called when a new player opens the same parent window. More...
 
virtual void OnPlayerRemoved (cPlayer &a_Player)
 Called when one of the players closes the parent window. More...
 
virtual void SetSlot (int a_SlotNum, cPlayer &a_Player, const cItem &a_Item)=0
 Called to set an item in the specified slot for the specified player. More...
 
virtual void ShiftClicked (cPlayer &a_Player, int a_SlotNum, const cItem &a_ClickedItem)
 Called from Clicked when the action is a shiftclick (left or right) More...
 
virtual ~cSlotArea ()
 

Protected Attributes

int m_NumSlots
 
cWindowm_ParentWindow
 

Detailed Description

Definition at line 33 of file SlotArea.h.

Constructor & Destructor Documentation

◆ cSlotArea()

cSlotArea::cSlotArea ( int  a_NumSlots,
cWindow a_ParentWindow 
)

Definition at line 33 of file SlotArea.cpp.

◆ ~cSlotArea()

virtual cSlotArea::~cSlotArea ( )
inlinevirtual

Definition at line 37 of file SlotArea.h.

Member Function Documentation

◆ Clicked()

void cSlotArea::Clicked ( cPlayer a_Player,
int  a_SlotNum,
eClickAction  a_ClickAction,
const cItem a_ClickedItem 
)
virtual

Called when a player clicks in the window.

Parameters taken from the click packet.

Reimplemented in cSlotAreaHorse, cSlotAreaBrewingstand, cSlotAreaFurnace, cSlotAreaEnchanting, cSlotAreaBeacon, cSlotAreaAnvil, cSlotAreaCrafting, cSlotAreaArmor, and cSlotAreaInventoryBase.

Definition at line 43 of file SlotArea.cpp.

◆ CollectItemsToHand()

bool cSlotArea::CollectItemsToHand ( cItem a_Dragging,
cPlayer a_Player,
bool  a_CollectFullStacks 
)
virtual

Called on DblClicking to collect all stackable items into hand.

The items are accumulated in a_Dragging and removed from the slots immediately. 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.

Definition at line 392 of file SlotArea.cpp.

◆ DblClicked()

void cSlotArea::DblClicked ( cPlayer a_Player,
int  a_SlotNum 
)
virtual

Called from Clicked when the action is a caDblClick.

Reimplemented in cSlotAreaCrafting.

Definition at line 235 of file SlotArea.cpp.

◆ DistributeStack()

void cSlotArea::DistributeStack ( cItem a_ItemStack,
cPlayer a_Player,
bool  a_ShouldApply,
bool  a_KeepEmptySlots,
bool  a_BackFill 
)
virtual

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. if a_ShouldApply is true, the changes are written into the slots; if a_ShouldApply is false, only a_ItemStack is modified to reflect the number of fits (for fit-testing purposes) If a_KeepEmptySlots is true, empty slots will be skipped and won't be filled

Reimplemented in cSlotAreaHorse, cSlotAreaBrewingstand, cSlotAreaFurnace, cSlotAreaEnchanting, cSlotAreaBeacon, cSlotAreaAnvil, cSlotAreaCrafting, and cSlotAreaArmor.

Definition at line 354 of file SlotArea.cpp.

◆ DropClicked()

void cSlotArea::DropClicked ( cPlayer a_Player,
int  a_SlotNum,
bool  a_DropStack 
)
virtual

Called from Clicked when the action is a drop click.

Definition at line 283 of file SlotArea.cpp.

◆ GetNumSlots()

int cSlotArea::GetNumSlots ( void  ) const
inline

Definition at line 39 of file SlotArea.h.

◆ GetSlot()

virtual const cItem* cSlotArea::GetSlot ( int  a_SlotNum,
cPlayer a_Player 
) const
pure virtual

Called to retrieve an item in the specified slot for the specified player.

Must return a valid cItem.

Implemented in cSlotAreaHorse, cSlotAreaMinecartWithChest, cSlotAreaBrewingstand, cSlotAreaFurnace, cSlotAreaEnderChest, cSlotAreaDoubleChest, cSlotAreaChest, cSlotAreaBeacon, cSlotAreaTemporary, cSlotAreaItemGrid, and cSlotAreaInventoryBase.

◆ MiddleClicked()

void cSlotArea::MiddleClicked ( cPlayer a_Player,
int  a_SlotNum 
)
virtual

Called from Clicked when the action is a middleclick.

Definition at line 265 of file SlotArea.cpp.

◆ NumberClicked()

void cSlotArea::NumberClicked ( cPlayer a_Player,
int  a_SlotNum,
eClickAction  a_ClickAction 
)
virtual

Called from Clicked when the action is a number click.

Definition at line 311 of file SlotArea.cpp.

◆ OnPlayerAdded()

void cSlotArea::OnPlayerAdded ( cPlayer a_Player)
virtual

Called when a new player opens the same parent window.

The window already tracks the player. CS-locked.

Reimplemented in cSlotAreaEnchanting, and cSlotAreaTemporary.

Definition at line 336 of file SlotArea.cpp.

◆ OnPlayerRemoved()

void cSlotArea::OnPlayerRemoved ( cPlayer a_Player)
virtual

Called when one of the players closes the parent window.

The window already doesn't track the player. CS-locked.

Reimplemented in cSlotAreaEnchanting, cSlotAreaAnvil, cSlotAreaCrafting, and cSlotAreaTemporary.

Definition at line 345 of file SlotArea.cpp.

◆ SetSlot()

virtual void cSlotArea::SetSlot ( int  a_SlotNum,
cPlayer a_Player,
const cItem a_Item 
)
pure virtual

◆ ShiftClicked()

void cSlotArea::ShiftClicked ( cPlayer a_Player,
int  a_SlotNum,
const cItem a_ClickedItem 
)
virtual

Called from Clicked when the action is a shiftclick (left or right)

Reimplemented in cSlotAreaAnvil.

Definition at line 215 of file SlotArea.cpp.

Member Data Documentation

◆ m_NumSlots

int cSlotArea::m_NumSlots
protected

Definition at line 85 of file SlotArea.h.

◆ m_ParentWindow

cWindow& cSlotArea::m_ParentWindow
protected

Definition at line 86 of file SlotArea.h.


The documentation for this class was generated from the following files: