summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornclok1405 <155463060+nclok1405@users.noreply.github.com>2025-12-04 00:58:32 +0900
committerGitHub <noreply@github.com>2025-12-03 08:58:32 -0700
commit17f7c3e8f5b1cc664efdd67d52e28326e607d0af (patch)
treeb2067d31edd761bb02d2ca9d35665de7fd93b66b
parent42282c804e8b30f95f1b83848bf88f2fe584dd61 (diff)
Add Expand All/Collapse All buttons to Hook Debugger (#6002)
-rw-r--r--soh/soh/Enhancements/debugger/hookDebugger.cpp35
-rw-r--r--soh/soh/Enhancements/debugger/hookDebugger.h5
2 files changed, 40 insertions, 0 deletions
diff --git a/soh/soh/Enhancements/debugger/hookDebugger.cpp b/soh/soh/Enhancements/debugger/hookDebugger.cpp
index 146db2ddc..709bbb1d4 100644
--- a/soh/soh/Enhancements/debugger/hookDebugger.cpp
+++ b/soh/soh/Enhancements/debugger/hookDebugger.cpp
@@ -1,4 +1,5 @@
#include "hookDebugger.h"
+#include "soh/SohGui/SohGui.hpp"
#include "soh/Enhancements/game-interactor/GameInteractor.h"
#include "soh/SohGui/UIWidgets.hpp"
#include "soh/OTRGlobals.h"
@@ -7,6 +8,9 @@
static std::map<const char*, std::map<HOOK_ID, HookInfo>*> hookData;
+static bool hookOptCollapseAll; // A bool that will collapse all hook group once
+static bool hookOptExpandAll; // A bool that will expand all hook group once
+
const ImVec4 grey = ImVec4(0.75, 0.75, 0.75, 1);
const ImVec4 yellow = ImVec4(1, 1, 0, 1);
const ImVec4 red = ImVec4(1, 0, 0, 1);
@@ -77,6 +81,9 @@ void DrawHookRegisteringInfos(const char* hookName) {
}
void HookDebuggerWindow::DrawElement() {
+ bool collapseLogic = false;
+ bool doingCollapseOrExpand = hookOptExpandAll || hookOptCollapseAll;
+
ImGui::BeginDisabled(CVarGetInteger(CVAR_SETTING("DisableChanges"), 0));
#ifndef __cpp_lib_source_location
ImGui::TextColored(yellow, "Some features of the Hook Debugger are unavailable because SoH was compiled "
@@ -84,9 +91,29 @@ void HookDebuggerWindow::DrawElement() {
"(\"__cpp_lib_source_location\" not defined in \"<version>\").");
#endif
+ if (UIWidgets::Button("Expand All", UIWidgets::ButtonOptions().Color(THEME_COLOR).Size(UIWidgets::Sizes::Inline))) {
+ hookOptCollapseAll = false;
+ hookOptExpandAll = true;
+ }
+ ImGui::SameLine();
+ if (UIWidgets::Button("Collapse All",
+ UIWidgets::ButtonOptions().Color(THEME_COLOR).Size(UIWidgets::Sizes::Inline))) {
+ hookOptExpandAll = false;
+ hookOptCollapseAll = true;
+ }
+
ImGui::PushFont(OTRGlobals::Instance->fontMonoLarger);
for (auto& [hookName, _] : hookData) {
+ if (doingCollapseOrExpand) {
+ if (hookOptExpandAll) {
+ collapseLogic = true;
+ } else if (hookOptCollapseAll) {
+ collapseLogic = false;
+ }
+ ImGui::SetNextItemOpen(collapseLogic, ImGuiCond_Always);
+ }
+
if (ImGui::TreeNode(hookName)) {
DrawHookRegisteringInfos(hookName);
ImGui::TreePop();
@@ -95,9 +122,17 @@ void HookDebuggerWindow::DrawElement() {
ImGui::PopFont();
ImGui::EndDisabled();
+
+ if (doingCollapseOrExpand) {
+ hookOptExpandAll = false;
+ hookOptCollapseAll = false;
+ }
}
void HookDebuggerWindow::InitElement() {
+ hookOptExpandAll = false;
+ hookOptCollapseAll = false;
+
#define DEFINE_HOOK(name, _) hookData.insert({ #name, GameInteractor::Instance->GetHookData<GameInteractor::name>() });
#include "../game-interactor/GameInteractor_HookTable.h"
diff --git a/soh/soh/Enhancements/debugger/hookDebugger.h b/soh/soh/Enhancements/debugger/hookDebugger.h
index 1a586a09c..c1f439f30 100644
--- a/soh/soh/Enhancements/debugger/hookDebugger.h
+++ b/soh/soh/Enhancements/debugger/hookDebugger.h
@@ -1,3 +1,6 @@
+#ifndef hookDebugger_h
+#define hookDebugger_h
+
#include <libultraship/libultraship.h>
class HookDebuggerWindow final : public Ship::GuiWindow {
@@ -8,3 +11,5 @@ class HookDebuggerWindow final : public Ship::GuiWindow {
void DrawElement() override;
void UpdateElement() override{};
};
+
+#endif // hookDebugger_h