Add "Reset to defaults" button to CVar viewer

This commit is contained in:
Phillip Stephens 2021-06-06 13:28:16 -07:00
parent 4845ea605a
commit 73b7ba8414
Signed by: Antidote
GPG Key ID: F8BEE4C83DACA60D
1 changed files with 10 additions and 1 deletions

View File

@ -370,7 +370,16 @@ void ImGuiConsole::ShowConsoleVariablesWindow() {
ImGui::SameLine();
ImGui::InputText("Filter", &m_cvarFiltersText);
auto cvars = m_cvarMgr.cvars(hecl::CVar::EFlags::Any & ~hecl::CVar::EFlags::Hidden);
if (ImGui::Button("Reset to defaults")) {
for (auto* cv : cvars) {
if (cv->name() == "developer" || cv->name() == "cheats") {
// don't reset developer or cheats to default
continue;
}
hecl::CVarUnlocker l(cv);
cv->fromLiteralToType(cv->defaultValue());
}
}
if (ImGui::BeginTable("ConsoleVariables", 2,
ImGuiTableFlags_Resizable | ImGuiTableFlags_Sortable | ImGuiTableFlags_RowBg |
ImGuiTableFlags_BordersOuter | ImGuiTableFlags_BordersV | ImGuiTableFlags_ScrollY)) {