Some stashed changes already applied.

This commit is contained in:
Ottermandias 2024-11-22 00:43:36 +01:00
parent f2bdaf1b49
commit ee48ea0166
10 changed files with 55 additions and 23 deletions

View file

@ -3,6 +3,7 @@ using Penumbra.Collections;
using Penumbra.Enums;
using Penumbra.Interop.Structs;
using Penumbra.String;
using Penumbra.String.Classes;
namespace Penumbra.UI.ResourceWatcher;
@ -24,14 +25,16 @@ internal unsafe struct Record
public ModCollection? Collection;
public ResourceHandle* Handle;
public ResourceTypeFlag ResourceType;
public ResourceCategoryFlag Category;
public ulong Crc64;
public uint RefCount;
public ResourceCategoryFlag Category;
public RecordType RecordType;
public OptionalBool Synchronously;
public OptionalBool ReturnValue;
public OptionalBool CustomLoad;
public LoadState LoadState;
public static Record CreateRequest(CiByteString path, bool sync)
=> new()
{
@ -49,6 +52,7 @@ internal unsafe struct Record
CustomLoad = OptionalBool.Null,
AssociatedGameObject = string.Empty,
LoadState = LoadState.None,
Crc64 = 0,
};
public static Record CreateDefaultLoad(CiByteString path, ResourceHandle* handle, ModCollection collection, string associatedGameObject)
@ -70,15 +74,16 @@ internal unsafe struct Record
CustomLoad = false,
AssociatedGameObject = associatedGameObject,
LoadState = handle->LoadState,
Crc64 = 0,
};
}
public static Record CreateLoad(CiByteString path, CiByteString originalPath, ResourceHandle* handle, ModCollection collection,
public static Record CreateLoad(FullPath path, CiByteString originalPath, ResourceHandle* handle, ModCollection collection,
string associatedGameObject)
=> new()
{
Time = DateTime.UtcNow,
Path = path.IsOwned ? path : path.Clone(),
Path = path.InternalName.IsOwned ? path.InternalName : path.InternalName.Clone(),
OriginalPath = originalPath.IsOwned ? originalPath : originalPath.Clone(),
Collection = collection,
Handle = handle,
@ -91,6 +96,7 @@ internal unsafe struct Record
CustomLoad = true,
AssociatedGameObject = associatedGameObject,
LoadState = handle->LoadState,
Crc64 = path.Crc64,
};
public static Record CreateDestruction(ResourceHandle* handle)
@ -112,6 +118,7 @@ internal unsafe struct Record
CustomLoad = OptionalBool.Null,
AssociatedGameObject = string.Empty,
LoadState = handle->LoadState,
Crc64 = 0,
};
}
@ -132,5 +139,6 @@ internal unsafe struct Record
CustomLoad = custom,
AssociatedGameObject = string.Empty,
LoadState = handle->LoadState,
Crc64 = 0,
};
}

View file

@ -250,7 +250,7 @@ public sealed class ResourceWatcher : IDisposable, ITab, IUiService
var record = manipulatedPath == null
? Record.CreateDefaultLoad(path.Path, handle, data.ModCollection, Name(data))
: Record.CreateLoad(manipulatedPath.Value.InternalName, path.Path, handle, data.ModCollection, Name(data));
: Record.CreateLoad(manipulatedPath.Value, path.Path, handle, data.ModCollection, Name(data));
if (!_ephemeral.OnlyAddMatchingResources || _table.WouldBeVisible(record))
_newRecords.Enqueue(record);
}

View file

@ -29,7 +29,8 @@ internal sealed class ResourceWatcherTable : Table<Record>
new HandleColumn { Label = "Resource" },
new LoadStateColumn { Label = "State" },
new RefCountColumn { Label = "#Ref" },
new DateColumn { Label = "Time" }
new DateColumn { Label = "Time" },
new Crc64Column { Label = "Crc64" }
)
{ }
@ -144,6 +145,21 @@ internal sealed class ResourceWatcherTable : Table<Record>
=> ImGui.TextUnformatted($"{item.Time.ToLongTimeString()}.{item.Time.Millisecond:D4}");
}
private sealed class Crc64Column : ColumnString<Record>
{
public override float Width
=> UiBuilder.MonoFont.GetCharAdvance('0') * 17;
public override unsafe string ToName(Record item)
=> item.Crc64 != 0 ? $"{item.Crc64:X16}" : string.Empty;
public override unsafe void DrawColumn(Record item, int _)
{
using var font = ImRaii.PushFont(UiBuilder.MonoFont, item.Handle != null);
ImUtf8.Text(ToName(item));
}
}
private sealed class CollectionColumn : ColumnString<Record>
{