From 79ff4420d9c6f037d4fe11a307a77ed912cb8184 Mon Sep 17 00:00:00 2001 From: Dentomologist Date: Sun, 2 Feb 2025 20:00:10 -0800 Subject: [PATCH] ImGui: Remember position of movable overlays Remember the position of various moveable overlays so users don't have to move them every time they start a new game. Window data is stored in Config/ImGui.ini. Affected overlays: - NetPlay Chat - NetPlay Golf - Movie statistics - All of the overlays in the Graphics->Advanced tab - Scissor Rectangles --- Source/Core/Common/CommonPaths.h | 1 + Source/Core/Common/FileUtil.cpp | 2 ++ Source/Core/Common/FileUtil.h | 1 + Source/Core/VideoCommon/OnScreenUI.cpp | 4 ++-- Source/Core/VideoCommon/PerformanceMetrics.cpp | 6 +++--- 5 files changed, 9 insertions(+), 5 deletions(-) diff --git a/Source/Core/Common/CommonPaths.h b/Source/Core/Common/CommonPaths.h index 0f6b7adfb6..810630bd1a 100644 --- a/Source/Core/Common/CommonPaths.h +++ b/Source/Core/Common/CommonPaths.h @@ -107,6 +107,7 @@ #define DUALSHOCKUDPCLIENT_CONFIG "DSUClient.ini" #define FREELOOK_CONFIG "FreeLook.ini" #define RETROACHIEVEMENTS_CONFIG "RetroAchievements.ini" +#define IMGUI_CONFIG "ImGui.ini" // Files in the directory returned by GetUserPath(D_LOGS_IDX) #define MAIN_LOG "dolphin.log" diff --git a/Source/Core/Common/FileUtil.cpp b/Source/Core/Common/FileUtil.cpp index ee2b330812..7f2570f70a 100644 --- a/Source/Core/Common/FileUtil.cpp +++ b/Source/Core/Common/FileUtil.cpp @@ -898,6 +898,7 @@ static void RebuildUserDirectories(unsigned int dir_index) s_user_paths[F_FREELOOKCONFIG_IDX] = s_user_paths[D_CONFIG_IDX] + FREELOOK_CONFIG; s_user_paths[F_RETROACHIEVEMENTSCONFIG_IDX] = s_user_paths[D_CONFIG_IDX] + RETROACHIEVEMENTS_CONFIG; + s_user_paths[F_IMGUICONFIG_IDX] = s_user_paths[D_CONFIG_IDX] + IMGUI_CONFIG; s_user_paths[F_MAINLOG_IDX] = s_user_paths[D_LOGS_IDX] + MAIN_LOG; s_user_paths[F_MEM1DUMP_IDX] = s_user_paths[D_DUMP_IDX] + MEM1_DUMP; s_user_paths[F_MEM2DUMP_IDX] = s_user_paths[D_DUMP_IDX] + MEM2_DUMP; @@ -935,6 +936,7 @@ static void RebuildUserDirectories(unsigned int dir_index) s_user_paths[F_FREELOOKCONFIG_IDX] = s_user_paths[D_CONFIG_IDX] + FREELOOK_CONFIG; s_user_paths[F_RETROACHIEVEMENTSCONFIG_IDX] = s_user_paths[D_CONFIG_IDX] + RETROACHIEVEMENTS_CONFIG; + s_user_paths[F_IMGUICONFIG_IDX] = s_user_paths[D_CONFIG_IDX] + IMGUI_CONFIG; break; case D_CACHE_IDX: diff --git a/Source/Core/Common/FileUtil.h b/Source/Core/Common/FileUtil.h index a887ffd8f3..f1d1dec54f 100644 --- a/Source/Core/Common/FileUtil.h +++ b/Source/Core/Common/FileUtil.h @@ -96,6 +96,7 @@ enum F_FREELOOKCONFIG_IDX, F_GBABIOS_IDX, F_RETROACHIEVEMENTSCONFIG_IDX, + F_IMGUICONFIG_IDX, NUM_PATH_INDICES }; diff --git a/Source/Core/VideoCommon/OnScreenUI.cpp b/Source/Core/VideoCommon/OnScreenUI.cpp index 23e11ce1cf..43545601ac 100644 --- a/Source/Core/VideoCommon/OnScreenUI.cpp +++ b/Source/Core/VideoCommon/OnScreenUI.cpp @@ -4,6 +4,7 @@ #include "VideoCommon/OnScreenUI.h" #include "Common/EnumMap.h" +#include "Common/FileUtil.h" #include "Common/Profiler.h" #include "Common/Timer.h" @@ -54,8 +55,7 @@ bool OnScreenUI::Initialize(u32 width, u32 height, float scale) return false; } - // Don't create an ini file. TODO: Do we want this in the future? - ImGui::GetIO().IniFilename = nullptr; + ImGui::GetIO().IniFilename = File::GetUserPath(F_IMGUICONFIG_IDX).data(); SetScale(scale); PortableVertexDeclaration vdecl = {}; diff --git a/Source/Core/VideoCommon/PerformanceMetrics.cpp b/Source/Core/VideoCommon/PerformanceMetrics.cpp index 1272b460e3..707055816f 100644 --- a/Source/Core/VideoCommon/PerformanceMetrics.cpp +++ b/Source/Core/VideoCommon/PerformanceMetrics.cpp @@ -83,9 +83,9 @@ double PerformanceMetrics::GetLastSpeedDenominator() const void PerformanceMetrics::DrawImGuiStats(const float backbuffer_scale) { const float bg_alpha = 0.7f; - const auto imgui_flags = ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoSavedSettings | - ImGuiWindowFlags_NoScrollbar | ImGuiWindowFlags_NoNav | - ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoFocusOnAppearing; + const auto imgui_flags = ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoScrollbar | + ImGuiWindowFlags_NoNav | ImGuiWindowFlags_AlwaysAutoResize | + ImGuiWindowFlags_NoFocusOnAppearing; const double fps = GetFPS(); const double vps = GetVPS();