2014-06-03 23:30:03 +00:00
|
|
|
#pragma once
|
2017-10-31 17:12:50 +00:00
|
|
|
#ifndef ES_CORE_SETTINGS_H
|
|
|
|
#define ES_CORE_SETTINGS_H
|
|
|
|
|
2013-06-17 19:01:03 +00:00
|
|
|
#include <map>
|
|
|
|
|
|
|
|
//This is a singleton for storing settings.
|
|
|
|
class Settings
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
static Settings* getInstance();
|
|
|
|
|
2013-06-19 21:02:42 +00:00
|
|
|
void loadFile();
|
|
|
|
void saveFile();
|
2013-06-17 19:01:03 +00:00
|
|
|
|
|
|
|
//You will get a warning if you try a get on a key that is not already present.
|
|
|
|
bool getBool(const std::string& name);
|
|
|
|
int getInt(const std::string& name);
|
2013-06-19 21:02:42 +00:00
|
|
|
float getFloat(const std::string& name);
|
2014-03-22 16:44:57 +00:00
|
|
|
const std::string& getString(const std::string& name);
|
2013-06-17 19:01:03 +00:00
|
|
|
|
|
|
|
void setBool(const std::string& name, bool value);
|
|
|
|
void setInt(const std::string& name, int value);
|
2013-06-19 21:02:42 +00:00
|
|
|
void setFloat(const std::string& name, float value);
|
2014-03-22 16:44:57 +00:00
|
|
|
void setString(const std::string& name, const std::string& value);
|
2013-06-17 19:01:03 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
static Settings* sInstance;
|
|
|
|
|
|
|
|
Settings();
|
|
|
|
|
|
|
|
//Clear everything and load default values.
|
|
|
|
void setDefaults();
|
2019-08-24 14:22:02 +00:00
|
|
|
void processBackwardCompatibility();
|
2013-06-17 19:01:03 +00:00
|
|
|
|
|
|
|
std::map<std::string, bool> mBoolMap;
|
|
|
|
std::map<std::string, int> mIntMap;
|
2013-06-19 21:02:42 +00:00
|
|
|
std::map<std::string, float> mFloatMap;
|
2014-03-22 16:44:57 +00:00
|
|
|
std::map<std::string, std::string> mStringMap;
|
2013-06-17 19:01:03 +00:00
|
|
|
};
|
2017-10-31 17:12:50 +00:00
|
|
|
|
|
|
|
#endif // ES_CORE_SETTINGS_H
|