UFO: Alien Invasion
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
ui_node_container.h File Reference

Go to the source code of this file.

Data Structures

class  uiContainerNode
 
struct  containerExtraData_s
 extradata for container widget More...
 

Macros

#define C_UNIT   25
 One unit in the containers is 25x25. More...
 

Typedefs

typedef struct containerExtraData_s containerExtraData_t
 extradata for container widget More...
 

Functions

void UI_RegisterContainerNode (uiBehaviour_t *behaviour)
 
void UI_DrawItem (uiNode_t *node, const vec3_t org, const Item *item, int x, int y, const vec3_t scale, const vec4_t color)
 Draws an item to the screen. More...
 
void UI_ContainerNodeUpdateEquipment (Inventory *inv, const equipDef_t *ed)
 Fills the ground container of the ui_inventory with unused items from a given equipment definition. More...
 
uiNode_tUI_GetContainerNodeByContainerIDX (const uiNode_t *const parent, const int index)
 Search a child container node by the given container id. More...
 
void UI_ContainerNodeAutoPlaceItem (uiNode_t *node, Item *ic)
 Try to autoplace an item from a container. More...
 
void UI_GetItemTooltip (const Item &item, char *tooltipText, size_t stringMaxLength)
 Generate tooltip text for an item. More...
 

Variables

Inventoryui_inventory
 

Macro Definition Documentation

Typedef Documentation

extradata for container widget

Note
everything is not used by all container's type (grid, single, scrolled)

Function Documentation

void UI_ContainerNodeAutoPlaceItem ( uiNode_t node,
Item ic 
)
void UI_ContainerNodeUpdateEquipment ( Inventory inv,
const equipDef_t ed 
)

Fills the ground container of the ui_inventory with unused items from a given equipment definition.

Todo:
it's not obvious for the caller that ui_inventory pointer must be set
Parameters
[in,out]invThe inventory to add the unused items from ed to
[in]edThe equipment definition to get the used items from that should be added to the ground container of inv
not used nor called by the container node; should be move somewhere else

Definition at line 102 of file ui_node_container.cpp.

References InventoryInterface::addToInventory(), CID_EQUIP, cls, csi, Item::def(), FILTER_AIRCRAFT, GAME_ItemIsUseable(), Inventory::getEquipContainer(), client_static_s::i, i, objDef_s::idx, INVDEF, INVSH_GetItemByIDX(), lengthof, MAX_CONTAINERS, Mem_Dup, Mem_Free, NONE, equipDef_s::numItems, csi_s::numODs, and Inventory::setContainer().

Referenced by GAME_GetImportData(), and GAME_UpdateInventory().

void UI_DrawItem ( uiNode_t node,
const vec3_t  org,
const Item item,
int  x,
int  y,
const vec3_t  scale,
const vec4_t  color 
)

Draws an item to the screen.

Parameters
[in]nodeContext node
[in]orgNode position on the screen (pixel). Single nodes: Use the center of the node.
[in]itemThe item to draw.
[in]x,yPosition in container. Set both to -1 if it's drawn in a single container.
[in]scale
[in]color
See also
SCR_DrawCursor Used to draw an item to the equipment containers. First look whether the objDef_t includes an image - if there is none then draw the model
Todo:
Change the rotation of the image as well, right now only the location is changed. How is image-rotation handled right now?
Todo:
Image size calculation depends on handling of image-rotation. imgWidth = od->sy * C_UNIT; imgHeight = od->sx * C_UNIT;

Definition at line 149 of file ui_node_container.cpp.

References modelInfo_t::angles, C_UNIT, modelInfo_t::center, objDef_s::center, modelInfo_t::color, Com_Printf(), Item::def(), GAME_GetModelForItem(), objDef_s::id, objDef_s::image, Item::mustReload(), modelInfo_t::name, OBJZERO, modelInfo_t::origin, Q_strnull(), R_Color(), R_DrawModelDirect(), Item::rotated, modelInfo_t::scale, objDef_s::scale, objDef_s::sx, objDef_s::sy, UI_DrawModelNode(), UI_DrawNormImageByName(), Vector4Copy, VectorCopy, VectorNegate, VectorScale, and objDef_s::weapon.

Referenced by uiItemNode::draw(), UI_BaseInventoryNodeDrawItems(), UI_ContainerNodeDrawDropPreview(), UI_ContainerNodeDrawGrid(), UI_ContainerNodeDrawSingle(), and UI_DrawDragAndDrop().

uiNode_t* UI_GetContainerNodeByContainerIDX ( const uiNode_t *const  parent,
const int  index 
)

Search a child container node by the given container id.

Note
Only search with one depth

Definition at line 290 of file ui_node_container.cpp.

References INVDEF, invDef_s::name, and UI_GetNode().

Referenced by UI_ContainerNodeAutoPlaceItem().

void UI_GetItemTooltip ( const Item item,
char *  tooltipText,
size_t  stringMaxLength 
)

Generate tooltip text for an item.

Parameters
[in]itemThe item we want to generate the tooltip text for.
[in,out]tooltipTextPointer to a string the information should be written into.
[in]stringMaxLengthMax. string size of tooltipText.
Returns
Number of lines

Definition at line 247 of file ui_node_container.cpp.

References _, Item::ammoDef(), Com_sprintf(), Item::def(), GAME_ItemIsUseable(), Item::getAmmoLeft(), Item::getAmount(), i, Item::isWeapon(), objDef_s::name, objDef_s::numWeapons, Q_strcat(), and objDef_s::weapons.

Referenced by uiBaseInventoryNode::drawTooltip(), and uiContainerNode::drawTooltip().

Variable Documentation

Inventory* ui_inventory
Todo:
need refactoring to remove, reduce use... of that var Global access to many node content like that is very bad.

Definition at line 62 of file ui_node_container.cpp.

Referenced by CL_ActorSelect(), uiBaseInventoryNode::draw(), GAME_ActorSelect_f(), GAME_GetImportData(), GAME_UpdateInventory(), UI_ContainerNodeAutoPlace(), and UI_ContainerNodeGetExistingItem().