DDraceNetwork Docs
editor_trackers.h
Go to the documentation of this file.
1#ifndef GAME_EDITOR_EDITOR_TRACKERS_H
2#define GAME_EDITOR_EDITOR_TRACKERS_H
3
6#include <game/mapitems.h>
7
8#include <map>
9#include <memory>
10#include <vector>
11
12class CEditor;
13class CLayerTiles;
14class CLayerGroup;
15class CLayerSounds;
16struct CSoundSource;
17
19{
20public:
23
24 void BeginQuadTrack(const std::shared_ptr<CLayerQuads> &pLayer, const std::vector<int> &vSelectedQuads, int GroupIndex = -1, int LayerIndex = -1);
25 void EndQuadTrack();
26
27 void BeginQuadPropTrack(const std::shared_ptr<CLayerQuads> &pLayer, const std::vector<int> &vSelectedQuads, EQuadProp Prop, int GroupIndex = -1, int LayerIndex = -1);
28 void EndQuadPropTrack(EQuadProp Prop);
29
30 void BeginQuadPointPropTrack(const std::shared_ptr<CLayerQuads> &pLayer, const std::vector<int> &vSelectedQuads, int SelectedQuadPoints, int GroupIndex = -1, int LayerIndex = -1);
34
36
37private:
38 std::vector<int> m_vSelectedQuads;
40 std::map<int, std::vector<CPoint>> m_InitalPoints;
41
42 bool m_Tracking = false;
43 std::shared_ptr<CLayerQuads> m_pLayer;
44
46 std::vector<EQuadPointProp> m_vTrackedProps;
47 std::map<int, int> m_PreviousValues;
48 std::map<int, std::vector<std::map<EQuadPointProp, int>>> m_PreviousValuesPoint;
51};
52
54{
55 OP_NONE = 0,
63};
64
66{
67 OP_NONE = 0,
68 OP_MOVE,
70};
71
73{
74public:
76
77 void Begin(EEnvelopeEditorOp Operation);
78 void Stop(bool Switch = true);
80
82
83private:
85
87 {
88 bool m_Used;
89 int m_Time;
90 std::map<int, int> m_Values;
91 };
92
93 std::map<int, SPointData> m_SavedValues;
94
96 void HandlePointDragEnd(bool Switch);
97};
98
100{
101public:
103
104 void Begin(CSoundSource *pSource, ESoundSourceOp Operation, int LayerIndex);
105 void End();
106
107private:
112
113 struct SData
114 {
116 };
118
120 {
124 };
125 void HandlePointMove(EState State);
126};
127
129{
130 static int GetDefaultGroupIndex(CEditor *pEditor);
131 static int GetDefaultLayerIndex(CEditor *pEditor);
132};
133
134template<typename T, typename E>
136{
137public:
141
142 void Begin(T *pObject, E Prop, EEditState State, int GroupIndex = -1, int LayerIndex = -1)
143 {
144 if(m_Tracking || Prop == static_cast<E>(-1))
145 return;
146 m_pObject = pObject;
147
152
153 int Value = PropToValue(Prop);
154 if(StartChecker(Prop, State, Value))
155 {
156 m_Tracking = true;
157 m_OriginalValue = Value;
158 OnStart(Prop);
159 }
160 }
161
162 void End(E Prop, EEditState State, int GroupIndex = -1, int LayerIndex = -1)
163 {
164 if(!m_Tracking || Prop == static_cast<E>(-1))
165 return;
166
169
170 int Value = PropToValue(Prop);
171 if(EndChecker(Prop, State, Value))
172 {
173 m_Tracking = false;
174 OnEnd(Prop, Value);
175 }
176 }
177
178protected:
179 virtual void OnStart(E Prop) {}
180 virtual void OnEnd(E Prop, int Value) {}
181 virtual int PropToValue(E Prop) { return 0; }
182 virtual bool StartChecker(E Prop, EEditState State, int Value)
183 {
184 return State == EEditState::START || State == EEditState::ONE_GO;
185 }
186 virtual bool EndChecker(E Prop, EEditState State, int Value)
187 {
188 return (State == EEditState::END || State == EEditState::ONE_GO) && (Value != m_OriginalValue);
189 }
190
198};
199
200class CLayerPropTracker : public CPropTracker<CLayer, ELayerProp>
201{
202public:
204 CPropTracker<CLayer, ELayerProp>(pEditor){};
205
206protected:
207 void OnEnd(ELayerProp Prop, int Value) override;
208 int PropToValue(ELayerProp Prop) override;
209};
210
211class CLayerTilesPropTracker : public CPropTracker<CLayerTiles, ETilesProp>
212{
213public:
216
217protected:
218 void OnStart(ETilesProp Prop) override;
219 void OnEnd(ETilesProp Prop, int Value) override;
220 bool EndChecker(ETilesProp Prop, EEditState State, int Value) override;
221
222 int PropToValue(ETilesProp Prop) override;
223
224private:
225 std::map<int, std::shared_ptr<CLayer>> m_SavedLayers;
226};
227
228class CLayerTilesCommonPropTracker : public CPropTracker<CLayerTiles, ETilesCommonProp>
229{
230public:
233
234protected:
235 void OnStart(ETilesCommonProp Prop) override;
236 void OnEnd(ETilesCommonProp Prop, int Value) override;
237 bool EndChecker(ETilesCommonProp Prop, EEditState State, int Value) override;
238
239 int PropToValue(ETilesCommonProp Prop) override;
240
241private:
242 std::map<std::shared_ptr<CLayerTiles>, std::map<int, std::shared_ptr<CLayer>>> m_SavedLayers;
243
244public:
245 std::vector<std::shared_ptr<CLayerTiles>> m_vpLayers;
246 std::vector<int> m_vLayerIndices;
247};
248
249class CLayerGroupPropTracker : public CPropTracker<CLayerGroup, EGroupProp>
250{
251public:
254
255protected:
256 void OnEnd(EGroupProp Prop, int Value) override;
257 int PropToValue(EGroupProp Prop) override;
258};
259
260class CLayerQuadsPropTracker : public CPropTracker<CLayerQuads, ELayerQuadsProp>
261{
262public:
265
266protected:
267 void OnEnd(ELayerQuadsProp Prop, int Value) override;
268 int PropToValue(ELayerQuadsProp Prop) override;
269};
270
271class CLayerSoundsPropTracker : public CPropTracker<CLayerSounds, ELayerSoundsProp>
272{
273public:
276
277protected:
278 void OnEnd(ELayerSoundsProp Prop, int Value) override;
279 int PropToValue(ELayerSoundsProp Prop) override;
280};
281
282class CSoundSourcePropTracker : public CPropTracker<CSoundSource, ESoundProp>
283{
284public:
287
288protected:
289 void OnEnd(ESoundProp Prop, int Value) override;
290 int PropToValue(ESoundProp Prop) override;
291};
292
293class CSoundSourceRectShapePropTracker : public CPropTracker<CSoundSource, ERectangleShapeProp>
294{
295public:
298
299protected:
300 void OnEnd(ERectangleShapeProp Prop, int Value) override;
301 int PropToValue(ERectangleShapeProp Prop) override;
302};
303
304class CSoundSourceCircleShapePropTracker : public CPropTracker<CSoundSource, ECircleShapeProp>
305{
306public:
309
310protected:
311 void OnEnd(ECircleShapeProp Prop, int Value) override;
312 int PropToValue(ECircleShapeProp Prop) override;
313};
314
315#endif
Definition: editor.h:276
Definition: editor_trackers.h:73
CEditor * m_pEditor
Definition: editor_trackers.h:81
void Stop(bool Switch=true)
Definition: editor_trackers.cpp:296
void HandlePointDragStart()
Definition: editor_trackers.cpp:309
std::map< int, SPointData > m_SavedValues
Definition: editor_trackers.h:93
void HandlePointDragEnd(bool Switch)
Definition: editor_trackers.cpp:327
void Reset()
Definition: editor_trackers.h:79
void Begin(EEnvelopeEditorOp Operation)
Definition: editor_trackers.cpp:278
EEnvelopeEditorOp m_TrackedOp
Definition: editor_trackers.h:84
Definition: editor_trackers.h:250
int PropToValue(EGroupProp Prop) override
Definition: editor_trackers.cpp:569
void OnEnd(EGroupProp Prop, int Value) override
Definition: editor_trackers.cpp:564
CLayerGroupPropTracker(CEditor *pEditor)
Definition: editor_trackers.h:252
Definition: layer_group.h:10
Definition: editor_trackers.h:201
void OnEnd(ELayerProp Prop, int Value) override
Definition: editor_trackers.cpp:422
CLayerPropTracker(CEditor *pEditor)
Definition: editor_trackers.h:203
int PropToValue(ELayerProp Prop) override
Definition: editor_trackers.cpp:434
Definition: editor_trackers.h:261
CLayerQuadsPropTracker(CEditor *pEditor)
Definition: editor_trackers.h:263
int PropToValue(ELayerQuadsProp Prop) override
Definition: editor_trackers.cpp:595
void OnEnd(ELayerQuadsProp Prop, int Value) override
Definition: editor_trackers.cpp:589
Definition: layer_quads.h:7
Definition: editor_trackers.h:272
CLayerSoundsPropTracker(CEditor *pEditor)
Definition: editor_trackers.h:274
void OnEnd(ELayerSoundsProp Prop, int Value) override
Definition: editor_trackers.cpp:604
int PropToValue(ELayerSoundsProp Prop) override
Definition: editor_trackers.cpp:610
Definition: layer_sounds.h:7
Definition: editor_trackers.h:229
std::vector< int > m_vLayerIndices
Definition: editor_trackers.h:246
std::vector< std::shared_ptr< CLayerTiles > > m_vpLayers
Definition: editor_trackers.h:245
void OnStart(ETilesCommonProp Prop) override
Definition: editor_trackers.cpp:508
std::map< std::shared_ptr< CLayerTiles >, std::map< int, std::shared_ptr< CLayer > > > m_SavedLayers
Definition: editor_trackers.h:242
bool EndChecker(ETilesCommonProp Prop, EEditState State, int Value) override
Definition: editor_trackers.cpp:550
void OnEnd(ETilesCommonProp Prop, int Value) override
Definition: editor_trackers.cpp:519
int PropToValue(ETilesCommonProp Prop) override
Definition: editor_trackers.cpp:555
CLayerTilesCommonPropTracker(CEditor *pEditor)
Definition: editor_trackers.h:231
Definition: editor_trackers.h:212
CLayerTilesPropTracker(CEditor *pEditor)
Definition: editor_trackers.h:214
void OnEnd(ETilesProp Prop, int Value) override
Definition: editor_trackers.cpp:479
std::map< int, std::shared_ptr< CLayer > > m_SavedLayers
Definition: editor_trackers.h:225
int PropToValue(ETilesProp Prop) override
Definition: editor_trackers.cpp:489
bool EndChecker(ETilesProp Prop, EEditState State, int Value) override
Definition: editor_trackers.cpp:447
void OnStart(ETilesProp Prop) override
Definition: editor_trackers.cpp:452
Definition: layer_tiles.h:35
Definition: layer.h:16
Definition: editor_trackers.h:136
virtual void OnEnd(E Prop, int Value)
Definition: editor_trackers.h:180
virtual int PropToValue(E Prop)
Definition: editor_trackers.h:181
void Begin(T *pObject, E Prop, EEditState State, int GroupIndex=-1, int LayerIndex=-1)
Definition: editor_trackers.h:142
int m_OriginalLayerIndex
Definition: editor_trackers.h:193
T * m_pObject
Definition: editor_trackers.h:192
CPropTracker(CEditor *pEditor)
Definition: editor_trackers.h:138
virtual bool EndChecker(E Prop, EEditState State, int Value)
Definition: editor_trackers.h:186
int m_CurrentGroupIndex
Definition: editor_trackers.h:196
void End(E Prop, EEditState State, int GroupIndex=-1, int LayerIndex=-1)
Definition: editor_trackers.h:162
virtual void OnStart(E Prop)
Definition: editor_trackers.h:179
int m_OriginalValue
Definition: editor_trackers.h:191
int m_OriginalGroupIndex
Definition: editor_trackers.h:194
bool m_Tracking
Definition: editor_trackers.h:197
CEditor * m_pEditor
Definition: editor_trackers.h:140
int m_CurrentLayerIndex
Definition: editor_trackers.h:195
virtual bool StartChecker(E Prop, EEditState State, int Value)
Definition: editor_trackers.h:182
Definition: editor_trackers.h:19
std::vector< int > m_vSelectedQuads
Definition: editor_trackers.h:38
std::shared_ptr< CLayerQuads > m_pLayer
Definition: editor_trackers.h:43
int m_SelectedQuadPoints
Definition: editor_trackers.h:39
void EndQuadPointPropTrackAll()
Definition: editor_trackers.cpp:229
~CQuadEditTracker()
Definition: editor_trackers.cpp:12
void EndQuadTrack()
Definition: editor_trackers.cpp:36
void AddQuadPointPropTrack(EQuadPointProp Prop)
Definition: editor_trackers.cpp:134
EQuadProp m_TrackedProp
Definition: editor_trackers.h:45
CEditor * m_pEditor
Definition: editor_trackers.h:35
CQuadEditTracker()
Definition: editor_trackers.cpp:9
bool m_Tracking
Definition: editor_trackers.h:42
int m_GroupIndex
Definition: editor_trackers.h:50
void BeginQuadTrack(const std::shared_ptr< CLayerQuads > &pLayer, const std::vector< int > &vSelectedQuads, int GroupIndex=-1, int LayerIndex=-1)
Definition: editor_trackers.cpp:18
int m_LayerIndex
Definition: editor_trackers.h:49
std::map< int, std::vector< std::map< EQuadPointProp, int > > > m_PreviousValuesPoint
Definition: editor_trackers.h:48
void BeginQuadPointPropTrack(const std::shared_ptr< CLayerQuads > &pLayer, const std::vector< int > &vSelectedQuads, int SelectedQuadPoints, int GroupIndex=-1, int LayerIndex=-1)
Definition: editor_trackers.cpp:116
void EndQuadPropTrack(EQuadProp Prop)
Definition: editor_trackers.cpp:79
std::map< int, int > m_PreviousValues
Definition: editor_trackers.h:47
std::vector< EQuadPointProp > m_vTrackedProps
Definition: editor_trackers.h:46
void BeginQuadPropTrack(const std::shared_ptr< CLayerQuads > &pLayer, const std::vector< int > &vSelectedQuads, EQuadProp Prop, int GroupIndex=-1, int LayerIndex=-1)
Definition: editor_trackers.cpp:53
void EndQuadPointPropTrack(EQuadPointProp Prop)
Definition: editor_trackers.cpp:180
std::map< int, std::vector< CPoint > > m_InitalPoints
Definition: editor_trackers.h:40
Definition: editor_trackers.h:305
CSoundSourceCircleShapePropTracker(CEditor *pEditor)
Definition: editor_trackers.h:307
void OnEnd(ECircleShapeProp Prop, int Value) override
Definition: editor_trackers.cpp:659
int PropToValue(ECircleShapeProp Prop) override
Definition: editor_trackers.cpp:664
Definition: editor_trackers.h:100
ESoundSourceOp m_TrackedOp
Definition: editor_trackers.h:110
int m_LayerIndex
Definition: editor_trackers.h:111
CSoundSourceOperationTracker(CEditor *pEditor)
Definition: editor_trackers.cpp:367
CEditor * m_pEditor
Definition: editor_trackers.h:108
EState
Definition: editor_trackers.h:120
@ STATE_BEGIN
Definition: editor_trackers.h:121
@ STATE_EDITING
Definition: editor_trackers.h:122
@ STATE_END
Definition: editor_trackers.h:123
SData m_Data
Definition: editor_trackers.h:117
CSoundSource * m_pSource
Definition: editor_trackers.h:109
void HandlePointMove(EState State)
Definition: editor_trackers.cpp:396
void End()
Definition: editor_trackers.cpp:385
void Begin(CSoundSource *pSource, ESoundSourceOp Operation, int LayerIndex)
Definition: editor_trackers.cpp:372
Definition: editor_trackers.h:283
CSoundSourcePropTracker(CEditor *pEditor)
Definition: editor_trackers.h:285
void OnEnd(ESoundProp Prop, int Value) override
Definition: editor_trackers.cpp:619
int PropToValue(ESoundProp Prop) override
Definition: editor_trackers.cpp:624
Definition: editor_trackers.h:294
void OnEnd(ERectangleShapeProp Prop, int Value) override
Definition: editor_trackers.cpp:644
int PropToValue(ERectangleShapeProp Prop) override
Definition: editor_trackers.cpp:649
CSoundSourceRectShapePropTracker(CEditor *pEditor)
Definition: editor_trackers.h:296
ETilesCommonProp
Definition: mapitems.h:85
ELayerQuadsProp
Definition: mapitems.h:112
EQuadProp
Definition: mapitems.h:5
EQuadPointProp
Definition: mapitems.h:18
ETilesProp
Definition: mapitems.h:69
ERectangleShapeProp
Definition: mapitems.h:45
ECircleShapeProp
Definition: mapitems.h:53
ELayerSoundsProp
Definition: mapitems.h:119
ELayerProp
Definition: mapitems.h:60
EGroupProp
Definition: mapitems.h:96
ESoundProp
Definition: mapitems.h:29
EEnvelopeEditorOp
Definition: editor_trackers.h:54
ESoundSourceOp
Definition: editor_trackers.h:66
#define E(buf, str)
Definition: editor_trackers.h:87
bool m_Used
Definition: editor_trackers.h:88
std::map< int, int > m_Values
Definition: editor_trackers.h:90
int m_Time
Definition: editor_trackers.h:89
Definition: editor_trackers.h:114
CPoint m_OriginalPoint
Definition: editor_trackers.h:115
Definition: mapitems.h:483
Definition: editor_trackers.h:129
static int GetDefaultLayerIndex(CEditor *pEditor)
Definition: editor_trackers.cpp:415
static int GetDefaultGroupIndex(CEditor *pEditor)
Definition: editor_trackers.cpp:410
EEditState
Definition: ui.h:23