-
Notifications
You must be signed in to change notification settings - Fork 48
/
Copy pathMarkerEditor.h
246 lines (196 loc) · 6.37 KB
/
MarkerEditor.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
#pragma once
#include "Bedrock/WhiteBoard/WhiteBoard.h"
#include "gw2tactical.h"
#include "TrailLogger.h"
enum class MarkerAction
{
AddMarkerFull, // done
MoveMarker, // done
AddTrailFull, // done
MoveTrailVertex, // done
AddTrailVertex, // done
DeleteTrailVertex, // done
DeleteMarkerTrail, // done
SetMarkerTrailCategory,
ChangeMarkerTrailAttrib,
ChangeCategoryAttrib,
// todo
AddCategory,
DeleteCategory,
};
enum class TypeParameters
{
Size,
MiniMapSize,
MiniMapFadeoutLevel,
MinSize,
MaxSize,
IconFile,
ScaleWithZoom,
Color,
Alpha,
FadeNear,
FadeFar,
Height,
Behavior,
AchievementID,
AchievementBit,
ResetLength,
DefaultToggle,
HasCountDown,
ToggleCategory,
AutoTrigger,
TriggerRange,
InfoRange,
Info,
Copy,
CopyMessage,
MiniMapVisible,
BigMapVisible,
InGameVisible,
KeepOnMapEdge,
AnimSpeed,
TrailScale,
TrailFile,
Texture,
MAX
};
class MarkerActionData
{
MarkerAction action{};
GUID targetMarker{};
MarkerTypeData typeData{};
GUID guid{};
int intData{}; // vertex index / map id
CVector3 position{}; // marker/vertex pos
CVector3 rotation{}; // rotation
TS32 stringID = -1;
POI fullMarker;
GW2Trail* fullTrail = nullptr;
public:
MarkerActionData() = default;
MarkerActionData( MarkerAction action, const GUID& guid, const int intData = 0, const CVector3& pos = CVector3{}, const int stringData = 0 );
MarkerActionData( MarkerAction action, const GUID& guid, const int intData, const int stringData );
MarkerActionData( MarkerAction action, const POI& fullMarker );
MarkerActionData( MarkerAction action, GW2Trail* fullTrail );
MarkerActionData( MarkerAction action, const GUID& guid, const MarkerTypeData& data, int stringData = -1 );
void Do();
};
class MarkerDOM
{
static int bufferIndex;
static CArray<MarkerActionData> actionBuffer;
static CArray<MarkerActionData> undoBuffer;
public:
static void CropBuffers();
static void AddMarkerFull( const POI& poi );
static void DeleteMarkerTrail( const GUID& guid );
static void MoveMarker( const GUID& guid, const CVector3& pos );
static void AddTrailFull( GW2Trail* trail );
static void MoveTrailVertex( const GUID& guid, int vertexID, const CVector3& pos );
static void AddTrailVertex( const GUID& guid, int vertexID, const CVector3& pos );
static void DeleteTrailVertex( const GUID& guid, int vertexID );
static void SetMarkerTrailCategory( const GUID& guid, const CString& category );
static void ChangeMarkerTrailAttrib( const GUID& guid, const MarkerTypeData& typeData );
static void ChangeCategoryAttrib( const CString& category, const MarkerTypeData& typeData );
static void Undo();
static void Redo();
static void ResetUndoBuffer();
};
struct UberToolPart
{
CCoreVertexBuffer* mesh = nullptr;
int triCount = 0;
~UberToolPart();
};
enum class UberToolMode
{
Move,
Scale,
Rotate
};
enum UberToolElement
{
none,
moveX,
moveY,
moveZ,
moveYZ,
moveXZ,
moveXY,
rotateX,
rotateY,
rotateZ
};
class GW2MarkerEditor : public CWBItem
{
UberToolMode uberToolMode = UberToolMode::Move;
CMatrix4x4 cam;
CMatrix4x4 persp;
CMatrix4x4 uberTool;
virtual TBOOL MessageProc( CWBMessage& message );
virtual void OnDraw( CWBDrawAPI* API );
TBOOL hidden = false;
CArray<GW2TacticalCategory*> categoryList;
TBOOL changeDefault = false;
GUID editedMarker{};
int selectedVertexIndex{};
CString editedCategory{};
CCoreVertexFormat* vertexFormat = nullptr;
CCoreVertexShader* vxShader = nullptr;
CCorePixelShader* pxShader = nullptr;
CCoreConstantBuffer* constBuffer = nullptr;
CCoreRasterizerState* rasterizer1 = nullptr;
CCoreRasterizerState* rasterizer2 = nullptr;
CCoreDepthStencilState* depthStencil = nullptr;
UberToolPart plane;
UberToolPart arrow;
UberToolPart circle;
UberToolElement hoverElement = UberToolElement::none;
UberToolElement draggedElement = UberToolElement::none;
CVector3 clickedPos{};
CVector3 hoverPos{};
CVector3 originalPosition{};
CVector3 originalRotation{};
CVector3 originalScale{};
CVector3 clickedOriginalDelta{};
CVector3 GetUberToolMovePos( const CVector3& location );
int defaultCatBeingSet = -1;
bool selectingEditedCategory = false;
void InitUberTool();
void UpdateEditorFromCategory( const MarkerTypeData& data );
void UpdateTypeParameterValue( TypeParameters param );
void ToggleTypeParameterSaved( TypeParameters param );
bool GetTypeParameterSaved( TypeParameters param );
void GetTypeParameterValue( TypeParameters param, bool& boolValue, int& intValue, float& floatValue, CString& stringValue );
MarkerTypeData* GetEditedTypeParameters();
void UpdateEditedTypeParameters( const MarkerTypeData& data );
void HideEditorUI( bool fade );
void ShowMarkerUI( bool marker, bool trail );
GUID GetMouseTrail( int& idx, CVector3& hitPoint, bool& indexPlusOne );
public:
TBOOL HandleUberToolMessages( CWBMessage& message );
void DrawUberTool( CWBDrawAPI* API, const CRect& drawrect );
virtual TBOOL IsMouseTransparent( CPoint& ClientSpacePoint, WBMESSAGE MessageType );
GW2MarkerEditor( CWBItem* Parent, CRect Position );
virtual ~GW2MarkerEditor();
static CWBItem* Factory( CWBItem* Root, CXMLNode& node, CRect& Pos );
WB_DECLARE_GUIITEM( _T( "markereditor" ), CWBItem );
bool GetMouseTransparency( CPoint& ClientSpacePoint, WBMESSAGE MessageType );
bool ShouldPassMouseEvent();
void SetEditedGUID( const GUID& guid );
void SetSelectedVertexIndex( int idx );
void SetEditedCategory( const CString& category );
void DeleteSelectedMarker();
void DeleteSelectedTrailSegment();
void CopySelectedMarker();
GUID GetEditedGUID();
int GetSelectedVertexIndex();
CVector3 GetSelectedVertexPosition();
void UpdateEditorContent();
};
bool IsTypeParameterSaved( const MarkerTypeData& data, TypeParameters param );
void GetTypeParameter( const MarkerTypeData& data, TypeParameters param, float& floatResult, int& intResult, CString& stringResult, bool& boolResult );
void SetTypeParameter( MarkerTypeData& data, TypeParameters param, const float floatResult, const int intResult, const CString& stringResult, const bool boolResult );
void SetTypeParameterSaved( MarkerTypeData& data, TypeParameters param, bool saved );
void PropagateCategoryParameter( GW2TacticalCategory* category, TypeParameters param, const bool boolValue, const int intValue, const float floatValue, const CString& stringValue );