UFO: Alien Invasion
Loading...
Searching...
No Matches
ui_node_zone.cpp
Go to the documentation of this file.
1
7
8/*
9Copyright (C) 2002-2025 UFO: Alien Invasion.
10
11This program is free software; you can redistribute it and/or
12modify it under the terms of the GNU General Public License
13as published by the Free Software Foundation; either version 2
14of the License, or (at your option) any later version.
15
16This program is distributed in the hope that it will be useful,
17but WITHOUT ANY WARRANTY; without even the implied warranty of
18MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
19
20See the GNU General Public License for more details.
21
22You should have received a copy of the GNU General Public License
23along with this program; if not, write to the Free Software
24Foundation, 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
40
41#define EXTRADATA_TYPE zoneExtraData_t
42#define EXTRADATA(node) UI_EXTRADATA(node, EXTRADATA_TYPE)
43
45
47{
48 if (node->onClick) {
50 }
51}
52
53void uiZoneNode::onMouseDown (uiNode_t* node, int x, int y, int button)
54{
55 if (!EXTRADATA(node).repeat)
56 return;
57 if (button == K_MOUSE1) {
59 capturedTimer = UI_AllocTimer(node, EXTRADATA(node).clickDelay, UI_ZoneNodeRepeat);
61 }
62}
63
64void uiZoneNode::onMouseUp (uiNode_t* node, int x, int y, int button)
65{
66 if (!EXTRADATA(node).repeat)
67 return;
68 if (button == K_MOUSE1) {
70 }
71}
72
84
89{
90 EXTRADATA(node).clickDelay = 1000;
91}
92
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}
Header file for keyboard handler.
@ K_MOUSE1
Definition cl_keys.h:46
void onLoading(uiNode_t *node) override
Call before the script initialized the node.
void onMouseUp(uiNode_t *node, int x, int y, int button) override
void onMouseDown(uiNode_t *node, int x, int y, int button) override
void onCapturedMouseLost(uiNode_t *node) override
Called when the node have lost the captured node We clean cached data.
@ V_BOOL
Definition scripts.h:50
@ 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
Atomic structure used to define most of the UI.
Definition ui_nodes.h:80
struct uiAction_s * onClick
Definition ui_nodes.h:135
void UI_ExecuteEventActions(uiNode_t *source, const uiAction_t *firstAction)
#define UI_RegisterExtradataNodeProperty(BEHAVIOUR, NAME, TYPE, EXTRADATATYPE, ATTRIBUTE)
Initialize a property from extradata of node.
void UI_SetMouseCapture(uiNode_t *node)
Captured the mouse into a node.
Definition ui_input.cpp:516
void UI_MouseRelease(void)
Release the captured node.
Definition ui_input.cpp:526
void * UI_SWIG_TypeQuery(const char *name)
This function queries the SWIG type table for a type information structure. It is used in combination...
SharedPtr< uiNode > UINodePtr
#define EXTRADATA_TYPE
#define EXTRADATA(node)
static uiTimer_t * capturedTimer
static void UI_ZoneNodeRepeat(uiNode_t *node, uiTimer_t *timer)
void UI_RegisterZoneNode(uiBehaviour_t *behaviour)
uiTimer_t * UI_AllocTimer(uiNode_t *node, int firstDelay, timerCallback_t callback)
Allocate a new time for a node.
Definition ui_timer.cpp:123
void UI_TimerStart(uiTimer_t *timer)
Restart a timer.
Definition ui_timer.cpp:150
void UI_TimerRelease(uiTimer_t *timer)
Release the timer. It no more exists.
Definition ui_timer.cpp:176