Merge pull request #21888 from AaronVanGeffen/scenes-refactor

Refactor logic into scenes (IntroScene/TitleScene/GameScene)
This commit is contained in:
Michael Steenbeek 2024-04-27 14:01:06 +02:00 committed by GitHub
commit e6207ee1b3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
54 changed files with 787 additions and 564 deletions

View File

@ -41,8 +41,8 @@
#include <openrct2/interface/InteractiveConsole.h>
#include <openrct2/localisation/StringIds.h>
#include <openrct2/platform/Platform.h>
#include <openrct2/scenes/title/TitleSequencePlayer.h>
#include <openrct2/scripting/ScriptEngine.h>
#include <openrct2/title/TitleSequencePlayer.h>
#include <openrct2/ui/UiContext.h>
#include <openrct2/ui/WindowManager.h>
#include <openrct2/world/Location.hpp>

View File

@ -25,7 +25,6 @@
# include <algorithm>
# include <cmath>
# include <openrct2-ui/interface/Window.h>
# include <openrct2/Intro.h>
# include <openrct2/config/Config.h>
# include <openrct2/core/Console.hpp>
# include <openrct2/drawing/Drawing.h>

View File

@ -38,7 +38,7 @@
#include <openrct2/ride/Track.h>
#include <openrct2/ride/TrackPaint.h>
#include <openrct2/scenario/Scenario.h>
#include <openrct2/title/TitleScreen.h>
#include <openrct2/scenes/title/TitleScene.h>
#include <openrct2/util/Util.h>
#include <openrct2/windows/Intent.h>
#include <openrct2/windows/TileInspectorGlobals.h>

View File

@ -21,11 +21,11 @@
# include <openrct2/entity/EntityRegistry.h>
# include <openrct2/object/ObjectManager.h>
# include <openrct2/scenario/Scenario.h>
# include <openrct2/scenes/title/TitleScene.h>
# include <openrct2/scenes/title/TitleSequence.h>
# include <openrct2/scenes/title/TitleSequenceManager.h>
# include <openrct2/scenes/title/TitleSequencePlayer.h>
# include <openrct2/scripting/ScriptEngine.h>
# include <openrct2/title/TitleScreen.h>
# include <openrct2/title/TitleSequence.h>
# include <openrct2/title/TitleSequenceManager.h>
# include <openrct2/title/TitleSequencePlayer.h>
# include <type_traits>
# include <variant>

View File

@ -30,10 +30,10 @@
#include <openrct2/object/ObjectManager.h>
#include <openrct2/scenario/ScenarioRepository.h>
#include <openrct2/scenario/ScenarioSources.h>
#include <openrct2/title/TitleScreen.h>
#include <openrct2/title/TitleSequence.h>
#include <openrct2/title/TitleSequenceManager.h>
#include <openrct2/title/TitleSequencePlayer.h>
#include <openrct2/scenes/title/TitleScene.h>
#include <openrct2/scenes/title/TitleSequence.h>
#include <openrct2/scenes/title/TitleSequenceManager.h>
#include <openrct2/scenes/title/TitleSequencePlayer.h>
#include <openrct2/ui/UiContext.h>
#include <openrct2/ui/WindowManager.h>
#include <openrct2/windows/Intent.h>

View File

