From eee01f5857ebb50e2fbc6f87620e078ca8ff915d Mon Sep 17 00:00:00 2001 From: Vinicius Rangel Date: Thu, 3 Oct 2024 21:55:51 -0300 Subject: [PATCH] devtools: change basic fps scale --- src/core/devtools/layer.cpp | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/src/core/devtools/layer.cpp b/src/core/devtools/layer.cpp index de0789223..0c7e85e4c 100644 --- a/src/core/devtools/layer.cpp +++ b/src/core/devtools/layer.cpp @@ -17,7 +17,9 @@ using namespace ImGui; using namespace Core::Devtools; using L = Core::Devtools::Layer; -static bool show_simple_fps = true; +static bool show_simple_fps = false; +static float fps_scale = 1.0f; + static bool show_advanced_debug = false; static int dump_frame_count = 1; @@ -149,7 +151,10 @@ void L::SetupSettings() { }; handler.ReadLineFn = [](ImGuiContext*, ImGuiSettingsHandler*, void*, const char* line) { int v; - if (sscanf(line, "show_advanced_debug=%d", &v) == 1) { + float f; + if (sscanf(line, "fps_scale=%f", &f) == 1) { + fps_scale = f; + } else if (sscanf(line, "show_advanced_debug=%d", &v) == 1) { show_advanced_debug = v != 0; } else if (sscanf(line, "show_frame_graph=%d", &v) == 1) { frame_graph.is_open = v != 0; @@ -159,6 +164,7 @@ void L::SetupSettings() { }; handler.WriteAllFn = [](ImGuiContext*, ImGuiSettingsHandler* handler, ImGuiTextBuffer* buf) { buf->appendf("[%s][Data]\n", handler->TypeName); + buf->appendf("fps_scale=%f\n", fps_scale); buf->appendf("show_advanced_debug=%d\n", show_advanced_debug); buf->appendf("show_frame_graph=%d\n", frame_graph.is_open); buf->appendf("dump_frame_count=%d\n", dump_frame_count); @@ -190,11 +196,24 @@ void L::Draw() { } if (show_simple_fps) { - SetWindowPos("Video Info", {999999.0f, 0.0f}, ImGuiCond_FirstUseEver); if (Begin("Video Info", nullptr, ImGuiWindowFlags_NoNav | ImGuiWindowFlags_NoDecoration | ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoDocking)) { + SetWindowPos("Video Info", {999999.0f, 0.0f}, ImGuiCond_FirstUseEver); + if (BeginPopupContextWindow()) { +#define M(label, value) \ + if (MenuItem(label, nullptr, fps_scale == value)) \ + fps_scale = value + M("0.5x", 0.5f); + M("1.0x", 1.0f); + M("1.5x", 1.5f); + M("2.0x", 2.0f); + M("2.5x", 2.5f); + EndPopup(); +#undef M + } KeepWindowInside(); + SetWindowFontScale(fps_scale); DrawSimple(); } End();