Add Expand All/Collapse All buttons to Hook Debugger (#6002)
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
#include "hookDebugger.h"
|
#include "hookDebugger.h"
|
||||||
|
#include "soh/SohGui/SohGui.hpp"
|
||||||
#include "soh/Enhancements/game-interactor/GameInteractor.h"
|
#include "soh/Enhancements/game-interactor/GameInteractor.h"
|
||||||
#include "soh/SohGui/UIWidgets.hpp"
|
#include "soh/SohGui/UIWidgets.hpp"
|
||||||
#include "soh/OTRGlobals.h"
|
#include "soh/OTRGlobals.h"
|
||||||
@@ -7,6 +8,9 @@
|
|||||||
|
|
||||||
static std::map<const char*, std::map<HOOK_ID, HookInfo>*> hookData;
|
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 grey = ImVec4(0.75, 0.75, 0.75, 1);
|
||||||
const ImVec4 yellow = ImVec4(1, 1, 0, 1);
|
const ImVec4 yellow = ImVec4(1, 1, 0, 1);
|
||||||
const ImVec4 red = ImVec4(1, 0, 0, 1);
|
const ImVec4 red = ImVec4(1, 0, 0, 1);
|
||||||
@@ -77,6 +81,9 @@ void DrawHookRegisteringInfos(const char* hookName) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void HookDebuggerWindow::DrawElement() {
|
void HookDebuggerWindow::DrawElement() {
|
||||||
|
bool collapseLogic = false;
|
||||||
|
bool doingCollapseOrExpand = hookOptExpandAll || hookOptCollapseAll;
|
||||||
|
|
||||||
ImGui::BeginDisabled(CVarGetInteger(CVAR_SETTING("DisableChanges"), 0));
|
ImGui::BeginDisabled(CVarGetInteger(CVAR_SETTING("DisableChanges"), 0));
|
||||||
#ifndef __cpp_lib_source_location
|
#ifndef __cpp_lib_source_location
|
||||||
ImGui::TextColored(yellow, "Some features of the Hook Debugger are unavailable because SoH was compiled "
|
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>\").");
|
"(\"__cpp_lib_source_location\" not defined in \"<version>\").");
|
||||||
#endif
|
#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);
|
ImGui::PushFont(OTRGlobals::Instance->fontMonoLarger);
|
||||||
|
|
||||||
for (auto& [hookName, _] : hookData) {
|
for (auto& [hookName, _] : hookData) {
|
||||||
|
if (doingCollapseOrExpand) {
|
||||||
|
if (hookOptExpandAll) {
|
||||||
|
collapseLogic = true;
|
||||||
|
} else if (hookOptCollapseAll) {
|
||||||
|
collapseLogic = false;
|
||||||
|
}
|
||||||
|
ImGui::SetNextItemOpen(collapseLogic, ImGuiCond_Always);
|
||||||
|
}
|
||||||
|
|
||||||
if (ImGui::TreeNode(hookName)) {
|
if (ImGui::TreeNode(hookName)) {
|
||||||
DrawHookRegisteringInfos(hookName);
|
DrawHookRegisteringInfos(hookName);
|
||||||
ImGui::TreePop();
|
ImGui::TreePop();
|
||||||
@@ -95,9 +122,17 @@ void HookDebuggerWindow::DrawElement() {
|
|||||||
|
|
||||||
ImGui::PopFont();
|
ImGui::PopFont();
|
||||||
ImGui::EndDisabled();
|
ImGui::EndDisabled();
|
||||||
|
|
||||||
|
if (doingCollapseOrExpand) {
|
||||||
|
hookOptExpandAll = false;
|
||||||
|
hookOptCollapseAll = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void HookDebuggerWindow::InitElement() {
|
void HookDebuggerWindow::InitElement() {
|
||||||
|
hookOptExpandAll = false;
|
||||||
|
hookOptCollapseAll = false;
|
||||||
|
|
||||||
#define DEFINE_HOOK(name, _) hookData.insert({ #name, GameInteractor::Instance->GetHookData<GameInteractor::name>() });
|
#define DEFINE_HOOK(name, _) hookData.insert({ #name, GameInteractor::Instance->GetHookData<GameInteractor::name>() });
|
||||||
|
|
||||||
#include "../game-interactor/GameInteractor_HookTable.h"
|
#include "../game-interactor/GameInteractor_HookTable.h"
|
||||||
|
|||||||
@@ -1,3 +1,6 @@
|
|||||||
|
#ifndef hookDebugger_h
|
||||||
|
#define hookDebugger_h
|
||||||
|
|
||||||
#include <libultraship/libultraship.h>
|
#include <libultraship/libultraship.h>
|
||||||
|
|
||||||
class HookDebuggerWindow final : public Ship::GuiWindow {
|
class HookDebuggerWindow final : public Ship::GuiWindow {
|
||||||
@@ -8,3 +11,5 @@ class HookDebuggerWindow final : public Ship::GuiWindow {
|
|||||||
void DrawElement() override;
|
void DrawElement() override;
|
||||||
void UpdateElement() override{};
|
void UpdateElement() override{};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#endif // hookDebugger_h
|
||||||
|
|||||||
Reference in New Issue
Block a user