OpenXcom  1.0
Open-source clone of the original X-Com
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
Public Member Functions | List of all members
OpenXcom::RuleInventory Class Reference

Represents a specific section of the inventory, containing information like available slots and screen position. More...

#include <RuleInventory.h>

Public Member Functions

 RuleInventory (const std::string &id)
 Creates a blank inventory ruleset. More...
 
 ~RuleInventory ()
 Cleans up the inventory ruleset.
 
void load (const YAML::Node &node, int listOrder)
 Loads inventory data from YAML. More...
 
std::string getId () const
 Gets the inventory's id. More...
 
int getX () const
 Gets the X position of the inventory. More...
 
int getY () const
 Gets the Y position of the inventory. More...
 
InventoryType getType () const
 Gets the inventory type. More...
 
std::vector< struct RuleSlot > * getSlots ()
 Gets all the slots in the inventory. More...
 
bool checkSlotInPosition (int *x, int *y) const
 Checks for a slot in a certain position. More...
 
bool fitItemInSlot (RuleItem *item, int x, int y) const
 Checks if an item fits in a slot. More...
 
int getCost (RuleInventory *slot) const
 Gets a certain cost in the inventory. More...
 

Detailed Description

Represents a specific section of the inventory, containing information like available slots and screen position.

Constructor & Destructor Documentation

OpenXcom::RuleInventory::RuleInventory ( const std::string &  id)

Creates a blank inventory ruleset.

Creates a blank ruleset for a certain type of inventory section.

Parameters
idString defining the id.

Member Function Documentation

bool OpenXcom::RuleInventory::checkSlotInPosition ( int *  x,
int *  y 
) const

Checks for a slot in a certain position.

Gets the slot located in the specified mouse position.

Parameters
xMouse X position. Returns the slot's X position.
yMouse Y position. Returns the slot's Y position.
Returns
True if there's a slot there.
bool OpenXcom::RuleInventory::fitItemInSlot ( RuleItem item,
int  x,
int  y 
) const

Checks if an item fits in a slot.

Checks if an item completely fits when placed in a certain slot.

Parameters
itemPointer to item ruleset.
xSlot X position.
ySlot Y position.
Returns
True if there's a slot there.
int OpenXcom::RuleInventory::getCost ( RuleInventory slot) const

Gets a certain cost in the inventory.

Gets the time unit cost to place an item in another section.

Parameters
slotThe new section id.
Returns
The time unit cost.
std::string OpenXcom::RuleInventory::getId ( ) const

Gets the inventory's id.

Gets the language string that names this inventory section.

Each section has a unique name.

Returns
The section name.
std::vector< struct RuleSlot > * OpenXcom::RuleInventory::getSlots ( )

Gets all the slots in the inventory.

Gets all the slots in the inventory section.

Returns
The list of slots.
InventoryType OpenXcom::RuleInventory::getType ( ) const

Gets the inventory type.

Gets the type of the inventory section.

Slot-based contain a limited number of slots. Hands only contain one slot but can hold any item. Ground can hold infinite items but don't attach to soldiers.

Returns
The inventory type.
int OpenXcom::RuleInventory::getX ( ) const

Gets the X position of the inventory.

Gets the X position of the inventory section on the screen.

Returns
The X position in pixels.
int OpenXcom::RuleInventory::getY ( ) const

Gets the Y position of the inventory.

Gets the Y position of the inventory section on the screen.

Returns
The Y position in pixels.
void OpenXcom::RuleInventory::load ( const YAML::Node &  node,
int  listOrder 
)

Loads inventory data from YAML.

Loads the inventory from a YAML file.

Parameters
nodeYAML node.
listOrderThe list weight for this inventory.

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