![]() |
OpenXcom
1.0
Open-source clone of the original X-Com
|
Interactive view of an inventory. More...
#include <Inventory.h>
Public Member Functions | |
Inventory (Game *game, int width, int height, int x=0, int y=0, bool base=false) | |
Creates a new inventory view at the specified position and size. More... | |
~Inventory () | |
Cleans up the inventory. More... | |
void | setPalette (SDL_Color *colors, int firstcolor=0, int ncolors=256) |
Sets the inventory's palette. More... | |
void | setTuMode (bool tu) |
Sets the inventory's Time Unit mode. More... | |
void | setSelectedUnit (BattleUnit *unit) |
Sets the inventory's selected unit. More... | |
void | draw () |
Draws the inventory. More... | |
void | drawGrid () |
Draws the inventory grid. More... | |
void | drawItems () |
Draws the inventory items. More... | |
BattleItem * | getSelectedItem () const |
Gets the currently selected item. More... | |
void | setSelectedItem (BattleItem *item) |
Sets the currently selected item. More... | |
BattleItem * | getMouseOverItem () const |
Gets the mouse over item. More... | |
void | setMouseOverItem (BattleItem *item) |
Sets the mouse over item. More... | |
void | think () |
Handles timers. | |
void | blit (Surface *surface) |
Blits the inventory onto another surface. More... | |
void | mouseOver (Action *action, State *state) |
Special handling for mouse hovers. More... | |
void | mouseClick (Action *action, State *state) |
Special handling for mouse clicks. More... | |
bool | unload () |
Unloads the selected weapon. More... | |
void | arrangeGround (bool alterOffset=true) |
Arranges items on the ground. More... | |
bool | fitItem (RuleInventory *newSlot, BattleItem *item, std::string &warning) |
Attempts to place an item in an inventory slot. More... | |
bool | canBeStacked (BattleItem *itemA, BattleItem *itemB) |
Checks if two items can be stacked on one another. More... | |
void | showWarning (const std::string &msg) |
Shows a warning message. More... | |
void | drawPrimers () |
Show priming warnings on grenades. More... | |
![]() | |
InteractiveSurface (int width, int height, int x=0, int y=0) | |
Creates a new interactive surface with the specified size and position. More... | |
virtual | ~InteractiveSurface () |
Cleans up the interactive surface. | |
void | setVisible (bool visible) |
Sets the surface's visibility. More... | |
virtual void | handle (Action *action, State *state) |
Processes any pending events. More... | |
virtual void | setFocus (bool focus) |
Sets the focus of this surface. More... | |
bool | isFocused () const |
Gets the focus of this surface. More... | |
virtual void | unpress (State *state) |
Unpresses the surface. More... | |
void | onMouseClick (ActionHandler handler, Uint8 button=SDL_BUTTON_LEFT) |
Hooks an action handler to a mouse click on the surface. More... | |
void | onMousePress (ActionHandler handler, Uint8 button=0) |
Hooks an action handler to a mouse press over the surface. More... | |
void | onMouseRelease (ActionHandler handler, Uint8 button=0) |
Hooks an action handler to a mouse release over the surface. More... | |
void | onMouseIn (ActionHandler handler) |
Hooks an action handler to moving the mouse into the surface. More... | |
void | onMouseOver (ActionHandler handler) |
Hooks an action handler to moving the mouse over the surface. More... | |
void | onMouseOut (ActionHandler handler) |
Hooks an action handler to moving the mouse out of the surface. More... | |
void | onKeyboardPress (ActionHandler handler, SDLKey key=SDLK_ANY) |
Hooks an action handler to pressing a key when the surface is focused. More... | |
void | onKeyboardRelease (ActionHandler handler, SDLKey key=SDLK_ANY) |
Hooks an action handler to releasing a key when the surface is focused. More... | |
virtual void | mousePress (Action *action, State *state) |
Processes a mouse button press event. More... | |
virtual void | mouseRelease (Action *action, State *state) |
Processes a mouse button release event. More... | |
virtual void | mouseIn (Action *action, State *state) |
Processes a mouse hover in event. More... | |
virtual void | mouseOut (Action *action, State *state) |
Processes a mouse hover out event. More... | |
virtual void | keyboardPress (Action *action, State *state) |
Processes a keyboard key press event. More... | |
virtual void | keyboardRelease (Action *action, State *state) |
Processes a keyboard key release event. More... | |
void | setListButton () |
Check this surface to see if it's a textlist button. More... | |
![]() | |
Surface (int width, int height, int x=0, int y=0, int bpp=8) | |
Creates a new surface with the specified size and position. More... | |
Surface (const Surface &other) | |
Creates a new surface from an existing one. More... | |
virtual | ~Surface () |
Cleans up the surface. More... | |
void | loadRaw (const std::vector< unsigned char > &bytes) |
Loads a raw pixel array. More... | |
void | loadRaw (const std::vector< char > &bytes) |
Loads a raw pixel array. More... | |
void | loadScr (const std::string &filename) |
Loads an X-Com SCR graphic. More... | |
void | loadSpk (const std::string &filename) |
Loads an X-Com SPK graphic. More... | |
void | loadBdy (const std::string &filename) |
Loads a TFTD BDY graphic. More... | |
void | loadImage (const std::string &filename) |
Loads a general image file. More... | |
void | clear (Uint32 color=0) |
Clears the surface's contents eith a specified colour. More... | |
void | offset (int off, int min=-1, int max=-1, int mul=1) |
Offsets the surface's colors by a set amount. More... | |
void | offsetBlock (int off, int blk=16, int mul=1) |
Offsets the surface's colors in a color block. More... | |
void | invert (Uint8 mid) |
Inverts the surface's colors. More... | |
virtual void | initText (Font *, Font *, Language *) |
Initializes the surface's various text resources. | |
void | copy (Surface *surface) |
Copies a portion of another surface into this one. More... | |
void | drawRect (SDL_Rect *rect, Uint8 color) |
Draws a filled rectangle on the surface. More... | |
void | drawRect (Sint16 x, Sint16 y, Sint16 w, Sint16 h, Uint8 color) |
Draws a filled rectangle on the surface. More... | |
void | drawLine (Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, Uint8 color) |
Draws a line on the surface. More... | |
void | drawCircle (Sint16 x, Sint16 y, Sint16 r, Uint8 color) |
Draws a filled circle on the surface. More... | |
void | drawPolygon (Sint16 *x, Sint16 *y, int n, Uint8 color) |
Draws a filled polygon on the surface. More... | |
void | drawTexturedPolygon (Sint16 *x, Sint16 *y, int n, Surface *texture, int dx, int dy) |
Draws a textured polygon on the surface. More... | |
void | drawString (Sint16 x, Sint16 y, const char *s, Uint8 color) |
Draws a string on the surface. More... | |
SDL_Color * | getPalette () const |
Returns the surface's 8bpp palette. More... | |
virtual void | setX (int x) |
Sets the X position of the surface. More... | |
int | getX () const |
Returns the position of the surface in the X axis. More... | |
virtual void | setY (int y) |
Sets the Y position of the surface. More... | |
int | getY () const |
Returns the position of the surface in the Y axis. More... | |
bool | getVisible () const |
Gets the surface's visibility. More... | |
void | resetCrop () |
Resets the cropping rectangle for the surface. More... | |
SDL_Rect * | getCrop () |
Gets the cropping rectangle for the surface. More... | |
void | setPixel (int x, int y, Uint8 pixel) |
Changes the color of a pixel in the surface, relative to the top-left corner of the surface. More... | |
void | setPixelIterative (int *x, int *y, Uint8 pixel) |
Changes the color of a pixel in the surface and returns the next pixel position. More... | |
Uint8 | getPixel (int x, int y) const |
Returns the color of a specified pixel in the surface. More... | |
Uint8 * | getRaw (int x, int y) const |
Returns the pointer to a specified pixel in the surface. More... | |
SDL_Surface * | getSurface () const |
Returns the internal SDL_Surface for SDL calls. More... | |
int | getWidth () const |
Returns the width of the surface. More... | |
virtual void | setWidth (int width) |
Sets the width of the surface. More... | |
int | getHeight () const |
Returns the height of the surface. More... | |
virtual void | setHeight (int height) |
Sets the height of the surface. More... | |
void | setHidden (bool hidden) |
Sets the surface's special hidden flag. More... | |
void | lock () |
Locks the surface. More... | |
void | unlock () |
Unlocks the surface. More... | |
void | blitNShade (Surface *surface, int x, int y, int shade, bool half=false, int newBaseColor=0) |
Specific blit function to blit battlescape terrain data in different shades in a fast way. More... | |
void | blitNShade (Surface *surface, int x, int y, int shade, GraphSubset range) |
Specific blit function to blit battlescape terrain data in different shades in a fast way. More... | |
void | invalidate (bool valid=true) |
Invalidate the surface: force it to be redrawn. More... | |
std::string | getTooltip () const |
Gets the tooltip of the surface. More... | |
void | setTooltip (const std::string &tooltip) |
Sets the tooltip of the surface. More... | |
virtual void | setColor (Uint8) |
Sets the color of the surface. | |
virtual void | setSecondaryColor (Uint8) |
Sets the secondary color of the surface. | |
virtual void | setBorderColor (Uint8) |
Sets the border colour of the surface. | |
virtual void | setHighContrast (bool) |
Sets the high contrast color setting of the surface. | |
void | setTFTDMode (bool mode) |
Sets this button to use a colour lookup table instead of inversion for its alternate form. More... | |
bool | isTFTDMode () const |
checks if this is a TFTD mode surface. More... | |
Static Public Member Functions | |
static bool | overlapItems (BattleUnit *unit, BattleItem *item, RuleInventory *slot, int x=0, int y=0) |
Checks for item overlap. More... | |
Additional Inherited Members | |
![]() | |
bool | isButtonPressed (Uint8 button=0) const |
Is this mouse button pressed? | |
virtual bool | isButtonHandled (Uint8 button=0) |
Is this mouse button event handled? | |
void | setButtonPressed (Uint8 button, bool pressed) |
Set a mouse button's internal state. | |
![]() | |
template<typename T > | |
void | rawCopy (const std::vector< T > &bytes) |
Copies raw pixels. More... | |
void | resize (int width, int height) |
Resizes the surface. More... | |
Interactive view of an inventory.
Lets the player view and manage a soldier's equipment.
OpenXcom::Inventory::Inventory | ( | Game * | game, |
int | width, | ||
int | height, | ||
int | x = 0 , |
||
int | y = 0 , |
||
bool | base = false |
||
) |
Creates a new inventory view at the specified position and size.
Sets up an inventory with the specified size and position.
game | Pointer to core game. |
width | Width in pixels. |
height | Height in pixels. |
x | X position in pixels. |
y | Y position in pixels. |
base | Is the inventory being called from the basescape? |
OpenXcom::Inventory::~Inventory | ( | ) |
Cleans up the inventory.
Deletes inventory surfaces.
void OpenXcom::Inventory::arrangeGround | ( | bool | alterOffset = true | ) |
Arranges items on the ground.
Arranges items on the ground for the inventory display.
Since items on the ground aren't assigned to anyone, they don't actually have permanent slot positions.
alterOffset | Whether to alter the ground offset. |
|
virtual |
Blits the inventory onto another surface.
Blits the inventory elements.
surface | Pointer to surface to blit onto. |
Reimplemented from OpenXcom::Surface.
bool OpenXcom::Inventory::canBeStacked | ( | BattleItem * | itemA, |
BattleItem * | itemB | ||
) |
Checks if two items can be stacked on one another.
itemA | First item. |
itemB | Second item. |
|
virtual |
void OpenXcom::Inventory::drawGrid | ( | ) |
Draws the inventory grid.
Draws the inventory grid for item placement.
void OpenXcom::Inventory::drawItems | ( | ) |
Draws the inventory items.
Draws the items contained in the soldier's inventory.
void OpenXcom::Inventory::drawPrimers | ( | ) |
Show priming warnings on grenades.
Shows primer warnings on all live grenades.
bool OpenXcom::Inventory::fitItem | ( | RuleInventory * | newSlot, |
BattleItem * | item, | ||
std::string & | warning | ||
) |
Attempts to place an item in an inventory slot.
Attempts to place the item in the inventory slot.
newSlot | Where to place the item. |
item | Item to be placed. |
warning | Warning message if item could not be placed. |
BattleItem * OpenXcom::Inventory::getMouseOverItem | ( | ) | const |
Gets the mouse over item.
Returns the item currently under mouse cursor.
BattleItem * OpenXcom::Inventory::getSelectedItem | ( | ) | const |
Gets the currently selected item.
Returns the item currently grabbed by the player.
Special handling for mouse clicks.
Picks up / drops an item.
action | Pointer to an action. |
state | State that the action handlers belong to. |
Reimplemented from OpenXcom::InteractiveSurface.
Special handling for mouse hovers.
Moves the selected item.
action | Pointer to an action. |
state | State that the action handlers belong to. |
Reimplemented from OpenXcom::InteractiveSurface.
|
static |
Checks for item overlap.
Checks if an item in a certain slot position would overlap with any other inventory item.
unit | Pointer to current unit. |
item | Pointer to battle item. |
slot | Inventory slot, or NULL if none. |
x | X position in slot. |
y | Y position in slot. |
void OpenXcom::Inventory::setMouseOverItem | ( | BattleItem * | item | ) |
Sets the mouse over item.
Changes the item currently under mouse cursor.
item | Pointer to selected item, or NULL if none. |
|
virtual |
Sets the inventory's palette.
Replaces a certain amount of colors in the inventory's palette.
colors | Pointer to the set of colors. |
firstcolor | Offset of the first color to replace. |
ncolors | Amount of colors to replace. |
Reimplemented from OpenXcom::Surface.
void OpenXcom::Inventory::setSelectedItem | ( | BattleItem * | item | ) |
Sets the currently selected item.
Changes the item currently grabbed by the player.
item | Pointer to selected item, or NULL if none. |
void OpenXcom::Inventory::setSelectedUnit | ( | BattleUnit * | unit | ) |
Sets the inventory's selected unit.
Changes the unit to display the inventory of.
unit | Pointer to battle unit. |
void OpenXcom::Inventory::setTuMode | ( | bool | tu | ) |
Sets the inventory's Time Unit mode.
Changes the inventory's Time Units mode.
When True, inventory actions cost soldier time units (for battle). When False, inventory actions don't cost anything (for pre-equip).
tu | Time Units mode. |
void OpenXcom::Inventory::showWarning | ( | const std::string & | msg | ) |
Shows a warning message.
msg | The message to show. |
bool OpenXcom::Inventory::unload | ( | ) |
Unloads the selected weapon.
Unloads the selected weapon, placing the gun on the right hand and the ammo on the left hand.