mirror of
https://github.com/HarbourMasters/Shipwright.git
synced 2024-11-23 01:42:19 -05:00
Minor Actor Viewer tweaks and fixes (#491)
* Show new Actor description, fix window opening * Play error sound when spawning invalid actor * Add reset button, don't reset actor when changing scene
This commit is contained in:
parent
b56426a67d
commit
950f954c89
@ -7,6 +7,7 @@
|
|||||||
#include <bit>
|
#include <bit>
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <Cvar.h>
|
||||||
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#include <z64.h>
|
#include <z64.h>
|
||||||
@ -483,7 +484,7 @@ std::map<u16, const char*> actorDescriptions = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const std::string GetActorDescription(u16 id) {
|
const std::string GetActorDescription(u16 id) {
|
||||||
return actorDescriptions[id];
|
return actorDescriptions[id] != NULL ? actorDescriptions[id] : "???";
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T> void DrawGroupWithBorder(T&& drawFunc) {
|
template <typename T> void DrawGroupWithBorder(T&& drawFunc) {
|
||||||
@ -530,6 +531,7 @@ void PopulateActorDropdown(int i, std::vector<Actor*>& data) {
|
|||||||
|
|
||||||
void DrawActorViewer(bool& open) {
|
void DrawActorViewer(bool& open) {
|
||||||
if (!open) {
|
if (!open) {
|
||||||
|
CVar_SetS32("gActorViewerEnabled", 0);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -559,7 +561,6 @@ void DrawActorViewer(bool& open) {
|
|||||||
display = empty;
|
display = empty;
|
||||||
fetch = nullptr;
|
fetch = nullptr;
|
||||||
dispOverlay = nullptr;
|
dispOverlay = nullptr;
|
||||||
newActor = { 0, 0, { 0, 0, 0 }, { 0, 0, 0 } };
|
|
||||||
actor = category = 0;
|
actor = category = 0;
|
||||||
filler = "Please Select";
|
filler = "Please Select";
|
||||||
list.clear();
|
list.clear();
|
||||||
@ -696,6 +697,7 @@ void DrawActorViewer(bool& open) {
|
|||||||
if (ImGui::TreeNode("New...")) {
|
if (ImGui::TreeNode("New...")) {
|
||||||
ImGui::PushItemWidth(ImGui::GetFontSize() * 10);
|
ImGui::PushItemWidth(ImGui::GetFontSize() * 10);
|
||||||
|
|
||||||
|
ImGui::Text(GetActorDescription(newActor.id).c_str());
|
||||||
ImGui::InputScalar("ID", ImGuiDataType_S16, &newActor.id, &one);
|
ImGui::InputScalar("ID", ImGuiDataType_S16, &newActor.id, &one);
|
||||||
ImGui::InputScalar("params", ImGuiDataType_S16, &newActor.params, &one);
|
ImGui::InputScalar("params", ImGuiDataType_S16, &newActor.params, &one);
|
||||||
|
|
||||||
@ -728,18 +730,31 @@ void DrawActorViewer(bool& open) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (ImGui::Button("Spawn")) {
|
if (ImGui::Button("Spawn")) {
|
||||||
|
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,
|
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);
|
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")) {
|
if (ImGui::Button("Spawn as Child")) {
|
||||||
Actor* parent = &display;
|
Actor* parent = &display;
|
||||||
if (parent != NULL) {
|
if (parent != NULL) {
|
||||||
|
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,
|
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.pos.y, newActor.pos.z, newActor.rot.x, newActor.rot.y,
|
||||||
newActor.params);
|
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();
|
ImGui::TreePop();
|
||||||
}
|
}
|
||||||
@ -748,7 +763,6 @@ void DrawActorViewer(bool& open) {
|
|||||||
if (needs_reset) {
|
if (needs_reset) {
|
||||||
fetch = nullptr;
|
fetch = nullptr;
|
||||||
dispOverlay = nullptr;
|
dispOverlay = nullptr;
|
||||||
newActor = { 0, 0, { 0, 0, 0 }, { 0, 0, 0 } };
|
|
||||||
actor = category = 0;
|
actor = category = 0;
|
||||||
filler = "Please Select";
|
filler = "Please Select";
|
||||||
list.clear();
|
list.clear();
|
||||||
|
Loading…
Reference in New Issue
Block a user