ui_node_baseinventory.c File Reference

The container node refer to 3 different nodes merged into a singler one. Both can drag and drop solider items from a container to another one. The first container is a soldier slot. For example, the left arm, the bag pack... The second is the base item list. And the last it a floor container used into the battlescape. The node name itself is used to know the container role. More...

#include "../ui_main.h"
#include "../ui_parse.h"
#include "../ui_actions.h"
#include "../ui_dragndrop.h"
#include "../ui_tooltip.h"
#include "../ui_nodes.h"
#include "../ui_input.h"
#include "../ui_render.h"
#include "ui_node_baseinventory.h"
#include "ui_node_model.h"
#include "ui_node_container.h"
#include "ui_node_abstractnode.h"
#include "../../client.h"
#include "../../renderer/r_draw.h"
#include "../../renderer/r_mesh.h"
#include "../../cl_game.h"
#include "../../cl_team.h"
#include "../../battlescape/cl_actor.h"
#include "../../cl_inventory.h"
Include dependency graph for ui_node_baseinventory.c:

Go to the source code of this file.

Data Structures

struct  containerItemIterator_t

Defines

#define EXTRADATA_TYPE   containerExtraData_t
#define EXTRADATA(node)   UI_EXTRADATA(node, EXTRADATA_TYPE)
#define EXTRADATACONST(node)   UI_EXTRADATACONST(node, EXTRADATA_TYPE)
#define CII_AMMOONLY   0x01
 Flag for containerItemIterator_t (CII) groupSteps.
#define CII_WEAPONONLY   0x02
#define CII_AVAILABLEONLY   0x04
#define CII_NOTAVAILABLEONLY   0x08
#define CII_END   0x80

Functions

static invList_tUI_ContainerNodeGetExistingItem (const uiNode_t *node, objDef_t *item, const itemFilterTypes_t filterType)
 Searches if there is an item at location (x/y) in a scrollable container. You can also provide an item to search for directly (x/y is ignored in that case).
static void UI_ContainerItemIteratorNext (containerItemIterator_t *iterator)
 Compute the next itemID.
static void UI_ContainerItemIteratorInit (containerItemIterator_t *iterator, const uiNode_t *const node)
 Use a container node to init an item iterator.
static void UI_BaseInventoryNodeUpdateScroll (uiNode_t *node)
 Update display of scroll buttons.
static void UI_GetItemTooltip (item_t item, char *tooltipText, size_t stringMaxLength)
 Generate tooltip text for an item.
static void UI_BaseInventoryNodeLoaded (uiNode_t *const node)
 Calculates the size of a container node and links the container into the node (uses the invDef_t shape bitmask to determine the size).
static int UI_BaseInventoryNodeDrawItems (uiNode_t *node, objDef_t *highlightType)
 Draw the base inventory.
static void UI_BaseInventoryNodeDraw2 (uiNode_t *node, objDef_t *highlightType)
 Draw the inventory of the base.
static void UI_BaseInventoryNodeDraw (uiNode_t *node)
 Main function to draw a container node.
static invList_tUI_BaseInventoryNodeGetItem (const uiNode_t *const node, int mouseX, int mouseY, int *contX, int *contY)
static void UI_BaseInventoryNodeDrawTooltip (uiNode_t *node, int x, int y)
 Custom tooltip for container node.
static void UI_ContainerNodeAutoPlace (uiNode_t *node, int mouseX, int mouseY)
 Try to autoplace an item at a position when right-click was used in the inventory.
static void UI_BaseInventoryNodeCapturedMouseMove (uiNode_t *node, int x, int y)
static void UI_BaseInventoryNodeMouseDown (uiNode_t *node, int x, int y, int button)
static void UI_BaseInventoryNodeMouseUp (uiNode_t *node, int x, int y, int button)
static void UI_BaseInventoryNodeWheel (uiNode_t *node, qboolean down, int x, int y)
static void UI_BaseInventoryNodeLoading (uiNode_t *node)
static qboolean UI_BaseInventoryNodeDNDEnter (uiNode_t *target)
 Call when a DND enter into the node.
static qboolean UI_BaseInventoryNodeDNDMove (uiNode_t *target, int x, int y)
 Call into the target when the DND hover it.
static void UI_BaseInventoryNodeDNDLeave (uiNode_t *node)
 Call when a DND enter into the node.
static void UI_BaseInventoryNodeInit (uiNode_t *node)
 Call when we open the window containing the node.
void UI_RegisterBaseInventoryNode (uiBehaviour_t *behaviour)

Variables

