UFO: Alien Invasion
Toggle main menu visibility
Loading...
Searching...
No Matches
ui_node_base.cpp
Go to the documentation of this file.
1
4
5
/*
6
Copyright (C) 2002-2025 UFO: Alien Invasion.
7
8
This program is free software; you can redistribute it and/or
9
modify it under the terms of the GNU General Public License
10
as published by the Free Software Foundation; either version 2
11
of the License, or (at your option) any later version.
12
13
This program is distributed in the hope that it will be useful,
14
but WITHOUT ANY WARRANTY; without even the implied warranty of
15
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
16
17
See the GNU General Public License for more details.
18
19
You should have received a copy of the GNU General Public License
20
along with this program; if not, write to the Free Software
21
Foundation, 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
"
34
#include "
../../input/cl_input.h
"
35
#include "
../../input/cl_keys.h
"
36
#include "
../../sound/s_main.h
"
37
38
#include "
../../../common/scripts_lua.h
"
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
52
void
uiBaseLayoutNode::drawTooltip
(
const
uiNode_t
* node,
int
x,
int
y)
const
53
{
54
GAME_DrawBaseLayoutTooltip
(
EXTRADATACONST
(node).baseid, x, y);
55
}
56
60
void
uiBaseLayoutNode::draw
(
uiNode_t
* node)
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
75
void
uiBaseLayoutNode::onLoading
(
uiNode_t
* node)
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
83
void
UI_RegisterBaseLayoutNode
(
uiBehaviour_t
* behaviour)
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
}
GAME_DrawBaseLayout
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
GAME_DrawBaseLayoutTooltip
void GAME_DrawBaseLayoutTooltip(int baseIdx, int x, int y)
Cgame callback to draw tooltip for baselayout UI node.
Definition
cl_game.cpp:1521
cl_game.h
Shared game type headers.
cl_input.h
External (non-keyboard) input devices.
cl_keys.h
Header file for keyboard handler.
cl_shared.h
Share stuff between the different cgame implementations.
uiBaseLayoutNode
Definition
ui_node_base.h:27
uiBaseLayoutNode::draw
void draw(uiNode_t *node) override
Draw a small square with the layout of the given base.
Definition
ui_node_base.cpp:60
uiBaseLayoutNode::onLoading
void onLoading(uiNode_t *node) override
Called before loading. Used to set default attribute values.
Definition
ui_node_base.cpp:75
uiBaseLayoutNode::drawTooltip
void drawTooltip(const uiNode_t *node, int x, int y) const override
Custom tooltip for baseayout.
Definition
ui_node_base.cpp:52
BASE_SIZE
#define BASE_SIZE
Definition
cp_base.h:38
s_main.h
Specifies sound API?
V_INT
@ V_INT
Definition
scripts.h:52
scripts_lua.h
Header for lua script functions.
baseExtraData_t
Definition
ui_node_base.h:34
uiBehaviour_t
node behaviour, how a node work
Definition
ui_behaviour.h:39
uiBehaviour_t::name
const char * name
Definition
ui_behaviour.h:41
uiBehaviour_t::lua_SWIG_typeinfo
void * lua_SWIG_typeinfo
Definition
ui_behaviour.h:57
uiBehaviour_t::manager
UINodePtr manager
Definition
ui_behaviour.h:43
uiBehaviour_t::extraDataSize
intptr_t extraDataSize
Definition
ui_behaviour.h:54
uiBox_t::size
vec2_t size
Definition
ui_nodes.h:52
uiNode_t
Atomic structure used to define most of the UI.
Definition
ui_nodes.h:80
uiNode_t::color
vec4_t color
Definition
ui_nodes.h:127
uiNode_t::box
uiBox_t box
Definition
ui_nodes.h:96
uiNode_t::padding
int padding
Definition
ui_nodes.h:109
uiNode_t::bgcolor
vec4_t bgcolor
Definition
ui_nodes.h:125
vec2_t
vec_t vec2_t[2]
Definition
ufotypes.h:38
ui_behaviour.h
UI_RegisterExtradataNodeProperty
#define UI_RegisterExtradataNodeProperty(BEHAVIOUR, NAME, TYPE, EXTRADATATYPE, ATTRIBUTE)
Initialize a property from extradata of node.
Definition
ui_behaviour.h:109
UI_SWIG_TypeQuery
void * UI_SWIG_TypeQuery(const char *name)
This function queries the SWIG type table for a type information structure. It is used in combination...
Definition
ui_lua_shared.cpp:2903
ui_main.h
UI_GetNodeAbsPos
void UI_GetNodeAbsPos(const uiNode_t *node, vec2_t pos)
Returns the absolute position of a node.
Definition
ui_node.cpp:526
UINodePtr
SharedPtr< uiNode > UINodePtr
Definition
ui_node_abstractnode.h:66
EXTRADATA_TYPE
#define EXTRADATA_TYPE
Definition
ui_node_abstractoption.cpp:38
EXTRADATA
#define EXTRADATA(node)
Definition
ui_node_abstractoption.cpp:39
EXTRADATACONST
#define EXTRADATACONST(node)
Definition
ui_node_abstractvalue.cpp:41
UI_RegisterBaseLayoutNode
void UI_RegisterBaseLayoutNode(uiBehaviour_t *behaviour)
Definition
ui_node_base.cpp:83
ui_node_base.h
ui_nodes.h
ui_parse.h
ui_render.h
ui_tooltip.h
Vector4Set
#define Vector4Set(v, r, g, b, a)
Definition
vector.h:62
src
client
ui
node
ui_node_base.cpp
Generated on __DATE__ __TIME__ for UFO: Alien Invasion by
1.17.0