Move ownership and details to IntroSceneImpl

This commit is contained in:
Hielke Morsink committed 2026-02-19 14:01:21 +01:00
1 parent ac30eeb06e
commit 93ccb908b5
2 files changed
+93 -32

No files matched your search

+85 -31
View File
@@ -19,27 +19,13 @@
#include "../../drawing/Drawing.h"
#include "../../drawing/Rectangle.h"
#include <memory>
#include <cstdint>
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<IntroSceneImpl> 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<Audio::IAudioChannel> _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<Audio::IAudioChannel> _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<IntroSceneImpl>())
{
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;
+8 -1
View File
@@ -11,7 +11,7 @@
#include "../Scene.h"
#include <cstdint>
#include <memory>
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<IntroSceneImpl> _impl;
};
bool IntroIsPlaying();