UFO: Alien Invasion
Toggle main menu visibility
Loading...
Searching...
No Matches
ui_node_zone.cpp
Go to the documentation of this file.
1
7
8
/*
9
Copyright (C) 2002-2025 UFO: Alien Invasion.
10
11
This program is free software; you can redistribute it and/or
12
modify it under the terms of the GNU General Public License
13
as published by the Free Software Foundation; either version 2
14
of the License, or (at your option) any later version.
15
16
This program is distributed in the hope that it will be useful,
17
but WITHOUT ANY WARRANTY; without even the implied warranty of
18
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
19
20
See the GNU General Public License for more details.
21
22
You should have received a copy of the GNU General Public License
23
along with this program; if not, write to the Free Software
24
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
25
26
*/
27
28
#include "
../ui_nodes.h
"
29
#include "
../ui_parse.h
"
30
#include "
../ui_behaviour.h
"
31
#include "
../ui_input.h
"
32
#include "
../ui_timer.h
"
33
#include "
../ui_actions.h
"
34
#include "
ui_node_zone.h
"
35
#include "
ui_node_window.h
"
36
37
#include "
../../input/cl_keys.h
"
38
39
#include "
../../../common/scripts_lua.h
"
40
41
#define EXTRADATA_TYPE zoneExtraData_t
42
#define EXTRADATA(node) UI_EXTRADATA(node, EXTRADATA_TYPE)
43
44
static
uiTimer_t
*
capturedTimer
;
45
46
static
void
UI_ZoneNodeRepeat
(
uiNode_t
* node,
uiTimer_t
*
timer
)
47
{
48
if
(node->
onClick
) {
49
UI_ExecuteEventActions
(node, node->
onClick
);
50
}
51
}
52
53
void
uiZoneNode::onMouseDown
(
uiNode_t
* node,
int
x,
int
y,
int
button)
54
{
55
if
(!
EXTRADATA
(node).repeat)
56
return
;
57
if
(button ==
K_MOUSE1
) {
58
UI_SetMouseCapture
(node);
59
capturedTimer
=
UI_AllocTimer
(node,
EXTRADATA
(node).clickDelay,
UI_ZoneNodeRepeat
);
60
UI_TimerStart
(
capturedTimer
);
61
}
62
}
63
64
void
uiZoneNode::onMouseUp
(
uiNode_t
* node,
int
x,
int
y,
int
button)
65
{
66
if
(!
EXTRADATA
(node).repeat)
67
return
;
68
if
(button ==
K_MOUSE1
) {
69
UI_MouseRelease
();
70
}
71
}
72
77
void
uiZoneNode::onCapturedMouseLost
(
uiNode_t
* node)
78
{
79
if
(
capturedTimer
) {
80
UI_TimerRelease
(
capturedTimer
);
81
capturedTimer
=
nullptr
;
82
}
83
}
84
88
void
uiZoneNode::onLoading
(
uiNode_t
* node)
89
{
90
EXTRADATA
(node).clickDelay = 1000;
91
}
92
93
void
UI_RegisterZoneNode
(
uiBehaviour_t
* behaviour)
94
{
95
behaviour->
name
=
"zone"
;
96
behaviour->
manager
=
UINodePtr
(
new
uiZoneNode
());
97
behaviour->
extraDataSize
=
sizeof
(
EXTRADATA_TYPE
);
98
behaviour->
lua_SWIG_typeinfo
=
UI_SWIG_TypeQuery
(
"uiZoneNode_t *"
);
99
100
/* If true, the <code>onclick</code> call back is called more than one time if the user does not release the button. */
101
UI_RegisterExtradataNodeProperty
(behaviour,
"repeat"
,
V_BOOL
,
zoneExtraData_t
, repeat);
102
/* Delay is used between 2 calls of <code>onclick</code>. */
103
UI_RegisterExtradataNodeProperty
(behaviour,
"clickdelay"
,
V_INT
,
zoneExtraData_t
, clickDelay);
104
}
cl_keys.h
Header file for keyboard handler.
K_MOUSE1
@ K_MOUSE1
Definition
cl_keys.h:46
uiZoneNode
Definition
ui_node_zone.h:27
uiZoneNode::onLoading
void onLoading(uiNode_t *node) override
Call before the script initialized the node.
Definition
ui_node_zone.cpp:88
uiZoneNode::onMouseUp
void onMouseUp(uiNode_t *node, int x, int y, int button) override
Definition
ui_node_zone.cpp:64
uiZoneNode::onMouseDown
void onMouseDown(uiNode_t *node, int x, int y, int button) override
Definition
ui_node_zone.cpp:53
uiZoneNode::onCapturedMouseLost
void onCapturedMouseLost(uiNode_t *node) override
Called when the node have lost the captured node We clean cached data.
Definition
ui_node_zone.cpp:77
V_BOOL
@ V_BOOL
Definition
scripts.h:50
V_INT
@ V_INT
Definition
scripts.h:52
scripts_lua.h
Header for lua script functions.
timer
Definition
common.cpp:81
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::onClick
struct uiAction_s * onClick
Definition
ui_nodes.h:135
uiTimer_t
Definition
ui_timer.h:36
zoneExtraData_t
Definition
ui_node_zone.h:34
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_SetMouseCapture
void UI_SetMouseCapture(uiNode_t *node)
Captured the mouse into a node.
Definition
ui_input.cpp:516
UI_MouseRelease
void UI_MouseRelease(void)
Release the captured node.
Definition
ui_input.cpp:526
ui_input.h
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
capturedTimer
static uiTimer_t * capturedTimer
Definition
ui_node_spinner.cpp:48
ui_node_window.h
UI_ZoneNodeRepeat
static void UI_ZoneNodeRepeat(uiNode_t *node, uiTimer_t *timer)
Definition
ui_node_zone.cpp:46
UI_RegisterZoneNode
void UI_RegisterZoneNode(uiBehaviour_t *behaviour)
Definition
ui_node_zone.cpp:93
ui_node_zone.h
ui_nodes.h
ui_parse.h
UI_AllocTimer
uiTimer_t * UI_AllocTimer(uiNode_t *node, int firstDelay, timerCallback_t callback)
Allocate a new time for a node.
Definition
ui_timer.cpp:123
UI_TimerStart
void UI_TimerStart(uiTimer_t *timer)
Restart a timer.
Definition
ui_timer.cpp:150
UI_TimerRelease
void UI_TimerRelease(uiTimer_t *timer)
Release the timer. It no more exists.
Definition
ui_timer.cpp:176
ui_timer.h
src
client
ui
node
ui_node_zone.cpp
Generated on __DATE__ __TIME__ for UFO: Alien Invasion by
1.17.0