Refactor TitleScreen to TitleScene; introduce GameScene

Co-authored-by: ζeh Matt <5415177+ZehMatt@users.noreply.github.com>
This commit is contained in:
Aaron van Geffen 2024-04-23 21:31:05 +02:00
parent 49b75e6606
commit 255e89ec37
44 changed files with 323 additions and 226 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

@ -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

@ -66,11 +66,11 @@
#include "ride/TrackDesignRepository.h"
#include "scenario/Scenario.h"
#include "scenario/ScenarioRepository.h"
#include "scenes/Scene.h"
#include "scenes/game/GameScene.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"
@ -124,11 +124,10 @@ namespace OpenRCT2
#endif
// Scenes
std::unique_ptr<TitleScene> _titleScene;
std::unique_ptr<GameScene> _gameScene;
IScene* _activeScene = nullptr;
// Game states
std::unique_ptr<TitleScreen> _titleScreen;
DrawingEngine _drawingEngineType = DrawingEngine::Software;
std::unique_ptr<IDrawingEngine> _drawingEngine;
std::unique_ptr<Painter> _painter;
@ -175,7 +174,8 @@ namespace OpenRCT2
#ifndef DISABLE_NETWORK
, _network(*this)
#endif
, _titleScreen(std::make_unique<TitleScreen>())
, _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.
@ -309,7 +309,35 @@ namespace OpenRCT2
return EXIT_FAILURE;
}
virtual IScene* GetActiveScene() override
IScene* GetLoadingScene() override
{
// TODO: Implement me.
return nullptr;
}
IScene* GetIntroScene() override
{
// TODO: Implement me.
return nullptr;
}
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;
}
@ -610,7 +638,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, {});
@ -746,7 +774,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
@ -765,7 +793,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, {});
@ -776,7 +804,7 @@ namespace OpenRCT2
if (loadTitleScreenFirstOnFail)
{
TitleLoad();
SetActiveScene(GetTitleScene());
}
auto windowManager = _uiContext->GetWindowManager();
Formatter ft;
@ -807,7 +835,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());
}
@ -910,10 +938,10 @@ namespace OpenRCT2
{
case StartupAction::Intro:
gIntroState = IntroState::PublisherBegin;
TitleLoad();
SetActiveScene(GetTitleScene());
break;
case StartupAction::Title:
TitleLoad();
SetActiveScene(GetTitleScene());
break;
case StartupAction::Open:
{
@ -926,7 +954,7 @@ namespace OpenRCT2
auto data = DownloadPark(gOpenRCT2StartupActionPath);
if (data.empty())
{
TitleLoad();
SetActiveScene(GetTitleScene());
break;
}
@ -934,7 +962,7 @@ namespace OpenRCT2
if (!LoadParkFromStream(&ms, gOpenRCT2StartupActionPath, true))
{
Console::Error::WriteLine("Failed to load '%s'", gOpenRCT2StartupActionPath);
TitleLoad();
SetActiveScene(GetTitleScene());
break;
}
#endif
@ -952,12 +980,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)
@ -997,7 +1025,7 @@ namespace OpenRCT2
}
else if (!Editor::LoadLandscape(gOpenRCT2StartupActionPath))
{
TitleLoad();
SetActiveScene(GetTitleScene());
}
break;
default:
@ -1201,18 +1229,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

@ -144,8 +144,14 @@ namespace OpenRCT2
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 void SetActiveScene(IScene* screen) abstract;
virtual int32_t RunOpenRCT2(int argc, const char** argv) 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

@ -512,6 +512,21 @@
<ClInclude Include="scenario\ScenarioRepository.h" />
<ClInclude Include="scenario\ScenarioSources.h" />
<ClInclude Include="scenes\Scene.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" />
@ -552,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" />
@ -1001,6 +1002,20 @@
<ClCompile Include="scenario\ScenarioRepository.cpp" />
<ClCompile Include="scenario\ScenarioSources.cpp" />
<ClCompile Include="scenes\Scene.cpp" />
<ClCompile Include="scenes\game\GameScene.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" />
@ -1022,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

@ -24,7 +24,7 @@
#include "../localisation/Language.h"
#include "../paint/Paint.h"
#include "../profiling/Profiling.h"
#include "../title/TitleScreen.h"
#include "../scenes/title/TitleScene.h"
#include "../ui/UiContext.h"
#include "../world/TileInspector.h"

View File

@ -25,7 +25,7 @@ namespace OpenRCT2
virtual IContext& GetContext() = 0;
virtual void Load() = 0;
virtual void Update() = 0;
virtual void Tick() = 0;
virtual void Stop() = 0;
};

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,27 @@
/*****************************************************************************
* 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 "../../drawing/Drawing.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

@ -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>