This repository has been archived by the owner on Oct 24, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
/
dispreel.h
231 lines (203 loc) · 8.85 KB
/
dispreel.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
// DispReel.h: Definition of the DispReel class
//
//////////////////////////////////////////////////////////////////////
#pragma once
#if !defined(AFX_DISPREEL_H__1052EB33_4F53_460B_AAB8_09D3C517F225__INCLUDED_)
#define AFX_DISPREEL_H__1052EB33_4F53_460B_AAB8_09D3C517F225__INCLUDED_
#include "resource.h" // main symbols
/////////////////////////////////////////////////////////////////////////////
// DispReel
// add data in this class is persisted with the table
class DispReelData final : public BaseProperty
{
public:
Vertex2D m_v1, m_v2; // position on map (top right corner)
int m_imagesPerGridRow;
int m_reelcount; // number of individual reel in the set
float m_width, m_height; // size of each reel
float m_reelspacing; // spacing between each reel and the boarders
int m_motorsteps; // steps (or frames) to move each reel each frame
int m_digitrange; // max number of digits per reel (usually 9)
string m_szSound; // sound to play for each turn of a digit
int m_updateinterval; // time in ms between each animation update
COLORREF m_backcolor; // colour of the background
TimerDataRoot m_tdr; // timer information
bool m_transparent; // is the background transparent
bool m_useImageGrid;
};
class DispReel :
public CComObjectRootEx<CComSingleThreadModel>,
public IDispatchImpl<IDispReel, &IID_IDispReel, &LIBID_VPinballLib>,
//public ISupportErrorInfo,
//public CComObjectRoot,
public CComCoClass<DispReel, &CLSID_DispReel>,
public EventProxy<DispReel, &DIID_IDispReelEvents>,
public IConnectionPointContainerImpl<DispReel>,
public IProvideClassInfo2Impl<&CLSID_DispReel, &DIID_IDispReelEvents, &LIBID_VPinballLib>,
public ISelect,
public IEditable,
public IScriptable,
public IFireEvents,
public Hitable,
public IPerPropertyBrowsing // Ability to fill in dropdown(s) in property browser
{
public:
DispReel();
virtual ~DispReel() {}
BEGIN_COM_MAP(DispReel)
COM_INTERFACE_ENTRY(IDispatch)
COM_INTERFACE_ENTRY(IDispReel)
COM_INTERFACE_ENTRY_IMPL(IConnectionPointContainer)
COM_INTERFACE_ENTRY(IProvideClassInfo)
COM_INTERFACE_ENTRY(IProvideClassInfo2)
COM_INTERFACE_ENTRY(IPerPropertyBrowsing)
//COM_INTERFACE_ENTRY(ISupportErrorInfo)
END_COM_MAP()
//DECLARE_NOT_AGGREGATABLE(DispReel)
// Remove the comment from the line above if you don't want your object to
// support aggregation.
BEGIN_CONNECTION_POINT_MAP(DispReel)
CONNECTION_POINT_ENTRY(DIID_IDispReelEvents)
END_CONNECTION_POINT_MAP()
STANDARD_EDITABLE_DECLARES(DispReel, eItemDispReel, DISPREEL, 2)
void MoveOffset(const float dx, const float dy) final;
void SetObjectPos() final;
// Multi-object manipulation
Vertex2D GetCenter() const final;
void PutCenter(const Vertex2D &pv) final;
ItemTypeEnum HitableGetItemType() const final { return eItemDispReel; }
void WriteRegDefaults() final;
DECLARE_REGISTRY_RESOURCEID(IDR_DISP_REEL)
// ISupportsErrorInfo
STDMETHOD(InterfaceSupportsErrorInfo)(REFIID riid);
int GetImagesPerGridRow() const { return m_d.m_imagesPerGridRow; }
void SetImagesPerGridRow(const int amount) { m_d.m_imagesPerGridRow = max(1, amount); }
int GetReels() const { return m_d.m_reelcount; }
void SetReels(const int reels)
{
m_d.m_reelcount = min(max(1, reels), MAX_REELS); // must have at least 1 reel and a max of MAX_REELS
m_d.m_v2.x = m_d.m_v1.x + getBoxWidth();
m_d.m_v2.y = m_d.m_v1.y + getBoxHeight();
}
int GetRange() const { return m_d.m_digitrange; }
void SetRange(const int newRange)
{
m_d.m_digitrange = max(0, newRange); // must have at least 1 digit (0 is a digit)
if (m_d.m_digitrange > 512 - 1) m_d.m_digitrange = 512 - 1; // and a max of 512 (0->511) //!! 512 requested by highrise
}
float GetX() const { return m_d.m_v1.x; }
void SetX(const float x)
{
const float delta = x - m_d.m_v1.x;
m_d.m_v1.x += delta;
m_d.m_v2.x = m_d.m_v1.x + getBoxWidth();
}
float GetY() const { return m_d.m_v1.y; }
void SetY(const float y)
{
const float delta = y - m_d.m_v1.y;
m_d.m_v1.y += delta;
m_d.m_v2.y = m_d.m_v1.y + getBoxHeight();
}
float GetWidth() const { return m_d.m_width; }
void SetWidth(const float width)
{
m_d.m_width = max(0.0f, width);
m_d.m_v2.x = m_d.m_v1.x + getBoxWidth();
}
float GetHeight() const { return m_d.m_height; }
void SetHeight(const float height)
{
m_d.m_height = max(0.0f, height);
m_d.m_v2.y = m_d.m_v1.y + getBoxHeight();
}
float GetSpacing() const { return m_d.m_reelspacing; }
void SetSpacing(const float newSpace)
{
m_d.m_reelspacing = max(0.0f, newSpace);
m_d.m_v2.x = m_d.m_v1.x + getBoxWidth();
m_d.m_v2.y = m_d.m_v1.y + getBoxHeight();
}
int GetMotorSteps() const { return m_d.m_motorsteps; }
void SetMotorSteps(const int steps)
{
m_d.m_motorsteps = max(1, steps); // must have at least 1 step)
}
int GetUpdateInterval() const { return m_d.m_updateinterval; }
void SetUpdateInterval(const int interval)
{
m_d.m_updateinterval = max((int)5, interval);
}
void Animate();
class DispReelAnimObject final : public AnimObject
{
public:
void Animate() { m_pDispReel->Animate(); } // this function is called every frame to animate the object/reels animation
DispReel *m_pDispReel;
} m_dispreelanim;
DispReelData m_d;
private:
float getBoxWidth() const;
float getBoxHeight() const;
PinTable *m_ptable;
float m_renderwidth, m_renderheight; // size of each reel (rendered)
struct ReelInfo
{
int currentValue; // current digit value
int motorPulses; // number of motor pulses received for this reel (can be negative)
int motorStepCount; // when equal to zero then at a whole letter
float motorCalcStep; // calculated steping rate of motor
float motorOffset; // frame value of motor (where to display the reel)
};
ReelInfo m_reelInfo[MAX_REELS];
float m_reeldigitwidth; // size of the individual reel digits (in bitmap form)
float m_reeldigitheight;
U32 m_timeNextUpdate;
struct TexCoordRect
{
float u_min, u_max;
float v_min, v_max;
};
vector<TexCoordRect> m_digitTexCoords;
// IDispReel
public:
// properties
STDMETHOD(get_IsTransparent)(/*[out, retval]*/ VARIANT_BOOL *pVal);
STDMETHOD(put_IsTransparent)(/*[in]*/ VARIANT_BOOL newVal);
STDMETHOD(get_Y)(/*[out, retval]*/ float *pVal);
STDMETHOD(put_Y)(/*[in]*/ float newVal);
STDMETHOD(get_X)(/*[out, retval]*/ float *pVal);
STDMETHOD(put_X)(/*[in]*/ float newVal);
STDMETHOD(get_Reels)(/*[out, retval]*/ float *pVal);
STDMETHOD(put_Reels)(/*[in]*/ float newVal);
STDMETHOD(get_Height)(/*[out, retval]*/ float *pVal);
STDMETHOD(put_Height)(/*[in]*/ float newVal);
STDMETHOD(get_Width)(/*[out, retval]*/ float *pVal);
STDMETHOD(put_Width)(/*[in]*/ float newVal);
STDMETHOD(get_Spacing)(/*[out, retval]*/ float *pVal);
STDMETHOD(put_Spacing)(/*[in]*/ float newVal);
STDMETHOD(get_BackColor)(/*[out, retval]*/ OLE_COLOR *pVal);
STDMETHOD(put_BackColor)(/*[in]*/ OLE_COLOR newVal);
STDMETHOD(get_Image)(/*[out, retval]*/ BSTR *pVal);
STDMETHOD(put_Image)(/*[in]*/ BSTR newVal);
STDMETHOD(get_Sound)(/*[out, retval]*/ BSTR *pVal);
STDMETHOD(put_Sound)(/*[in]*/ BSTR newVal);
STDMETHOD(get_Steps)(/*[out, retval]*/ float *pVal);
STDMETHOD(put_Steps)(/*[in]*/ float newVal);
STDMETHOD(get_Range)(/*[out, retval]*/ float *pVal);
STDMETHOD(put_Range)(/*[in]*/ float newVal);
STDMETHOD(get_UpdateInterval)(/*[out, retval]*/ long *pVal);
STDMETHOD(put_UpdateInterval)(/*[in]*/ long newVal);
STDMETHOD(get_UseImageGrid)(/*[out, retval]*/ VARIANT_BOOL *pVal);
STDMETHOD(put_UseImageGrid)(/*[in]*/ VARIANT_BOOL newVal);
STDMETHOD(get_ImagesPerGridRow)(/*[out, retval]*/ long *pVal);
STDMETHOD(put_ImagesPerGridRow)(/*[in]*/ long newVal);
STDMETHOD(get_Visible)(/*[out, retval]*/ VARIANT_BOOL *pVal);
STDMETHOD(put_Visible)(/*[in]*/ VARIANT_BOOL newVal);
// methods
STDMETHOD(ResetToZero)();
STDMETHOD(AddValue)(/*[in]*/ long Value);
STDMETHOD(SetValue)(/*[in]*/ long Value);
STDMETHOD(SpinReel)(/*[in]*/ long ReelNumber, /*[in]*/ long PulseCount);
};
#endif // !defined(AFX_DISPREEL_H__1052EB33_4F53_460B_AAB8_09D3C517F225__INCLUDED_)