UFO: Alien Invasion
Loading...
Searching...
No Matches
ui_node_baseinventory.cpp File Reference

"Base inventory" is one of the container nodes. It allow to see and drag and drop soldier items from a base to soldier equipments. More...

#include "../ui_main.h"
#include "../ui_parse.h"
#include "../ui_behaviour.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_lua.h"
#include "ui_node_baseinventory.h"
#include "ui_node_model.h"
#include "ui_node_container.h"
#include "ui_node_abstractnode.h"
#include "ui_node_abstractscrollable.h"
#include "../../cl_shared.h"
#include "../../cgame/cl_game.h"
#include "../../input/cl_keys.h"
#include "../../cl_inventory.h"
#include "../../../common/scripts_lua.h"
Include dependency graph for ui_node_baseinventory.cpp:

Go to the source code of this file.

Data Structures

struct  containerItemIterator_t

Macros

#define EXTRADATA_TYPE   baseInventoryExtraData_t
#define EXTRADATA(node)
#define EXTRADATACONST(node)
#define CII_AMMOONLY   0x01
 Flag for containerItemIterator_t (CII) groupSteps.
#define CII_WEAPONONLY   0x02
#define CII_AVAILABLEONLY   0x04
#define CII_NOTAVAILABLEONLY   0x08
#define CII_IMPLANTONLY   0x10
#define CII_END   0x80

Functions

bool CL_BattlescapeRunning (void)
 Check whether we already have actors spawned on the battlefield.
static ItemUI_ContainerNodeGetExistingItem (const uiNode_t *node, const 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 int UI_BaseInventoryNodeDrawItems (uiNode_t *node, const objDef_t *highlightType)
 Draw the base inventory.
static void UI_BaseInventoryNodeDraw2 (uiNode_t *node, const objDef_t *highlightType)
 Draw the inventory of the base.
static ItemUI_BaseInventoryNodeGetItem (const uiNode_t *const node, int mouseX, int mouseY, int *contX, int *contY)
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.
void UI_RegisterBaseInventoryNode (uiBehaviour_t *behaviour)

Variables

cvar_tcl_selected
static int dragInfoFromX = -1
static int dragInfoFromY = -1
static const ItemdragInfoIC
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 colorDisabledHiden = {0.5, 0.5, 0.5, 0.5}
static const vec4_t colorDisabledLoadable = {0.5, 0.25, 0.25, 1.0}
static int oldMouseX = 0
static int oldMouseY = 0

Detailed Description

"Base inventory" is one of the container nodes. It allow to see and drag and drop soldier items from a base to soldier equipments.

Todo
extend it with aircraft equipment

Definition in file ui_node_baseinventory.cpp.

Macro Definition Documentation

◆ CII_AMMOONLY

#define CII_AMMOONLY   0x01

Flag for containerItemIterator_t (CII) groupSteps.

Definition at line 94 of file ui_node_baseinventory.cpp.

Referenced by UI_ContainerItemIteratorInit(), and UI_ContainerItemIteratorNext().

◆ CII_AVAILABLEONLY

#define CII_AVAILABLEONLY   0x04

◆ CII_END

#define CII_END   0x80

◆ CII_IMPLANTONLY

#define CII_IMPLANTONLY   0x10

◆ CII_NOTAVAILABLEONLY

#define CII_NOTAVAILABLEONLY   0x08

◆ CII_WEAPONONLY

#define CII_WEAPONONLY   0x02

it mean any soldier equipment, else ammo

Definition at line 95 of file ui_node_baseinventory.cpp.

Referenced by UI_ContainerItemIteratorInit(), and UI_ContainerItemIteratorNext().

◆ EXTRADATA

#define EXTRADATA ( node)

◆ EXTRADATA_TYPE

#define EXTRADATA_TYPE   baseInventoryExtraData_t

Definition at line 52 of file ui_node_baseinventory.cpp.

◆ EXTRADATACONST

#define EXTRADATACONST ( node)

Function Documentation

◆ CL_BattlescapeRunning()

bool CL_BattlescapeRunning ( void )
extern

◆ UI_BaseInventoryNodeDraw2()

void UI_BaseInventoryNodeDraw2 ( uiNode_t * node,
const objDef_t * highlightType )
static

◆ UI_BaseInventoryNodeDrawItems()

◆ UI_BaseInventoryNodeGetItem()

◆ UI_BaseInventoryNodeUpdateScroll()

void UI_BaseInventoryNodeUpdateScroll ( uiNode_t * node)
static

Update display of scroll buttons.

Parameters
[in]nodeContext node

Definition at line 218 of file ui_node_baseinventory.cpp.

References EXTRADATA, UI_ExecuteEventActions(), and UI_ExecuteLuaEventScript().

Referenced by uiBaseInventoryNode::onScroll(), UI_BaseInventoryNodeDraw2(), and UI_ContainerNodeAutoPlace().

◆ UI_ContainerItemIteratorInit()

◆ UI_ContainerItemIteratorNext()

void UI_ContainerItemIteratorNext ( containerItemIterator_t * iterator)
static

◆ UI_ContainerNodeAutoPlace()

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]nodeThe context node
[in]mouseXX mouse coordinates.
[in]mouseYY mouse coordinates.

Definition at line 630 of file ui_node_baseinventory.cpp.

References CL_BattlescapeRunning(), cl_selected, Com_DPrintf(), DEBUG_CLIENT, EXTRADATA, UI_BaseInventoryNodeGetItem(), UI_BaseInventoryNodeUpdateScroll(), UI_ContainerNodeAutoPlaceItem(), and ui_inventory.

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

◆ UI_ContainerNodeGetExistingItem()

Item * UI_ContainerNodeGetExistingItem ( const uiNode_t * node,
const 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]nodeContext node
[in]itemItem requested
[in]filterTypeFilter used.
Todo
Remove filter it is not a generic concept, and here it mean nothing
Returns
Item Pointer to the Item/item that is located at x/y or equals "item".
See also
Inventory::getItemAtPos

Definition at line 82 of file ui_node_baseinventory.cpp.

References Com_Printf(), EXTRADATACONST, INV_SearchInInventoryWithFilter(), and ui_inventory.

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

◆ UI_RegisterBaseInventoryNode()

Variable Documentation

◆ cl_selected

◆ colorDefault

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

Definition at line 240 of file ui_node_baseinventory.cpp.

Referenced by UI_BaseInventoryNodeDrawItems(), UI_ContainerNodeDrawGrid(), and UI_ContainerNodeDrawSingle().

◆ colorDisabledHiden

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

Definition at line 242 of file ui_node_baseinventory.cpp.

Referenced by UI_BaseInventoryNodeDrawItems().

◆ colorDisabledLoadable

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

◆ colorLoadable

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

◆ dragInfoFromX

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 63 of file ui_node_baseinventory.cpp.

Referenced by uiContainerNode::onDndFinished(), uiBaseInventoryNode::onMouseDown(), and uiContainerNode::onMouseDown().

◆ dragInfoFromY

◆ dragInfoIC

const Item* dragInfoIC
static

◆ oldMouseX

◆ oldMouseY

◆ scale