153 lines
3.2 KiB
C++
153 lines
3.2 KiB
C++
|
#include <Corrade/Containers/Optional.h>
|
||
|
#include <Corrade/Containers/Pair.h>
|
||
|
#include <Corrade/Utility/Path.h>
|
||
|
|
||
|
#include "Configuration.h"
|
||
|
|
||
|
Configuration::Configuration() {
|
||
|
Containers::String exe_path = Utility::Path::split(*Utility::Path::executableLocation()).first();
|
||
|
_conf = Utility::Configuration{Utility::Path::join(exe_path, "MassBuilderSaveTool.ini")};
|
||
|
|
||
|
if(_conf.hasValue("swap_interval")) {
|
||
|
_swapInterval = _conf.value<int>("swap_interval");
|
||
|
}
|
||
|
else {
|
||
|
_conf.setValue("swap_interval", 1);
|
||
|
}
|
||
|
|
||
|
if(_conf.hasValue("frame_limit")) {
|
||
|
std::string frame_limit = _conf.value("frame_limit");
|
||
|
if(frame_limit == "half_vsync") {
|
||
|
_swapInterval = 2;
|
||
|
}
|
||
|
_conf.removeValue("frame_limit");
|
||
|
}
|
||
|
|
||
|
if(_conf.hasValue("fps_cap")) {
|
||
|
_fpsCap = _conf.value<float>("fps_cap");
|
||
|
}
|
||
|
else {
|
||
|
_conf.setValue("fps_cap", 60.0f);
|
||
|
}
|
||
|
|
||
|
if(_conf.hasValue("cheat_mode")) {
|
||
|
_cheatMode = _conf.value<bool>("cheat_mode");
|
||
|
}
|
||
|
else {
|
||
|
_conf.setValue("cheat_mode", _cheatMode);
|
||
|
}
|
||
|
|
||
|
if(_conf.hasValue("advanced_mode")) {
|
||
|
_advancedMode = _conf.value<bool>("advanced_mode");
|
||
|
}
|
||
|
else {
|
||
|
_conf.setValue("advanced_mode", _advancedMode);
|
||
|
}
|
||
|
|
||
|
if(_conf.hasValue("startup_update_check")) {
|
||
|
_checkUpdatesOnStartup = _conf.value<bool>("startup_update_check");
|
||
|
}
|
||
|
else {
|
||
|
_conf.setValue("startup_update_check", _checkUpdatesOnStartup);
|
||
|
}
|
||
|
|
||
|
if(_conf.hasValue("skip_disclaimer")) {
|
||
|
_skipDisclaimer = _conf.value<bool>("skip_disclaimer");
|
||
|
}
|
||
|
else {
|
||
|
_conf.setValue("skip_disclaimer", _skipDisclaimer);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
Configuration::~Configuration() {
|
||
|
save();
|
||
|
}
|
||
|
|
||
|
void
|
||
|
Configuration::save() {
|
||
|
_conf.save();
|
||
|
}
|
||
|
|
||
|
int
|
||
|
Configuration::swapInterval() const {
|
||
|
return _swapInterval;
|
||
|
}
|
||
|
|
||
|
void
|
||
|
Configuration::setSwapInterval(int interval) {
|
||
|
_swapInterval = interval;
|
||
|
_conf.setValue("swap_interval", _swapInterval);
|
||
|
_conf.save();
|
||
|
}
|
||
|
|
||
|
float
|
||
|
Configuration::fpsCap() const {
|
||
|
return _fpsCap;
|
||
|
}
|
||
|
|
||
|
void
|
||
|
Configuration::setFpsCap(float cap) {
|
||
|
_fpsCap = cap;
|
||
|
_conf.setValue("fps_cap", _fpsCap);
|
||
|
_conf.save();
|
||
|
}
|
||
|
|
||
|
bool
|
||
|
Configuration::cheatMode() const {
|
||
|
return _cheatMode;
|
||
|
}
|
||
|
|
||
|
void
|
||
|
Configuration::setCheatMode(bool enabled) {
|
||
|
_cheatMode = enabled;
|
||
|
_conf.setValue("cheat_mode", _cheatMode);
|
||
|
_conf.save();
|
||
|
}
|
||
|
|
||
|
bool
|
||
|
Configuration::advancedMode() const {
|
||
|
return _advancedMode;
|
||
|
}
|
||
|
|
||
|
void
|
||
|
Configuration::setAdvancedMode(bool enabled) {
|
||
|
_advancedMode = enabled;
|
||
|
_conf.setValue("advanced_mode", _advancedMode);
|
||
|
_conf.save();
|
||
|
}
|
||
|
|
||
|
bool
|
||
|
Configuration::checkUpdatesOnStartup() const {
|
||
|
return _checkUpdatesOnStartup;
|
||
|
}
|
||
|
|
||
|
void
|
||
|
Configuration::setCheckUpdatesOnStartup(bool mode) {
|
||
|
_checkUpdatesOnStartup = mode;
|
||
|
_conf.setValue("startup_update_check", _checkUpdatesOnStartup);
|
||
|
_conf.save();
|
||
|
}
|
||
|
|
||
|
bool
|
||
|
Configuration::skipDisclaimer() const {
|
||
|
return _skipDisclaimer;
|
||
|
}
|
||
|
|
||
|
void
|
||
|
Configuration::setSkipDisclaimer(bool mode) {
|
||
|
_skipDisclaimer = mode;
|
||
|
_conf.setValue("skip_disclaimer", _skipDisclaimer);
|
||
|
_conf.save();
|
||
|
}
|
||
|
|
||
|
Configuration&
|
||
|
Configuration::instance() {
|
||
|
static Configuration conf{};
|
||
|
return conf;
|
||
|
}
|
||
|
|
||
|
Configuration&
|
||
|
conf() {
|
||
|
return Configuration::instance();
|
||
|
}
|