Mana
Loading...
Searching...
No Matches
Public Member Functions | Private Types | Private Member Functions | Private Attributes | List of all members
ItemContainer Class Reference

An item container. More...

#include <itemcontainer.h>

Inheritance diagram for ItemContainer:

Public Member Functions

 ItemContainer (Inventory *inventory)
 Constructor.
 
 ~ItemContainer () override
 
void hidePopup ()
 
void logic () override
 Necessary for checking how full the inventory is.
 
void draw (gcn::Graphics *graphics) override
 Draws the items.
 
void drawFrame (gcn::Graphics *graphics) override
 
void keyPressed (gcn::KeyEvent &event) override
 
void keyReleased (gcn::KeyEvent &event) override
 
void mousePressed (gcn::MouseEvent &event) override
 
void mouseDragged (gcn::MouseEvent &event) override
 
void mouseReleased (gcn::MouseEvent &event) override
 
void mouseMoved (gcn::MouseEvent &event) override
 
void mouseExited (gcn::MouseEvent &event) override
 
void widgetResized (const gcn::Event &event) override
 
ItemgetSelectedItem () const
 Returns the selected item.
 
void selectNone ()
 Sets selected item to NULL.
 
void setFilter (const std::string &filter)
 Sets item filter.
 
void addSelectionListener (gcn::SelectionListener *listener)
 Adds a listener to the list that's notified each time a change to the selection occurs.
 
void removeSelectionListener (gcn::SelectionListener *listener)
 Removes a listener from the list that's notified each time a change to the selection occurs.
 

Private Types

enum  Direction { Left , Right , Up , Down }
 
enum  SelectionState {
  SEL_NONE = 0 , SEL_SELECTED , SEL_SELECTING , SEL_DESELECTING ,
  SEL_DRAGGING
}
 

Private Member Functions

void keyAction ()
 Execute all the functionality associated with the action key.
 
void moveHighlight (Direction direction)
 Moves the highlight in the direction specified.
 
void setSelectedIndex (int index)
 Sets the currently selected item.
 
void adjustHeight ()
 Determine and set the height of the container.
 
void distributeValueChangedEvent ()
 Sends out selection events to the list of selection listeners.
 
int getSlotIndex (int x, int y) const
 Gets the slot index based on the cursor position.
 
ItemgetItemAt (int) const
 

Private Attributes

InventorymInventory
 
int mGridColumns = 1
 
int mGridRows = 1
 
int mSelectedIndex = -1
 
int mHighlightedIndex = -1
 
int mLastUsedSlot = -1
 
SelectionState mSelectionStatus = SEL_NONE
 
bool mSwapItems = false
 
bool mDescItems = false
 
int mDragPosX = 0
 
int mDragPosY = 0
 
std::map< int, Item * > mFilteredMap
 
std::string mFilter
 
ItemPopupmItemPopup
 
std::list< gcn::SelectionListener * > mSelectionListeners
 

Detailed Description

An item container.

Used to show items in inventory and trade dialog.

Definition at line 46 of file itemcontainer.h.

Member Enumeration Documentation

◆ Direction

Enumerator
Left 
Right 
Up 
Down 

Definition at line 125 of file itemcontainer.h.

◆ SelectionState

Enumerator
SEL_NONE 
SEL_SELECTED 
SEL_SELECTING 
SEL_DESELECTING 
SEL_DRAGGING 

Definition at line 133 of file itemcontainer.h.

Constructor & Destructor Documentation

◆ ItemContainer()

ItemContainer::ItemContainer ( Inventory inventory)

Constructor.

Initializes the graphic.

Parameters
inventory

Definition at line 46 of file itemcontainer.cpp.

◆ ~ItemContainer()

ItemContainer::~ItemContainer ( )
override

Definition at line 57 of file itemcontainer.cpp.

Member Function Documentation

◆ addSelectionListener()

void ItemContainer::addSelectionListener ( gcn::SelectionListener *  listener)
inline

Adds a listener to the list that's notified each time a change to the selection occurs.

Definition at line 110 of file itemcontainer.h.

◆ adjustHeight()

void ItemContainer::adjustHeight ( )
private

Determine and set the height of the container.

Definition at line 382 of file itemcontainer.cpp.

◆ distributeValueChangedEvent()

void ItemContainer::distributeValueChangedEvent ( )
private

Sends out selection events to the list of selection listeners.

Definition at line 207 of file itemcontainer.cpp.

◆ draw()

void ItemContainer::draw ( gcn::Graphics *  graphics)
override

Draws the items.

Definition at line 75 of file itemcontainer.cpp.

◆ drawFrame()

void ItemContainer::drawFrame ( gcn::Graphics *  graphics)
inlineoverride

Definition at line 74 of file itemcontainer.h.

◆ getItemAt()

Item * ItemContainer::getItemAt ( int  index) const
private

Definition at line 196 of file itemcontainer.cpp.

◆ getSelectedItem()

Item * ItemContainer::getSelectedItem ( ) const

Returns the selected item.

Definition at line 191 of file itemcontainer.cpp.

