mirror of
https://github.com/k4zmu2a/SpaceCadetPinball.git
synced 2024-11-22 02:32:39 +01:00
Message code enum part 3: light and light group.
This commit is contained in:
parent
803ca14ef2
commit
e80010e3c6
@ -8,7 +8,7 @@
|
||||
#include "timer.h"
|
||||
#include "TPinballTable.h"
|
||||
|
||||
TLight::TLight(TPinballTable* table, int groupIndex) : TPinballComponent(table, groupIndex, true)
|
||||
TLight::TLight(TPinballTable* table, int groupIndex) : TPinballComponent2(table, groupIndex, true)
|
||||
{
|
||||
TimeoutTimer = 0;
|
||||
FlasherOnFlag = false;
|
||||
@ -23,13 +23,13 @@ TLight::TLight(TPinballTable* table, int groupIndex) : TPinballComponent(table,
|
||||
SourceDelay[1] = *floatArr2;
|
||||
}
|
||||
|
||||
int TLight::Message(int code, float value)
|
||||
int TLight::Message2(MessageCode code, float value)
|
||||
{
|
||||
int bmpIndex;
|
||||
|
||||
switch (code)
|
||||
{
|
||||
case ~MessageCode::Reset:
|
||||
case MessageCode::Reset:
|
||||
Reset();
|
||||
for (auto index = 0; index < PinballTable->PlayerCount; ++index)
|
||||
{
|
||||
@ -40,7 +40,7 @@ int TLight::Message(int code, float value)
|
||||
playerPtr->MessageField = MessageField;
|
||||
}
|
||||
break;
|
||||
case ~MessageCode::PlayerChanged:
|
||||
case MessageCode::PlayerChanged:
|
||||
{
|
||||
auto playerPtr = &PlayerData[PinballTable->CurrentPlayer];
|
||||
playerPtr->FlasherOnFlag = FlasherOnFlag;
|
||||
@ -57,29 +57,29 @@ int TLight::Message(int code, float value)
|
||||
MessageField = playerPtr->MessageField;
|
||||
if (LightOnBmpIndex)
|
||||
{
|
||||
Message(11, static_cast<float>(LightOnBmpIndex));
|
||||
Message2(MessageCode::TLightSetOnStateBmpIndex, static_cast<float>(LightOnBmpIndex));
|
||||
}
|
||||
if (LightOnFlag)
|
||||
Message(1, 0.0);
|
||||
Message2(MessageCode::TLightTurnOn, 0.0);
|
||||
if (FlasherOnFlag)
|
||||
Message(4, 0.0);
|
||||
Message2(MessageCode::TLightFlasherStart, 0.0);
|
||||
break;
|
||||
}
|
||||
case 0:
|
||||
case MessageCode::TLightTurnOff:
|
||||
LightOnFlag = false;
|
||||
if (!FlasherOnFlag && !ToggledOffFlag && !ToggledOnFlag)
|
||||
SetSpriteBmp(BmpArr[0]);
|
||||
break;
|
||||
case 1:
|
||||
case MessageCode::TLightTurnOn:
|
||||
LightOnFlag = true;
|
||||
if (!FlasherOnFlag && !ToggledOffFlag && !ToggledOnFlag)
|
||||
SetSpriteBmp(BmpArr[1]);
|
||||
break;
|
||||
case 2:
|
||||
case MessageCode::TLightGetLightOnFlag:
|
||||
return LightOnFlag;
|
||||
case 3:
|
||||
case MessageCode::TLightGetFlasherOnFlag:
|
||||
return FlasherOnFlag;
|
||||
case 4:
|
||||
case MessageCode::TLightFlasherStart:
|
||||
schedule_timeout(0.0);
|
||||
if (!FlasherOnFlag || !FlashTimer)
|
||||
{
|
||||
@ -90,15 +90,15 @@ int TLight::Message(int code, float value)
|
||||
flasher_start(LightOnFlag);
|
||||
}
|
||||
break;
|
||||
case 5:
|
||||
case MessageCode::TLightApplyMultDelay:
|
||||
FlashDelay[0] = value * SourceDelay[0];
|
||||
FlashDelay[1] = value * SourceDelay[1];
|
||||
break;
|
||||
case 6:
|
||||
case MessageCode::TLightApplyDelay:
|
||||
FlashDelay[0] = SourceDelay[0];
|
||||
FlashDelay[1] = SourceDelay[1];
|
||||
break;
|
||||
case 7:
|
||||
case MessageCode::TLightFlasherStartTimed:
|
||||
if (!FlasherOnFlag)
|
||||
flasher_start(LightOnFlag);
|
||||
FlasherOnFlag = true;
|
||||
@ -107,7 +107,7 @@ int TLight::Message(int code, float value)
|
||||
ToggledOffFlag = false;
|
||||
schedule_timeout(value);
|
||||
break;
|
||||
case 8:
|
||||
case MessageCode::TLightTurnOffTimed:
|
||||
if (!ToggledOffFlag)
|
||||
{
|
||||
if (FlasherOnFlag)
|
||||
@ -124,7 +124,7 @@ int TLight::Message(int code, float value)
|
||||
}
|
||||
schedule_timeout(value);
|
||||
break;
|
||||
case 9:
|
||||
case MessageCode::TLightTurnOnTimed:
|
||||
if (!ToggledOnFlag)
|
||||
{
|
||||
if (FlasherOnFlag)
|
||||
@ -141,7 +141,7 @@ int TLight::Message(int code, float value)
|
||||
}
|
||||
schedule_timeout(value);
|
||||
break;
|
||||
case 11:
|
||||
case MessageCode::TLightSetOnStateBmpIndex:
|
||||
LightOnBmpIndex = Clamp(static_cast<int>(floor(value)), 0, static_cast<int>(ListBitmap->size()) - 1);
|
||||
BmpArr[0] = nullptr;
|
||||
BmpArr[1] = ListBitmap->at(LightOnBmpIndex);
|
||||
@ -160,19 +160,19 @@ int TLight::Message(int code, float value)
|
||||
}
|
||||
SetSpriteBmp(BmpArr[bmpIndex]);
|
||||
break;
|
||||
case 12:
|
||||
case MessageCode::TLightIncOnStateBmpIndex:
|
||||
bmpIndex = LightOnBmpIndex + 1;
|
||||
if (bmpIndex >= static_cast<int>(ListBitmap->size()))
|
||||
bmpIndex = static_cast<int>(ListBitmap->size()) - 1;
|
||||
Message(11, static_cast<float>(bmpIndex));
|
||||
Message2(MessageCode::TLightSetOnStateBmpIndex, static_cast<float>(bmpIndex));
|
||||
break;
|
||||
case 13:
|
||||
case MessageCode::TLightDecOnStateBmpIndex:
|
||||
bmpIndex = LightOnBmpIndex - 1;
|
||||
if (bmpIndex < 0)
|
||||
bmpIndex = 0;
|
||||
Message(11, static_cast<float>(bmpIndex));
|
||||
Message2(MessageCode::TLightSetOnStateBmpIndex, static_cast<float>(bmpIndex));
|
||||
break;
|
||||
case 14:
|
||||
case MessageCode::TLightResetTimed:
|
||||
if (TimeoutTimer)
|
||||
timer::kill(TimeoutTimer);
|
||||
TimeoutTimer = 0;
|
||||
@ -183,49 +183,49 @@ int TLight::Message(int code, float value)
|
||||
ToggledOnFlag = false;
|
||||
SetSpriteBmp(BmpArr[LightOnFlag]);
|
||||
break;
|
||||
case 15:
|
||||
case MessageCode::TLightFlasherStartTimedThenStayOn:
|
||||
TurnOffAfterFlashingFg = false;
|
||||
if (UndoOverrideTimer)
|
||||
timer::kill(UndoOverrideTimer);
|
||||
UndoOverrideTimer = 0;
|
||||
Message(1, 0.0);
|
||||
Message(7, value);
|
||||
Message2(MessageCode::TLightTurnOn, 0.0);
|
||||
Message2(MessageCode::TLightFlasherStartTimed, value);
|
||||
break;
|
||||
case 16:
|
||||
case MessageCode::TLightFlasherStartTimedThenStayOff:
|
||||
if (UndoOverrideTimer)
|
||||
timer::kill(UndoOverrideTimer);
|
||||
UndoOverrideTimer = 0;
|
||||
Message(7, value);
|
||||
Message2(MessageCode::TLightFlasherStartTimed, value);
|
||||
TurnOffAfterFlashingFg = true;
|
||||
break;
|
||||
case 17:
|
||||
Message(static_cast<int>(floor(value)) != 0, 0.0);
|
||||
case MessageCode::TLightToggleValue:
|
||||
Message2(static_cast<int>(floor(value)) ? MessageCode::TLightTurnOn : MessageCode::TLightTurnOff, 0.0);
|
||||
return LightOnFlag;
|
||||
case 18:
|
||||
Message(17, value);
|
||||
Message(14, 0.0);
|
||||
case MessageCode::TLightResetAndToggleValue:
|
||||
Message2(MessageCode::TLightToggleValue, value);
|
||||
Message2(MessageCode::TLightResetTimed, 0.0);
|
||||
return LightOnFlag;
|
||||
case 19:
|
||||
Message(1, 0.0);
|
||||
Message(14, 0.0);
|
||||
case MessageCode::TLightResetAndTurnOn:
|
||||
Message2(MessageCode::TLightTurnOn, 0.0);
|
||||
Message2(MessageCode::TLightResetTimed, 0.0);
|
||||
break;
|
||||
case 20:
|
||||
Message(0, 0.0);
|
||||
Message(14, 0.0);
|
||||
case MessageCode::TLightResetAndTurnOff:
|
||||
Message2(MessageCode::TLightTurnOff, 0.0);
|
||||
Message2(MessageCode::TLightResetTimed, 0.0);
|
||||
break;
|
||||
case 21:
|
||||
Message(17, !LightOnFlag);
|
||||
case MessageCode::TLightToggle:
|
||||
Message2(MessageCode::TLightToggleValue, !LightOnFlag);
|
||||
return LightOnFlag;
|
||||
case 22:
|
||||
Message(18, !LightOnFlag);
|
||||
case MessageCode::TLightResetAndToggle:
|
||||
Message2(MessageCode::TLightResetAndToggleValue, !LightOnFlag);
|
||||
return LightOnFlag;
|
||||
case 23:
|
||||
case MessageCode::TLightSetMessageField:
|
||||
MessageField = static_cast<int>(floor(value));
|
||||
break;
|
||||
case -24:
|
||||
case -25:
|
||||
case MessageCode::TLightFtTmpOverrideOn:
|
||||
case MessageCode::TLightFtTmpOverrideOff:
|
||||
// FT codes in negative to avoid overlap with 3DPB TLightGroup codes
|
||||
render::sprite_set_bitmap(RenderSprite, BmpArr[code == -24]);
|
||||
render::sprite_set_bitmap(RenderSprite, BmpArr[code == MessageCode::TLightFtTmpOverrideOn]);
|
||||
if (UndoOverrideTimer)
|
||||
timer::kill(UndoOverrideTimer);
|
||||
UndoOverrideTimer = 0;
|
||||
@ -235,7 +235,7 @@ int TLight::Message(int code, float value)
|
||||
UndoOverrideTimer = timer::set(value, this, UndoTmpOverride);
|
||||
}
|
||||
break;
|
||||
case -26:
|
||||
case MessageCode::TLightFtResetOverride:
|
||||
if (UndoOverrideTimer)
|
||||
timer::kill(UndoOverrideTimer);
|
||||
UndoOverrideTimer = 0;
|
||||
@ -298,7 +298,7 @@ void TLight::TimerExpired(int timerId, void* caller)
|
||||
if (light->TurnOffAfterFlashingFg)
|
||||
{
|
||||
light->TurnOffAfterFlashingFg = false;
|
||||
light->Message(20, 0.0);
|
||||
light->Message2(MessageCode::TLightResetAndTurnOff, 0.0);
|
||||
}
|
||||
if (light->Control)
|
||||
control::handler(60, light);
|
||||
@ -341,5 +341,5 @@ void TLight::flasher_callback(int timerId, void* caller)
|
||||
void TLight::UndoTmpOverride(int timerId, void* caller)
|
||||
{
|
||||
auto light = static_cast<TLight*>(caller);
|
||||
light->Message(-26, 0.0f);
|
||||
light->Message2(MessageCode::TLightFtResetOverride, 0.0f);
|
||||
}
|
||||
|
@ -13,11 +13,11 @@ struct TLight_player_backup
|
||||
|
||||
|
||||
class TLight :
|
||||
public TPinballComponent
|
||||
public TPinballComponent2
|
||||
{
|
||||
public:
|
||||
TLight(TPinballTable* table, int groupIndex);
|
||||
int Message(int code, float value) override;
|
||||
int Message2(MessageCode code, float value) override;
|
||||
void Reset();
|
||||
void schedule_timeout(float time);
|
||||
void flasher_stop(int bmpIndex);
|
||||
|
@ -32,13 +32,13 @@ TLightBargraph::~TLightBargraph()
|
||||
delete[] TimerTimeArray;
|
||||
}
|
||||
|
||||
int TLightBargraph::Message(int code, float value)
|
||||
int TLightBargraph::Message2(MessageCode code, float value)
|
||||
{
|
||||
switch (code)
|
||||
{
|
||||
case 37:
|
||||
case MessageCode::TLightGroupGetOnCount:
|
||||
return TimeIndex;
|
||||
case 45:
|
||||
case MessageCode::TLightGroupToggleSplitIndex:
|
||||
{
|
||||
if (TimerBargraph)
|
||||
{
|
||||
@ -51,24 +51,24 @@ int TLightBargraph::Message(int code, float value)
|
||||
timeIndex = maxCount - 1;
|
||||
if (timeIndex >= 0)
|
||||
{
|
||||
TLightGroup::Message(45, static_cast<float>(timeIndex / 2));
|
||||
TLightGroup::Message2(MessageCode::TLightGroupToggleSplitIndex, static_cast<float>(timeIndex / 2));
|
||||
if (!(timeIndex & 1))
|
||||
TLightGroup::Message(46, 0.0);
|
||||
TLightGroup::Message2(MessageCode::TLightGroupStartFlasher, 0.0);
|
||||
if (TimerTimeArray)
|
||||
TimerBargraph = timer::set(TimerTimeArray[timeIndex], this, BargraphTimerExpired);
|
||||
TimeIndex = timeIndex;
|
||||
}
|
||||
else
|
||||
{
|
||||
TLightGroup::Message(20, 0.0);
|
||||
TLightGroup::Message2(MessageCode::TLightResetAndTurnOff, 0.0);
|
||||
TimeIndex = 0;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case ~MessageCode::SetTiltLock:
|
||||
case MessageCode::SetTiltLock:
|
||||
Reset();
|
||||
break;
|
||||
case ~MessageCode::PlayerChanged:
|
||||
case MessageCode::PlayerChanged:
|
||||
if (TimerBargraph)
|
||||
{
|
||||
timer::kill(TimerBargraph);
|
||||
@ -79,10 +79,10 @@ int TLightBargraph::Message(int code, float value)
|
||||
TimeIndex = PlayerTimerIndexBackup[static_cast<int>(floor(value))];
|
||||
if (TimeIndex)
|
||||
{
|
||||
TLightBargraph::Message(45, static_cast<float>(TimeIndex));
|
||||
TLightBargraph::Message2(MessageCode::TLightGroupToggleSplitIndex, static_cast<float>(TimeIndex));
|
||||
}
|
||||
break;
|
||||
case ~MessageCode::Reset:
|
||||
case MessageCode::Reset:
|
||||
{
|
||||
Reset();
|
||||
int* playerPtr = PlayerTimerIndexBackup;
|
||||
@ -92,11 +92,11 @@ int TLightBargraph::Message(int code, float value)
|
||||
|
||||
++playerPtr;
|
||||
}
|
||||
TLightGroup::Message(~MessageCode::Reset, value);
|
||||
TLightGroup::Message2(MessageCode::Reset, value);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
TLightGroup::Message(code, value);
|
||||
TLightGroup::Message2(code, value);
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
@ -119,12 +119,12 @@ void TLightBargraph::BargraphTimerExpired(int timerId, void* caller)
|
||||
bar->TimerBargraph = 0;
|
||||
if (bar->TimeIndex)
|
||||
{
|
||||
bar->Message(45, static_cast<float>(bar->TimeIndex - 1));
|
||||
bar->Message2(MessageCode::TLightGroupToggleSplitIndex, static_cast<float>(bar->TimeIndex - 1));
|
||||
control::handler(60, bar);
|
||||
}
|
||||
else
|
||||
{
|
||||
bar->Message(20, 0.0);
|
||||
bar->Message2(MessageCode::TLightResetAndTurnOff, 0.0);
|
||||
control::handler(47, bar);
|
||||
}
|
||||
}
|
||||
|
@ -7,7 +7,7 @@ class TLightBargraph :
|
||||
public:
|
||||
TLightBargraph(TPinballTable* table, int groupIndex);
|
||||
~TLightBargraph() override;
|
||||
int Message(int code, float value) override;
|
||||
int Message2(MessageCode code, float value) override;
|
||||
void Reset() override;
|
||||
|
||||
static void BargraphTimerExpired(int timerId, void* caller);
|
||||
|
@ -8,7 +8,7 @@
|
||||
#include "TLight.h"
|
||||
#include "TPinballTable.h"
|
||||
|
||||
TLightGroup::TLightGroup(TPinballTable* table, int groupIndex) : TPinballComponent(table, groupIndex, false)
|
||||
TLightGroup::TLightGroup(TPinballTable* table, int groupIndex) : TPinballComponent2(table, groupIndex, false)
|
||||
{
|
||||
Timer = 0;
|
||||
NotifyTimer = 0;
|
||||
@ -28,15 +28,15 @@ TLightGroup::TLightGroup(TPinballTable* table, int groupIndex) : TPinballCompone
|
||||
}
|
||||
}
|
||||
|
||||
int TLightGroup::Message(int code, float value)
|
||||
int TLightGroup::Message2(MessageCode code, float value)
|
||||
{
|
||||
auto const count = static_cast<int>(List.size());
|
||||
switch (code)
|
||||
{
|
||||
case ~MessageCode::SetTiltLock:
|
||||
case ~MessageCode::GameOver:
|
||||
case MessageCode::SetTiltLock:
|
||||
case MessageCode::GameOver:
|
||||
break;
|
||||
case ~MessageCode::PlayerChanged:
|
||||
case MessageCode::PlayerChanged:
|
||||
{
|
||||
auto playerPtr = &PlayerData[PinballTable->CurrentPlayer];
|
||||
playerPtr->MessageField = MessageField;
|
||||
@ -53,7 +53,7 @@ int TLightGroup::Message(int code, float value)
|
||||
TimerExpired(0, this);
|
||||
break;
|
||||
}
|
||||
case ~MessageCode::Reset:
|
||||
case MessageCode::Reset:
|
||||
Reset();
|
||||
for (auto index = 0; index < PinballTable->PlayerCount; index++)
|
||||
{
|
||||
@ -63,99 +63,99 @@ int TLightGroup::Message(int code, float value)
|
||||
playerPtr->Timer1Time = Timer1Time;
|
||||
}
|
||||
break;
|
||||
case 24:
|
||||
case MessageCode::TLightGroupStepBackward:
|
||||
{
|
||||
auto lastLight = List.at(count - 1);
|
||||
if (lastLight->FlasherOnFlag || lastLight->ToggledOnFlag || lastLight->ToggledOffFlag)
|
||||
break;
|
||||
if (MessageField2)
|
||||
if (MessageField2 != MessageCode::TLightGroupNull)
|
||||
{
|
||||
TLightGroup::Message(34, 0.0);
|
||||
TLightGroup::Message2(MessageCode::TLightGroupReset, 0.0);
|
||||
}
|
||||
AnimationFlag = 1;
|
||||
MessageField2 = code;
|
||||
auto lightMessageField = lastLight->MessageField;
|
||||
auto lightStatusBefore = lastLight->LightOnFlag;
|
||||
auto lastMessage = lastLight->MessageField;
|
||||
auto lastStatus = lastLight->LightOnFlag;
|
||||
for (auto index = count - 1; index > 0; --index)
|
||||
{
|
||||
auto lightCur = List.at(index);
|
||||
auto lightPrev = List.at(index - 1);
|
||||
lightCur->Message(lightPrev->LightOnFlag, 0.0);
|
||||
lightCur->Message2(lightPrev->LightOnFlag ? MessageCode::TLightTurnOn : MessageCode::TLightTurnOff, 0.0);
|
||||
lightCur->MessageField = lightPrev->MessageField;
|
||||
}
|
||||
auto firstLight = List.at(0);
|
||||
firstLight->Message(lightStatusBefore, 0.0);
|
||||
firstLight->MessageField = lightMessageField;
|
||||
firstLight->Message2(lastStatus ? MessageCode::TLightTurnOn : MessageCode::TLightTurnOff, 0.0);
|
||||
firstLight->MessageField = lastMessage;
|
||||
reschedule_animation(value);
|
||||
break;
|
||||
}
|
||||
case 25:
|
||||
case MessageCode::TLightGroupStepForward:
|
||||
{
|
||||
auto lastLight = List.at(count - 1);
|
||||
if (lastLight->FlasherOnFlag || lastLight->ToggledOnFlag || lastLight->ToggledOffFlag)
|
||||
break;
|
||||
if (MessageField2)
|
||||
if (MessageField2 != MessageCode::TLightGroupNull)
|
||||
{
|
||||
TLightGroup::Message(34, 0.0);
|
||||
TLightGroup::Message2(MessageCode::TLightGroupReset, 0.0);
|
||||
}
|
||||
auto firstLight = List.at(0);
|
||||
AnimationFlag = 1;
|
||||
MessageField2 = code;
|
||||
auto lightMessageField = firstLight->MessageField;
|
||||
auto lightStatusBefore = firstLight->LightOnFlag;
|
||||
auto firstMessage = firstLight->MessageField;
|
||||
auto firstStatus = firstLight->LightOnFlag;
|
||||
for (auto index = 0; index < count - 1; index++)
|
||||
{
|
||||
auto lightCur = List.at(index);
|
||||
auto lightNext = List.at(index + 1);
|
||||
lightCur->Message(lightNext->LightOnFlag, 0.0);
|
||||
lightCur->Message2(lightNext->LightOnFlag ? MessageCode::TLightTurnOn : MessageCode::TLightTurnOff, 0.0);
|
||||
lightCur->MessageField = lightNext->MessageField;
|
||||
}
|
||||
lastLight->Message(lightStatusBefore, 0.0);
|
||||
lastLight->MessageField = lightMessageField;
|
||||
lastLight->Message2(firstStatus ? MessageCode::TLightTurnOn : MessageCode::TLightTurnOff, 0.0);
|
||||
lastLight->MessageField = firstMessage;
|
||||
reschedule_animation(value);
|
||||
break;
|
||||
}
|
||||
case 26:
|
||||
case MessageCode::TLightGroupAnimationBackward:
|
||||
{
|
||||
if (AnimationFlag || !MessageField2)
|
||||
if (AnimationFlag || MessageField2 == MessageCode::TLightGroupNull)
|
||||
start_animation();
|
||||
MessageField2 = code;
|
||||
AnimationFlag = 0;
|
||||
auto lastLight = List.at(count - 1);
|
||||
auto flasherFlag2 = lastLight->ToggledOnFlag;
|
||||
auto lastStatus = lastLight->ToggledOnFlag;
|
||||
for (auto i = count - 1; i > 0; --i)
|
||||
{
|
||||
auto lightCur = List.at(i);
|
||||
auto lightPrev = List.at(i - 1);
|
||||
lightCur->Message(lightPrev->ToggledOnFlag + 8, 0.0);
|
||||
lightCur->Message2(lightPrev->ToggledOnFlag ? MessageCode::TLightTurnOnTimed : MessageCode::TLightTurnOffTimed, 0.0);
|
||||
}
|
||||
auto firstLight = List.at(0);
|
||||
firstLight->Message((flasherFlag2 != 0) + 8, 0);
|
||||
firstLight->Message2(lastStatus ? MessageCode::TLightTurnOnTimed : MessageCode::TLightTurnOffTimed, 0);
|
||||
reschedule_animation(value);
|
||||
break;
|
||||
}
|
||||
case 27:
|
||||
case MessageCode::TLightGroupAnimationForward:
|
||||
{
|
||||
if (AnimationFlag || !MessageField2)
|
||||
if (AnimationFlag || MessageField2 == MessageCode::TLightGroupNull)
|
||||
start_animation();
|
||||
MessageField2 = code;
|
||||
AnimationFlag = 0;
|
||||
auto firstLight = List.at(0);
|
||||
auto flasherFlag2 = firstLight->ToggledOnFlag;
|
||||
auto firstStatus = firstLight->ToggledOnFlag;
|
||||
for (auto i = 0; i < count - 1; i++)
|
||||
{
|
||||
auto lightCur = List.at(i);
|
||||
auto lightNext = List.at(i + 1);
|
||||
lightCur->Message(lightNext->ToggledOnFlag + 8, 0.0);
|
||||
lightCur->Message2(lightNext->ToggledOnFlag ? MessageCode::TLightTurnOnTimed : MessageCode::TLightTurnOffTimed, 0.0);
|
||||
}
|
||||
auto lastLight = List.at(count - 1);
|
||||
lastLight->Message((flasherFlag2 != 0) + 8, 0);
|
||||
lastLight->Message2(firstStatus ? MessageCode::TLightTurnOnTimed : MessageCode::TLightTurnOffTimed, 0);
|
||||
reschedule_animation(value);
|
||||
break;
|
||||
}
|
||||
case 28:
|
||||
case MessageCode::TLightGroupLightShowAnimation:
|
||||
{
|
||||
if (AnimationFlag || !MessageField2)
|
||||
if (AnimationFlag || MessageField2 == MessageCode::TLightGroupNull)
|
||||
start_animation();
|
||||
MessageField2 = code;
|
||||
AnimationFlag = 0;
|
||||
@ -164,27 +164,27 @@ int TLightGroup::Message(int code, float value)
|
||||
if (rand() % 100 > 70)
|
||||
{
|
||||
auto randVal = RandFloat() * value * 3.0f + 0.1f;
|
||||
light->Message(9, randVal);
|
||||
light->Message2(MessageCode::TLightTurnOnTimed, randVal);
|
||||
}
|
||||
}
|
||||
reschedule_animation(value);
|
||||
break;
|
||||
}
|
||||
case 29:
|
||||
case MessageCode::TLightGroupGameOverAnimation:
|
||||
{
|
||||
if (AnimationFlag || !MessageField2)
|
||||
if (AnimationFlag || MessageField2 == MessageCode::TLightGroupNull)
|
||||
start_animation();
|
||||
MessageField2 = code;
|
||||
AnimationFlag = 0;
|
||||
for (auto light : List)
|
||||
{
|
||||
auto randVal = static_cast<float>(rand() % 100 > 70);
|
||||
light->Message(18, randVal);
|
||||
light->Message2(MessageCode::TLightResetAndToggleValue, randVal);
|
||||
}
|
||||
reschedule_animation(value);
|
||||
break;
|
||||
}
|
||||
case 30:
|
||||
case MessageCode::TLightGroupRandomAnimationSaturation:
|
||||
{
|
||||
auto noBmpInd1Count = 0;
|
||||
for (auto light : List)
|
||||
@ -201,16 +201,16 @@ int TLightGroup::Message(int code, float value)
|
||||
auto light = *it;
|
||||
if (!light->LightOnFlag && randModCount-- == 0)
|
||||
{
|
||||
light->Message(1, 0.0);
|
||||
light->Message2(MessageCode::TLightTurnOn, 0.0);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (MessageField2)
|
||||
if (MessageField2 != MessageCode::TLightGroupNull)
|
||||
start_animation();
|
||||
break;
|
||||
}
|
||||
case 31:
|
||||
case MessageCode::TLightGroupRandomAnimationDesaturation:
|
||||
{
|
||||
auto bmpInd1Count = 0;
|
||||
for (auto light : List)
|
||||
@ -227,71 +227,72 @@ int TLightGroup::Message(int code, float value)
|
||||
auto light = *it;
|
||||
if (light->LightOnFlag && randModCount-- == 0)
|
||||
{
|
||||
light->Message(0, 0.0);
|
||||
light->Message2(MessageCode::TLightTurnOff, 0.0);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (MessageField2)
|
||||
if (MessageField2 != MessageCode::TLightGroupNull)
|
||||
start_animation();
|
||||
break;
|
||||
}
|
||||
case 32:
|
||||
case MessageCode::TLightGroupOffsetAnimationForward:
|
||||
{
|
||||
auto index = next_light_up();
|
||||
if (index < 0)
|
||||
break;
|
||||
List.at(index)->Message(1, 0.0);
|
||||
if (MessageField2)
|
||||
List.at(index)->Message2(MessageCode::TLightTurnOn, 0.0);
|
||||
if (MessageField2 != MessageCode::TLightGroupNull)
|
||||
start_animation();
|
||||
return 1;
|
||||
}
|
||||
case 33:
|
||||
case MessageCode::TLightGroupOffsetAnimationBackward:
|
||||
{
|
||||
auto index = next_light_down();
|
||||
if (index < 0)
|
||||
break;
|
||||
List.at(index)->Message(0, 0.0);
|
||||
if (MessageField2)
|
||||
List.at(index)->Message2(MessageCode::TLightTurnOff, 0.0);
|
||||
if (MessageField2 != MessageCode::TLightGroupNull)
|
||||
start_animation();
|
||||
return 1;
|
||||
}
|
||||
case 34:
|
||||
case MessageCode::TLightGroupReset:
|
||||
{
|
||||
if (Timer)
|
||||
timer::kill(Timer);
|
||||
Timer = 0;
|
||||
if (MessageField2 == 26 || MessageField2 == 27 || MessageField2 == 28)
|
||||
TLightGroup::Message(14, 0.0);
|
||||
MessageField2 = 0;
|
||||
if (MessageField2 == MessageCode::TLightGroupAnimationBackward ||
|
||||
MessageField2 == MessageCode::TLightGroupAnimationForward || MessageField2 == MessageCode::TLightGroupLightShowAnimation)
|
||||
TLightGroup::Message2(MessageCode::TLightResetTimed, 0.0);
|
||||
MessageField2 = MessageCode::TLightGroupNull;
|
||||
AnimationFlag = 0;
|
||||
break;
|
||||
}
|
||||
case 35:
|
||||
case MessageCode::TLightGroupTurnOnAtIndex:
|
||||
{
|
||||
auto index = static_cast<int>(floor(value));
|
||||
if (index >= count || index < 0)
|
||||
break;
|
||||
|
||||
auto light = List.at(index);
|
||||
light->Message(1, 0.0);
|
||||
if (MessageField2)
|
||||
light->Message2(MessageCode::TLightTurnOn, 0.0);
|
||||
if (MessageField2 != MessageCode::TLightGroupNull)
|
||||
start_animation();
|
||||
break;
|
||||
}
|
||||
case 36:
|
||||
case MessageCode::TLightGroupTurnOffAtIndex:
|
||||
{
|
||||
auto index = static_cast<int>(floor(value));
|
||||
if (index >= count || index < 0)
|
||||
break;
|
||||
|
||||
auto light = List.at(index);
|
||||
light->Message(0, 0.0);
|
||||
if (MessageField2)
|
||||
light->Message2(MessageCode::TLightTurnOff, 0.0);
|
||||
if (MessageField2 != MessageCode::TLightGroupNull)
|
||||
start_animation();
|
||||
break;
|
||||
}
|
||||
case 37:
|
||||
case MessageCode::TLightGroupGetOnCount:
|
||||
{
|
||||
auto bmp1Count = 0;
|
||||
for (auto light : List)
|
||||
@ -301,86 +302,86 @@ int TLightGroup::Message(int code, float value)
|
||||
}
|
||||
return bmp1Count;
|
||||
}
|
||||
case 38:
|
||||
case MessageCode::TLightGroupGetLightCount:
|
||||
return count;
|
||||
case 39:
|
||||
return MessageField2;
|
||||
case 40:
|
||||
case MessageCode::TLightGroupGetMessage2:
|
||||
return ~MessageField2;
|
||||
case MessageCode::TLightGroupGetAnimationFlag:
|
||||
return AnimationFlag;
|
||||
case 41:
|
||||
case MessageCode::TLightGroupResetAndTurnOn:
|
||||
{
|
||||
auto index = next_light_up();
|
||||
if (index < 0)
|
||||
break;
|
||||
if (MessageField2 || AnimationFlag)
|
||||
TLightGroup::Message(34, 0.0);
|
||||
List.at(index)->Message(15, value);
|
||||
if (MessageField2 != MessageCode::TLightGroupNull || AnimationFlag)
|
||||
TLightGroup::Message2(MessageCode::TLightGroupReset, 0.0);
|
||||
List.at(index)->Message2(MessageCode::TLightFlasherStartTimedThenStayOn, value);
|
||||
return 1;
|
||||
}
|
||||
case 42:
|
||||
case MessageCode::TLightGroupResetAndTurnOff:
|
||||
{
|
||||
auto index = next_light_down();
|
||||
if (index < 0)
|
||||
break;
|
||||
if (MessageField2 || AnimationFlag)
|
||||
TLightGroup::Message(34, 0.0);
|
||||
List.at(index)->Message(16, value);
|
||||
if (MessageField2 != MessageCode::TLightGroupNull || AnimationFlag)
|
||||
TLightGroup::Message2(MessageCode::TLightGroupReset, 0.0);
|
||||
List.at(index)->Message2(MessageCode::TLightFlasherStartTimedThenStayOff, value);
|
||||
return 1;
|
||||
}
|
||||
case 43:
|
||||
case MessageCode::TLightGroupRestartNotifyTimer:
|
||||
if (NotifyTimer)
|
||||
timer::kill(NotifyTimer);
|
||||
NotifyTimer = 0;
|
||||
if (value > 0.0f)
|
||||
NotifyTimer = timer::set(value, this, NotifyTimerExpired);
|
||||
break;
|
||||
case 44:
|
||||
case MessageCode::TLightGroupFlashWhenOn:
|
||||
{
|
||||
for (auto it = List.rbegin(); it != List.rend(); ++it)
|
||||
{
|
||||
auto light = *it;
|
||||
if (light->LightOnFlag)
|
||||
{
|
||||
light->Message(0, 0.0);
|
||||
light->Message(16, value);
|
||||
light->Message2(MessageCode::TLightTurnOff, 0.0);
|
||||
light->Message2(MessageCode::TLightFlasherStartTimedThenStayOff, value);
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
case 45:
|
||||
case MessageCode::TLightGroupToggleSplitIndex:
|
||||
{
|
||||
control::handler(code, this);
|
||||
control::handler(~code, this);
|
||||
auto index = static_cast<int>(floor(value));
|
||||
if (index >= 0 && index < count)
|
||||
{
|
||||
// Turn off lights (index, end]
|
||||
for (auto i = count - 1; i > index; i--)
|
||||
{
|
||||
List.at(i)->Message(20, 0.0);
|
||||
List.at(i)->Message2(MessageCode::TLightResetAndTurnOff, 0.0);
|
||||
}
|
||||
|
||||
// Turn on lights [begin, index]
|
||||
for (auto i = index; i >= 0; i--)
|
||||
{
|
||||
List.at(i)->Message(19, 0.0);
|
||||
List.at(i)->Message2(MessageCode::TLightResetAndTurnOn, 0.0);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 46:
|
||||
case MessageCode::TLightGroupStartFlasher:
|
||||
{
|
||||
auto index = next_light_down();
|
||||
if (index >= 0)
|
||||
{
|
||||
List.at(index)->Message(4, 0.0);
|
||||
List.at(index)->Message2(MessageCode::TLightFlasherStart, 0.0);
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
for (auto it = List.rbegin(); it != List.rend(); ++it)
|
||||
{
|
||||
(*it)->Message(code, value);
|
||||
(*it)->Message2(code, value);
|
||||
}
|
||||
break;
|
||||
}
|
||||
@ -395,7 +396,7 @@ void TLightGroup::Reset()
|
||||
if (NotifyTimer)
|
||||
timer::kill(NotifyTimer);
|
||||
NotifyTimer = 0;
|
||||
MessageField2 = 0;
|
||||
MessageField2 = MessageCode::TLightGroupNull;
|
||||
AnimationFlag = 0;
|
||||
Timer1Time = Timer1TimeDefault;
|
||||
}
|
||||
@ -407,7 +408,7 @@ void TLightGroup::reschedule_animation(float time)
|
||||
Timer = 0;
|
||||
if (time == 0)
|
||||
{
|
||||
MessageField2 = 0;
|
||||
MessageField2 = MessageCode::TLightGroupNull;
|
||||
AnimationFlag = 0;
|
||||
return;
|
||||
}
|
||||
@ -422,9 +423,9 @@ void TLightGroup::start_animation()
|
||||
{
|
||||
auto light = *it;
|
||||
if (light->LightOnFlag)
|
||||
light->Message(9, 0.0);
|
||||
light->Message2(MessageCode::TLightTurnOnTimed, 0.0);
|
||||
else
|
||||
light->Message(8, 0.0);
|
||||
light->Message2(MessageCode::TLightTurnOffTimed, 0.0);
|
||||
}
|
||||
}
|
||||
|
||||
@ -452,7 +453,7 @@ void TLightGroup::TimerExpired(int timerId, void* caller)
|
||||
{
|
||||
auto group = static_cast<TLightGroup*>(caller);
|
||||
group->Timer = 0;
|
||||
group->Message(group->MessageField2, group->Timer1Time);
|
||||
group->Message2(group->MessageField2, group->Timer1Time);
|
||||
}
|
||||
|
||||
void TLightGroup::NotifyTimerExpired(int timerId, void* caller)
|
||||
|
@ -7,19 +7,19 @@ class TLight;
|
||||
struct TLightGroup_player_backup
|
||||
{
|
||||
int MessageField;
|
||||
int MessageField2;
|
||||
MessageCode MessageField2;
|
||||
float Timer1Time;
|
||||
int Unknown3;
|
||||
};
|
||||
|
||||
|
||||
class TLightGroup :
|
||||
public TPinballComponent
|
||||
public TPinballComponent2
|
||||
{
|
||||
public:
|
||||
TLightGroup(TPinballTable* table, int groupIndex);
|
||||
~TLightGroup() override = default;
|
||||
int Message(int code, float value) override;
|
||||
int Message2(MessageCode code, float value) override;
|
||||
virtual void Reset();
|
||||
void reschedule_animation(float time);
|
||||
void start_animation();
|
||||
@ -32,7 +32,7 @@ public:
|
||||
std::vector<TLight*> List;
|
||||
float Timer1Time{};
|
||||
float Timer1TimeDefault;
|
||||
int MessageField2{};
|
||||
MessageCode MessageField2{};
|
||||
int AnimationFlag{};
|
||||
int NotifyTimer;
|
||||
int Timer;
|
||||
|
@ -41,12 +41,13 @@ enum class MessageCode
|
||||
TLightFtTmpOverrideOff = -25,
|
||||
TLightFtResetOverride = -26,
|
||||
|
||||
TLightGroupNull = 0,
|
||||
TLightGroupStepBackward = 24,
|
||||
TLightGroupStepForward = 25,
|
||||
TLightGroupAnimationBackward = 26,
|
||||
TLightGroupAnimationForward = 27,
|
||||
TLightGroupRandomAnimation1 = 28,
|
||||
TLightGroupRandomAnimation2 = 29,
|
||||
TLightGroupLightShowAnimation = 28,
|
||||
TLightGroupGameOverAnimation = 29,
|
||||
TLightGroupRandomAnimationSaturation = 30,
|
||||
TLightGroupRandomAnimationDesaturation = 31,
|
||||
TLightGroupOffsetAnimationForward = 32,
|
||||
|
@ -299,7 +299,7 @@ void TPinballTable::tilt(float time)
|
||||
{
|
||||
component->Message2(MessageCode::SetTiltLock, time);
|
||||
}
|
||||
LightGroup->Message(8, 0);
|
||||
LightGroup->Message2(MessageCode::TLightTurnOffTimed, 0);
|
||||
TiltLockFlag = 1;
|
||||
control::table_control_handler(1011);
|
||||
}
|
||||
@ -357,7 +357,7 @@ int TPinballTable::Message2(MessageCode code, float value)
|
||||
}
|
||||
break;
|
||||
case MessageCode::ClearTiltLock:
|
||||
LightGroup->Message(14, 0.0);
|
||||
LightGroup->Message2(MessageCode::TLightResetTimed, 0.0);
|
||||
if (TiltLockFlag)
|
||||
{
|
||||
TiltLockFlag = 0;
|
||||
@ -367,8 +367,8 @@ int TPinballTable::Message2(MessageCode code, float value)
|
||||
}
|
||||
break;
|
||||
case MessageCode::StartGamePlayer1:
|
||||
LightGroup->Message(34, 0.0);
|
||||
LightGroup->Message(20, 0.0);
|
||||
LightGroup->Message2(MessageCode::TLightGroupReset, 0.0);
|
||||
LightGroup->Message2(MessageCode::TLightResetAndTurnOff, 0.0);
|
||||
Plunger->Message2(MessageCode::PlungerStartFeedTimer, 0.0);
|
||||
if (Demo && Demo->ActiveFlag)
|
||||
rc_text = pb::get_rc_string(Msg::STRING131);
|
||||
@ -446,7 +446,7 @@ int TPinballTable::Message2(MessageCode code, float value)
|
||||
UnknownP71 = 0;
|
||||
pb::InfoTextBox->Clear();
|
||||
pb::MissTextBox->Clear();
|
||||
LightGroup->Message(28, 0.2f);
|
||||
LightGroup->Message2(MessageCode::TLightGroupLightShowAnimation, 0.2f);
|
||||
auto time = loader::play_sound(SoundIndex1, nullptr, "TPinballTable2");
|
||||
if (time < 0)
|
||||
time = 5.0f;
|
||||
@ -565,7 +565,7 @@ int TPinballTable::Message2(MessageCode code, float value)
|
||||
if (LightShowTimer)
|
||||
{
|
||||
timer::kill(LightShowTimer);
|
||||
LightGroup->Message(34, 0.0);
|
||||
LightGroup->Message2(MessageCode::TLightGroupReset, 0.0);
|
||||
}
|
||||
LightShowTimer = 0;
|
||||
ScoreMultiplier = 0;
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,5 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
class TSink;
|
||||
class TLight;
|
||||
class TSound;
|
||||
class TPinballTable;
|
||||
@ -69,7 +70,8 @@ public:
|
||||
static bool table_unlimited_balls;
|
||||
static Msg RankRcArray[9], MissionRcArray[17];
|
||||
static int mission_select_scores[17];
|
||||
static component_tag_base *wormhole_tag_array1[3], *wormhole_tag_array2[3], *wormhole_tag_array3[3];
|
||||
static std::reference_wrapper<TSink*> wormhole_tag_array1[3];
|
||||
static std::reference_wrapper<TLight*> wormhole_tag_array2[3], wormhole_tag_array3[3];
|
||||
|
||||
static void make_links(TPinballTable* table);
|
||||
static void ClearLinks();
|
||||
|
@ -215,7 +215,7 @@ void pb::mode_change(GameModes mode)
|
||||
winmain::DemoActive = false;
|
||||
}
|
||||
if (MainTable && MainTable->LightGroup)
|
||||
MainTable->LightGroup->Message(29, 1.4f);
|
||||
MainTable->LightGroup->Message2(MessageCode::TLightGroupGameOverAnimation, 1.4f);
|
||||
break;
|
||||
}
|
||||
game_mode = mode;
|
||||
@ -504,10 +504,10 @@ void pb::InputDown(GameInput input)
|
||||
MainTable->port_draw();
|
||||
break;
|
||||
case 'i':
|
||||
MainTable->LightGroup->Message(-24, 1.0f);
|
||||
MainTable->LightGroup->Message2(MessageCode::TLightFtTmpOverrideOn, 1.0f);
|
||||
break;
|
||||
case 'j':
|
||||
MainTable->LightGroup->Message(-25, 1.0f);
|
||||
MainTable->LightGroup->Message2(MessageCode::TLightFtTmpOverrideOff, 1.0f);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user