2020-02-22 18:37:42 -05:00
|
|
|
#pragma once
|
|
|
|
#include "common.hpp"
|
|
|
|
#include "gta/player.hpp"
|
|
|
|
|
|
|
|
namespace big
|
|
|
|
{
|
|
|
|
class settings
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
explicit settings() = default;
|
|
|
|
~settings() = default;
|
|
|
|
|
|
|
|
nlohmann::json options;
|
|
|
|
nlohmann::json default_options =
|
|
|
|
R"({
|
2020-12-26 15:18:41 +01:00
|
|
|
"god_mode": false,
|
2020-12-27 00:47:08 +01:00
|
|
|
"join_message": false,
|
2020-12-26 15:18:41 +01:00
|
|
|
"never_wanted": false,
|
2020-12-26 21:56:22 +01:00
|
|
|
"no_bike_fall": false,
|
2020-12-26 16:49:21 +01:00
|
|
|
"no_idle_kick": false,
|
2020-12-26 15:18:41 +01:00
|
|
|
"off_radar": false,
|
2020-12-29 01:10:25 +01:00
|
|
|
"parked_vehicle_density": 1.0,
|
|
|
|
"pedestrian_population": 1.0,
|
|
|
|
"population_modifiers": false,
|
2020-12-26 15:18:41 +01:00
|
|
|
"ragdoll": false,
|
2020-12-26 17:35:47 +01:00
|
|
|
"rank": 6969,
|
2020-12-27 19:26:08 +01:00
|
|
|
"reveal_players": false,
|
2020-12-29 23:18:09 +01:00
|
|
|
"speedo_type": 0,
|
2020-12-26 17:35:47 +01:00
|
|
|
"spoof_rank": false,
|
2020-12-26 22:06:31 +01:00
|
|
|
"sticky_tyres": false,
|
2020-12-29 01:10:25 +01:00
|
|
|
"super_sprint": false,
|
|
|
|
"vehicle_density": 1.0
|
2020-02-22 18:37:42 -05:00
|
|
|
})"_json;
|
|
|
|
|
|
|
|
bool save()
|
|
|
|
{
|
|
|
|
std::string settings_file = std::getenv("appdata");
|
|
|
|
settings_file += "\\BigBaseV2\\settings.json";
|
|
|
|
|
|
|
|
std::ofstream file(settings_file, std::ios::out | std::ios::trunc);
|
|
|
|
file << options.dump(4);
|
|
|
|
file.close();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool load()
|
|
|
|
{
|
|
|
|
std::string settings_file = std::getenv("appdata");
|
|
|
|
settings_file += "\\BigBaseV2\\settings.json";
|
|
|
|
|
|
|
|
std::ifstream file(settings_file);
|
|
|
|
|
|
|
|
if (!file.is_open())
|
|
|
|
{
|
|
|
|
write_default_config();
|
|
|
|
file.open(settings_file);
|
|
|
|
}
|
|
|
|
|
|
|
|
file >> options;
|
|
|
|
|
|
|
|
bool should_save = false;
|
|
|
|
for (auto& e : default_options.items())
|
|
|
|
{
|
|
|
|
if (options.count(e.key()) == 0)
|
|
|
|
{
|
|
|
|
should_save = true;
|
|
|
|
options[e.key()] = e.value();
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (should_save)
|
|
|
|
{
|
|
|
|
LOG(INFO) << "Updating settings.";
|
|
|
|
save();
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
bool write_default_config()
|
|
|
|
{
|
|
|
|
std::string settings_file = std::getenv("appdata");
|
|
|
|
settings_file += "\\BigBaseV2\\settings.json";
|
|
|
|
|
|
|
|
std::ofstream file(settings_file, std::ios::out);
|
|
|
|
file << default_options.dump(4);
|
|
|
|
file.close();
|
|
|
|
|
|
|
|
options.clear();
|
|
|
|
options = default_options;
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
inline settings g_settings;
|
|
|
|
}
|