static int dragInfoFromX = -1
static int dragInfoFromY = -1
static const invList_tdragInfoIC
static const vec3_t scale = {3.5, 3.5, 3.5}
static const vec4_t colorDefault = {1, 1, 1, 1}
static const vec4_t colorLoadable = {0.5, 1, 0.5, 1}
static const vec4_t colorDisabled = {0.5, 0.5, 0.5, 1}
static const vec4_t colorDisabledHiden = {0.5, 0.5, 0.5, 0.5}
static const vec4_t colorDisabledLoadable = {0.5, 0.25, 0.25, 1.0}
static const vec4_t colorPreview = { 0.5, 0.5, 1, 1 }
static int oldMouseX = 0
static int oldMouseY = 0

Detailed Description

The container node refer to 3 different nodes merged into a singler one. Both can drag and drop solider items from a container to another one. The first container is a soldier slot. For example, the left arm, the bag pack... The second is the base item list. And the last it a floor container used into the battlescape. The node name itself is used to know the container role.

Todo:

Move base container list outside

Move container role outside of the node name

Link soldier container with a soldier

Link base container with a base

Link floor container with a map/cell...

Definition in file ui_node_baseinventory.c.


Define Documentation

#define CII_AMMOONLY   0x01

Flag for containerItemIterator_t (CII) groupSteps.

Definition at line 91 of file ui_node_baseinventory.c.

Referenced by UI_ContainerItemIteratorInit(), and UI_ContainerItemIteratorNext().

#define CII_AVAILABLEONLY   0x04
#define CII_END   0x80
#define CII_NOTAVAILABLEONLY   0x08
#define CII_WEAPONONLY   0x02

it mean any soldier equipment, else ammo

Definition at line 92 of file ui_node_baseinventory.c.

Referenced by UI_ContainerItemIteratorInit(), and UI_ContainerItemIteratorNext().

#define EXTRADATA ( node   )     UI_EXTRADATA(node, EXTRADATA_TYPE)

Definition at line 57 of file ui_node_baseinventory.c.

#define EXTRADATA_TYPE   containerExtraData_t

Definition at line 56 of file ui_node_baseinventory.c.

#define EXTRADATACONST ( node   )     UI_EXTRADATACONST(node, EXTRADATA_TYPE)

Definition at line 58 of file ui_node_baseinventory.c.


Function Documentation

static void UI_BaseInventoryNodeCapturedMouseMove ( uiNode_t node,
int  x,
int  y 
) [static]
static qboolean UI_BaseInventoryNodeDNDEnter ( uiNode_t target  )  [static]

Call when a DND enter into the node.

Definition at line 895 of file ui_node_baseinventory.c.

References DND_ITEM, EXTRADATA, qfalse, UI_DNDGetSourceNode(), and UI_DNDGetType().

Referenced by UI_RegisterBaseInventoryNode().

static void UI_BaseInventoryNodeDNDLeave ( uiNode_t node  )  [static]

Call when a DND enter into the node.

Definition at line 916 of file ui_node_baseinventory.c.

Referenced by UI_RegisterBaseInventoryNode().

static qboolean UI_BaseInventoryNodeDNDMove ( uiNode_t target,
int  x,
int  y 
) [static]

Call into the target when the DND hover it.

Returns:
True if the DND is accepted

Definition at line 908 of file ui_node_baseinventory.c.

References qtrue.

Referenced by UI_RegisterBaseInventoryNode().

static void UI_BaseInventoryNodeDraw ( uiNode_t node  )  [static]
static void UI_BaseInventoryNodeDraw2 ( uiNode_t node,
objDef_t highlightType 
) [static]
static int UI_BaseInventoryNodeDrawItems ( uiNode_t node,
objDef_t highlightType 
) [static]
static void UI_BaseInventoryNodeDrawTooltip ( uiNode_t node,
int  x,
int  y 
) [static]

Custom tooltip for container node.

Parameters:
[in] node Node we request to draw tooltip
[in] x Position x of the mouse
[in] y Position y of the mouse

Definition at line 640 of file ui_node_baseinventory.c.

References invList_s::item, MAX_VAR, Q_strcat(), UI_BaseInventoryNodeGetItem(), UI_DrawTooltip(), UI_GetItemTooltip(), UI_GetNodeAbsPos(), va(), invList_s::x, and invList_s::y.

Referenced by UI_RegisterBaseInventoryNode().

static invList_t* UI_BaseInventoryNodeGetItem ( const uiNode_t *const   node,
int  mouseX,
int  mouseY,
int *  contX,
int *  contY 
) [static]
static void UI_BaseInventoryNodeInit ( uiNode_t node  )  [static]

