forked from vpinball/vpinball
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlightseq.h
207 lines (177 loc) · 6.52 KB
/
lightseq.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
// LightSeq.h: Definition of the LightSeq class
//
//////////////////////////////////////////////////////////////////////
#pragma once
#if !defined(AFX_LIGHTSEQ_H__5EC2D0B7_3868_4CCC_81EC_A4653460DF7E__INCLUDED_)
#define AFX_LIGHTSEQ_H__5EC2D0B7_3868_4CCC_81EC_A4653460DF7E__INCLUDED_
#include "resource.h" // main symbols
/////////////////////////////////////////////////////////////////////////////
// LightSeq
class LightSeqData
{
public:
Vertex2D m_v;
Vertex2D m_vCenter;
std::basic_string<WCHAR> m_wzCollection;
long m_updateinterval;
TimerDataRoot m_tdr;
};
struct LightSeqQueueData {
SequencerState Animation;
long TailLength;
long Repeat;
long Pause;
long UpdateRate;
};
struct LightSeqQueue {
int Head;
int Tail;
LightSeqQueueData Data[LIGHTSEQQUEUESIZE];
};
enum {
eSeqNull,
eSeqBlink,
eSeqRandom,
eSeqLine,
eSeqCircle,
eSeqRadar
};
struct _tracer {
int type; // type of tracer processing required
int delay;
int length;
int frameCount;
float x; // current grid coordinates
float stepX; // step to next grid coordinate for the next frame
float processStepX; // step to next grid coordinate for processing this frame
float y;
float stepY;
float processStepY;
float radius;
float stepRadius;
bool processRadiusNeg;
float angle;
float stepAngle;
};
class LightSeq :
public CComObjectRootEx<CComSingleThreadModel>,
public IDispatchImpl<ILightSeq, &IID_ILightSeq, &LIBID_VPinballLib>,
//public ISupportErrorInfo,
//public CComObjectRoot,
public CComCoClass<LightSeq, &CLSID_LightSeq>,
public IConnectionPointContainerImpl<LightSeq>,
public IProvideClassInfo2Impl<&CLSID_LightSeq, &DIID_ILightSeqEvents, &LIBID_VPinballLib>,
public EventProxy<LightSeq, &DIID_ILightSeqEvents>,
public ISelect,
public IEditable,
public IScriptable,
public IFireEvents,
public Hitable,
public IPerPropertyBrowsing // Ability to fill in dropdown(s) in property browser
//public EditableImpl<LightSeq>
{
public:
LightSeq();
~LightSeq();
//HRESULT Init(PinTable *ptable, float x, float y);
BEGIN_COM_MAP(LightSeq)
COM_INTERFACE_ENTRY(IDispatch)
COM_INTERFACE_ENTRY(ILightSeq)
COM_INTERFACE_ENTRY_IMPL(IConnectionPointContainer)
COM_INTERFACE_ENTRY(IProvideClassInfo)
COM_INTERFACE_ENTRY(IProvideClassInfo2)
COM_INTERFACE_ENTRY(IPerPropertyBrowsing)
//COM_INTERFACE_ENTRY(ISupportErrorInfo)
END_COM_MAP()
BEGIN_CONNECTION_POINT_MAP(LightSeq)
CONNECTION_POINT_ENTRY(DIID_ILightSeqEvents)
END_CONNECTION_POINT_MAP()
void RenderOutline(Sur * const psur);
virtual void MoveOffset(const float dx, const float dy);
virtual void SetObjectPos();
// Multi-object manipulation
virtual Vertex2D GetCenter() const;
virtual void PutCenter(const Vertex2D& pv);
virtual void RenderBlueprint(Sur *psur, const bool solid);
virtual ItemTypeEnum HitableGetItemType() const { return eItemLightSeq; }
virtual void WriteRegDefaults();
STANDARD_EDITABLE_DECLARES(LightSeq, eItemLightSeq, LIGHTSEQ, 3)
//DECLARE_NOT_AGGREGATABLE(LightSeq)
// Remove the comment from the line above if you don't want your object to
// support aggregation.
DECLARE_REGISTRY_RESOURCEID(IDR_LIGHT_SEQ)
// ISupportsErrorInfo
STDMETHOD(InterfaceSupportsErrorInfo)(REFIID riid);
private:
U32 m_timeNextUpdate;
int m_blinkSequence;
float m_GridXCenter;
float m_GridYCenter;
int m_lightSeqGridHeight;
int m_lightSeqGridWidth;
int m_GridXCenterAdjust;
int m_GridYCenterAdjust;
_tracer m_th1, m_th2, m_tt1, m_tt2;
Collection *m_pcollection;
short *m_pgridData;
LightSeqQueue m_queue;
SequencerState m_playAnimation;
long m_tailLength;
long m_pauseValue;
long m_replayCount;
long m_updateRate;
bool m_playInProgress;
bool m_pauseInProgress;
// ILightSeq
public:
STDMETHOD(get_Collection)(/*[out, retval]*/ BSTR *pVal);
STDMETHOD(put_Collection)(/*[in]*/ BSTR newVal);
STDMETHOD(get_CenterX)(/*[out, retval]*/ float *pVal);
STDMETHOD(put_CenterX)(/*[in]*/ float newVal);
STDMETHOD(get_CenterY)(/*[out, retval]*/ float *pVal);
STDMETHOD(put_CenterY)(/*[in]*/ float newVal);
STDMETHOD(get_UpdateInterval)(/*[out, retval]*/ long *pVal);
STDMETHOD(put_UpdateInterval)(/*[in]*/ long newVal);
// methods
STDMETHOD(Play)(/*[in]*/ SequencerState Animation, /*[in]*/ long TailLength, /*[in]*/ long Repeat, /*[in]*/ long Pause);
STDMETHOD(StopPlay)();
float GetX() const { return m_d.m_vCenter.x; }
void SetX(const float value)
{
if ((value < 0.f) || (value >= (float)EDITOR_BG_WIDTH))
return;
m_d.m_vCenter.x = value;
// set the center point of the grid for effects which start from the center
m_GridXCenter = floorf(m_d.m_vCenter.x * (float)(1.0 / LIGHTSEQGRIDSCALE));
m_GridXCenterAdjust = abs(m_lightSeqGridWidth / 2 - (int)m_GridXCenter);
}
float GetY() const { return m_d.m_vCenter.y; }
void SetY(const float value)
{
if ((value < 0.f) || (value >= (float)(2 * EDITOR_BG_WIDTH)))
return;
m_d.m_vCenter.y = value;
// set the center point of the grid for effects which start from the center
m_GridYCenter = floorf(m_d.m_vCenter.y * (float)(1.0 / LIGHTSEQGRIDSCALE));
m_GridYCenterAdjust = abs(m_lightSeqGridHeight / 2 - (int)m_GridYCenter);
}
long GetUpdateInterval() const { return m_d.m_updateinterval; }
void SetUpdateInterval(const long value) { m_d.m_updateinterval = max((long)1, value); }
void Animate();
class LightSeqAnimObject : public AnimObject
{
public:
virtual void Animate() { m_pLightSeq->Animate(); } // this function is called every frame to animate the object/light sequence
LightSeq *m_pLightSeq;
} m_lightseqanim;
LightSeqData m_d;
private:
PinTable *m_ptable;
void SetupTracers(const SequencerState Animation, long TailLength, long Repeat, long Pause);
bool ProcessTracer(_tracer * const pTracer, const LightState State);
void SetAllLightsToState(const LightState State);
void SetElementToState(const int index, const LightState State);
LightState GetElementState(const int index) const;
bool VerifyAndSetGridElement(const int x, const int y, const LightState State);
};
#endif // !defined(AFX_LIGHTSEQ_H__5EC2D0B7_3868_4CCC_81EC_A4653460DF7E__INCLUDED_)