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-01 22:21:10 +00:00
|
|
|
#include <boost/filesystem/path.hpp>
|
2017-11-22 21:01:12 +00:00
|
|
|
#include <map>
|
2017-11-10 19:16:42 +00:00
|
|
|
|
|
|
|
namespace pugi { class xml_node; }
|
2014-06-25 16:29:58 +00:00
|
|
|
|
|
|
|
enum MetaDataType
|
|
|
|
{
|
|
|
|
//generic types
|
|
|
|
MD_STRING,
|
|
|
|
MD_INT,
|
|
|
|
MD_FLOAT,
|
2017-06-12 16:38:59 +00:00
|
|
|
MD_BOOL,
|
2014-06-25 16:29:58 +00:00
|
|
|
|
|
|
|
//specialized types
|
|
|
|
MD_MULTILINE_STRING,
|
2016-12-04 23:47:34 +00:00
|
|
|
MD_PATH,
|
2014-06-25 16:29:58 +00:00
|
|
|
MD_RATING,
|
|
|
|
MD_DATE,
|
|
|
|
MD_TIME //used for lastplayed
|
|
|
|
};
|
|
|
|
|
|
|
|
struct MetaDataDecl
|
|
|
|
{
|
|
|
|
std::string key;
|
|
|
|
MetaDataType type;
|
|
|
|
std::string defaultValue;
|
|
|
|
bool isStatistic; //if true, ignore scraper values for this metadata
|
|
|
|
std::string displayName; // displayed as this in editors
|
|
|
|
std::string displayPrompt; // phrase displayed in editors when prompted to enter value (currently only for strings)
|
|
|
|
};
|
|
|
|
|
|
|
|
enum MetaDataListType
|
|
|
|
{
|
|
|
|
GAME_METADATA,
|
|
|
|
FOLDER_METADATA
|
|
|
|
};
|
|
|
|
|
|
|
|
const std::vector<MetaDataDecl>& getMDDByType(MetaDataListType type);
|
|
|
|
|
|
|
|
class MetaDataList
|
|
|
|
{
|
|
|
|
public:
|
2017-11-10 19:16:42 +00:00
|
|
|
static MetaDataList createFromXML(MetaDataListType type, pugi::xml_node& node, const boost::filesystem::path& relativeTo);
|
|
|
|
void appendToXML(pugi::xml_node& parent, bool ignoreDefaults, const boost::filesystem::path& relativeTo) const;
|
2014-06-25 16:29:58 +00:00
|
|
|
|
|
|
|
MetaDataList(MetaDataListType type);
|
|
|
|
|
|
|
|
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-09-03 20:45:52 +00:00
|
|
|
bool isDefault();
|
|
|
|
|
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()); }
|
|
|
|
|
|
|
|
private:
|
|
|
|
MetaDataListType mType;
|
|
|
|
std::map<std::string, std::string> mMap;
|
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
|