Inspect window filter & Patterned body state info

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

View File

@ -1,5 +1,5 @@
set(CHARACTER_SOURCES
CharacterCommon.hpp
CharacterCommon.hpp CharacterCommon.cpp
CAssetFactory.hpp CAssetFactory.cpp
CCharacterFactory.hpp CCharacterFactory.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
#include <string_view>
namespace metaforce {
namespace pas {
enum class ELocomotionType {
@ -52,6 +54,8 @@ enum class EAnimationState {
AdditiveReaction = 24
};
std::string_view AnimationStateToStr(EAnimationState state);
enum class EHurledState {
Invalid = -1,
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 void ShowMenuGame() {
@ -120,9 +125,7 @@ static void ShowMenuGame() {
}
}
void ImGuiStringViewText(std::string_view text) {
ImGui::TextUnformatted(text.begin(), text.end());
}
void ImGuiStringViewText(std::string_view text) { ImGui::TextUnformatted(text.begin(), text.end()); }
static void LerpActorColor(CActor* act) {
act->m_debugAddColorTime += 1.f / 60.f;
@ -137,6 +140,7 @@ static void LerpActorColor(CActor* act) {
}
static void ShowInspectWindow(bool* isOpen) {
static std::array<char, 40> filterText{};
if (ImGui::Begin("Inspect", isOpen)) {
CObjectList& list = *g_StateManager->GetObjectList();
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,
ImGuiTableFlags_Resizable | ImGuiTableFlags_Sortable | ImGuiTableFlags_RowBg |
ImGuiTableFlags_BordersOuter | ImGuiTableFlags_BordersV | ImGuiTableFlags_ScrollY)) {
@ -162,6 +167,14 @@ static void ShowInspectWindow(bool* isOpen) {
std::vector<CEntity*> items;
items.reserve(list.size());
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);
}
if (ImGuiTableSortSpecs* sortSpecs = ImGui::TableGetSortSpecs()) {
@ -190,13 +203,31 @@ static void ShowInspectWindow(bool* isOpen) {
TUniqueId uid = item->GetUniqueId();
ImGui::PushID(uid.Value());
ImGui::TableNextRow();
bool isActive = item->GetActive();
if (!isActive) {
ImGui::PushStyleColor(ImGuiCol_Text, 0xAAFFFFFF);
}
if (ImGui::TableNextColumn()) {
auto text = fmt::format(FMT_STRING("{:x}"), uid.Value());
if (TCastToPtr<CActor> act = item) {
ImGui::Selectable(text.c_str(), &act->m_debugSelected,
ImGuiSelectableFlags_SpanAllColumns | ImGuiSelectableFlags_AllowItemOverlap);
} else {
ImGui::TextUnformatted(text.c_str());
bool tmp = false;
bool* selected = &tmp;
TCastToPtr<CActor> act = item;
if (act != nullptr) {
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()) {
@ -210,6 +241,9 @@ static void ShowInspectWindow(bool* isOpen) {
ImGuiConsole::inspectingEntities.insert(uid);
}
}
if (!isActive) {
ImGui::PopStyleColor();
}
ImGui::PopID();
}
ImGui::EndTable();

View File

@ -417,8 +417,21 @@ IMGUI_ENTITY_INSPECT(MP1::CRipperControlledPlatform, CScriptPlatform, RipperCont
// <- CAi
IMGUI_ENTITY_INSPECT(CDestroyableRock, CAi, DestroyableRock, {})
IMGUI_ENTITY_INSPECT(CPatterned, CAi, Patterned,
{ BITFIELD_CHECKBOX("Enable state machine", x403_25_enableStateMachine); })
IMGUI_ENTITY_INSPECT(CPatterned, CAi, Patterned, {
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
IMGUI_ENTITY_INSPECT(MP1::CAtomicAlpha, CPatterned, AtomicAlpha, {})