Add Model Parsing and display them under Changed Items, also display variants there, and rework Data Sharing a bunch.

This commit is contained in:
Ottermandias 2022-11-24 18:25:51 +01:00
parent a64273bd73
commit eedd3e2dac
21 changed files with 17032 additions and 332 deletions

View file

@ -88,19 +88,19 @@ public partial class IndividualCollections
var kind = ObjectKind.None;
var lowerName = name.ToLowerInvariant();
// Prefer matching NPC names, fewer false positives than preferring players.
if( FindDataId( lowerName, _actorManager.Companions, out var dataId ) )
if( FindDataId( lowerName, _actorManager.Data.Companions, out var dataId ) )
{
kind = ObjectKind.Companion;
}
else if( FindDataId( lowerName, _actorManager.Mounts, out dataId ) )
else if( FindDataId( lowerName, _actorManager.Data.Mounts, out dataId ) )
{
kind = ObjectKind.MountType;
}
else if( FindDataId( lowerName, _actorManager.BNpcs, out dataId ) )
else if( FindDataId( lowerName, _actorManager.Data.BNpcs, out dataId ) )
{
kind = ObjectKind.BattleNpc;
}
else if( FindDataId( lowerName, _actorManager.ENpcs, out dataId ) )
else if( FindDataId( lowerName, _actorManager.Data.ENpcs, out dataId ) )
{
kind = ObjectKind.EventNpc;
}
@ -111,7 +111,7 @@ public partial class IndividualCollections
// If the name corresponds to a valid npc, add it as a group. If this fails, notify users.
var group = GetGroup( identifier );
var ids = string.Join( ", ", group.Select( i => i.DataId.ToString() ) );
if( Add( $"{_actorManager.ToName( kind, dataId )} ({kind.ToName()})", group, collection ) )
if( Add( $"{_actorManager.Data.ToName( kind, dataId )} ({kind.ToName()})", group, collection ) )
{
Penumbra.Log.Information( $"Migrated {name} ({kind.ToName()}) to NPC Identifiers [{ids}]." );
}
@ -128,7 +128,7 @@ public partial class IndividualCollections
identifier = _actorManager.CreatePlayer( ByteString.FromStringUnsafe( name, false ), ushort.MaxValue );
var shortName = string.Join( " ", name.Split().Select( n => $"{n[ 0 ]}." ) );
// Try to migrate the player name without logging full names.
if( Add( $"{name} ({_actorManager.ToWorldName( identifier.HomeWorld )})", new[] { identifier }, collection ) )
if( Add( $"{name} ({_actorManager.Data.ToWorldName( identifier.HomeWorld )})", new[] { identifier }, collection ) )
{
Penumbra.Log.Information( $"Migrated {shortName} ({collection.AnonymizedName}) to Player Identifier." );
}

View file

@ -100,13 +100,14 @@ public sealed partial class IndividualCollections
static ActorIdentifier[] CreateNpcs( ActorManager manager, ActorIdentifier identifier )
{
var name = manager.ToName( identifier.Kind, identifier.DataId );
var name = manager.Data.ToName( identifier.Kind, identifier.DataId );
var table = identifier.Kind switch
{
ObjectKind.BattleNpc => manager.BNpcs,
ObjectKind.EventNpc => manager.ENpcs,
ObjectKind.Companion => manager.Companions,
ObjectKind.MountType => manager.Mounts,
ObjectKind.BattleNpc => manager.Data.BNpcs,
ObjectKind.EventNpc => manager.Data.ENpcs,
ObjectKind.Companion => manager.Data.Companions,
ObjectKind.MountType => manager.Data.Mounts,
( ObjectKind )15 => manager.Data.Ornaments,
_ => throw new NotImplementedException(),
};
return table.Where( kvp => kvp.Value == name )
@ -205,11 +206,11 @@ public sealed partial class IndividualCollections
{
return identifier.Type switch
{
IdentifierType.Player => $"{identifier.PlayerName} ({_actorManager.ToWorldName( identifier.HomeWorld )})",
IdentifierType.Player => $"{identifier.PlayerName} ({_actorManager.Data.ToWorldName( identifier.HomeWorld )})",
IdentifierType.Retainer => $"{identifier.PlayerName} (Retainer)",
IdentifierType.Owned =>
$"{identifier.PlayerName} ({_actorManager.ToWorldName( identifier.HomeWorld )})'s {_actorManager.ToName( identifier.Kind, identifier.DataId )}",
IdentifierType.Npc => $"{_actorManager.ToName( identifier.Kind, identifier.DataId )} ({identifier.Kind.ToName()})",
$"{identifier.PlayerName} ({_actorManager.Data.ToWorldName( identifier.HomeWorld )})'s {_actorManager.Data.ToName( identifier.Kind, identifier.DataId )}",
IdentifierType.Npc => $"{_actorManager.Data.ToName( identifier.Kind, identifier.DataId )} ({identifier.Kind.ToName()})",
_ => string.Empty,
};
}

View file

@ -3,12 +3,14 @@ using System.Collections.Generic;
using System.Linq;
using System.Numerics;
using Dalamud.Interface;
using FFXIVClientStructs.FFXIV.Client.Graphics.Scene;
using ImGuiNET;
using Lumina.Data.Parsing;
using Lumina.Excel.GeneratedSheets;
using OtterGui;
using OtterGui.Classes;
using OtterGui.Raii;
using Penumbra.GameData.Structs;
using Penumbra.Mods;
using Penumbra.UI.Classes;
@ -44,10 +46,10 @@ public partial class ConfigWindow
}
ImGui.TableNextColumn();
if( item.Value.Item2 is Item it )
if( DrawChangedItemObject( item.Value.Item2, out var text ) )
{
using var color = ImRaii.PushColor( ImGuiCol.Text, ColorId.ItemId.Value() );
ImGuiUtil.RightAlign( $"({( ( Quad )it.ModelMain ).A})" );
ImGuiUtil.RightAlign( text );
}
}
@ -84,8 +86,8 @@ public partial class ConfigWindow
const ImGuiTableColumnFlags flags = ImGuiTableColumnFlags.NoResize | ImGuiTableColumnFlags.WidthFixed;
ImGui.TableSetupColumn( "items", flags, 400 * ImGuiHelpers.GlobalScale );
ImGui.TableSetupColumn( "mods", flags, varWidth - 100 * ImGuiHelpers.GlobalScale );
ImGui.TableSetupColumn( "id", flags, 100 * ImGuiHelpers.GlobalScale );
ImGui.TableSetupColumn( "mods", flags, varWidth - 120 * ImGuiHelpers.GlobalScale );
ImGui.TableSetupColumn( "id", flags, 120 * ImGuiHelpers.GlobalScale );
var items = Penumbra.CollectionManager.Current.ChangedItems;
var rest = _changedItemFilter.IsEmpty && _changedItemModFilter.IsEmpty

