mirror of
https://github.com/OpenRCT2/OpenRCT2.git
synced 2025-01-23 10:51:58 -05:00
Merge pull request #12482 from frutiemax/Fix12457
Close #12457: Refactor INTRO_STATE to use strong enum
This commit is contained in:
commit
9db2aac3bf
10 changed files with 65 additions and 61 deletions
|
@ -84,7 +84,7 @@ rct_window* window_title_exit_open()
|
|||
*/
|
||||
static void window_title_exit_mouseup(rct_window* w, rct_widgetindex widgetIndex)
|
||||
{
|
||||
if (gIntroState != INTRO_STATE_NONE)
|
||||
if (gIntroState != IntroState::None)
|
||||
return;
|
||||
|
||||
switch (widgetIndex)
|
||||
|
|
|
@ -76,7 +76,7 @@ rct_window* window_title_options_open()
|
|||
|
||||
static void window_title_options_mouseup(rct_window* w, rct_widgetindex widgetIndex)
|
||||
{
|
||||
if (gIntroState != INTRO_STATE_NONE)
|
||||
if (gIntroState != IntroState::None)
|
||||
return;
|
||||
|
||||
switch (widgetIndex)
|
||||
|
|
|
@ -726,7 +726,7 @@ namespace OpenRCT2
|
|||
*/
|
||||
void Launch()
|
||||
{
|
||||
gIntroState = INTRO_STATE_NONE;
|
||||
gIntroState = IntroState::None;
|
||||
if (gOpenRCT2Headless)
|
||||
{
|
||||
// NONE or OPEN are the only allowed actions for headless mode
|
||||
|
@ -746,7 +746,7 @@ namespace OpenRCT2
|
|||
switch (gOpenRCT2StartupAction)
|
||||
{
|
||||
case STARTUP_ACTION_INTRO:
|
||||
gIntroState = INTRO_STATE_PUBLISHER_BEGIN;
|
||||
gIntroState = IntroState::PublisherBegin;
|
||||
title_load();
|
||||
break;
|
||||
case STARTUP_ACTION_TITLE:
|
||||
|
@ -1013,7 +1013,7 @@ namespace OpenRCT2
|
|||
|
||||
date_update_real_time_of_day();
|
||||
|
||||
if (gIntroState != INTRO_STATE_NONE)
|
||||
if (gIntroState != IntroState::None)
|
||||
{
|
||||
intro_update();
|
||||
}
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
constexpr int32_t PALETTE_G1_IDX_DEVELOPER = 23217;
|
||||
constexpr int32_t PALETTE_G1_IDX_LOGO = 23224;
|
||||
|
||||
uint8_t gIntroState;
|
||||
IntroState gIntroState;
|
||||
|
||||
// Used mainly for timing but also for Y coordinate and fading.
|
||||
static int32_t _introStateCounter;
|
||||
|
@ -43,12 +43,12 @@ void intro_update()
|
|||
|
||||
switch (gIntroState)
|
||||
{
|
||||
case INTRO_STATE_DISCLAIMER_1:
|
||||
case INTRO_STATE_DISCLAIMER_2:
|
||||
case IntroState::Disclaimer1:
|
||||
case IntroState::Disclaimer2:
|
||||
// Originally used for the disclaimer text
|
||||
gIntroState = INTRO_STATE_PUBLISHER_BEGIN;
|
||||
gIntroState = IntroState::PublisherBegin;
|
||||
[[fallthrough]];
|
||||
case INTRO_STATE_PUBLISHER_BEGIN:
|
||||
case IntroState::PublisherBegin:
|
||||
load_palette();
|
||||
|
||||
// Set the Y for the Infogrames logo
|
||||
|
@ -57,9 +57,9 @@ void intro_update()
|
|||
// Play the chain lift sound
|
||||
_soundChannel = Mixer_Play_Effect(SoundId::LiftBM, MIXER_LOOP_INFINITE, MIXER_VOLUME_MAX, 0.5f, 1, true);
|
||||
_chainLiftFinished = false;
|
||||
gIntroState++;
|
||||
gIntroState = IntroState::PublisherScroll;
|
||||
break;
|
||||
case INTRO_STATE_PUBLISHER_SCROLL:
|
||||
case IntroState::PublisherScroll:
|
||||
// Move the Infogrames logo down
|
||||
_introStateCounter += 5;
|
||||
|
||||
|
@ -67,17 +67,17 @@ void intro_update()
|
|||
if (_introStateCounter > context_get_height() - 120)
|
||||
{
|
||||
_introStateCounter = -116;
|
||||
gIntroState++;
|
||||
gIntroState = IntroState::DeveloperBegin;
|
||||
}
|
||||
|
||||
break;
|
||||
case INTRO_STATE_DEVELOPER_BEGIN:
|
||||
case IntroState::DeveloperBegin:
|
||||
// Set the Y for the Chris Sawyer logo
|
||||
_introStateCounter = -116;
|
||||
|
||||
gIntroState++;
|
||||
gIntroState = IntroState::DeveloperScroll;
|
||||
break;
|
||||
case INTRO_STATE_DEVELOPER_SCROLL:
|
||||
case IntroState::DeveloperScroll:
|
||||
_introStateCounter += 5;
|
||||
|
||||
// Check if logo is almost scrolled to the bottom
|
||||
|
@ -110,20 +110,20 @@ void intro_update()
|
|||
// Play long peep scream sound
|
||||
_soundChannel = Mixer_Play_Effect(SoundId::Scream1, MIXER_LOOP_NONE, MIXER_VOLUME_MAX, 0.5f, 1, false);
|
||||
|
||||
gIntroState++;
|
||||
gIntroState = IntroState::LogoFadeIn;
|
||||
_introStateCounter = 0;
|
||||
}
|
||||
break;
|
||||
case INTRO_STATE_LOGO_FADE_IN:
|
||||
case IntroState::LogoFadeIn:
|
||||
// Fade in, add 4 / 256 to fading
|
||||
_introStateCounter += 0x400;
|
||||
if (_introStateCounter > 0xFF00)
|
||||
{
|
||||
gIntroState++;
|
||||
gIntroState = IntroState::LogoWait;
|
||||
_introStateCounter = 0;
|
||||
}
|
||||
break;
|
||||
case INTRO_STATE_LOGO_WAIT:
|
||||
case IntroState::LogoWait:
|
||||
// Wait 80 game ticks
|
||||
_introStateCounter++;
|
||||
if (_introStateCounter >= 80)
|
||||
|
@ -131,18 +131,18 @@ void intro_update()
|
|||
// Set fading to 256
|
||||
_introStateCounter = 0xFF00;
|
||||
|
||||
gIntroState++;
|
||||
gIntroState = IntroState::LogoFadeOut;
|
||||
}
|
||||
break;
|
||||
case INTRO_STATE_LOGO_FADE_OUT:
|
||||
case IntroState::LogoFadeOut:
|
||||
// Fade out, subtract 4 / 256 from fading
|
||||
_introStateCounter -= 0x400;
|
||||
if (_introStateCounter < 0)
|
||||
{
|
||||
gIntroState = INTRO_STATE_CLEAR;
|
||||
gIntroState = IntroState::Clear;
|
||||
}
|
||||
break;
|
||||
case INTRO_STATE_CLEAR:
|
||||
case IntroState::Clear:
|
||||
// Stop any playing sound
|
||||
if (_soundChannel != nullptr)
|
||||
{
|
||||
|
@ -151,14 +151,16 @@ void intro_update()
|
|||
}
|
||||
|
||||
// Move to next part
|
||||
gIntroState++;
|
||||
gIntroState = IntroState::Finish;
|
||||
_introStateCounter = 0;
|
||||
break;
|
||||
case INTRO_STATE_FINISH:
|
||||
gIntroState = INTRO_STATE_NONE;
|
||||
case IntroState::Finish:
|
||||
gIntroState = IntroState::None;
|
||||
load_palette();
|
||||
audio_start_title_music();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -168,13 +170,13 @@ void intro_draw(rct_drawpixelinfo* dpi)
|
|||
|
||||
switch (gIntroState)
|
||||
{
|
||||
case INTRO_STATE_DISCLAIMER_1:
|
||||
case INTRO_STATE_DISCLAIMER_2:
|
||||
case IntroState::Disclaimer1:
|
||||
case IntroState::Disclaimer2:
|
||||
break;
|
||||
case INTRO_STATE_PUBLISHER_BEGIN:
|
||||
case IntroState::PublisherBegin:
|
||||
gfx_clear(dpi, BACKROUND_COLOUR_DARK);
|
||||
break;
|
||||
case INTRO_STATE_PUBLISHER_SCROLL:
|
||||
case IntroState::PublisherScroll:
|
||||
gfx_clear(dpi, BACKROUND_COLOUR_DARK);
|
||||
|
||||
// Draw a white rectangle for the logo background (gives a bit of white margin)
|
||||
|
@ -190,18 +192,18 @@ void intro_draw(rct_drawpixelinfo* dpi)
|
|||
gfx_draw_sprite(dpi, SPR_INTRO_INFOGRAMES_01, { (screenWidth / 2) - 320 + 69, _introStateCounter + 319 }, 0);
|
||||
gfx_draw_sprite(dpi, SPR_INTRO_INFOGRAMES_11, { (screenWidth / 2) - 320 + 319, _introStateCounter + 319 }, 0);
|
||||
break;
|
||||
case INTRO_STATE_DEVELOPER_BEGIN:
|
||||
case IntroState::DeveloperBegin:
|
||||
gfx_clear(dpi, BACKROUND_COLOUR_DARK);
|
||||
gfx_transpose_palette(PALETTE_G1_IDX_DEVELOPER, 255);
|
||||
break;
|
||||
case INTRO_STATE_DEVELOPER_SCROLL:
|
||||
case IntroState::DeveloperScroll:
|
||||
gfx_clear(dpi, BACKROUND_COLOUR_DARK);
|
||||
|
||||
// Draw Chris Sawyer logo
|
||||
gfx_draw_sprite(dpi, SPR_INTRO_CHRIS_SAWYER_00, { (screenWidth / 2) - 320 + 70, _introStateCounter }, 0);
|
||||
gfx_draw_sprite(dpi, SPR_INTRO_CHRIS_SAWYER_10, { (screenWidth / 2) - 320 + 320, _introStateCounter }, 0);
|
||||
break;
|
||||
case INTRO_STATE_LOGO_FADE_IN:
|
||||
case IntroState::LogoFadeIn:
|
||||
if (_introStateCounter <= 0xFF00)
|
||||
{
|
||||
gfx_transpose_palette(PALETTE_G1_IDX_LOGO, (_introStateCounter >> 8) & 0xFF);
|
||||
|
@ -212,10 +214,10 @@ void intro_draw(rct_drawpixelinfo* dpi)
|
|||
}
|
||||
screen_intro_draw_logo(dpi);
|
||||
break;
|
||||
case INTRO_STATE_LOGO_WAIT:
|
||||
case IntroState::LogoWait:
|
||||
screen_intro_draw_logo(dpi);
|
||||
break;
|
||||
case INTRO_STATE_LOGO_FADE_OUT:
|
||||
case IntroState::LogoFadeOut:
|
||||
if (_introStateCounter >= 0)
|
||||
{
|
||||
gfx_transpose_palette(PALETTE_G1_IDX_LOGO, (_introStateCounter >> 8) & 0xFF);
|
||||
|
@ -226,9 +228,11 @@ void intro_draw(rct_drawpixelinfo* dpi)
|
|||
}
|
||||
screen_intro_draw_logo(dpi);
|
||||
break;
|
||||
case INTRO_STATE_CLEAR:
|
||||
case IntroState::Clear:
|
||||
gfx_clear(dpi, BACKROUND_COLOUR_DARK);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -261,13 +265,13 @@ static void screen_intro_skip_part()
|
|||
{
|
||||
switch (gIntroState)
|
||||
{
|
||||
case INTRO_STATE_NONE:
|
||||
case IntroState::None:
|
||||
break;
|
||||
case INTRO_STATE_DISCLAIMER_2:
|
||||
gIntroState = INTRO_STATE_PUBLISHER_BEGIN;
|
||||
case IntroState::Disclaimer2:
|
||||
gIntroState = IntroState::PublisherBegin;
|
||||
break;
|
||||
default:
|
||||
gIntroState = INTRO_STATE_CLEAR;
|
||||
gIntroState = IntroState::Clear;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,23 +14,23 @@
|
|||
|
||||
struct rct_drawpixelinfo;
|
||||
|
||||
enum INTRO_STATE
|
||||
enum class IntroState : uint8_t
|
||||
{
|
||||
INTRO_STATE_NONE,
|
||||
INTRO_STATE_PUBLISHER_BEGIN,
|
||||
INTRO_STATE_PUBLISHER_SCROLL,
|
||||
INTRO_STATE_DEVELOPER_BEGIN,
|
||||
INTRO_STATE_DEVELOPER_SCROLL,
|
||||
INTRO_STATE_LOGO_FADE_IN,
|
||||
INTRO_STATE_LOGO_WAIT,
|
||||
INTRO_STATE_LOGO_FADE_OUT,
|
||||
INTRO_STATE_DISCLAIMER_1,
|
||||
INTRO_STATE_DISCLAIMER_2,
|
||||
INTRO_STATE_CLEAR = 254,
|
||||
INTRO_STATE_FINISH = 255,
|
||||
None,
|
||||
PublisherBegin,
|
||||
PublisherScroll,
|
||||
DeveloperBegin,
|
||||
DeveloperScroll,
|
||||
LogoFadeIn,
|
||||
LogoWait,
|
||||
LogoFadeOut,
|
||||
Disclaimer1,
|
||||
Disclaimer2,
|
||||
Clear = 254,
|
||||
Finish = 255,
|
||||
};
|
||||
|
||||
extern uint8_t gIntroState;
|
||||
extern IntroState gIntroState;
|
||||
|
||||
void intro_update();
|
||||
void intro_draw(rct_drawpixelinfo* dpi);
|
||||
|
|
|
@ -253,7 +253,7 @@ void audio_play_sound(SoundId soundId, int32_t volume, int32_t pan)
|
|||
|
||||
void audio_start_title_music()
|
||||
{
|
||||
if (gGameSoundsOff || !(gScreenFlags & SCREEN_FLAGS_TITLE_DEMO) || gIntroState != INTRO_STATE_NONE)
|
||||
if (gGameSoundsOff || !(gScreenFlags & SCREEN_FLAGS_TITLE_DEMO) || gIntroState != IntroState::None)
|
||||
{
|
||||
audio_stop_title_music();
|
||||
return;
|
||||
|
|
|
@ -80,7 +80,7 @@ static std::vector<paint_session> extract_paint_session(const std::string parkFi
|
|||
return {};
|
||||
}
|
||||
|
||||
gIntroState = INTRO_STATE_NONE;
|
||||
gIntroState = IntroState::None;
|
||||
gScreenFlags = SCREEN_FLAGS_PLAYING;
|
||||
|
||||
int32_t mapSize = gMapSize;
|
||||
|
|
|
@ -188,7 +188,7 @@ void X8DrawingEngine::Invalidate(int32_t left, int32_t top, int32_t right, int32
|
|||
|
||||
void X8DrawingEngine::BeginDraw()
|
||||
{
|
||||
if (gIntroState == INTRO_STATE_NONE)
|
||||
if (gIntroState == IntroState::None)
|
||||
{
|
||||
#ifdef __ENABLE_LIGHTFX__
|
||||
// HACK we need to re-configure the bits if light fx has been enabled / disabled
|
||||
|
|
|
@ -444,7 +444,7 @@ static void benchgfx_render_screenshots(const char* inputPath, std::unique_ptr<I
|
|||
return;
|
||||
}
|
||||
|
||||
gIntroState = INTRO_STATE_NONE;
|
||||
gIntroState = IntroState::None;
|
||||
gScreenFlags = SCREEN_FLAGS_PLAYING;
|
||||
|
||||
// Create Viewport and DPI for every rotation and zoom.
|
||||
|
@ -649,7 +649,7 @@ int32_t cmdline_for_screenshot(const char** argv, int32_t argc, ScreenshotOption
|
|||
throw std::runtime_error("Failed to load park.");
|
||||
}
|
||||
|
||||
gIntroState = INTRO_STATE_NONE;
|
||||
gIntroState = IntroState::None;
|
||||
gScreenFlags = SCREEN_FLAGS_PLAYING;
|
||||
|
||||
rct_viewport viewport{};
|
||||
|
|
|
@ -37,7 +37,7 @@ Painter::Painter(const std::shared_ptr<IUiContext>& uiContext)
|
|||
void Painter::Paint(IDrawingEngine& de)
|
||||
{
|
||||
auto dpi = de.GetDrawingPixelInfo();
|
||||
if (gIntroState != INTRO_STATE_NONE)
|
||||
if (gIntroState != IntroState::None)
|
||||
{
|
||||
intro_draw(dpi);
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue