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 "../core/Console.hpp"
|
||||||
#include "../network/network.h"
|
#include "../network/network.h"
|
||||||
#include "../OpenRCT2.h"
|
#include "../OpenRCT2.h"
|
||||||
|
#include "../scenario/ScenarioRepository.h"
|
||||||
#include "TitleScreen.h"
|
#include "TitleScreen.h"
|
||||||
#include "TitleSequence.h"
|
#include "TitleSequence.h"
|
||||||
#include "TitleSequenceManager.h"
|
#include "TitleSequenceManager.h"
|
||||||
|
@ -59,7 +60,8 @@ static void TitleInitialise()
|
||||||
{
|
{
|
||||||
if (_sequencePlayer == nullptr)
|
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);
|
size_t seqId = title_sequence_manager_get_index_for_config_id(gConfigInterface.current_title_sequence_preset);
|
||||||
if (seqId == SIZE_MAX)
|
if (seqId == SIZE_MAX)
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
#include <SDL.h>
|
#include <SDL.h>
|
||||||
#include "../core/Console.hpp"
|
#include "../core/Console.hpp"
|
||||||
#include "../core/Exception.hpp"
|
#include "../core/Exception.hpp"
|
||||||
|
#include "../core/Guard.hpp"
|
||||||
#include "../core/Math.hpp"
|
#include "../core/Math.hpp"
|
||||||
#include "../core/Path.hpp"
|
#include "../core/Path.hpp"
|
||||||
#include "../core/String.hpp"
|
#include "../core/String.hpp"
|
||||||
|
@ -41,6 +42,8 @@ class TitleSequencePlayer final : public ITitleSequencePlayer
|
||||||
private:
|
private:
|
||||||
static constexpr const char * SFMM_FILENAME = "Six Flags Magic Mountain.SC6";
|
static constexpr const char * SFMM_FILENAME = "Six Flags Magic Mountain.SC6";
|
||||||
|
|
||||||
|
IScenarioRepository * _scenarioRepository = nullptr;
|
||||||
|
|
||||||
uint32 _sequenceId = 0;
|
uint32 _sequenceId = 0;
|
||||||
TitleSequence * _sequence = nullptr;
|
TitleSequence * _sequence = nullptr;
|
||||||
sint32 _position = 0;
|
sint32 _position = 0;
|
||||||
|
@ -51,6 +54,13 @@ private:
|
||||||
rct_xy32 _viewCentreLocation = { 0 };
|
rct_xy32 _viewCentreLocation = { 0 };
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
TitleSequencePlayer(IScenarioRepository * scenarioRepository)
|
||||||
|
{
|
||||||
|
Guard::ArgumentNotNull(scenarioRepository);
|
||||||
|
|
||||||
|
_scenarioRepository = scenarioRepository;
|
||||||
|
}
|
||||||
|
|
||||||
~TitleSequencePlayer() override
|
~TitleSequencePlayer() override
|
||||||
{
|
{
|
||||||
Eject();
|
Eject();
|
||||||
|
@ -233,8 +243,7 @@ private:
|
||||||
break;
|
break;
|
||||||
case TITLE_SCRIPT_LOADMM:
|
case TITLE_SCRIPT_LOADMM:
|
||||||
{
|
{
|
||||||
IScenarioRepository * scenarioRepo = GetScenarioRepository();
|
const scenario_index_entry * entry = _scenarioRepository->GetByFilename(SFMM_FILENAME);
|
||||||
const scenario_index_entry * entry = scenarioRepo->GetByFilename(SFMM_FILENAME);
|
|
||||||
if (entry == nullptr)
|
if (entry == nullptr)
|
||||||
{
|
{
|
||||||
Console::Error::WriteLine("%s not found.", SFMM_FILENAME);
|
Console::Error::WriteLine("%s not found.", SFMM_FILENAME);
|
||||||
|
@ -299,11 +308,10 @@ private:
|
||||||
}
|
}
|
||||||
|
|
||||||
const utf8 * path = nullptr;
|
const utf8 * path = nullptr;
|
||||||
IScenarioRepository * scenarioRepo = GetScenarioRepository();
|
size_t numScenarios = _scenarioRepository->GetCount();
|
||||||
size_t numScenarios = scenarioRepo->GetCount();
|
|
||||||
for (size_t i = 0; i < numScenarios; i++)
|
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)
|
if (scenario->source_index == sourceDesc.index)
|
||||||
{
|
{
|
||||||
path = scenario->path;
|
path = scenario->path;
|
||||||
|
@ -442,9 +450,9 @@ private:
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
ITitleSequencePlayer * CreateTitleSequencePlayer()
|
ITitleSequencePlayer * CreateTitleSequencePlayer(IScenarioRepository * scenarioRepository)
|
||||||
{
|
{
|
||||||
return new TitleSequencePlayer();
|
return new TitleSequencePlayer(scenarioRepository);
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C"
|
extern "C"
|
||||||
|
|
|
@ -20,6 +20,8 @@
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|
||||||
|
interface IScenarioRepository;
|
||||||
|
|
||||||
interface ITitleSequencePlayer
|
interface ITitleSequencePlayer
|
||||||
{
|
{
|
||||||
virtual ~ITitleSequencePlayer() = default;
|
virtual ~ITitleSequencePlayer() = default;
|
||||||
|
@ -33,7 +35,7 @@ interface ITitleSequencePlayer
|
||||||
virtual void Eject() abstract;
|
virtual void Eject() abstract;
|
||||||
};
|
};
|
||||||
|
|
||||||
ITitleSequencePlayer * CreateTitleSequencePlayer();
|
ITitleSequencePlayer * CreateTitleSequencePlayer(IScenarioRepository * scenarioRepository);
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue