2020-09-21 16:13:27 +00:00
|
|
|
// SPDX-License-Identifier: MIT
|
2020-05-24 08:29:29 +00:00
|
|
|
//
|
2020-09-21 16:13:27 +00:00
|
|
|
// EmulationStation Desktop Edition
|
2020-06-21 12:25:28 +00:00
|
|
|
// SystemData.h
|
2020-05-24 08:29:29 +00:00
|
|
|
//
|
2020-06-21 12:25:28 +00:00
|
|
|
// Provides data structures for the game systems and populates and indexes them based
|
2021-06-16 16:54:04 +00:00
|
|
|
// on the configuration in es_systems.xml as well as the presence of game ROM files.
|
2020-06-21 12:25:28 +00:00
|
|
|
// Also provides functions to read and write to the gamelist files and to handle theme
|
|
|
|
// loading.
|
2020-05-24 08:29:29 +00:00
|
|
|
//
|
|
|
|
|
2017-10-31 17:12:50 +00:00
|
|
|
#ifndef ES_APP_SYSTEM_DATA_H
|
|
|
|
#define ES_APP_SYSTEM_DATA_H
|
2014-06-25 16:29:58 +00:00
|
|
|
|
|
|
|
#include "PlatformId.h"
|
2023-01-04 18:01:41 +00:00
|
|
|
#include "ThemeData.h"
|
2020-09-21 17:17:34 +00:00
|
|
|
|
2017-11-01 22:21:10 +00:00
|
|
|
#include <algorithm>
|
2021-06-19 12:09:14 +00:00
|
|
|
#include <map>
|
2017-11-01 22:21:10 +00:00
|
|
|
#include <memory>
|
|
|
|
#include <string>
|
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
class FileData;
|
|
|
|
class FileFilterIndex;
|
|
|
|
class ThemeData;
|
2017-06-12 16:38:59 +00:00
|
|
|
|
2020-07-10 16:32:23 +00:00
|
|
|
struct SystemEnvironmentData {
|
2020-06-21 12:25:28 +00:00
|
|
|
std::string mStartPath;
|
|
|
|
std::vector<std::string> mSearchExtensions;
|
2021-08-22 13:26:38 +00:00
|
|
|
std::vector<std::pair<std::string, std::string>> mLaunchCommands;
|
2020-06-21 12:25:28 +00:00
|
|
|
std::vector<PlatformIds::PlatformId> mPlatformIds;
|
2017-06-12 16:38:59 +00:00
|
|
|
};
|
2014-06-25 16:29:58 +00:00
|
|
|
|
2021-06-19 12:09:14 +00:00
|
|
|
class FindRules
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
FindRules();
|
|
|
|
|
|
|
|
void loadFindRules();
|
|
|
|
|
|
|
|
private:
|
|
|
|
struct EmulatorRules {
|
2021-07-07 18:03:42 +00:00
|
|
|
#if defined(_WIN64)
|
2021-06-26 10:00:09 +00:00
|
|
|
std::vector<std::string> winRegistryPaths;
|
2021-11-22 19:03:05 +00:00
|
|
|
std::vector<std::string> winRegistryValues;
|
2021-07-07 18:03:42 +00:00
|
|
|
#endif
|
2021-06-19 12:09:14 +00:00
|
|
|
std::vector<std::string> systemPaths;
|
|
|
|
std::vector<std::string> staticPaths;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct CoreRules {
|
|
|
|
std::vector<std::string> corePaths;
|
|
|
|
};
|
|
|
|
|
|
|
|
std::map<std::string, struct EmulatorRules> mEmulators;
|
|
|
|
std::map<std::string, struct CoreRules> mCores;
|
|
|
|
|
|
|
|
friend FileData;
|
|
|
|
};
|
|
|
|
|
2014-06-25 16:29:58 +00:00
|
|
|
class SystemData
|
|
|
|
{
|
|
|
|
public:
|
2021-07-07 18:03:42 +00:00
|
|
|
SystemData(const std::string& name,
|
|
|
|
const std::string& fullName,
|
2021-09-25 09:02:27 +00:00
|
|
|
const std::string& sortName,
|
2021-07-07 18:03:42 +00:00
|
|
|
SystemEnvironmentData* envData,
|
|
|
|
const std::string& themeFolder,
|
|
|
|
bool CollectionSystem = false,
|
|
|
|
bool CustomCollectionSystem = false);
|
2020-06-21 12:25:28 +00:00
|
|
|
|
|
|
|
~SystemData();
|
|
|
|
|
2021-07-07 18:03:42 +00:00
|
|
|
FileData* getRootFolder() const { return mRootFolder; }
|
|
|
|
const std::string& getName() const { return mName; }
|
|
|
|
const std::string& getFullName() const { return mFullName; }
|
2021-09-25 09:02:27 +00:00
|
|
|
const std::string& getSortName() const { return mSortName; }
|
2021-07-07 18:03:42 +00:00
|
|
|
const std::string& getStartPath() const { return mEnvData->mStartPath; }
|
|
|
|
const std::vector<std::string>& getExtensions() const { return mEnvData->mSearchExtensions; }
|
|
|
|
const std::string& getThemeFolder() const { return mThemeFolder; }
|
|
|
|
SystemEnvironmentData* getSystemEnvData() const { return mEnvData; }
|
|
|
|
const std::vector<PlatformIds::PlatformId>& getPlatformIds() const
|
|
|
|
{
|
|
|
|
return mEnvData->mPlatformIds;
|
|
|
|
}
|
|
|
|
bool hasPlatformId(PlatformIds::PlatformId id)
|
|
|
|
{
|
|
|
|
if (!mEnvData)
|
|
|
|
return false;
|
|
|
|
return std::find(mEnvData->mPlatformIds.cbegin(), mEnvData->mPlatformIds.cend(), id) !=
|
|
|
|
mEnvData->mPlatformIds.cend();
|
|
|
|
}
|
|
|
|
|
2022-01-04 21:36:15 +00:00
|
|
|
const std::shared_ptr<ThemeData> getTheme() const { return mTheme; }
|
2020-06-21 12:25:28 +00:00
|
|
|
|
|
|
|
std::string getGamelistPath(bool forWrite) const;
|
|
|
|
std::string getThemePath() const;
|
|
|
|
|
2020-09-21 16:13:27 +00:00
|
|
|
std::pair<unsigned int, unsigned int> getDisplayedGameCount() const;
|
2022-05-18 17:47:51 +00:00
|
|
|
const bool getFlattenFolders() const { return mFlattenFolders; }
|
2021-11-09 21:40:08 +00:00
|
|
|
const bool getScrapeFlag() const { return mScrapeFlag; }
|
2020-06-21 12:25:28 +00:00
|
|
|
void setScrapeFlag(bool scrapeflag) { mScrapeFlag = scrapeflag; }
|
|
|
|
|
2021-11-09 21:40:08 +00:00
|
|
|
const std::string& getAlternativeEmulator() const { return mAlternativeEmulator; }
|
2021-08-22 13:26:38 +00:00
|
|
|
void setAlternativeEmulator(const std::string& command) { mAlternativeEmulator = command; }
|
2021-09-04 09:21:55 +00:00
|
|
|
std::string getLaunchCommandFromLabel(const std::string& label);
|
2021-08-22 13:26:38 +00:00
|
|
|
|
2020-06-21 12:25:28 +00:00
|
|
|
static void deleteSystems();
|
2021-09-05 15:39:11 +00:00
|
|
|
// Loads the systems configuration file(s) at getConfigPath() and creates the systems.
|
2020-06-21 12:25:28 +00:00
|
|
|
static bool loadConfig();
|
2021-09-05 15:39:11 +00:00
|
|
|
static std::vector<std::string> getConfigPath(bool legacyWarning);
|
2021-03-10 17:21:49 +00:00
|
|
|
|
2021-06-16 16:54:04 +00:00
|
|
|
// Generates the game system directories and information files based on es_systems.xml.
|
2021-03-10 17:21:49 +00:00
|
|
|
static bool createSystemDirectories();
|
|
|
|
|
2020-06-21 12:25:28 +00:00
|
|
|
static std::vector<SystemData*> sSystemVector;
|
2021-06-19 12:09:14 +00:00
|
|
|
static std::unique_ptr<FindRules> sFindRules;
|
2020-06-21 12:25:28 +00:00
|
|
|
|
2021-11-09 21:40:08 +00:00
|
|
|
const bool isCollection() const { return mIsCollectionSystem; }
|
|
|
|
const bool isCustomCollection() const { return mIsCustomCollectionSystem; }
|
|
|
|
const bool isGroupedCustomCollection() const { return mIsGroupedCustomCollectionSystem; }
|
2020-10-30 09:12:15 +00:00
|
|
|
void setIsGroupedCustomCollection(bool isGroupedCustom)
|
2021-07-07 18:03:42 +00:00
|
|
|
{
|
|
|
|
mIsGroupedCustomCollectionSystem = isGroupedCustom;
|
|
|
|
};
|
2021-11-09 21:40:08 +00:00
|
|
|
const bool isGameSystem() const { return mIsGameSystem; }
|
2020-06-21 12:25:28 +00:00
|
|
|
|
2021-09-23 15:07:27 +00:00
|
|
|
static SystemData* getSystemByName(const std::string& systemName);
|
2020-06-21 12:25:28 +00:00
|
|
|
SystemData* getNext() const;
|
|
|
|
SystemData* getPrev() const;
|
2020-07-28 13:19:54 +00:00
|
|
|
static SystemData* getRandomSystem(const SystemData* currentSystem);
|
2022-02-13 22:15:43 +00:00
|
|
|
FileData* getRandomGame(const FileData* currentGame = nullptr, bool gameSelectorMode = false);
|
2021-07-07 18:03:42 +00:00
|
|
|
FileData* getPlaceholder() { return mPlaceholder; }
|
2020-06-21 12:25:28 +00:00
|
|
|
|
2020-11-05 17:18:11 +00:00
|
|
|
void sortSystem(bool reloadGamelist = true, bool jumpToFirstRow = false);
|
2020-09-26 11:03:14 +00:00
|
|
|
|
2023-01-04 18:01:41 +00:00
|
|
|
// Load or reload theme.
|
|
|
|
void loadTheme(ThemeTriggers::TriggerType trigger);
|
2020-06-21 12:25:28 +00:00
|
|
|
|
2021-07-07 18:03:42 +00:00
|
|
|
FileFilterIndex* getIndex() { return mFilterIndex; }
|
2020-06-21 12:25:28 +00:00
|
|
|
void onMetaDataSavePoint();
|
2020-07-13 18:13:48 +00:00
|
|
|
void writeMetaData();
|
2020-06-21 12:25:28 +00:00
|
|
|
|
2021-09-19 17:46:59 +00:00
|
|
|
void setupSystemSortType(FileData* rootFolder);
|
2020-05-24 08:29:29 +00:00
|
|
|
|
2014-06-25 16:29:58 +00:00
|
|
|
private:
|
2020-06-21 12:25:28 +00:00
|
|
|
std::string mName;
|
|
|
|
std::string mFullName;
|
2021-09-25 09:02:27 +00:00
|
|
|
std::string mSortName;
|
2020-06-21 12:25:28 +00:00
|
|
|
SystemEnvironmentData* mEnvData;
|
2021-08-22 13:26:38 +00:00
|
|
|
std::string mAlternativeEmulator;
|
2020-06-21 12:25:28 +00:00
|
|
|
std::string mThemeFolder;
|
|
|
|
std::shared_ptr<ThemeData> mTheme;
|
|
|
|
|
2023-01-16 16:43:02 +00:00
|
|
|
bool mSymlinkMaxDepthReached;
|
2021-09-18 07:53:26 +00:00
|
|
|
bool mIsCollectionSystem;
|
|
|
|
bool mIsCustomCollectionSystem;
|
|
|
|
bool mIsGroupedCustomCollectionSystem;
|
|
|
|
bool mIsGameSystem;
|
|
|
|
bool mScrapeFlag; // Only used by scraper GUI to remember which systems to scrape.
|
2022-05-18 17:47:51 +00:00
|
|
|
bool mFlattenFolders;
|
2021-09-18 07:53:26 +00:00
|
|
|
|
2020-06-21 20:11:29 +00:00
|
|
|
bool populateFolder(FileData* folder);
|
2020-06-21 12:25:28 +00:00
|
|
|
void indexAllGameFilters(const FileData* folder);
|
|
|
|
void setIsGameSystemStatus();
|
|
|
|
|
|
|
|
FileFilterIndex* mFilterIndex;
|
|
|
|
|
|
|
|
FileData* mRootFolder;
|
2021-03-19 17:47:49 +00:00
|
|
|
FileData* mPlaceholder;
|
2014-06-25 16:29:58 +00:00
|
|
|
};
|
2017-10-31 17:12:50 +00:00
|
|
|
|
|
|
|
#endif // ES_APP_SYSTEM_DATA_H
|