From 923d9f7ff0d8b5b3fabdf2b89fa70854316a0e9a Mon Sep 17 00:00:00 2001 From: Hielke Morsink Date: Thu, 19 Feb 2026 12:05:52 +0100 Subject: [PATCH 1/4] Move IntroState enum out of header --- src/openrct2/scenes/intro/IntroScene.cpp | 14 ++++++++++++++ src/openrct2/scenes/intro/IntroScene.h | 14 -------------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/openrct2/scenes/intro/IntroScene.cpp b/src/openrct2/scenes/intro/IntroScene.cpp index 04d5de25ff..731d7dc9fc 100644 --- a/src/openrct2/scenes/intro/IntroScene.cpp +++ b/src/openrct2/scenes/intro/IntroScene.cpp @@ -26,6 +26,20 @@ using namespace OpenRCT2::Drawing; namespace OpenRCT2 { + enum class IntroState : uint8_t + { + None, + PublisherBegin, + PublisherScroll, + DeveloperBegin, + DeveloperScroll, + LogoFadeIn, + LogoWait, + LogoFadeOut, + Clear = 254, + Finish = 255, + }; + static constexpr PaletteIndex kBackgroundColourDark = PaletteIndex::pi10; static constexpr PaletteIndex kBackgroundColourLogo = PaletteIndex::primaryRemap2; static constexpr PaletteIndex kBorderColourPublisher = PaletteIndex::pi129; diff --git a/src/openrct2/scenes/intro/IntroScene.h b/src/openrct2/scenes/intro/IntroScene.h index 579a0cfa9f..4400c8067f 100644 --- a/src/openrct2/scenes/intro/IntroScene.h +++ b/src/openrct2/scenes/intro/IntroScene.h @@ -20,20 +20,6 @@ namespace OpenRCT2::Drawing namespace OpenRCT2 { - enum class IntroState : uint8_t - { - None, - PublisherBegin, - PublisherScroll, - DeveloperBegin, - DeveloperScroll, - LogoFadeIn, - LogoWait, - LogoFadeOut, - Clear = 254, - Finish = 255, - }; - class IntroScene final : public Scene { public: From ac30eeb06ec8c403742963bd586cc441d8c8ee4b Mon Sep 17 00:00:00 2001 From: Hielke Morsink Date: Thu, 19 Feb 2026 12:31:16 +0100 Subject: [PATCH 2/4] Remove unused function --- src/openrct2/scenes/intro/IntroScene.h | 1 - 1 file changed, 1 deletion(-) diff --git a/src/openrct2/scenes/intro/IntroScene.h b/src/openrct2/scenes/intro/IntroScene.h index 4400c8067f..a29a5ec0d4 100644 --- a/src/openrct2/scenes/intro/IntroScene.h +++ b/src/openrct2/scenes/intro/IntroScene.h @@ -31,6 +31,5 @@ namespace OpenRCT2 }; bool IntroIsPlaying(); - void IntroUpdate(); void IntroDraw(Drawing::RenderTarget& rt); } // namespace OpenRCT2 From 93ccb908b55942cea36403ee8eb5bda49efdcb24 Mon Sep 17 00:00:00 2001 From: Hielke Morsink Date: Thu, 19 Feb 2026 13:57:11 +0100 Subject: [PATCH 3/4] Move ownership and details to IntroSceneImpl --- src/openrct2/scenes/intro/IntroScene.cpp | 116 +++++++++++++++++------ src/openrct2/scenes/intro/IntroScene.h | 9 +- 2 files changed, 93 insertions(+), 32 deletions(-) diff --git a/src/openrct2/scenes/intro/IntroScene.cpp b/src/openrct2/scenes/intro/IntroScene.cpp index 731d7dc9fc..b8d66f481c 100644 --- a/src/openrct2/scenes/intro/IntroScene.cpp +++ b/src/openrct2/scenes/intro/IntroScene.cpp @@ -19,27 +19,13 @@ #include "../../drawing/Drawing.h" #include "../../drawing/Rectangle.h" -#include +#include using OpenRCT2::Audio::SoundId; using namespace OpenRCT2::Drawing; namespace OpenRCT2 { - enum class IntroState : uint8_t - { - None, - PublisherBegin, - PublisherScroll, - DeveloperBegin, - DeveloperScroll, - LogoFadeIn, - LogoWait, - LogoFadeOut, - Clear = 254, - Finish = 255, - }; - static constexpr PaletteIndex kBackgroundColourDark = PaletteIndex::pi10; static constexpr PaletteIndex kBackgroundColourLogo = PaletteIndex::primaryRemap2; static constexpr PaletteIndex kBorderColourPublisher = PaletteIndex::pi129; @@ -47,37 +33,98 @@ namespace OpenRCT2 static constexpr ImageIndex kPaletteChrisSawyerLogo = 23217; static constexpr ImageIndex kPaletteRCT2Logo = 23224; - static IntroState _introState; + static std::weak_ptr introSceneImplementation; - // Used mainly for timing but also for Y coordinate and fading. - static int32_t _introStateCounter; + class IntroSceneImpl + { + public: + bool IntroIsPlaying(); + void IntroDraw(Drawing::RenderTarget& rt); + void Load(); + void Stop(); + void Tick(IContext& sceneContext); - static std::shared_ptr _soundChannel = nullptr; - static bool _chainLiftFinished; + private: + void ScreenIntroProcessMouseInput(); + void ScreenIntroProcessKeyboardInput(); + void ScreenIntroSkipPart(); + void ScreenIntroDrawLogo(RenderTarget& rt); + + private: + enum class IntroState : uint8_t + { + None, + PublisherBegin, + PublisherScroll, + DeveloperBegin, + DeveloperScroll, + LogoFadeIn, + LogoWait, + LogoFadeOut, + Clear = 254, + Finish = 255, + }; + + IntroState _introState; + + // Used mainly for timing but also for Y coordinate and fading. + int32_t _introStateCounter; + + std::shared_ptr _soundChannel = nullptr; + bool _chainLiftFinished; + }; bool IntroIsPlaying() + { + if (auto impl = introSceneImplementation.lock()) + { + return impl->IntroIsPlaying(); + } + + return false; + } + + bool IntroSceneImpl::IntroIsPlaying() { return _introState != IntroState::None; } + IntroScene::IntroScene(IContext& context) + : Scene(context) + , _impl(std::make_shared()) + { + introSceneImplementation = _impl; + } + void IntroScene::Load() + { + _impl->Load(); + } + + void IntroSceneImpl::Load() { _introState = IntroState::PublisherBegin; } void IntroScene::Stop() + { + _impl->Stop(); + } + + void IntroSceneImpl::Stop() { _introState = IntroState::None; LoadPalette(); } - static void ScreenIntroProcessMouseInput(); - static void ScreenIntroProcessKeyboardInput(); - static void ScreenIntroSkipPart(); - static void ScreenIntroDrawLogo(RenderTarget& rt); - // rct2: 0x0068E966 void IntroScene::Tick() + { + auto& sceneContext = GetContext(); + _impl->Tick(sceneContext); + } + + void IntroSceneImpl::Tick(IContext& sceneContext) { ScreenIntroProcessMouseInput(); ScreenIntroProcessKeyboardInput(); @@ -195,8 +242,7 @@ namespace OpenRCT2 break; case IntroState::Finish: { - auto& context = GetContext(); - context.SetActiveScene(context.GetTitleScene()); + sceneContext.SetActiveScene(sceneContext.GetTitleScene()); break; } default: @@ -205,6 +251,14 @@ namespace OpenRCT2 } void IntroDraw(RenderTarget& rt) + { + if (auto impl = introSceneImplementation.lock()) + { + impl->IntroDraw(rt); + } + } + + void IntroSceneImpl::IntroDraw(RenderTarget& rt) { int32_t screenWidth = ContextGetWidth(); @@ -278,7 +332,7 @@ namespace OpenRCT2 } } - static void ScreenIntroProcessMouseInput() + void IntroSceneImpl::ScreenIntroProcessMouseInput() { if (ContextGetCursorState()->any & CURSOR_DOWN) { @@ -290,7 +344,7 @@ namespace OpenRCT2 * * rct2: 0x006E3AEC */ - static void ScreenIntroProcessKeyboardInput() + void IntroSceneImpl::ScreenIntroProcessKeyboardInput() { const uint8_t* keys = ContextGetKeysState(); for (int i = 0; i < 256; i++) @@ -303,7 +357,7 @@ namespace OpenRCT2 } } - static void ScreenIntroSkipPart() + void IntroSceneImpl::ScreenIntroSkipPart() { switch (_introState) { @@ -315,7 +369,7 @@ namespace OpenRCT2 } } - static void ScreenIntroDrawLogo(RenderTarget& rt) + void IntroSceneImpl::ScreenIntroDrawLogo(RenderTarget& rt) { int32_t screenWidth = ContextGetWidth(); int32_t imageWidth = 640; diff --git a/src/openrct2/scenes/intro/IntroScene.h b/src/openrct2/scenes/intro/IntroScene.h index a29a5ec0d4..e3cbbfdc9d 100644 --- a/src/openrct2/scenes/intro/IntroScene.h +++ b/src/openrct2/scenes/intro/IntroScene.h @@ -11,7 +11,7 @@ #include "../Scene.h" -#include +#include namespace OpenRCT2::Drawing { @@ -20,14 +20,21 @@ namespace OpenRCT2::Drawing namespace OpenRCT2 { + class IntroSceneImpl; + class IntroScene final : public Scene { public: using Scene::Scene; + IntroScene(IContext& context); + void Load() override; void Tick() override; void Stop() override; + + private: + std::shared_ptr _impl; }; bool IntroIsPlaying(); From 24ee46680c7d4d427d0edbc895183fcc8ce5fe93 Mon Sep 17 00:00:00 2001 From: Hielke Morsink Date: Thu, 19 Feb 2026 14:07:31 +0100 Subject: [PATCH 4/4] Move all IntroScene implementations to the end --- src/openrct2/scenes/intro/IntroScene.cpp | 46 ++++++++++++------------ 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/src/openrct2/scenes/intro/IntroScene.cpp b/src/openrct2/scenes/intro/IntroScene.cpp index b8d66f481c..6970d5feb8 100644 --- a/src/openrct2/scenes/intro/IntroScene.cpp +++ b/src/openrct2/scenes/intro/IntroScene.cpp @@ -89,28 +89,11 @@ namespace OpenRCT2 return _introState != IntroState::None; } - IntroScene::IntroScene(IContext& context) - : Scene(context) - , _impl(std::make_shared()) - { - introSceneImplementation = _impl; - } - - void IntroScene::Load() - { - _impl->Load(); - } - void IntroSceneImpl::Load() { _introState = IntroState::PublisherBegin; } - void IntroScene::Stop() - { - _impl->Stop(); - } - void IntroSceneImpl::Stop() { _introState = IntroState::None; @@ -118,12 +101,6 @@ namespace OpenRCT2 } // rct2: 0x0068E966 - void IntroScene::Tick() - { - auto& sceneContext = GetContext(); - _impl->Tick(sceneContext); - } - void IntroSceneImpl::Tick(IContext& sceneContext) { ScreenIntroProcessMouseInput(); @@ -390,4 +367,27 @@ namespace OpenRCT2 GfxDrawSprite(rt, ImageId(SPR_INTRO_LOGO_11), { imageX + 220, 240 }); GfxDrawSprite(rt, ImageId(SPR_INTRO_LOGO_21), { imageX + 440, 240 }); } + + IntroScene::IntroScene(IContext& context) + : Scene(context) + , _impl(std::make_shared()) + { + introSceneImplementation = _impl; + } + + void IntroScene::Load() + { + _impl->Load(); + } + + void IntroScene::Stop() + { + _impl->Stop(); + } + + void IntroScene::Tick() + { + auto& sceneContext = GetContext(); + _impl->Tick(sceneContext); + } } // namespace OpenRCT2