forked from iscle/SpaceCadetPinball
-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathTComponentGroup.cpp
63 lines (57 loc) · 1.25 KB
/
TComponentGroup.cpp
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
#include "pch.h"
#include "TComponentGroup.h"
#include "control.h"
#include "loader.h"
#include "timer.h"
#include "TPinballTable.h"
TComponentGroup::TComponentGroup(TPinballTable* table, int groupIndex) : TPinballComponent(table, groupIndex, false)
{
Timer = 0;
if (groupIndex > 0)
{
int attrCount;
auto shortArr = loader::query_iattribute(groupIndex, 1027, &attrCount);
auto shortArrPtr = shortArr;
for (auto index = 0; index < attrCount; ++index, ++shortArrPtr)
{
auto component = table->find_component(*shortArrPtr);
if (component)
List.push_back(component);
}
}
}
TComponentGroup::~TComponentGroup()
{
if (Timer)
{
timer::kill(Timer);
Timer = 0;
}
}
int TComponentGroup::Message(int code, float value)
{
if (code == 48)
{
if (this->Timer)
{
timer::kill(this->Timer);
this->Timer = 0;
}
if (value > 0.0f)
this->Timer = timer::set(value, this, NotifyTimerExpired);
}
else if (code <= 1007 || code > 1011 && code != 1020 && code != 1022)
{
for (auto component : List)
{
component->Message(code, value);
}
}
return 0;
}
void TComponentGroup::NotifyTimerExpired(int timerId, void* caller)
{
auto compGroup = static_cast<TComponentGroup*>(caller);
compGroup->Timer = 0;
control::handler(61, compGroup);
}