◆ getSlotIndex()

int ItemContainer::getSlotIndex ( int  x,
int  y 
) const
private

Gets the slot index based on the cursor position.

Parameters
xThe X coordinate position.
yThe Y coordinate position.
Returns
The slot index on success, -1 on failure.

Definition at line 393 of file itemcontainer.cpp.

◆ hidePopup()

void ItemContainer::hidePopup ( )

Definition at line 216 of file itemcontainer.cpp.

◆ keyAction()

void ItemContainer::keyAction ( )
private

Execute all the functionality associated with the action key.

Definition at line 408 of file itemcontainer.cpp.

◆ keyPressed()

void ItemContainer::keyPressed ( gcn::KeyEvent &  event)
override

Definition at line 221 of file itemcontainer.cpp.

◆ keyReleased()

void ItemContainer::keyReleased ( gcn::KeyEvent &  event)
override

Definition at line 250 of file itemcontainer.cpp.

◆ logic()

void ItemContainer::logic ( )
override

Necessary for checking how full the inventory is.

Definition at line 62 of file itemcontainer.cpp.

◆ mouseDragged()

void ItemContainer::mouseDragged ( gcn::MouseEvent &  event)
override

Definition at line 310 of file itemcontainer.cpp.

◆ mouseExited()

void ItemContainer::mouseExited ( gcn::MouseEvent &  event)
override

Definition at line 369 of file itemcontainer.cpp.

◆ mouseMoved()

void ItemContainer::mouseMoved ( gcn::MouseEvent &  event)
override

Definition at line 355 of file itemcontainer.cpp.

◆ mousePressed()

void ItemContainer::mousePressed ( gcn::MouseEvent &  event)
override

Definition at line 264 of file itemcontainer.cpp.

◆ mouseReleased()

void ItemContainer::mouseReleased ( gcn::MouseEvent &  event)
override

Definition at line 320 of file itemcontainer.cpp.

◆ moveHighlight()

void ItemContainer::moveHighlight ( Direction  direction)
private

Moves the highlight in the direction specified.

Parameters
directionThe move direction of the highlighter.

Definition at line 449 of file itemcontainer.cpp.

◆ removeSelectionListener()

void ItemContainer::removeSelectionListener ( gcn::SelectionListener *  listener)
inline

Removes a listener from the list that's notified each time a change to the selection occurs.

Definition at line 119 of file itemcontainer.h.

◆ selectNone()

void ItemContainer::selectNone ( )

Sets selected item to NULL.

Definition at line 175 of file itemcontainer.cpp.

◆ setFilter()

void ItemContainer::setFilter ( const std::string &  filter)

Sets item filter.

Definition at line 202 of file itemcontainer.cpp.

◆ setSelectedIndex()

void ItemContainer::setSelectedIndex ( int  index)
private

Sets the currently selected item.

Definition at line 182 of file itemcontainer.cpp.

◆ widgetResized()

void ItemContainer::widgetResized ( const gcn::Event &  event)
override

Definition at line 374 of file itemcontainer.cpp.

Member Data Documentation

◆ mDescItems

bool ItemContainer::mDescItems = false
private

Definition at line 188 of file itemcontainer.h.

◆ mDragPosX

int ItemContainer::mDragPosX = 0
private

Definition at line 189 of file itemcontainer.h.

◆ mDragPosY

int ItemContainer::mDragPosY = 0
private

Definition at line 190 of file itemcontainer.h.

◆ mFilter

std::string ItemContainer::mFilter
private

Definition at line 194 of file itemcontainer.h.

◆ mFilteredMap

std::map<int, Item*> ItemContainer::mFilteredMap
private

Definition at line 192 of file itemcontainer.h.

◆ mGridColumns

int ItemContainer::mGridColumns = 1
private

Definition at line 181 of file itemcontainer.h.

◆ mGridRows

int ItemContainer::mGridRows = 1
private

Definition at line 182 of file itemcontainer.h.

◆ mHighlightedIndex

int ItemContainer::mHighlightedIndex = -1
private

Definition at line 184 of file itemcontainer.h.

◆ mInventory

Inventory* ItemContainer::mInventory
private

Definition at line 180 of file itemcontainer.h.

◆ mItemPopup

ItemPopup* ItemContainer::mItemPopup
private

Definition at line 196 of file itemcontainer.h.

◆ mLastUsedSlot

int ItemContainer::mLastUsedSlot = -1
private

Definition at line 185 of file itemcontainer.h.

◆ mSelectedIndex

int ItemContainer::mSelectedIndex = -1
private

Definition at line 183 of file itemcontainer.h.

◆ mSelectionListeners

std::list<gcn::SelectionListener *> ItemContainer::mSelectionListeners
private

Definition at line 198 of file itemcontainer.h.

◆ mSelectionStatus

SelectionState ItemContainer::mSelectionStatus = SEL_NONE
private

Definition at line 186 of file itemcontainer.h.

◆ mSwapItems

bool ItemContainer::mSwapItems = false
private

Definition at line 187 of file itemcontainer.h.


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