diff --git a/soh/soh/Enhancements/debugger/actorViewer.cpp b/soh/soh/Enhancements/debugger/actorViewer.cpp index b3fdb1dec..2bbdb569d 100644 --- a/soh/soh/Enhancements/debugger/actorViewer.cpp +++ b/soh/soh/Enhancements/debugger/actorViewer.cpp @@ -875,6 +875,57 @@ void ActorViewerWindow::DrawElement() { static std::vector actorSearchResults; if (gPlayState != nullptr) { + if (ImGui::BeginChild("options", ImVec2(0, 0), ImGuiChildFlags_Border | ImGuiChildFlags_AutoResizeY)) { + bool toggled = false; + bool optionChange = false; + + ImGui::SeparatorText("Options"); + + toggled = UIWidgets::CVarCheckbox("Actor Name Tags", CVAR_ACTOR_NAME_TAGS("Enabled"), + { { .tooltip = "Adds \"name tags\" above actors for identification" } }); + + ImGui::SameLine(); + + UIWidgets::Button("Display Items", { { .tooltip = "Click to add display items on the name tags" } }); + + if (ImGui::BeginPopupContextItem(nullptr, ImGuiPopupFlags_MouseButtonLeft | ImGuiPopupFlags_NoReopen)) { + optionChange |= UIWidgets::CVarCheckbox("ID", CVAR_ACTOR_NAME_TAGS("DisplayID")); + optionChange |= UIWidgets::CVarCheckbox("Description", CVAR_ACTOR_NAME_TAGS("DisplayDescription")); + optionChange |= UIWidgets::CVarCheckbox("Category", CVAR_ACTOR_NAME_TAGS("DisplayCategory")); + optionChange |= UIWidgets::CVarCheckbox("Params", CVAR_ACTOR_NAME_TAGS("DisplayParams")); + + ImGui::EndPopup(); + } + + optionChange |= UIWidgets::CVarCheckbox( + "Name tags with Z-Buffer", CVAR_ACTOR_NAME_TAGS("WithZBuffer"), + { { .tooltip = "Allow name tags to be obstructed when behind geometry and actors" } }); + + if (toggled || optionChange) { + bool tagsEnabled = CVarGetInteger(CVAR_ACTOR_NAME_TAGS("Enabled"), 0); + bool noOptionsEnabled = !CVarGetInteger(CVAR_ACTOR_NAME_TAGS("DisplayID"), 0) && + !CVarGetInteger(CVAR_ACTOR_NAME_TAGS("DisplayDescription"), 0) && + !CVarGetInteger(CVAR_ACTOR_NAME_TAGS("DisplayCategory"), 0) && + !CVarGetInteger(CVAR_ACTOR_NAME_TAGS("DisplayParams"), 0); + + // Save the user an extra click and prevent adding "empty" tags by enabling, + // disabling, or setting an option based on what changed + if (tagsEnabled && noOptionsEnabled) { + if (toggled) { + CVarSetInteger(CVAR_ACTOR_NAME_TAGS("DisplayID"), 1); + } else { + CVarSetInteger(CVAR_ACTOR_NAME_TAGS("Enabled"), 0); + } + } else if (optionChange && !tagsEnabled && !noOptionsEnabled) { + CVarSetInteger(CVAR_ACTOR_NAME_TAGS("Enabled"), 1); + } + + NameTag_RemoveAllByTag(DEBUG_ACTOR_NAMETAG_TAG); + ActorViewer_AddTagForAllActors(); + } + } + ImGui::EndChild(); + PushStyleCombobox(THEME_COLOR); if (ImGui::BeginCombo("Actor Type", acMapping[category])) { for (int i = 0; i < acMapping.size(); i++) { @@ -1142,6 +1193,12 @@ void ActorViewerWindow::DrawElement() { ImGui::EndDisabled(); } +void ActorViewerWindow::ResetData() { + display = nullptr; + category = ACTORCAT_SWITCH; + list.clear(); +} + void ActorViewerWindow::InitElement() { ResetData(); @@ -1172,7 +1229,7 @@ void ActorViewerWindow::InitElement() { void ActorViewer_RegisterNameTagHooks() { COND_HOOK(OnActorInit, CVAR_ACTOR_NAME_TAGS_ENABLED, - [](void* actor) { ActorViewer_AddTagForActor(static_cast(actor)); }); + [](void* actor) { ActorViewer_AddTagForActor(static_cast(actor)); }); } RegisterShipInitFunc nametagInit(ActorViewer_RegisterNameTagHooks, { CVAR_ACTOR_NAME_TAGS_ENABLED_NAME }); diff --git a/soh/soh/Enhancements/debugger/actorViewer.h b/soh/soh/Enhancements/debugger/actorViewer.h index bdcf87452..0e73aa8bc 100644 --- a/soh/soh/Enhancements/debugger/actorViewer.h +++ b/soh/soh/Enhancements/debugger/actorViewer.h @@ -11,7 +11,7 @@ class ActorViewerWindow final : public Ship::GuiWindow { using GuiWindow::GuiWindow; void DrawElement() override; - void InitElement() override{}; + void InitElement() override; void UpdateElement() override{}; private: diff --git a/soh/src/code/z_actor.c b/soh/src/code/z_actor.c index 3684cdf25..0b9d20bc5 100644 --- a/soh/src/code/z_actor.c +++ b/soh/src/code/z_actor.c @@ -3476,8 +3476,6 @@ Actor* Actor_Delete(ActorContext* actorCtx, Actor* actor, PlayState* play) { Actor* newHead; ActorDBEntry* dbEntry; - GameInteractor_ExecuteOnActorDelete(actor); - player = GET_PLAYER(play); // Execute before actor memory is freed