diff --git a/Penumbra.GameData/Enums/BodySlot.cs b/Penumbra.GameData/Enums/BodySlot.cs index 0920b5e8..0e1220ce 100644 --- a/Penumbra.GameData/Enums/BodySlot.cs +++ b/Penumbra.GameData/Enums/BodySlot.cs @@ -29,7 +29,7 @@ namespace Penumbra.GameData.Enums } } - public static partial class GameData + public static partial class Names { public static readonly Dictionary< string, BodySlot > StringToBodySlot = new() { diff --git a/Penumbra.GameData/Enums/CustomizationType.cs b/Penumbra.GameData/Enums/CustomizationType.cs index f358c3ce..60cf23dd 100644 --- a/Penumbra.GameData/Enums/CustomizationType.cs +++ b/Penumbra.GameData/Enums/CustomizationType.cs @@ -38,7 +38,7 @@ namespace Penumbra.GameData.Enums } } - public static partial class GameData + public static partial class Names { public static readonly Dictionary< string, CustomizationType > SuffixToCustomizationType = new() { diff --git a/Penumbra.GameData/Enums/EquipSlot.cs b/Penumbra.GameData/Enums/EquipSlot.cs index 129e8a83..8d88a03a 100644 --- a/Penumbra.GameData/Enums/EquipSlot.cs +++ b/Penumbra.GameData/Enums/EquipSlot.cs @@ -106,7 +106,7 @@ namespace Penumbra.GameData.Enums } } - public static partial class GameData + public static partial class Names { public static readonly Dictionary< string, EquipSlot > SuffixToEquipSlot = new() { diff --git a/Penumbra.GameData/Enums/FileType.cs b/Penumbra.GameData/Enums/FileType.cs index 793b3bd6..e326ef17 100644 --- a/Penumbra.GameData/Enums/FileType.cs +++ b/Penumbra.GameData/Enums/FileType.cs @@ -19,7 +19,7 @@ namespace Penumbra.GameData.Enums Environment, } - public static partial class GameData + public static partial class Names { public static readonly Dictionary< string, FileType > ExtensionToFileType = new() { diff --git a/Penumbra.GameData/Enums/Race.cs b/Penumbra.GameData/Enums/Race.cs index 1f706319..88c97f59 100644 --- a/Penumbra.GameData/Enums/Race.cs +++ b/Penumbra.GameData/Enums/Race.cs @@ -296,7 +296,7 @@ namespace Penumbra.GameData.Enums } } - public static partial class GameData + public static partial class Names { public static GenderRace GenderRaceFromCode( string code ) { diff --git a/Penumbra.GameData/GameData.cs b/Penumbra.GameData/GameData.cs new file mode 100644 index 00000000..1c3670f8 --- /dev/null +++ b/Penumbra.GameData/GameData.cs @@ -0,0 +1,49 @@ +using System; +using System.Collections.Generic; +using Dalamud.Plugin; +using Lumina.Excel.GeneratedSheets; +using Penumbra.GameData.Enums; +using Penumbra.GameData.Structs; +using Penumbra.GameData.Util; + +namespace Penumbra.GameData +{ + public static class GameData + { + internal static ObjectIdentification? Identification; + internal static readonly GamePathParser GamePathParser = new(); + + public static IObjectIdentifier GetIdentifier( DalamudPluginInterface pi ) + { + Identification ??= new ObjectIdentification( pi ); + return Identification; + } + + public static IObjectIdentifier GetIdentifier( ) + { + if( Identification == null ) + { + throw new Exception( "Object Identification was not initialized." ); + } + return Identification; + } + + public static IGamePathParser GetGamePathParser() + => GamePathParser; + } + + public interface IObjectIdentifier + { + public void Identify( IDictionary< string, object? > set, GamePath path ); + + public Dictionary< string, object? > Identify( GamePath path ); + public Item? Identify( SetId setId, WeaponType weaponType, ushort variant, EquipSlot slot ); + } + + public interface IGamePathParser + { + public ObjectType PathToObjectType( GamePath path ); + public GameObjectInfo GetFileInfo( GamePath path ); + public string VfxToKey( GamePath path ); + } +} \ No newline at end of file diff --git a/Penumbra.GameData/GamePathParser.cs b/Penumbra.GameData/GamePathParser.cs index 4053fd57..3a979edf 100644 --- a/Penumbra.GameData/GamePathParser.cs +++ b/Penumbra.GameData/GamePathParser.cs @@ -9,7 +9,7 @@ using Penumbra.GameData.Util; namespace Penumbra.GameData { - public static class GamePathParser + internal class GamePathParser : IGamePathParser { private const string CharacterFolder = "chara"; private const string EquipmentFolder = "equipment"; @@ -31,7 +31,7 @@ namespace Penumbra.GameData private const string WorldFolder2 = "bg"; // @formatter:off - private static readonly Dictionary> Regexes = new() + private readonly Dictionary> _regexes = new() { { FileType.Font, new Dictionary< ObjectType, Regex[] >(){ { ObjectType.Font, new Regex[]{ new(@"common/font/(?'fontname'.*)_(?'id'\d\d)(_lobby)?\.fdt") } } } } , { FileType.Texture, new Dictionary< ObjectType, Regex[] >() { { ObjectType.Icon, new Regex[]{ new(@"ui/icon/(?'group'\d*)(/(?'lang'[a-z]{2}))?(/(?'hq'hq))?/(?'id'\d*)\.tex") } } @@ -68,7 +68,7 @@ namespace Penumbra.GameData }; // @formatter:on - public static ObjectType PathToObjectType( GamePath path ) + public ObjectType PathToObjectType( GamePath path ) { if( path.Empty ) { @@ -120,16 +120,16 @@ namespace Penumbra.GameData }; } - private static (FileType, ObjectType, Match?) ParseGamePath( GamePath path ) + private (FileType, ObjectType, Match?) ParseGamePath( GamePath path ) { - if( !GameData.Enums.GameData.ExtensionToFileType.TryGetValue( Extension( path ), out var fileType ) ) + if( !Enums.Names.ExtensionToFileType.TryGetValue( Extension( path ), out var fileType ) ) { fileType = FileType.Unknown; } var objectType = PathToObjectType( path ); - if( !Regexes.TryGetValue( fileType, out var objectDict ) ) + if( !_regexes.TryGetValue( fileType, out var objectDict ) ) { return ( fileType, objectType, null ); } @@ -157,7 +157,7 @@ namespace Penumbra.GameData return extIdx < 0 ? "" : filename.Substring( extIdx ); } - private static GameObjectInfo HandleEquipment( FileType fileType, ObjectType objectType, GroupCollection groups ) + private static GameObjectInfo HandleEquipment( FileType fileType, GroupCollection groups ) { var setId = ushort.Parse( groups[ "id" ].Value ); if( fileType == FileType.Imc ) @@ -165,8 +165,8 @@ namespace Penumbra.GameData return GameObjectInfo.Equipment( fileType, setId ); } - var gr = GameData.Enums.GameData.GenderRaceFromCode( groups[ "race" ].Value ); - var slot = GameData.Enums.GameData.SuffixToEquipSlot[ groups[ "slot" ].Value ]; + var gr = Enums.Names.GenderRaceFromCode( groups[ "race" ].Value ); + var slot = Enums.Names.SuffixToEquipSlot[ groups[ "slot" ].Value ]; if( fileType == FileType.Model ) { return GameObjectInfo.Equipment( fileType, setId, gr, slot ); @@ -176,7 +176,7 @@ namespace Penumbra.GameData return GameObjectInfo.Equipment( fileType, setId, gr, slot, variant ); } - private static GameObjectInfo HandleWeapon( FileType fileType, ObjectType objectType, GroupCollection groups ) + private static GameObjectInfo HandleWeapon( FileType fileType, GroupCollection groups ) { var weaponId = ushort.Parse( groups[ "weapon" ].Value ); var setId = ushort.Parse( groups[ "id" ].Value ); @@ -189,7 +189,7 @@ namespace Penumbra.GameData return GameObjectInfo.Weapon( fileType, setId, weaponId, variant ); } - private static GameObjectInfo HandleMonster( FileType fileType, ObjectType objectType, GroupCollection groups ) + private static GameObjectInfo HandleMonster( FileType fileType, GroupCollection groups ) { var monsterId = ushort.Parse( groups[ "monster" ].Value ); var bodyId = ushort.Parse( groups[ "id" ].Value ); @@ -202,7 +202,7 @@ namespace Penumbra.GameData return GameObjectInfo.Monster( fileType, monsterId, bodyId, variant ); } - private static GameObjectInfo HandleDemiHuman( FileType fileType, ObjectType objectType, GroupCollection groups ) + private static GameObjectInfo HandleDemiHuman( FileType fileType, GroupCollection groups ) { var demiHumanId = ushort.Parse( groups[ "id" ].Value ); var equipId = ushort.Parse( groups[ "equip" ].Value ); @@ -211,7 +211,7 @@ namespace Penumbra.GameData return GameObjectInfo.DemiHuman( fileType, demiHumanId, equipId ); } - var slot = GameData.Enums.GameData.SuffixToEquipSlot[ groups[ "slot" ].Value ]; + var slot = Enums.Names.SuffixToEquipSlot[ groups[ "slot" ].Value ]; if( fileType == FileType.Model ) { return GameObjectInfo.DemiHuman( fileType, demiHumanId, equipId, slot ); @@ -221,7 +221,7 @@ namespace Penumbra.GameData return GameObjectInfo.DemiHuman( fileType, demiHumanId, equipId, slot, variant ); } - private static GameObjectInfo HandleCustomization( FileType fileType, ObjectType objectType, GroupCollection groups ) + private static GameObjectInfo HandleCustomization( FileType fileType, GroupCollection groups ) { if( groups[ "skin" ].Success ) { @@ -236,9 +236,11 @@ namespace Penumbra.GameData return GameObjectInfo.Customization( fileType, tmpType, id ); } - var gr = GameData.Enums.GameData.GenderRaceFromCode( groups[ "race" ].Value ); - var bodySlot = GameData.Enums.GameData.StringToBodySlot[ groups[ "type" ].Value ]; - var type = groups[ "slot" ].Success ? GameData.Enums.GameData.SuffixToCustomizationType[ groups[ "slot" ].Value ] : CustomizationType.Skin; + var gr = Enums.Names.GenderRaceFromCode( groups[ "race" ].Value ); + var bodySlot = Enums.Names.StringToBodySlot[ groups[ "type" ].Value ]; + var type = groups[ "slot" ].Success + ? Enums.Names.SuffixToCustomizationType[ groups[ "slot" ].Value ] + : CustomizationType.Skin; if( fileType == FileType.Material ) { var variant = byte.Parse( groups[ "variant" ].Value ); @@ -248,7 +250,7 @@ namespace Penumbra.GameData return GameObjectInfo.Customization( fileType, type, id, gr, bodySlot ); } - private static GameObjectInfo HandleIcon( FileType fileType, ObjectType objectType, GroupCollection groups ) + private static GameObjectInfo HandleIcon( FileType fileType, GroupCollection groups ) { var hq = groups[ "hq" ].Success; var id = uint.Parse( groups[ "id" ].Value ); @@ -268,7 +270,7 @@ namespace Penumbra.GameData return GameObjectInfo.Icon( fileType, id, hq, language ); } - private static GameObjectInfo HandleMap( FileType fileType, ObjectType objectType, GroupCollection groups ) + private static GameObjectInfo HandleMap( FileType fileType, GroupCollection groups ) { var map = Encoding.ASCII.GetBytes( groups[ "id" ].Value ); var variant = byte.Parse( groups[ "variant" ].Value ); @@ -281,7 +283,7 @@ namespace Penumbra.GameData return GameObjectInfo.Map( fileType, map[ 0 ], map[ 1 ], map[ 2 ], map[ 3 ], variant ); } - public static GameObjectInfo GetFileInfo( GamePath path ) + public GameObjectInfo GetFileInfo( GamePath path ) { var (fileType, objectType, match) = ParseGamePath( path ); if( match == null || !match.Success ) @@ -294,14 +296,14 @@ namespace Penumbra.GameData var groups = match.Groups; switch( objectType ) { - case ObjectType.Accessory: return HandleEquipment( fileType, objectType, groups ); - case ObjectType.Equipment: return HandleEquipment( fileType, objectType, groups ); - case ObjectType.Weapon: return HandleWeapon( fileType, objectType, groups ); - case ObjectType.Map: return HandleMap( fileType, objectType, groups ); - case ObjectType.Monster: return HandleMonster( fileType, objectType, groups ); - case ObjectType.DemiHuman: return HandleDemiHuman( fileType, objectType, groups ); - case ObjectType.Character: return HandleCustomization( fileType, objectType, groups ); - case ObjectType.Icon: return HandleIcon( fileType, objectType, groups ); + case ObjectType.Accessory: return HandleEquipment( fileType, groups ); + case ObjectType.Equipment: return HandleEquipment( fileType, groups ); + case ObjectType.Weapon: return HandleWeapon( fileType, groups ); + case ObjectType.Map: return HandleMap( fileType, groups ); + case ObjectType.Monster: return HandleMonster( fileType, groups ); + case ObjectType.DemiHuman: return HandleDemiHuman( fileType, groups ); + case ObjectType.Character: return HandleCustomization( fileType, groups ); + case ObjectType.Icon: return HandleIcon( fileType, groups ); } } catch( Exception e ) @@ -312,19 +314,19 @@ namespace Penumbra.GameData return new GameObjectInfo { FileType = fileType, ObjectType = objectType }; } - private static readonly Regex VfxRegexTmb = new( @"chara/action/(?'key'[^\s]+?)\.tmb" ); - private static readonly Regex VfxRegexPap = new( @"chara/human/c0101/animation/a0001/[^\s]+?/(?'key'[^\s]+?)\.pap" ); + private readonly Regex _vfxRegexTmb = new( @"chara/action/(?'key'[^\s]+?)\.tmb" ); + private readonly Regex _vfxRegexPap = new( @"chara/human/c0101/animation/a0001/[^\s]+?/(?'key'[^\s]+?)\.pap" ); - public static string VfxToKey( GamePath path ) + public string VfxToKey( GamePath path ) { - var match = VfxRegexTmb.Match( path ); + var match = _vfxRegexTmb.Match( path ); if( match.Success ) { return match.Groups[ "key" ].Value.ToLowerInvariant(); } - match = VfxRegexPap.Match( path ); + match = _vfxRegexPap.Match( path ); return match.Success ? match.Groups[ "key" ].Value.ToLowerInvariant() : string.Empty; } } -} +} \ No newline at end of file diff --git a/Penumbra.GameData/ObjectIdentification.cs b/Penumbra.GameData/ObjectIdentification.cs index 950ac854..ae41793a 100644 --- a/Penumbra.GameData/ObjectIdentification.cs +++ b/Penumbra.GameData/ObjectIdentification.cs @@ -11,7 +11,7 @@ using Race = Penumbra.GameData.Enums.Race; namespace Penumbra.GameData { - internal class ObjectIdentification + internal class ObjectIdentification : IObjectIdentifier { private readonly List< (ulong, HashSet< Item >) > _weapons; private readonly List< (ulong, HashSet< Item >) > _equipment; @@ -267,7 +267,7 @@ namespace Penumbra.GameData private void IdentifyVfx( IDictionary< string, object? > set, GamePath path ) { - var key = GamePathParser.VfxToKey( path ); + var key = GameData.GamePathParser.VfxToKey( path ); if( key.Length == 0 || !_actions.TryGetValue( key, out var actions ) ) { return; @@ -287,11 +287,18 @@ namespace Penumbra.GameData } else { - var info = GamePathParser.GetFileInfo( path ); + var info = GameData.GamePathParser.GetFileInfo( path ); IdentifyParsed( set, info ); } } + public Dictionary< string, object? > Identify( GamePath path ) + { + Dictionary< string, object? > ret = new(); + Identify( ret, path ); + return ret; + } + public Item? Identify( SetId setId, WeaponType weaponType, ushort variant, EquipSlot slot ) { switch( slot ) @@ -313,4 +320,4 @@ namespace Penumbra.GameData } } } -} +} \ No newline at end of file diff --git a/Penumbra.GameData/ObjectIdentifier.cs b/Penumbra.GameData/ObjectIdentifier.cs deleted file mode 100644 index 2f48f22c..00000000 --- a/Penumbra.GameData/ObjectIdentifier.cs +++ /dev/null @@ -1,62 +0,0 @@ -using System; -using System.Collections.Generic; -using Dalamud.Plugin; -using Lumina.Excel.GeneratedSheets; -using Penumbra.GameData.Enums; -using Penumbra.GameData.Structs; -using Penumbra.GameData.Util; - -namespace Penumbra.GameData -{ - public static class ObjectIdentifier - { - private static ObjectIdentification? _identification = null; - - public static bool Initialize( DalamudPluginInterface pi ) - { - if( _identification != null ) - { - return true; - } - - try - { - _identification = new ObjectIdentification( pi ); - return true; - } - catch( Exception e ) - { - _identification = null; - PluginLog.Error( $"Failure while initializing Object Identifier:\n{e}" ); - return false; - } - } - - private static void Verify() - { - if( _identification == null ) - { - throw new Exception( "Object Identifier not initialized." ); - } - } - - public static void Identify( IDictionary< string, object? > set, GamePath path ) - { - Verify(); - _identification!.Identify( set, path ); - } - - public static Dictionary< string, object? > Identify( GamePath path ) - { - Dictionary< string, object? > ret = new(); - Identify( ret, path ); - return ret; - } - - public static Item? Identify( SetId setId, WeaponType weaponType, ushort variant, EquipSlot slot ) - { - Verify(); - return _identification!.Identify( setId, weaponType, variant, slot ); - } - } -} diff --git a/Penumbra.GameData/Structs/GameObjectInfo.cs b/Penumbra.GameData/Structs/GameObjectInfo.cs index 643c8566..80b6c792 100644 --- a/Penumbra.GameData/Structs/GameObjectInfo.cs +++ b/Penumbra.GameData/Structs/GameObjectInfo.cs @@ -123,7 +123,7 @@ namespace Penumbra.GameData.Structs public GenderRace GenderRace { - get => GameData.Enums.GameData.GenderRaceFromByte( _genderRaceByte ); + get => Names.GenderRaceFromByte( _genderRaceByte ); set => _genderRaceByte = value.ToByte(); } diff --git a/Penumbra.GameData/Util/GamePath.cs b/Penumbra.GameData/Util/GamePath.cs index 7d32b427..598dafe5 100644 --- a/Penumbra.GameData/Util/GamePath.cs +++ b/Penumbra.GameData/Util/GamePath.cs @@ -69,9 +69,9 @@ namespace Penumbra.GameData.Util { return rhs switch { - string path => string.Compare( _path, path, StringComparison.InvariantCulture ), + string path => string.Compare( _path, path, StringComparison.InvariantCulture ), GamePath path => string.Compare( _path, path._path, StringComparison.InvariantCulture ), - _ => -1, + _ => -1, }; } @@ -87,7 +87,7 @@ namespace Penumbra.GameData.Util public override object ReadJson( JsonReader reader, Type objectType, object? existingValue, JsonSerializer serializer ) { var token = JToken.Load( reader ); - return token.ToObject(); + return token.ToObject< GamePath >(); } public override bool CanWrite diff --git a/Penumbra/Importer/TexToolsMeta.cs b/Penumbra/Importer/TexToolsMeta.cs index 9b0a559d..9182e150 100644 --- a/Penumbra/Importer/TexToolsMeta.cs +++ b/Penumbra/Importer/TexToolsMeta.cs @@ -79,7 +79,7 @@ namespace Penumbra.Importer public Info( GamePath fileName ) { - PrimaryType = GamePathParser.PathToObjectType( fileName ); + PrimaryType = GameData.GameData.GetGamePathParser().PathToObjectType( fileName ); PrimaryId = 0; SecondaryType = BodySlot.Unknown; SecondaryId = 0; @@ -113,14 +113,14 @@ namespace Penumbra.Importer { case ObjectType.Equipment: case ObjectType.Accessory: - if( GameData.Enums.GameData.SuffixToEquipSlot.TryGetValue( match.Groups[ "Slot" ].Value, out var tmpSlot ) ) + if( GameData.Enums.Names.SuffixToEquipSlot.TryGetValue( match.Groups[ "Slot" ].Value, out var tmpSlot ) ) { EquipSlot = tmpSlot; } break; case ObjectType.Character: - if( GameData.Enums.GameData.SuffixToCustomizationType.TryGetValue( match.Groups[ "Slot" ].Value, out var tmpCustom ) ) + if( GameData.Enums.Names.SuffixToCustomizationType.TryGetValue( match.Groups[ "Slot" ].Value, out var tmpCustom ) ) { CustomizationType = tmpCustom; } @@ -130,7 +130,7 @@ namespace Penumbra.Importer } if( match.Groups[ "SecondaryType" ].Success - && GameData.Enums.GameData.StringToBodySlot.TryGetValue( match.Groups[ "SecondaryType" ].Value, out SecondaryType ) ) + && GameData.Enums.Names.StringToBodySlot.TryGetValue( match.Groups[ "SecondaryType" ].Value, out SecondaryType ) ) { SecondaryId = ushort.Parse( match.Groups[ "SecondaryId" ].Value ); } diff --git a/Penumbra/Meta/EntryExtensions.cs b/Penumbra/Meta/EntryExtensions.cs index 9eef2c5a..293d135e 100644 --- a/Penumbra/Meta/EntryExtensions.cs +++ b/Penumbra/Meta/EntryExtensions.cs @@ -46,7 +46,7 @@ namespace Penumbra.Meta public static class GmpEntryExtension { - public static GmpEntry Apply( this GmpEntry entry, MetaManipulation manipulation ) + public static GmpEntry Apply( this ref GmpEntry entry, MetaManipulation manipulation ) { if( manipulation.Type != MetaType.Gmp ) { diff --git a/Penumbra/Mod/ModCleanup.cs b/Penumbra/Mod/ModCleanup.cs index 18ddd4c6..40ebc487 100644 --- a/Penumbra/Mod/ModCleanup.cs +++ b/Penumbra/Mod/ModCleanup.cs @@ -161,7 +161,7 @@ namespace Penumbra.Mod var duplicates = FindOrCreateDuplicates( _mod ); if( !inOption1 ) { - duplicates.AddFile( relName2, relName2.ToGamePath() ); + duplicates.AddFile( relName1, relName2.ToGamePath() ); } if( !inOption2 ) diff --git a/Penumbra/Mod/ModData.cs b/Penumbra/Mod/ModData.cs index 4f3a0c6e..d359f412 100644 --- a/Penumbra/Mod/ModData.cs +++ b/Penumbra/Mod/ModData.cs @@ -31,18 +31,19 @@ namespace Penumbra.Mod public void ComputeChangedItems() { + var identifier = GameData.GameData.GetIdentifier(); ChangedItems.Clear(); foreach( var file in Resources.ModFiles.Select( f => new RelPath( f, BasePath ) ) ) { foreach( var path in ModFunctions.GetAllFiles( file, Meta ) ) { - ObjectIdentifier.Identify( ChangedItems, path ); + identifier.Identify( ChangedItems, path ); } } foreach( var path in Meta.FileSwaps.Keys ) { - ObjectIdentifier.Identify( ChangedItems, path ); + identifier.Identify( ChangedItems, path ); } } diff --git a/Penumbra/Mod/ModFunctions.cs b/Penumbra/Mod/ModFunctions.cs index 84214508..8f7f6e1c 100644 --- a/Penumbra/Mod/ModFunctions.cs +++ b/Penumbra/Mod/ModFunctions.cs @@ -53,7 +53,7 @@ namespace Penumbra.Mod if( ret.Count == 0 ) { - ret.Add( relPath.ToGamePath( ) ); + ret.Add( relPath.ToGamePath() ); } return ret; diff --git a/Penumbra/Plugin.cs b/Penumbra/Plugin.cs index f2975aea..f3a32f18 100644 --- a/Penumbra/Plugin.cs +++ b/Penumbra/Plugin.cs @@ -1,12 +1,9 @@ -using System; using Dalamud.Game.Command; using Dalamud.Plugin; using EmbedIO; using EmbedIO.WebApi; using Penumbra.API; -using Penumbra.GameData; using Penumbra.Interop; -using Penumbra.Meta; using Penumbra.Meta.Files; using Penumbra.Mods; using Penumbra.UI; @@ -41,7 +38,7 @@ namespace Penumbra { PluginInterface = pluginInterface; Service< DalamudPluginInterface >.Set( PluginInterface ); - ObjectIdentifier.Initialize( PluginInterface ); + GameData.GameData.GetIdentifier( PluginInterface ); Configuration = Configuration.Load( PluginInterface ); @@ -72,7 +69,7 @@ namespace Penumbra SettingsInterface = new SettingsInterface( this ); PluginInterface.UiBuilder.DisableGposeUiHide = true; - PluginInterface.UiBuilder.OnBuildUi += SettingsInterface.Draw; + PluginInterface.UiBuilder.OnBuildUi += SettingsInterface.Draw; if( Configuration.EnableHttpApi ) { diff --git a/Penumbra/UI/MenuTabs/TabDebug.cs b/Penumbra/UI/MenuTabs/TabDebug.cs index 783d3862..0206f137 100644 --- a/Penumbra/UI/MenuTabs/TabDebug.cs +++ b/Penumbra/UI/MenuTabs/TabDebug.cs @@ -39,6 +39,8 @@ namespace Penumbra.UI if( ImGui.BeginTable( "##ActorTable", 13, ImGuiTableFlags.SizingFixedFit | ImGuiTableFlags.ScrollX, new Vector2( -1, ImGui.GetTextLineHeightWithSpacing() * 4 * actors.Count ) ) ) { + var identifier = GameData.GameData.GetIdentifier( _plugin.PluginInterface ); + foreach( var actor in actors ) { // @formatter:off @@ -65,17 +67,17 @@ namespace Penumbra.UI ImGui.Text( "(not set)" ); } ImGui.TableNextColumn(); - ImGui.Text( ObjectIdentifier.Identify( actor.Value.Mainhand.Set, actor.Value.Mainhand.Type, actor.Value.Mainhand.Variant, EquipSlot.MainHand )?.Name.ToString() ?? "Unknown" ); + ImGui.Text( identifier.Identify( actor.Value.Mainhand.Set, actor.Value.Mainhand.Type, actor.Value.Mainhand.Variant, EquipSlot.MainHand )?.Name.ToString() ?? "Unknown" ); ImGui.TableNextColumn(); - ImGui.Text( ObjectIdentifier.Identify( actor.Value.Head.Set, actor.Value.Head.Variant, 0, EquipSlot.Head )?.Name.ToString() ?? "Unknown" ); + ImGui.Text( identifier.Identify( actor.Value.Head.Set, actor.Value.Head.Variant, 0, EquipSlot.Head )?.Name.ToString() ?? "Unknown" ); ImGui.TableNextColumn(); - ImGui.Text( ObjectIdentifier.Identify( actor.Value.Body.Set, actor.Value.Body.Variant, 0, EquipSlot.Body )?.Name.ToString() ?? "Unknown" ); + ImGui.Text( identifier.Identify( actor.Value.Body.Set, actor.Value.Body.Variant, 0, EquipSlot.Body )?.Name.ToString() ?? "Unknown" ); ImGui.TableNextColumn(); - ImGui.Text( ObjectIdentifier.Identify( actor.Value.Hands.Set, actor.Value.Hands.Variant, 0, EquipSlot.Hands )?.Name.ToString() ?? "Unknown" ); + ImGui.Text( identifier.Identify( actor.Value.Hands.Set, actor.Value.Hands.Variant, 0, EquipSlot.Hands )?.Name.ToString() ?? "Unknown" ); ImGui.TableNextColumn(); - ImGui.Text( ObjectIdentifier.Identify( actor.Value.Legs.Set, actor.Value.Legs.Variant, 0, EquipSlot.Legs )?.Name.ToString() ?? "Unknown" ); + ImGui.Text( identifier.Identify( actor.Value.Legs.Set, actor.Value.Legs.Variant, 0, EquipSlot.Legs )?.Name.ToString() ?? "Unknown" ); ImGui.TableNextColumn(); - ImGui.Text( ObjectIdentifier.Identify( actor.Value.Feet.Set, actor.Value.Feet.Variant, 0, EquipSlot.Feet )?.Name.ToString() ?? "Unknown" ); + ImGui.Text( identifier.Identify( actor.Value.Feet.Set, actor.Value.Feet.Variant, 0, EquipSlot.Feet )?.Name.ToString() ?? "Unknown" ); ImGui.TableNextRow(); ImGui.TableNextColumn(); @@ -95,17 +97,17 @@ namespace Penumbra.UI ImGui.TableNextRow(); ImGui.TableNextColumn(); ImGui.TableNextColumn(); - ImGui.Text( ObjectIdentifier.Identify( actor.Value.Offhand.Set, actor.Value.Offhand.Type, actor.Value.Offhand.Variant, EquipSlot.Offhand )?.Name.ToString() ?? "Unknown" ); + ImGui.Text( identifier.Identify( actor.Value.Offhand.Set, actor.Value.Offhand.Type, actor.Value.Offhand.Variant, EquipSlot.Offhand )?.Name.ToString() ?? "Unknown" ); ImGui.TableNextColumn(); - ImGui.Text( ObjectIdentifier.Identify( actor.Value.Ear.Set, actor.Value.Ear.Variant, 0, EquipSlot.Ears )?.Name.ToString() ?? "Unknown" ); + ImGui.Text( identifier.Identify( actor.Value.Ear.Set, actor.Value.Ear.Variant, 0, EquipSlot.Ears )?.Name.ToString() ?? "Unknown" ); ImGui.TableNextColumn(); - ImGui.Text( ObjectIdentifier.Identify( actor.Value.Neck.Set, actor.Value.Neck.Variant, 0, EquipSlot.Neck )?.Name.ToString() ?? "Unknown" ); + ImGui.Text( identifier.Identify( actor.Value.Neck.Set, actor.Value.Neck.Variant, 0, EquipSlot.Neck )?.Name.ToString() ?? "Unknown" ); ImGui.TableNextColumn(); - ImGui.Text( ObjectIdentifier.Identify( actor.Value.Wrist.Set, actor.Value.Wrist.Variant, 0, EquipSlot.Wrists )?.Name.ToString() ?? "Unknown" ); + ImGui.Text( identifier.Identify( actor.Value.Wrist.Set, actor.Value.Wrist.Variant, 0, EquipSlot.Wrists )?.Name.ToString() ?? "Unknown" ); ImGui.TableNextColumn(); - ImGui.Text( ObjectIdentifier.Identify( actor.Value.LFinger.Set, actor.Value.LFinger.Variant, 0, EquipSlot.RingL )?.Name.ToString() ?? "Unknown" ); + ImGui.Text( identifier.Identify( actor.Value.LFinger.Set, actor.Value.LFinger.Variant, 0, EquipSlot.RingL )?.Name.ToString() ?? "Unknown" ); ImGui.TableNextColumn(); - ImGui.Text( ObjectIdentifier.Identify( actor.Value.RFinger.Set, actor.Value.RFinger.Variant, 0, EquipSlot.RingL )?.Name.ToString() ?? "Unknown" ); + ImGui.Text( identifier.Identify( actor.Value.RFinger.Set, actor.Value.RFinger.Variant, 0, EquipSlot.RingL )?.Name.ToString() ?? "Unknown" ); // @formatter:on } diff --git a/Penumbra/UI/MenuTabs/TabInstalled/TabInstalledDetails.cs b/Penumbra/UI/MenuTabs/TabInstalled/TabInstalledDetails.cs index e40a4ea8..866e084d 100644 --- a/Penumbra/UI/MenuTabs/TabInstalled/TabInstalledDetails.cs +++ b/Penumbra/UI/MenuTabs/TabInstalled/TabInstalledDetails.cs @@ -13,22 +13,6 @@ using Penumbra.Util; namespace Penumbra.UI { - internal static class ListRemoveExtension - { - // Remove the entry at idx from the list if the new string is empty, otherwise replace it. - public static void RemoveOrChange( this List< string > list, string newString, int idx ) - { - if( newString.Length == 0 ) - { - list.RemoveAt( idx ); - } - else - { - list[ idx ] = newString; - } - } - } - public partial class SettingsInterface { private partial class PluginDetails diff --git a/Penumbra/UI/MenuTabs/TabInstalled/TabInstalledDetailsManipulations.cs b/Penumbra/UI/MenuTabs/TabInstalled/TabInstalledDetailsManipulations.cs index 4aca73e0..05dc4a5e 100644 --- a/Penumbra/UI/MenuTabs/TabInstalled/TabInstalledDetailsManipulations.cs +++ b/Penumbra/UI/MenuTabs/TabInstalled/TabInstalledDetailsManipulations.cs @@ -742,7 +742,7 @@ namespace Penumbra.UI CustomCombo( "Equipment Slot", EqdpEquipSlots, out var equipSlot, ref _newManipEquipSlot ); CustomCombo( "Race", Races, out var race, ref _newManipRace ); CustomCombo( "Gender", Genders, out var gender, ref _newManipGender ); - newManip = MetaManipulation.Eqdp( equipSlot, GameData.Enums.GameData.CombinedRace( gender, race ), ( ushort )_newManipSetId, + newManip = MetaManipulation.Eqdp( equipSlot, GameData.Enums.Names.CombinedRace( gender, race ), ( ushort )_newManipSetId, new EqdpEntry() ); break; } @@ -771,7 +771,7 @@ namespace Penumbra.UI CustomCombo( "Race", Races, out var race, ref _newManipRace ); CustomCombo( "Gender", Genders, out var gender, ref _newManipGender ); - newManip = MetaManipulation.Est( objectType, equipSlot, GameData.Enums.GameData.CombinedRace( gender, race ), bodySlot, + newManip = MetaManipulation.Est( objectType, equipSlot, GameData.Enums.Names.CombinedRace( gender, race ), bodySlot, ( ushort )_newManipSetId, 0 ); break; }