Call when we open the window containing the node.

ATM it should not work with the battlescape cause TU is not computed

Definition at line 923 of file ui_node_baseinventory.c.

References CL_BattlescapeRunning().

Referenced by UI_RegisterBaseInventoryNode().

static void UI_BaseInventoryNodeLoaded ( uiNode_t *const   node  )  [static]

Calculates the size of a container node and links the container into the node (uses the invDef_t shape bitmask to determine the size).

Parameters:
[in,out] node The node to get the size for

Definition at line 271 of file ui_node_baseinventory.c.

References EXTRADATA, and INVSH_GetInventoryDefinitionByID().

Referenced by UI_RegisterBaseInventoryNode().

static void UI_BaseInventoryNodeLoading ( uiNode_t node  )  [static]

Definition at line 885 of file ui_node_baseinventory.c.

References uiNode_s::color, and EXTRADATA.

Referenced by UI_RegisterBaseInventoryNode().

static void UI_BaseInventoryNodeMouseDown ( uiNode_t node,
int  x,
int  y,
int  button 
) [static]
static void UI_BaseInventoryNodeMouseUp ( uiNode_t node,
int  x,
int  y,
int  button 
) [static]
static void UI_BaseInventoryNodeUpdateScroll ( uiNode_t node  )  [static]

Update display of scroll buttons.

Note:
The cvars "mn_cont_scroll_prev_hover" and "mn_cont_scroll_next_hover" are set by the "in" and "out" functions of the scroll buttons.
Parameters:
[in] node Context node

Definition at line 210 of file ui_node_baseinventory.c.

References EXTRADATA, and UI_ExecuteEventActions().

Referenced by UI_BaseInventoryNodeDraw2(), UI_BaseInventoryNodeWheel(), and UI_ContainerNodeAutoPlace().

static void UI_BaseInventoryNodeWheel ( uiNode_t node,
qboolean  down,
int  x,
int  y 
) [static]

Definition at line 864 of file ui_node_baseinventory.c.

References EXTRADATA, and UI_BaseInventoryNodeUpdateScroll().

Referenced by UI_RegisterBaseInventoryNode().

static void UI_ContainerItemIteratorInit ( containerItemIterator_t iterator,
const uiNode_t *const   node 
) [static]
static void UI_ContainerItemIteratorNext ( containerItemIterator_t iterator  )  [static]

Compute the next itemID.

Note:
If something found, item type can be find with iterator->itemID
If item is available into the container iterator->itemFound point to this element
If nothing found (no next element) then iterator->itemID >= csi.numODs

Todo:
not sure its the right check

Definition at line 113 of file ui_node_baseinventory.c.

References CII_AMMOONLY, CII_AVAILABLEONLY, CII_END, CII_NOTAVAILABLEONLY, CII_WEAPONONLY, csi, containerItemIterator_t::filterEquipType, GAME_ItemIsUseable(), containerItemIterator_t::groupID, containerItemIterator_t::groupSteps, INV_IsAmmo, INV_IsArmour, INV_ItemMatchesFilter(), INVSH_GetItemByIDX(), objDef_s::isMisc, containerItemIterator_t::itemFound, containerItemIterator_t::itemID, containerItemIterator_t::node, csi_s::numODs, objDef_s::numWeapons, UI_ContainerNodeGetExistingItem(), and objDef_s::weapon.

Referenced by UI_BaseInventoryNodeDrawItems(), UI_BaseInventoryNodeGetItem(), and UI_ContainerItemIteratorInit().

static void UI_ContainerNodeAutoPlace ( uiNode_t node,
int  mouseX,
int  mouseY 
) [static]

Try to autoplace an item at a position when right-click was used in the inventory.

Parameters:
[in] node The context node
[in] mouseX X mouse coordinates.
[in] mouseY Y mouse coordinates.
Todo:

Not generic function. Not sure we can do it in a generic way

Merge it with node container, bad code but it is worst to have copy-paste of it

HACK: Hard to know where the item is located now, but if its an armor we fire the change event of the armour container. At least to update the actor skin. The right way is to compute the source and the target container and fire the change event for both

Definition at line 673 of file ui_node_baseinventory.c.

