Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minor Actor Viewer tweaks and fixes #491

Merged
merged 3 commits into from
Jun 20, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 22 additions & 8 deletions soh/soh/Enhancements/debugger/actorViewer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include <bit>
#include <map>
#include <string>
#include <Cvar.h>

extern "C" {
#include <z64.h>
Expand Down Expand Up @@ -483,7 +484,7 @@ std::map<u16, const char*> actorDescriptions = {
};

const std::string GetActorDescription(u16 id) {
return actorDescriptions[id];
return actorDescriptions[id] != NULL ? actorDescriptions[id] : "???";
}

template <typename T> void DrawGroupWithBorder(T&& drawFunc) {
Expand Down Expand Up @@ -530,6 +531,7 @@ void PopulateActorDropdown(int i, std::vector<Actor*>& data) {

void DrawActorViewer(bool& open) {
if (!open) {
CVar_SetS32("gActorViewerEnabled", 0);
return;
}

Expand Down Expand Up @@ -559,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();
Expand Down Expand Up @@ -696,6 +697,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);

Expand Down Expand Up @@ -728,27 +730,39 @@ 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);
}
}
}

if (ImGui::Button("Reset")) {
newActor = { 0, 0, { 0, 0, 0 }, { 0, 0, 0 } };
}

ImGui::TreePop();
}
} else {
ImGui::Text("Global Context needed for actor info!");
if (needs_reset) {
fetch = nullptr;
dispOverlay = nullptr;
newActor = { 0, 0, { 0, 0, 0 }, { 0, 0, 0 } };
actor = category = 0;
filler = "Please Select";
list.clear();
Expand Down