|
UFO: Alien Invasion
|
The container node refer to several different nodes merged into a single one. All of them can drag and drop soldier items from one container to another. The first container is a soldier slot. For example, the left arm, the bag pack... The second is the base inventory (which is now an extended node from container). And the last is a floor container used in the battlescape. The node name itself is used to know the container role. 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_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 "../../cgame/cl_game.h"#include "../../battlescape/cl_actor.h"#include "../../cl_inventory.h"#include "../../../common/scripts_lua.h"
Go to the source code of this file.
Macros | |
| #define | EXTRADATA_TYPE containerExtraData_t |
| #define | EXTRADATA(node) |
| #define | EXTRADATACONST(node) |
Functions | |
| static bool | UI_IsScrollContainerNode (const uiNode_t *const node) |
| 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. | |
| 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. | |
| void | UI_GetItemTooltip (const Item &item, char *tooltipText, size_t stringMaxLength) |
| Generate tooltip text for an item. | |
| uiNode_t * | UI_GetContainerNodeByContainerIDX (const uiNode_t *const parent, const int index) |
| Search a child container node by the given container id. | |
| static void | UI_DrawDisabled (const uiNode_t *node) |
| Draws the rectangle in a 'free' style on position posx/posy (pixel) in the size sizex/sizey (pixel). | |
| static void | UI_DrawFree (containerIndex_t container, const uiNode_t *node, int posx, int posy, int sizex, int sizey, bool showTUs) |
| Draws the rectangle in a 'free' style on position posx/posy (pixel) in the size sizex/sizey (pixel). | |
| static void | UI_ContainerNodeDrawFreeSpace (uiNode_t *node, Inventory *inv) |
| Draws the free and usable inventory positions when dragging an item. | |
| static void | UI_ContainerNodeDrawSingle (uiNode_t *node, const objDef_t *highlightType) |
| Draw a container which only contains one item. | |
| static void | UI_ContainerNodeDrawGrid (uiNode_t *node, const objDef_t *highlightType) |
| Draw a grip container. | |
| static void | UI_ContainerNodeDrawDropPreview (uiNode_t *target) |
| Draw a preview of the DND item dropped into the node. | |
| static Item * | UI_ContainerNodeGetItemAtPosition (const uiNode_t *const node, int mouseX, int mouseY, int *contX=nullptr, int *contY=nullptr) |
| Gets location of the item the mouse is over. | |
| static bool | UI_ContainerNodeAddItem (const invDef_t *container, Item *ic, containerIndex_t containerID, Item **icp) |
| void | UI_ContainerNodeAutoPlaceItem (uiNode_t *node, Item *ic) |
| Try to autoplace an item from a container. | |
| 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_RegisterContainerNode (uiBehaviour_t *behaviour) |
Variables | |
| Inventory * | ui_inventory = nullptr |
| static int | dragInfoFromX = -1 |
| static int | dragInfoFromY = -1 |
| static int | dragInfoToX = -1 |
| static int | dragInfoToY = -1 |
| static const Item * | 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 | 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 several different nodes merged into a single one. All of them can drag and drop soldier items from one container to another. The first container is a soldier slot. For example, the left arm, the bag pack... The second is the base inventory (which is now an extended node from container). And the last is a floor container used in the battlescape. The node name itself is used to know the container role.
Move container role outside of the node name
Link soldier container with a soldier
Link floor container with a map/cell...
Definition in file ui_node_container.cpp.
| #define EXTRADATA | ( | node | ) |
Definition at line 65 of file ui_node_container.cpp.
Referenced by UI_ContainerNodeAutoPlace(), UI_ContainerNodeAutoPlaceItem(), UI_ContainerNodeDrawDropPreview(), UI_ContainerNodeDrawFreeSpace(), UI_ContainerNodeDrawGrid(), and UI_ContainerNodeDrawSingle().
| #define EXTRADATA_TYPE containerExtraData_t |
Definition at line 64 of file ui_node_container.cpp.
| #define EXTRADATACONST | ( | node | ) |
Definition at line 66 of file ui_node_container.cpp.
Referenced by UI_ContainerNodeGetItemAtPosition(), and UI_IsScrollContainerNode().
|
static |
Definition at line 673 of file ui_node_container.cpp.
References INV_MoveItem(), INVDEF, and ui_inventory.
Referenced by UI_ContainerNodeAutoPlaceItem().
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. |
Definition at line 795 of file ui_node_container.cpp.
References CL_BattlescapeRunning(), cl_selected, EXTRADATA, UI_ContainerNodeAutoPlaceItem(), UI_ContainerNodeGetItemAtPosition(), and ui_inventory.
Try to autoplace an item from a container.
| [in] | node | The context node |
| [in] | ic | An item from the node container |
Definition at line 687 of file ui_node_container.cpp.
References Item::ammoDef(), CID_ARMOUR, CID_BACKPACK, CID_BELT, CID_EQUIP, CID_HEADGEAR, CID_HOLSTER, CID_IMPLANT, CID_LEFT, CID_RIGHT, Item::def(), EXTRADATA, Item::getAmmoLeft(), objDef_t::headgear, i, invDef_t::id, objDef_t::idx, objDef_t::implant, INV_LoadWeapon(), INV_MoveItem(), INV_UnloadWeapon(), INVDEF, objDef_t::isAmmo(), Item::isArmour(), Item::isWeapon(), lengthof, uiNode_t::lua_onChange, NONE, uiNode_t::onChange, uiNode_t::parent, uiNode_t::root, targetNode, UI_ContainerNodeAddItem(), UI_ExecuteEventActions(), UI_ExecuteLuaEventScript(), UI_GetContainerNodeByContainerIDX(), UI_GetNode(), ui_inventory, and objDef_t::weapons.
Referenced by UI_ContainerNodeAutoPlace(), and UI_ContainerNodeAutoPlace().
Draw a preview of the DND item dropped into the node.
Definition at line 523 of file ui_node_container.cpp.
References uiNode_t::box, C_UNIT, CL_BattlescapeRunning(), colorPreview, Item::def(), dragInfoIC, dragInfoToX, dragInfoToY, EXTRADATA, INV_DOES_NOT_FIT, INV_FITS, INV_FITS_BOTH, INV_FITS_ONLY_ROTATED, Item::isArmour(), K_SHIFT, Key_IsDown(), Item::rotated, scale, uiBox_t::size, UI_DNDGetItem(), UI_DrawItem(), UI_GetNodeAbsPos(), ui_inventory, and UI_IsScrollContainerNode().
Referenced by uiContainerNode::draw().
Draws the free and usable inventory positions when dragging an item.
< Get the 'type' of the dragged item.
Definition at line 334 of file ui_node_container.cpp.
References uiNode_t::box, C_UNIT, Inventory::canHoldItem(), Item::def(), dragInfoIC, EXTRADATA, objDef_t::getShapeRotated(), INV_FITS, INV_FITS_ONLY_ROTATED, INVSH_CheckShape(), INVSH_MergeShapes(), OBJZERO, objDef_t::shape, SHAPE_BIG_MAX_HEIGHT, SHAPE_BIG_MAX_WIDTH, uiBox_t::size, UI_DNDGetItem(), UI_DNDIsDragging(), UI_DNDIsSourceNode(), UI_DrawFree(), and UI_GetNodeAbsPos().
Referenced by uiContainerNode::draw().
Draw a grip container.
Definition at line 502 of file ui_node_container.cpp.
References colorDefault, colorLoadable, Item::def(), EXTRADATA, Container::getNextItem(), Item::getX(), Item::getY(), objDef_t::isLoadableInWeapon(), scale, UI_DrawItem(), UI_GetNodeAbsPos(), and ui_inventory.
Referenced by uiContainerNode::draw().
Draw a container which only contains one item.
| node | Context node |
| highlightType | Current selected object |
Definition at line 435 of file ui_node_container.cpp.
References uiNode_t::box, colorDefault, colorDisabled, colorDisabledLoadable, colorLoadable, Item::def(), EXTRADATA, objDef_t::fireTwoHanded, invDef_t::id, Item::isHeldTwoHanded(), invDef_t::isLeftDef(), objDef_t::isLoadableInWeapon(), invDef_t::isRightDef(), scale, uiBox_t::size, UI_DrawDisabled(), UI_DrawItem(), UI_GetNodeAbsPos(), ui_inventory, and Vector4Copy.
Referenced by uiContainerNode::draw().
|
static |
Gets location of the item the mouse is over.
| [in] | node | The container-node. |
| [in] | mouseX | X location of the mouse. |
| [in] | mouseY | Y location of the mouse. |
| [out] | contX | X location in the container (index of item in row). |
| [out] | contY | Y location in the container (row). |
Definition at line 625 of file ui_node_container.cpp.
References C_UNIT, EXTRADATACONST, int(), Sys_Error(), UI_GetNodeAbsPos(), ui_inventory, and UI_IsScrollContainerNode().
Referenced by uiContainerNode::drawTooltip(), uiContainerNode::onMouseDown(), and UI_ContainerNodeAutoPlace().
| 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.
ui_inventory pointer must be set | [in,out] | inv | The inventory to add the unused items from ed to |
| [in] | ed | The equipment definition to get the used items from that should be added to the ground container of inv |
Definition at line 102 of file ui_node_container.cpp.
References CID_EQUIP, cls, csi, Item::def(), FILTER_AIRCRAFT, GAME_ItemIsUseable(), Inventory::getEquipContainer(), i, objDef_t::idx, INVDEF, INVSH_GetItemByIDX(), lengthof, MAX_CONTAINERS, Mem_Dup, Mem_Free, NONE, equipDef_t::numItems, and ui_inventory.
Referenced by GAME_GetImportData(), and GAME_UpdateInventory().
Draws the rectangle in a 'free' style on position posx/posy (pixel) in the size sizex/sizey (pixel).
Definition at line 300 of file ui_node_container.cpp.
References uiNode_t::box, uiBox_t::size, UI_DrawFill(), and UI_GetNodeAbsPos().
Referenced by UI_ContainerNodeDrawSingle().
|
static |
Draws the rectangle in a 'free' style on position posx/posy (pixel) in the size sizex/sizey (pixel).
Definition at line 312 of file ui_node_container.cpp.
References _, ALIGN_UL, uiNode_t::box, CL_BattlescapeRunning(), invDef_t::in, INVDEF, invDef_t::out, uiBox_t::size, UI_DrawFill(), UI_DrawString(), UI_GetNodeAbsPos(), and va().
Referenced by UI_ContainerNodeDrawFreeSpace().
| 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.
| [in] | node | Context node |
| [in] | org | Node position on the screen (pixel). Single nodes: Use the center of the node. |
| [in] | item | The item to draw. |
| [in] | x,y | Position in container. Set both to -1 if it's drawn in a single container. |
| [in] | scale | |
| [in] | color |
Definition at line 149 of file ui_node_container.cpp.
References modelInfo_t::angles, C_UNIT, modelInfo_t::center, objDef_t::center, modelInfo_t::color, Com_Printf(), Item::def(), GAME_GetModelForItem(), objDef_t::id, objDef_t::image, Item::mustReload(), modelInfo_t::name, OBJZERO, modelInfo_t::origin, Q_strnull(), R_Color(), R_DrawModelDirect(), Item::rotated, modelInfo_t::scale, objDef_t::scale, scale, objDef_t::sx, objDef_t::sy, UI_DrawModelNode(), UI_DrawNormImageByName(), Vector4Copy, VectorCopy, VectorNegate, VectorScale, and objDef_t::weapon.
Referenced by uiItemNode::draw(), UI_BaseInventoryNodeDrawItems(), UI_ContainerNodeDrawDropPreview(), UI_ContainerNodeDrawGrid(), UI_ContainerNodeDrawSingle(), and UI_DrawDragAndDrop().
Search a child container node by the given container id.
Definition at line 290 of file ui_node_container.cpp.
References index, INVDEF, invDef_t::name, and UI_GetNode().
Referenced by UI_ContainerNodeAutoPlaceItem().
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 247 of file ui_node_container.cpp.
References _, Item::ammoDef(), Com_sprintf(), Item::def(), GAME_ItemIsUseable(), Item::getAmmoLeft(), Item::getAmount(), i, Item::isWeapon(), objDef_t::name, objDef_t::numWeapons, Q_strcat(), and objDef_t::weapons.
Referenced by uiBaseInventoryNode::drawTooltip(), and uiContainerNode::drawTooltip().
|
inlinestatic |
Definition at line 88 of file ui_node_container.cpp.
References EXTRADATACONST.
Referenced by uiContainerNode::draw(), uiContainerNode::onDndEnter(), uiContainerNode::onDndFinished(), uiContainerNode::onDndMove(), uiContainerNode::onLoaded(), UI_ContainerNodeDrawDropPreview(), and UI_ContainerNodeGetItemAtPosition().
| void UI_RegisterContainerNode | ( | uiBehaviour_t * | behaviour | ) |
Definition at line 1072 of file ui_node_container.cpp.
References EXTRADATA_TYPE, uiBehaviour_t::extraDataSize, uiBehaviour_t::lua_SWIG_typeinfo, uiBehaviour_t::manager, uiBehaviour_t::name, UI_RegisterExtradataNodeProperty, UI_SWIG_TypeQuery(), V_INT, and V_UI_ACTION.
|
static |
Definition at line 424 of file ui_node_container.cpp.
|
static |
Definition at line 426 of file ui_node_container.cpp.
Referenced by UI_ContainerNodeDrawSingle().
|
static |
Definition at line 427 of file ui_node_container.cpp.
|
static |
Definition at line 425 of file ui_node_container.cpp.
|
static |
Make the preview item look bluish
Definition at line 428 of file ui_node_container.cpp.
Referenced by UI_ContainerNodeDrawDropPreview().
|
static |
self cache for drag item
Definition at line 72 of file ui_node_container.cpp.
|
static |
Definition at line 73 of file ui_node_container.cpp.
|
static |
The current invList pointer (only used for ignoring the dragged item for finding free space right now)
Definition at line 86 of file ui_node_container.cpp.
|
static |
self cache for the preview and dropped item
Definition at line 79 of file ui_node_container.cpp.
Referenced by uiContainerNode::onDndFinished(), uiContainerNode::onDndLeave(), uiContainerNode::onDndMove(), and UI_ContainerNodeDrawDropPreview().
|
static |
Definition at line 80 of file ui_node_container.cpp.
Referenced by uiContainerNode::onDndFinished(), uiContainerNode::onDndLeave(), uiContainerNode::onDndMove(), and UI_ContainerNodeDrawDropPreview().
|
static |
Definition at line 816 of file ui_node_container.cpp.
|
static |
Definition at line 817 of file ui_node_container.cpp.
|
static |
Definition at line 422 of file ui_node_container.cpp.
Definition at line 62 of file ui_node_container.cpp.
Referenced by CL_ActorSelect(), uiBaseInventoryNode::draw(), uiContainerNode::draw(), GAME_ActorSelect_f(), GAME_GetImportData(), GAME_UpdateInventory(), uiContainerNode::onDndFinished(), uiContainerNode::onDndMove(), UI_ContainerNodeAddItem(), UI_ContainerNodeAutoPlace(), UI_ContainerNodeAutoPlace(), UI_ContainerNodeAutoPlaceItem(), UI_ContainerNodeDrawDropPreview(), UI_ContainerNodeDrawGrid(), UI_ContainerNodeDrawSingle(), UI_ContainerNodeGetExistingItem(), UI_ContainerNodeGetItemAtPosition(), and UI_ContainerNodeUpdateEquipment().