mirror of
https://github.com/xivdev/Penumbra.git
synced 2025-12-12 18:27:24 +01:00
Remove BonusItem from use and update ResourceTree a bit.
This commit is contained in:
parent
2c5ffc1bc5
commit
1d5a7a41ab
5 changed files with 69 additions and 65 deletions
|
|
@ -1 +1 @@
|
||||||
Subproject commit 07b01ec9b043e4b8f56d084f5d6cde1ed4ed9a58
|
Subproject commit 61e067857c2cf62bf8426ff6b305e37990f7767a
|
||||||
|
|
@ -36,13 +36,13 @@ internal partial record ResolveContext
|
||||||
private Utf8GamePath ResolveEquipmentModelPath()
|
private Utf8GamePath ResolveEquipmentModelPath()
|
||||||
{
|
{
|
||||||
var path = IsEquipmentSlot(SlotIndex)
|
var path = IsEquipmentSlot(SlotIndex)
|
||||||
? GamePaths.Equipment.Mdl.Path(Equipment.Set, ResolveModelRaceCode(), Slot)
|
? GamePaths.Equipment.Mdl.Path(Equipment.Set, ResolveModelRaceCode(), Slot.ToSlot())
|
||||||
: GamePaths.Accessory.Mdl.Path(Equipment.Set, ResolveModelRaceCode(), Slot);
|
: GamePaths.Accessory.Mdl.Path(Equipment.Set, ResolveModelRaceCode(), Slot.ToSlot());
|
||||||
return Utf8GamePath.FromString(path, out var gamePath) ? gamePath : Utf8GamePath.Empty;
|
return Utf8GamePath.FromString(path, out var gamePath) ? gamePath : Utf8GamePath.Empty;
|
||||||
}
|
}
|
||||||
|
|
||||||
private GenderRace ResolveModelRaceCode()
|
private GenderRace ResolveModelRaceCode()
|
||||||
=> ResolveEqdpRaceCode(Slot, Equipment.Set);
|
=> ResolveEqdpRaceCode(Slot.ToSlot(), Equipment.Set);
|
||||||
|
|
||||||
private unsafe GenderRace ResolveEqdpRaceCode(EquipSlot slot, PrimaryId primaryId)
|
private unsafe GenderRace ResolveEqdpRaceCode(EquipSlot slot, PrimaryId primaryId)
|
||||||
{
|
{
|
||||||
|
|
@ -161,7 +161,7 @@ internal partial record ResolveContext
|
||||||
return variant.Id;
|
return variant.Id;
|
||||||
}
|
}
|
||||||
|
|
||||||
var entry = ImcFile.GetEntry(imcFileData, Slot, variant, out var exists);
|
var entry = ImcFile.GetEntry(imcFileData, Slot.ToSlot(), variant, out var exists);
|
||||||
if (!exists)
|
if (!exists)
|
||||||
return variant.Id;
|
return variant.Id;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -30,7 +30,7 @@ internal record GlobalResolveContext(
|
||||||
public readonly Dictionary<(Utf8GamePath, nint), ResourceNode> Nodes = new(128);
|
public readonly Dictionary<(Utf8GamePath, nint), ResourceNode> Nodes = new(128);
|
||||||
|
|
||||||
public unsafe ResolveContext CreateContext(CharaBase* characterBase, uint slotIndex = 0xFFFFFFFFu,
|
public unsafe ResolveContext CreateContext(CharaBase* characterBase, uint slotIndex = 0xFFFFFFFFu,
|
||||||
EquipSlot slot = EquipSlot.Unknown, CharacterArmor equipment = default, SecondaryId secondaryId = default)
|
FullEquipType slot = FullEquipType.Unknown, CharacterArmor equipment = default, SecondaryId secondaryId = default)
|
||||||
=> new(this, characterBase, slotIndex, slot, equipment, secondaryId);
|
=> new(this, characterBase, slotIndex, slot, equipment, secondaryId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -38,7 +38,7 @@ internal unsafe partial record ResolveContext(
|
||||||
GlobalResolveContext Global,
|
GlobalResolveContext Global,
|
||||||
Pointer<CharaBase> CharacterBasePointer,
|
Pointer<CharaBase> CharacterBasePointer,
|
||||||
uint SlotIndex,
|
uint SlotIndex,
|
||||||
EquipSlot Slot,
|
FullEquipType Slot,
|
||||||
CharacterArmor Equipment,
|
CharacterArmor Equipment,
|
||||||
SecondaryId SecondaryId)
|
SecondaryId SecondaryId)
|
||||||
{
|
{
|
||||||
|
|
@ -346,13 +346,14 @@ internal unsafe partial record ResolveContext(
|
||||||
if (isEquipment)
|
if (isEquipment)
|
||||||
foreach (var item in Global.Identifier.Identify(Equipment.Set, 0, Equipment.Variant, Slot.ToSlot()))
|
foreach (var item in Global.Identifier.Identify(Equipment.Set, 0, Equipment.Variant, Slot.ToSlot()))
|
||||||
{
|
{
|
||||||
var name = Slot switch
|
var name = item.Name;
|
||||||
|
if (Slot is FullEquipType.Finger)
|
||||||
|
name = SlotIndex switch
|
||||||
{
|
{
|
||||||
EquipSlot.RFinger => "R: ",
|
8 => "R: " + name,
|
||||||
EquipSlot.LFinger => "L: ",
|
9 => "L: " + name,
|
||||||
_ => string.Empty,
|
_ => name,
|
||||||
}
|
};
|
||||||
+ item.Name;
|
|
||||||
return new ResourceNode.UiData(name, item.Type.GetCategoryIcon().ToFlag());
|
return new ResourceNode.UiData(name, item.Type.GetCategoryIcon().ToFlag());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -361,7 +362,7 @@ internal unsafe partial record ResolveContext(
|
||||||
return dataFromPath;
|
return dataFromPath;
|
||||||
|
|
||||||
return isEquipment
|
return isEquipment
|
||||||
? new ResourceNode.UiData(Slot.ToName(), Slot.ToEquipType().GetCategoryIcon().ToFlag())
|
? new ResourceNode.UiData(Slot.ToName(), Slot.GetCategoryIcon().ToFlag())
|
||||||
: new ResourceNode.UiData(null, ChangedItemIconFlag.Unknown);
|
: new ResourceNode.UiData(null, ChangedItemIconFlag.Unknown);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -80,12 +80,13 @@ public class ResourceTree
|
||||||
{
|
{
|
||||||
ModelType.Human => i switch
|
ModelType.Human => i switch
|
||||||
{
|
{
|
||||||
< 10 => globalContext.CreateContext(model, i, i.ToEquipSlot(), equipment[(int)i]),
|
< 10 => globalContext.CreateContext(model, i, i.ToEquipSlot().ToEquipType(), equipment[(int)i]),
|
||||||
16 or 17 => globalContext.CreateContext(model, i, EquipSlot.Head, equipment[(int)(i - 6)]),
|
16 => globalContext.CreateContext(model, i, FullEquipType.Glasses, equipment[10]),
|
||||||
_ => globalContext.CreateContext(model, i),
|
17 => globalContext.CreateContext(model, i, FullEquipType.Unknown, equipment[11]),
|
||||||
|
_ => globalContext.CreateContext(model, i),
|
||||||
},
|
},
|
||||||
_ => i < equipment.Length
|
_ => i < equipment.Length
|
||||||
? globalContext.CreateContext(model, i, i.ToEquipSlot(), equipment[(int)i])
|
? globalContext.CreateContext(model, i, i.ToEquipSlot().ToEquipType(), equipment[(int)i])
|
||||||
: globalContext.CreateContext(model, i),
|
: globalContext.CreateContext(model, i),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -133,7 +134,7 @@ public class ResourceTree
|
||||||
var weapon = (Weapon*)subObject;
|
var weapon = (Weapon*)subObject;
|
||||||
|
|
||||||
// This way to tell apart MainHand and OffHand is not always accurate, but seems good enough for what we're doing with it.
|
// This way to tell apart MainHand and OffHand is not always accurate, but seems good enough for what we're doing with it.
|
||||||
var slot = weaponIndex > 0 ? EquipSlot.OffHand : EquipSlot.MainHand;
|
var slot = weaponIndex > 0 ? FullEquipType.UnknownOffhand : FullEquipType.UnknownMainhand;
|
||||||
var equipment = new CharacterArmor(weapon->ModelSetId, (byte)weapon->Variant, new StainIds(weapon->Stain0, weapon->Stain1));
|
var equipment = new CharacterArmor(weapon->ModelSetId, (byte)weapon->Variant, new StainIds(weapon->Stain0, weapon->Stain1));
|
||||||
var weaponType = weapon->SecondaryId;
|
var weaponType = weapon->SecondaryId;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -190,52 +190,6 @@ public class ResourceTreeViewer
|
||||||
var frameHeight = ImGui.GetFrameHeight();
|
var frameHeight = ImGui.GetFrameHeight();
|
||||||
var cellHeight = _actionCapacity > 0 ? frameHeight : 0.0f;
|
var cellHeight = _actionCapacity > 0 ? frameHeight : 0.0f;
|
||||||
|
|
||||||
bool MatchesFilter(ResourceNode node, ChangedItemIconFlag filterIcon)
|
|
||||||
{
|
|
||||||
if (!_typeFilter.HasFlag(filterIcon))
|
|
||||||
return false;
|
|
||||||
|
|
||||||
if (_nodeFilter.Length == 0)
|
|
||||||
return true;
|
|
||||||
|
|
||||||
return node.Name != null && node.Name.Contains(_nodeFilter, StringComparison.OrdinalIgnoreCase)
|
|
||||||
|| node.FullPath.FullName.Contains(_nodeFilter, StringComparison.OrdinalIgnoreCase)
|
|
||||||
|| node.FullPath.InternalName.ToString().Contains(_nodeFilter, StringComparison.OrdinalIgnoreCase)
|
|
||||||
|| Array.Exists(node.PossibleGamePaths, path => path.Path.ToString().Contains(_nodeFilter, StringComparison.OrdinalIgnoreCase));
|
|
||||||
}
|
|
||||||
|
|
||||||
NodeVisibility CalculateNodeVisibility(nint nodePathHash, ResourceNode node, ChangedItemIconFlag parentFilterIcon)
|
|
||||||
{
|
|
||||||
if (node.Internal && !debugMode)
|
|
||||||
return NodeVisibility.Hidden;
|
|
||||||
|
|
||||||
var filterIcon = node.IconFlag != 0 ? node.IconFlag : parentFilterIcon;
|
|
||||||
if (MatchesFilter(node, filterIcon))
|
|
||||||
return NodeVisibility.Visible;
|
|
||||||
|
|
||||||
foreach (var child in node.Children)
|
|
||||||
{
|
|
||||||
if (GetNodeVisibility(unchecked(nodePathHash * 31 + child.ResourceHandle), child, filterIcon) != NodeVisibility.Hidden)
|
|
||||||
return NodeVisibility.DescendentsOnly;
|
|
||||||
}
|
|
||||||
|
|
||||||
return NodeVisibility.Hidden;
|
|
||||||
}
|
|
||||||
|
|
||||||
NodeVisibility GetNodeVisibility(nint nodePathHash, ResourceNode node, ChangedItemIconFlag parentFilterIcon)
|
|
||||||
{
|
|
||||||
if (!_filterCache.TryGetValue(nodePathHash, out var visibility))
|
|
||||||
{
|
|
||||||
visibility = CalculateNodeVisibility(nodePathHash, node, parentFilterIcon);
|
|
||||||
_filterCache.Add(nodePathHash, visibility);
|
|
||||||
}
|
|
||||||
|
|
||||||
return visibility;
|
|
||||||
}
|
|
||||||
|
|
||||||
string GetAdditionalDataSuffix(CiByteString data)
|
|
||||||
=> !debugMode || data.IsEmpty ? string.Empty : $"\n\nAdditional Data: {data}";
|
|
||||||
|
|
||||||
foreach (var (resourceNode, index) in resourceNodes.WithIndex())
|
foreach (var (resourceNode, index) in resourceNodes.WithIndex())
|
||||||
{
|
{
|
||||||
var nodePathHash = unchecked(pathHash + resourceNode.ResourceHandle);
|
var nodePathHash = unchecked(pathHash + resourceNode.ResourceHandle);
|
||||||
|
|
@ -346,6 +300,54 @@ public class ResourceTreeViewer
|
||||||
if (unfolded)
|
if (unfolded)
|
||||||
DrawNodes(resourceNode.Children, level + 1, unchecked(nodePathHash * 31), filterIcon);
|
DrawNodes(resourceNode.Children, level + 1, unchecked(nodePathHash * 31), filterIcon);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return;
|
||||||
|
|
||||||
|
string GetAdditionalDataSuffix(CiByteString data)
|
||||||
|
=> !debugMode || data.IsEmpty ? string.Empty : $"\n\nAdditional Data: {data}";
|
||||||
|
|
||||||
|
NodeVisibility GetNodeVisibility(nint nodePathHash, ResourceNode node, ChangedItemIconFlag parentFilterIcon)
|
||||||
|
{
|
||||||
|
if (!_filterCache.TryGetValue(nodePathHash, out var visibility))
|
||||||
|
{
|
||||||
|
visibility = CalculateNodeVisibility(nodePathHash, node, parentFilterIcon);
|
||||||
|
_filterCache.Add(nodePathHash, visibility);
|
||||||
|
}
|
||||||
|
|
||||||
|
return visibility;
|
||||||
|
}
|
||||||
|
|
||||||
|
NodeVisibility CalculateNodeVisibility(nint nodePathHash, ResourceNode node, ChangedItemIconFlag parentFilterIcon)
|
||||||
|
{
|
||||||
|
if (node.Internal && !debugMode)
|
||||||
|
return NodeVisibility.Hidden;
|
||||||
|
|
||||||
|
var filterIcon = node.IconFlag != 0 ? node.IconFlag : parentFilterIcon;
|
||||||
|
if (MatchesFilter(node, filterIcon))
|
||||||
|
return NodeVisibility.Visible;
|
||||||
|
|
||||||
|
foreach (var child in node.Children)
|
||||||
|
{
|
||||||
|
if (GetNodeVisibility(unchecked(nodePathHash * 31 + child.ResourceHandle), child, filterIcon) != NodeVisibility.Hidden)
|
||||||
|
return NodeVisibility.DescendentsOnly;
|
||||||
|
}
|
||||||
|
|
||||||
|
return NodeVisibility.Hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool MatchesFilter(ResourceNode node, ChangedItemIconFlag filterIcon)
|
||||||
|
{
|
||||||
|
if (!_typeFilter.HasFlag(filterIcon))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (_nodeFilter.Length == 0)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
return node.Name != null && node.Name.Contains(_nodeFilter, StringComparison.OrdinalIgnoreCase)
|
||||||
|
|| node.FullPath.FullName.Contains(_nodeFilter, StringComparison.OrdinalIgnoreCase)
|
||||||
|
|| node.FullPath.InternalName.ToString().Contains(_nodeFilter, StringComparison.OrdinalIgnoreCase)
|
||||||
|
|| Array.Exists(node.PossibleGamePaths, path => path.Path.ToString().Contains(_nodeFilter, StringComparison.OrdinalIgnoreCase));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[Flags]
|
[Flags]
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue