mirror of https://github.com/OpenRCT2/OpenRCT2.git
Merge pull request #5106 from IntelOrca/refactor/use-scenario-repo
Refactor / use scenario repository as dependency
This commit is contained in:
commit
ef6fa35323
|
@ -152,7 +152,7 @@ extern "C"
|
|||
|
||||
IObjectRepository * objRepo = CreateObjectRepository(OpenRCT2::_env);
|
||||
ITrackDesignRepository * tdRepo = CreateTrackDesignRepository(OpenRCT2::_env);
|
||||
CreateScenarioRepository(OpenRCT2::_env);
|
||||
IScenarioRepository * scenarioRepo = CreateScenarioRepository(OpenRCT2::_env);
|
||||
|
||||
if (!language_open(gConfigGeneral.language))
|
||||
{
|
||||
|
@ -174,6 +174,7 @@ extern "C"
|
|||
// as its not required until the player wants to place a new ride.
|
||||
tdRepo->Scan();
|
||||
|
||||
scenarioRepo->Scan();
|
||||
TitleSequenceManager::Scan();
|
||||
|
||||
if (!gOpenRCT2Headless)
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
#include "../core/Console.hpp"
|
||||
#include "../network/network.h"
|
||||
#include "../OpenRCT2.h"
|
||||
#include "../scenario/ScenarioRepository.h"
|
||||
#include "TitleScreen.h"
|
||||
#include "TitleSequence.h"
|
||||
#include "TitleSequenceManager.h"
|
||||
|
@ -59,7 +60,8 @@ static void TitleInitialise()
|
|||
{
|
||||
if (_sequencePlayer == nullptr)
|
||||
{
|
||||
_sequencePlayer = CreateTitleSequencePlayer();
|
||||
IScenarioRepository * scenarioRepository = GetScenarioRepository();
|
||||
_sequencePlayer = CreateTitleSequencePlayer(scenarioRepository);
|
||||
}
|
||||
size_t seqId = title_sequence_manager_get_index_for_config_id(gConfigInterface.current_title_sequence_preset);
|
||||
if (seqId == SIZE_MAX)
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
#include <SDL.h>
|
||||
#include "../core/Console.hpp"
|
||||
#include "../core/Exception.hpp"
|
||||
#include "../core/Guard.hpp"
|
||||
#include "../core/Math.hpp"
|
||||
#include "../core/Path.hpp"
|
||||
#include "../core/String.hpp"
|
||||
|
@ -39,6 +40,10 @@ extern "C"
|
|||
class TitleSequencePlayer final : public ITitleSequencePlayer
|
||||
{
|
||||
private:
|
||||
static constexpr const char * SFMM_FILENAME = "Six Flags Magic Mountain.SC6";
|
||||
|
||||
IScenarioRepository * _scenarioRepository = nullptr;
|
||||
|
||||
uint32 _sequenceId = 0;
|
||||
TitleSequence * _sequence = nullptr;
|
||||
sint32 _position = 0;
|
||||
|
@ -49,6 +54,13 @@ private:
|
|||
rct_xy32 _viewCentreLocation = { 0 };
|
||||
|
||||
public:
|
||||
TitleSequencePlayer(IScenarioRepository * scenarioRepository)
|
||||
{
|
||||
Guard::ArgumentNotNull(scenarioRepository);
|
||||
|
||||
_scenarioRepository = scenarioRepository;
|
||||
}
|
||||
|
||||
~TitleSequencePlayer() override
|
||||
{
|
||||
Eject();
|
||||
|
@ -231,7 +243,14 @@ private:
|
|||
break;
|
||||
case TITLE_SCRIPT_LOADMM:
|
||||
{
|
||||
const utf8 * path = get_file_path(PATH_ID_SIXFLAGS_MAGICMOUNTAIN);
|
||||
const scenario_index_entry * entry = _scenarioRepository->GetByFilename(SFMM_FILENAME);
|
||||
if (entry == nullptr)
|
||||
{
|
||||
Console::Error::WriteLine("%s not found.", SFMM_FILENAME);
|
||||
return false;
|
||||
}
|
||||
|
||||
const utf8 * path = entry->path;
|
||||
if (!LoadParkFromFile(path))
|
||||
{
|
||||
Console::Error::WriteLine("Failed to load: \"%s\" for the title sequence.", path);
|
||||
|
@ -289,11 +308,10 @@ private:
|
|||
}
|
||||
|
||||
const utf8 * path = nullptr;
|
||||
IScenarioRepository * scenarioRepo = GetScenarioRepository();
|
||||
size_t numScenarios = scenarioRepo->GetCount();
|
||||
size_t numScenarios = _scenarioRepository->GetCount();
|
||||
for (size_t i = 0; i < numScenarios; i++)
|
||||
{
|
||||
const scenario_index_entry * scenario = scenarioRepo->GetByIndex(i);
|
||||
const scenario_index_entry * scenario = _scenarioRepository->GetByIndex(i);
|
||||
if (scenario->source_index == sourceDesc.index)
|
||||
{
|
||||
path = scenario->path;
|
||||
|
@ -432,9 +450,9 @@ private:
|
|||
}
|
||||
};
|
||||
|
||||
ITitleSequencePlayer * CreateTitleSequencePlayer()
|
||||
ITitleSequencePlayer * CreateTitleSequencePlayer(IScenarioRepository * scenarioRepository)
|
||||
{
|
||||
return new TitleSequencePlayer();
|
||||
return new TitleSequencePlayer(scenarioRepository);
|
||||
}
|
||||
|
||||
extern "C"
|
||||
|
|
|
@ -20,6 +20,8 @@
|
|||
|
||||
#ifdef __cplusplus
|
||||
|
||||
interface IScenarioRepository;
|
||||
|
||||
interface ITitleSequencePlayer
|
||||
{
|
||||
virtual ~ITitleSequencePlayer() = default;
|
||||
|
@ -33,7 +35,7 @@ interface ITitleSequencePlayer
|
|||
virtual void Eject() abstract;
|
||||
};
|
||||
|
||||
ITitleSequencePlayer * CreateTitleSequencePlayer();
|
||||
ITitleSequencePlayer * CreateTitleSequencePlayer(IScenarioRepository * scenarioRepository);
|
||||
|
||||
#else
|
||||
|
||||
|
|
Loading…
Reference in New Issue