From 62337bd29e5eea99cb35e646cbb650a0f99db75d Mon Sep 17 00:00:00 2001 From: Gary Talent Date: Thu, 5 Feb 2026 22:15:00 -0600 Subject: [PATCH] [studio] FileInfo: Rename ID to Asset ID, allow for no value of fields --- .../studio/applib/src/popups/fileinfo.cpp | 83 ++++++++++++------- .../studio/applib/src/popups/fileinfo.hpp | 10 +-- 2 files changed, 56 insertions(+), 37 deletions(-) diff --git a/src/olympic/studio/applib/src/popups/fileinfo.cpp b/src/olympic/studio/applib/src/popups/fileinfo.cpp index 1ffaf206..8d7a1fd4 100644 --- a/src/olympic/studio/applib/src/popups/fileinfo.cpp +++ b/src/olympic/studio/applib/src/popups/fileinfo.cpp @@ -15,10 +15,10 @@ ox::Error FileInfo::open(ox::StringParam filePath) noexcept { auto &fs = m_sctx.project->romFs(); auto const fileBuff = fs.read(m_filePath).or_value({}); auto hdr = keel::readAssetHeader(fileBuff).or_value({}); - m_fileInfo.id = hdr.uuid.toString(); - m_fileInfo.typeName = std::move(hdr.clawHdr.typeName); - m_fileInfo.typeVersion = hdr.clawHdr.typeVersion; - m_fileInfo.format = [&hdr] { + m_fileInfo.assetId.emplace(hdr.uuid.toString()); + m_fileInfo.typeName.emplace(std::move(hdr.clawHdr.typeName)); + m_fileInfo.typeVersion.emplace(hdr.clawHdr.typeVersion); + m_fileInfo.format.emplace([&hdr] { switch (hdr.clawHdr.fmt) { case ox::ClawFormat::Metal: return ox::StringLiteral{"Metal Claw"}; @@ -27,8 +27,8 @@ ox::Error FileInfo::open(ox::StringParam filePath) noexcept { default: return ox::StringLiteral{"Other"}; } - }(); - m_fileInfo.dataSize = hdr.clawHdr.dataSize; + }()); + m_fileInfo.dataSize.emplace(hdr.clawHdr.dataSize); Popup::open(); return {}; } @@ -81,37 +81,56 @@ void FileInfo::drawTable() const noexcept { ImGuiTableFlags_RowBg)) { ImGui::TableSetupColumn("Field", ImGuiTableColumnFlags_WidthFixed, 70); ImGui::TableSetupColumn("Value", ImGuiTableColumnFlags_NoHide); - // id - ImGui::TableNextRow(); - ImGui::TableSetColumnIndex(0); - ImGui::Text("ID:"); - ImGui::TableSetColumnIndex(1); - ImGui::Text("%s", m_fileInfo.id.c_str()); + bool somethingDrew = false; + // asset id + if (m_fileInfo.assetId) { + ImGui::TableNextRow(); + ImGui::TableSetColumnIndex(0); + ImGui::Text("Asset ID:"); + ImGui::TableSetColumnIndex(1); + ImGui::Text("%s", m_fileInfo.assetId->c_str()); + somethingDrew = true; + } // typeName - ImGui::TableNextRow(); - ImGui::TableSetColumnIndex(0); - ImGui::Text("Type Name:"); - ImGui::TableSetColumnIndex(1); - ImGui::Text("%s", m_fileInfo.typeName.c_str()); + if (m_fileInfo.typeName) { + ImGui::TableNextRow(); + ImGui::TableSetColumnIndex(0); + ImGui::Text("Type Name:"); + ImGui::TableSetColumnIndex(1); + ImGui::Text("%s", m_fileInfo.typeName->c_str()); + somethingDrew = true; + } // typeVersion - ImGui::TableNextRow(); - ImGui::TableSetColumnIndex(0); - ImGui::Text("Type Version:"); - ImGui::TableSetColumnIndex(1); - ImGui::Text("%d", m_fileInfo.typeVersion); + if (m_fileInfo.typeVersion) { + ImGui::TableNextRow(); + ImGui::TableSetColumnIndex(0); + ImGui::Text("Type Version:"); + ImGui::TableSetColumnIndex(1); + ImGui::Text("%d", *m_fileInfo.typeVersion); + somethingDrew = true; + } // format - ImGui::TableNextRow(); - ImGui::TableSetColumnIndex(0); - ImGui::Text("Format:"); - ImGui::TableSetColumnIndex(1); - ImGui::Text("%s", m_fileInfo.format.c_str()); + if (m_fileInfo.format) { + ImGui::TableNextRow(); + ImGui::TableSetColumnIndex(0); + ImGui::Text("Format:"); + ImGui::TableSetColumnIndex(1); + ImGui::Text("%s", m_fileInfo.format->c_str()); + somethingDrew = true; + } // size - ImGui::TableNextRow(); - ImGui::TableSetColumnIndex(0); - ImGui::Text("Data Size:"); - ImGui::TableSetColumnIndex(1); - ImGui::Text("%lluB", m_fileInfo.dataSize); + if (m_fileInfo.dataSize) { + ImGui::TableNextRow(); + ImGui::TableSetColumnIndex(0); + ImGui::Text("Data Size:"); + ImGui::TableSetColumnIndex(1); + ImGui::Text("%lluB", *m_fileInfo.dataSize); + somethingDrew = true; + } ImGui::EndTable(); + if (!somethingDrew) { + ImGui::Text("No information available"); + } } } diff --git a/src/olympic/studio/applib/src/popups/fileinfo.hpp b/src/olympic/studio/applib/src/popups/fileinfo.hpp index ec2ac713..55c27619 100644 --- a/src/olympic/studio/applib/src/popups/fileinfo.hpp +++ b/src/olympic/studio/applib/src/popups/fileinfo.hpp @@ -16,12 +16,12 @@ class FileInfo: public ig::Popup { Context &m_sctx; ox::String m_filePath; struct { - ox::UUIDStr id; - ox::String typeName; - int typeVersion{}; - ox::StringLiteral format; + ox::Optional assetId; + ox::Optional typeName; + ox::Optional typeVersion{}; + ox::Optional format; // use manual sizing to work with %ull - unsigned long long dataSize{}; + ox::Optional dataSize{}; } m_fileInfo; public: