From d655a7e364222fadf70f40503620db76502f0110 Mon Sep 17 00:00:00 2001 From: ajanhallinta <4janhallinta@gmail.com> Date: Thu, 16 Jun 2022 12:41:35 +0300 Subject: [PATCH 1/3] Show new Actor description, fix window opening --- soh/soh/Enhancements/debugger/actorViewer.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/soh/soh/Enhancements/debugger/actorViewer.cpp b/soh/soh/Enhancements/debugger/actorViewer.cpp index 54c5f0770c6..8c04bcd0b1b 100644 --- a/soh/soh/Enhancements/debugger/actorViewer.cpp +++ b/soh/soh/Enhancements/debugger/actorViewer.cpp @@ -7,6 +7,7 @@ #include #include #include +#include extern "C" { #include @@ -483,7 +484,7 @@ std::map actorDescriptions = { }; const std::string GetActorDescription(u16 id) { - return actorDescriptions[id]; + return actorDescriptions[id] != NULL ? actorDescriptions[id] : "???"; } template void DrawGroupWithBorder(T&& drawFunc) { @@ -530,6 +531,7 @@ void PopulateActorDropdown(int i, std::vector& data) { void DrawActorViewer(bool& open) { if (!open) { + CVar_SetS32("gActorViewerEnabled", 0); return; } @@ -696,6 +698,7 @@ void DrawActorViewer(bool& open) { if (ImGui::TreeNode("New...")) { ImGui::PushItemWidth(ImGui::GetFontSize() * 10); + ImGui::Text(GetActorDescription(newActor.id).c_str()); ImGui::InputScalar("ID", ImGuiDataType_S16, &newActor.id, &one); ImGui::InputScalar("params", ImGuiDataType_S16, &newActor.params, &one); From 829a7849d1c2ec88eda3917baaabbffc45cc6ff5 Mon Sep 17 00:00:00 2001 From: ajanhallinta <4janhallinta@gmail.com> Date: Thu, 16 Jun 2022 13:30:43 +0300 Subject: [PATCH 2/3] Play error sound when spawning invalid actor --- soh/soh/Enhancements/debugger/actorViewer.cpp | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/soh/soh/Enhancements/debugger/actorViewer.cpp b/soh/soh/Enhancements/debugger/actorViewer.cpp index 8c04bcd0b1b..52ac3f60b2d 100644 --- a/soh/soh/Enhancements/debugger/actorViewer.cpp +++ b/soh/soh/Enhancements/debugger/actorViewer.cpp @@ -731,16 +731,25 @@ void DrawActorViewer(bool& open) { } if (ImGui::Button("Spawn")) { - Actor_Spawn(&gGlobalCtx->actorCtx, gGlobalCtx, newActor.id, newActor.pos.x, newActor.pos.y, - newActor.pos.z, newActor.rot.x, newActor.rot.y, newActor.rot.z, newActor.params); + if (newActor.id >= 0 && newActor.id < ACTOR_ID_MAX && gActorOverlayTable[newActor.id].initInfo != NULL) { + Actor_Spawn(&gGlobalCtx->actorCtx, gGlobalCtx, newActor.id, newActor.pos.x, newActor.pos.y, + newActor.pos.z, newActor.rot.x, newActor.rot.y, newActor.rot.z, newActor.params); + } else { + func_80078884(NA_SE_SY_ERROR); + } } if (ImGui::Button("Spawn as Child")) { Actor* parent = &display; if (parent != NULL) { - Actor_SpawnAsChild(&gGlobalCtx->actorCtx, parent, gGlobalCtx, newActor.id, newActor.pos.x, - newActor.pos.y, newActor.pos.z, newActor.rot.x, newActor.rot.y, newActor.rot.z, - newActor.params); + if (newActor.id >= 0 && newActor.id < ACTOR_ID_MAX && + gActorOverlayTable[newActor.id].initInfo != NULL) { + Actor_SpawnAsChild(&gGlobalCtx->actorCtx, parent, gGlobalCtx, newActor.id, newActor.pos.x, + newActor.pos.y, newActor.pos.z, newActor.rot.x, newActor.rot.y, + newActor.rot.z, newActor.params); + } else { + func_80078884(NA_SE_SY_ERROR); + } } } From bb964be559cce174526cbc392bf4c1c08662a8ba Mon Sep 17 00:00:00 2001 From: ajanhallinta <4janhallinta@gmail.com> Date: Thu, 16 Jun 2022 13:41:27 +0300 Subject: [PATCH 3/3] Add reset button, don't reset actor when changing scene --- soh/soh/Enhancements/debugger/actorViewer.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/soh/soh/Enhancements/debugger/actorViewer.cpp b/soh/soh/Enhancements/debugger/actorViewer.cpp index 52ac3f60b2d..a3294797bcf 100644 --- a/soh/soh/Enhancements/debugger/actorViewer.cpp +++ b/soh/soh/Enhancements/debugger/actorViewer.cpp @@ -561,7 +561,6 @@ void DrawActorViewer(bool& open) { display = empty; fetch = nullptr; dispOverlay = nullptr; - newActor = { 0, 0, { 0, 0, 0 }, { 0, 0, 0 } }; actor = category = 0; filler = "Please Select"; list.clear(); @@ -753,6 +752,10 @@ void DrawActorViewer(bool& open) { } } + if (ImGui::Button("Reset")) { + newActor = { 0, 0, { 0, 0, 0 }, { 0, 0, 0 } }; + } + ImGui::TreePop(); } } else { @@ -760,7 +763,6 @@ void DrawActorViewer(bool& open) { if (needs_reset) { fetch = nullptr; dispOverlay = nullptr; - newActor = { 0, 0, { 0, 0, 0 }, { 0, 0, 0 } }; actor = category = 0; filler = "Please Select"; list.clear();