Remove BonusItem from use and update ResourceTree a bit.

This commit is contained in:
Ottermandias 2024-10-11 16:35:47 +02:00
parent 2c5ffc1bc5
commit 1d5a7a41ab
5 changed files with 69 additions and 65 deletions

@ -1 +1 @@
Subproject commit 07b01ec9b043e4b8f56d084f5d6cde1ed4ed9a58
Subproject commit 61e067857c2cf62bf8426ff6b305e37990f7767a

View file

@ -36,13 +36,13 @@ internal partial record ResolveContext
private Utf8GamePath ResolveEquipmentModelPath()
{
var path = IsEquipmentSlot(SlotIndex)
? GamePaths.Equipment.Mdl.Path(Equipment.Set, ResolveModelRaceCode(), Slot)
: GamePaths.Accessory.Mdl.Path(Equipment.Set, ResolveModelRaceCode(), Slot);
? GamePaths.Equipment.Mdl.Path(Equipment.Set, ResolveModelRaceCode(), Slot.ToSlot())
: GamePaths.Accessory.Mdl.Path(Equipment.Set, ResolveModelRaceCode(), Slot.ToSlot());
return Utf8GamePath.FromString(path, out var gamePath) ? gamePath : Utf8GamePath.Empty;
}
private GenderRace ResolveModelRaceCode()
=> ResolveEqdpRaceCode(Slot, Equipment.Set);
=> ResolveEqdpRaceCode(Slot.ToSlot(), Equipment.Set);
private unsafe GenderRace ResolveEqdpRaceCode(EquipSlot slot, PrimaryId primaryId)
{
@ -161,7 +161,7 @@ internal partial record ResolveContext
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)
return variant.Id;

View file

@ -30,7 +30,7 @@ internal record GlobalResolveContext(
public readonly Dictionary<(Utf8GamePath, nint), ResourceNode> Nodes = new(128);
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);
}
@ -38,7 +38,7 @@ internal unsafe partial record ResolveContext(
GlobalResolveContext Global,
Pointer<CharaBase> CharacterBasePointer,
uint SlotIndex,
EquipSlot Slot,
FullEquipType Slot,
CharacterArmor Equipment,
SecondaryId SecondaryId)
{
@ -346,13 +346,14 @@ internal unsafe partial record ResolveContext(
if (isEquipment)
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: ",
EquipSlot.LFinger => "L: ",
_ => string.Empty,
}
+ item.Name;
8 => "R: " + name,
9 => "L: " + name,
_ => name,
};
return new ResourceNode.UiData(name, item.Type.GetCategoryIcon().ToFlag());
}
@ -361,7 +362,7 @@ internal unsafe partial record ResolveContext(
return dataFromPath;
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);
}

View file

@ -80,12 +80,13 @@ public class ResourceTree
{
ModelType.Human => i switch
{
< 10 => globalContext.CreateContext(model, i, i.ToEquipSlot(), equipment[(int)i]),
16 or 17 => globalContext.CreateContext(model, i, EquipSlot.Head, equipment[(int)(i - 6)]),
_ => globalContext.CreateContext(model, i),
< 10 => globalContext.CreateContext(model, i, i.ToEquipSlot().ToEquipType(), equipment[(int)i]),
16 => globalContext.CreateContext(model, i, FullEquipType.Glasses, equipment[10]),
17 => globalContext.CreateContext(model, i, FullEquipType.Unknown, equipment[11]),
_ => globalContext.CreateContext(model, i),
},
_ => 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),
};
@ -133,7 +134,7 @@ public class ResourceTree
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.
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 weaponType = weapon->SecondaryId;

View file

@ -190,52 +190,6 @@ public class ResourceTreeViewer
var frameHeight = ImGui.GetFrameHeight();
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())
{
var nodePathHash = unchecked(pathHash + resourceNode.ResourceHandle);
@ -346,6 +300,54 @@ public class ResourceTreeViewer
if (unfolded)
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]