mirror of
https://github.com/xivdev/Penumbra.git
synced 2026-02-20 14:57:50 +01:00
Remove usage of SizedString and SizedStringPair.
This commit is contained in:
parent
68441f753b
commit
cdf9ea1b87
4 changed files with 37 additions and 64 deletions
|
|
@ -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<CacheItem> 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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -74,12 +74,12 @@ public sealed class ModFileSystemCache : FileSystemCache<ModFileSystemCache.ModD
|
|||
}
|
||||
}
|
||||
|
||||
public sealed class ModData(IFileSystemData<Mod> node) : BaseFileSystemNodeCache<ModData>, IDisposable
|
||||
public sealed class ModData(IFileSystemData<Mod> node) : BaseFileSystemNodeCache<ModData>
|
||||
{
|
||||
public readonly IFileSystemData<Mod> 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<ModFileSystemCache.ModD
|
|||
if (priority != Priority)
|
||||
{
|
||||
Priority = priority;
|
||||
PriorityText.Dispose();
|
||||
PriorityText = priority.IsDefault ? SizedString.Empty : new SizedString($"[{priority}]");
|
||||
PriorityText = priority.IsDefault ? StringU8.Empty : new StringU8($"[{priority}]");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -178,16 +177,13 @@ public sealed class ModFileSystemCache : FileSystemCache<ModFileSystemCache.ModD
|
|||
var itemPos = Im.Item.LowerRightCorner.X;
|
||||
var maxWidth = Im.Window.Position.X + Im.Window.MaximumContentRegion.X;
|
||||
var remainingSpace = maxWidth - itemPos;
|
||||
var offset = remainingSpace - PriorityText.Size.X;
|
||||
var offset = remainingSpace - PriorityText.CalculateSize().X;
|
||||
if (Im.Scroll.MaximumY is 0)
|
||||
offset -= Im.Style.ItemInnerSpacing.X;
|
||||
|
||||
if (offset > 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()
|
||||
|
|
|
|||
|
|
@ -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<CachedRecord, TableCache<CachedRecord>>
|
||||
|
|
@ -96,9 +90,7 @@ internal sealed class ResourceWatcherTable : TableBase<CachedRecord, TableCache<
|
|||
new Crc64Column(filterConfig) { Label = new StringU8("Crc64"u8) },
|
||||
new OsThreadColumn(filterConfig) { Label = new StringU8("TID"u8) }
|
||||
)
|
||||
{
|
||||
_records = records;
|
||||
}
|
||||
=> _records = records;
|
||||
|
||||
private static void DrawByteString(StringU8 path, float length)
|
||||
{
|
||||
|
|
@ -513,7 +505,7 @@ internal sealed class ResourceWatcherTable : TableBase<CachedRecord, TableCache<
|
|||
public override uint ToValue(in CachedRecord item, int globalIndex)
|
||||
=> 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<CachedRecord, TableCache<
|
|||
public override uint ToValue(in CachedRecord item, int globalIndex)
|
||||
=> 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)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue