2020-05-25 19:34:42 +00:00
|
|
|
//
|
2020-06-21 12:25:28 +00:00
|
|
|
// Settings.h
|
2020-05-25 19:34:42 +00:00
|
|
|
//
|
2020-06-21 12:25:28 +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:
|
2020-06-21 12:25:28 +00:00
|
|
|
static Settings* getInstance();
|
2013-06-17 19:01:03 +00:00
|
|
|
|
2020-06-21 12:25:28 +00:00
|
|
|
void loadFile();
|
|
|
|
void saveFile();
|
2013-06-17 19:01:03 +00:00
|
|
|
|
2020-06-21 12:25:28 +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);
|
|
|
|
float getFloat(const std::string& name);
|
|
|
|
const std::string& getString(const std::string& name);
|
2013-06-17 19:01:03 +00:00
|
|
|
|
2020-06-21 12:25:28 +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:
|
2020-06-21 12:25:28 +00:00
|
|
|
static Settings* sInstance;
|
2013-06-17 19:01:03 +00:00
|
|
|
|
2020-06-21 12:25:28 +00:00
|
|
|
Settings();
|
2013-06-17 19:01:03 +00:00
|
|
|
|
2020-06-21 12:25:28 +00:00
|
|
|
// Clear everything and load default values.
|
|
|
|
void setDefaults();
|
2013-06-17 19:01:03 +00:00
|
|
|
|
2020-06-21 12:25:28 +00:00
|
|
|
bool mWasChanged;
|
2020-05-25 19:34:42 +00:00
|
|
|
|
2020-06-21 12:25:28 +00:00
|
|
|
std::map<std::string, bool> mBoolMap;
|
|
|
|
std::map<std::string, int> mIntMap;
|
|
|
|
std::map<std::string, float> mFloatMap;
|
|
|
|
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
|