@ -35,8 +35,8 @@
#include <openrct2/platform/Platform.h>
#include <openrct2/ride/RideData.h>
#include <openrct2/scenario/Scenario.h>
#include <openrct2/scenes/title/TitleScene.h>
#include <openrct2/sprites.h>
#include <openrct2/title/TitleScreen.h>
#include <openrct2/util/Util.h>
#include <openrct2/windows/Intent.h>
#include <string>
@ -368,7 +368,9 @@ static std::vector<Widget> _window_editor_object_selection_widgets = {
{
GameNotifyMapChange();
GameUnloadScripts();
TitleLoad();
auto* context = OpenRCT2::GetContext();
context->SetActiveScene(context->GetTitleScene());
}
break;
case WIDX_FILTER_RIDE_TAB_ALL:

View File

@ -31,7 +31,7 @@
#include <openrct2/rct2/T6Exporter.h>
#include <openrct2/ride/TrackDesign.h>
#include <openrct2/scenario/Scenario.h>
#include <openrct2/title/TitleScreen.h>
#include <openrct2/scenes/title/TitleScene.h>
#include <openrct2/ui/UiContext.h>
#include <openrct2/util/Util.h>
#include <openrct2/windows/Intent.h>
@ -354,7 +354,9 @@ static Widget window_loadsave_widgets[] =
{
WindowCloseByClass(WindowClass::Loadsave);
InvokeCallback(MODAL_RESULT_OK, pathBuffer);
TitleLoad();
auto* context = OpenRCT2::GetContext();
context->SetActiveScene(context->GetTitleScene());
}
else
{

View File

@ -40,9 +40,9 @@
#include <openrct2/platform/Platform.h>
#include <openrct2/ride/RideAudio.h>
#include <openrct2/scenario/Scenario.h>
#include <openrct2/scenes/title/TitleScene.h>
#include <openrct2/scenes/title/TitleSequenceManager.h>
#include <openrct2/sprites.h>
#include <openrct2/title/TitleScreen.h>
#include <openrct2/title/TitleSequenceManager.h>
#include <openrct2/ui/UiContext.h>
#include <openrct2/util/Util.h>

View File

@ -10,7 +10,6 @@
#include <openrct2-ui/interface/Widget.h>
#include <openrct2-ui/windows/Window.h>
#include <openrct2/Context.h>
#include <openrct2/Intro.h>
#include <openrct2/config/Config.h>
#include <openrct2/localisation/Localisation.h>
#include <openrct2/sprites.h>
@ -38,9 +37,6 @@ static Widget _titleExitWidgets[] = {
void OnMouseUp(WidgetIndex widgetIndex) override
{
if (gIntroState != IntroState::None)
return;
switch (widgetIndex)
{
case WIDX_EXIT:

View File

@ -10,7 +10,6 @@
#include <openrct2-ui/interface/Widget.h>
#include <openrct2-ui/windows/Window.h>
#include <openrct2/Context.h>
#include <openrct2/Intro.h>
#include <openrct2/config/Config.h>
#include <openrct2/localisation/Localisation.h>

View File

@ -19,7 +19,6 @@
#include "GameState.h"
#include "GameStateSnapshots.h"
#include "Input.h"
#include "Intro.h"
#include "OpenRCT2.h"
#include "ParkImporter.h"
#include "PlatformEnvironment.h"
@ -66,10 +65,12 @@
#include "ride/TrackDesignRepository.h"
#include "scenario/Scenario.h"
#include "scenario/ScenarioRepository.h"
#include "scenes/game/GameScene.h"
#include "scenes/intro/IntroScene.h"
#include "scenes/title/TitleScene.h"
#include "scenes/title/TitleSequenceManager.h"
#include "scripting/HookEngine.h"
#include "scripting/ScriptEngine.h"
#include "title/TitleScreen.h"
#include "title/TitleSequenceManager.h"
#include "ui/UiContext.h"
#include "ui/WindowManager.h"
#include "util/Util.h"
@ -122,8 +123,11 @@ namespace OpenRCT2
NetworkBase _network;
#endif
// Game states
std::unique_ptr<TitleScreen> _titleScreen;
// Scenes
std::unique_ptr<IntroScene> _introScene;
std::unique_ptr<TitleScene> _titleScene;
std::unique_ptr<GameScene> _gameScene;
IScene* _activeScene = nullptr;
DrawingEngine _drawingEngineType = DrawingEngine::Software;
std::unique_ptr<IDrawingEngine> _drawingEngine;
@ -171,7 +175,9 @@ namespace OpenRCT2
#ifndef DISABLE_NETWORK
, _network(*this)
#endif
, _titleScreen(std::make_unique<TitleScreen>())
, _introScene(std::make_unique<IntroScene>(*this))
, _titleScene(std::make_unique<TitleScene>(*this))
, _gameScene(std::make_unique<GameScene>(*this))
, _painter(std::make_unique<Painter>(uiContext))
{
// Can't have more than one context currently.
@ -305,6 +311,47 @@ namespace OpenRCT2
return EXIT_FAILURE;
}
IScene* GetLoadingScene() override
{
// TODO: Implement me.
return nullptr;
}
IScene* GetIntroScene() override
{
return _introScene.get();
}
IScene* GetTitleScene() override
{
return _titleScene.get();
}
IScene* GetGameScene() override
{
return _gameScene.get();
}
IScene* GetEditorScene() override
{
// TODO: Implement me.
return nullptr;
}
IScene* GetActiveScene() override
{
return _activeScene;
}
void SetActiveScene(IScene* screen) override
{
if (_activeScene != nullptr)
_activeScene->Stop();
_activeScene = screen;
if (_activeScene)
_activeScene->Load();
}
void WriteLine(const std::string& s) override
{
_stdInOutConsole.WriteLine(s);
@ -592,7 +639,7 @@ namespace OpenRCT2
Console::Error::WriteLine(e.what());
if (loadTitleScreenOnFail)
{
TitleLoad();
SetActiveScene(GetTitleScene());
}
auto windowManager = _uiContext->GetWindowManager();
windowManager->ShowError(STR_FAILED_TO_LOAD_FILE_CONTAINS_INVALID_DATA, STR_NONE, {});
@ -728,7 +775,7 @@ namespace OpenRCT2
// If loading the SV6 or SV4 failed return to the title screen if requested.
if (loadTitleScreenFirstOnFail)
{
TitleLoad();
SetActiveScene(GetTitleScene());
}
// The path needs to be duplicated as it's a const here
// which the window function doesn't like
@ -747,7 +794,7 @@ namespace OpenRCT2
// If loading the SV6 or SV4 failed return to the title screen if requested.
if (loadTitleScreenFirstOnFail)
{
TitleLoad();
SetActiveScene(GetTitleScene());
}
auto windowManager = _uiContext->GetWindowManager();
windowManager->ShowError(STR_FILE_CONTAINS_UNSUPPORTED_RIDE_TYPES, STR_NONE, {});
@ -758,7 +805,7 @@ namespace OpenRCT2
if (loadTitleScreenFirstOnFail)
{
TitleLoad();
SetActiveScene(GetTitleScene());
}
auto windowManager = _uiContext->GetWindowManager();
Formatter ft;
@ -789,7 +836,7 @@ namespace OpenRCT2
// If loading the SV6 or SV4 failed return to the title screen if requested.
if (loadTitleScreenFirstOnFail)
{
TitleLoad();
SetActiveScene(GetTitleScene());
}
Console::Error::WriteLine(e.what());
}
@ -871,7 +918,6 @@ namespace OpenRCT2
});
}
gIntroState = IntroState::None;
if (gOpenRCT2Headless)
{
// NONE or OPEN are the only allowed actions for headless mode
@ -891,11 +937,10 @@ namespace OpenRCT2
switch (gOpenRCT2StartupAction)
{
case StartupAction::Intro:
gIntroState = IntroState::PublisherBegin;
TitleLoad();
SetActiveScene(GetIntroScene());
break;
case StartupAction::Title:
TitleLoad();
SetActiveScene(GetTitleScene());
break;
case StartupAction::Open:
{
@ -908,7 +953,7 @@ namespace OpenRCT2
auto data = DownloadPark(gOpenRCT2StartupActionPath);
if (data.empty())
{
TitleLoad();
SetActiveScene(GetTitleScene());
break;
}
@ -916,7 +961,7 @@ namespace OpenRCT2
if (!LoadParkFromStream(&ms, gOpenRCT2StartupActionPath, true))
{
Console::Error::WriteLine("Failed to load '%s'", gOpenRCT2StartupActionPath);
TitleLoad();
SetActiveScene(GetTitleScene());
break;
}
#endif
@ -934,12 +979,12 @@ namespace OpenRCT2
{
Console::Error::WriteLine("Failed to load '%s'", gOpenRCT2StartupActionPath);
Console::Error::WriteLine("%s", ex.what());
TitleLoad();
SetActiveScene(GetTitleScene());
break;
}
}
gScreenFlags = SCREEN_FLAGS_PLAYING;
SetActiveScene(GetGameScene());
#ifndef DISABLE_NETWORK
if (gNetworkStart == NETWORK_MODE_SERVER)
@ -979,7 +1024,7 @@ namespace OpenRCT2
}
else if (!Editor::LoadLandscape(gOpenRCT2StartupActionPath))
{
TitleLoad();
SetActiveScene(GetTitleScene());
}
break;
default:
@ -1183,18 +1228,8 @@ namespace OpenRCT2
DateUpdateRealTimeOfDay();
if (gIntroState != IntroState::None)
{
IntroUpdate();
}
else if ((gScreenFlags & SCREEN_FLAGS_TITLE_DEMO) && !gOpenRCT2Headless)
{
_titleScreen->Tick();
}
else
{
gameStateTick();
}
if (_activeScene)
_activeScene->Tick();
#ifdef __ENABLE_DISCORD__
if (_discordService != nullptr)

View File

@ -84,6 +84,7 @@ namespace OpenRCT2
struct IPlatformEnvironment;
struct IReplayManager;
struct IScene;
namespace Audio
{
@ -142,6 +143,16 @@ namespace OpenRCT2
#ifndef DISABLE_NETWORK
virtual NetworkBase& GetNetwork() abstract;
#endif
virtual IScene* GetLoadingScene() abstract;
virtual IScene* GetIntroScene() abstract;
virtual IScene* GetTitleScene() abstract;
virtual IScene* GetGameScene() abstract;
virtual IScene* GetEditorScene() abstract;
virtual IScene* GetActiveScene() abstract;
virtual void SetActiveScene(IScene* screen) abstract;
virtual int32_t RunOpenRCT2(int argc, const char** argv) abstract;
virtual bool Initialise() abstract;

View File

@ -53,8 +53,8 @@
#include "ride/TrackDesign.h"
#include "ride/Vehicle.h"
#include "scenario/Scenario.h"
#include "scenes/title/TitleScene.h"
#include "scripting/ScriptEngine.h"
#include "title/TitleScreen.h"
#include "ui/UiContext.h"
#include "ui/WindowManager.h"
#include "util/SawyerCoding.h"
@ -511,11 +511,13 @@ void GameFixSaveVars()
void GameLoadInit()
{
IGameStateSnapshots* snapshots = GetContext()->GetGameStateSnapshots();
auto* context = GetContext();
IGameStateSnapshots* snapshots = context->GetGameStateSnapshots();
snapshots->Reset();
gScreenFlags = SCREEN_FLAGS_PLAYING;
OpenRCT2::Audio::StopAll();
context->SetActiveScene(context->GetGameScene());
if (!gLoadKeepWindowsOpen)
{
ViewportInitAll();
@ -527,7 +529,7 @@ void GameLoadInit()
WindowUnfollowSprite(*mainWindow);
}
auto windowManager = GetContext()->GetUiContext()->GetWindowManager();
auto windowManager = context->GetUiContext()->GetWindowManager();
auto& gameState = GetGameState();
windowManager->SetMainView(gameState.SavedView, gameState.SavedViewZoom, gameState.SavedViewRotation);
@ -553,7 +555,6 @@ void GameLoadInit()
ContextBroadcastIntent(&intent);
}
OpenRCT2::Audio::StopTitleMusic();
gGameSpeed = 1;
}
@ -841,7 +842,9 @@ void GameLoadOrQuitNoSavePrompt()
gFirstTimeSaving = true;
GameNotifyMapChange();
GameUnloadScripts();
TitleLoad();
auto* context = OpenRCT2::GetContext();
context->SetActiveScene(context->GetTitleScene());
break;
}
case PromptMode::SaveBeforeNewGame:

View File

@ -34,9 +34,9 @@
#include "profiling/Profiling.h"
#include "ride/Vehicle.h"
#include "scenario/Scenario.h"
#include "scenes/title/TitleScene.h"
#include "scenes/title/TitleSequencePlayer.h"
#include "scripting/ScriptEngine.h"
#include "title/TitleScreen.h"
#include "title/TitleSequencePlayer.h"
#include "ui/UiContext.h"
#include "windows/Intent.h"
#include "world/Climate.h"

View File

@ -1,303 +0,0 @@
/*****************************************************************************
* Copyright (c) 2014-2024 OpenRCT2 developers
*
* For a complete list of all authors, please refer to contributors.md
* Interested in contributing? Visit https://github.com/OpenRCT2/OpenRCT2
*
* OpenRCT2 is licensed under the GNU General Public License version 3.
*****************************************************************************/
#include "Intro.h"
#include "Context.h"
#include "audio/AudioChannel.h"
#include "audio/AudioMixer.h"
#include "audio/audio.h"
#include "drawing/Drawing.h"
#include "sprites.h"
#include <memory>
using namespace OpenRCT2::Audio;
static constexpr PaletteIndex kBackgroundColourDark = PALETTE_INDEX_10;
static constexpr PaletteIndex kBackgroundColourLogo = PALETTE_INDEX_245;
static constexpr PaletteIndex kBorderColourPublisher = PALETTE_INDEX_129;
constexpr int32_t PALETTE_G1_IDX_DEVELOPER = 23217;
constexpr int32_t PALETTE_G1_IDX_LOGO = 23224;
IntroState gIntroState;
// Used mainly for timing but also for Y coordinate and fading.
static int32_t _introStateCounter;
static std::shared_ptr<IAudioChannel> _soundChannel = nullptr;
static bool _chainLiftFinished;
static void ScreenIntroProcessMouseInput();
static void ScreenIntroProcessKeyboardInput();
static void ScreenIntroSkipPart();
static void ScreenIntroDrawLogo(DrawPixelInfo& dpi);
// rct2: 0x0068E966
void IntroUpdate()
{
ScreenIntroProcessMouseInput();
ScreenIntroProcessKeyboardInput();
switch (gIntroState)
{
case IntroState::Disclaimer1:
case IntroState::Disclaimer2:
// Originally used for the disclaimer text
gIntroState = IntroState::PublisherBegin;
[[fallthrough]];
case IntroState::PublisherBegin:
LoadPalette();
// Set the Y for the Infogrames logo
_introStateCounter = -580;
// Play the chain lift sound
_soundChannel = CreateAudioChannel(SoundId::LiftBM, true);
_chainLiftFinished = false;
gIntroState = IntroState::PublisherScroll;
break;
case IntroState::PublisherScroll:
// Move the Infogrames logo down
_introStateCounter += 5;
// Check if logo is off the screen...ish
if (_introStateCounter > ContextGetHeight() - 120)
{
_introStateCounter = -116;
gIntroState = IntroState::DeveloperBegin;
}
break;
case IntroState::DeveloperBegin:
// Set the Y for the Chris Sawyer logo
_introStateCounter = -116;
gIntroState = IntroState::DeveloperScroll;
break;
case IntroState::DeveloperScroll:
_introStateCounter += 5;
// Check if logo is almost scrolled to the bottom
if (!_chainLiftFinished && _introStateCounter >= ContextGetHeight() + 40 - 421)
{
_chainLiftFinished = true;
// Stop the chain lift sound
if (_soundChannel != nullptr)
{
_soundChannel->Stop();
_soundChannel = nullptr;
}
// Play the track friction sound
_soundChannel = CreateAudioChannel(SoundId::TrackFrictionBM, true, kMixerVolumeMax, 0.25f, 0.75);
}
// Check if logo is off the screen...ish
if (_introStateCounter >= ContextGetHeight() + 40)
{
// Stop the track friction sound
if (_soundChannel != nullptr)
{
_soundChannel->Stop();
_soundChannel = nullptr;
}
// Play long peep scream sound
_soundChannel = CreateAudioChannel(SoundId::Scream1);
gIntroState = IntroState::LogoFadeIn;
_introStateCounter = 0;
}
break;
case IntroState::LogoFadeIn:
// Fade in, add 4 / 256 to fading
_introStateCounter += 0x400;
if (_introStateCounter > 0xFF00)
{
gIntroState = IntroState::LogoWait;
_introStateCounter = 0;
}
break;
case IntroState::LogoWait:
// Wait 80 game ticks
_introStateCounter++;
if (_introStateCounter >= 80)
{
// Set fading to 256
_introStateCounter = 0xFF00;
gIntroState = IntroState::LogoFadeOut;
}
break;
case IntroState::LogoFadeOut:
// Fade out, subtract 4 / 256 from fading
_introStateCounter -= 0x400;
if (_introStateCounter < 0)
{
gIntroState = IntroState::Clear;
}
break;
case IntroState::Clear:
// Stop any playing sound
if (_soundChannel != nullptr)
{
_soundChannel->Stop();
_soundChannel = nullptr;
}
// Move to next part
gIntroState = IntroState::Finish;
_introStateCounter = 0;
break;
case IntroState::Finish:
gIntroState = IntroState::None;
LoadPalette();
OpenRCT2::Audio::PlayTitleMusic();
break;
default:
break;
}
}
void IntroDraw(DrawPixelInfo& dpi)
{
int32_t screenWidth = ContextGetWidth();
switch (gIntroState)
{
case IntroState::Disclaimer1:
case IntroState::Disclaimer2:
break;
case IntroState::PublisherBegin:
GfxClear(dpi, kBackgroundColourDark);
break;
case IntroState::PublisherScroll:
GfxClear(dpi, kBackgroundColourDark);
// Draw a white rectangle for the logo background (gives a bit of white margin)
GfxFillRect(
dpi,
{ { (screenWidth / 2) - 320 + 50, _introStateCounter + 50 },
{ (screenWidth / 2) - 320 + 50 + 540, _introStateCounter + 50 + 425 } },
kBorderColourPublisher);
// Draw Infogrames logo
GfxDrawSprite(dpi, ImageId(SPR_INTRO_INFOGRAMES_00), { (screenWidth / 2) - 320 + 69, _introStateCounter + 69 });
GfxDrawSprite(dpi, ImageId(SPR_INTRO_INFOGRAMES_10), { (screenWidth / 2) - 320 + 319, _introStateCounter + 69 });
GfxDrawSprite(dpi, ImageId(SPR_INTRO_INFOGRAMES_01), { (screenWidth / 2) - 320 + 69, _introStateCounter + 319 });
GfxDrawSprite(dpi, ImageId(SPR_INTRO_INFOGRAMES_11), { (screenWidth / 2) - 320 + 319, _introStateCounter + 319 });
break;
case IntroState::DeveloperBegin:
GfxClear(dpi, kBackgroundColourDark);
GfxTransposePalette(PALETTE_G1_IDX_DEVELOPER, 255);
break;
case IntroState::DeveloperScroll:
GfxClear(dpi, kBackgroundColourDark);
// Draw Chris Sawyer logo
GfxDrawSprite(dpi, ImageId(SPR_INTRO_CHRIS_SAWYER_00), { (screenWidth / 2) - 320 + 70, _introStateCounter });
GfxDrawSprite(dpi, ImageId(SPR_INTRO_CHRIS_SAWYER_10), { (screenWidth / 2) - 320 + 320, _introStateCounter });
break;
case IntroState::LogoFadeIn:
if (_introStateCounter <= 0xFF00)
{
GfxTransposePalette(PALETTE_G1_IDX_LOGO, (_introStateCounter >> 8) & 0xFF);
}
else
{
GfxTransposePalette(PALETTE_G1_IDX_LOGO, 255);
}
ScreenIntroDrawLogo(dpi);
break;
case IntroState::LogoWait:
ScreenIntroDrawLogo(dpi);
break;
case IntroState::LogoFadeOut:
if (_introStateCounter >= 0)
{
GfxTransposePalette(PALETTE_G1_IDX_LOGO, (_introStateCounter >> 8) & 0xFF);
}
else
{
GfxTransposePalette(PALETTE_G1_IDX_LOGO, 0);
}
ScreenIntroDrawLogo(dpi);
break;
case IntroState::Clear:
GfxClear(dpi, kBackgroundColourDark);
break;
default:
break;
}
}
static void ScreenIntroProcessMouseInput()
{
if (ContextGetCursorState()->any == CURSOR_PRESSED)
{
ScreenIntroSkipPart();
}
}
/**
*
* rct2: 0x006E3AEC
*/
static void ScreenIntroProcessKeyboardInput()
{
const uint8_t* keys = ContextGetKeysState();
for (int i = 0; i < 256; i++)
{
if (keys[i] != 0)
{
ScreenIntroSkipPart();
break;
}
}
}
static void ScreenIntroSkipPart()
{
switch (gIntroState)
{
case IntroState::None:
break;
case IntroState::Disclaimer2:
gIntroState = IntroState::PublisherBegin;
break;
default:
gIntroState = IntroState::Clear;
break;
}
}
static void ScreenIntroDrawLogo(DrawPixelInfo& dpi)
{
int32_t screenWidth = ContextGetWidth();
int32_t imageWidth = 640;
int32_t imageX = (screenWidth - imageWidth) / 2;
DrawingEngineInvalidateImage(SPR_INTRO_LOGO_00);
DrawingEngineInvalidateImage(SPR_INTRO_LOGO_10);
DrawingEngineInvalidateImage(SPR_INTRO_LOGO_20);
DrawingEngineInvalidateImage(SPR_INTRO_LOGO_01);
DrawingEngineInvalidateImage(SPR_INTRO_LOGO_11);
DrawingEngineInvalidateImage(SPR_INTRO_LOGO_21);
GfxClear(dpi, kBackgroundColourLogo);
GfxDrawSprite(dpi, ImageId(SPR_INTRO_LOGO_00), { imageX + 0, 0 });
GfxDrawSprite(dpi, ImageId(SPR_INTRO_LOGO_10), { imageX + 220, 0 });
GfxDrawSprite(dpi, ImageId(SPR_INTRO_LOGO_20), { imageX + 440, 0 });
GfxDrawSprite(dpi, ImageId(SPR_INTRO_LOGO_01), { imageX + 0, 240 });
GfxDrawSprite(dpi, ImageId(SPR_INTRO_LOGO_11), { imageX + 220, 240 });
GfxDrawSprite(dpi, ImageId(SPR_INTRO_LOGO_21), { imageX + 440, 240 });
}

View File

@ -10,7 +10,6 @@
#include "audio.h"
#include "../Context.h"
#include "../Intro.h"
#include "../OpenRCT2.h"
#include "../PlatformEnvironment.h"
#include "../config/Config.h"
@ -26,6 +25,7 @@
#include "../object/ObjectManager.h"
#include "../ride/Ride.h"
#include "../ride/RideAudio.h"
#include "../scenes/intro/IntroScene.h"
#include "../ui/UiContext.h"
#include "../util/Util.h"
#include "../world/Climate.h"
@ -294,7 +294,7 @@ namespace OpenRCT2::Audio
void PlayTitleMusic()
{
if (gGameSoundsOff || !(gScreenFlags & SCREEN_FLAGS_TITLE_DEMO) || gIntroState != IntroState::None)
if (gGameSoundsOff || !(gScreenFlags & SCREEN_FLAGS_TITLE_DEMO) || IntroIsPlaying())
{
StopTitleMusic();
return;

View File

@ -10,12 +10,12 @@
#include "X8DrawingEngine.h"
#include "../Context.h"
#include "../Intro.h"
#include "../config/Config.h"
#include "../core/Numerics.hpp"
#include "../interface/Screenshot.h"
#include "../interface/Viewport.h"
#include "../interface/Window.h"
#include "../scenes/intro/IntroScene.h"
#include "../ui/UiContext.h"
#include "../util/Util.h"
#include "Drawing.h"
@ -184,7 +184,7 @@ void X8DrawingEngine::Invalidate(int32_t left, int32_t top, int32_t right, int32
void X8DrawingEngine::BeginDraw()
{
if (gIntroState == IntroState::None)
if (!IntroIsPlaying())
{
// HACK we need to re-configure the bits if light fx has been enabled / disabled
if (_lastLightFXenabled != (gConfigGeneral.EnableLightFx != 0))
@ -837,4 +837,4 @@ void X8DrawingContext::DrawTTFBitmap(
else
DrawTTFBitmapInternal<false>(dpi, fgColor, surface, x, y, 0);
#endif // NO_TTF
}
}

View File

@ -12,7 +12,6 @@
#include "../Context.h"
#include "../Game.h"
#include "../GameState.h"
#include "../Intro.h"
#include "../OpenRCT2.h"
#include "../PlatformEnvironment.h"
#include "../actions/CheatSetAction.h"
@ -490,7 +489,6 @@ int32_t CommandLineForScreenshot(const char** argv, int32_t argc, ScreenshotOpti
throw std::runtime_error("Failed to load park.");
}
gIntroState = IntroState::None;
gScreenFlags = SCREEN_FLAGS_PLAYING;
Viewport viewport{};

View File

@ -275,7 +275,6 @@
<ClInclude Include="interface\WindowClasses.h" />
<ClInclude Include="interface\Window_internal.h" />
<ClInclude Include="interface\ZoomLevel.h" />
<ClInclude Include="Intro.h" />
<ClInclude Include="Limits.h" />
<ClInclude Include="localisation\ConversionTables.h" />
<ClInclude Include="localisation\Currency.h" />
@ -511,6 +510,23 @@
<ClInclude Include="scenario\Scenario.h" />
<ClInclude Include="scenario\ScenarioRepository.h" />
<ClInclude Include="scenario\ScenarioSources.h" />
<ClInclude Include="scenes\Scene.h" />
<ClInclude Include="scenes\intro\IntroScene.h" />
<ClInclude Include="scenes\game\GameScene.h" />
<ClInclude Include="scenes\title\Command\End.h" />
<ClInclude Include="scenes\title\Command\FollowEntity.h" />
<ClInclude Include="scenes\title\Command\LoadPark.h" />
<ClInclude Include="scenes\title\Command\LoadScenario.h" />
<ClInclude Include="scenes\title\Command\Restart.h" />
<ClInclude Include="scenes\title\Command\RotateView.h" />
<ClInclude Include="scenes\title\Command\SetLocation.h" />
<ClInclude Include="scenes\title\Command\SetSpeed.h" />
<ClInclude Include="scenes\title\Command\SetZoom.h" />
<ClInclude Include="scenes\title\Command\Wait.h" />
<ClInclude Include="scenes\title\TitleScene.h" />
<ClInclude Include="scenes\title\TitleSequence.h" />
<ClInclude Include="scenes\title\TitleSequenceManager.h" />
<ClInclude Include="scenes\title\TitleSequencePlayer.h" />
<ClInclude Include="scripting\bindings\entity\ScGuest.hpp" />
<ClInclude Include="scripting\bindings\entity\ScLitter.hpp" />
<ClInclude Include="scripting\bindings\entity\ScPeep.hpp" />
@ -551,20 +567,6 @@
<ClInclude Include="scripting\bindings\world\ScTile.hpp" />
<ClInclude Include="sprites.h" />
<ClInclude Include="System.hpp" />
<ClInclude Include="title\Command\End.h" />
<ClInclude Include="title\Command\FollowEntity.h" />
<ClInclude Include="title\Command\LoadPark.h" />
<ClInclude Include="title\Command\LoadScenario.h" />
<ClInclude Include="title\Command\Restart.h" />
<ClInclude Include="title\Command\RotateView.h" />
<ClInclude Include="title\Command\SetLocation.h" />
<ClInclude Include="title\Command\SetSpeed.h" />
<ClInclude Include="title\Command\SetZoom.h" />
<ClInclude Include="title\Command\Wait.h" />
<ClInclude Include="title\TitleScreen.h" />
<ClInclude Include="title\TitleSequence.h" />
<ClInclude Include="title\TitleSequenceManager.h" />
<ClInclude Include="title\TitleSequencePlayer.h" />
<ClInclude Include="TrackImporter.h" />
<ClInclude Include="ui\UiContext.h" />
<ClInclude Include="ui\WindowManager.h" />
@ -791,7 +793,6 @@
<ClCompile Include="interface\Window.cpp" />
<ClCompile Include="interface\Window_internal.cpp" />
<ClCompile Include="interface\ZoomLevel.cpp" />
<ClCompile Include="Intro.cpp" />
<ClCompile Include="localisation\ConversionTables.cpp" />
<ClCompile Include="localisation\Convert.cpp" />
<ClCompile Include="localisation\Currency.cpp" />
@ -999,6 +1000,22 @@
<ClCompile Include="scenario\Scenario.cpp" />
<ClCompile Include="scenario\ScenarioRepository.cpp" />
<ClCompile Include="scenario\ScenarioSources.cpp" />
<ClCompile Include="scenes\Scene.cpp" />
<ClCompile Include="scenes\game\GameScene.cpp" />
<ClCompile Include="scenes\intro\IntroScene.cpp" />
<ClCompile Include="scenes\title\Command\End.cpp" />
<ClCompile Include="scenes\title\Command\FollowEntity.cpp" />
<ClCompile Include="scenes\title\Command\LoadPark.cpp" />
<ClCompile Include="scenes\title\Command\LoadScenario.cpp" />
<ClCompile Include="scenes\title\Command\Restart.cpp" />
<ClCompile Include="scenes\title\Command\RotateView.cpp" />
<ClCompile Include="scenes\title\Command\SetLocation.cpp" />
<ClCompile Include="scenes\title\Command\SetSpeed.cpp" />
<ClCompile Include="scenes\title\Command\SetZoom.cpp" />
<ClCompile Include="scenes\title\Command\Wait.cpp" />
<ClCompile Include="scenes\title\TitleScene.cpp" />
<ClCompile Include="scenes\title\TitleSequence.cpp" />
<ClCompile Include="scenes\title\TitleSequenceManager.cpp" />
<ClCompile Include="scripting\bindings\entity\ScGuest.cpp" />
<ClCompile Include="scripting\bindings\entity\ScLitter.cpp" />
<ClCompile Include="scripting\bindings\entity\ScStaff.cpp" />
@ -1020,19 +1037,6 @@
<ClCompile Include="scripting\HookEngine.cpp" />
<ClCompile Include="scripting\Plugin.cpp" />
<ClCompile Include="scripting\ScriptEngine.cpp" />
<ClCompile Include="title\Command\End.cpp" />
<ClCompile Include="title\Command\FollowEntity.cpp" />
<ClCompile Include="title\Command\LoadPark.cpp" />
<ClCompile Include="title\Command\LoadScenario.cpp" />
<ClCompile Include="title\Command\Restart.cpp" />
<ClCompile Include="title\Command\RotateView.cpp" />
<ClCompile Include="title\Command\SetLocation.cpp" />
<ClCompile Include="title\Command\SetSpeed.cpp" />
<ClCompile Include="title\Command\SetZoom.cpp" />
<ClCompile Include="title\Command\Wait.cpp" />
<ClCompile Include="title\TitleScreen.cpp" />
<ClCompile Include="title\TitleSequence.cpp" />
<ClCompile Include="title\TitleSequenceManager.cpp" />
<ClCompile Include="TrackImporter.cpp" />
<ClCompile Include="ui\DummyUiContext.cpp" />
<ClCompile Include="ui\DummyWindowManager.cpp" />

View File

@ -11,7 +11,6 @@
#include "../Game.h"
#include "../GameState.h"
#include "../Intro.h"
#include "../OpenRCT2.h"
#include "../ReplayManager.h"
#include "../config/Config.h"
@ -24,7 +23,8 @@
#include "../localisation/Language.h"
#include "../paint/Paint.h"
#include "../profiling/Profiling.h"
#include "../title/TitleScreen.h"
#include "../scenes/intro/IntroScene.h"
#include "../scenes/title/TitleScene.h"
#include "../ui/UiContext.h"
#include "../world/TileInspector.h"
@ -43,7 +43,8 @@ void Painter::Paint(IDrawingEngine& de)
PROFILED_FUNCTION();
auto dpi = de.GetDrawingPixelInfo();
if (gIntroState != IntroState::None)
if (IntroIsPlaying())
{
IntroDraw(*dpi);
}

View File

@ -7,29 +7,24 @@
* OpenRCT2 is licensed under the GNU General Public License version 3.
*****************************************************************************/
#pragma once
#include "Scene.h"
#include "common.h"
#include "../Context.h"
#include "../GameState.h"
struct DrawPixelInfo;
using namespace OpenRCT2;
enum class IntroState : uint8_t
Scene::Scene(IContext& context)
: _context(context)
{
None,
PublisherBegin,
PublisherScroll,
DeveloperBegin,
DeveloperScroll,
LogoFadeIn,
LogoWait,
LogoFadeOut,
Disclaimer1,
Disclaimer2,
Clear = 254,
Finish = 255,
};
}
extern IntroState gIntroState;
IContext& Scene::GetContext()
{
return _context;
}
void IntroUpdate();
void IntroDraw(DrawPixelInfo& dpi);
GameState_t& Scene::GetGameState()
{
return OpenRCT2::GetGameState();
}

View File

@ -0,0 +1,44 @@
/*****************************************************************************
* Copyright (c) 2014-2024 OpenRCT2 developers
*
* For a complete list of all authors, please refer to contributors.md
* Interested in contributing? Visit https://github.com/OpenRCT2/OpenRCT2
*
* OpenRCT2 is licensed under the GNU General Public License version 3.
*****************************************************************************/
#pragma once
#include "../common.h"
namespace OpenRCT2
{
struct GameState_t;
struct IContext;
struct IScene
{
public:
virtual ~IScene() = default;
virtual GameState_t& GetGameState() = 0;
virtual IContext& GetContext() = 0;
virtual void Load() = 0;
virtual void Tick() = 0;
virtual void Stop() = 0;
};
class Scene : public IScene
{
public:
Scene(IContext& context);
GameState_t& GetGameState() override;
IContext& GetContext() override;
protected:
IContext& _context;
};
} // namespace OpenRCT2

View File

@ -0,0 +1,37 @@
/*****************************************************************************
* Copyright (c) 2014-2019 OpenRCT2 developers
*
* For a complete list of all authors, please refer to contributors.md
* Interested in contributing? Visit https://github.com/OpenRCT2/OpenRCT2
*
* OpenRCT2 is licensed under the GNU General Public License version 3.
*****************************************************************************/
#include "GameScene.h"
#include "../../Context.h"
#include "../../Game.h"
#include "../../GameState.h"
#include "../../OpenRCT2.h"
#include "../../audio/audio.h"
using namespace OpenRCT2;
void GameScene::Load()
{
LOG_VERBOSE("GameScene::Load()");
gScreenFlags = SCREEN_FLAGS_PLAYING;
LOG_VERBOSE("GameScene::Load() finished");
}
void GameScene::Tick()
{
gameStateTick();
}
void GameScene::Stop()
{
Audio::StopAll();
}

View File

@ -0,0 +1,26 @@
/*****************************************************************************
* Copyright (c) 2014-2019 OpenRCT2 developers
*
* For a complete list of all authors, please refer to contributors.md
* Interested in contributing? Visit https://github.com/OpenRCT2/OpenRCT2
*
* OpenRCT2 is licensed under the GNU General Public License version 3.
*****************************************************************************/
#pragma once
#include "../../common.h"
#include "../Scene.h"
namespace OpenRCT2
{
class GameScene final : public Scene
{
public:
using Scene::Scene;
void Load() override;
void Tick() override;
void Stop() override;
};
} // namespace OpenRCT2

View File

@ -0,0 +1,326 @@
/*****************************************************************************
* Copyright (c) 2014-2024 OpenRCT2 developers
*
* For a complete list of all authors, please refer to contributors.md
* Interested in contributing? Visit https://github.com/OpenRCT2/OpenRCT2
*
* OpenRCT2 is licensed under the GNU General Public License version 3.
*****************************************************************************/
#include "IntroScene.h"
#include "../../Context.h"
#include "../../audio/AudioChannel.h"
#include "../../audio/AudioMixer.h"
#include "../../audio/audio.h"
#include "../../drawing/Drawing.h"
#include "../../sprites.h"
#include <memory>
using OpenRCT2::Audio::SoundId;
namespace OpenRCT2
{
static constexpr PaletteIndex kBackgroundColourDark = PALETTE_INDEX_10;
static constexpr PaletteIndex kBackgroundColourLogo = PALETTE_INDEX_245;
static constexpr PaletteIndex kBorderColourPublisher = PALETTE_INDEX_129;
constexpr int32_t PALETTE_G1_IDX_DEVELOPER = 23217;
constexpr int32_t PALETTE_G1_IDX_LOGO = 23224;
static IntroState _introState;
// Used mainly for timing but also for Y coordinate and fading.
static int32_t _introStateCounter;
static std::shared_ptr<Audio::IAudioChannel> _soundChannel = nullptr;
static bool _chainLiftFinished;
bool IntroIsPlaying()
{
return _introState != IntroState::None;
}
void IntroScene::Load()
{
_introState = IntroState::PublisherBegin;
}
void IntroScene::Stop()
{
_introState = IntroState::None;
LoadPalette();
}
static void ScreenIntroProcessMouseInput();
static void ScreenIntroProcessKeyboardInput();
static void ScreenIntroSkipPart();
static void ScreenIntroDrawLogo(DrawPixelInfo& dpi);
// rct2: 0x0068E966
void IntroScene::Tick()
{
ScreenIntroProcessMouseInput();
ScreenIntroProcessKeyboardInput();
switch (_introState)
{
case IntroState::Disclaimer1:
case IntroState::Disclaimer2:
// Originally used for the disclaimer text
_introState = IntroState::PublisherBegin;
[[fallthrough]];
case IntroState::PublisherBegin:
LoadPalette();
// Set the Y for the Infogrames logo
_introStateCounter = -580;
// Play the chain lift sound
_soundChannel = Audio::CreateAudioChannel(SoundId::LiftBM, true);
_chainLiftFinished = false;
_introState = IntroState::PublisherScroll;
break;
case IntroState::PublisherScroll:
// Move the Infogrames logo down
_introStateCounter += 5;
// Check if logo is off the screen...ish
if (_introStateCounter > ContextGetHeight() - 120)
{
_introStateCounter = -116;
_introState = IntroState::DeveloperBegin;
}
break;
case IntroState::DeveloperBegin:
// Set the Y for the Chris Sawyer logo
_introStateCounter = -116;
_introState = IntroState::DeveloperScroll;
break;
case IntroState::DeveloperScroll:
_introStateCounter += 5;
// Check if logo is almost scrolled to the bottom
if (!_chainLiftFinished && _introStateCounter >= ContextGetHeight() + 40 - 421)
{
_chainLiftFinished = true;
// Stop the chain lift sound
if (_soundChannel != nullptr)
{
_soundChannel->Stop();
_soundChannel = nullptr;
}
// Play the track friction sound
_soundChannel = Audio::CreateAudioChannel(
SoundId::TrackFrictionBM, true, Audio::kMixerVolumeMax, 0.25f, 0.75);
}
// Check if logo is off the screen...ish
if (_introStateCounter >= ContextGetHeight() + 40)
{
// Stop the track friction sound
if (_soundChannel != nullptr)
{
_soundChannel->Stop();
_soundChannel = nullptr;
}
// Play long peep scream sound
_soundChannel = Audio::CreateAudioChannel(SoundId::Scream1);
_introState = IntroState::LogoFadeIn;
_introStateCounter = 0;
}
break;
case IntroState::LogoFadeIn:
// Fade in, add 4 / 256 to fading
_introStateCounter += 0x400;
if (_introStateCounter > 0xFF00)
{
_introState = IntroState::LogoWait;
_introStateCounter = 0;
}
break;
case IntroState::LogoWait:
// Wait 80 game ticks
_introStateCounter++;
if (_introStateCounter >= 80)
{
// Set fading to 256
_introStateCounter = 0xFF00;
_introState = IntroState::LogoFadeOut;
}
break;
case IntroState::LogoFadeOut:
// Fade out, subtract 4 / 256 from fading
_introStateCounter -= 0x400;
if (_introStateCounter < 0)
{
_introState = IntroState::Clear;
}
break;
case IntroState::Clear:
// Stop any playing sound
if (_soundChannel != nullptr)
{
_soundChannel->Stop();
_soundChannel = nullptr;
}
// Move to next part
_introState = IntroState::Finish;
_introStateCounter = 0;
break;
case IntroState::Finish:
{
auto& context = GetContext();
context.SetActiveScene(context.GetTitleScene());
}
default:
break;
}
}
void IntroDraw(DrawPixelInfo& dpi)
{
int32_t screenWidth = ContextGetWidth();
switch (_introState)
{
case IntroState::Disclaimer1:
case IntroState::Disclaimer2:
break;
case IntroState::PublisherBegin:
GfxClear(dpi, kBackgroundColourDark);
break;
case IntroState::PublisherScroll:
GfxClear(dpi, kBackgroundColourDark);
// Draw a white rectangle for the logo background (gives a bit of white margin)
GfxFillRect(
dpi,
{ { (screenWidth / 2) - 320 + 50, _introStateCounter + 50 },
{ (screenWidth / 2) - 320 + 50 + 540, _introStateCounter + 50 + 425 } },
kBorderColourPublisher);
// Draw Infogrames logo
GfxDrawSprite(dpi, ImageId(SPR_INTRO_INFOGRAMES_00), { (screenWidth / 2) - 320 + 69, _introStateCounter + 69 });
GfxDrawSprite(
dpi, ImageId(SPR_INTRO_INFOGRAMES_10), { (screenWidth / 2) - 320 + 319, _introStateCounter + 69 });
GfxDrawSprite(
dpi, ImageId(SPR_INTRO_INFOGRAMES_01), { (screenWidth / 2) - 320 + 69, _introStateCounter + 319 });
GfxDrawSprite(
dpi, ImageId(SPR_INTRO_INFOGRAMES_11), { (screenWidth / 2) - 320 + 319, _introStateCounter + 319 });
break;
case IntroState::DeveloperBegin:
GfxClear(dpi, kBackgroundColourDark);
GfxTransposePalette(PALETTE_G1_IDX_DEVELOPER, 255);
break;
case IntroState::DeveloperScroll:
GfxClear(dpi, kBackgroundColourDark);
// Draw Chris Sawyer logo
GfxDrawSprite(dpi, ImageId(SPR_INTRO_CHRIS_SAWYER_00), { (screenWidth / 2) - 320 + 70, _introStateCounter });
GfxDrawSprite(dpi, ImageId(SPR_INTRO_CHRIS_SAWYER_10), { (screenWidth / 2) - 320 + 320, _introStateCounter });
break;
case IntroState::LogoFadeIn:
if (_introStateCounter <= 0xFF00)
{
GfxTransposePalette(PALETTE_G1_IDX_LOGO, (_introStateCounter >> 8) & 0xFF);
}
else
{
GfxTransposePalette(PALETTE_G1_IDX_LOGO, 255);
}
ScreenIntroDrawLogo(dpi);
break;
case IntroState::LogoWait:
ScreenIntroDrawLogo(dpi);
break;
case IntroState::LogoFadeOut:
if (_introStateCounter >= 0)
{
GfxTransposePalette(PALETTE_G1_IDX_LOGO, (_introStateCounter >> 8) & 0xFF);
}
else
{
GfxTransposePalette(PALETTE_G1_IDX_LOGO, 0);
}
ScreenIntroDrawLogo(dpi);
break;
case IntroState::Clear:
GfxClear(dpi, kBackgroundColourDark);
break;
default:
break;
}
}
static void ScreenIntroProcessMouseInput()
{
if (ContextGetCursorState()->any == CURSOR_PRESSED)
{
ScreenIntroSkipPart();
}
}
/**
*
* rct2: 0x006E3AEC
*/
static void ScreenIntroProcessKeyboardInput()
{
const uint8_t* keys = ContextGetKeysState();
for (int i = 0; i < 256; i++)
{
if (keys[i] != 0)
{
ScreenIntroSkipPart();
break;
}
}
}
static void ScreenIntroSkipPart()
{
switch (_introState)
{
case IntroState::None:
break;
case IntroState::Disclaimer2:
_introState = IntroState::PublisherBegin;
break;
default:
_introState = IntroState::Clear;
break;
}
}
static void ScreenIntroDrawLogo(DrawPixelInfo& dpi)
{
int32_t screenWidth = ContextGetWidth();
int32_t imageWidth = 640;
int32_t imageX = (screenWidth - imageWidth) / 2;
DrawingEngineInvalidateImage(SPR_INTRO_LOGO_00);
DrawingEngineInvalidateImage(SPR_INTRO_LOGO_10);
DrawingEngineInvalidateImage(SPR_INTRO_LOGO_20);
DrawingEngineInvalidateImage(SPR_INTRO_LOGO_01);
DrawingEngineInvalidateImage(SPR_INTRO_LOGO_11);
DrawingEngineInvalidateImage(SPR_INTRO_LOGO_21);
GfxClear(dpi, kBackgroundColourLogo);
GfxDrawSprite(dpi, ImageId(SPR_INTRO_LOGO_00), { imageX + 0, 0 });
GfxDrawSprite(dpi, ImageId(SPR_INTRO_LOGO_10), { imageX + 220, 0 });
GfxDrawSprite(dpi, ImageId(SPR_INTRO_LOGO_20), { imageX + 440, 0 });
GfxDrawSprite(dpi, ImageId(SPR_INTRO_LOGO_01), { imageX + 0, 240 });
GfxDrawSprite(dpi, ImageId(SPR_INTRO_LOGO_11), { imageX + 220, 240 });
GfxDrawSprite(dpi, ImageId(SPR_INTRO_LOGO_21), { imageX + 440, 240 });
}
} // namespace OpenRCT2

View File

@ -0,0 +1,48 @@
/*****************************************************************************
* Copyright (c) 2014-2024 OpenRCT2 developers
*
* For a complete list of all authors, please refer to contributors.md
* Interested in contributing? Visit https://github.com/OpenRCT2/OpenRCT2
*
* OpenRCT2 is licensed under the GNU General Public License version 3.
*****************************************************************************/
#pragma once
#include "../../common.h"
#include "../Scene.h"
struct DrawPixelInfo;
namespace OpenRCT2
{
enum class IntroState : uint8_t
{
None,
PublisherBegin,
PublisherScroll,
DeveloperBegin,
DeveloperScroll,
LogoFadeIn,
LogoWait,
LogoFadeOut,
Disclaimer1,
Disclaimer2,
Clear = 254,
Finish = 255,
};
class IntroScene final : public Scene
{
public:
using Scene::Scene;
void Load() override;
void Tick() override;
void Stop() override;
};
bool IntroIsPlaying();
void IntroUpdate();
void IntroDraw(DrawPixelInfo& dpi);
} // namespace OpenRCT2

View File

@ -9,7 +9,7 @@
#include "FollowEntity.h"
#include "../../interface/Window.h"
#include "../../../interface/Window.h"
namespace OpenRCT2::Title
{

View File

@ -9,9 +9,9 @@
#pragma once
#include "../../Identifiers.h"
#include "../../core/String.hpp"
#include "../../localisation/Localisation.h"
#include "../../../Identifiers.h"
#include "../../../core/String.hpp"
#include "../../../localisation/Localisation.h"
#include <cstdint>

View File

@ -9,7 +9,7 @@
#pragma once
#include "../../core/String.hpp"
#include "../../../core/String.hpp"
#include <cstdint>

View File

@ -9,8 +9,8 @@
#include "RotateView.h"
#include "../../interface/Viewport.h"
#include "../../interface/Window.h"
#include "../../../interface/Viewport.h"
#include "../../../interface/Window.h"
namespace OpenRCT2::Title
{

View File

@ -9,10 +9,10 @@
#include "SetLocation.h"
#include "../../OpenRCT2.h"
#include "../../interface/Window.h"
#include "../../interface/Window_internal.h"
#include "../../world/Map.h"
#include "../../../OpenRCT2.h"
#include "../../../interface/Window.h"
#include "../../../interface/Window_internal.h"
#include "../../../world/Map.h"
namespace OpenRCT2::Title
{

View File

@ -9,7 +9,7 @@
#include "SetSpeed.h"
#include "../../Game.h"
#include "../../../Game.h"
#include <algorithm>

View File

@ -9,8 +9,8 @@
#include "SetZoom.h"
#include "../../interface/Window.h"
#include "../../interface/ZoomLevel.h"
#include "../../../interface/Window.h"
#include "../../../interface/ZoomLevel.h"
namespace OpenRCT2::Title
{

View File

@ -9,7 +9,7 @@
#include "Wait.h"
#include "../../Context.h"
#include "../../../Context.h"
#include <algorithm>

View File

@ -7,28 +7,28 @@
* OpenRCT2 is licensed under the GNU General Public License version 3.
*****************************************************************************/
#include "TitleScreen.h"
#include "TitleScene.h"
#include "../Context.h"
#include "../Game.h"
#include "../GameState.h"
#include "../Input.h"
#include "../OpenRCT2.h"
#include "../Version.h"
#include "../audio/audio.h"
#include "../config/Config.h"
#include "../core/Console.hpp"
#include "../drawing/Drawing.h"
#include "../interface/Screenshot.h"
#include "../interface/Viewport.h"
#include "../interface/Window.h"
#include "../localisation/Localisation.h"
#include "../network/NetworkBase.h"
#include "../network/network.h"
#include "../scenario/Scenario.h"
#include "../scenario/ScenarioRepository.h"
#include "../ui/UiContext.h"
#include "../util/Util.h"
#include "../../Context.h"
#include "../../Game.h"
#include "../../GameState.h"
#include "../../Input.h"
#include "../../OpenRCT2.h"
#include "../../Version.h"
#include "../../audio/audio.h"
#include "../../config/Config.h"
#include "../../core/Console.hpp"
#include "../../drawing/Drawing.h"
#include "../../interface/Screenshot.h"
#include "../../interface/Viewport.h"
#include "../../interface/Window.h"
#include "../../localisation/Localisation.h"
#include "../../network/NetworkBase.h"
#include "../../network/network.h"
#include "../../scenario/Scenario.h"
#include "../../scenario/ScenarioRepository.h"
#include "../../ui/UiContext.h"
#include "../../util/Util.h"
#include "TitleSequence.h"
#include "TitleSequenceManager.h"
#include "TitleSequencePlayer.h"
@ -37,29 +37,18 @@ using namespace OpenRCT2;
// TODO Remove when no longer required.
bool gPreviewingTitleSequenceInGame;
static TitleScreen* _singleton = nullptr;
TitleScreen::TitleScreen()
{
_singleton = this;
}
TitleScreen::~TitleScreen()
{
_singleton = nullptr;
}
ITitleSequencePlayer* TitleScreen::GetSequencePlayer()
ITitleSequencePlayer* TitleScene::GetSequencePlayer()
{
return _sequencePlayer;
}
size_t TitleScreen::GetCurrentSequence()
size_t TitleScene::GetCurrentSequence()
{
return _currentSequence;
}
bool TitleScreen::PreviewSequence(size_t value)
bool TitleScene::PreviewSequence(size_t value)
{
_currentSequence = value;
_previewingSequence = TryLoadSequence(true);
@ -81,7 +70,7 @@ bool TitleScreen::PreviewSequence(size_t value)
return _previewingSequence;
}
void TitleScreen::StopPreviewingSequence()
void TitleScene::StopPreviewingSequence()
{
if (_previewingSequence)
{
@ -96,24 +85,24 @@ void TitleScreen::StopPreviewingSequence()
}
}
bool TitleScreen::IsPreviewingSequence()
bool TitleScene::IsPreviewingSequence()
{
return _previewingSequence;
}
bool TitleScreen::ShouldHideVersionInfo()
bool TitleScene::ShouldHideVersionInfo()
{
return _hideVersionInfo;
}
void TitleScreen::SetHideVersionInfo(bool value)
void TitleScene::SetHideVersionInfo(bool value)
{
_hideVersionInfo = value;
}
void TitleScreen::Load()
void TitleScene::Load()
{
LOG_VERBOSE("TitleScreen::Load()");
LOG_VERBOSE("TitleScene::Load()");
if (GameIsPaused())
{
@ -125,9 +114,8 @@ void TitleScreen::Load()
gCurrentLoadedPath.clear();
#ifndef DISABLE_NETWORK
GetContext()->GetNetwork().Close();
GetContext().GetNetwork().Close();
#endif
OpenRCT2::Audio::StopAll();
gameStateInitAll(GetGameState(), DEFAULT_MAP_SIZE);
ViewportInitAll();
ContextOpenWindow(WindowClass::MainWindow);
@ -150,10 +138,10 @@ void TitleScreen::Load()
_sequencePlayer->Update();
}
LOG_VERBOSE("TitleScreen::Load() finished");
LOG_VERBOSE("TitleScene::Load() finished");
}
void TitleScreen::Tick()
void TitleScene::Tick()
{
gInUpdateCode = true;
@ -188,7 +176,12 @@ void TitleScreen::Tick()
gInUpdateCode = false;
}
void TitleScreen::ChangePresetSequence(size_t preset)
void TitleScene::Stop()
{
Audio::StopAll();
}
void TitleScene::ChangePresetSequence(size_t preset)
{
size_t count = TitleSequenceManager::GetCount();
if (preset >= count)
@ -208,7 +201,7 @@ void TitleScreen::ChangePresetSequence(size_t preset)
* Creates the windows shown on the title screen; New game, load game,
* tutorial, toolbox and exit.
*/
void TitleScreen::CreateWindows()
void TitleScene::CreateWindows()
{
ContextOpenWindow(WindowClass::TitleMenu);
ContextOpenWindow(WindowClass::TitleExit);
@ -218,11 +211,11 @@ void TitleScreen::CreateWindows()
_hideVersionInfo = false;
}
void TitleScreen::TitleInitialise()
void TitleScene::TitleInitialise()
{
if (_sequencePlayer == nullptr)
{
_sequencePlayer = GetContext()->GetUiContext()->GetTitleSequencePlayer();
_sequencePlayer = GetContext().GetUiContext()->GetTitleSequencePlayer();
}
if (gConfigInterface.RandomTitleSequence)
{
@ -298,13 +291,13 @@ void TitleScreen::TitleInitialise()
ChangePresetSequence(static_cast<int32_t>(seqId));
}
bool TitleScreen::TryLoadSequence(bool loadPreview)
bool TitleScene::TryLoadSequence(bool loadPreview)
{
if (_loadedTitleSequenceId != _currentSequence || loadPreview)
{
if (_sequencePlayer == nullptr)
{
_sequencePlayer = GetContext()->GetUiContext()->GetTitleSequencePlayer();
_sequencePlayer = GetContext().GetUiContext()->GetTitleSequencePlayer();
}
size_t numSequences = TitleSequenceManager::GetCount();
@ -343,55 +336,55 @@ bool TitleScreen::TryLoadSequence(bool loadPreview)
return true;
}
void TitleLoad()
{
if (_singleton != nullptr)
{
_singleton->Load();
}
}
void TitleCreateWindows()
{
if (_singleton != nullptr)
auto* context = OpenRCT2::GetContext();
auto* titleScene = static_cast<TitleScene*>(context->GetTitleScene());
if (titleScene != nullptr)
{
_singleton->CreateWindows();
titleScene->CreateWindows();
}
}
void* TitleGetSequencePlayer()
{
void* result = nullptr;
if (_singleton != nullptr)
auto* context = OpenRCT2::GetContext();
auto* titleScene = static_cast<TitleScene*>(context->GetTitleScene());
if (titleScene != nullptr)
{
result = _singleton->GetSequencePlayer();
return titleScene->GetSequencePlayer();
}
return result;
return nullptr;
}
void TitleSequenceChangePreset(size_t preset)
{
if (_singleton != nullptr)
auto* context = OpenRCT2::GetContext();
auto* titleScene = static_cast<TitleScene*>(context->GetTitleScene());
if (titleScene != nullptr)
{
_singleton->ChangePresetSequence(preset);
titleScene->ChangePresetSequence(preset);
}
}
bool TitleShouldHideVersionInfo()
{
bool result = false;
if (_singleton != nullptr)
auto* context = OpenRCT2::GetContext();
auto* titleScene = static_cast<TitleScene*>(context->GetTitleScene());
if (titleScene != nullptr)
{
result = _singleton->ShouldHideVersionInfo();
return titleScene->ShouldHideVersionInfo();
}
return result;
return false;
}
void TitleSetHideVersionInfo(bool value)
{
if (_singleton != nullptr)
auto* context = OpenRCT2::GetContext();
auto* titleScene = static_cast<TitleScene*>(context->GetTitleScene());
if (titleScene != nullptr)
{
_singleton->SetHideVersionInfo(value);
titleScene->SetHideVersionInfo(value);
}
}
@ -402,36 +395,43 @@ size_t TitleGetConfigSequence()
size_t TitleGetCurrentSequence()
{
size_t result = 0;
if (_singleton != nullptr)
auto* context = OpenRCT2::GetContext();
auto* titleScene = static_cast<TitleScene*>(context->GetTitleScene());
if (titleScene != nullptr)
{
result = _singleton->GetCurrentSequence();
return titleScene->GetCurrentSequence();
}
return result;
return 0;
}
bool TitlePreviewSequence(size_t value)
{
if (_singleton != nullptr)
auto* context = OpenRCT2::GetContext();
auto* titleScene = static_cast<TitleScene*>(context->GetTitleScene());
if (titleScene != nullptr)
{
return _singleton->PreviewSequence(value);
return titleScene->PreviewSequence(value);
}
return false;
}
void TitleStopPreviewingSequence()
{
if (_singleton != nullptr)
auto* context = OpenRCT2::GetContext();
auto* titleScene = static_cast<TitleScene*>(context->GetTitleScene());
if (titleScene != nullptr)
{
_singleton->StopPreviewingSequence();
titleScene->StopPreviewingSequence();
}
}
bool TitleIsPreviewingSequence()
{
if (_singleton != nullptr)
auto* context = OpenRCT2::GetContext();
auto* titleScene = static_cast<TitleScene*>(context->GetTitleScene());
if (titleScene != nullptr)
{
return _singleton->IsPreviewingSequence();
return titleScene->IsPreviewingSequence();
}
return false;
}

View File

@ -9,18 +9,18 @@
#pragma once
#include "../common.h"
#include "../drawing/Drawing.h"
#include "../../common.h"
#include "../../drawing/Drawing.h"
#include "../Scene.h"
struct ITitleSequencePlayer;
namespace OpenRCT2
{
class TitleScreen final
class TitleScene final : public Scene
{
public:
TitleScreen();
~TitleScreen();
using Scene::Scene;
ITitleSequencePlayer* GetSequencePlayer();
size_t GetCurrentSequence();
@ -30,8 +30,9 @@ namespace OpenRCT2
bool ShouldHideVersionInfo();
void SetHideVersionInfo(bool value);
void Load();
void Tick();
void Load() override;
void Tick() override;
void Stop() override;
void CreateWindows();
void ChangePresetSequence(size_t preset);
@ -50,7 +51,6 @@ namespace OpenRCT2
// When testing title sequences within a normal game
extern bool gPreviewingTitleSequenceInGame;
void TitleLoad();
void TitleCreateWindows();
void* TitleGetSequencePlayer();
void TitleSequenceChangePreset(size_t preset);

View File

@ -9,22 +9,22 @@
#include "TitleSequence.h"
#include "../common.h"
#include "../core/Collections.hpp"
#include "../core/Console.hpp"
#include "../core/File.h"
#include "../core/FileScanner.h"
#include "../core/FileStream.h"
#include "../core/Guard.hpp"
#include "../core/Memory.hpp"
#include "../core/MemoryStream.h"
#include "../core/Path.hpp"
#include "../core/String.hpp"
#include "../core/StringBuilder.h"
#include "../core/Zip.h"
#include "../scenario/ScenarioRepository.h"
#include "../scenario/ScenarioSources.h"
#include "../util/Util.h"
#include "../../common.h"
#include "../../core/Collections.hpp"
#include "../../core/Console.hpp"
#include "../../core/File.h"
#include "../../core/FileScanner.h"
#include "../../core/FileStream.h"
#include "../../core/Guard.hpp"
#include "../../core/Memory.hpp"
#include "../../core/MemoryStream.h"
#include "../../core/Path.hpp"
#include "../../core/String.hpp"
#include "../../core/StringBuilder.h"
#include "../../core/Zip.h"
#include "../../scenario/ScenarioRepository.h"
#include "../../scenario/ScenarioSources.h"
#include "../../util/Util.h"
#include <algorithm>
#include <array>

View File

@ -9,8 +9,8 @@
#pragma once
#include "../common.h"
#include "../openrct2/core/IStream.hpp"
#include "../../common.h"
#include "../../core/IStream.hpp"
#include "Command/End.h"
#include "Command/FollowEntity.h"
#include "Command/LoadPark.h"

View File

@ -9,17 +9,17 @@
#include "TitleSequenceManager.h"
#include "../Context.h"
#include "../OpenRCT2.h"
#include "../PlatformEnvironment.h"
#include "../core/Collections.hpp"
#include "../core/File.h"
#include "../core/FileScanner.h"
#include "../core/Memory.hpp"
#include "../core/Path.hpp"
#include "../core/String.hpp"
#include "../localisation/Localisation.h"
#include "../platform/Platform.h"
#include "../../Context.h"
#include "../../OpenRCT2.h"
#include "../../PlatformEnvironment.h"
#include "../../core/Collections.hpp"
#include "../../core/File.h"
#include "../../core/FileScanner.h"
#include "../../core/Memory.hpp"
#include "../../core/Path.hpp"
#include "../../core/String.hpp"
#include "../../localisation/Localisation.h"
#include "../../platform/Platform.h"
#include "TitleSequence.h"
#include <algorithm>

View File

@ -8,8 +8,8 @@
*****************************************************************************/
#pragma once
#include "../common.h"
#include "../core/String.hpp"
#include "../../common.h"
#include "../../core/String.hpp"
#include <limits>
#include <string>

View File

@ -9,7 +9,7 @@
#pragma once
#include "../common.h"
#include "../../common.h"
struct ITitleSequencePlayer
{

View File

@ -15,7 +15,7 @@
#include "../interface/Window.h"
#include "../localisation/Localisation.h"
#include "../platform/Platform.h"
#include "../title/TitleScreen.h"
#include "../scenes/title/TitleScene.h"
#include "zlib.h"
#include <algorithm>