[studio] FileInfo: Rename ID to Asset ID, allow for no value of fields
All checks were successful
Build / build (push) Successful in 1m12s

This commit is contained in:
2026-02-05 22:15:00 -06:00
parent 7b24b33849
commit 62337bd29e
2 changed files with 56 additions and 37 deletions

View File

@@ -15,10 +15,10 @@ ox::Error FileInfo::open(ox::StringParam filePath) noexcept {
auto &fs = m_sctx.project->romFs(); auto &fs = m_sctx.project->romFs();
auto const fileBuff = fs.read(m_filePath).or_value({}); auto const fileBuff = fs.read(m_filePath).or_value({});
auto hdr = keel::readAssetHeader(fileBuff).or_value({}); auto hdr = keel::readAssetHeader(fileBuff).or_value({});
m_fileInfo.id = hdr.uuid.toString(); m_fileInfo.assetId.emplace(hdr.uuid.toString());
m_fileInfo.typeName = std::move(hdr.clawHdr.typeName); m_fileInfo.typeName.emplace(std::move(hdr.clawHdr.typeName));
m_fileInfo.typeVersion = hdr.clawHdr.typeVersion; m_fileInfo.typeVersion.emplace(hdr.clawHdr.typeVersion);
m_fileInfo.format = [&hdr] { m_fileInfo.format.emplace([&hdr] {
switch (hdr.clawHdr.fmt) { switch (hdr.clawHdr.fmt) {
case ox::ClawFormat::Metal: case ox::ClawFormat::Metal:
return ox::StringLiteral{"Metal Claw"}; return ox::StringLiteral{"Metal Claw"};
@@ -27,8 +27,8 @@ ox::Error FileInfo::open(ox::StringParam filePath) noexcept {
default: default:
return ox::StringLiteral{"Other"}; return ox::StringLiteral{"Other"};
} }
}(); }());
m_fileInfo.dataSize = hdr.clawHdr.dataSize; m_fileInfo.dataSize.emplace(hdr.clawHdr.dataSize);
Popup::open(); Popup::open();
return {}; return {};
} }
@@ -81,37 +81,56 @@ void FileInfo::drawTable() const noexcept {
ImGuiTableFlags_RowBg)) { ImGuiTableFlags_RowBg)) {
ImGui::TableSetupColumn("Field", ImGuiTableColumnFlags_WidthFixed, 70); ImGui::TableSetupColumn("Field", ImGuiTableColumnFlags_WidthFixed, 70);
ImGui::TableSetupColumn("Value", ImGuiTableColumnFlags_NoHide); ImGui::TableSetupColumn("Value", ImGuiTableColumnFlags_NoHide);
// id bool somethingDrew = false;
// asset id
if (m_fileInfo.assetId) {
ImGui::TableNextRow(); ImGui::TableNextRow();
ImGui::TableSetColumnIndex(0); ImGui::TableSetColumnIndex(0);
ImGui::Text("ID:"); ImGui::Text("Asset ID:");
ImGui::TableSetColumnIndex(1); ImGui::TableSetColumnIndex(1);
ImGui::Text("%s", m_fileInfo.id.c_str()); ImGui::Text("%s", m_fileInfo.assetId->c_str());
somethingDrew = true;
}
// typeName // typeName
if (m_fileInfo.typeName) {
ImGui::TableNextRow(); ImGui::TableNextRow();
ImGui::TableSetColumnIndex(0); ImGui::TableSetColumnIndex(0);
ImGui::Text("Type Name:"); ImGui::Text("Type Name:");
ImGui::TableSetColumnIndex(1); ImGui::TableSetColumnIndex(1);
ImGui::Text("%s", m_fileInfo.typeName.c_str()); ImGui::Text("%s", m_fileInfo.typeName->c_str());
somethingDrew = true;
}
// typeVersion // typeVersion
if (m_fileInfo.typeVersion) {
ImGui::TableNextRow(); ImGui::TableNextRow();
ImGui::TableSetColumnIndex(0); ImGui::TableSetColumnIndex(0);
ImGui::Text("Type Version:"); ImGui::Text("Type Version:");
ImGui::TableSetColumnIndex(1); ImGui::TableSetColumnIndex(1);
ImGui::Text("%d", m_fileInfo.typeVersion); ImGui::Text("%d", *m_fileInfo.typeVersion);
somethingDrew = true;
}
// format // format
if (m_fileInfo.format) {
ImGui::TableNextRow(); ImGui::TableNextRow();
ImGui::TableSetColumnIndex(0); ImGui::TableSetColumnIndex(0);
ImGui::Text("Format:"); ImGui::Text("Format:");
ImGui::TableSetColumnIndex(1); ImGui::TableSetColumnIndex(1);
ImGui::Text("%s", m_fileInfo.format.c_str()); ImGui::Text("%s", m_fileInfo.format->c_str());
somethingDrew = true;
}
// size // size
if (m_fileInfo.dataSize) {
ImGui::TableNextRow(); ImGui::TableNextRow();
ImGui::TableSetColumnIndex(0); ImGui::TableSetColumnIndex(0);
ImGui::Text("Data Size:"); ImGui::Text("Data Size:");
ImGui::TableSetColumnIndex(1); ImGui::TableSetColumnIndex(1);
ImGui::Text("%lluB", m_fileInfo.dataSize); ImGui::Text("%lluB", *m_fileInfo.dataSize);
somethingDrew = true;
}
ImGui::EndTable(); ImGui::EndTable();
if (!somethingDrew) {
ImGui::Text("No information available");
}
} }
} }

View File

@@ -16,12 +16,12 @@ class FileInfo: public ig::Popup {
Context &m_sctx; Context &m_sctx;
ox::String m_filePath; ox::String m_filePath;
struct { struct {
ox::UUIDStr id; ox::Optional<ox::UUIDStr> assetId;
ox::String typeName; ox::Optional<ox::String> typeName;
int typeVersion{}; ox::Optional<int> typeVersion{};
ox::StringLiteral format; ox::Optional<ox::StringLiteral> format;
// use manual sizing to work with %ull // use manual sizing to work with %ull
unsigned long long dataSize{}; ox::Optional<unsigned long long> dataSize{};
} m_fileInfo; } m_fileInfo;
public: public: