Only show byte sizes in MiB, format Tris in data analysis window

This commit is contained in:
Loporrit
2025-02-17 02:25:09 +00:00
parent aafdb45b5e
commit 9bf36765e4
3 changed files with 14 additions and 13 deletions

View File

@@ -171,7 +171,7 @@ public class DataAnalysisUi : WindowMediatorSubscriberBase
UiSharedService.AttachToolTip("Click \"Start analysis\" to calculate download size");
}
}
ImGui.TextUnformatted($"Total modded model triangles: {_cachedAnalysis.Sum(c => c.Value.Sum(f => f.Value.Triangles))}");
ImGui.TextUnformatted($"Total modded model triangles: {UiSharedService.TrisToString(_cachedAnalysis.Sum(c => c.Value.Sum(f => f.Value.Triangles)))}");
ImGui.Separator();
using var tabbar = ImRaii.TabBar("objectSelection");
@@ -226,7 +226,7 @@ public class DataAnalysisUi : WindowMediatorSubscriberBase
{
ImGui.TextUnformatted(UiSharedService.ByteToString(vramUsage.Sum(f => f.OriginalSize)));
}
ImGui.TextUnformatted($"{kvp.Key} modded model triangles: {kvp.Value.Sum(f => f.Value.Triangles)}");
ImGui.TextUnformatted($"{kvp.Key} modded model triangles: {UiSharedService.TrisToString(kvp.Value.Sum(f => f.Value.Triangles))}");
ImGui.Separator();
if (_selectedObjectTab != kvp.Key)
@@ -482,7 +482,7 @@ public class DataAnalysisUi : WindowMediatorSubscriberBase
if (string.Equals(fileGroup.Key, "mdl", StringComparison.Ordinal))
{
ImGui.TableNextColumn();
ImGui.TextUnformatted(item.Triangles.ToString());
ImGui.TextUnformatted(UiSharedService.TrisToString(item.Triangles));
if (ImGui.IsItemClicked()) _selectedHash = item.Hash;
}
}

View File

@@ -798,12 +798,12 @@ public class SettingsUi : WindowMediatorSubscriberBase
_uiShared.DrawCacheDirectorySetting();
ImGui.AlignTextToFramePadding();
if (_cacheMonitor.FileCacheSize >= 0)
ImGui.TextUnformatted($"Currently utilized local storage: {UiSharedService.ByteToString(_cacheMonitor.FileCacheSize)}");
ImGui.TextUnformatted($"Currently utilized local storage: {_cacheMonitor.FileCacheSize / 1024.0 / 1024.0 / 1024.0:0.00} GiB");
else
ImGui.TextUnformatted($"Currently utilized local storage: Calculating...");
bool isLinux = _dalamudUtilService.IsWine;
if (!isLinux)
ImGui.TextUnformatted($"Remaining space free on drive: {UiSharedService.ByteToString(_cacheMonitor.FileCacheDriveFree)}");
ImGui.TextUnformatted($"Remaining space free on drive: {_cacheMonitor.FileCacheDriveFree / 1024.0 / 1024.0 / 1024.0:0.00} GiB");
bool useFileCompactor = _configService.Current.UseCompactor;
if (!useFileCompactor && !isLinux)
{

View File

@@ -184,15 +184,16 @@ public partial class UiSharedService : DisposableMediatorSubscriberBase
public static string ByteToString(long bytes, bool addSuffix = true)
{
string[] suffix = ["B", "KiB", "MiB", "GiB", "TiB"];
int i;
double dblSByte = bytes;
for (i = 0; i < suffix.Length && bytes >= 1024; i++, bytes /= 1024)
{
dblSByte = bytes / 1024.0;
}
_ = addSuffix;
double dblSByte = bytes / 1048576.0;
if (dblSByte > 0.0 && dblSByte < 0.01)
dblSByte = 0.01;
return $"{dblSByte:0.00} MiB";
}
return addSuffix ? $"{dblSByte:0.00} {suffix[i]}" : $"{dblSByte:0.00}";
public static string TrisToString(long tris)
{
return tris > 1000 ? $"{tris / 1000.0:0.0}k" : $"{tris}";
}
public static void CenterNextWindow(float width, float height, ImGuiCond cond = ImGuiCond.None)