-
Notifications
You must be signed in to change notification settings - Fork 48
/
Copy pathgw2tactical.h
297 lines (246 loc) · 7.69 KB
/
gw2tactical.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
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
#pragma once
#include "Bedrock/WhiteBoard/whiteboard.h"
#include <objbase.h>
#include <unordered_map>
#include <set>
#include "Achievements.h"
enum class POIBehavior : TS32
{
AlwaysVisible,
ReappearOnMapChange,
ReappearOnDailyReset,
OnlyVisibleBeforeActivation,
ReappearAfterTimer,
ReappearOnMapReset,
OncePerInstance,
DailyPerChar,
OncePerInstancePerChar,
WvWObjective,
};
struct MarkerTypeData
{
struct
{
TBOOL autoTrigger : 1;
TBOOL hasCountdown : 1;
TBOOL miniMapVisible : 1;
TBOOL bigMapVisible : 1;
TBOOL inGameVisible : 1;
TBOOL scaleWithZoom : 1;
TBOOL keepOnMapEdge : 1;
TBOOL defaultToggle : 1;
TBOOL defaultToggleLoaded : 1;
} bits;
struct
{
TBOOL iconFileSaved : 1;
TBOOL sizeSaved : 1;
TBOOL alphaSaved : 1;
TBOOL fadeNearSaved : 1;
TBOOL fadeFarSaved : 1;
TBOOL heightSaved : 1;
TBOOL behaviorSaved : 1;
TBOOL resetLengthSaved : 1;
TBOOL autoTriggerSaved : 1;
TBOOL hasCountdownSaved : 1;
TBOOL triggerRangeSaved : 1;
TBOOL minSizeSaved : 1;
TBOOL maxSizeSaved : 1;
TBOOL colorSaved : 1;
TBOOL trailDataSaved : 1;
TBOOL animSpeedSaved : 1;
TBOOL textureSaved : 1;
TBOOL trailScaleSaved : 1;
TBOOL toggleCategorySaved : 1;
TBOOL achievementIdSaved : 1;
TBOOL achievementBitSaved : 1;
TBOOL miniMapVisibleSaved : 1;
TBOOL bigMapVisibleSaved : 1;
TBOOL inGameVisibleSaved : 1;
TBOOL scaleWithZoomSaved : 1;
TBOOL miniMapSizeSaved : 1;
TBOOL miniMapFadeOutLevelSaved : 1;
TBOOL keepOnMapEdgeSaved : 1;
TBOOL infoSaved : 1;
TBOOL infoRangeSaved : 1;
TBOOL copySaved : 1;
TBOOL copyMessageSaved : 1;
TBOOL defaultToggleSaved : 1;
} saveBits;
unsigned char festivalSaveMask = 0;
unsigned char festivalMask = 0;
MarkerTypeData();
TF32 size = 1.0;
TF32 alpha = 1.0f;
TF32 fadeNear = -1;
TF32 fadeFar = -1;
TF32 height = 1.5f;
TF32 triggerRange = 2.0f;
TF32 animSpeed = 1;
TF32 trailScale = 1;
TS32 miniMapSize = 20;
TF32 miniMapFadeOutLevel = 100.0f;
TF32 infoRange = 2.0f;
POIBehavior behavior = POIBehavior::AlwaysVisible;
CColor color = CColor( 0xffffffff );
TS16 resetLength = 0;
TS16 minSize = 5;
TS16 maxSize = 2048;
TS16 iconFile = -1;
TS16 trailData = -1;
TS16 texture = -1;
TS16 toggleCategory = -1;
TS16 achievementId = -1;
TS16 achievementBit = -1;
TS16 info = -1;
TS16 copy = -1;
TS16 copyMessage = -1;
void Read( CXMLNode& n, TBOOL StoreSaveState );
void Write( CXMLNode* n );
void ClearSavedBits();
};
class GW2TacticalCategory;
struct POI
{
MarkerTypeData typeData;
CVector3 position;
CVector3 rotation;
TS32 mapID;
GUID guid;
TS16 Type = -1; //type string id
WBATLASHANDLE icon = 0;
CVector4 cameraSpacePosition;
TU8 wvwObjectiveID;
time_t lastUpdateTime = 0;
TBOOL external = false;
TBOOL routeMember = false;
TS16 zipFile;
TS16 iconFile;
GW2TacticalCategory* category = nullptr;
void SetCategory( CWBApplication* App, GW2TacticalCategory* t );
bool IsVisible( const tm& ptm, const time_t& currtime );
};
struct POIActivationDataKey
{
GUID guid;
int uniqueData = 0;
POIActivationDataKey() = default;
POIActivationDataKey( GUID g, int inst )
: guid( g )
, uniqueData( inst )
{
}
bool operator== ( const POIActivationDataKey& d )
{
return guid == d.guid && uniqueData == d.uniqueData;
}
};
struct POIActivationData
{
GUID poiguid;
int uniqueData = 0;
time_t lastUpdateTime = 0;
};
struct POIRoute
{
CString name;
TBOOL backwards = true;
CArray<GUID> route;
TBOOL external = false;
TBOOL hasResetPos = false;
CVector3 resetPos;
float resetRad = 0;
int MapID = 0;
TS32 activeItem = -1;
};
TU32 DictionaryHash( const GUID& i );
TU32 DictionaryHash( const POIActivationDataKey& i );
extern std::unordered_map<int, CDictionaryEnumerable<GUID, POI>> POISet;
extern CDictionaryEnumerable<POIActivationDataKey, POIActivationData> activationData;
extern CArray<POIRoute> Routes;
extern CDictionaryEnumerable<CString, POI> wvwPOIs;
extern GW2TacticalCategory CategoryRoot;
extern CDictionaryEnumerable<CString, GW2TacticalCategory*> CategoryMap;
CDictionaryEnumerable<GUID, POI>& GetMapPOIs();
CDictionaryEnumerable<GUID, POI>& GetPOIs( int mapId );
class GW2TacticalDisplay : public CWBItem
{
bool tacticalIconsOnEdge;
TF32 asp;
CMatrix4x4 cam;
CMatrix4x4 persp;
CRect drawrect;
void InsertPOI( POI& poi );
void DrawPOI( CWBDrawAPI* API, const tm& ptm, const time_t& currtime, POI& poi, bool drawDistance, CString& infoText );
void DrawPOIMinimap( CWBDrawAPI* API, const CRect& miniRect, CVector2& pos, const tm& ptm, const time_t& currtime, POI& poi, float alpha, float zoomLevel );
virtual void OnDraw( CWBDrawAPI* API );
CVector3 ProjectTacticalPos( CVector3 pos, TF32 fov, TF32 asp );
CArray<POI*> mapPOIs;
CArray<POI*> minimapPOIs;
bool drawWvWNames;
TS64 bigMessageStart = 0;
int bigMessageLength = 3000;
POI* triggeredPOI = nullptr;
TS32 bigMessage = -1;
bool hideExternal = false;
public:
bool storeMarkerPositions = false;
CDictionary<GUID, CRect> markerPositions;
CDictionary<GUID, CRect> markerMinimapPositions;
GW2TacticalDisplay( CWBItem* Parent, CRect Position );
virtual ~GW2TacticalDisplay();
static CWBItem* Factory( CWBItem* Root, CXMLNode& node, CRect& Pos );
WB_DECLARE_GUIITEM( _T( "gw2tactical" ), CWBItem );
virtual TBOOL IsMouseTransparent( CPoint& ClientSpacePoint, WBMESSAGE MessageType );
void RemoveUserMarkersFromMap();
void TriggerBigMessage( TS32 messageString );
};
class GW2TacticalCategory
{
CString cachedTypeName;
public:
CString name;
CString displayName;
TS16 zipFile;
MarkerTypeData data;
TBOOL keepSaveState = false;
TBOOL forceExport = false;
TBOOL isOnlySeparator = false;
GW2TacticalCategory* parent = nullptr;
CArray<GW2TacticalCategory*> children;
std::set<int> containedMapIds;
CString GetFullTypeName();
TBOOL isDisplayed = true;
TBOOL cachedVisibility = true;
TBOOL IsVisible() const;
void CacheVisibility();
static bool visibilityCached;
void CalculateVisibilityCache();
void SetDefaultToggleValues();
bool hiddenFromContextMenu = false;
int markerCount = 0;
bool needsExport = false;
void SetExportNeeded();
void ClearExportNeeded();
virtual ~GW2TacticalCategory()
{
children.FreeArray();
}
};
bool CreateNewPOI( CWBApplication* App, POI& poi, int defaultCategory, bool testRange = true );
bool CreateNewTrail( CWBApplication* App, const CString& fileName, class GW2Trail*& poi );
void DeletePOI();
void DeletePOI( const GUID& guid );
void UpdatePOI( CWBApplication* App );
void DeleteTrail( const GUID& guid );
void OpenTypeContextMenu( CWBContextMenu* ctx, CArray<GW2TacticalCategory*>& CategoryList, TBOOL AddVisibilityMarkers = false, TS32 BaseID = 0, TBOOL markerEditor = false, CDictionary<TS32, Achievement>& achievements = CDictionary<TS32, Achievement>() );
void OpenTypeContextMenu( CWBContextItem* ctx, CArray<GW2TacticalCategory*>& CategoryList, TBOOL AddVisibilityMarkers = false, TS32 BaseID = 0, TBOOL markerEditor = false, CDictionary<TS32, Achievement>& achievements = CDictionary<TS32, Achievement>() );
void AddTypeContextMenu( CWBContextMenu* ctx, CArray<GW2TacticalCategory*>& CategoryList, GW2TacticalCategory* Parent, TBOOL AddVisibilityMarkers, TS32 BaseID, TBOOL closeOnClick );
GW2TacticalCategory* FindInCategoryTree( GW2TacticalCategory* cat );
void SetAllCategoriesToVisibleInContext( GW2TacticalCategory* Parent );
float WorldToGameCoords( float world );
float GameToWorldCoords( float game );
void FindClosestRouteMarkers( TBOOL force );
TS32 AddStringToMap( const CString& string );
CString& GetStringFromMap( TS32 idx );
GW2TacticalCategory* GetCategory( CString s );