mirror of https://github.com/OpenRCT2/OpenRCT2.git
Introduce Scene class and handling
Co-authored-by: ζeh Matt <5415177+ZehMatt@users.noreply.github.com>
This commit is contained in:
parent
be9f1a2072
commit
49b75e6606
|
@ -66,6 +66,7 @@
|
||||||
#include "ride/TrackDesignRepository.h"
|
#include "ride/TrackDesignRepository.h"
|
||||||
#include "scenario/Scenario.h"
|
#include "scenario/Scenario.h"
|
||||||
#include "scenario/ScenarioRepository.h"
|
#include "scenario/ScenarioRepository.h"
|
||||||
|
#include "scenes/Scene.h"
|
||||||
#include "scripting/HookEngine.h"
|
#include "scripting/HookEngine.h"
|
||||||
#include "scripting/ScriptEngine.h"
|
#include "scripting/ScriptEngine.h"
|
||||||
#include "title/TitleScreen.h"
|
#include "title/TitleScreen.h"
|
||||||
|
@ -122,6 +123,9 @@ namespace OpenRCT2
|
||||||
NetworkBase _network;
|
NetworkBase _network;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// Scenes
|
||||||
|
IScene* _activeScene = nullptr;
|
||||||
|
|
||||||
// Game states
|
// Game states
|
||||||
std::unique_ptr<TitleScreen> _titleScreen;
|
std::unique_ptr<TitleScreen> _titleScreen;
|
||||||
|
|
||||||
|
@ -305,6 +309,20 @@ namespace OpenRCT2
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
virtual 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
|
void WriteLine(const std::string& s) override
|
||||||
{
|
{
|
||||||
_stdInOutConsole.WriteLine(s);
|
_stdInOutConsole.WriteLine(s);
|
||||||
|
|
|
@ -84,6 +84,7 @@ namespace OpenRCT2
|
||||||
|
|
||||||
struct IPlatformEnvironment;
|
struct IPlatformEnvironment;
|
||||||
struct IReplayManager;
|
struct IReplayManager;
|
||||||
|
struct IScene;
|
||||||
|
|
||||||
namespace Audio
|
namespace Audio
|
||||||
{
|
{
|
||||||
|
@ -142,6 +143,10 @@ namespace OpenRCT2
|
||||||
#ifndef DISABLE_NETWORK
|
#ifndef DISABLE_NETWORK
|
||||||
virtual NetworkBase& GetNetwork() abstract;
|
virtual NetworkBase& GetNetwork() abstract;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
virtual IScene* GetActiveScene() abstract;
|
||||||
|
virtual void SetActiveScene(IScene * screen) abstract;
|
||||||
|
|
||||||
virtual int32_t RunOpenRCT2(int argc, const char** argv) abstract;
|
virtual int32_t RunOpenRCT2(int argc, const char** argv) abstract;
|
||||||
|
|
||||||
virtual bool Initialise() abstract;
|
virtual bool Initialise() abstract;
|
||||||
|
|
|
@ -511,6 +511,7 @@
|
||||||
<ClInclude Include="scenario\Scenario.h" />
|
<ClInclude Include="scenario\Scenario.h" />
|
||||||
<ClInclude Include="scenario\ScenarioRepository.h" />
|
<ClInclude Include="scenario\ScenarioRepository.h" />
|
||||||
<ClInclude Include="scenario\ScenarioSources.h" />
|
<ClInclude Include="scenario\ScenarioSources.h" />
|
||||||
|
<ClInclude Include="scenes\Scene.h" />
|
||||||
<ClInclude Include="scripting\bindings\entity\ScGuest.hpp" />
|
<ClInclude Include="scripting\bindings\entity\ScGuest.hpp" />
|
||||||
<ClInclude Include="scripting\bindings\entity\ScLitter.hpp" />
|
<ClInclude Include="scripting\bindings\entity\ScLitter.hpp" />
|
||||||
<ClInclude Include="scripting\bindings\entity\ScPeep.hpp" />
|
<ClInclude Include="scripting\bindings\entity\ScPeep.hpp" />
|
||||||
|
@ -999,6 +1000,7 @@
|
||||||
<ClCompile Include="scenario\Scenario.cpp" />
|
<ClCompile Include="scenario\Scenario.cpp" />
|
||||||
<ClCompile Include="scenario\ScenarioRepository.cpp" />
|
<ClCompile Include="scenario\ScenarioRepository.cpp" />
|
||||||
<ClCompile Include="scenario\ScenarioSources.cpp" />
|
<ClCompile Include="scenario\ScenarioSources.cpp" />
|
||||||
|
<ClCompile Include="scenes\Scene.cpp" />
|
||||||
<ClCompile Include="scripting\bindings\entity\ScGuest.cpp" />
|
<ClCompile Include="scripting\bindings\entity\ScGuest.cpp" />
|
||||||
<ClCompile Include="scripting\bindings\entity\ScLitter.cpp" />
|
<ClCompile Include="scripting\bindings\entity\ScLitter.cpp" />
|
||||||
<ClCompile Include="scripting\bindings\entity\ScStaff.cpp" />
|
<ClCompile Include="scripting\bindings\entity\ScStaff.cpp" />
|
||||||
|
|
|
@ -0,0 +1,30 @@
|
||||||
|
/*****************************************************************************
|
||||||
|
* 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 "Scene.h"
|
||||||
|
|
||||||
|
#include "../Context.h"
|
||||||
|
#include "../GameState.h"
|
||||||
|
|
||||||
|
using namespace OpenRCT2;
|
||||||
|
|
||||||
|
Scene::Scene(IContext& context)
|
||||||
|
: _context(context)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
IContext& Scene::GetContext()
|
||||||
|
{
|
||||||
|
return _context;
|
||||||
|
}
|
||||||
|
|
||||||
|
GameState_t& Scene::GetGameState()
|
||||||
|
{
|
||||||
|
return OpenRCT2::GetGameState();
|
||||||
|
}
|
|
@ -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 Update() = 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
|
Loading…
Reference in New Issue