References item_s::a, CL_BattlescapeRunning(), cl_selected, Com_DPrintf(), csi, DEBUG_CLIENT, EXTRADATA, objDef_s::fireTwoHanded, objDef_s::headgear, id, csi_s::idArmour, csi_s::idBackpack, csi_s::idBelt, csi_s::idEquip, csi_s::idHeadgear, csi_s::idHolster, csi_s::idLeft, csi_s::idRight, objDef_s::idx, cvar_s::integer, INV_IsAmmo, INV_IsArmour, INV_LoadWeapon(), INV_MoveItem(), INV_UnloadWeapon(), INVDEF, INVSH_FindSpace(), INVSH_SearchInInventory(), invList_s::item, item_s::m, NONE, uiNode_s::onChange, qfalse, uiNode_s::root, item_s::t, UI_BaseInventoryNodeGetItem(), UI_BaseInventoryNodeUpdateScroll(), UI_ExecuteEventActions(), UI_GetNode(), ui_inventory, and objDef_s::weapon.

Referenced by UI_BaseInventoryNodeMouseDown().

static invList_t* UI_ContainerNodeGetExistingItem ( const uiNode_t node,
objDef_t item,
const itemFilterTypes_t  filterType 
) [static]

Searches if there is an item at location (x/y) in a scrollable container. You can also provide an item to search for directly (x/y is ignored in that case).

Note:
x = x-th item in a row, y = row. i.e. x/y does not equal the "grid" coordinates as used in those containers.
Parameters:
[in] node Context node
[in] item Item requested
[in] filterType Filter used.
Todo:
Remove filter it is not a generic concept, and here it mean nothing
Returns:
invList_t Pointer to the invList_t/item that is located at x/y or equals "item".
See also:
INVSH_SearchInInventory

Definition at line 83 of file ui_node_baseinventory.c.

References EXTRADATACONST, INVSH_SearchInInventoryWithFilter(), NONE, and ui_inventory.

Referenced by UI_BaseInventoryNodeDrawItems(), UI_BaseInventoryNodeGetItem(), and UI_ContainerItemIteratorNext().

static void UI_GetItemTooltip ( item_t  item,
char *  tooltipText,
size_t  stringMaxLength 
) [static]

Generate tooltip text for an item.

Parameters:
[in] item The item we want to generate the tooltip text for.
[in,out] tooltipText Pointer to a string the information should be written into.
[in] stringMaxLength Max. string size of tooltipText.
Returns:
Number of lines

Definition at line 224 of file ui_node_baseinventory.c.

References _, item_s::a, item_s::amount, Com_sprintf(), GAME_ItemIsUseable(), i, item_s::m, objDef_s::name, objDef_s::numWeapons, Q_strcat(), item_s::t, va(), objDef_s::weapon, and objDef_s::weapons.

Referenced by UI_BaseInventoryNodeDrawTooltip().

void UI_RegisterBaseInventoryNode ( uiBehaviour_t behaviour  ) 

Variable Documentation

const vec4_t colorDefault = {1, 1, 1, 1} [static]
Todo:
it may be nice to vectorise that

Definition at line 278 of file ui_node_baseinventory.c.

Referenced by UI_BaseInventoryNodeDrawItems().

const vec4_t colorDisabled = {0.5, 0.5, 0.5, 1} [static]

Definition at line 280 of file ui_node_baseinventory.c.

const vec4_t colorDisabledHiden = {0.5, 0.5, 0.5, 0.5} [static]

Definition at line 281 of file ui_node_baseinventory.c.

Referenced by UI_BaseInventoryNodeDrawItems().

const vec4_t colorDisabledLoadable = {0.5, 0.25, 0.25, 1.0} [static]

Definition at line 282 of file ui_node_baseinventory.c.

Referenced by UI_BaseInventoryNodeDrawItems().

const vec4_t colorLoadable = {0.5, 1, 0.5, 1} [static]

Definition at line 279 of file ui_node_baseinventory.c.

Referenced by UI_BaseInventoryNodeDrawItems().

const vec4_t colorPreview = { 0.5, 0.5, 1, 1 } [static]

Make the preview item look bluish

Definition at line 283 of file ui_node_baseinventory.c.

int dragInfoFromX = -1 [static]

self cache for drag item

Note:
we can use a global variable because we only can have 1 source node at a time

Definition at line 64 of file ui_node_baseinventory.c.

Referenced by UI_BaseInventoryNodeMouseDown().

int dragInfoFromY = -1 [static]

Definition at line 65 of file ui_node_baseinventory.c.

Referenced by UI_BaseInventoryNodeMouseDown().

const invList_t* dragInfoIC [static]

The current invList pointer (only used for ignoring the dragged item for finding free space right now)

Definition at line 71 of file ui_node_baseinventory.c.

int oldMouseX = 0 [static]
int oldMouseY = 0 [static]
const vec3_t scale = {3.5, 3.5, 3.5} [static]

Generated by  doxygen 1.6.2