/
hu_automap.h
227 lines (174 loc) · 6.75 KB
/
hu_automap.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
/**\file hu_automap.h
*\section License
* License: GPL
* Online License Link: http://www.gnu.org/licenses/gpl.html
*
*\author Copyright © 2008-2012 Daniel Swanson <danij@dengine.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301 USA
*/
/**
* UIAutomap widget.
*/
#ifndef LIBCOMMON_GUI_LIBRARY_UIAUTOMAP_H
#define LIBCOMMON_GUI_LIBRARY_UIAUTOMAP_H
#include "am_map.h"
#include "hu_lib.h"
#define MAX_MAP_POINTS (10)
/// To be called to register the console commands and variables of this module.
void UIAutomap_Register(void);
extern boolean freezeMapRLs;
/**
* UIAutomap. UIWidget for displaying a simplified, dynamic interpretation
* of the current map with navigational interface.
*/
#define UIAUTOMAP_BORDER 4 ///< In fixed 320x200 pixels.
/**
* @defgroup uiautomapFlags UIAutomap Flags
*/
///@{
#define AMF_REND_THINGS 0x01
#define AMF_REND_KEYS 0x02
#define AMF_REND_ALLLINES 0x04
#define AMF_REND_SPECIALLINES 0x08
#define AMF_REND_VERTEXES 0x10
#define AMF_REND_LINE_NORMALS 0x20
///@}
// Mapped point of interest.
typedef struct {
float pos[3];
} guidata_automap_point_t;
typedef struct {
automapcfg_t* mcfg;
int scissorState;
RectRaw scissorRegion;
// DGL display lists:
DGLuint lists[NUM_MAP_OBJECTLISTS]; // Each list contains one or more of given type of automap obj.
boolean constructMap; // @c true = force a rebuild of all lists.
// State:
int flags;
boolean active;
boolean reveal;
boolean pan; // If the map viewer location is currently in free pan mode.
boolean rotate;
boolean forceMaxScale; // If the map is currently in forced max zoom mode.
float priorToMaxScale; // Viewer scale before entering maxScale mode.
uint followPlayer; // Console player being followed.
// Used by MTOF to scale from map-to-frame-buffer coords.
float scaleMTOF;
// Used by FTOM to scale from frame-buffer-to-map coords (=1/scaleMTOF).
float scaleFTOM;
// Map bounds:
float minScale;
float bounds[4];
// Paramaters for render:
float alpha, targetAlpha, oldAlpha;
float alphaTimer;
// Viewer location on the map:
float viewTimer;
float viewX, viewY; // Current.
float targetViewX, targetViewY; // Should be at.
float oldViewX, oldViewY; // Previous.
// For the parallax layer.
float viewPLX, viewPLY; // Current.
// View frame scale:
float viewScaleTimer;
float viewScale; // Current.
float targetViewScale; // Should be at.
float oldViewScale; // Previous.
float minScaleMTOF; // Viewer frame scale limits.
float maxScaleMTOF;
// View frame rotation:
float angleTimer;
float angle; // Current.
float targetAngle; // Should be at.
float oldAngle; // Previous.
// Axis-aligned bounding box of the potentially visible area
// (rotation-aware) in map coordinates.
float viewAABB[4];
// Bounding box of the actual visible area in map coordinates.
float topLeft[2], bottomRight[2], topRight[2], bottomLeft[2];
// Misc:
float maxViewPositionDelta;
boolean updateViewScale;
// Mapped points of interest:
guidata_automap_point_t points[MAX_MAP_POINTS];
boolean pointsUsed[MAX_MAP_POINTS];
int pointCount;
} guidata_automap_t;
#ifdef __cplusplus
extern "C" {
#endif
void UIAutomap_LoadResources(void);
void UIAutomap_ReleaseResources(void);
automapcfg_t* UIAutomap_Config(uiwidget_t* obj);
void UIAutomap_Rebuild(uiwidget_t* obj);
void UIAutomap_ClearLists(uiwidget_t* obj);
void UIAutomap_Reset(uiwidget_t* obj);
void UIAutomap_Drawer(uiwidget_t* obj, const Point2Raw* offset);
boolean UIAutomap_Open(uiwidget_t* obj, boolean yes, boolean fast);
void UIAutomap_Ticker(uiwidget_t* obj, timespan_t ticLength);
void UIAutomap_UpdateGeometry(uiwidget_t* obj);
boolean UIAutomap_Active(uiwidget_t* obj);
boolean UIAutomap_Reveal(uiwidget_t* obj);
boolean UIAutomap_SetReveal(uiwidget_t* obj, boolean on);
/**
* Add a point of interest at this location.
*/
int UIAutomap_AddPoint(uiwidget_t* obj, float x, float y, float z);
boolean UIAutomap_PointOrigin(const uiwidget_t* obj, int pointIdx, float* x, float* y, float* z);
int UIAutomap_PointCount(const uiwidget_t* obj);
void UIAutomap_ClearPoints(uiwidget_t* obj);
int UIAutomap_Flags(const uiwidget_t* obj);
/**
* @param flags @see AutomapFlags.
*/
void UIAutomap_SetFlags(uiwidget_t* obj, int flags);
void UIAutomap_SetWorldBounds(uiwidget_t* obj, float lowX, float hiX, float lowY, float hiY);
void UIAutomap_SetMinScale(uiwidget_t* obj, const float scale);
void UIAutomap_CameraOrigin(uiwidget_t* obj, float* x, float* y);
boolean UIAutomap_SetCameraOrigin(uiwidget_t* obj, float x, float y);
boolean UIAutomap_TranslateCameraOrigin(uiwidget_t* obj, float x, float y);
/**
* @param max Maximum view position delta in world units.
*/
void UIAutomap_SetCameraOriginFollowMoveDelta(uiwidget_t* obj, float max);
float UIAutomap_CameraAngle(uiwidget_t* obj);
boolean UIAutomap_SetCameraAngle(uiwidget_t* obj, float angle);
boolean UIAutomap_SetScale(uiwidget_t* obj, float scale);
float UIAutomap_Opacity(const uiwidget_t* obj);
boolean UIAutomap_SetOpacity(uiwidget_t* obj, float alpha);
/**
* Conversion helpers:
*/
/// Scale from automap window to map coordinates.
float UIAutomap_FrameToMap(uiwidget_t* obj, float val);
/// Scale from map to automap window coordinates.
float UIAutomap_MapToFrame(uiwidget_t* obj, float val);
void UIAutomap_VisibleBounds(const uiwidget_t* obj, float topLeft[2], float bottomRight[2], float topRight[2], float bottomLeft[2]);
void UIAutomap_PVisibleAABounds(const uiwidget_t* obj, float* lowX, float* hiX, float* lowY, float* hiY);
boolean UIAutomap_CameraRotation(uiwidget_t* obj);
boolean UIAutomap_SetCameraRotation(uiwidget_t* obj, boolean on);
boolean UIAutomap_PanMode(uiwidget_t* obj);
boolean UIAutomap_SetPanMode(uiwidget_t* obj, boolean on);
mobj_t* UIAutomap_FollowMobj(uiwidget_t* obj);
boolean UIAutomap_ZoomMax(uiwidget_t* obj);
boolean UIAutomap_SetZoomMax(uiwidget_t* obj, boolean on);
void UIAutomap_ParallaxLayerOrigin(uiwidget_t* obj, float* x, float* y);
#ifdef __cplusplus
}
#endif
#endif /* LIBCOMMON_GUI_LIBRARY_UIAUTOMAP_H */