UFO: Alien Invasion
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
ui_node_battlescape.cpp
Go to the documentation of this file.
1 
8 /*
9 Copyright (C) 2002-2020 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_behaviour.h"
30 #include "ui_node_abstractnode.h"
31 #include "ui_node_battlescape.h"
32 #include "../../client.h"
33 
34 #include "../../../common/scripts_lua.h"
35 
39 static void UI_SetRenderRect (int x, int y, int width, int height)
40 {
41  viddef.x = x * viddef.rx;
42  viddef.y = y * viddef.ry;
43  viddef.viewWidth = width * viddef.rx;
44  viddef.viewHeight = height * viddef.ry;
45 }
46 
51 {
52  /* node->ghost = true; */
53 }
54 
56 {
58  vec2_t pos;
59  UI_GetNodeAbsPos(node, pos);
60  UI_SetRenderRect(pos[0], pos[1], node->box.size[0], node->box.size[1]);
61 }
62 
64 {
65  vec2_t pos;
66  UI_GetNodeAbsPos(node, pos);
67  UI_SetRenderRect(pos[0], pos[1], node->box.size[0], node->box.size[1]);
68 }
69 
70 
72 {
73  vec2_t pos;
74  UI_GetNodeAbsPos(node, pos);
75  UI_SetRenderRect(pos[0], pos[1], node->box.size[0], node->box.size[1]);
76 }
77 
79 {
80  UI_SetRenderRect(0, 0, 0, 0);
81 }
82 
86 bool uiBattleScapeNode::onScroll (uiNode_t* node, int deltaX, int deltaY)
87 {
88  while (deltaY < 0) {
90  deltaY++;
91  }
92  while (deltaY > 0) {
94  deltaY--;
95  }
96  return true;
97 }
98 
100 {
101  behaviour->name = "battlescape";
102  behaviour->manager = UINodePtr(new uiBattleScapeNode());
103  behaviour->lua_SWIG_typeinfo = UI_SWIG_TypeQuery("uiBattlescapeNode_t *");
104 }
vec2_t size
Definition: ui_nodes.h:52
int viewHeight
Definition: cl_video.h:76
bool onScroll(uiNode_t *node, int deltaX, int deltaY) override
Called when user request scrolling on the battlescape.
const char * name
Definition: ui_behaviour.h:41
void UI_RegisterBattlescapeNode(uiBehaviour_t *behaviour)
void onWindowOpened(uiNode_t *node, linkedList_t *params) override
UINodePtr manager
Definition: ui_behaviour.h:43
float rx
Definition: cl_video.h:71
viddef_t viddef
Definition: cl_video.cpp:34
void onLoading(uiNode_t *node) override
Call before the script initialized the node.
void onWindowClosed(uiNode_t *node) override
int x
Definition: cl_video.h:76
void CL_CameraZoomIn(void)
Zooms the scene of the battlefield in.
Definition: cl_camera.cpp:302
SharedPtr< uiNode > UINodePtr
void * lua_SWIG_typeinfo
Definition: ui_behaviour.h:57
Atomic structure used to define most of the UI.
Definition: ui_nodes.h:80
void draw(uiNode_t *node) override
void * UI_SWIG_TypeQuery(const char *name)
This function queries the SWIG type table for a type information structure. It is used in combination...
void UI_GetNodeAbsPos(const uiNode_t *node, vec2_t pos)
Returns the absolute position of a node.
Definition: ui_node.cpp:514
void onSizeChanged(uiNode_t *node) override
Callback stub.
int viewWidth
Definition: cl_video.h:76
node behaviour, how a node work
Definition: ui_behaviour.h:39
vec_t vec2_t[2]
Definition: ufotypes.h:38
int y
Definition: cl_video.h:76
static void UI_SetRenderRect(int x, int y, int width, int height)
Determine the position and size of the render.
uiBox_t box
Definition: ui_nodes.h:96
float ry
Definition: cl_video.h:72
void CL_CameraZoomOut(void)
Zooms the scene of the battlefield out.
Definition: cl_camera.cpp:325