UFO: Alien Invasion
Loading...
Searching...
No Matches
ui_node_base.cpp
Go to the documentation of this file.
1
4
5/*
6Copyright (C) 2002-2025 UFO: Alien Invasion.
7
8This program is free software; you can redistribute it and/or
9modify it under the terms of the GNU General Public License
10as published by the Free Software Foundation; either version 2
11of the License, or (at your option) any later version.
12
13This program is distributed in the hope that it will be useful,
14but WITHOUT ANY WARRANTY; without even the implied warranty of
15MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
16
17See the GNU General Public License for more details.
18
19You should have received a copy of the GNU General Public License
20along with this program; if not, write to the Free Software
21Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
22*/
23
24#include "../ui_main.h"
25#include "../ui_parse.h"
26#include "../ui_behaviour.h"
27#include "../ui_tooltip.h"
28#include "../ui_nodes.h"
29#include "../ui_render.h"
30#include "ui_node_base.h"
31
32#include "../../cl_shared.h"
33#include "../../cgame/cl_game.h"
35#include "../../input/cl_keys.h"
36#include "../../sound/s_main.h"
37
39
40#define EXTRADATA_TYPE baseExtraData_t
41#define EXTRADATA(node) UI_EXTRADATA(node, EXTRADATA_TYPE)
42#define EXTRADATACONST(node) UI_EXTRADATACONST(node, EXTRADATA_TYPE)
43
44// TODO: remove me - duplicated in cp_base.h
45#define BASE_SIZE 5
46
52void uiBaseLayoutNode::drawTooltip (const uiNode_t* node, int x, int y) const
53{
55}
56
61{
62 const int totalMarge = node->padding * (BASE_SIZE + 1);
63 const int width = (node->box.size[0] - totalMarge) / BASE_SIZE;
64 const int height = (node->box.size[1] - totalMarge) / BASE_SIZE;
65
66 vec2_t nodepos;
67 UI_GetNodeAbsPos(node, nodepos);
68
69 GAME_DrawBaseLayout(EXTRADATA(node).baseid, nodepos[0], nodepos[1], totalMarge, width, height, node->padding, node->bgcolor, node->color);
70}
71
76{
77 EXTRADATA(node).baseid = -1;
78 node->padding = 3;
79 Vector4Set(node->color, 1, 1, 1, 1);
80 Vector4Set(node->bgcolor, 0.5, 0.5, 0.5, 1);
81}
82
84{
85 behaviour->name = "baselayout";
86 behaviour->manager = UINodePtr(new uiBaseLayoutNode());
87 behaviour->extraDataSize = sizeof(EXTRADATA_TYPE);
88 behaviour->lua_SWIG_typeinfo = UI_SWIG_TypeQuery("uiBaseLayoutNode_t *");
89
90 /* Identify the base, from a base ID, the node use. */
91 UI_RegisterExtradataNodeProperty(behaviour, "baseid", V_INT, baseExtraData_t, baseid);
92}
void GAME_DrawBaseLayout(int baseIdx, int x, int y, int totalMarge, int w, int h, int padding, const vec4_t bgcolor, const vec4_t color)
Definition cl_game.cpp:1508
void GAME_DrawBaseLayoutTooltip(int baseIdx, int x, int y)
Cgame callback to draw tooltip for baselayout UI node.
Definition cl_game.cpp:1521
Shared game type headers.
External (non-keyboard) input devices.
Header file for keyboard handler.
Share stuff between the different cgame implementations.
void draw(uiNode_t *node) override
Draw a small square with the layout of the given base.
void onLoading(uiNode_t *node) override
Called before loading. Used to set default attribute values.
void drawTooltip(const uiNode_t *node, int x, int y) const override
Custom tooltip for baseayout.
#define BASE_SIZE
Definition cp_base.h:38
Specifies sound API?
@ V_INT
Definition scripts.h:52
Header for lua script functions.
node behaviour, how a node work
const char * name
void * lua_SWIG_typeinfo
UINodePtr manager
intptr_t extraDataSize
vec2_t size
Definition ui_nodes.h:52
Atomic structure used to define most of the UI.
Definition ui_nodes.h:80
vec4_t color
Definition ui_nodes.h:127
uiBox_t box
Definition ui_nodes.h:96
int padding
Definition ui_nodes.h:109
vec4_t bgcolor
Definition ui_nodes.h:125
vec_t vec2_t[2]
Definition ufotypes.h:38
#define UI_RegisterExtradataNodeProperty(BEHAVIOUR, NAME, TYPE, EXTRADATATYPE, ATTRIBUTE)
Initialize a property from extradata of node.
void * UI_SWIG_TypeQuery(const char *name)
This function queries the SWIG type table for a type information structure. It is used in combination...
void UI_GetNodeAbsPos(const uiNode_t *node, vec2_t pos)
Returns the absolute position of a node.
Definition ui_node.cpp:526
SharedPtr< uiNode > UINodePtr
#define EXTRADATA_TYPE
#define EXTRADATA(node)
#define EXTRADATACONST(node)
void UI_RegisterBaseLayoutNode(uiBehaviour_t *behaviour)
#define Vector4Set(v, r, g, b, a)
Definition vector.h:62