2020-05-25 19:34:42 +00:00
|
|
|
//
|
|
|
|
// Settings.h
|
|
|
|
//
|
2020-05-26 16:34:33 +00:00
|
|
|
// Functions to read from and write to the configuration file es_settings.cfg.
|
|
|
|
// The default values for the application settings are defined here as well.
|
2020-05-25 19:34:42 +00:00
|
|
|
//
|
|
|
|
|
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>
|
|
|
|
|
2020-05-25 19:34:42 +00:00
|
|
|
// This is a singleton for storing settings.
|
2013-06-17 19:01:03 +00:00
|
|
|
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
|
|
|
|
2020-05-25 19:34:42 +00:00
|
|
|
// You will get a warning if you try a get on a key that is not already present.
|
2013-06-17 19:01:03 +00:00
|
|
|
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
|
|
|
|
2020-05-15 15:42:36 +00:00
|
|
|
bool setBool(const std::string& name, bool value);
|
|
|
|
bool setInt(const std::string& name, int value);
|
|
|
|
bool setFloat(const std::string& name, float value);
|
|
|
|
bool setString(const std::string& name, const std::string& value);
|
2013-06-17 19:01:03 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
static Settings* sInstance;
|
|
|
|
|
|
|
|
Settings();
|
|
|
|
|
2020-05-25 19:34:42 +00:00
|
|
|
// Clear everything and load default values.
|
2013-06-17 19:01:03 +00:00
|
|
|
void setDefaults();
|
|
|
|
|
2020-05-15 15:42:36 +00:00
|
|
|
bool mWasChanged;
|
2020-05-25 19:34:42 +00:00
|
|
|
|
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
|