Fix settings::write_default_config & added reset all settings button (#1547)
* fix(settings): correctly write default settings * feat(Settings): Added button to reset all settings * fix(Settings): Use SeparatorText for subtitle
This commit is contained in:
parent
c3121de8e7
commit
d4bcd70629
@ -83,6 +83,15 @@ namespace big
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool menu_settings::write_default_config()
|
||||||
|
{
|
||||||
|
std::ofstream file(m_save_file->get_path(), std::ios::out | std::ios::trunc);
|
||||||
|
file << m_default_options.dump(4);
|
||||||
|
file.close();
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
bool menu_settings::deep_compare(nlohmann::json& current_settings, const nlohmann::json& default_settings, bool compare_value)
|
bool menu_settings::deep_compare(nlohmann::json& current_settings, const nlohmann::json& default_settings, bool compare_value)
|
||||||
{
|
{
|
||||||
bool should_save = false;
|
bool should_save = false;
|
||||||
@ -122,14 +131,4 @@ namespace big
|
|||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool menu_settings::write_default_config()
|
|
||||||
{
|
|
||||||
std::ofstream file(m_save_file->get_path(), std::ios::out | std::ios::trunc);
|
|
||||||
nlohmann::json j = *this;
|
|
||||||
file << j.dump(4);
|
|
||||||
file.close();
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
}
|
@ -49,11 +49,11 @@ namespace big
|
|||||||
|
|
||||||
void attempt_save();
|
void attempt_save();
|
||||||
bool load();
|
bool load();
|
||||||
|
bool write_default_config();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool deep_compare(nlohmann::json& current_settings, const nlohmann::json& default_settings, bool compare_value = false);
|
bool deep_compare(nlohmann::json& current_settings, const nlohmann::json& default_settings, bool compare_value = false);
|
||||||
bool save();
|
bool save();
|
||||||
bool write_default_config();
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool m_running;
|
bool m_running;
|
||||||
|
@ -4,7 +4,13 @@ namespace big
|
|||||||
{
|
{
|
||||||
void view::settings()
|
void view::settings()
|
||||||
{
|
{
|
||||||
components::sub_title("SETTINGS_MISC"_T);
|
ImGui::SeparatorText("SETTINGS_MISC"_T.data());
|
||||||
ImGui::Checkbox("SETTINGS_MISC_DEV_DLC"_T.data(), &g.settings.dev_dlc);
|
ImGui::Checkbox("SETTINGS_MISC_DEV_DLC"_T.data(), &g.settings.dev_dlc);
|
||||||
|
|
||||||
|
if (ImGui::Button("Reset Settings"))
|
||||||
|
{
|
||||||
|
g.write_default_config();
|
||||||
|
g.load();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Reference in New Issue
Block a user