View file

@ -68,12 +68,12 @@ public partial class ConfigWindow
private string _newCharacterName = string.Empty;
private ObjectKind _newKind = ObjectKind.BattleNpc;
private readonly WorldCombo _worldCombo = new(Penumbra.Actors.Worlds);
private readonly NpcCombo _mountCombo = new("##mountCombo", Penumbra.Actors.Mounts);
private readonly NpcCombo _companionCombo = new("##companionCombo", Penumbra.Actors.Companions);
private readonly NpcCombo _ornamentCombo = new("##ornamentCombo", Penumbra.Actors.Ornaments);
private readonly NpcCombo _bnpcCombo = new("##bnpcCombo", Penumbra.Actors.BNpcs);
private readonly NpcCombo _enpcCombo = new("##enpcCombo", Penumbra.Actors.ENpcs);
private readonly WorldCombo _worldCombo = new(Penumbra.Actors.Data.Worlds);
private readonly NpcCombo _mountCombo = new("##mountCombo", Penumbra.Actors.Data.Mounts );
private readonly NpcCombo _companionCombo = new("##companionCombo", Penumbra.Actors.Data.Companions );
private readonly NpcCombo _ornamentCombo = new("##ornamentCombo", Penumbra.Actors.Data.Ornaments );
private readonly NpcCombo _bnpcCombo = new("##bnpcCombo", Penumbra.Actors.Data.BNpcs );
private readonly NpcCombo _enpcCombo = new("##enpcCombo", Penumbra.Actors.Data.ENpcs );
private const string NewPlayerTooltipEmpty = "Please enter a valid player name and choose an available world or 'Any World'.";
private const string NewRetainerTooltipEmpty = "Please enter a valid retainer name.";

View file

@ -16,6 +16,7 @@ using Penumbra.Interop.Resolver;
using Penumbra.Interop.Structs;
using Penumbra.String;
using CharacterUtility = Penumbra.Interop.CharacterUtility;
using ObjectKind = Dalamud.Game.ClientState.Objects.Enums.ObjectKind;
namespace Penumbra.UI;
@ -193,7 +194,8 @@ public partial class ConfigWindow
ImGuiUtil.DrawTableColumn( $"0x{obj.Address:X}" );
var identifier = Penumbra.Actors.FromObject( obj, true );
ImGuiUtil.DrawTableColumn( Penumbra.Actors.ToString( identifier ) );
ImGuiUtil.DrawTableColumn( identifier.DataId.ToString() );
var id = obj.ObjectKind == ObjectKind.BattleNpc ? $"{identifier.DataId} | {obj.DataId}" : identifier.DataId.ToString();
ImGuiUtil.DrawTableColumn( id );
}
}

View file

@ -3,6 +3,7 @@ using System.Linq;
using System.Numerics;
using Dalamud.Interface;
using Dalamud.Interface.ImGuiFileDialog;
using FFXIVClientStructs.FFXIV.Client.Graphics.Scene;
using ImGuiNET;
using Lumina.Data.Parsing;
using Lumina.Excel.GeneratedSheets;
@ -12,6 +13,7 @@ using OtterGui.Widgets;
using Penumbra.Api.Enums;
using Penumbra.Collections;
using Penumbra.GameData.Actors;
using Penumbra.GameData.Enums;
using Penumbra.Interop.Structs;
using Penumbra.String;
using Penumbra.UI.Classes;
@ -71,10 +73,27 @@ public partial class ConfigWindow
}
}
if( data is Item it && drawId )
if( drawId && DrawChangedItemObject( data, out var text ) )
{
ImGui.SameLine( ImGui.GetContentRegionAvail().X );
ImGuiUtil.RightJustify( $"({( ( Quad )it.ModelMain ).A})", ColorId.ItemId.Value() );
ImGuiUtil.RightJustify( text, ColorId.ItemId.Value() );
}
}
private static bool DrawChangedItemObject( object? obj, out string text )
{
switch( obj )
{
case Item it:
var quad = ( Quad )it.ModelMain;
text = quad.C == 0 ? $"({quad.A}-{quad.B})" : $"({quad.A}-{quad.B}-{quad.C})";
return true;
case ModelChara m:
text = $"({( ( CharacterBase.ModelType )m.Type ).ToName()} {m.Model}-{m.Base}-{m.Variant})";
return true;
default:
text = string.Empty;
return false;
}
}