2016-11-12 18:12:11 +01:00
|
|
|
/*****************************************************************************
|
2019-03-17 08:16:15 +01:00
|
|
|
* Copyright (c) 2014-2019 OpenRCT2 developers
|
2016-11-12 18:12:11 +01:00
|
|
|
*
|
2018-06-15 14:07:34 +02:00
|
|
|
* For a complete list of all authors, please refer to contributors.md
|
|
|
|
* Interested in contributing? Visit https://github.com/OpenRCT2/OpenRCT2
|
2016-11-12 18:12:11 +01:00
|
|
|
*
|
2018-06-15 14:07:34 +02:00
|
|
|
* OpenRCT2 is licensed under the GNU General Public License version 3.
|
2016-11-12 18:12:11 +01:00
|
|
|
*****************************************************************************/
|
|
|
|
|
2018-06-22 23:15:14 +02:00
|
|
|
#include "TitleSequenceManager.h"
|
|
|
|
|
2020-04-30 18:50:26 +02:00
|
|
|
#include "../Context.h"
|
2018-06-22 23:15:14 +02:00
|
|
|
#include "../OpenRCT2.h"
|
2020-04-30 18:50:26 +02:00
|
|
|
#include "../PlatformEnvironment.h"
|
2016-11-29 14:22:11 +01:00
|
|
|
#include "../core/Collections.hpp"
|
2016-11-12 18:12:11 +01:00
|
|
|
#include "../core/FileScanner.h"
|
|
|
|
#include "../core/Memory.hpp"
|
|
|
|
#include "../core/Path.hpp"
|
|
|
|
#include "../core/String.hpp"
|
2018-01-06 18:32:25 +01:00
|
|
|
#include "../localisation/Localisation.h"
|
2017-09-18 17:05:28 +02:00
|
|
|
#include "../platform/platform.h"
|
2018-06-22 23:15:14 +02:00
|
|
|
#include "TitleSequence.h"
|
|
|
|
|
|
|
|
#include <algorithm>
|
2018-11-21 23:16:04 +01:00
|
|
|
#include <iterator>
|
2018-06-22 23:15:14 +02:00
|
|
|
#include <vector>
|
2016-11-12 18:12:11 +01:00
|
|
|
|
|
|
|
namespace TitleSequenceManager
|
|
|
|
{
|
|
|
|
struct PredefinedSequence
|
|
|
|
{
|
2018-06-22 23:15:14 +02:00
|
|
|
const utf8* ConfigId;
|
|
|
|
const utf8* Filename;
|
2016-11-12 18:12:11 +01:00
|
|
|
rct_string_id StringId;
|
|
|
|
};
|
|
|
|
|
2018-06-22 23:15:14 +02:00
|
|
|
const PredefinedSequence PredefinedSequences[] = {
|
|
|
|
{ "*RCT1", "rct1.parkseq", STR_TITLE_SEQUENCE_RCT1 },
|
|
|
|
{ "*RCT1AA", "rct1aa.parkseq", STR_TITLE_SEQUENCE_RCT1_AA },
|
|
|
|
{ "*RCT1AALL", "rct1aall.parkseq", STR_TITLE_SEQUENCE_RCT1_AA_LL },
|
|
|
|
{ "*RCT2", "rct2.parkseq", STR_TITLE_SEQUENCE_RCT2 },
|
|
|
|
{ "*OPENRCT2", "openrct2.parkseq", STR_TITLE_SEQUENCE_OPENRCT2 },
|
2016-11-12 18:12:11 +01:00
|
|
|
};
|
|
|
|
|
2017-10-09 17:13:14 +02:00
|
|
|
static std::vector<TitleSequenceManagerItem> _items;
|
2016-11-12 18:12:11 +01:00
|
|
|
|
2018-06-22 23:15:14 +02:00
|
|
|
static std::string GetNewTitleSequencePath(const std::string& name, bool isZip);
|
|
|
|
static size_t FindItemIndexByPath(const utf8* path);
|
|
|
|
static void Scan(const utf8* directory);
|
|
|
|
static void AddSequence(const utf8* scanPath);
|
2016-11-29 14:22:11 +01:00
|
|
|
static void SortSequences();
|
2018-06-22 23:15:14 +02:00
|
|
|
static std::string GetNameFromSequencePath(const std::string& path);
|
2020-04-30 18:50:26 +02:00
|
|
|
static std::string GetDataSequencesPath();
|
|
|
|
static std::string GetUserSequencesPath();
|
2018-06-22 23:15:14 +02:00
|
|
|
static bool IsNameReserved(const std::string& name);
|
2016-11-12 18:12:11 +01:00
|
|
|
|
|
|
|
size_t GetCount()
|
|
|
|
{
|
|
|
|
return _items.size();
|
|
|
|
}
|
|
|
|
|
2018-06-22 23:15:14 +02:00
|
|
|
const TitleSequenceManagerItem* GetItem(size_t i)
|
2016-11-12 18:12:11 +01:00
|
|
|
{
|
2017-02-15 22:10:53 +01:00
|
|
|
if (i >= _items.size())
|
|
|
|
{
|
|
|
|
return nullptr;
|
|
|
|
}
|
2016-11-12 18:12:11 +01:00
|
|
|
return &_items[i];
|
|
|
|
}
|
|
|
|
|
2018-06-22 23:15:14 +02:00
|
|
|
static size_t FindItemIndexByPath(const utf8* path)
|
2016-11-29 14:22:11 +01:00
|
|
|
{
|
2018-06-22 23:15:14 +02:00
|
|
|
size_t index = Collections::IndexOf(
|
|
|
|
_items, [path](const TitleSequenceManagerItem& item) -> bool { return String::Equals(path, item.Path.c_str()); });
|
2016-11-29 14:22:11 +01:00
|
|
|
return index;
|
|
|
|
}
|
|
|
|
|
2016-11-27 17:16:17 +01:00
|
|
|
void DeleteItem(size_t i)
|
|
|
|
{
|
|
|
|
auto item = GetItem(i);
|
2017-01-28 22:13:36 +01:00
|
|
|
if (item == nullptr)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
2018-06-22 23:15:14 +02:00
|
|
|
const utf8* path = item->Path.c_str();
|
2016-11-27 17:16:17 +01:00
|
|
|
if (item->IsZip)
|
|
|
|
{
|
|
|
|
platform_file_delete(path);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
platform_directory_delete(path);
|
|
|
|
}
|
|
|
|
_items.erase(_items.begin() + i);
|
|
|
|
}
|
|
|
|
|
2018-06-22 23:15:14 +02:00
|
|
|
size_t RenameItem(size_t i, const utf8* newName)
|
2016-11-27 17:16:17 +01:00
|
|
|
{
|
|
|
|
auto item = &_items[i];
|
2018-06-22 23:15:14 +02:00
|
|
|
const utf8* oldPath = item->Path.c_str();
|
2016-11-27 17:16:17 +01:00
|
|
|
|
|
|
|
utf8 newPath[MAX_PATH];
|
|
|
|
Path::GetDirectory(newPath, sizeof(newPath), oldPath);
|
|
|
|
Path::Append(newPath, sizeof(newPath), newName);
|
|
|
|
if (item->IsZip)
|
|
|
|
{
|
|
|
|
String::Append(newPath, sizeof(newPath), TITLE_SEQUENCE_EXTENSION);
|
|
|
|
platform_file_move(oldPath, newPath);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
platform_file_move(oldPath, newPath);
|
|
|
|
}
|
|
|
|
|
|
|
|
item->Name = std::string(newName);
|
|
|
|
item->Path = std::string(newPath);
|
2016-11-29 14:22:11 +01:00
|
|
|
|
|
|
|
SortSequences();
|
|
|
|
size_t index = FindItemIndexByPath(newPath);
|
|
|
|
return index;
|
|
|
|
}
|
|
|
|
|
2018-06-22 23:15:14 +02:00
|
|
|
size_t DuplicateItem(size_t i, const utf8* name)
|
2016-11-29 14:22:11 +01:00
|
|
|
{
|
|
|
|
auto item = &_items[i];
|
2018-06-22 23:15:14 +02:00
|
|
|
const utf8* srcPath = item->Path.c_str();
|
2016-11-29 14:22:11 +01:00
|
|
|
|
2016-12-05 00:51:34 +01:00
|
|
|
std::string dstPath = GetNewTitleSequencePath(std::string(name), item->IsZip);
|
|
|
|
if (!platform_file_copy(srcPath, dstPath.c_str(), true))
|
2016-11-29 14:22:11 +01:00
|
|
|
{
|
|
|
|
return SIZE_MAX;
|
|
|
|
}
|
|
|
|
|
2016-12-05 00:51:34 +01:00
|
|
|
AddSequence(dstPath.c_str());
|
2016-11-29 14:22:11 +01:00
|
|
|
SortSequences();
|
2016-12-05 00:51:34 +01:00
|
|
|
size_t index = FindItemIndexByPath(dstPath.c_str());
|
2016-11-29 14:22:11 +01:00
|
|
|
return index;
|
2016-11-27 17:16:17 +01:00
|
|
|
}
|
|
|
|
|
2018-06-22 23:15:14 +02:00
|
|
|
size_t CreateItem(const utf8* name)
|
2016-11-29 14:42:24 +01:00
|
|
|
{
|
2016-12-05 00:51:34 +01:00
|
|
|
std::string path = GetNewTitleSequencePath(std::string(name), true);
|
2018-06-22 23:15:14 +02:00
|
|
|
TitleSequence* seq = CreateTitleSequence();
|
2016-11-29 14:42:24 +01:00
|
|
|
seq->Name = String::Duplicate(name);
|
2016-12-05 00:51:34 +01:00
|
|
|
seq->Path = String::Duplicate(path.c_str());
|
2016-11-29 14:42:24 +01:00
|
|
|
seq->IsZip = true;
|
|
|
|
|
2017-10-14 23:56:09 +02:00
|
|
|
bool success = TitleSequenceSave(seq);
|
2016-11-29 14:42:24 +01:00
|
|
|
FreeTitleSequence(seq);
|
|
|
|
|
|
|
|
size_t index = SIZE_MAX;
|
|
|
|
if (success)
|
|
|
|
{
|
2016-12-05 00:51:34 +01:00
|
|
|
AddSequence(path.c_str());
|
2016-11-29 14:42:24 +01:00
|
|
|
SortSequences();
|
2016-12-05 00:51:34 +01:00
|
|
|
index = FindItemIndexByPath(path.c_str());
|
2016-11-29 14:42:24 +01:00
|
|
|
}
|
2016-11-29 18:54:57 +01:00
|
|
|
return index;
|
2016-11-29 14:42:24 +01:00
|
|
|
}
|
|
|
|
|
2018-06-22 23:15:14 +02:00
|
|
|
static std::string GetNewTitleSequencePath(const std::string& name, bool isZip)
|
2016-12-05 00:51:34 +01:00
|
|
|
{
|
2020-04-30 18:50:26 +02:00
|
|
|
auto path = Path::Combine(GetUserSequencesPath(), name);
|
2016-12-05 00:51:34 +01:00
|
|
|
if (isZip)
|
|
|
|
{
|
2020-04-30 18:50:26 +02:00
|
|
|
path = Path::Combine(path, TITLE_SEQUENCE_EXTENSION);
|
2016-12-05 00:51:34 +01:00
|
|
|
}
|
2020-04-30 18:50:26 +02:00
|
|
|
return path;
|
2016-12-05 00:51:34 +01:00
|
|
|
}
|
|
|
|
|
2018-06-22 23:15:14 +02:00
|
|
|
static size_t GetPredefinedIndex(const std::string& path)
|
2016-11-12 19:38:30 +01:00
|
|
|
{
|
2018-06-22 23:15:14 +02:00
|
|
|
const utf8* filename = Path::GetFileName(path.c_str());
|
2018-11-21 23:16:04 +01:00
|
|
|
for (size_t i = 0; i < std::size(PredefinedSequences); i++)
|
2016-11-12 19:38:30 +01:00
|
|
|
{
|
|
|
|
if (String::Equals(filename, PredefinedSequences[i].Filename, true))
|
|
|
|
{
|
|
|
|
return i;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return PREDEFINED_INDEX_CUSTOM;
|
|
|
|
}
|
|
|
|
|
2016-11-29 14:22:11 +01:00
|
|
|
static void SortSequences()
|
2016-11-12 18:12:11 +01:00
|
|
|
{
|
2016-11-12 19:53:01 +01:00
|
|
|
// Sort sequences by predefined index and then name
|
2018-06-22 23:15:14 +02:00
|
|
|
std::sort(
|
|
|
|
_items.begin(), _items.end(), [](const TitleSequenceManagerItem& a, const TitleSequenceManagerItem& b) -> bool {
|
|
|
|
if (a.PredefinedIndex < b.PredefinedIndex)
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else if (a.PredefinedIndex > b.PredefinedIndex)
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return _strcmpi(a.Name.c_str(), b.Name.c_str()) < 0;
|
|
|
|
});
|
2016-11-12 19:53:01 +01:00
|
|
|
}
|
|
|
|
|
2016-12-14 13:07:48 +01:00
|
|
|
void Scan()
|
2016-11-29 14:22:11 +01:00
|
|
|
{
|
|
|
|
_items.clear();
|
|
|
|
|
|
|
|
// Scan data path
|
2020-04-30 18:50:26 +02:00
|
|
|
auto path = GetDataSequencesPath();
|
|
|
|
Scan(path.c_str());
|
2016-11-29 14:22:11 +01:00
|
|
|
|
|
|
|
// Scan user path
|
2020-04-30 18:50:26 +02:00
|
|
|
path = GetUserSequencesPath();
|
|
|
|
Scan(path.c_str());
|
2016-11-29 14:22:11 +01:00
|
|
|
|
|
|
|
SortSequences();
|
|
|
|
}
|
|
|
|
|
2018-06-22 23:15:14 +02:00
|
|
|
static void Scan(const utf8* directory)
|
2016-11-12 19:53:01 +01:00
|
|
|
{
|
|
|
|
utf8 pattern[MAX_PATH];
|
|
|
|
String::Set(pattern, sizeof(pattern), directory);
|
2016-11-13 14:15:01 +01:00
|
|
|
Path::Append(pattern, sizeof(pattern), "script.txt;*.parkseq");
|
2016-11-12 19:53:01 +01:00
|
|
|
|
2018-06-22 23:15:14 +02:00
|
|
|
IFileScanner* fileScanner = Path::ScanDirectory(pattern, true);
|
2016-11-12 18:12:11 +01:00
|
|
|
while (fileScanner->Next())
|
|
|
|
{
|
2018-06-22 23:15:14 +02:00
|
|
|
const utf8* path = fileScanner->GetPath();
|
2016-11-29 14:22:11 +01:00
|
|
|
AddSequence(path);
|
2016-11-12 18:12:11 +01:00
|
|
|
}
|
|
|
|
delete fileScanner;
|
2016-11-12 19:38:30 +01:00
|
|
|
}
|
2016-11-12 18:12:11 +01:00
|
|
|
|
2018-06-22 23:15:14 +02:00
|
|
|
static void AddSequence(const utf8* scanPath)
|
2016-11-29 14:22:11 +01:00
|
|
|
{
|
2016-12-24 01:06:42 +01:00
|
|
|
TitleSequenceManagerItem item;
|
|
|
|
|
2016-11-29 14:22:11 +01:00
|
|
|
std::string path;
|
|
|
|
bool isZip = true;
|
|
|
|
if (String::Equals(Path::GetExtension(scanPath), ".txt", true))
|
|
|
|
{
|
|
|
|
// If we are given a .txt file, set the path to the containing directory
|
2018-06-22 23:15:14 +02:00
|
|
|
utf8* utf8Path = Path::GetDirectory(scanPath);
|
2016-12-19 23:44:17 +01:00
|
|
|
path = std::string(utf8Path);
|
|
|
|
Memory::Free(utf8Path);
|
2016-11-29 14:22:11 +01:00
|
|
|
isZip = false;
|
2016-12-24 01:06:42 +01:00
|
|
|
item.Name = Path::GetFileName(path.c_str());
|
2016-11-29 14:22:11 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
path = std::string(scanPath);
|
2016-12-24 01:06:42 +01:00
|
|
|
item.Name = GetNameFromSequencePath(path);
|
2016-11-29 14:22:11 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
item.PredefinedIndex = GetPredefinedIndex(path);
|
|
|
|
item.Path = path;
|
|
|
|
if (item.PredefinedIndex != PREDEFINED_INDEX_CUSTOM)
|
|
|
|
{
|
|
|
|
rct_string_id stringId = PredefinedSequences[item.PredefinedIndex].StringId;
|
2017-05-26 09:49:22 +02:00
|
|
|
item.Name = language_get_string(stringId);
|
2016-11-29 14:22:11 +01:00
|
|
|
}
|
2017-10-14 22:43:09 +02:00
|
|
|
else if (IsNameReserved(item.Name))
|
|
|
|
{
|
|
|
|
// Reserved names are not allowed because they map to the
|
|
|
|
// actual predefined names and also prevent editing
|
|
|
|
return;
|
|
|
|
}
|
2016-11-29 14:22:11 +01:00
|
|
|
item.IsZip = isZip;
|
|
|
|
_items.push_back(item);
|
|
|
|
}
|
|
|
|
|
2018-06-22 23:15:14 +02:00
|
|
|
static std::string GetNameFromSequencePath(const std::string& path)
|
2016-11-12 19:38:30 +01:00
|
|
|
{
|
2018-06-22 23:15:14 +02:00
|
|
|
utf8* name = Path::GetFileNameWithoutExtension(path.c_str());
|
2016-11-12 18:12:11 +01:00
|
|
|
std::string result = std::string(name);
|
|
|
|
Memory::Free(name);
|
|
|
|
return result;
|
|
|
|
}
|
2016-11-12 19:53:01 +01:00
|
|
|
|
2020-04-30 18:50:26 +02:00
|
|
|
static std::string GetDataSequencesPath()
|
2016-11-12 19:53:01 +01:00
|
|
|
{
|
2020-04-30 18:50:26 +02:00
|
|
|
auto env = OpenRCT2::GetContext()->GetPlatformEnvironment();
|
|
|
|
return env->GetDirectoryPath(OpenRCT2::DIRBASE::OPENRCT2, OpenRCT2::DIRID::SEQUENCE);
|
2016-11-12 19:53:01 +01:00
|
|
|
}
|
|
|
|
|
2020-04-30 18:50:26 +02:00
|
|
|
static std::string GetUserSequencesPath()
|
2016-11-12 19:53:01 +01:00
|
|
|
{
|
2020-04-30 18:50:26 +02:00
|
|
|
auto env = OpenRCT2::GetContext()->GetPlatformEnvironment();
|
|
|
|
return env->GetDirectoryPath(OpenRCT2::DIRBASE::USER, OpenRCT2::DIRID::SEQUENCE);
|
2016-11-12 19:53:01 +01:00
|
|
|
}
|
2017-10-14 22:43:09 +02:00
|
|
|
|
2018-06-22 23:15:14 +02:00
|
|
|
static bool IsNameReserved(const std::string& name)
|
2017-10-14 22:43:09 +02:00
|
|
|
{
|
2018-06-22 23:15:14 +02:00
|
|
|
for (const auto& pseq : TitleSequenceManager::PredefinedSequences)
|
2017-10-14 22:43:09 +02:00
|
|
|
{
|
2018-06-22 23:15:14 +02:00
|
|
|
const utf8* predefinedName = Path::GetFileNameWithoutExtension(pseq.Filename);
|
2017-10-14 22:43:09 +02:00
|
|
|
std::string reservedName = std::string(predefinedName);
|
|
|
|
Memory::Free(predefinedName);
|
|
|
|
if (String::Equals(name, reservedName, true))
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
2018-05-04 22:40:09 +02:00
|
|
|
} // namespace TitleSequenceManager
|
2016-11-12 18:12:11 +01:00
|
|
|
|
2018-02-01 18:49:14 +01:00
|
|
|
size_t title_sequence_manager_get_count()
|
2016-11-12 18:12:11 +01:00
|
|
|
{
|
2018-02-01 18:49:14 +01:00
|
|
|
return TitleSequenceManager::GetCount();
|
|
|
|
}
|
2016-11-12 18:12:11 +01:00
|
|
|
|
2018-06-22 23:15:14 +02:00
|
|
|
const utf8* title_sequence_manager_get_name(size_t index)
|
2018-02-01 18:49:14 +01:00
|
|
|
{
|
|
|
|
auto item = TitleSequenceManager::GetItem(index);
|
|
|
|
if (item == nullptr)
|
2016-11-12 18:12:11 +01:00
|
|
|
{
|
2018-02-01 18:49:14 +01:00
|
|
|
return nullptr;
|
2016-11-12 18:12:11 +01:00
|
|
|
}
|
2018-06-22 23:15:14 +02:00
|
|
|
const utf8* name = item->Name.c_str();
|
2018-02-01 18:49:14 +01:00
|
|
|
return name;
|
|
|
|
}
|
2016-11-12 18:12:11 +01:00
|
|
|
|
2018-06-22 23:15:14 +02:00
|
|
|
const utf8* title_sequence_manager_get_path(size_t index)
|
2018-02-01 18:49:14 +01:00
|
|
|
{
|
|
|
|
auto item = TitleSequenceManager::GetItem(index);
|
2018-06-22 23:15:14 +02:00
|
|
|
if (item == nullptr)
|
|
|
|
{
|
2018-02-01 18:49:14 +01:00
|
|
|
return nullptr;
|
2016-11-12 18:12:11 +01:00
|
|
|
}
|
2018-06-22 23:15:14 +02:00
|
|
|
const utf8* name = item->Path.c_str();
|
2018-02-01 18:49:14 +01:00
|
|
|
return name;
|
|
|
|
}
|
2016-11-12 18:12:11 +01:00
|
|
|
|
2018-06-22 23:15:14 +02:00
|
|
|
const utf8* title_sequence_manager_get_config_id(size_t index)
|
2018-02-01 18:49:14 +01:00
|
|
|
{
|
|
|
|
auto item = TitleSequenceManager::GetItem(index);
|
2018-06-22 23:15:14 +02:00
|
|
|
if (item == nullptr)
|
|
|
|
{
|
2018-02-01 18:49:14 +01:00
|
|
|
return nullptr;
|
|
|
|
}
|
2018-06-22 23:15:14 +02:00
|
|
|
const utf8* name = item->Name.c_str();
|
|
|
|
const utf8* filename = Path::GetFileName(item->Path.c_str());
|
|
|
|
for (const auto& pseq : TitleSequenceManager::PredefinedSequences)
|
2016-11-12 18:12:11 +01:00
|
|
|
{
|
2018-02-01 18:49:14 +01:00
|
|
|
if (String::Equals(filename, pseq.Filename, true))
|
2016-11-12 18:12:11 +01:00
|
|
|
{
|
2018-02-01 18:49:14 +01:00
|
|
|
return pseq.ConfigId;
|
2016-11-12 18:12:11 +01:00
|
|
|
}
|
|
|
|
}
|
2018-02-01 18:49:14 +01:00
|
|
|
return name;
|
|
|
|
}
|
2016-11-12 18:12:11 +01:00
|
|
|
|
2018-02-01 18:49:14 +01:00
|
|
|
size_t title_sequence_manager_get_predefined_index(size_t index)
|
|
|
|
{
|
|
|
|
auto item = TitleSequenceManager::GetItem(index);
|
2018-06-22 23:15:14 +02:00
|
|
|
if (item == nullptr)
|
|
|
|
{
|
2018-02-01 18:49:14 +01:00
|
|
|
return 0;
|
2016-11-27 15:47:02 +01:00
|
|
|
}
|
2018-02-01 18:49:14 +01:00
|
|
|
size_t predefinedIndex = item->PredefinedIndex;
|
|
|
|
return predefinedIndex;
|
|
|
|
}
|
2016-11-27 15:47:02 +01:00
|
|
|
|
2018-06-22 23:15:14 +02:00
|
|
|
size_t title_sequence_manager_get_index_for_config_id(const utf8* configId)
|
2018-02-01 18:49:14 +01:00
|
|
|
{
|
|
|
|
size_t count = TitleSequenceManager::GetCount();
|
|
|
|
for (size_t i = 0; i < count; i++)
|
2016-11-12 18:12:11 +01:00
|
|
|
{
|
2018-06-22 23:15:14 +02:00
|
|
|
const utf8* cid = title_sequence_manager_get_config_id(i);
|
2018-02-01 18:49:14 +01:00
|
|
|
if (String::Equals(cid, configId))
|
2016-11-12 18:12:11 +01:00
|
|
|
{
|
2018-02-01 18:49:14 +01:00
|
|
|
return i;
|
2016-11-12 18:12:11 +01:00
|
|
|
}
|
|
|
|
}
|
2018-02-01 18:49:14 +01:00
|
|
|
return SIZE_MAX;
|
|
|
|
}
|
2016-11-12 18:12:11 +01:00
|
|
|
|
2018-06-22 23:15:14 +02:00
|
|
|
size_t title_sequence_manager_get_index_for_name(const utf8* name)
|
2018-02-01 18:49:14 +01:00
|
|
|
{
|
|
|
|
size_t count = TitleSequenceManager::GetCount();
|
|
|
|
for (size_t i = 0; i < count; i++)
|
2016-11-27 17:16:17 +01:00
|
|
|
{
|
2018-06-22 23:15:14 +02:00
|
|
|
const utf8* tn = title_sequence_manager_get_name(i);
|
2018-02-01 18:49:14 +01:00
|
|
|
if (String::Equals(tn, name))
|
2016-11-27 17:16:17 +01:00
|
|
|
{
|
2018-02-01 18:49:14 +01:00
|
|
|
return i;
|
2016-11-27 17:16:17 +01:00
|
|
|
}
|
|
|
|
}
|
2018-02-01 18:49:14 +01:00
|
|
|
return SIZE_MAX;
|
|
|
|
}
|
2016-11-27 17:16:17 +01:00
|
|
|
|
2018-06-22 23:15:14 +02:00
|
|
|
bool title_sequence_manager_is_name_reserved(const utf8* name)
|
2018-02-01 18:49:14 +01:00
|
|
|
{
|
|
|
|
return TitleSequenceManager::IsNameReserved(name);
|
|
|
|
}
|
2017-10-14 22:43:09 +02:00
|
|
|
|
2018-02-01 18:49:14 +01:00
|
|
|
void title_sequence_manager_scan()
|
|
|
|
{
|
|
|
|
TitleSequenceManager::Scan();
|
|
|
|
}
|
2016-11-27 17:16:17 +01:00
|
|
|
|
2018-02-01 18:49:14 +01:00
|
|
|
void title_sequence_manager_delete(size_t i)
|
|
|
|
{
|
|
|
|
TitleSequenceManager::DeleteItem(i);
|
|
|
|
}
|
2016-11-27 17:16:17 +01:00
|
|
|
|
2018-06-22 23:15:14 +02:00
|
|
|
size_t title_sequence_manager_rename(size_t i, const utf8* name)
|
2018-02-01 18:49:14 +01:00
|
|
|
{
|
|
|
|
return TitleSequenceManager::RenameItem(i, name);
|
|
|
|
}
|
2016-11-29 14:22:11 +01:00
|
|
|
|
2018-06-22 23:15:14 +02:00
|
|
|
size_t title_sequence_manager_duplicate(size_t i, const utf8* name)
|
2018-02-01 18:49:14 +01:00
|
|
|
{
|
|
|
|
return TitleSequenceManager::DuplicateItem(i, name);
|
|
|
|
}
|
2016-11-29 14:42:24 +01:00
|
|
|
|
2018-06-22 23:15:14 +02:00
|
|
|
size_t title_sequence_manager_create(const utf8* name)
|
2018-02-01 18:49:14 +01:00
|
|
|
{
|
|
|
|
return TitleSequenceManager::CreateItem(name);
|
2016-11-12 18:12:11 +01:00
|
|
|
}
|