2020-05-24 08:29:29 +00:00
|
|
|
//
|
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
|
|
|
|
// on the configuration in es_systems.cfg as well as the presence of game ROM files.
|
|
|
|
// Also provides functions to read and write to the gamelist files and to handle theme
|
|
|
|
// loading.
|
2020-05-24 08:29:29 +00:00
|
|
|
//
|
|
|
|
|
2014-06-25 16:29:58 +00:00
|
|
|
#pragma once
|
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"
|
2017-11-01 22:21:10 +00:00
|
|
|
#include <algorithm>
|
|
|
|
#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;
|
|
|
|
std::string mLaunchCommand;
|
|
|
|
std::vector<PlatformIds::PlatformId> mPlatformIds;
|
2017-06-12 16:38:59 +00:00
|
|
|
};
|
2014-06-25 16:29:58 +00:00
|
|
|
|
|
|
|
class SystemData
|
|
|
|
{
|
|
|
|
public:
|
2020-07-10 16:32:23 +00:00
|
|
|
SystemData(
|
|
|
|
const std::string& name,
|
2020-06-21 12:25:28 +00:00
|
|
|
const std::string& fullName,
|
|
|
|
SystemEnvironmentData* envData,
|
|
|
|
const std::string& themeFolder,
|
|
|
|
bool CollectionSystem = false);
|
|
|
|
|
|
|
|
~SystemData();
|
|
|
|
|
|
|
|
inline FileData* getRootFolder() const { return mRootFolder; };
|
|
|
|
inline const std::string& getName() const { return mName; }
|
|
|
|
inline const std::string& getFullName() const { return mFullName; }
|
|
|
|
inline const std::string& getStartPath() const { return mEnvData->mStartPath; }
|
|
|
|
inline const std::vector<std::string>& getExtensions() const
|
|
|
|
{ return mEnvData->mSearchExtensions; }
|
|
|
|
inline const std::string& getThemeFolder() const { return mThemeFolder; }
|
|
|
|
inline SystemEnvironmentData* getSystemEnvData() const { return mEnvData; }
|
|
|
|
inline const std::vector<PlatformIds::PlatformId>& getPlatformIds() const
|
|
|
|
{ return mEnvData->mPlatformIds; }
|
|
|
|
inline bool hasPlatformId(PlatformIds::PlatformId id) { if (!mEnvData) return false;
|
|
|
|
return std::find(mEnvData->mPlatformIds.cbegin(), mEnvData->mPlatformIds.cend(), id)
|
|
|
|
!= mEnvData->mPlatformIds.cend(); }
|
|
|
|
|
|
|
|
inline const std::shared_ptr<ThemeData>& getTheme() const { return mTheme; }
|
|
|
|
|
|
|
|
std::string getGamelistPath(bool forWrite) const;
|
|
|
|
bool hasGamelist() const;
|
|
|
|
std::string getThemePath() const;
|
|
|
|
|
|
|
|
unsigned int getGameCount() const;
|
|
|
|
unsigned int getDisplayedGameCount() const;
|
|
|
|
bool getScrapeFlag() { return mScrapeFlag; };
|
|
|
|
void setScrapeFlag(bool scrapeflag) { mScrapeFlag = scrapeflag; }
|
|
|
|
|
|
|
|
static void deleteSystems();
|
|
|
|
// Load the system config file at getConfigPath().
|
|
|
|
// Returns true if no errors were encountered.
|
|
|
|
// An example will be written if the file doesn't exist.
|
|
|
|
static bool loadConfig();
|
2020-07-09 17:26:48 +00:00
|
|
|
static bool copyConfigTemplate(const std::string& path);
|
2020-06-21 12:25:28 +00:00
|
|
|
static std::string getConfigPath(bool forWrite);
|
|
|
|
|
|
|
|
static std::vector<SystemData*> sSystemVector;
|
|
|
|
|
|
|
|
inline std::vector<SystemData*>::const_iterator getIterator() const
|
|
|
|
{ return std::find(sSystemVector.cbegin(), sSystemVector.cend(), this); };
|
|
|
|
inline std::vector<SystemData*>::const_reverse_iterator getRevIterator() const
|
|
|
|
{ return std::find(sSystemVector.crbegin(), sSystemVector.crend(), this); };
|
|
|
|
inline bool isCollection() { return mIsCollectionSystem; };
|
|
|
|
inline bool isGameSystem() { return mIsGameSystem; };
|
|
|
|
|
|
|
|
bool isVisible();
|
|
|
|
|
|
|
|
SystemData* getNext() const;
|
|
|
|
SystemData* getPrev() const;
|
2020-07-28 13:19:54 +00:00
|
|
|
static SystemData* getRandomSystem(const SystemData* currentSystem);
|
|
|
|
static FileData* getRandomCollectionFolder(const FileData* currentFolder);
|
|
|
|
FileData* getRandomGame(const FileData* currentGame = nullptr);
|
2020-06-21 12:25:28 +00:00
|
|
|
|
|
|
|
// Load or re-load theme.
|
|
|
|
void loadTheme();
|
|
|
|
|
|
|
|
FileFilterIndex* getIndex() { return mFilterIndex; };
|
|
|
|
void onMetaDataSavePoint();
|
2020-07-13 18:13:48 +00:00
|
|
|
void writeMetaData();
|
2020-06-21 12:25:28 +00:00
|
|
|
|
|
|
|
void setupSystemSortType(FileData* mRootFolder);
|
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
|
|
|
bool mIsCollectionSystem;
|
|
|
|
bool mIsGameSystem;
|
|
|
|
bool mScrapeFlag; // Only used by scraper GUI to remember which systems to scrape.
|
|
|
|
std::string mName;
|
|
|
|
std::string mFullName;
|
|
|
|
SystemEnvironmentData* mEnvData;
|
|
|
|
std::string mThemeFolder;
|
|
|
|
std::shared_ptr<ThemeData> mTheme;
|
|
|
|
|
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;
|
2014-06-25 16:29:58 +00:00
|
|
|
};
|
2017-10-31 17:12:50 +00:00
|
|
|
|
|
|
|
#endif // ES_APP_SYSTEM_DATA_H
|