2020-11-01 16:45:29 +01:00
|
|
|
#include "pch.h"
|
|
|
|
#include "TTimer.h"
|
2021-01-01 14:14:11 +01:00
|
|
|
|
|
|
|
#include "control.h"
|
|
|
|
#include "timer.h"
|
|
|
|
|
2022-09-06 10:58:35 +02:00
|
|
|
TTimer::TTimer(TPinballTable* table, int groupIndex) : TPinballComponent2(table, groupIndex, true)
|
2021-01-01 14:14:11 +01:00
|
|
|
{
|
|
|
|
Timer = 0;
|
|
|
|
}
|
|
|
|
|
2022-09-06 10:58:35 +02:00
|
|
|
int TTimer::Message2(MessageCode code, float value)
|
2021-01-01 14:14:11 +01:00
|
|
|
{
|
2022-09-06 10:58:35 +02:00
|
|
|
switch (code)
|
2021-01-01 14:14:11 +01:00
|
|
|
{
|
2022-09-06 10:58:35 +02:00
|
|
|
case MessageCode::TTimerResetTimer:
|
2021-01-01 14:14:11 +01:00
|
|
|
if (Timer)
|
|
|
|
timer::kill(Timer);
|
|
|
|
Timer = timer::set(value, this, TimerExpired);
|
2022-09-06 10:58:35 +02:00
|
|
|
break;
|
|
|
|
case MessageCode::SetTiltLock:
|
|
|
|
case MessageCode::GameOver:
|
|
|
|
case MessageCode::Reset:
|
2021-01-01 14:14:11 +01:00
|
|
|
if (Timer)
|
|
|
|
{
|
|
|
|
timer::kill(Timer);
|
|
|
|
Timer = 0;
|
|
|
|
}
|
2022-09-06 10:58:35 +02:00
|
|
|
break;
|
|
|
|
default: break;
|
2021-01-01 14:14:11 +01:00
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void TTimer::TimerExpired(int timerId, void* caller)
|
|
|
|
{
|
|
|
|
auto timer = static_cast<TTimer*>(caller);
|
|
|
|
timer->Timer = 0;
|
|
|
|
control::handler(60, timer);
|
|
|
|
}
|