From 73b7ba8414ca8f591c4a488c5e3b19f0a3feb362 Mon Sep 17 00:00:00 2001 From: Phillip Stephens Date: Sun, 6 Jun 2021 13:28:16 -0700 Subject: [PATCH] Add "Reset to defaults" button to CVar viewer --- Runtime/ImGuiConsole.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/Runtime/ImGuiConsole.cpp b/Runtime/ImGuiConsole.cpp index 8d520c037..4c7b1e310 100644 --- a/Runtime/ImGuiConsole.cpp +++ b/Runtime/ImGuiConsole.cpp @@ -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)) {