-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathztimeline.h
More file actions
286 lines (200 loc) · 8.86 KB
/
Copy pathztimeline.h
File metadata and controls
286 lines (200 loc) · 8.86 KB
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
/**********************************************************************************************************
This is part of the TimeLine Control of the Paradox Interactive DLL custom drawn object
ztimeline library is used as it is with slightly modified to comply with the my object
The original copyright is not removed.
Date Updated : July 2008
--------------- original copyrights ----------------
Zenerd Standard Library
Copyright (C) 2000-2002 by Zenerd
Component: Time Line Data-Structure
Date : October 2001
Author(s): Jeffrey M. Barber
--------------------------------------------------
Notes : NO BOUND CHECKING
: Modified to comply to my needs
: Comments are added by G. Papaioannou
************************************************************************************************************/
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#include <vector>
#include <algorithm>
using namespace std;
/***********************************************************************************************
Class ZSliceInternalFx
ZSliceInternalFx represents time slices between InFxDuration and OutFxDuration
Its used to represent fxs inside the body of the slice ie
/-------- Slice Body Fx or SBFx-----\
_______________________/_____________________________________\________________________
| | | | | |
| InFxDurtaion | | ZSliceInternalFx 1|ZSliceInternalFx 2 | OutFxDurtaion |
|_______________|_______|___________________|___________________|____________________|
\-------------Body of the Slice ----------------/
The actual structure of the ZTimeSlice can hold
1. start of the fx (represented by nTime_start member)
2. duration of the fx (represented by nTime_length member)
3. action ID of the fx (nFxActionID). It can used in any way you want
***********************************************************************************************/
class ZSliceInternalFx
{
private:
int m_nTime_start; // start time
int m_nTime_length;
double m_nFxActionID;
char compare(const ZSliceInternalFx &c);
bool ZSliceInternalFx::isIn(int time);
public:
ZSliceInternalFx();
ZSliceInternalFx(int start, int length, double actionID);
~ZSliceInternalFx();
int GetSliceFxStart();
int GetSliceFxLength();
double GetSliceFxActionID();
void GetInternalFx(int &Start, int &Length, double &ActionID);
void operator = (const ZSliceInternalFx &c);
bool operator < (const ZSliceInternalFx &c);
bool operator > (const ZSliceInternalFx &c);
bool operator == (const ZSliceInternalFx &c);
bool operator <= (const ZSliceInternalFx &c);
bool operator >= (const ZSliceInternalFx &c);
void EditSliceFx(int start, int length, double actionID);
void GetFxToSlice(int &start, int &length, double &actionID);
};
/***********************************************************************************************
Class ZTimeSlice
TimeSlice represents the actual object on the timeline.
The actual structure of the ZTimeSlice can hold
1. start of the slice (represented by m_time_start member)
2. duration of the slice (represented by m_time_length member)
3. action ID of the slice (m_action_weight by m_time_length member). It can used in any way you want
***********************************************************************************************/
class ZTimeSlice
{
private:
int m_time_start; // start time
int m_time_length; // length of action
int m_timeFxInDuration; //duration of the in Fx
int m_timeFxOutDuration; //duration of the out Fx
double m_action_weight; // what is the action weight, or action details
vector<ZSliceInternalFx> m_InternalFx; //fxs inside the slice body. This is the part between m_timeFxInDuration & m_timeFxOutDuration
private:
char compare(const ZTimeSlice & c);
void swap(int a, int b);
void qsort(int l = -100, int r = -100);
public:
// basic management details
ZTimeSlice();
ZTimeSlice(const ZTimeSlice & c);
ZTimeSlice(int start, int length, int TimeFxInDuration, int TimeFxOutDuration, double weight);
~ZTimeSlice();
void operator = (const ZTimeSlice & c);
bool operator < (const ZTimeSlice & c);
bool operator > (const ZTimeSlice & c);
bool operator == (const ZTimeSlice & c);
bool operator <= (const ZTimeSlice & c);
bool operator >= (const ZTimeSlice & c);
bool isIn(int time);
void SetStart(int start);
void SetLength(int length);
void SetWeight(double weight);
void SetTimeFxInDuration(int length);
void SetTimeFxOutDuration(int length);
int GetSliceFxCount();
int GetStart();
int GetLength();
double GetWeight();
int GetTimeFxInDuration();
int GetTimeFxOutDuration();
void GetFxToSlice(int Fx, int &Start, int &Length, double &ActionID);
void Delete(int ID);
void Edit(int start, int length, int TimeFxInDuration, int TimeFxOutDuration, double weight);
bool AddSliceFx(int start, int length, double actionID);
void EditSliceFx(int FxSlice,int start, int length, double actionID);
int get_time_end();
};
/*************************************************************************************************************
class ZTimeSpan
Time span is used when we need multiple time lines one down the other. Its the railroad where the
TimeSlice sits on top.
It holds the ZTimeSlice structure in the m_splices as well as the 2 member vars for the ownwer and the action
***************************************************************************************************************/
class ZTimeSpan
{
private:
vector<ZTimeSlice> m_splices;
int m_action;
int m_owner;
private:
void swap(int a, int b);
void qsort(int l = -100, int r = -100);
char compare(const ZTimeSpan & c);
public:
ZTimeSpan(int owner = 0, int action = 0);
ZTimeSpan(const ZTimeSpan & c);
~ZTimeSpan();
void operator = (const ZTimeSpan &c);
bool operator < (const ZTimeSpan &c);
bool operator > (const ZTimeSpan &c);
bool operator == (const ZTimeSpan &c);
bool operator <= (const ZTimeSpan &c);
bool operator >= (const ZTimeSpan &c);
// data insertion
bool AddSplice(int start, int length, int TimeFxInDuration, int TimeFxOutDuration, double weight);
void SetOwner(int owner);
void SetAction(int action);
int GetOwner();
int GetAction();
int GetSliceAt(int time);
void GetFxToSlice(int Slice, int Fx, int &Start, int &Length, double &ActionID);
void Edit(int slice, int start, int length, int TimeFxInDuration, int TimeFxOutDuration, double weight);
void Delete(int slice);
int GetSliceCount();
int GetSliceFxCount(int slice);
void GetSlice(int Slice, int &Start, int &Length, int &TimeFxInDuration, int &TimeFxOutDuration, double &Weight);
bool AddSliceFx(int slice, int start, int length, double actionID);
void EditSliceFx(int slice, int FxSlice,int start, int length, double actionID);
};
/*************************************************************************************************************
class ZTimeLine
ZTimeline -> ZTimeSpan -> ZTimeSlice
ZTimeLine can hold many ZTimeSpans which in turns can hold many ZTimeSlice
***************************************************************************************************************/
#ifndef ZENERD_TIMELINE
#define ZENERD_TIMELINE
class ZTimeLine
{
private:
vector<ZTimeSpan> m_ZTimeSpans;
void swap(int a, int b);
void qsort(int l = -100, int r = -100);
public:
ZTimeLine();
ZTimeLine(const ZTimeLine & c);
~ZTimeLine();
void operator=(const ZTimeLine & c);
// Regarding Time Spans
int GetSpanCount();
bool AddTimeSpan(int Owner, int Action);
int GetTimeSpan(int Owner, int Action);
void SetAction(int Span, int Action);
void SetOwner(int Span, int Owner);
int GetAction(int Span);
int GetOwner(int Span);
// Regarging Slice Body Fxs;
bool AddNewFxToSlice(int Span, int Slice, int Start, int Length, double ActionID);
void GetFxToSlice(int Span,int Slice, int Fx, int &Start, int &Length, double &ActionID);
void EditFxToSlice(int Span,int Slice, int Fx, int Start, int Length, double ActionID);
// Regarding Time Slices
int GetSliceCount(int Span);
int GetSliceFxCount(int Span, int Slice);
bool AddTimeSlice(int Span, int Time, int Length, int TimeFxInDuration, int TimeFxOutDuration, double Weight);
int GetTimeSlice(int Span, int Time);
int GetSlice(int Span, int Time); // why did I do this?, not sure
// Unified Structure
void GetSlice(int Span, int Slice, int &Start, int &Length, int &TimeFxInDuration, int &TimeFxOutDuration, double &Weight);// this gets the data
void Edit(int Span, int Slice, int Start, int Length, int TimeFxInDuration, int TimeFxOutDuration, double Weight);
void Delete(int Span, int Slice = -1);
// verification, note: no internal means for collision are used since they may or may not be needed
int isCollision(int Span, int Skip, int Start, int Length);// is there a collision between this data and other data
};
#endif