mirror of https://github.com/AxioDL/metaforce.git
Various fixes / cleanup
This commit is contained in:
parent
f167fc4281
commit
72954c5019
|
@ -10,16 +10,9 @@
|
||||||
|
|
||||||
namespace metaforce {
|
namespace metaforce {
|
||||||
|
|
||||||
struct EntityInfo {
|
static std::set<TUniqueId> inspectingEntities;
|
||||||
TUniqueId uid;
|
|
||||||
bool closed = false;
|
|
||||||
|
|
||||||
explicit EntityInfo(TUniqueId uid) : uid(uid) {}
|
static void ShowMenuGame() {
|
||||||
};
|
|
||||||
|
|
||||||
static std::vector<EntityInfo> inspectingEntities;
|
|
||||||
|
|
||||||
static void ShowMenuFile() {
|
|
||||||
static bool paused;
|
static bool paused;
|
||||||
paused = g_Main->IsPaused();
|
paused = g_Main->IsPaused();
|
||||||
if (ImGui::MenuItem("Paused", nullptr, &paused)) {
|
if (ImGui::MenuItem("Paused", nullptr, &paused)) {
|
||||||
|
@ -78,53 +71,48 @@ static void ShowInspectWindow(bool* isOpen) {
|
||||||
}
|
}
|
||||||
if (ImGui::TableNextColumn()) {
|
if (ImGui::TableNextColumn()) {
|
||||||
if (ImGui::SmallButton("View")) {
|
if (ImGui::SmallButton("View")) {
|
||||||
if (!std::any_of(inspectingEntities.begin(), inspectingEntities.end(),
|
inspectingEntities.insert(uid);
|
||||||
[=](EntityInfo& v) { return v.uid == uid; })) {
|
|
||||||
inspectingEntities.emplace_back(uid);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ImGui::PopID();
|
ImGui::PopID();
|
||||||
}
|
}
|
||||||
ImGui::EndTable();
|
ImGui::EndTable();
|
||||||
}
|
}
|
||||||
ImGui::End();
|
|
||||||
}
|
}
|
||||||
|
ImGui::End();
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool showEntityInfoWindow(EntityInfo& info) {
|
static bool showEntityInfoWindow(TUniqueId uid) {
|
||||||
CEntity* ent = g_StateManager->ObjectById(info.uid);
|
bool open = true;
|
||||||
|
CEntity* ent = g_StateManager->ObjectById(uid);
|
||||||
if (ent == nullptr) {
|
if (ent == nullptr) {
|
||||||
return true;
|
return false;
|
||||||
}
|
}
|
||||||
const char* name = "Entity";
|
auto name = fmt::format(FMT_STRING("{}##{:x}"), !ent->GetName().empty() ? ent->GetName() : "Entity", uid.Value());
|
||||||
if (!ent->GetName().empty()) {
|
if (ImGui::Begin(name.c_str(), &open, ImGuiWindowFlags_AlwaysAutoResize)) {
|
||||||
name = ent->GetName().data();
|
ImGui::Text("ID: %x", uid.Value());
|
||||||
}
|
|
||||||
ImGui::PushID(info.uid.Value());
|
|
||||||
if (ImGui::Begin(name, &info.closed, ImGuiWindowFlags_AlwaysAutoResize)) {
|
|
||||||
ImGui::Text("ID: %x", info.uid.Value());
|
|
||||||
ImGui::Text("Name: %s", ent->GetName().data());
|
ImGui::Text("Name: %s", ent->GetName().data());
|
||||||
if (const TCastToPtr<CActor> act = ent) {
|
if (const TCastToPtr<CActor> act = ent) {
|
||||||
const zeus::CVector3f& pos = act->GetTranslation();
|
const zeus::CVector3f& pos = act->GetTranslation();
|
||||||
ImGui::Text("Position: %f, %f, %f", pos.x(), pos.y(), pos.z());
|
ImGui::Text("Position: %f, %f, %f", pos.x(), pos.y(), pos.z());
|
||||||
}
|
}
|
||||||
ImGui::End();
|
|
||||||
}
|
}
|
||||||
ImGui::PopID();
|
ImGui::End();
|
||||||
return false;
|
return open;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ShowAppMainMenuBar() {
|
static void ShowAppMainMenuBar() {
|
||||||
static bool showInspectWindow = false;
|
static bool showInspectWindow = false;
|
||||||
static bool showDemoWindow = false;
|
static bool showDemoWindow = false;
|
||||||
if (ImGui::BeginMainMenuBar()) {
|
if (ImGui::BeginMainMenuBar()) {
|
||||||
if (ImGui::BeginMenu("File")) {
|
if (ImGui::BeginMenu("Game")) {
|
||||||
ShowMenuFile();
|
ShowMenuGame();
|
||||||
ImGui::EndMenu();
|
ImGui::EndMenu();
|
||||||
}
|
}
|
||||||
|
ImGui::Spacing();
|
||||||
if (ImGui::BeginMenu("Tools")) {
|
if (ImGui::BeginMenu("Tools")) {
|
||||||
ImGui::MenuItem("Inspect", nullptr, &showInspectWindow);
|
ImGui::MenuItem("Inspect", nullptr, &showInspectWindow,
|
||||||
|
g_StateManager != nullptr && g_StateManager->GetObjectList());
|
||||||
ImGui::Separator();
|
ImGui::Separator();
|
||||||
ImGui::MenuItem("Demo", nullptr, &showDemoWindow);
|
ImGui::MenuItem("Demo", nullptr, &showDemoWindow);
|
||||||
ImGui::EndMenu();
|
ImGui::EndMenu();
|
||||||
|
@ -137,7 +125,7 @@ static void ShowAppMainMenuBar() {
|
||||||
{
|
{
|
||||||
auto iter = inspectingEntities.begin();
|
auto iter = inspectingEntities.begin();
|
||||||
while (iter != inspectingEntities.end()) {
|
while (iter != inspectingEntities.end()) {
|
||||||
if (iter->closed || showEntityInfoWindow(*iter)) {
|
if (!showEntityInfoWindow(*iter)) {
|
||||||
iter = inspectingEntities.erase(iter);
|
iter = inspectingEntities.erase(iter);
|
||||||
} else {
|
} else {
|
||||||
iter++;
|
iter++;
|
||||||
|
|
Loading…
Reference in New Issue