-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathlightseq.h
210 lines (176 loc) · 5.79 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
208
209
210
// 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;
WCHAR m_wzCollection[MAXNAMEBUFFER]; // collection to use
long m_updateinterval;
TimerDataRoot m_tdr;
};
typedef struct {
SequencerState Animation;
long TailLength;
long Repeat;
long Pause;
long UpdateRate;
} _LightSeqQueueData;
typedef struct {
int Head;
int Tail;
_LightSeqQueueData Data[LIGHTSEQQUEUESIZE];
} _LightSeqQueue;
enum {
eSeqNull,
eSeqBlink,
eSeqRandom,
eSeqLine,
eSeqCircle,
eSeqRadar
};
typedef struct {
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;
float processRadius;
float angle;
float stepAngle;
float processAngle;
} _tracer;
class LightSeqCenter : public ISelect
{
public:
LightSeqCenter(LightSeq * const pLightSeq);
virtual HRESULT GetTypeName(BSTR *pVal);
virtual IDispatch *GetDispatch();
virtual void GetDialogPanes(Vector<PropertyPane> *pvproppane);
virtual void Delete();
virtual void Uncreate();
virtual int GetSelectLevel();
virtual IEditable *GetIEditable();
virtual PinTable *GetPTable();
virtual BOOL LoadToken(int id, BiffReader *pbr) {return fTrue;}
virtual void GetCenter(Vertex2D * const pv) const;
virtual void PutCenter(const Vertex2D * const pv);
virtual void MoveOffset(const float dx, const float dy);
virtual ItemTypeEnum GetItemType() {return eItemLightSeqCenter;}
LightSeq *m_pLightSeq;
};
class LightSeq :
public CComObjectRootEx<CComSingleThreadModel>,
public IDispatchImpl<ILightSeq, &IID_ILightSeq, &LIBID_VPinballLib>,
//public ISupportErrorInfo,
//public CComObjectRoot,
public CComCoClass<LightSeq,&CLSID_LightSeq>,
#ifdef VBA
public CApcProjectItem<LightSeq>,
#endif
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()
//virtual HRESULT GetTypeName(BSTR *pVal);
virtual void GetDialogPanes(Vector<PropertyPane> *pvproppane);
void RenderOutline(Sur * const psur);
virtual void MoveOffset(const float dx, const float dy);
virtual void SetObjectPos();
// Multi-object manipulation
virtual void GetCenter(Vertex2D * const pv) const;
virtual void PutCenter(const Vertex2D * const pv);
virtual void RenderBlueprint(Sur *psur);
void WriteRegDefaults();
STANDARD_DISPATCH_DECLARE
STANDARD_EDITABLE_DECLARES(eItemLightSeq)
//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)();
PinTable *m_ptable;
LightSeqData m_d;
LightSeqUpdater *m_ptu;
LightSeqCenter m_LightSeqCenter;
bool RenderAnimation();
private:
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);
bool VerifyAndSetGridElement(const int x, const int y, const LightState State);
};
#endif // !defined(AFX_LIGHTSEQ_H__5EC2D0B7_3868_4CCC_81EC_A4653460DF7E__INCLUDED_)