From dd683e8e48817e5746f06b5ce3c670d89e3f5c59 Mon Sep 17 00:00:00 2001 From: Andrea Odetti Date: Sun, 4 Apr 2021 14:31:57 +0100 Subject: [PATCH] ImGui: display all current registry settings. Signed-off-by: Andrea Odetti --- source/frontends/common2/ptreeregistry.cpp | 13 ++++++++ source/frontends/common2/ptreeregistry.h | 2 ++ source/frontends/qt/configuration.cpp | 5 +++ source/frontends/qt/configuration.h | 2 ++ source/frontends/sdl/imgui/sdlsettings.cpp | 39 ++++++++++++++++++++++ source/linux/registry.h | 4 +++ 6 files changed, 65 insertions(+) diff --git a/source/frontends/common2/ptreeregistry.cpp b/source/frontends/common2/ptreeregistry.cpp index 671be460..8f4ce101 100644 --- a/source/frontends/common2/ptreeregistry.cpp +++ b/source/frontends/common2/ptreeregistry.cpp @@ -66,4 +66,17 @@ namespace common2 myINI.put(path, value); } + std::map> PTreeRegistry::getAllValues() const + { + std::map> values; + for (const auto & it1 : myINI) + { + for (const auto & it2 : it1.second) + { + values[it1.first][it2.first] = it2.second.get_value(); + } + } + return values; + } + } diff --git a/source/frontends/common2/ptreeregistry.h b/source/frontends/common2/ptreeregistry.h index 443615de..0e3af57a 100644 --- a/source/frontends/common2/ptreeregistry.h +++ b/source/frontends/common2/ptreeregistry.h @@ -33,6 +33,8 @@ namespace common2 template void putValue(const std::string & section, const std::string & key, const T & value); + std::map> getAllValues() const override; + protected: ini_t myINI; }; diff --git a/source/frontends/qt/configuration.cpp b/source/frontends/qt/configuration.cpp index 4867b967..eb6a6964 100644 --- a/source/frontends/qt/configuration.cpp +++ b/source/frontends/qt/configuration.cpp @@ -44,3 +44,8 @@ void Configuration::putDWord(const std::string & section, const std::string & ke { mySettings.setValue(getKey(section, key), QVariant::fromValue(value)); } + +std::map> Configuration::getAllValues() const +{ + throw std::runtime_error("Configuration::getAllValues not implemented."); +} diff --git a/source/frontends/qt/configuration.h b/source/frontends/qt/configuration.h index ee3f1e96..f1bfcbe7 100644 --- a/source/frontends/qt/configuration.h +++ b/source/frontends/qt/configuration.h @@ -15,6 +15,8 @@ public: void putString(const std::string & section, const std::string & key, const std::string & value) override; void putDWord(const std::string & section, const std::string & key, const DWORD value) override; + std::map> getAllValues() const override; + private: QSettings mySettings; }; diff --git a/source/frontends/sdl/imgui/sdlsettings.cpp b/source/frontends/sdl/imgui/sdlsettings.cpp index 2194ef0f..0f1ffd15 100644 --- a/source/frontends/sdl/imgui/sdlsettings.cpp +++ b/source/frontends/sdl/imgui/sdlsettings.cpp @@ -2,6 +2,7 @@ #include "frontends/sdl/imgui/sdlsettings.h" #include "frontends/sdl/imgui/settingshelper.h" #include "frontends/sdl/sdlframe.h" +#include "linux/registry.h" #include "Interface.h" #include "CardManager.h" @@ -555,6 +556,44 @@ namespace sa2 ImGui::EndTabItem(); } + if (ImGui::BeginTabItem("Registry")) + { + if (ImGui::BeginTable("Registry", 2, ImGuiTableFlags_RowBg | ImGuiTableFlags_SizingFixedFit)) + { + ImGui::TableSetupColumn("Option", ImGuiTableColumnFlags_WidthFixed); + ImGui::TableSetupColumn("Value", ImGuiTableColumnFlags_WidthStretch); + ImGui::TableHeadersRow(); + + ImGui::TableNextRow(); + ImGui::TableNextColumn(); + if (ImGui::TreeNode("Registry")) + { + const std::map> values = Registry::instance->getAllValues(); + + for (const auto & it1 : values) + { + ImGui::TableNextRow(); + ImGui::TableNextColumn(); + if (ImGui::TreeNodeEx(it1.first.c_str(), ImGuiTreeNodeFlags_SpanFullWidth)) + { + for (const auto & it2 : it1.second) + { + ImGui::TableNextRow(); + ImGui::TableNextColumn(); + ImGui::TreeNodeEx(it2.first.c_str(), ImGuiTreeNodeFlags_Leaf | ImGuiTreeNodeFlags_Bullet | ImGuiTreeNodeFlags_NoTreePushOnOpen | ImGuiTreeNodeFlags_SpanFullWidth); + ImGui::TableNextColumn(); + ImGui::TextUnformatted(it2.second.c_str()); + } + ImGui::TreePop(); + } + } + ImGui::TreePop(); + } + ImGui::EndTable(); + } + ImGui::EndTabItem(); + } + ImGui::EndTabBar(); } diff --git a/source/linux/registry.h b/source/linux/registry.h index fdee8b45..de3b808d 100644 --- a/source/linux/registry.h +++ b/source/linux/registry.h @@ -2,6 +2,7 @@ #include "linux/windows/wincompat.h" #include +#include #include #include @@ -18,6 +19,9 @@ public: virtual void putString(const std::string & section, const std::string & key, const std::string & value) = 0; virtual void putDWord(const std::string & section, const std::string & key, const DWORD value) = 0; + + virtual std::map> getAllValues() const = 0; + }; BOOL RegLoadString (LPCTSTR section, LPCTSTR key, BOOL peruser, LPTSTR buffer, DWORD chars);