2020-05-24 08:29:29 +00:00
|
|
|
//
|
|
|
|
// MetaData.h
|
|
|
|
//
|
|
|
|
// Static data for default metadata values as well as functions
|
|
|
|
// to read and write metadata from the gamelist files.
|
|
|
|
//
|
|
|
|
|
2014-06-25 16:29:58 +00:00
|
|
|
#pragma once
|
2017-10-31 17:12:50 +00:00
|
|
|
#ifndef ES_APP_META_DATA_H
|
|
|
|
#define ES_APP_META_DATA_H
|
2014-06-25 16:29:58 +00:00
|
|
|
|
2017-11-22 21:01:12 +00:00
|
|
|
#include <map>
|
2018-01-29 22:50:10 +00:00
|
|
|
#include <vector>
|
2017-11-10 19:16:42 +00:00
|
|
|
|
|
|
|
namespace pugi { class xml_node; }
|
2014-06-25 16:29:58 +00:00
|
|
|
|
2020-05-24 08:29:29 +00:00
|
|
|
enum MetaDataType {
|
2020-06-06 11:10:33 +00:00
|
|
|
// Generic types.
|
2014-06-25 16:29:58 +00:00
|
|
|
MD_STRING,
|
|
|
|
MD_INT,
|
|
|
|
MD_FLOAT,
|
2017-06-12 16:38:59 +00:00
|
|
|
MD_BOOL,
|
2014-06-25 16:29:58 +00:00
|
|
|
|
2020-06-06 11:10:33 +00:00
|
|
|
// Specialized types.
|
2014-06-25 16:29:58 +00:00
|
|
|
MD_MULTILINE_STRING,
|
2020-05-19 15:52:11 +00:00
|
|
|
MD_LAUNCHSTRING,
|
2016-12-04 23:47:34 +00:00
|
|
|
MD_PATH,
|
2014-06-25 16:29:58 +00:00
|
|
|
MD_RATING,
|
|
|
|
MD_DATE,
|
2020-06-06 11:10:33 +00:00
|
|
|
MD_TIME // Used for lastplayed.
|
2014-06-25 16:29:58 +00:00
|
|
|
};
|
|
|
|
|
2020-05-24 08:29:29 +00:00
|
|
|
struct MetaDataDecl {
|
2014-06-25 16:29:58 +00:00
|
|
|
std::string key;
|
|
|
|
MetaDataType type;
|
|
|
|
std::string defaultValue;
|
2020-05-24 08:29:29 +00:00
|
|
|
// If true, ignore values for this metadata.
|
|
|
|
bool isStatistic;
|
|
|
|
// Displayed as this in editors.
|
|
|
|
std::string displayName;
|
|
|
|
// Phrase displayed in editors when prompted to enter value (currently only for strings).
|
|
|
|
std::string displayPrompt;
|
2020-06-06 11:10:33 +00:00
|
|
|
// If set to false, the scraper will not overwrite this metadata.
|
|
|
|
bool shouldScrape;
|
2014-06-25 16:29:58 +00:00
|
|
|
};
|
|
|
|
|
2020-05-24 08:29:29 +00:00
|
|
|
enum MetaDataListType {
|
2014-06-25 16:29:58 +00:00
|
|
|
GAME_METADATA,
|
|
|
|
FOLDER_METADATA
|
|
|
|
};
|
|
|
|
|
|
|
|
const std::vector<MetaDataDecl>& getMDDByType(MetaDataListType type);
|
|
|
|
|
|
|
|
class MetaDataList
|
|
|
|
{
|
|
|
|
public:
|
2020-05-24 08:29:29 +00:00
|
|
|
static MetaDataList createFromXML(MetaDataListType type,
|
|
|
|
pugi::xml_node& node, const std::string& relativeTo);
|
|
|
|
void appendToXML(pugi::xml_node& parent, bool ignoreDefaults,
|
|
|
|
const std::string& relativeTo) const;
|
2014-06-25 16:29:58 +00:00
|
|
|
|
|
|
|
MetaDataList(MetaDataListType type);
|
2019-08-25 15:23:02 +00:00
|
|
|
|
2014-06-25 16:29:58 +00:00
|
|
|
void set(const std::string& key, const std::string& value);
|
|
|
|
|
|
|
|
const std::string& get(const std::string& key) const;
|
|
|
|
int getInt(const std::string& key) const;
|
|
|
|
float getFloat(const std::string& key) const;
|
|
|
|
|
2016-12-19 15:59:40 +00:00
|
|
|
bool wasChanged() const;
|
|
|
|
void resetChangedFlag();
|
|
|
|
|
2014-06-25 16:29:58 +00:00
|
|
|
inline MetaDataListType getType() const { return mType; }
|
|
|
|
inline const std::vector<MetaDataDecl>& getMDD() const { return getMDDByType(getType()); }
|
2020-06-13 14:47:12 +00:00
|
|
|
inline const std::vector<MetaDataDecl>& getMDD(MetaDataListType type) const
|
|
|
|
{ return getMDDByType(type); }
|
2014-06-25 16:29:58 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
MetaDataListType mType;
|
|
|
|
std::map<std::string, std::string> mMap;
|
2020-05-24 08:29:29 +00:00
|
|
|
std::string mNoResult = "";
|
2016-12-19 15:59:40 +00:00
|
|
|
bool mWasChanged;
|
2014-06-25 16:29:58 +00:00
|
|
|
};
|
2017-10-31 17:12:50 +00:00
|
|
|
|
|
|
|
#endif // ES_APP_META_DATA_H
|