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"
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_t * | UI_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_t * | UI_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_t * | dragInfoIC |
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 |
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.
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 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 |
Definition at line 93 of file ui_node_baseinventory.c.
Referenced by UI_ContainerItemIteratorInit(), and UI_ContainerItemIteratorNext().
#define CII_END 0x80 |
Definition at line 95 of file ui_node_baseinventory.c.
Referenced by UI_ContainerItemIteratorInit(), and UI_ContainerItemIteratorNext().
#define CII_NOTAVAILABLEONLY 0x08 |
Definition at line 94 of file ui_node_baseinventory.c.
Referenced by UI_ContainerItemIteratorInit(), and UI_ContainerItemIteratorNext().
#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.
static void UI_BaseInventoryNodeCapturedMouseMove | ( | uiNode_t * | node, | |
int | x, | |||
int | y | |||
) | [static] |
Definition at line 810 of file ui_node_baseinventory.c.
References invList_s::item, oldMouseX, oldMouseY, UI_DNDDragItem(), and UI_MouseRelease().
Referenced by UI_RegisterBaseInventoryNode().
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().
Call into the target when the DND hover it.
Definition at line 908 of file ui_node_baseinventory.c.
References qtrue.
Referenced by UI_RegisterBaseInventoryNode().
static void UI_BaseInventoryNodeDraw | ( | uiNode_t * | node | ) | [static] |
Main function to draw a container node.
Definition at line 483 of file ui_node_baseinventory.c.
References uiNode_s::color, DND_ITEM, EXTRADATA, item_s::t, UI_BaseInventoryNodeDraw2(), UI_DNDGetItem(), UI_DNDGetType(), UI_DNDIsDragging(), and ui_inventory.
Referenced by UI_RegisterBaseInventoryNode().
Draw the inventory of the base.
Definition at line 439 of file ui_node_baseinventory.c.
References ALIGN_UL, EXTRADATA, uiNode_s::pos, pos, qfalse, qtrue, R_FontDrawString(), R_PopClipRect(), R_PushClipRect(), uiNode_s::size, UI_BaseInventoryNodeDrawItems(), UI_BaseInventoryNodeUpdateScroll(), UI_GetNodeAbsPos(), and va().
Referenced by UI_BaseInventoryNodeDraw().
Draw the base inventory.
Definition at line 289 of file ui_node_baseinventory.c.
References _, ALIGN_LC, ALIGN_UL, objDef_s::ammos, item_s::amount, C_UNIT, colorDefault, colorDisabledHiden, colorDisabledLoadable, colorLoadable, csi, EXTRADATA, GAME_ItemIsUseable(), INV_IsAmmo, INVSH_GetItemByIDX(), INVSH_LoadableInWeapon(), invList_s::item, containerItemIterator_t::itemFound, containerItemIterator_t::itemID, LONGLINES_WRAP, objDef_s::name, objDef_s::numAmmos, csi_s::numODs, pos, qfalse, qtrue, R_FontTextSize(), scale, uiNode_s::size, objDef_s::sx, objDef_s::sy, item_s::t, UI_ContainerItemIteratorInit(), UI_ContainerItemIteratorNext(), UI_ContainerNodeGetExistingItem(), UI_DrawItem(), UI_DrawString(), UI_GetNodeAbsPos(), va(), Vector2Copy, and objDef_s::weapon.
Referenced by UI_BaseInventoryNodeDraw2().
static void UI_BaseInventoryNodeDrawTooltip | ( | uiNode_t * | node, | |
int | x, | |||
int | y | |||
) | [static] |
Custom tooltip for container node.
[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] |
Definition at line 506 of file ui_node_baseinventory.c.
References _, objDef_s::ammos, C_UNIT, csi, EXTRADATACONST, GAME_ItemIsUseable(), INVSH_GetItemByIDX(), containerItemIterator_t::itemFound, containerItemIterator_t::itemID, LONGLINES_WRAP, objDef_s::name, NONE, objDef_s::numAmmos, csi_s::numODs, pos, qfalse, R_FontTextSize(), uiNode_s::size, objDef_s::sx, objDef_s::sy, UI_ContainerItemIteratorInit(), UI_ContainerItemIteratorNext(), UI_ContainerNodeGetExistingItem(), UI_GetNodeAbsPos(), Vector2Copy, objDef_s::weapon, invList_s::x, and invList_s::y.
Referenced by UI_BaseInventoryNodeDrawTooltip(), UI_BaseInventoryNodeMouseDown(), and UI_ContainerNodeAutoPlace().
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).
[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] |
Definition at line 819 of file ui_node_baseinventory.c.
References dragInfoFromX, dragInfoFromY, EXTRADATA, objDef_s::idx, invList_s::item, K_MOUSE1, K_MOUSE2, oldMouseX, oldMouseY, item_s::t, UI_BaseInventoryNodeGetItem(), UI_ContainerNodeAutoPlace(), UI_DNDAbort(), UI_DNDIsDragging(), UI_ExecuteEventActions(), and UI_SetMouseCapture().
Referenced by UI_RegisterBaseInventoryNode().
static void UI_BaseInventoryNodeMouseUp | ( | uiNode_t * | node, | |
int | x, | |||
int | y, | |||
int | button | |||
) | [static] |
Definition at line 853 of file ui_node_baseinventory.c.
References K_MOUSE1, UI_DNDDrop(), UI_DNDIsDragging(), UI_GetMouseCapture(), and UI_MouseRelease().
Referenced by UI_RegisterBaseInventoryNode().
static void UI_BaseInventoryNodeUpdateScroll | ( | uiNode_t * | node | ) | [static] |
Update display of scroll buttons.
[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().
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] |
Use a container node to init an item iterator.
Definition at line 170 of file ui_node_baseinventory.c.
References CII_AMMOONLY, CII_AVAILABLEONLY, CII_END, CII_NOTAVAILABLEONLY, CII_WEAPONONLY, EXTRADATACONST, containerItemIterator_t::filterEquipType, containerItemIterator_t::groupID, containerItemIterator_t::groupSteps, containerItemIterator_t::itemID, containerItemIterator_t::node, and UI_ContainerItemIteratorNext().
Referenced by UI_BaseInventoryNodeDrawItems(), and UI_BaseInventoryNodeGetItem().
static void UI_ContainerItemIteratorNext | ( | containerItemIterator_t * | iterator | ) | [static] |
Compute the next itemID.
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.
[in] | node | The context node |
[in] | mouseX | X mouse coordinates. |
[in] | mouseY | Y mouse coordinates. |
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).
[in] | node | Context node |
[in] | item | Item requested |
[in] | filterType | Filter used. |
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.
[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 . |
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 | ) |
Definition at line 929 of file ui_node_baseinventory.c.
References uiBehaviour_s::capturedMouseMove, Com_RegisterConstInt(), uiBehaviour_s::dndEnter, uiBehaviour_s::dndLeave, uiBehaviour_s::dndMove, uiBehaviour_s::draw, uiBehaviour_s::drawTooltip, uiBehaviour_s::extends, FILTER_AIRCRAFT, FILTER_CRAFTITEM, FILTER_DISASSEMBLY, FILTER_DUMMY, FILTER_S_ARMOUR, FILTER_S_HEAVY, FILTER_S_MISC, FILTER_S_PRIMARY, FILTER_S_SECONDARY, FILTER_UGVITEM, uiBehaviour_s::init, uiBehaviour_s::loaded, uiBehaviour_s::loading, uiBehaviour_s::mouseDown, uiBehaviour_s::mouseUp, uiBehaviour_s::mouseWheel, uiBehaviour_s::name, UI_BaseInventoryNodeCapturedMouseMove(), UI_BaseInventoryNodeDNDEnter(), UI_BaseInventoryNodeDNDLeave(), UI_BaseInventoryNodeDNDMove(), UI_BaseInventoryNodeDraw(), UI_BaseInventoryNodeDrawTooltip(), UI_BaseInventoryNodeInit(), UI_BaseInventoryNodeLoaded(), UI_BaseInventoryNodeLoading(), UI_BaseInventoryNodeMouseDown(), UI_BaseInventoryNodeMouseUp(), and UI_BaseInventoryNodeWheel().
const vec4_t colorDefault = {1, 1, 1, 1} [static] |
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
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] |
Definition at line 807 of file ui_node_baseinventory.c.
Referenced by UI_BaseInventoryNodeCapturedMouseMove(), and UI_BaseInventoryNodeMouseDown().
int oldMouseY = 0 [static] |
Definition at line 808 of file ui_node_baseinventory.c.
Referenced by UI_BaseInventoryNodeCapturedMouseMove(), and UI_BaseInventoryNodeMouseDown().
Definition at line 276 of file ui_node_baseinventory.c.
Referenced by Vector4ClipPolygon< ClipPlane >::apply(), BuildFacelights(), BuildVertexNormals(), ConstructDevice2Manip(), edge_snap(), DragPlanes::evaluateTransform(), ExportLightmap(), homogenous_clip_line(), M_AddToSampleBuffer(), Matrix4x4_Invert_Simple(), Matrix4x4_Normalize(), Matrix4x4_Normalize3(), Matrix4x4_TransformPositivePlane(), Matrix4x4_TransformStandardPlane(), Pivot2World_viewplaneSpace(), Pivot2World_viewpointSpace(), Pivot2World_worldSpace(), R_Draw2DMapMarkers(), R_Draw3DMapMarkers(), R_DrawFlareSurfaces(), R_FilterTexture(), read_scale(), SV_ModLoadAliasMD2Model(), UI_BaseInventoryNodeDrawItems(), UI_DrawDragAndDrop(), UI_EKGNodeDraw(), UI_ImageNodeDraw(), UI_InitModelInfoView(), UI_ItemNodeDraw(), UI_ModelNodeLoading(), and WindingCenter().