[studio] FileInfo: Rename ID to Asset ID, allow for no value of fields
All checks were successful
Build / build (push) Successful in 1m12s
All checks were successful
Build / build (push) Successful in 1m12s
This commit is contained in:
@@ -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
|
||||
bool somethingDrew = false;
|
||||
// asset id
|
||||
if (m_fileInfo.assetId) {
|
||||
ImGui::TableNextRow();
|
||||
ImGui::TableSetColumnIndex(0);
|
||||
ImGui::Text("ID:");
|
||||
ImGui::Text("Asset ID:");
|
||||
ImGui::TableSetColumnIndex(1);
|
||||
ImGui::Text("%s", m_fileInfo.id.c_str());
|
||||
ImGui::Text("%s", m_fileInfo.assetId->c_str());
|
||||
somethingDrew = true;
|
||||
}
|
||||
// typeName
|
||||
if (m_fileInfo.typeName) {
|
||||
ImGui::TableNextRow();
|
||||
ImGui::TableSetColumnIndex(0);
|
||||
ImGui::Text("Type Name:");
|
||||
ImGui::TableSetColumnIndex(1);
|
||||
ImGui::Text("%s", m_fileInfo.typeName.c_str());
|
||||
ImGui::Text("%s", m_fileInfo.typeName->c_str());
|
||||
somethingDrew = true;
|
||||
}
|
||||
// typeVersion
|
||||
if (m_fileInfo.typeVersion) {
|
||||
ImGui::TableNextRow();
|
||||
ImGui::TableSetColumnIndex(0);
|
||||
ImGui::Text("Type Version:");
|
||||
ImGui::TableSetColumnIndex(1);
|
||||
ImGui::Text("%d", m_fileInfo.typeVersion);
|
||||
ImGui::Text("%d", *m_fileInfo.typeVersion);
|
||||
somethingDrew = true;
|
||||
}
|
||||
// format
|
||||
if (m_fileInfo.format) {
|
||||
ImGui::TableNextRow();
|
||||
ImGui::TableSetColumnIndex(0);
|
||||
ImGui::Text("Format:");
|
||||
ImGui::TableSetColumnIndex(1);
|
||||
ImGui::Text("%s", m_fileInfo.format.c_str());
|
||||
ImGui::Text("%s", m_fileInfo.format->c_str());
|
||||
somethingDrew = true;
|
||||
}
|
||||
// size
|
||||
if (m_fileInfo.dataSize) {
|
||||
ImGui::TableNextRow();
|
||||
ImGui::TableSetColumnIndex(0);
|
||||
ImGui::Text("Data Size:");
|
||||
ImGui::TableSetColumnIndex(1);
|
||||
ImGui::Text("%lluB", m_fileInfo.dataSize);
|
||||
ImGui::Text("%lluB", *m_fileInfo.dataSize);
|
||||
somethingDrew = true;
|
||||
}
|
||||
ImGui::EndTable();
|
||||
if (!somethingDrew) {
|
||||
ImGui::Text("No information available");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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<ox::UUIDStr> assetId;
|
||||
ox::Optional<ox::String> typeName;
|
||||
ox::Optional<int> typeVersion{};
|
||||
ox::Optional<ox::StringLiteral> format;
|
||||
// use manual sizing to work with %ull
|
||||
unsigned long long dataSize{};
|
||||
ox::Optional<unsigned long long> dataSize{};
|
||||
} m_fileInfo;
|
||||
|
||||
public:
|
||||
|
||||
Reference in New Issue
Block a user