mirror of
https://github.com/xivdev/Penumbra.git
synced 2026-02-17 13:27:44 +01:00
Material editor: live-preview changes
This commit is contained in:
parent
ccca2f1434
commit
f64fdd2b26
14 changed files with 1067 additions and 110 deletions
|
|
@ -65,26 +65,34 @@ internal record class ResolveContext(Configuration Config, IObjectIdentifier Ide
|
|||
private ResourceNode CreateNodeFromGamePath(ResourceType type, nint sourceAddress, Utf8GamePath gamePath, bool @internal)
|
||||
=> new(null, type, sourceAddress, gamePath, FilterFullPath(Collection.ResolvePath(gamePath) ?? new FullPath(gamePath)), @internal);
|
||||
|
||||
private unsafe ResourceNode? CreateNodeFromResourceHandle(ResourceType type, nint sourceAddress, ResourceHandle* handle, bool @internal,
|
||||
bool withName)
|
||||
public static unsafe FullPath GetResourceHandlePath(ResourceHandle* handle)
|
||||
{
|
||||
if (handle == null)
|
||||
return null;
|
||||
|
||||
var name = handle->FileName();
|
||||
if (name.IsEmpty)
|
||||
return null;
|
||||
return FullPath.Empty;
|
||||
|
||||
if (name[0] == (byte)'|')
|
||||
{
|
||||
var pos = name.IndexOf((byte)'|', 1);
|
||||
if (pos < 0)
|
||||
return null;
|
||||
return FullPath.Empty;
|
||||
|
||||
name = name.Substring(pos + 1);
|
||||
}
|
||||
|
||||
var fullPath = new FullPath(Utf8GamePath.FromByteString(name, out var p) ? p : Utf8GamePath.Empty);
|
||||
return new FullPath(Utf8GamePath.FromByteString(name, out var p) ? p : Utf8GamePath.Empty);
|
||||
}
|
||||
|
||||
private unsafe ResourceNode? CreateNodeFromResourceHandle(ResourceType type, nint sourceAddress, ResourceHandle* handle, bool @internal,
|
||||
bool withName)
|
||||
{
|
||||
if (handle == null)
|
||||
return null;
|
||||
|
||||
var fullPath = GetResourceHandlePath(handle);
|
||||
if (fullPath.InternalName.IsEmpty)
|
||||
return null;
|
||||
|
||||
var gamePaths = Collection.ReverseResolvePath(fullPath).ToList();
|
||||
fullPath = FilterFullPath(fullPath);
|
||||
|
||||
|
|
@ -161,7 +169,7 @@ internal record class ResolveContext(Configuration Config, IObjectIdentifier Ide
|
|||
if (mtrl == null)
|
||||
return null;
|
||||
|
||||
var resource = (MtrlResource*)mtrl->ResourceHandle;
|
||||
var resource = mtrl->ResourceHandle;
|
||||
var node = CreateNodeFromResourceHandle(ResourceType.Mtrl, (nint) mtrl, &resource->Handle, false, WithNames);
|
||||
if (node == null)
|
||||
return null;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue