From cdf9ea1b875ae5e213708adb3aaf7c2cd405238f Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Wed, 18 Feb 2026 16:37:38 +0100 Subject: [PATCH] Remove usage of SizedString and SizedStringPair. --- Penumbra/UI/ManagementTab/DuplicateModsTab.cs | 20 +++------ Penumbra/UI/ManagementTab/UnusedModsTab.cs | 25 ++++------- .../UI/ModsTab/Selector/ModFileSystemCache.cs | 14 +++---- .../ResourceWatcher/ResourceWatcherTable.cs | 42 ++++++++----------- 4 files changed, 37 insertions(+), 64 deletions(-) diff --git a/Penumbra/UI/ManagementTab/DuplicateModsTab.cs b/Penumbra/UI/ManagementTab/DuplicateModsTab.cs index 1e77f130..39ef18dd 100644 --- a/Penumbra/UI/ManagementTab/DuplicateModsTab.cs +++ b/Penumbra/UI/ManagementTab/DuplicateModsTab.cs @@ -38,10 +38,10 @@ public sealed class DuplicateModsTab(ModConfigUpdater configUpdater, ModManager table.SetupColumn(""u8, TableColumnFlags.WidthFixed, Im.Style.FrameHeight * 2 + Im.Style.ItemInnerSpacing.X); table.SetupColumn("Mod Name"u8, TableColumnFlags.WidthStretch, 0.25f); table.SetupColumn("Mod Directory"u8, TableColumnFlags.WidthStretch, 0.25f); - table.SetupColumn("Active"u8, TableColumnFlags.WidthFixed, cache.Active.Size.X); - table.SetupColumn("Import Date"u8, TableColumnFlags.WidthFixed, cache.Date.Size.X); + table.SetupColumn("Active"u8, TableColumnFlags.WidthFixed, cache.Active.CalculateSize().X); + table.SetupColumn("Import Date"u8, TableColumnFlags.WidthFixed, cache.Date.CalculateSize().X); table.SetupColumn("Path"u8, TableColumnFlags.WidthStretch, 0.5f); - table.SetupColumn("Notes"u8, TableColumnFlags.WidthFixed, cache.Notes.Size.X + Im.Style.FrameHeight + Im.Style.ItemInnerSpacing.X); + table.SetupColumn("Notes"u8, TableColumnFlags.WidthFixed, cache.Notes.CalculateSize().X + Im.Style.FrameHeight + Im.Style.ItemInnerSpacing.X); table.HeaderRow(); var lastDrawnName = StringU8.Empty; @@ -113,9 +113,9 @@ public sealed class DuplicateModsTab(ModConfigUpdater configUpdater, ModManager public List Items = []; - public readonly SizedString Active = new("Active"u8); - public readonly SizedString Date = new("00/00/0000 00:00"u8); - public readonly SizedString Notes = new("Notes"u8); + public readonly StringU8 Active = new("Active"u8); + public readonly StringU8 Date = new("00/00/0000 00:00"u8); + public readonly StringU8 Notes = new("Notes"u8); public override void Update() { @@ -146,13 +146,5 @@ public sealed class DuplicateModsTab(ModConfigUpdater configUpdater, ModManager .ThenBy(i => i.Directory).ToList(); Dirty = IManagedCache.DirtyFlags.Clean; } - - protected override void Dispose(bool disposing) - { - base.Dispose(disposing); - Active.Dispose(); - Date.Dispose(); - Notes.Dispose(); - } } } diff --git a/Penumbra/UI/ManagementTab/UnusedModsTab.cs b/Penumbra/UI/ManagementTab/UnusedModsTab.cs index 13463f4b..7f07ce37 100644 --- a/Penumbra/UI/ManagementTab/UnusedModsTab.cs +++ b/Penumbra/UI/ManagementTab/UnusedModsTab.cs @@ -380,7 +380,7 @@ public sealed class UnusedModsTab( public override long ToValue(in CacheItem item, int globalIndex) => item.Mod.LastConfigEdit; - protected override SizedString DisplayNumber(in CacheItem item, int globalIndex) + protected override StringU8 DisplayNumber(in CacheItem item, int globalIndex) => item.Duration; protected override string ComparisonText(in CacheItem item, int globalIndex) @@ -409,7 +409,7 @@ public sealed class UnusedModsTab( public override long ToValue(in CacheItem item, int globalIndex) => item.ModSize; - protected override SizedString DisplayNumber(in CacheItem item, int globalIndex) + protected override StringU8 DisplayNumber(in CacheItem item, int globalIndex) => item.ModSizeString; protected override string ComparisonText(in CacheItem item, int globalIndex) @@ -486,36 +486,29 @@ public sealed class UnusedModsTab( StringU8 ModPath, StringU8 DirectoryName, long ModSize, - SizedStringPair ModSizeString, - SizedStringPair Duration, - (StringPair, StringPair)[] Notes) : IDisposable + StringPair ModSizeString, + StringPair Duration, + (StringPair, StringPair)[] Notes) { public long ModSize { get => field < 0 ? field = WindowsFunctions.GetDirectorySize(Mod.ModPath.FullName) : field; } = ModSize; - private SizedStringPair _modSizeString = ModSizeString; + private StringPair _modSizeString = ModSizeString; - public SizedStringPair ModSizeString + public StringPair ModSizeString { get => _modSizeString.IsEmpty - ? _modSizeString = new SizedStringPair(FormattingFunctions.HumanReadableSize(ModSize)) + ? _modSizeString = new StringPair(FormattingFunctions.HumanReadableSize(ModSize)) : _modSizeString; } public CacheItem(Mod mod, (string, string)[] notes, DateTime now) : this(mod, new StringU8(mod.Name), new StringU8(mod.Path.CurrentPath), new StringU8($"Directory Name: {mod.Identifier}"), - -1, SizedStringPair.Empty, new SizedStringPair(FormattingFunctions.DurationString(mod.LastConfigEdit, now)), + -1, StringPair.Empty, new StringPair(FormattingFunctions.DurationString(mod.LastConfigEdit, now)), notes.Select(n => (new StringPair(n.Item1), new StringPair(n.Item2))).ToArray()) { } - - public void Dispose() - { - if (!_modSizeString.IsEmpty) - _modSizeString.Dispose(); - Duration.Dispose(); - } } public static void DrawNotes((StringPair, StringPair)[] notes) diff --git a/Penumbra/UI/ModsTab/Selector/ModFileSystemCache.cs b/Penumbra/UI/ModsTab/Selector/ModFileSystemCache.cs index 3cd1e077..7b745ad7 100644 --- a/Penumbra/UI/ModsTab/Selector/ModFileSystemCache.cs +++ b/Penumbra/UI/ModsTab/Selector/ModFileSystemCache.cs @@ -74,12 +74,12 @@ public sealed class ModFileSystemCache : FileSystemCache node) : BaseFileSystemNodeCache, IDisposable + public sealed class ModData(IFileSystemData node) : BaseFileSystemNodeCache { public readonly IFileSystemData Node = node; public Vector4 TextColor; public ModPriority Priority; - public SizedString PriorityText = SizedString.Empty; + public StringU8 PriorityText = StringU8.Empty; public ModSettings? Settings; public ModCollection Collection = ModCollection.Empty; public StringU8 Name = new(node.Value.Name); @@ -94,8 +94,7 @@ public sealed class ModFileSystemCache : FileSystemCache Im.Style.ItemSpacing.X) - Im.Window.DrawList.Text(new Vector2(itemPos + offset, line), ColorId.SelectorPriority.Value().Color, PriorityText.Text); + Im.Window.DrawList.Text(new Vector2(itemPos + offset, line), ColorId.SelectorPriority.Value().Color, PriorityText); } - - public void Dispose() - => PriorityText.Dispose(); } public override void Update() diff --git a/Penumbra/UI/ResourceWatcher/ResourceWatcherTable.cs b/Penumbra/UI/ResourceWatcher/ResourceWatcherTable.cs index 364b4454..b0cfe9bc 100644 --- a/Penumbra/UI/ResourceWatcher/ResourceWatcherTable.cs +++ b/Penumbra/UI/ResourceWatcher/ResourceWatcherTable.cs @@ -43,27 +43,21 @@ public static class LoadStateExtensions | LoadStateFlag.None; } -internal sealed unsafe class CachedRecord(Record record) : IDisposable +internal sealed unsafe class CachedRecord(Record record) { - public readonly Record Record = record; - public readonly string PathU16 = record.Path.ToString(); - public readonly StringU8 TypeName = new(record.RecordType.ToNameU8()); - public readonly StringU8 Time = new($"{record.Time.ToLongTimeString()}.{record.Time.Millisecond:D4}"); - public readonly StringPair Crc64 = new($"{record.Crc64:X16}"); - public readonly StringU8 Collection = record.Collection is null ? StringU8.Empty : new StringU8(record.Collection.Identity.Name); - public readonly StringU8 AssociatedGameObject = new(record.AssociatedGameObject); - public readonly string OriginalPath = record.OriginalPath.ToString(); - public readonly StringU8 ResourceCategory = new($"{record.Category}"); - public readonly StringU8 ResourceType = new(record.ResourceType.ToString().ToLowerInvariant()); - public readonly string HandleU16 = $"0x{(nint)record.Handle:X}"; - public readonly SizedStringPair Thread = new($"{record.OsThreadId}"); - public readonly SizedStringPair RefCount = new($"{record.RefCount}"); - - public void Dispose() - { - Thread.Dispose(); - RefCount.Dispose(); - } + public readonly Record Record = record; + public readonly string PathU16 = record.Path.ToString(); + public readonly StringU8 TypeName = new(record.RecordType.ToNameU8()); + public readonly StringU8 Time = new($"{record.Time.ToLongTimeString()}.{record.Time.Millisecond:D4}"); + public readonly StringPair Crc64 = new($"{record.Crc64:X16}"); + public readonly StringU8 Collection = record.Collection is null ? StringU8.Empty : new StringU8(record.Collection.Identity.Name); + public readonly StringU8 AssociatedGameObject = new(record.AssociatedGameObject); + public readonly string OriginalPath = record.OriginalPath.ToString(); + public readonly StringU8 ResourceCategory = new($"{record.Category}"); + public readonly StringU8 ResourceType = new(record.ResourceType.ToString().ToLowerInvariant()); + public readonly string HandleU16 = $"0x{(nint)record.Handle:X}"; + public readonly StringPair Thread = new($"{record.OsThreadId}"); + public readonly StringPair RefCount = new($"{record.RefCount}"); } internal sealed class ResourceWatcherTable : TableBase> @@ -96,9 +90,7 @@ internal sealed class ResourceWatcherTable : TableBase _records = records; private static void DrawByteString(StringU8 path, float length) { @@ -513,7 +505,7 @@ internal sealed class ResourceWatcherTable : TableBase item.Record.RefCount; - protected override SizedString DisplayNumber(in CachedRecord item, int globalIndex) + protected override StringU8 DisplayNumber(in CachedRecord item, int globalIndex) => item.RefCount; protected override string ComparisonText(in CachedRecord item, int globalIndex) @@ -535,7 +527,7 @@ internal sealed class ResourceWatcherTable : TableBase item.Record.OsThreadId; - protected override SizedString DisplayNumber(in CachedRecord item, int globalIndex) + protected override StringU8 DisplayNumber(in CachedRecord item, int globalIndex) => item.Thread; protected override string ComparisonText(in CachedRecord item, int globalIndex)