add format for textures in analysis

This commit is contained in:
Caraxi 2023-07-21 22:34:00 +09:30
parent 71c510b0f4
commit 9023aa8006
2 changed files with 37 additions and 1 deletions

View file

@ -5,6 +5,8 @@ using MareSynchronos.Services.Mediator;
using MareSynchronos.UI; using MareSynchronos.UI;
using MareSynchronos.Utils; using MareSynchronos.Utils;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
using Lumina.Data;
using Lumina.Data.Files;
namespace MareSynchronos.Services; namespace MareSynchronos.Services;
@ -176,5 +178,31 @@ public sealed class CharacterAnalyzer : MediatorSubscriberBase, IDisposable
} }
public long OriginalSize { get; private set; } = OriginalSize; public long OriginalSize { get; private set; } = OriginalSize;
public long CompressedSize { get; private set; } = CompressedSize; public long CompressedSize { get; private set; } = CompressedSize;
private string? _format;
public string? Format
{
get
{
if (_format != null) return _format;
switch (FileType)
{
case "tex":
{
using var stream = new FileStream(FilePaths[0], FileMode.Open, FileAccess.Read, FileShare.Read);
using var reader = new BinaryReader(stream);
reader.BaseStream.Position = 4;
var format = (TexFile.TextureFormat) reader.ReadInt32();
_format = format.ToString();
return _format;
}
default:
_format = string.Empty;
return _format;
}
}
}
} }
} }

View file

@ -240,7 +240,7 @@ public class DataAnalysisUi : WindowMediatorSubscriberBase
private void DrawTable(IGrouping<string, CharacterAnalyzer.FileDataEntry> fileGroup) private void DrawTable(IGrouping<string, CharacterAnalyzer.FileDataEntry> fileGroup)
{ {
using var table = ImRaii.Table("Analysis", 5, ImGuiTableFlags.Sortable | ImGuiTableFlags.RowBg | ImGuiTableFlags.ScrollY | ImGuiTableFlags.SizingFixedFit, using var table = ImRaii.Table("Analysis", 6, ImGuiTableFlags.Sortable | ImGuiTableFlags.RowBg | ImGuiTableFlags.ScrollY | ImGuiTableFlags.SizingFixedFit,
new Vector2(0, 300)); new Vector2(0, 300));
if (!table.Success) return; if (!table.Success) return;
ImGui.TableSetupColumn("Hash"); ImGui.TableSetupColumn("Hash");
@ -248,6 +248,7 @@ new Vector2(0, 300));
ImGui.TableSetupColumn("Gamepaths"); ImGui.TableSetupColumn("Gamepaths");
ImGui.TableSetupColumn("Original Size"); ImGui.TableSetupColumn("Original Size");
ImGui.TableSetupColumn("Compressed Size"); ImGui.TableSetupColumn("Compressed Size");
ImGui.TableSetupColumn("Format");
ImGui.TableSetupScrollFreeze(0, 1); ImGui.TableSetupScrollFreeze(0, 1);
ImGui.TableHeadersRow(); ImGui.TableHeadersRow();
@ -276,6 +277,10 @@ new Vector2(0, 300));
_cachedAnalysis![_selectedObjectTab] = _cachedAnalysis[_selectedObjectTab].OrderBy(k => k.Value.CompressedSize).ToDictionary(d => d.Key, d => d.Value, StringComparer.Ordinal); _cachedAnalysis![_selectedObjectTab] = _cachedAnalysis[_selectedObjectTab].OrderBy(k => k.Value.CompressedSize).ToDictionary(d => d.Key, d => d.Value, StringComparer.Ordinal);
if (idx == 4 && sortSpecs.Specs.SortDirection == ImGuiSortDirection.Descending) if (idx == 4 && sortSpecs.Specs.SortDirection == ImGuiSortDirection.Descending)
_cachedAnalysis![_selectedObjectTab] = _cachedAnalysis[_selectedObjectTab].OrderByDescending(k => k.Value.CompressedSize).ToDictionary(d => d.Key, d => d.Value, StringComparer.Ordinal); _cachedAnalysis![_selectedObjectTab] = _cachedAnalysis[_selectedObjectTab].OrderByDescending(k => k.Value.CompressedSize).ToDictionary(d => d.Key, d => d.Value, StringComparer.Ordinal);
if (idx == 5 && sortSpecs.Specs.SortDirection == ImGuiSortDirection.Ascending)
_cachedAnalysis![_selectedObjectTab] = _cachedAnalysis[_selectedObjectTab].OrderBy(k => k.Value.Format).ToDictionary(d => d.Key, d => d.Value, StringComparer.Ordinal);
if (idx == 5 && sortSpecs.Specs.SortDirection == ImGuiSortDirection.Descending)
_cachedAnalysis![_selectedObjectTab] = _cachedAnalysis[_selectedObjectTab].OrderByDescending(k => k.Value.Format).ToDictionary(d => d.Key, d => d.Value, StringComparer.Ordinal);
sortSpecs.SpecsDirty = false; sortSpecs.SpecsDirty = false;
} }
@ -309,6 +314,9 @@ new Vector2(0, 300));
ImGui.TableNextColumn(); ImGui.TableNextColumn();
ImGui.TextUnformatted(UiSharedService.ByteToString(item.CompressedSize)); ImGui.TextUnformatted(UiSharedService.ByteToString(item.CompressedSize));
if (ImGui.IsItemClicked()) _selectedHash = item.Hash; if (ImGui.IsItemClicked()) _selectedHash = item.Hash;
ImGui.TableNextColumn();
ImGui.TextUnformatted(item.Format);
if (ImGui.IsItemClicked()) _selectedHash = item.Hash;
} }
} }
} }