2020-08-19 05:07:55 +00:00
|
|
|
#pragma once
|
|
|
|
#include <string>
|
2020-10-04 06:28:48 +00:00
|
|
|
#include <type_traits>
|
2020-08-19 05:07:55 +00:00
|
|
|
#include <SimpleIni.h>
|
|
|
|
|
|
|
|
class SettingsManager {
|
|
|
|
public:
|
|
|
|
SettingsManager(std::string filename);
|
2020-12-18 07:05:24 +00:00
|
|
|
void Reload();
|
2020-08-19 05:07:55 +00:00
|
|
|
|
|
|
|
void Close();
|
2020-12-17 06:40:02 +00:00
|
|
|
bool GetUseMemoryDB() const;
|
|
|
|
std::string GetUserAgent() const;
|
|
|
|
std::string GetDiscordToken() const;
|
|
|
|
bool GetShowMemberListDiscriminators() const;
|
|
|
|
bool GetShowEmojis() const;
|
|
|
|
std::string GetLinkColor() const;
|
|
|
|
int GetCacheHTTPConcurrency() const;
|
2020-12-18 06:13:31 +00:00
|
|
|
bool GetPrefetch() const;
|
2020-12-18 07:05:24 +00:00
|
|
|
std::string GetMainCSS() const;
|
2020-12-22 00:08:44 +00:00
|
|
|
bool GetShowAnimations() const;
|
2021-03-04 05:02:37 +00:00
|
|
|
bool GetShowOwnerCrown() const;
|
2020-12-17 06:40:02 +00:00
|
|
|
|
|
|
|
bool IsValid() const;
|
2020-10-04 06:28:48 +00:00
|
|
|
|
|
|
|
template<typename T>
|
|
|
|
void SetSetting(std::string section, std::string key, T value) {
|
2020-12-17 06:40:02 +00:00
|
|
|
m_ini.SetValue(section.c_str(), key.c_str(), std::to_string(value).c_str());
|
|
|
|
m_ini.SaveFile(m_filename.c_str());
|
|
|
|
}
|
2020-10-04 19:25:00 +00:00
|
|
|
|
2021-01-07 07:41:49 +00:00
|
|
|
void SetSetting(std::string section, std::string key, std::string value) {
|
2020-12-17 06:40:02 +00:00
|
|
|
m_ini.SetValue(section.c_str(), key.c_str(), value.c_str());
|
2020-10-04 19:25:00 +00:00
|
|
|
m_ini.SaveFile(m_filename.c_str());
|
2020-10-04 06:28:48 +00:00
|
|
|
}
|
2020-11-03 06:52:19 +00:00
|
|
|
|
2020-12-17 06:40:02 +00:00
|
|
|
private:
|
|
|
|
std::string GetSettingString(const std::string §ion, const std::string &key, std::string fallback = "") const;
|
|
|
|
int GetSettingInt(const std::string §ion, const std::string &key, int fallback) const;
|
|
|
|
bool GetSettingBool(const std::string §ion, const std::string &key, bool fallback) const;
|
2020-08-19 05:07:55 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
bool m_ok;
|
|
|
|
std::string m_filename;
|
|
|
|
CSimpleIniA m_ini;
|
|
|
|
};
|