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