Inspect window filter & Patterned body state info

This commit is contained in:
Luke Street 2021-05-26 15:57:59 -04:00
parent 7f5eeb89eb
commit 256685c611
5 changed files with 124 additions and 11 deletions

View File

@ -1,5 +1,5 @@
set(CHARACTER_SOURCES set(CHARACTER_SOURCES
CharacterCommon.hpp CharacterCommon.hpp CharacterCommon.cpp
CAssetFactory.hpp CAssetFactory.cpp CAssetFactory.hpp CAssetFactory.cpp
CCharacterFactory.hpp CCharacterFactory.cpp CCharacterFactory.hpp CCharacterFactory.cpp
CModelData.hpp CModelData.cpp CModelData.hpp CModelData.cpp

View File

@ -0,0 +1,62 @@
#include "CharacterCommon.hpp"
using namespace std::literals;
namespace metaforce::pas {
std::string_view AnimationStateToStr(EAnimationState state) {
switch (state) {
case EAnimationState::Invalid:
return "Invalid"sv;
case EAnimationState::Fall:
return "Fall"sv;
case EAnimationState::Getup:
return "Getup"sv;
case EAnimationState::LieOnGround:
return "LieOnGround"sv;
case EAnimationState::Step:
return "Step"sv;
case EAnimationState::Death:
return "Death"sv;
case EAnimationState::Locomotion:
return "Locomotion"sv;
case EAnimationState::KnockBack:
return "KnockBack"sv;
case EAnimationState::MeleeAttack:
return "MeleeAttack"sv;
case EAnimationState::Turn:
return "Turn"sv;
case EAnimationState::LoopAttack:
return "LoopAttack"sv;
case EAnimationState::LoopReaction:
return "LoopReaction"sv;
case EAnimationState::GroundHit:
return "GroundHit"sv;
case EAnimationState::Generate:
return "Generate"sv;
case EAnimationState::Jump:
return "Jump"sv;
case EAnimationState::Hurled:
return "Hurled"sv;
case EAnimationState::Slide:
return "Slide"sv;
case EAnimationState::Taunt:
return "Taunt"sv;
case EAnimationState::Scripted:
return "Scripted"sv;
case EAnimationState::ProjectileAttack:
return "ProjectileAttack"sv;
case EAnimationState::Cover:
return "Cover"sv;
case EAnimationState::WallHang:
return "WallHang"sv;
case EAnimationState::AdditiveIdle:
return "AdditiveIdle"sv;
case EAnimationState::AdditiveAim:
return "AdditiveAim"sv;
case EAnimationState::AdditiveFlinch:
return "AdditiveFlinch"sv;
case EAnimationState::AdditiveReaction:
return "AdditiveReaction"sv;
}
}
} // namespace metaforce::pas

View File

@ -1,5 +1,7 @@
#pragma once #pragma once
#include <string_view>
namespace metaforce { namespace metaforce {
namespace pas { namespace pas {
enum class ELocomotionType { enum class ELocomotionType {
@ -52,6 +54,8 @@ enum class EAnimationState {
AdditiveReaction = 24 AdditiveReaction = 24
}; };
std::string_view AnimationStateToStr(EAnimationState state);
enum class EHurledState { enum class EHurledState {
Invalid = -1, Invalid = -1,
KnockIntoAir, KnockIntoAir,

View File

@ -90,6 +90,11 @@ static void Warp(const CAssetId worldId, TAreaId aId) {
} }
} }
bool containsCaseInsensitive(std::string_view str, std::string_view val) {
return std::search(str.begin(), str.end(), val.begin(), val.end(),
[](char ch1, char ch2) { return std::toupper(ch1) == std::toupper(ch2); }) != str.end();
}
static bool stepFrame = false; static bool stepFrame = false;
static void ShowMenuGame() { static void ShowMenuGame() {
@ -120,9 +125,7 @@ static void ShowMenuGame() {
} }
} }
void ImGuiStringViewText(std::string_view text) { void ImGuiStringViewText(std::string_view text) { ImGui::TextUnformatted(text.begin(), text.end()); }
ImGui::TextUnformatted(text.begin(), text.end());
}
static void LerpActorColor(CActor* act) { static void LerpActorColor(CActor* act) {
act->m_debugAddColorTime += 1.f / 60.f; act->m_debugAddColorTime += 1.f / 60.f;
@ -137,6 +140,7 @@ static void LerpActorColor(CActor* act) {
} }
static void ShowInspectWindow(bool* isOpen) { static void ShowInspectWindow(bool* isOpen) {
static std::array<char, 40> filterText{};
if (ImGui::Begin("Inspect", isOpen)) { if (ImGui::Begin("Inspect", isOpen)) {
CObjectList& list = *g_StateManager->GetObjectList(); CObjectList& list = *g_StateManager->GetObjectList();
ImGui::Text("Objects: %d / 1024", list.size()); ImGui::Text("Objects: %d / 1024", list.size());
@ -147,6 +151,7 @@ static void ShowInspectWindow(bool* isOpen) {
} }
} }
} }
ImGui::InputText("Filter", filterText.data(), filterText.size());
if (ImGui::BeginTable("Entities", 4, if (ImGui::BeginTable("Entities", 4,
ImGuiTableFlags_Resizable | ImGuiTableFlags_Sortable | ImGuiTableFlags_RowBg | ImGuiTableFlags_Resizable | ImGuiTableFlags_Sortable | ImGuiTableFlags_RowBg |
ImGuiTableFlags_BordersOuter | ImGuiTableFlags_BordersV | ImGuiTableFlags_ScrollY)) { ImGuiTableFlags_BordersOuter | ImGuiTableFlags_BordersV | ImGuiTableFlags_ScrollY)) {
@ -162,6 +167,14 @@ static void ShowInspectWindow(bool* isOpen) {
std::vector<CEntity*> items; std::vector<CEntity*> items;
items.reserve(list.size()); items.reserve(list.size());
for (auto* ent : list) { for (auto* ent : list) {
std::string_view search{filterText.data(), strlen(filterText.data())};
if (!search.empty()) {
std::string_view type = ent->ImGuiType();
std::string_view name = ent->GetName();
if (!containsCaseInsensitive(type, search) && !containsCaseInsensitive(name, search)) {
continue;
}
}
items.push_back(ent); items.push_back(ent);
} }
if (ImGuiTableSortSpecs* sortSpecs = ImGui::TableGetSortSpecs()) { if (ImGuiTableSortSpecs* sortSpecs = ImGui::TableGetSortSpecs()) {
@ -190,13 +203,31 @@ static void ShowInspectWindow(bool* isOpen) {
TUniqueId uid = item->GetUniqueId(); TUniqueId uid = item->GetUniqueId();
ImGui::PushID(uid.Value()); ImGui::PushID(uid.Value());
ImGui::TableNextRow(); ImGui::TableNextRow();
bool isActive = item->GetActive();
if (!isActive) {
ImGui::PushStyleColor(ImGuiCol_Text, 0xAAFFFFFF);
}
if (ImGui::TableNextColumn()) { if (ImGui::TableNextColumn()) {
auto text = fmt::format(FMT_STRING("{:x}"), uid.Value()); auto text = fmt::format(FMT_STRING("{:x}"), uid.Value());
if (TCastToPtr<CActor> act = item) { bool tmp = false;
ImGui::Selectable(text.c_str(), &act->m_debugSelected, bool* selected = &tmp;
ImGuiSelectableFlags_SpanAllColumns | ImGuiSelectableFlags_AllowItemOverlap); TCastToPtr<CActor> act = item;
} else { if (act != nullptr) {
ImGui::TextUnformatted(text.c_str()); selected = &act->m_debugSelected;
}
ImGui::Selectable(text.c_str(), selected,
ImGuiSelectableFlags_SpanAllColumns | ImGuiSelectableFlags_AllowItemOverlap);
if (ImGui::BeginPopupContextItem(text.c_str())) {
if (!isActive) {
ImGui::PopStyleColor();
}
if (ImGui::MenuItem(isActive ? "Deactivate" : "Activate")) {
item->SetActive(!isActive);
}
ImGui::EndPopup();
if (!isActive) {
ImGui::PushStyleColor(ImGuiCol_Text, 0xAAFFFFFF);
}
} }
} }
if (ImGui::TableNextColumn()) { if (ImGui::TableNextColumn()) {
@ -210,6 +241,9 @@ static void ShowInspectWindow(bool* isOpen) {
ImGuiConsole::inspectingEntities.insert(uid); ImGuiConsole::inspectingEntities.insert(uid);
} }
} }
if (!isActive) {
ImGui::PopStyleColor();
}
ImGui::PopID(); ImGui::PopID();
} }
ImGui::EndTable(); ImGui::EndTable();

View File

@ -417,8 +417,21 @@ IMGUI_ENTITY_INSPECT(MP1::CRipperControlledPlatform, CScriptPlatform, RipperCont
// <- CAi // <- CAi
IMGUI_ENTITY_INSPECT(CDestroyableRock, CAi, DestroyableRock, {}) IMGUI_ENTITY_INSPECT(CDestroyableRock, CAi, DestroyableRock, {})
IMGUI_ENTITY_INSPECT(CPatterned, CAi, Patterned, IMGUI_ENTITY_INSPECT(CPatterned, CAi, Patterned, {
{ BITFIELD_CHECKBOX("Enable state machine", x403_25_enableStateMachine); }) BITFIELD_CHECKBOX("Enable state machine", x403_25_enableStateMachine);
ImGui::Text("Body state:");
ImGui::SameLine();
ImGuiStringViewText(pas::AnimationStateToStr(x450_bodyController->GetCurrentStateId()));
if (ImGui::Button("Burn")) {
Burn(1.f, 1.f);
}
if (ImGui::Button("Shock")) {
Shock(*g_StateManager, 1.f, 1.f);
}
if (ImGui::Button("Freeze")) {
Freeze(*g_StateManager, GetTranslation(), zeus::skZero3f, 1.f);
}
})
// <- CPatterned // <- CPatterned
IMGUI_ENTITY_INSPECT(MP1::CAtomicAlpha, CPatterned, AtomicAlpha, {}) IMGUI_ENTITY_INSPECT(MP1::CAtomicAlpha, CPatterned, AtomicAlpha, {})