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
struct SystemEnvironmentData
{
std : : string mStartPath ;
std : : vector < std : : string > mSearchExtensions ;
std : : string mLaunchCommand ;
std : : vector < PlatformIds : : PlatformId > mPlatformIds ;
} ;
2014-06-25 16:29:58 +00:00
class SystemData
{
public :
2017-06-12 16:38:59 +00:00
SystemData ( const std : : string & name , const std : : string & fullName , SystemEnvironmentData * envData , const std : : string & themeFolder , bool CollectionSystem = false ) ;
2014-06-25 16:29:58 +00:00
~ SystemData ( ) ;
inline FileData * getRootFolder ( ) const { return mRootFolder ; } ;
inline const std : : string & getName ( ) const { return mName ; }
inline const std : : string & getFullName ( ) const { return mFullName ; }
2017-06-12 16:38:59 +00:00
inline const std : : string & getStartPath ( ) const { return mEnvData - > mStartPath ; }
inline const std : : vector < std : : string > & getExtensions ( ) const { return mEnvData - > mSearchExtensions ; }
2014-06-25 16:29:58 +00:00
inline const std : : string & getThemeFolder ( ) const { return mThemeFolder ; }
2017-06-12 16:38:59 +00:00
inline SystemEnvironmentData * getSystemEnvData ( ) const { return mEnvData ; }
inline const std : : vector < PlatformIds : : PlatformId > & getPlatformIds ( ) const { return mEnvData - > mPlatformIds ; }
2017-11-11 14:56:22 +00:00
inline bool hasPlatformId ( PlatformIds : : PlatformId id ) { if ( ! mEnvData ) return false ; return std : : find ( mEnvData - > mPlatformIds . cbegin ( ) , mEnvData - > mPlatformIds . cend ( ) , id ) ! = mEnvData - > mPlatformIds . cend ( ) ; }
2014-06-25 16:29:58 +00:00
inline const std : : shared_ptr < ThemeData > & getTheme ( ) const { return mTheme ; }
std : : string getGamelistPath ( bool forWrite ) const ;
bool hasGamelist ( ) const ;
std : : string getThemePath ( ) const ;
2017-05-18 10:16:57 +00:00
2014-06-25 16:29:58 +00:00
unsigned int getGameCount ( ) const ;
2017-03-18 17:54:39 +00:00
unsigned int getDisplayedGameCount ( ) const ;
2014-06-25 16:29:58 +00:00
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 ;
2017-11-11 14:56:22 +00:00
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 ) ; } ;
2017-06-12 16:38:59 +00:00
inline bool isCollection ( ) { return mIsCollectionSystem ; } ;
2017-12-01 19:28:45 +00:00
inline bool isGameSystem ( ) { return mIsGameSystem ; } ;
bool isVisible ( ) ;
2019-08-25 15:23:02 +00:00
2017-09-08 13:20:07 +00:00
SystemData * getNext ( ) const ;
SystemData * getPrev ( ) const ;
2017-06-12 16:38:59 +00:00
static SystemData * getRandomSystem ( ) ;
FileData * getRandomGame ( ) ;
2014-06-25 16:29:58 +00:00
// Load or re-load theme.
void loadTheme ( ) ;
2017-03-18 17:54:39 +00:00
FileFilterIndex * getIndex ( ) { return mFilterIndex ; } ;
2019-08-24 14:22:02 +00:00
void onMetaDataSavePoint ( ) ;
2017-03-18 17:54:39 +00:00
2014-06-25 16:29:58 +00:00
private :
2017-06-12 16:38:59 +00:00
bool mIsCollectionSystem ;
bool mIsGameSystem ;
2014-06-25 16:29:58 +00:00
std : : string mName ;
std : : string mFullName ;
2017-06-12 16:38:59 +00:00
SystemEnvironmentData * mEnvData ;
2014-06-25 16:29:58 +00:00
std : : string mThemeFolder ;
std : : shared_ptr < ThemeData > mTheme ;
void populateFolder ( FileData * folder ) ;
2017-11-04 16:03:24 +00:00
void indexAllGameFilters ( const FileData * folder ) ;
2017-06-12 16:38:59 +00:00
void setIsGameSystemStatus ( ) ;
2019-08-24 14:22:02 +00:00
void writeMetaData ( ) ;
2014-06-25 16:29:58 +00:00
2017-03-18 17:54:39 +00:00
FileFilterIndex * mFilterIndex ;
2014-06-25 16:29:58 +00:00
FileData * mRootFolder ;
} ;
2017-10-31 17:12:50 +00:00
# endif // ES_APP_SYSTEM_DATA_H