mirror of
https://github.com/k4zmu2a/SpaceCadetPinball.git
synced 2024-11-14 19:25:18 -05:00
Message code enum part 1: global messages and some hacks.
This commit is contained in:
parent
69fd91f003
commit
44d5fd5097
21 changed files with 276 additions and 145 deletions
|
@ -27,9 +27,9 @@ int TBlocker::Message(int code, float value)
|
|||
{
|
||||
switch (code)
|
||||
{
|
||||
case 1011:
|
||||
case 1020:
|
||||
case 1024:
|
||||
case ~MessageCode::SetTiltLock:
|
||||
case ~MessageCode::PlayerChanged:
|
||||
case ~MessageCode::Reset:
|
||||
case 51:
|
||||
if (Timer)
|
||||
{
|
||||
|
|
|
@ -62,7 +62,7 @@ int TBumper::Message(int code, float value)
|
|||
TBumper::Message(11, static_cast<float>(nextBmp));
|
||||
break;
|
||||
}
|
||||
case 1020:
|
||||
case ~MessageCode::PlayerChanged:
|
||||
{
|
||||
auto playerPtr = &PlayerData[PinballTable->CurrentPlayer];
|
||||
playerPtr->BmpIndex = BmpIndex;
|
||||
|
@ -74,7 +74,7 @@ int TBumper::Message(int code, float value)
|
|||
TBumper::Message(11, static_cast<float>(BmpIndex));
|
||||
break;
|
||||
}
|
||||
case 1024:
|
||||
case ~MessageCode::Reset:
|
||||
{
|
||||
if (Timer)
|
||||
{
|
||||
|
|
|
@ -24,3 +24,18 @@ public:
|
|||
virtual int FieldEffect(TBall* ball, vector2* vecDst);
|
||||
bool DefaultCollision(TBall* ball, vector2* nextPosition, vector2* direction);
|
||||
};
|
||||
|
||||
|
||||
class TCollisionComponent2 : public TCollisionComponent
|
||||
{
|
||||
public:
|
||||
TCollisionComponent2(TPinballTable* table, int group_index, bool create_wall)
|
||||
: TCollisionComponent(table, group_index, create_wall)
|
||||
{
|
||||
}
|
||||
|
||||
DEPRECATED int Message(int code, float value) override
|
||||
{
|
||||
return Message2(static_cast<MessageCode>(code), value);
|
||||
}
|
||||
};
|
||||
|
|
|
@ -60,19 +60,19 @@ int TDemo::Message(int code, float value)
|
|||
{
|
||||
switch (code)
|
||||
{
|
||||
case 1014:
|
||||
case ~MessageCode::NewGame:
|
||||
if (RestartGameTimer)
|
||||
timer::kill(RestartGameTimer);
|
||||
RestartGameTimer = 0;
|
||||
break;
|
||||
case 1022:
|
||||
case ~MessageCode::GameOver:
|
||||
if (RestartGameTimer)
|
||||
timer::kill(RestartGameTimer);
|
||||
RestartGameTimer = 0;
|
||||
if (ActiveFlag != 0)
|
||||
RestartGameTimer = timer::set(5.0, this, NewGameRestartTimer);
|
||||
break;
|
||||
case 1024:
|
||||
case ~MessageCode::Reset:
|
||||
if (FlipLeftTimer)
|
||||
timer::kill(FlipLeftTimer);
|
||||
FlipLeftTimer = 0;
|
||||
|
@ -125,7 +125,7 @@ void TDemo::Collision(TBall* ball, vector2* nextPosition, vector2* direction, fl
|
|||
case 1404:
|
||||
if (!PlungerFlag)
|
||||
{
|
||||
PinballTable->Message(1004, ball->TimeNow);
|
||||
PinballTable->Message2(MessageCode::PlungerInputPressed, ball->TimeNow);
|
||||
float time = RandFloat() + 2.0f;
|
||||
PlungerFlag = timer::set(time, this, PlungerRelease);
|
||||
}
|
||||
|
@ -139,14 +139,14 @@ void TDemo::PlungerRelease(int timerId, void* caller)
|
|||
{
|
||||
auto demo = static_cast<TDemo*>(caller);
|
||||
demo->PlungerFlag = 0;
|
||||
demo->PinballTable->Message(1005, pb::time_next);
|
||||
demo->PinballTable->Message2(MessageCode::PlungerInputReleased, pb::time_next);
|
||||
}
|
||||
|
||||
void TDemo::UnFlipRight(int timerId, void* caller)
|
||||
{
|
||||
auto demo = static_cast<TDemo*>(caller);
|
||||
if (demo->FlipRightFlag)
|
||||
demo->PinballTable->Message(1003, pb::time_next);
|
||||
demo->PinballTable->Message2(MessageCode::RightFlipperInputReleased, pb::time_next);
|
||||
demo->FlipRightFlag = 0;
|
||||
}
|
||||
|
||||
|
@ -154,7 +154,7 @@ void TDemo::UnFlipLeft(int timerId, void* caller)
|
|||
{
|
||||
auto demo = static_cast<TDemo*>(caller);
|
||||
if (demo->FlipLeftFlag)
|
||||
demo->PinballTable->Message(1001, pb::time_next);
|
||||
demo->PinballTable->Message2(MessageCode::LeftFlipperInputReleased, pb::time_next);
|
||||
demo->FlipLeftFlag = 0;
|
||||
}
|
||||
|
||||
|
@ -168,7 +168,7 @@ void TDemo::FlipRight(int timerId, void* caller)
|
|||
timer::kill(demo->FlipRightTimer);
|
||||
demo->FlipRightTimer = 0;
|
||||
}
|
||||
demo->PinballTable->Message(1002, pb::time_next);
|
||||
demo->PinballTable->Message2(MessageCode::RightFlipperInputPressed, pb::time_next);
|
||||
demo->FlipRightFlag = 1;
|
||||
float time = demo->UnFlipTimerTime1 + demo->UnFlipTimerTime2 - RandFloat() *
|
||||
(demo->UnFlipTimerTime2 + demo->UnFlipTimerTime2);
|
||||
|
@ -186,7 +186,7 @@ void TDemo::FlipLeft(int timerId, void* caller)
|
|||
timer::kill(demo->FlipLeftTimer);
|
||||
demo->FlipLeftTimer = 0;
|
||||
}
|
||||
demo->PinballTable->Message(1000, pb::time_next);
|
||||
demo->PinballTable->Message2(MessageCode::LeftFlipperInputPressed, pb::time_next);
|
||||
demo->FlipLeftFlag = 1;
|
||||
float time = demo->UnFlipTimerTime1 + demo->UnFlipTimerTime2 - RandFloat() *
|
||||
(demo->UnFlipTimerTime2 + demo->UnFlipTimerTime2);
|
||||
|
@ -198,6 +198,6 @@ void TDemo::NewGameRestartTimer(int timerId, void* caller)
|
|||
{
|
||||
auto demo = static_cast<TDemo*>(caller);
|
||||
pb::replay_level(true);
|
||||
demo->PinballTable->Message(1014, static_cast<float>(demo->PinballTable->PlayerCount));
|
||||
demo->PinballTable->Message2(MessageCode::NewGame, static_cast<float>(demo->PinballTable->PlayerCount));
|
||||
demo->RestartGameTimer = 0;
|
||||
}
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
#include "timer.h"
|
||||
#include "TPinballTable.h"
|
||||
|
||||
TFlipper::TFlipper(TPinballTable* table, int groupIndex) : TCollisionComponent(table, groupIndex, false)
|
||||
TFlipper::TFlipper(TPinballTable* table, int groupIndex) : TCollisionComponent2(table, groupIndex, false)
|
||||
{
|
||||
visualStruct visual{};
|
||||
|
||||
|
@ -58,38 +58,45 @@ TFlipper::~TFlipper()
|
|||
}
|
||||
}
|
||||
|
||||
int TFlipper::Message(int code, float value)
|
||||
int TFlipper::Message2(MessageCode code, float value)
|
||||
{
|
||||
if (code == 1 || code == 2 || (code > 1008 && code <= 1011) || code == 1022)
|
||||
switch (code)
|
||||
{
|
||||
if (code == 1)
|
||||
case MessageCode::TFlipperExtend:
|
||||
case MessageCode::TFlipperRetract:
|
||||
case MessageCode::Resume:
|
||||
case MessageCode::LooseFocus:
|
||||
case MessageCode::SetTiltLock:
|
||||
case MessageCode::GameOver:
|
||||
if (code == MessageCode::TFlipperExtend)
|
||||
{
|
||||
control::handler(1, this);
|
||||
loader::play_sound(HardHitSoundId, this, "TFlipper1");
|
||||
}
|
||||
else if (code == 2)
|
||||
else if (code == MessageCode::TFlipperRetract)
|
||||
{
|
||||
loader::play_sound(SoftHitSoundId, this, "TFlipper2");
|
||||
}
|
||||
else
|
||||
{
|
||||
// Retract for all non-input messages
|
||||
code = 2;
|
||||
code = MessageCode::TFlipperRetract;
|
||||
}
|
||||
|
||||
MessageField = FlipperEdge->SetMotion(code, value);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (code == 1020 || code == 1024)
|
||||
{
|
||||
MessageField = FlipperEdge->SetMotion(~code, value);
|
||||
break;
|
||||
case MessageCode::PlayerChanged:
|
||||
case MessageCode::Reset:
|
||||
if (MessageField)
|
||||
{
|
||||
MessageField = 0;
|
||||
FlipperEdge->SetMotion(1024, value);
|
||||
UpdateSprite(0);
|
||||
}
|
||||
break;
|
||||
default: break;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -4,12 +4,12 @@
|
|||
class TFlipperEdge;
|
||||
|
||||
class TFlipper :
|
||||
public TCollisionComponent
|
||||
public TCollisionComponent2
|
||||
{
|
||||
public:
|
||||
TFlipper(TPinballTable* table, int groupIndex);
|
||||
~TFlipper() override;
|
||||
int Message(int code, float value) override;
|
||||
int Message2(MessageCode code, float value) override;
|
||||
void port_draw() override;
|
||||
void Collision(TBall* ball, vector2* nextPosition, vector2* direction, float distance,
|
||||
TEdgeSegment* edge) override;
|
||||
|
|
|
@ -470,7 +470,7 @@ int TFlipperEdge::SetMotion(int code, float value)
|
|||
AngleDst = 0.0f;
|
||||
AngleAdvanceTime = RetractTime;
|
||||
break;
|
||||
case 1024:
|
||||
case ~MessageCode::Reset:
|
||||
AngleSrc = 0.0f;
|
||||
AngleDst = 0.0f;
|
||||
break;
|
||||
|
|
|
@ -72,11 +72,11 @@ int TKickout::Message(int code, float value)
|
|||
Timer = timer::set(value, this, TimerExpired);
|
||||
}
|
||||
break;
|
||||
case 1011:
|
||||
case ~MessageCode::SetTiltLock:
|
||||
if (NotSomeFlag)
|
||||
ActiveFlag = 0;
|
||||
break;
|
||||
case 1024:
|
||||
case ~MessageCode::Reset:
|
||||
if (KickFlag1)
|
||||
{
|
||||
if (Timer)
|
||||
|
|
|
@ -29,7 +29,7 @@ int TLight::Message(int code, float value)
|
|||
|
||||
switch (code)
|
||||
{
|
||||
case 1024:
|
||||
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 1020:
|
||||
case ~MessageCode::PlayerChanged:
|
||||
{
|
||||
auto playerPtr = &PlayerData[PinballTable->CurrentPlayer];
|
||||
playerPtr->FlasherOnFlag = FlasherOnFlag;
|
||||
|
|
|
@ -65,10 +65,10 @@ int TLightBargraph::Message(int code, float value)
|
|||
}
|
||||
break;
|
||||
}
|
||||
case 1011:
|
||||
case ~MessageCode::SetTiltLock:
|
||||
Reset();
|
||||
break;
|
||||
case 1020:
|
||||
case ~MessageCode::PlayerChanged:
|
||||
if (TimerBargraph)
|
||||
{
|
||||
timer::kill(TimerBargraph);
|
||||
|
@ -82,7 +82,7 @@ int TLightBargraph::Message(int code, float value)
|
|||
TLightBargraph::Message(45, static_cast<float>(TimeIndex));
|
||||
}
|
||||
break;
|
||||
case 1024:
|
||||
case ~MessageCode::Reset:
|
||||
{
|
||||
Reset();
|
||||
int* playerPtr = PlayerTimerIndexBackup;
|
||||
|
@ -92,7 +92,7 @@ int TLightBargraph::Message(int code, float value)
|
|||
|
||||
++playerPtr;
|
||||
}
|
||||
TLightGroup::Message(1024, value);
|
||||
TLightGroup::Message(~MessageCode::Reset, value);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
|
|
|
@ -33,10 +33,10 @@ int TLightGroup::Message(int code, float value)
|
|||
auto const count = static_cast<int>(List.size());
|
||||
switch (code)
|
||||
{
|
||||
case 1011:
|
||||
case 1022:
|
||||
case ~MessageCode::SetTiltLock:
|
||||
case ~MessageCode::GameOver:
|
||||
break;
|
||||
case 1020:
|
||||
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 1024:
|
||||
case ~MessageCode::Reset:
|
||||
Reset();
|
||||
for (auto index = 0; index < PinballTable->PlayerCount; index++)
|
||||
{
|
||||
|
|
|
@ -7,20 +7,113 @@ struct component_control;
|
|||
struct vector2;
|
||||
class TPinballTable;
|
||||
|
||||
enum class message_code
|
||||
|
||||
enum class MessageCode
|
||||
{
|
||||
// Private codes <1000, different meaning for each component
|
||||
TFlipperExtend = 1,
|
||||
TFlipperRetract = 2,
|
||||
|
||||
TLightTurnOff = 0,
|
||||
TLightTurnOn = 1,
|
||||
TLightGetLightOnFlag = 2,
|
||||
TLightGetFlasherOnFlag = 3,
|
||||
TLightFlasherStart = 4,
|
||||
TLightApplyMultDelay = 5,
|
||||
TLightApplyDelay = 6,
|
||||
TLightFlasherStartTimed = 7,
|
||||
TLightTurnOffTimed = 8,
|
||||
TLightTurnOnTimed = 9,
|
||||
TLightSetOnStateBmpIndex = 11,
|
||||
TLightIncOnStateBmpIndex = 12,
|
||||
TLightDecOnStateBmpIndex = 13,
|
||||
TLightResetTimed = 14,
|
||||
TLightFlasherStartTimedThenStayOn = 15,
|
||||
TLightFlasherStartTimedThenStayOff = 16,
|
||||
TLightToggleValue = 17,
|
||||
TLightResetAndToggleValue = 18,
|
||||
TLightResetAndTurnOn = 19,
|
||||
TLightResetAndTurnOff = 20,
|
||||
TLightToggle = 21,
|
||||
TLightResetAndToggle = 22,
|
||||
TLightSetMessageField = 23,
|
||||
TLightFtTmpOverrideOn = -24,
|
||||
TLightFtTmpOverrideOff = -25,
|
||||
TLightFtResetOverride = -26,
|
||||
|
||||
TLightGroupStepBackward = 24,
|
||||
TLightGroupStepForward = 25,
|
||||
TLightGroupAnimationBackward = 26,
|
||||
TLightGroupAnimationForward = 27,
|
||||
TLightGroupRandomAnimation1 = 28,
|
||||
TLightGroupRandomAnimation2 = 29,
|
||||
TLightGroupRandomAnimationSaturation = 30,
|
||||
TLightGroupRandomAnimationDesaturation = 31,
|
||||
TLightGroupOffsetAnimationForward = 32,
|
||||
TLightGroupOffsetAnimationBackward = 33,
|
||||
TLightGroupReset = 34,
|
||||
TLightGroupTurnOnAtIndex = 35,
|
||||
TLightGroupTurnOffAtIndex = 36,
|
||||
TLightGroupGetOnCount = 37,
|
||||
TLightGroupGetLightCount = 38,
|
||||
TLightGroupGetMessage2 = 39,
|
||||
TLightGroupGetAnimationFlag = 40,
|
||||
TLightGroupResetAndTurnOn = 41,
|
||||
TLightGroupResetAndTurnOff = 42,
|
||||
TLightGroupRestartNotifyTimer = 43,
|
||||
TLightGroupFlashWhenOn = 44,
|
||||
TLightGroupToggleSplitIndex = 45,
|
||||
TLightGroupStartFlasher = 46,
|
||||
|
||||
// Public codes 1000+, apply to all components
|
||||
LeftFlipperInputPressed = 1000,
|
||||
LeftFlipperInputReleased = 1001,
|
||||
RightFlipperInputPressed = 1002,
|
||||
RightFlipperInputReleased = 1003,
|
||||
PlungerInputPressed = 1004,
|
||||
PlungerInputReleased = 1005,
|
||||
Pause = 1008,
|
||||
Resume = 1009,
|
||||
LooseFocus = 1010,
|
||||
SetTiltLock = 1011,
|
||||
ResetTiltLock = 1012,
|
||||
StartGamePlayer1 = 1013,
|
||||
NewGame = 1014,
|
||||
PlungerFeedBall = 1015,
|
||||
PlungerStartFeedTimer = 1016,
|
||||
PlungerLaunchBall = 1017,
|
||||
PlungerRelaunchBall = 1018,
|
||||
PlayerChanged = 1020,
|
||||
SwitchToNextPlayer = 1021,
|
||||
GameOver = 1022,
|
||||
Reset = 1024,
|
||||
LightActiveCount = 37,
|
||||
LightTotalCount = 38,
|
||||
LightSetMessageField = 23,
|
||||
};
|
||||
|
||||
// Temporary hacks for int -> enum class migration.
|
||||
template <typename T, typename X = typename std::underlying_type<T>::type>
|
||||
constexpr typename std::enable_if<std::is_enum<T>::value, X>::type operator~(T value)
|
||||
{
|
||||
return static_cast<X>(value);
|
||||
}
|
||||
#if defined(__GNUC__) || defined(__clang__)
|
||||
#define DEPRECATED __attribute__((deprecated))
|
||||
#elif defined(_MSC_VER)
|
||||
#define DEPRECATED __declspec(deprecated)
|
||||
#else
|
||||
#define DEPRECATED
|
||||
#endif
|
||||
|
||||
|
||||
class TPinballComponent
|
||||
{
|
||||
public:
|
||||
TPinballComponent(TPinballTable* table, int groupIndex, bool loadVisuals);
|
||||
virtual ~TPinballComponent();
|
||||
virtual int Message(int code, float value);
|
||||
virtual int Message2(MessageCode code, float value)
|
||||
{
|
||||
return Message(~code, value);
|
||||
}
|
||||
virtual void port_draw();
|
||||
int get_scoring(unsigned int index) const;
|
||||
virtual vector2 get_coordinates();
|
||||
|
@ -39,3 +132,18 @@ private:
|
|||
float VisualPosNormX;
|
||||
float VisualPosNormY;
|
||||
};
|
||||
|
||||
|
||||
class TPinballComponent2 : public TPinballComponent
|
||||
{
|
||||
public:
|
||||
TPinballComponent2(TPinballTable* table, int group_index, bool load_visuals)
|
||||
: TPinballComponent(table, group_index, load_visuals)
|
||||
{
|
||||
}
|
||||
|
||||
DEPRECATED int Message(int code, float value) override
|
||||
{
|
||||
return Message2(static_cast<MessageCode>(code), value);
|
||||
}
|
||||
};
|
||||
|
|
|
@ -42,7 +42,7 @@
|
|||
int TPinballTable::score_multipliers[5] = {1, 2, 3, 5, 10};
|
||||
|
||||
|
||||
TPinballTable::TPinballTable(): TPinballComponent(nullptr, -1, false)
|
||||
TPinballTable::TPinballTable(): TPinballComponent2(nullptr, -1, false)
|
||||
{
|
||||
int shortArrLength;
|
||||
|
||||
|
@ -297,7 +297,7 @@ void TPinballTable::tilt(float time)
|
|||
|
||||
for (auto component : ComponentList)
|
||||
{
|
||||
component->Message(1011, time);
|
||||
component->Message2(MessageCode::SetTiltLock, time);
|
||||
}
|
||||
LightGroup->Message(8, 0);
|
||||
TiltLockFlag = 1;
|
||||
|
@ -314,48 +314,49 @@ void TPinballTable::port_draw()
|
|||
}
|
||||
}
|
||||
|
||||
int TPinballTable::Message(int code, float value)
|
||||
int TPinballTable::Message2(MessageCode code, float value)
|
||||
{
|
||||
const char* rc_text;
|
||||
|
||||
switch (code)
|
||||
{
|
||||
case 1000:
|
||||
case MessageCode::LeftFlipperInputPressed:
|
||||
if (!TiltLockFlag)
|
||||
{
|
||||
FlipperL->Message(1, value);
|
||||
FlipperL->Message2(MessageCode::TFlipperExtend, value);
|
||||
}
|
||||
break;
|
||||
case 1001:
|
||||
case MessageCode::LeftFlipperInputReleased:
|
||||
if (!TiltLockFlag)
|
||||
{
|
||||
FlipperL->Message(2, value);
|
||||
FlipperL->Message2(MessageCode::TFlipperRetract, value);
|
||||
}
|
||||
break;
|
||||
case 1002:
|
||||
case MessageCode::RightFlipperInputPressed:
|
||||
if (!TiltLockFlag)
|
||||
{
|
||||
FlipperR->Message(1, value);
|
||||
FlipperR->Message2(MessageCode::TFlipperExtend, value);
|
||||
}
|
||||
break;
|
||||
case 1003:
|
||||
case MessageCode::RightFlipperInputReleased:
|
||||
if (!TiltLockFlag)
|
||||
{
|
||||
FlipperR->Message(2, value);
|
||||
FlipperR->Message2(MessageCode::TFlipperRetract, value);
|
||||
}
|
||||
break;
|
||||
case 1004:
|
||||
case 1005:
|
||||
Plunger->Message(code, value);
|
||||
case MessageCode::PlungerInputPressed:
|
||||
case MessageCode::PlungerInputReleased:
|
||||
Plunger->Message2(code, value);
|
||||
break;
|
||||
case 1008:
|
||||
case 1009:
|
||||
case 1010:
|
||||
case MessageCode::Pause:
|
||||
case MessageCode::Resume:
|
||||
case MessageCode::LooseFocus:
|
||||
for (auto component : ComponentList)
|
||||
{
|
||||
component->Message(code, value);
|
||||
component->Message2(code, value);
|
||||
}
|
||||
break;
|
||||
case 1012:
|
||||
case MessageCode::ResetTiltLock:
|
||||
LightGroup->Message(14, 0.0);
|
||||
if (TiltLockFlag)
|
||||
{
|
||||
|
@ -365,19 +366,19 @@ int TPinballTable::Message(int code, float value)
|
|||
TiltTimeoutTimer = 0;
|
||||
}
|
||||
break;
|
||||
case 1013:
|
||||
case MessageCode::StartGamePlayer1:
|
||||
LightGroup->Message(34, 0.0);
|
||||
LightGroup->Message(20, 0.0);
|
||||
Plunger->Message(1016, 0.0);
|
||||
Plunger->Message2(MessageCode::PlungerStartFeedTimer, 0.0);
|
||||
if (Demo && Demo->ActiveFlag)
|
||||
rc_text = pb::get_rc_string(Msg::STRING131);
|
||||
else
|
||||
rc_text = pb::get_rc_string(Msg::STRING127);
|
||||
pb::InfoTextBox->Display(rc_text, -1.0);
|
||||
if (Demo)
|
||||
Demo->Message(1014, 0.0);
|
||||
Demo->Message2(MessageCode::NewGame, 0.0);
|
||||
break;
|
||||
case 1014:
|
||||
case MessageCode::NewGame:
|
||||
if (EndGameTimeoutTimer)
|
||||
{
|
||||
timer::kill(EndGameTimeoutTimer);
|
||||
|
@ -388,12 +389,12 @@ int TPinballTable::Message(int code, float value)
|
|||
{
|
||||
timer::kill(LightShowTimer);
|
||||
LightShowTimer = 0;
|
||||
Message(1013, 0.0);
|
||||
Message2(MessageCode::StartGamePlayer1, 0.0);
|
||||
}
|
||||
else
|
||||
{
|
||||
CheatsUsed = 0;
|
||||
Message(1024, 0.0);
|
||||
Message2(MessageCode::Reset, 0.0);
|
||||
auto ball = BallList[0];
|
||||
ball->Position.Y = 0.0;
|
||||
ball->Position.X = 0.0;
|
||||
|
@ -457,13 +458,13 @@ int TPinballTable::Message(int code, float value)
|
|||
MultiballFlag = true;
|
||||
midi::play_track(MidiTracks::Track1, true);
|
||||
break;
|
||||
case 1018:
|
||||
case MessageCode::PlungerRelaunchBall:
|
||||
if (ReplayTimer)
|
||||
timer::kill(ReplayTimer);
|
||||
ReplayTimer = timer::set(floor(value), this, replay_timer_callback);
|
||||
ReplayActiveFlag = 1;
|
||||
break;
|
||||
case 1021:
|
||||
case MessageCode::SwitchToNextPlayer:
|
||||
{
|
||||
if (PlayerCount <= 1)
|
||||
{
|
||||
|
@ -505,7 +506,7 @@ int TPinballTable::Message(int code, float value)
|
|||
|
||||
for (auto component : ComponentList)
|
||||
{
|
||||
component->Message(1020, static_cast<float>(nextPlayer));
|
||||
component->Message2(MessageCode::PlayerChanged, static_cast<float>(nextPlayer));
|
||||
}
|
||||
|
||||
const char* textboxText = nullptr;
|
||||
|
@ -547,16 +548,16 @@ int TPinballTable::Message(int code, float value)
|
|||
CurrentPlayer = nextPlayer;
|
||||
}
|
||||
break;
|
||||
case 1022:
|
||||
case MessageCode::GameOver:
|
||||
loader::play_sound(SoundIndex2, nullptr, "TPinballTable3");
|
||||
pb::MissTextBox->Clear();
|
||||
pb::InfoTextBox->Display(pb::get_rc_string(Msg::STRING135), -1.0);
|
||||
EndGameTimeoutTimer = timer::set(3.0, this, EndGame_timeout);
|
||||
break;
|
||||
case 1024:
|
||||
case MessageCode::Reset:
|
||||
for (auto component : ComponentList)
|
||||
{
|
||||
component->Message(1024, 0);
|
||||
component->Message2(MessageCode::Reset, 0);
|
||||
}
|
||||
if (ReplayTimer)
|
||||
timer::kill(ReplayTimer);
|
||||
|
@ -588,7 +589,7 @@ int TPinballTable::Message(int code, float value)
|
|||
default: break;
|
||||
}
|
||||
|
||||
control::table_control_handler(code);
|
||||
control::table_control_handler(~code);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -657,10 +658,10 @@ void TPinballTable::EndGame_timeout(int timerId, void* caller)
|
|||
|
||||
for (auto component : table->ComponentList)
|
||||
{
|
||||
component->Message(1022, 0);
|
||||
component->Message2(MessageCode::GameOver, 0);
|
||||
}
|
||||
if (table->Demo)
|
||||
table->Demo->Message(1022, 0.0);
|
||||
table->Demo->Message2(MessageCode::GameOver, 0.0);
|
||||
control::handler(67, pb::MissTextBox);
|
||||
pb::InfoTextBox->Display(pb::get_rc_string(Msg::STRING125), -1.0);
|
||||
}
|
||||
|
@ -669,7 +670,7 @@ void TPinballTable::LightShow_timeout(int timerId, void* caller)
|
|||
{
|
||||
auto table = static_cast<TPinballTable*>(caller);
|
||||
table->LightShowTimer = 0;
|
||||
table->Message(1013, 0.0);
|
||||
table->Message2(MessageCode::StartGamePlayer1, 0.0);
|
||||
}
|
||||
|
||||
void TPinballTable::replay_timer_callback(int timerId, void* caller)
|
||||
|
|
|
@ -23,7 +23,7 @@ struct score_struct_super
|
|||
};
|
||||
|
||||
|
||||
class TPinballTable : public TPinballComponent
|
||||
class TPinballTable : public TPinballComponent2
|
||||
{
|
||||
public:
|
||||
TPinballTable();
|
||||
|
@ -34,7 +34,7 @@ public:
|
|||
void ChangeBallCount(int count);
|
||||
void tilt(float time);
|
||||
void port_draw() override;
|
||||
int Message(int code, float value) override;
|
||||
int Message2(MessageCode code, float value) override;
|
||||
TBall* AddBall(float x, float y);
|
||||
int BallCountInRect(const RectF& rect);
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
#include "timer.h"
|
||||
#include "TPinballTable.h"
|
||||
|
||||
TPlunger::TPlunger(TPinballTable* table, int groupIndex) : TCollisionComponent(table, groupIndex, true)
|
||||
TPlunger::TPlunger(TPinballTable* table, int groupIndex) : TCollisionComponent2(table, groupIndex, true)
|
||||
{
|
||||
visualStruct visual{};
|
||||
|
||||
|
@ -47,7 +47,7 @@ void TPlunger::Collision(TBall* ball, vector2* nextPosition, vector2* direction,
|
|||
maths::basic_collision(ball, nextPosition, direction, Elasticity, Smoothness, 0, boost);
|
||||
if (SomeCounter)
|
||||
SomeCounter--;
|
||||
Message(1005, 0.0);
|
||||
Message2(MessageCode::PlungerInputReleased, 0.0);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -56,11 +56,11 @@ void TPlunger::Collision(TBall* ball, vector2* nextPosition, vector2* direction,
|
|||
}
|
||||
}
|
||||
|
||||
int TPlunger::Message(int code, float value)
|
||||
int TPlunger::Message2(MessageCode code, float value)
|
||||
{
|
||||
switch (code)
|
||||
{
|
||||
case 1004:
|
||||
case MessageCode::PlungerInputPressed:
|
||||
if (!PullbackStartedFlag && PinballTable->MultiballCount > 0 && !PinballTable->TiltLockFlag)
|
||||
{
|
||||
PullbackStartedFlag = true;
|
||||
|
@ -70,7 +70,7 @@ int TPlunger::Message(int code, float value)
|
|||
PullbackTimer(0, this);
|
||||
}
|
||||
break;
|
||||
case 1015:
|
||||
case MessageCode::PlungerFeedBall:
|
||||
{
|
||||
RectF rect{};
|
||||
rect.XMin = PinballTable->CollisionCompOffset * -1.2f + PinballTable->PlungerPositionX;
|
||||
|
@ -91,23 +91,23 @@ int TPlunger::Message(int code, float value)
|
|||
}
|
||||
break;
|
||||
}
|
||||
case 1016:
|
||||
case MessageCode::PlungerStartFeedTimer:
|
||||
timer::set(0.95999998f, this, BallFeedTimer);
|
||||
loader::play_sound(SoundIndexP1, this, "TPlunger2");
|
||||
break;
|
||||
case 1017:
|
||||
case MessageCode::PlungerLaunchBall:
|
||||
PullbackStartedFlag = true;
|
||||
Boost = MaxPullback;
|
||||
Message(1005, 0.0f);
|
||||
Message2(MessageCode::PlungerInputReleased, 0.0f);
|
||||
break;
|
||||
case 1018:
|
||||
case MessageCode::PlungerRelaunchBall:
|
||||
SomeCounter++;
|
||||
timer::set(value, this, BallFeedTimer);
|
||||
loader::play_sound(SoundIndexP1, this, "TPlunger2_1");
|
||||
PullbackStartedFlag = true;
|
||||
PullbackTimer(0, this);
|
||||
break;
|
||||
case 1020:
|
||||
case MessageCode::PlayerChanged:
|
||||
PullbackStartedFlag = false;
|
||||
Boost = 0.0f;
|
||||
Threshold = 1000000000.0f;
|
||||
|
@ -116,13 +116,13 @@ int TPlunger::Message(int code, float value)
|
|||
timer::kill(PullbackTimer);
|
||||
timer::kill(ReleasedTimer);
|
||||
break;
|
||||
case 1011:
|
||||
case MessageCode::SetTiltLock:
|
||||
SomeCounter = 0;
|
||||
timer::kill(BallFeedTimer);
|
||||
break;
|
||||
case 1005:
|
||||
case 1009:
|
||||
case 1010:
|
||||
case MessageCode::PlungerInputReleased:
|
||||
case MessageCode::Resume:
|
||||
case MessageCode::LooseFocus:
|
||||
if (PullbackStartedFlag && !SomeCounter)
|
||||
{
|
||||
PullbackStartedFlag = false;
|
||||
|
@ -143,7 +143,7 @@ int TPlunger::Message(int code, float value)
|
|||
timer::set(PullbackDelay, this, ReleasedTimer);
|
||||
}
|
||||
break;
|
||||
case 1024:
|
||||
case MessageCode::Reset:
|
||||
{
|
||||
PullbackStartedFlag = false;
|
||||
Boost = 0.0f;
|
||||
|
@ -168,14 +168,14 @@ int TPlunger::Message(int code, float value)
|
|||
break;
|
||||
}
|
||||
|
||||
control::handler(code, this);
|
||||
control::handler(~code, this);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void TPlunger::BallFeedTimer(int timerId, void* caller)
|
||||
{
|
||||
auto plunger = static_cast<TPlunger*>(caller);
|
||||
plunger->Message(1015, 0.0);
|
||||
plunger->Message2(MessageCode::PlungerFeedBall, 0.0);
|
||||
}
|
||||
|
||||
void TPlunger::PullbackTimer(int timerId, void* caller)
|
||||
|
|
|
@ -2,14 +2,14 @@
|
|||
#include "TCollisionComponent.h"
|
||||
|
||||
class TPlunger :
|
||||
public TCollisionComponent
|
||||
public TCollisionComponent2
|
||||
{
|
||||
public:
|
||||
TPlunger(TPinballTable* table, int groupIndex);
|
||||
~TPlunger() override = default;
|
||||
void Collision(TBall* ball, vector2* nextPosition, vector2* direction, float distance,
|
||||
TEdgeSegment* edge) override;
|
||||
int Message(int code, float value) override;
|
||||
int Message2(MessageCode code, float value) override;
|
||||
|
||||
static void BallFeedTimer(int timerId, void* caller);
|
||||
static void PullbackTimer(int timerId, void* caller);
|
||||
|
|
|
@ -25,12 +25,12 @@ int TPopupTarget::Message(int code, float value)
|
|||
case 50:
|
||||
this->Timer = timer::set(this->TimerTime, this, TimerExpired);
|
||||
break;
|
||||
case 1020:
|
||||
case ~MessageCode::PlayerChanged:
|
||||
this->PlayerMessagefieldBackup[this->PinballTable->CurrentPlayer] = this->MessageField;
|
||||
this->MessageField = this->PlayerMessagefieldBackup[static_cast<int>(floor(value))];
|
||||
TPopupTarget::Message(50 - (MessageField != 0), 0.0);
|
||||
break;
|
||||
case 1024:
|
||||
case ~MessageCode::Reset:
|
||||
{
|
||||
this->MessageField = 0;
|
||||
int* playerPtr = this->PlayerMessagefieldBackup;
|
||||
|
|
|
@ -36,12 +36,12 @@ int TSink::Message(int code, float value)
|
|||
value = TimerTime;
|
||||
timer::set(value, this, TimerExpired);
|
||||
break;
|
||||
case 1020:
|
||||
case ~MessageCode::PlayerChanged:
|
||||
timer::kill(TimerExpired);
|
||||
PlayerMessagefieldBackup[PinballTable->CurrentPlayer] = MessageField;
|
||||
MessageField = PlayerMessagefieldBackup[static_cast<int>(floor(value))];
|
||||
break;
|
||||
case 1024:
|
||||
case ~MessageCode::Reset:
|
||||
{
|
||||
timer::kill(TimerExpired);
|
||||
MessageField = 0;
|
||||
|
|
|
@ -27,7 +27,7 @@ int TSoloTarget::Message(int code, float value)
|
|||
case 50:
|
||||
ActiveFlag = code == 50;
|
||||
break;
|
||||
case 1024:
|
||||
case ~MessageCode::Reset:
|
||||
if (Timer)
|
||||
timer::kill(Timer);
|
||||
Timer = 0;
|
||||
|
|
|
@ -1023,7 +1023,7 @@ void control::table_bump_ball_sink_lock()
|
|||
TableG->BallLockedCounter = TableG->BallLockedCounter + 1;
|
||||
soundwave44->Play(nullptr, "table_bump_ball_sink_lock");
|
||||
info_text_box->Display(pb::get_rc_string(Msg::STRING102), 2.0);
|
||||
TableG->Plunger->Message(1018, 2.0f);
|
||||
TableG->Plunger->Message2(MessageCode::PlungerRelaunchBall, 2.0f);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2087,7 +2087,7 @@ void control::GravityWellKickoutControl(int code, TPinballComponent* caller)
|
|||
kickout1->ActiveFlag = 1;
|
||||
break;
|
||||
}
|
||||
case 1024:
|
||||
case ~MessageCode::Reset:
|
||||
kickout1->ActiveFlag = 0;
|
||||
break;
|
||||
}
|
||||
|
@ -2225,7 +2225,7 @@ void control::MissionControl(int code, TPinballComponent* caller)
|
|||
if (mission_text_box == caller)
|
||||
code = 67;
|
||||
break;
|
||||
case 1009:
|
||||
case ~MessageCode::Resume:
|
||||
code = 67;
|
||||
break;
|
||||
default:
|
||||
|
@ -2600,7 +2600,7 @@ void control::BallDrainControl(int code, TPinballComponent* caller)
|
|||
{
|
||||
if (lite199->MessageField)
|
||||
{
|
||||
TableG->Message(1022, 0.0);
|
||||
TableG->Message2(MessageCode::GameOver, 0.0);
|
||||
if (pb::chk_highscore())
|
||||
{
|
||||
soundwave3->Play(nullptr, "BallDrainControl1");
|
||||
|
@ -2610,14 +2610,14 @@ void control::BallDrainControl(int code, TPinballComponent* caller)
|
|||
}
|
||||
else
|
||||
{
|
||||
plunger->Message(1016, 0.0);
|
||||
plunger->Message2(MessageCode::PlungerStartFeedTimer, 0.0);
|
||||
}
|
||||
}
|
||||
else if (code == 63)
|
||||
{
|
||||
if (table_unlimited_balls)
|
||||
{
|
||||
drain->Message(1024, 0.0);
|
||||
drain->Message2(MessageCode::Reset, 0.0);
|
||||
sink3->Message(56, 0.0);
|
||||
}
|
||||
else
|
||||
|
@ -2694,7 +2694,7 @@ void control::BallDrainControl(int code, TPinballComponent* caller)
|
|||
TableG->ChangeBallCount(TableG->BallCount - 1);
|
||||
if (TableG->CurrentPlayer + 1 != TableG->PlayerCount || TableG->BallCount)
|
||||
{
|
||||
TableG->Message(1021, 0.0);
|
||||
TableG->Message2(MessageCode::SwitchToNextPlayer, 0.0);
|
||||
lite199->MessageField = 0;
|
||||
}
|
||||
else
|
||||
|
@ -2742,7 +2742,7 @@ void control::BallDrainControl(int code, TPinballComponent* caller)
|
|||
lite196->Message(20, 0.0);
|
||||
lite195->Message(20, 0.0);
|
||||
fuel_bargraph->Message(20, 0.0);
|
||||
fuel_bargraph->Message(1024, 0.0);
|
||||
fuel_bargraph->Message2(MessageCode::Reset, 0.0);
|
||||
GravityWellKickoutControl(1024, nullptr);
|
||||
lite62->Message(20, 0.0);
|
||||
lite4->MessageField = 0;
|
||||
|
@ -2752,26 +2752,26 @@ void control::BallDrainControl(int code, TPinballComponent* caller)
|
|||
ramp_tgt_lights->MessageField = 0;
|
||||
outer_circle->Message(34, 0.0);
|
||||
middle_circle->Message(34, 0.0);
|
||||
attack_bump->Message(1024, 0.0);
|
||||
launch_bump->Message(1024, 0.0);
|
||||
gate1->Message(1024, 0.0);
|
||||
gate2->Message(1024, 0.0);
|
||||
block1->Message(1024, 0.0);
|
||||
target1->Message(1024, 0.0);
|
||||
target2->Message(1024, 0.0);
|
||||
target3->Message(1024, 0.0);
|
||||
target6->Message(1024, 0.0);
|
||||
target5->Message(1024, 0.0);
|
||||
target4->Message(1024, 0.0);
|
||||
target9->Message(1024, 0.0);
|
||||
target8->Message(1024, 0.0);
|
||||
target7->Message(1024, 0.0);
|
||||
attack_bump->Message2(MessageCode::Reset, 0.0);
|
||||
launch_bump->Message2(MessageCode::Reset, 0.0);
|
||||
gate1->Message2(MessageCode::Reset, 0.0);
|
||||
gate2->Message2(MessageCode::Reset, 0.0);
|
||||
block1->Message2(MessageCode::Reset, 0.0);
|
||||
target1->Message2(MessageCode::Reset, 0.0);
|
||||
target2->Message2(MessageCode::Reset, 0.0);
|
||||
target3->Message2(MessageCode::Reset, 0.0);
|
||||
target6->Message2(MessageCode::Reset, 0.0);
|
||||
target5->Message2(MessageCode::Reset, 0.0);
|
||||
target4->Message2(MessageCode::Reset, 0.0);
|
||||
target9->Message2(MessageCode::Reset, 0.0);
|
||||
target8->Message2(MessageCode::Reset, 0.0);
|
||||
target7->Message2(MessageCode::Reset, 0.0);
|
||||
if (lite199->MessageField)
|
||||
lite198->MessageField = 32;
|
||||
else
|
||||
lite198->MessageField = 0;
|
||||
MissionControl(66, nullptr);
|
||||
TableG->Message(1012, 0.0);
|
||||
TableG->Message2(MessageCode::ResetTiltLock, 0.0);
|
||||
if (light_on(&control_lite58_tag))
|
||||
lite58->Message(20, 0.0);
|
||||
else
|
||||
|
@ -3162,8 +3162,8 @@ void control::GameoverController(int code, TPinballComponent* caller)
|
|||
{
|
||||
goal_lights->Message(20, 0.0);
|
||||
pb::mode_change(GameModes::GameOver);
|
||||
flip1->Message(1022, 0.0);
|
||||
flip2->Message(1022, 0.0);
|
||||
flip1->Message2(MessageCode::GameOver, 0.0);
|
||||
flip2->Message2(MessageCode::GameOver, 0.0);
|
||||
mission_text_box->MessageField = 0;
|
||||
midi::play_track(MidiTracks::Track1, false);
|
||||
return;
|
||||
|
|
|
@ -170,7 +170,7 @@ void pb::SelectDatFile(const std::vector<const char*>& dataSearchPaths)
|
|||
void pb::reset_table()
|
||||
{
|
||||
if (MainTable)
|
||||
MainTable->Message(1024, 0.0);
|
||||
MainTable->Message2(MessageCode::Reset, 0.0);
|
||||
}
|
||||
|
||||
|
||||
|
@ -226,7 +226,7 @@ void pb::toggle_demo()
|
|||
if (demo_mode)
|
||||
{
|
||||
demo_mode = false;
|
||||
MainTable->Message(1024, 0.0);
|
||||
MainTable->Message2(MessageCode::Reset, 0.0);
|
||||
mode_change(GameModes::GameOver);
|
||||
MissTextBox->Clear();
|
||||
InfoTextBox->Display(get_rc_string(Msg::STRING125), -1.0);
|
||||
|
@ -243,7 +243,7 @@ void pb::replay_level(bool demoMode)
|
|||
mode_change(GameModes::InGame);
|
||||
if (options::Options.Music)
|
||||
midi::music_play();
|
||||
MainTable->Message(1014, static_cast<float>(options::Options.Players));
|
||||
MainTable->Message2(MessageCode::NewGame, static_cast<float>(options::Options.Players));
|
||||
}
|
||||
|
||||
void pb::ballset(float dx, float dy)
|
||||
|
@ -374,7 +374,7 @@ void pb::pause_continue()
|
|||
if (winmain::single_step)
|
||||
{
|
||||
if (MainTable)
|
||||
MainTable->Message(1008, time_now);
|
||||
MainTable->Message2(MessageCode::Pause, time_now);
|
||||
InfoTextBox->Display(get_rc_string(Msg::STRING123), -1.0);
|
||||
midi::music_stop();
|
||||
Sound::Deactivate();
|
||||
|
@ -382,7 +382,7 @@ void pb::pause_continue()
|
|||
else
|
||||
{
|
||||
if (MainTable)
|
||||
MainTable->Message(1009, 0.0);
|
||||
MainTable->Message2(MessageCode::Resume, 0.0);
|
||||
if (!demo_mode)
|
||||
{
|
||||
const char* text;
|
||||
|
@ -408,7 +408,7 @@ void pb::pause_continue()
|
|||
void pb::loose_focus()
|
||||
{
|
||||
if (MainTable)
|
||||
MainTable->Message(1010, time_now);
|
||||
MainTable->Message2(MessageCode::LooseFocus, time_now);
|
||||
}
|
||||
|
||||
void pb::InputUp(GameInput input)
|
||||
|
@ -418,15 +418,15 @@ void pb::InputUp(GameInput input)
|
|||
|
||||
if (AnyBindingMatchesInput(options::Options.Key.LeftFlipper, input))
|
||||
{
|
||||
MainTable->Message(1001, time_now);
|
||||
MainTable->Message2(MessageCode::LeftFlipperInputReleased, time_now);
|
||||
}
|
||||
if (AnyBindingMatchesInput(options::Options.Key.RightFlipper, input))
|
||||
{
|
||||
MainTable->Message(1003, time_now);
|
||||
MainTable->Message2(MessageCode::RightFlipperInputReleased, time_now);
|
||||
}
|
||||
if (AnyBindingMatchesInput(options::Options.Key.Plunger, input))
|
||||
{
|
||||
MainTable->Message(1005, time_now);
|
||||
MainTable->Message2(MessageCode::PlungerInputReleased, time_now);
|
||||
}
|
||||
if (AnyBindingMatchesInput(options::Options.Key.LeftTableBump, input))
|
||||
{
|
||||
|
@ -453,15 +453,15 @@ void pb::InputDown(GameInput input)
|
|||
|
||||
if (AnyBindingMatchesInput(options::Options.Key.LeftFlipper, input))
|
||||
{
|
||||
MainTable->Message(1000, time_now);
|
||||
MainTable->Message2(MessageCode::LeftFlipperInputPressed, time_now);
|
||||
}
|
||||
if (AnyBindingMatchesInput(options::Options.Key.RightFlipper, input))
|
||||
{
|
||||
MainTable->Message(1002, time_now);
|
||||
MainTable->Message2(MessageCode::RightFlipperInputPressed, time_now);
|
||||
}
|
||||
if (AnyBindingMatchesInput(options::Options.Key.Plunger, input))
|
||||
{
|
||||
MainTable->Message(1004, time_now);
|
||||
MainTable->Message2(MessageCode::PlungerInputPressed, time_now);
|
||||
}
|
||||
if (AnyBindingMatchesInput(options::Options.Key.LeftTableBump, input))
|
||||
{
|
||||
|
@ -515,7 +515,7 @@ void pb::InputDown(GameInput input)
|
|||
|
||||
void pb::launch_ball()
|
||||
{
|
||||
MainTable->Plunger->Message(1017, 0.0f);
|
||||
MainTable->Plunger->Message2(MessageCode::PlungerLaunchBall, 0.0f);
|
||||
}
|
||||
|
||||
void pb::end_game()
|
||||
|
|
Loading…
Reference in a new issue