ES-DE/es-app/src/SystemData.h
pjft d0cdbf2159 Adding support for Virtual Systems
- Refactoring System Environment data
- Added Virtual System Manager class
- Added "all", "favorites" and "last played" systems
- Added GuiInfoPopup class for notifications
- Added Favorites to metadata, as well as a shortcut to toggle favorites
- Added warning if enabling systems but themes don't support it
- Added "filter by favorites" per system
- Adjusted "Go to Random Game" behavior to account for the fact that we now have an "All Games" system
- Added "sort by system name" for the collections
2017-07-07 20:16:21 +01:00

97 lines
3.4 KiB
C++

#pragma once
#include <vector>
#include <string>
#include "FileData.h"
#include "Window.h"
#include "MetaData.h"
#include "PlatformId.h"
#include "ThemeData.h"
#include "FileFilterIndex.h"
#include "CollectionSystemManager.h"
struct SystemEnvironmentData
{
std::string mStartPath;
std::vector<std::string> mSearchExtensions;
std::string mLaunchCommand;
std::vector<PlatformIds::PlatformId> mPlatformIds;
};
class SystemData
{
public:
SystemData(const std::string& name, 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.begin(), mEnvData->mPlatformIds.end(), id) != mEnvData->mPlatformIds.end(); }
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;
static void deleteSystems();
static bool loadConfig(); //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 void writeExampleConfig(const std::string& path);
static std::string getConfigPath(bool forWrite); // if forWrite, will only return ~/.emulationstation/es_systems.cfg, never /etc/emulationstation/es_systems.cfg
static std::vector<SystemData*> sSystemVector;
inline std::vector<SystemData*>::const_iterator getIterator() const { return std::find(sSystemVector.begin(), sSystemVector.end(), this); };
inline std::vector<SystemData*>::const_reverse_iterator getRevIterator() const { return std::find(sSystemVector.rbegin(), sSystemVector.rend(), this); };
inline bool isCollection() { return mIsCollectionSystem; };
inline bool isGameSystem() { return mIsGameSystem; }
inline SystemData* getNext() const
{
auto it = getIterator();
it++;
if(it == sSystemVector.end()) it = sSystemVector.begin();
return *it;
}
inline SystemData* getPrev() const
{
auto it = getRevIterator();
it++;
if(it == sSystemVector.rend()) it = sSystemVector.rbegin();
return *it;
}
static SystemData* getRandomSystem();
FileData* getRandomGame();
// Load or re-load theme.
void loadTheme();
FileFilterIndex* getIndex() { return mFilterIndex; };
private:
bool mIsCollectionSystem;
bool mIsGameSystem;
std::string mName;
std::string mFullName;
SystemEnvironmentData* mEnvData;
std::string mThemeFolder;
std::shared_ptr<ThemeData> mTheme;
void populateFolder(FileData* folder);
void setIsGameSystemStatus();
FileFilterIndex* mFilterIndex;
FileData* mRootFolder;
};