UFO: Alien Invasion
Toggle main menu visibility
Loading...
Searching...
No Matches
ui_node_timer.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
25
#include "
../ui_timer.h
"
26
#include "
../ui_parse.h
"
27
#include "
../ui_actions.h
"
28
#include "
../ui_behaviour.h
"
29
#include "
../ui_lua.h
"
30
#include "
ui_node_timer.h
"
31
32
#include "
../../../common/scripts_lua.h
"
33
34
#define EXTRADATA_TYPE timerExtraData_t
35
#define EXTRADATA(node) UI_EXTRADATA(node, EXTRADATA_TYPE)
36
#define EXTRADATACONST(node) UI_EXTRADATACONST(node, EXTRADATA_TYPE)
37
41
void
uiTimerNode::onWindowOpened
(
uiNode_t
* node,
linkedList_t
* params)
42
{
43
EXTRADATA
(node).lastTime =
CL_Milliseconds
();
44
}
45
46
void
uiTimerNode::onWindowClosed
(
uiNode_t
* node)
47
{
48
}
49
53
void
uiTimerNode::draw
(
uiNode_t
* node)
54
{
55
uiLocatedNode::draw
(node);
56
timerExtraData_t
&
data
=
EXTRADATA
(node);
57
/* embedded timer */
58
if
(
data
.onTimeOut &&
data
.timeOut) {
59
if
(
data
.lastTime == 0)
60
data
.lastTime =
CL_Milliseconds
();
61
if
(
data
.lastTime +
data
.timeOut <
CL_Milliseconds
()) {
62
/* allow to reset timeOut on the event, and restart it, with an uptodate lastTime */
63
data
.lastTime = 0;
64
Com_DPrintf
(
DEBUG_CLIENT
,
"uiTimerNode::draw: Timeout for node '%s'\n"
, node->
name
);
65
if
(
data
.onTimeOut !=
nullptr
) {
66
UI_ExecuteEventActions
(node,
data
.onTimeOut);
67
}
68
else
if
(
data
.lua_onEvent != LUA_NOREF) {
69
UI_ExecuteLuaEventScript
(node,
data
.lua_onEvent);
70
}
71
}
72
}
73
}
74
75
void
UI_RegisterTimerNode
(
uiBehaviour_t
* behaviour)
76
{
77
behaviour->
name
=
"timer"
;
78
behaviour->
manager
=
UINodePtr
(
new
uiTimerNode
());
79
behaviour->
extraDataSize
=
sizeof
(
EXTRADATA_TYPE
);
80
behaviour->
lua_SWIG_typeinfo
=
UI_SWIG_TypeQuery
(
"uiTimerNode_t *"
);
81
82
/* This property control milliseconds between each calls of <code>onEvent</code>.
83
* If the value is 0 (the default value) nothing is called. We can change the
84
* value at runtime.
85
*/
86
UI_RegisterExtradataNodeProperty
(behaviour,
"timeout"
,
V_INT
,
EXTRADATA_TYPE
, timeOut);
87
88
/* Invoked periodically. See <code>timeout</code>. */
89
UI_RegisterExtradataNodeProperty
(behaviour,
"onEvent"
,
V_UI_ACTION
,
EXTRADATA_TYPE
, onTimeOut);
90
}
CL_Milliseconds
int CL_Milliseconds(void)
Definition
cl_main.cpp:1207
uiLocatedNode::draw
virtual void draw(uiNode_t *node)
Definition
ui_node_abstractnode.h:71
uiTimerNode
Definition
ui_node_timer.h:34
uiTimerNode::onWindowClosed
void onWindowClosed(uiNode_t *node) override
Definition
ui_node_timer.cpp:46
uiTimerNode::onWindowOpened
void onWindowOpened(uiNode_t *node, linkedList_t *params) override
Called when we init the node on the screen.
Definition
ui_node_timer.cpp:41
uiTimerNode::draw
void draw(uiNode_t *node) override
Definition
ui_node_timer.cpp:53
Com_DPrintf
void Com_DPrintf(int level, const char *fmt,...)
A Com_Printf that only shows up if the "developer" cvar is set.
Definition
common.cpp:440
DEBUG_CLIENT
#define DEBUG_CLIENT
Definition
defines.h:59
data
QGL_EXTERN GLsizei const GLvoid * data
Definition
r_gl.h:89
V_INT
@ V_INT
Definition
scripts.h:52
scripts_lua.h
Header for lua script functions.
linkedList_t
Definition
list.h:30
timerExtraData_t
extradata for the window node
Definition
ui_node_timer.h:44
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
uiNode_t
Atomic structure used to define most of the UI.
Definition
ui_nodes.h:80
uiNode_t::name
char name[MAX_VAR]
Definition
ui_nodes.h:82
UI_ExecuteEventActions
void UI_ExecuteEventActions(uiNode_t *source, const uiAction_t *firstAction)
Definition
ui_actions.cpp:726
ui_actions.h
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_ExecuteLuaEventScript
bool UI_ExecuteLuaEventScript(uiNode_t *node, LUA_EVENT event)
Executes a lua event handler.
Definition
ui_lua.cpp:71
ui_lua.h
Basic lua initialization for the ui.
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
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
UI_RegisterTimerNode
void UI_RegisterTimerNode(uiBehaviour_t *behaviour)
Definition
ui_node_timer.cpp:75
ui_node_timer.h
ui_parse.h
V_UI_ACTION
#define V_UI_ACTION
Definition
ui_parse.h:54
ui_timer.h
src
client
ui
node
ui_node_timer.cpp
Generated on __DATE__ __TIME__ for UFO: Alien Invasion by
1.17.0