mirror of https://github.com/OpenRCT2/OpenRCT2.git
Pass scenario repository dependency to TitleSequencePlayer
This commit is contained in:
parent
d5f2ea814a
commit
e36dc622ad
|
@ -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"
|
||||
|
@ -41,6 +42,8 @@ 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;
|
||||
|
@ -51,6 +54,13 @@ private:
|
|||
rct_xy32 _viewCentreLocation = { 0 };
|
||||
|
||||
public:
|
||||
TitleSequencePlayer(IScenarioRepository * scenarioRepository)
|
||||
{
|
||||
Guard::ArgumentNotNull(scenarioRepository);
|
||||
|
||||
_scenarioRepository = scenarioRepository;
|
||||
}
|
||||
|
||||
~TitleSequencePlayer() override
|
||||
{
|
||||
Eject();
|
||||
|
@ -233,8 +243,7 @@ private:
|
|||
break;
|
||||
case TITLE_SCRIPT_LOADMM:
|
||||
{
|
||||
IScenarioRepository * scenarioRepo = GetScenarioRepository();
|
||||
const scenario_index_entry * entry = scenarioRepo->GetByFilename(SFMM_FILENAME);
|
||||
const scenario_index_entry * entry = _scenarioRepository->GetByFilename(SFMM_FILENAME);
|
||||
if (entry == nullptr)
|
||||
{
|
||||
Console::Error::WriteLine("%s not found.", SFMM_FILENAME);
|
||||
|
@ -299,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;
|
||||
|
@ -442,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