OpenRCT2/src/openrct2/scenario/ScenarioRepository.h

102 lines
2.8 KiB
C
Raw Normal View History

2016-10-12 13:36:30 +02:00
/*****************************************************************************
* Copyright (c) 2014-2023 OpenRCT2 developers
2016-10-12 13:36:30 +02:00
*
* For a complete list of all authors, please refer to contributors.md
* Interested in contributing? Visit https://github.com/OpenRCT2/OpenRCT2
2016-10-12 13:36:30 +02:00
*
* OpenRCT2 is licensed under the GNU General Public License version 3.
2016-10-12 13:36:30 +02:00
*****************************************************************************/
#pragma once
2016-12-14 13:13:52 +01:00
#include "../common.h"
#include "../core/String.hpp"
#include "../scenario/Scenario.h"
2016-10-12 13:36:30 +02:00
2018-06-22 23:14:50 +02:00
#include <memory>
struct RCTObjectEntry;
2016-10-12 13:36:30 +02:00
struct ScenarioHighscoreEntry
2016-10-12 13:36:30 +02:00
{
u8string fileName;
u8string name;
2023-02-16 21:48:21 +01:00
money64 company_value{};
datetime64 timestamp{};
};
2016-10-12 13:36:30 +02:00
enum class ScenarioSource : uint8_t
{
RCT1,
RCT1_AA,
RCT1_LL,
RCT2,
RCT2_WW,
RCT2_TT,
UCES,
Real,
Extras,
Other
};
struct ScenarioIndexEntry
2016-10-12 13:36:30 +02:00
{
utf8 Path[MAX_PATH];
uint64_t Timestamp;
2016-10-12 13:36:30 +02:00
// Category / sequence
uint8_t Category;
ScenarioSource SourceGame;
int16_t SourceIndex = -1;
uint16_t ScenarioId;
2016-10-12 13:36:30 +02:00
// Objective
uint8_t ObjectiveType;
uint8_t ObjectiveArg1;
int64_t ObjectiveArg2;
int16_t ObjectiveArg3;
ScenarioHighscoreEntry* Highscore = nullptr;
utf8 InternalName[64]; // Untranslated name
utf8 Name[64]; // Translated name
utf8 Details[256];
};
2016-10-12 13:36:30 +02:00
2017-06-11 13:53:37 +02:00
namespace OpenRCT2
{
struct IPlatformEnvironment;
2017-06-11 13:53:37 +02:00
}
struct IScenarioRepository
2016-10-12 13:36:30 +02:00
{
virtual ~IScenarioRepository() = default;
/**
* Scans the scenario directories and grabs the metadata for all the scenarios.
*/
virtual void Scan(int32_t language) abstract;
2016-10-12 13:36:30 +02:00
virtual size_t GetCount() const abstract;
virtual const ScenarioIndexEntry* GetByIndex(size_t index) const abstract;
virtual const ScenarioIndexEntry* GetByFilename(u8string_view filename) const abstract;
2018-06-22 23:14:50 +02:00
/**
* Does not return custom scenarios due to the fact that they may have the same name.
*/
virtual const ScenarioIndexEntry* GetByInternalName(const utf8* name) const abstract;
virtual const ScenarioIndexEntry* GetByPath(const utf8* path) const abstract;
2018-06-22 23:14:50 +02:00
virtual bool TryRecordHighscore(
int32_t language, const utf8* scenarioFileName, money64 companyValue, const utf8* name) abstract;
2016-10-12 13:36:30 +02:00
};
[[nodiscard]] std::unique_ptr<IScenarioRepository> CreateScenarioRepository(
const std::shared_ptr<OpenRCT2::IPlatformEnvironment>& env);
[[nodiscard]] IScenarioRepository* GetScenarioRepository();
2016-10-12 13:36:30 +02:00
void ScenarioRepositoryScan();
[[nodiscard]] size_t ScenarioRepositoryGetCount();
[[nodiscard]] const ScenarioIndexEntry* ScenarioRepositoryGetByIndex(size_t index);
[[nodiscard]] bool ScenarioRepositoryTryRecordHighscore(const utf8* scenarioFileName, money64 companyValue, const utf8* name);
void ScenarioTranslate(ScenarioIndexEntry* scenarioEntry);