UFO: Alien Invasion
Toggle main menu visibility
Loading...
Searching...
No Matches
ui_node_texture.cpp
Go to the documentation of this file.
1
13
14
/*
15
Copyright (C) 2002-2025 UFO: Alien Invasion.
16
17
This program is free software; you can redistribute it and/or
18
modify it under the terms of the GNU General Public License
19
as published by the Free Software Foundation; either version 2
20
of the License, or (at your option) any later version.
21
22
This program is distributed in the hope that it will be useful,
23
but WITHOUT ANY WARRANTY; without even the implied warranty of
24
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
25
26
See the GNU General Public License for more details.
27
28
You should have received a copy of the GNU General Public License
29
along with this program; if not, write to the Free Software
30
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
31
32
*/
33
34
#include "
../ui_nodes.h
"
35
#include "
../ui_parse.h
"
36
#include "
../ui_behaviour.h
"
37
#include "
../ui_render.h
"
38
#include "
../../renderer/r_draw.h
"
39
#include "
ui_node_texture.h
"
40
#include "
ui_node_abstractnode.h
"
41
42
#include "
../../../common/scripts_lua.h
"
43
44
#define EXTRADATA_TYPE 0
45
50
void
uiTextureNode::draw
(
uiNode_t
* node)
51
{
52
vec2_t
nodepos;
53
const
image_t
* image;
54
55
const
char
* imageName =
UI_GetReferenceString
(node, node->
image
);
56
if
(
Q_strnull
(imageName))
57
return
;
58
59
image =
UI_LoadWrappedImage
(imageName);
60
if
(!image)
61
return
;
62
63
/* avoid potential infinit loop */
64
if
(image->
height
== 0 || image->
width
== 0)
65
return
;
66
67
UI_GetNodeAbsPos
(node, nodepos);
68
69
UI_DrawNormImage
(
false
, nodepos[0], nodepos[1], node->
box
.
size
[0], node->
box
.
size
[1], node->
box
.
size
[0], node->
box
.
size
[1], 0, 0, image);
70
}
71
72
void
UI_RegisterTextureNode
(
uiBehaviour_t
* behaviour)
73
{
74
behaviour->
name
=
"texture"
;
75
behaviour->
manager
=
UINodePtr
(
new
uiTextureNode
());
76
behaviour->
extraDataSize
=
sizeof
(
EXTRADATA_TYPE
);
77
behaviour->
lua_SWIG_typeinfo
=
UI_SWIG_TypeQuery
(
"uiTextureNode_t *"
);
78
79
/* Source of the texture */
80
UI_RegisterNodeProperty
(behaviour,
"src"
,
V_CVAR_OR_STRING
,
uiNode_t
, image);
81
}
uiTextureNode
Definition
ui_node_texture.h:29
uiTextureNode::draw
void draw(uiNode_t *node) override
Draws the texture node.
Definition
ui_node_texture.cpp:50
r_draw.h
scripts_lua.h
Header for lua script functions.
Q_strnull
bool Q_strnull(const char *string)
Definition
shared.h:138
image_t
Definition
r_image.h:61
image_t::height
int height
Definition
r_image.h:64
image_t::width
int width
Definition
r_image.h:64
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::box
uiBox_t box
Definition
ui_nodes.h:96
uiNode_t::image
char * image
Definition
ui_nodes.h:123
vec2_t
vec_t vec2_t[2]
Definition
ufotypes.h:38
ui_behaviour.h
UI_RegisterNodeProperty
#define UI_RegisterNodeProperty(BEHAVIOUR, NAME, TYPE, OBJECTTYPE, ATTRIBUTE)
Initialize a property.
Definition
ui_behaviour.h:91
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_GetNodeAbsPos
void UI_GetNodeAbsPos(const uiNode_t *node, vec2_t pos)
Returns the absolute position of a node.
Definition
ui_node.cpp:526
ui_node_abstractnode.h
UINodePtr
SharedPtr< uiNode > UINodePtr
Definition
ui_node_abstractnode.h:66
EXTRADATA_TYPE
#define EXTRADATA_TYPE
Definition
ui_node_abstractoption.cpp:38
UI_RegisterTextureNode
void UI_RegisterTextureNode(uiBehaviour_t *behaviour)
Definition
ui_node_texture.cpp:72
ui_node_texture.h
ui_nodes.h
UI_GetReferenceString
const char * UI_GetReferenceString(const uiNode_t *const node, const char *ref)
Definition
ui_parse.cpp:1406
ui_parse.h
V_CVAR_OR_STRING
#define V_CVAR_OR_STRING
Definition
ui_parse.h:69
UI_LoadWrappedImage
const struct image_s * UI_LoadWrappedImage(const char *name)
Searches for a wrapped image in the image array.
Definition
ui_render.cpp:106
UI_DrawNormImage
void UI_DrawNormImage(bool flip, float x, float y, float w, float h, float sh, float th, float sl, float tl, const image_t *image)
Draw a normalized (to the screen) image.
Definition
ui_render.cpp:126
ui_render.h
src
client
ui
node
ui_node_texture.cpp
Generated on __DATE__ __TIME__ for UFO: Alien Invasion by
1.17.0