diff --git a/src/openrct2-ui/windows/TitleExit.cpp b/src/openrct2-ui/windows/TitleExit.cpp index 6b43f27b48..2e55ab6b03 100644 --- a/src/openrct2-ui/windows/TitleExit.cpp +++ b/src/openrct2-ui/windows/TitleExit.cpp @@ -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) diff --git a/src/openrct2-ui/windows/TitleOptions.cpp b/src/openrct2-ui/windows/TitleOptions.cpp index 8049b3e7e2..4eaa46e6c2 100644 --- a/src/openrct2-ui/windows/TitleOptions.cpp +++ b/src/openrct2-ui/windows/TitleOptions.cpp @@ -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) diff --git a/src/openrct2/Context.cpp b/src/openrct2/Context.cpp index d23c64a203..94d1d3493e 100644 --- a/src/openrct2/Context.cpp +++ b/src/openrct2/Context.cpp @@ -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(); } diff --git a/src/openrct2/Intro.cpp b/src/openrct2/Intro.cpp index d83f9a3bc7..070523bb61 100644 --- a/src/openrct2/Intro.cpp +++ b/src/openrct2/Intro.cpp @@ -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; } } diff --git a/src/openrct2/Intro.h b/src/openrct2/Intro.h index 4b4f38b142..70e9592fe3 100644 --- a/src/openrct2/Intro.h +++ b/src/openrct2/Intro.h @@ -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); diff --git a/src/openrct2/audio/Audio.cpp b/src/openrct2/audio/Audio.cpp index ae7e808c53..a23c26b946 100644 --- a/src/openrct2/audio/Audio.cpp +++ b/src/openrct2/audio/Audio.cpp @@ -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; diff --git a/src/openrct2/cmdline/BenchSpriteSort.cpp b/src/openrct2/cmdline/BenchSpriteSort.cpp index fdf254c07b..ef32d9adc7 100644 --- a/src/openrct2/cmdline/BenchSpriteSort.cpp +++ b/src/openrct2/cmdline/BenchSpriteSort.cpp @@ -80,7 +80,7 @@ static std::vector extract_paint_session(const std::string parkFi return {}; } - gIntroState = INTRO_STATE_NONE; + gIntroState = IntroState::None; gScreenFlags = SCREEN_FLAGS_PLAYING; int32_t mapSize = gMapSize; diff --git a/src/openrct2/drawing/X8DrawingEngine.cpp b/src/openrct2/drawing/X8DrawingEngine.cpp index e3994cc323..5f964636ca 100644 --- a/src/openrct2/drawing/X8DrawingEngine.cpp +++ b/src/openrct2/drawing/X8DrawingEngine.cpp @@ -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 diff --git a/src/openrct2/interface/Screenshot.cpp b/src/openrct2/interface/Screenshot.cpp index 5fc29e9a69..444c37381e 100644 --- a/src/openrct2/interface/Screenshot.cpp +++ b/src/openrct2/interface/Screenshot.cpp @@ -444,7 +444,7 @@ static void benchgfx_render_screenshots(const char* inputPath, std::unique_ptr& uiContext) void Painter::Paint(IDrawingEngine& de) { auto dpi = de.GetDrawingPixelInfo(); - if (gIntroState != INTRO_STATE_NONE) + if (gIntroState != IntroState::None) { intro_draw(dpi); }