From 3f48cd69104a903bd4436b1c83bc317693a6180b Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Mon, 13 Oct 2025 17:44:57 +0200 Subject: [PATCH] Fix up Ipc Testers. --- Luna | 2 +- Penumbra.GameData | 2 +- .../Api/IpcTester/CollectionsIpcTester.cs | 171 +++++------ Penumbra/Api/IpcTester/EditingIpcTester.cs | 34 ++- Penumbra/Api/IpcTester/GameStateIpcTester.cs | 78 ++--- Penumbra/Api/IpcTester/IpcTester.cs | 4 +- Penumbra/Api/IpcTester/MetaIpcTester.cs | 28 +- .../Api/IpcTester/ModSettingsIpcTester.cs | 264 +++++++++-------- Penumbra/Api/IpcTester/ModsIpcTester.cs | 143 +++++---- .../Api/IpcTester/PluginStateIpcTester.cs | 84 +++--- Penumbra/Api/IpcTester/RedrawingIpcTester.cs | 34 ++- Penumbra/Api/IpcTester/ResolveIpcTester.cs | 102 ++++--- .../Api/IpcTester/ResourceTreeIpcTester.cs | 175 ++++++----- Penumbra/Api/IpcTester/TemporaryIpcTester.cs | 274 +++++++++++------- Penumbra/Api/IpcTester/UiIpcTester.cs | 73 +++-- 15 files changed, 843 insertions(+), 625 deletions(-) diff --git a/Luna b/Luna index 8fab2f16..2542a466 160000 --- a/Luna +++ b/Luna @@ -1 +1 @@ -Subproject commit 8fab2f1622f6ccfdab34462bd3ebe7b4947c0589 +Subproject commit 2542a4665aca0ee7a66ad940638ff84cd04e35b5 diff --git a/Penumbra.GameData b/Penumbra.GameData index 3ea62e44..fcb443b7 160000 --- a/Penumbra.GameData +++ b/Penumbra.GameData @@ -1 +1 @@ -Subproject commit 3ea62e440aff15a856d5555bb8a0dd1862c40f59 +Subproject commit fcb443b79b0954967a959aa2f498699bd1a54923 diff --git a/Penumbra/Api/IpcTester/CollectionsIpcTester.cs b/Penumbra/Api/IpcTester/CollectionsIpcTester.cs index 5143639b..a75f3294 100644 --- a/Penumbra/Api/IpcTester/CollectionsIpcTester.cs +++ b/Penumbra/Api/IpcTester/CollectionsIpcTester.cs @@ -1,12 +1,13 @@ using Dalamud.Plugin; using ImSharp; +using Luna; using Penumbra.Api.Enums; using Penumbra.Api.IpcSubscribers; using Penumbra.GameData.Data; namespace Penumbra.Api.IpcTester; -public class CollectionsIpcTester(IDalamudPluginInterface pi) : Luna.IUiService +public class CollectionsIpcTester(IDalamudPluginInterface pi) : IUiService { private int _objectIdx; private Guid? _collectionId; @@ -46,98 +47,109 @@ public class CollectionsIpcTester(IDalamudPluginInterface pi) : Luna.IUiService if (!table) return; + table.DrawColumn("Last Return Code"u8); table.DrawColumn($"{_returnCode}"); if (_oldCollection is not null) Im.Text(!_oldCollection.HasValue ? "Created" : _oldCollection.ToString()!); table.NextRow(); - table.DrawColumn(GetCollectionsByIdentifier.Label); - table.DrawColumn("Collection Identifier"u8); - var collectionList = new GetCollectionsByIdentifier(pi).Invoke(_collectionId.GetValueOrDefault().ToString()); - if (collectionList.Count == 0) + using (IpcTester.DrawIntro(GetCollectionsByIdentifier.Label, "Collection Identifier"u8)) { - DrawCollection(table, null); - } - else - { - DrawCollection(table, collectionList[0]); - foreach (var pair in collectionList.Skip(1)) + var collectionList = new GetCollectionsByIdentifier(pi).Invoke(_collectionId.GetValueOrDefault().ToString()); + if (collectionList.Count == 0) { - table.NextRow(); - table.NextColumn(); - table.NextColumn(); - table.NextColumn(); - DrawCollection(table, pair); + DrawCollection(table, null); + } + else + { + DrawCollection(table, collectionList[0]); + foreach (var pair in collectionList.Skip(1)) + { + table.NextRow(); + table.NextColumn(); + table.NextColumn(); + table.NextColumn(); + DrawCollection(table, pair); + } } } - table.DrawColumn(GetCollection.Label); - table.DrawColumn("Current Collection"u8); - DrawCollection(table, new GetCollection(pi).Invoke(ApiCollectionType.Current)); - - table.DrawColumn(GetCollection.Label); - table.DrawColumn("Default Collection"u8); - DrawCollection(table, new GetCollection(pi).Invoke(ApiCollectionType.Default)); - - table.DrawColumn(GetCollection.Label); - table.DrawColumn("Interface Collection"u8); - DrawCollection(table, new GetCollection(pi).Invoke(ApiCollectionType.Interface)); - - table.DrawColumn(GetCollection.Label); - table.DrawColumn("Special Collection"u8); - DrawCollection(table, new GetCollection(pi).Invoke(_type)); - - table.DrawColumn(GetCollections.Label); - table.DrawColumn("Collections"u8); - DrawCollectionPopup(); - table.NextColumn(); - if (Im.Button("Get##Collections"u8)) + using (IpcTester.DrawIntro(GetCollection.Label, "Current Collection"u8)) { - _collections = new GetCollections(pi).Invoke(); - Im.Popup.Open("Collections"u8); + DrawCollection(table, new GetCollection(pi).Invoke(ApiCollectionType.Current)); } - table.DrawColumn(GetCollectionForObject.Label); - table.DrawColumn("Get Object Collection"u8); - var (valid, individual, effectiveCollection) = new GetCollectionForObject(pi).Invoke(_objectIdx); - DrawCollection(table, effectiveCollection); - Im.Line.Same(); - Im.Text($"({(valid ? "Valid" : "Invalid")} Object{(individual ? ", Individual Assignment)" : ")")}"); - - table.DrawColumn(SetCollection.Label); - table.DrawColumn("Set Special Collection"u8); - table.NextColumn(); - if (Im.Button("Set##SpecialCollection"u8)) - (_returnCode, _oldCollection) = - new SetCollection(pi).Invoke(_type, _collectionId.GetValueOrDefault(Guid.Empty), _allowCreation, _allowDeletion); - table.NextColumn(); - if (Im.Button("Remove##SpecialCollection"u8)) - (_returnCode, _oldCollection) = new SetCollection(pi).Invoke(_type, null, _allowCreation, _allowDeletion); - - table.DrawColumn(SetCollectionForObject.Label); - table.DrawColumn("Set Object Collection"u8); - table.NextColumn(); - if (Im.Button("Set##ObjectCollection"u8)) - (_returnCode, _oldCollection) = new SetCollectionForObject(pi).Invoke(_objectIdx, _collectionId.GetValueOrDefault(Guid.Empty), - _allowCreation, _allowDeletion); - table.NextColumn(); - if (Im.Button("Remove##ObjectCollection"u8)) - (_returnCode, _oldCollection) = new SetCollectionForObject(pi).Invoke(_objectIdx, null, _allowCreation, _allowDeletion); - - table.DrawColumn(GetChangedItemsForCollection.Label); - table.DrawColumn("Changed Item List"u8); - DrawChangedItemPopup(); - table.NextColumn(); - if (Im.Button("Get##ChangedItems"u8)) + using (IpcTester.DrawIntro(GetCollection.Label, "Default Collection"u8)) { - var items = new GetChangedItemsForCollection(pi).Invoke(_collectionId.GetValueOrDefault(Guid.Empty)); - _changedItems = items.Select(kvp => + DrawCollection(table, new GetCollection(pi).Invoke(ApiCollectionType.Default)); + } + + using (IpcTester.DrawIntro(GetCollection.Label, "Interface Collection"u8)) + { + DrawCollection(table, new GetCollection(pi).Invoke(ApiCollectionType.Interface)); + } + + using (IpcTester.DrawIntro(GetCollection.Label, "Special Collection"u8)) + { + DrawCollection(table, new GetCollection(pi).Invoke(_type)); + } + + using (IpcTester.DrawIntro(GetCollections.Label, "Collections"u8)) + { + DrawCollectionPopup(); + table.NextColumn(); + if (Im.SmallButton("Get##Collections"u8)) { - var (type, id) = kvp.Value.ToApiObject(); - return (kvp.Key, type, id); - }).ToArray(); - Im.Popup.Open("Changed Item List"u8); + _collections = new GetCollections(pi).Invoke(); + Im.Popup.Open("Collections"u8); + } + } + + using (IpcTester.DrawIntro(GetCollectionForObject.Label, "Get Object Collection"u8)) + { + var (valid, individual, effectiveCollection) = new GetCollectionForObject(pi).Invoke(_objectIdx); + DrawCollection(table, effectiveCollection); + Im.Line.Same(); + Im.Text($"({(valid ? "Valid" : "Invalid")} Object{(individual ? ", Individual Assignment)" : ")")}"); + } + + using (IpcTester.DrawIntro(SetCollection.Label, "Set Special Collection"u8)) + { + table.NextColumn(); + if (Im.SmallButton("Set##SpecialCollection"u8)) + (_returnCode, _oldCollection) = + new SetCollection(pi).Invoke(_type, _collectionId.GetValueOrDefault(Guid.Empty), _allowCreation, _allowDeletion); + table.NextColumn(); + if (Im.SmallButton("Remove##SpecialCollection"u8)) + (_returnCode, _oldCollection) = new SetCollection(pi).Invoke(_type, null, _allowCreation, _allowDeletion); + } + + using (IpcTester.DrawIntro(SetCollectionForObject.Label, "Set Object Collection"u8)) + { + table.NextColumn(); + if (Im.SmallButton("Set##ObjectCollection"u8)) + (_returnCode, _oldCollection) = new SetCollectionForObject(pi).Invoke(_objectIdx, _collectionId.GetValueOrDefault(Guid.Empty), + _allowCreation, _allowDeletion); + table.NextColumn(); + if (Im.SmallButton("Remove##ObjectCollection"u8)) + (_returnCode, _oldCollection) = new SetCollectionForObject(pi).Invoke(_objectIdx, null, _allowCreation, _allowDeletion); + } + + using (IpcTester.DrawIntro(GetChangedItemsForCollection.Label, "Changed Item List"u8)) + { + DrawChangedItemPopup(); + table.NextColumn(); + if (Im.SmallButton("Get##ChangedItems"u8)) + { + var items = new GetChangedItemsForCollection(pi).Invoke(_collectionId.GetValueOrDefault(Guid.Empty)); + _changedItems = items.Select(kvp => + { + var (type, id) = kvp.Value.ToApiObject(); + return (kvp.Key, type, id); + }).ToArray(); + Im.Popup.Open("Changed Item List"u8); + } } } @@ -199,9 +211,6 @@ public class CollectionsIpcTester(IDalamudPluginInterface pi) : Luna.IUiService Im.Text(collection.Value.Name); table.NextColumn(); - using (Im.Font.PushMono()) - { - ImEx.CopyOnClickSelectable($"{collection.Value.Id}"); - } + LunaStyle.DrawGuid(collection.Value.Id); } } diff --git a/Penumbra/Api/IpcTester/EditingIpcTester.cs b/Penumbra/Api/IpcTester/EditingIpcTester.cs index 4e719693..fff2e302 100644 --- a/Penumbra/Api/IpcTester/EditingIpcTester.cs +++ b/Penumbra/Api/IpcTester/EditingIpcTester.cs @@ -35,20 +35,26 @@ public class EditingIpcTester(IDalamudPluginInterface pi) : Luna.IUiService if (!table) return; - IpcTester.DrawIntro(ConvertTextureFile.Label, "Convert Texture 1"u8); - if (ImEx.Button("Save 1"u8, Vector2.Zero, StringU8.Empty, _task1 is { IsCompleted: false })) - _task1 = new ConvertTextureFile(pi).Invoke(_inputPath, _outputPath, _typeSelector, _mipMaps); - Im.Line.Same(); - Im.Text(_task1 is null ? "Not Initiated"u8 : $"{_task1.Status}"); - if (Im.Item.Hovered() && _task1?.Status is TaskStatus.Faulted) - Im.Tooltip.Set($"{_task1.Exception}"); + using (IpcTester.DrawIntro(ConvertTextureFile.Label, "Convert Texture 1"u8)) + { + table.NextColumn(); + if (ImEx.Button("Save 1"u8, Vector2.Zero, StringU8.Empty, _task1 is { IsCompleted: false })) + _task1 = new ConvertTextureFile(pi).Invoke(_inputPath, _outputPath, _typeSelector, _mipMaps); + Im.Line.Same(); + Im.Text(_task1 is null ? "Not Initiated"u8 : $"{_task1.Status}"); + if (Im.Item.Hovered() && _task1?.Status is TaskStatus.Faulted) + Im.Tooltip.Set($"{_task1.Exception}"); + } - IpcTester.DrawIntro(ConvertTextureFile.Label, "Convert Texture 2"u8); - if (ImEx.Button("Save 2"u8, Vector2.Zero, StringU8.Empty, _task2 is { IsCompleted: false })) - _task2 = new ConvertTextureFile(pi).Invoke(_inputPath2, _outputPath2, _typeSelector, _mipMaps); - Im.Line.Same(); - Im.Text(_task2 is null ? "Not Initiated"u8 : $"{_task2.Status}"); - if (Im.Item.Hovered() && _task2?.Status is TaskStatus.Faulted) - Im.Tooltip.Set($"{_task2.Exception}"); + using (IpcTester.DrawIntro(ConvertTextureFile.Label, "Convert Texture 2"u8)) + { + table.NextColumn(); + if (ImEx.Button("Save 2"u8, Vector2.Zero, StringU8.Empty, _task2 is { IsCompleted: false })) + _task2 = new ConvertTextureFile(pi).Invoke(_inputPath2, _outputPath2, _typeSelector, _mipMaps); + Im.Line.Same(); + Im.Text(_task2 is null ? "Not Initiated"u8 : $"{_task2.Status}"); + if (Im.Item.Hovered() && _task2?.Status is TaskStatus.Faulted) + Im.Tooltip.Set($"{_task2.Exception}"); + } } } diff --git a/Penumbra/Api/IpcTester/GameStateIpcTester.cs b/Penumbra/Api/IpcTester/GameStateIpcTester.cs index 800e7f77..2f0405eb 100644 --- a/Penumbra/Api/IpcTester/GameStateIpcTester.cs +++ b/Penumbra/Api/IpcTester/GameStateIpcTester.cs @@ -1,14 +1,16 @@ using Dalamud.Plugin; using ImSharp; +using Luna; using Penumbra.Api.Enums; using Penumbra.Api.Helpers; using Penumbra.Api.IpcSubscribers; +using Penumbra.GameData.Interop; namespace Penumbra.Api.IpcTester; -public class GameStateIpcTester : Luna.IUiService, IDisposable +public class GameStateIpcTester : IUiService, IDisposable { - private readonly IDalamudPluginInterface _pi; + private readonly IDalamudPluginInterface _pi; public readonly EventSubscriber CharacterBaseCreating; public readonly EventSubscriber CharacterBaseCreated; public readonly EventSubscriber GameObjectResourcePathResolved; @@ -29,8 +31,8 @@ public class GameStateIpcTester : Luna.IUiService, IDisposable public GameStateIpcTester(IDalamudPluginInterface pi) { _pi = pi; - CharacterBaseCreating = IpcSubscribers.CreatingCharacterBase.Subscriber(pi, UpdateLastCreated); - CharacterBaseCreated = IpcSubscribers.CreatedCharacterBase.Subscriber(pi, UpdateLastCreated2); + CharacterBaseCreating = CreatingCharacterBase.Subscriber(pi, UpdateLastCreated); + CharacterBaseCreated = CreatedCharacterBase.Subscriber(pi, UpdateLastCreated2); GameObjectResourcePathResolved = IpcSubscribers.GameObjectResourcePathResolved.Subscriber(pi, UpdateGameObjectResourcePath); CharacterBaseCreating.Disable(); CharacterBaseCreated.Disable(); @@ -68,36 +70,49 @@ public class GameStateIpcTester : Luna.IUiService, IDisposable if (!table) return; - IpcTester.DrawIntro(GetDrawObjectInfo.Label, "Draw Object Info"u8); - if (_currentDrawObject == nint.Zero) + using (IpcTester.DrawIntro(GetDrawObjectInfo.Label, "Draw Object Info"u8)) { - Im.Text("Invalid"u8); - } - else - { - var (ptr, (collectionId, collectionName)) = new GetDrawObjectInfo(_pi).Invoke(_currentDrawObject); - Im.Text(ptr == nint.Zero ? $"No Actor Associated, {collectionName}" : $"{ptr:X}, {collectionName}"); - Im.Line.Same(); - ImEx.MonoText($"{collectionId}"); + table.NextColumn(); + if (_currentDrawObject == nint.Zero) + { + Im.Text("Invalid"u8); + } + else + { + var (ptr, (collectionId, collectionName)) = new GetDrawObjectInfo(_pi).Invoke(_currentDrawObject); + Im.Text(ptr == nint.Zero ? $"No Actor Associated, {collectionName}" : $"{ptr:X}, {collectionName}"); + Im.Line.Same(); + LunaStyle.DrawGuid(collectionId); + } } - IpcTester.DrawIntro(GetCutsceneParentIndex.Label, "Cutscene Parent"u8); - Im.Text($"{new GetCutsceneParentIndex(_pi).Invoke(_currentCutsceneActor)}"); + using (IpcTester.DrawIntro(GetCutsceneParentIndex.Label, "Cutscene Parent"u8)) + { + table.DrawColumn($"{new GetCutsceneParentIndex(_pi).Invoke(_currentCutsceneActor)}"); + } - IpcTester.DrawIntro(SetCutsceneParentIndex.Label, "Cutscene Parent"u8); - if (Im.Button("Set Parent"u8)) - _cutsceneError = new SetCutsceneParentIndex(_pi) - .Invoke(_currentCutsceneActor, _currentCutsceneParent); + using (IpcTester.DrawIntro(SetCutsceneParentIndex.Label, "Cutscene Parent"u8)) + { + table.NextColumn(); + if (Im.SmallButton("Set Parent"u8)) + _cutsceneError = new SetCutsceneParentIndex(_pi) + .Invoke(_currentCutsceneActor, _currentCutsceneParent); + } - IpcTester.DrawIntro(CreatingCharacterBase.Label, "Last Drawobject created"u8); - if (_lastCreatedGameObjectTime < DateTimeOffset.Now) - Im.Text(_lastCreatedDrawObject != nint.Zero - ? $"0x{_lastCreatedDrawObject:X} for <{_lastCreatedGameObjectName}> at {_lastCreatedGameObjectTime}" - : $"NULL for <{_lastCreatedGameObjectName}> at {_lastCreatedGameObjectTime}"); + using (IpcTester.DrawIntro(CreatingCharacterBase.Label, "Last Drawobject created"u8)) + { + if (_lastCreatedGameObjectTime < DateTimeOffset.Now) + table.DrawColumn(_lastCreatedDrawObject != nint.Zero + ? $"0x{_lastCreatedDrawObject:X} for <{_lastCreatedGameObjectName}> at {_lastCreatedGameObjectTime}" + : $"NULL for <{_lastCreatedGameObjectName}> at {_lastCreatedGameObjectTime}"); + } - IpcTester.DrawIntro(IpcSubscribers.GameObjectResourcePathResolved.Label, "Last GamePath resolved"u8); - if (_lastResolvedGamePathTime < DateTimeOffset.Now) - Im.Text($"{_lastResolvedGamePath} -> {_lastResolvedFullPath} for <{_lastResolvedObject}> at {_lastResolvedGamePathTime}"); + using (IpcTester.DrawIntro(IpcSubscribers.GameObjectResourcePathResolved.Label, "Last GamePath resolved"u8)) + { + if (_lastResolvedGamePathTime < DateTimeOffset.Now) + table.DrawColumn( + $"{_lastResolvedGamePath} -> {_lastResolvedFullPath} for <{_lastResolvedObject}> at {_lastResolvedGamePathTime}"); + } } private void UpdateLastCreated(nint gameObject, Guid _, nint _2, nint _3, nint _4) @@ -122,9 +137,6 @@ public class GameStateIpcTester : Luna.IUiService, IDisposable _lastResolvedGamePathTime = DateTimeOffset.Now; } - private static unsafe StringU8 GetObjectName(nint gameObject) - { - var obj = (FFXIVClientStructs.FFXIV.Client.Game.Object.GameObject*)gameObject; - return new StringU8(obj is not null && obj->Name[0] != 0 ? obj->Name : "Unknown"u8); - } + private static StringU8 GetObjectName(nint gameObject) + => new(((Actor)gameObject).StoredName()); } diff --git a/Penumbra/Api/IpcTester/IpcTester.cs b/Penumbra/Api/IpcTester/IpcTester.cs index 3348750e..79e935c0 100644 --- a/Penumbra/Api/IpcTester/IpcTester.cs +++ b/Penumbra/Api/IpcTester/IpcTester.cs @@ -52,11 +52,13 @@ public class IpcTester( } } - internal static void DrawIntro(Utf8StringHandler label, Utf8StringHandler info) + internal static Im.IdDisposable DrawIntro(Utf8StringHandler label, Utf8StringHandler info) { + var id = Im.Id.Push(ref info); Im.Table.NextRow(); Im.Table.DrawColumn(ref label); Im.Table.DrawColumn(ref info); + return id; } private void Subscribe() diff --git a/Penumbra/Api/IpcTester/MetaIpcTester.cs b/Penumbra/Api/IpcTester/MetaIpcTester.cs index 57fca5fa..84402d94 100644 --- a/Penumbra/Api/IpcTester/MetaIpcTester.cs +++ b/Penumbra/Api/IpcTester/MetaIpcTester.cs @@ -28,21 +28,29 @@ public class MetaIpcTester(IDalamudPluginInterface pi) : Luna.IUiService if (!table) return; - IpcTester.DrawIntro(GetPlayerMetaManipulations.Label, "Player Meta Manipulations"u8); - if (Im.Button("Copy to Clipboard##Player"u8)) + using (IpcTester.DrawIntro(GetPlayerMetaManipulations.Label, "Player Meta Manipulations"u8)) { - var base64 = new GetPlayerMetaManipulations(pi).Invoke(); - Im.Clipboard.Set(base64); + table.NextColumn(); + if (Im.SmallButton("Copy to Clipboard##Player"u8)) + { + var base64 = new GetPlayerMetaManipulations(pi).Invoke(); + Im.Clipboard.Set(base64); + } } - IpcTester.DrawIntro(GetMetaManipulations.Label, "Game Object Manipulations"u8); - if (Im.Button("Copy to Clipboard##GameObject"u8)) + using (IpcTester.DrawIntro(GetMetaManipulations.Label, "Game Object Manipulations"u8)) { - var base64 = new GetMetaManipulations(pi).Invoke(_gameObjectIndex); - Im.Clipboard.Set(base64); + table.NextColumn(); + if (Im.SmallButton("Copy to Clipboard##GameObject"u8)) + { + var base64 = new GetMetaManipulations(pi).Invoke(_gameObjectIndex); + Im.Clipboard.Set(base64); + } } - IpcTester.DrawIntro(string.Empty, "Parsed Data"u8); - Im.Text($"Version: {_parsedVersion}, Count: {_metaDict.Count}"); + using (IpcTester.DrawIntro(StringU8.Empty, "Parsed Data"u8)) + { + table.DrawColumn($"Version: {_parsedVersion}, Count: {_metaDict.Count}"); + } } } diff --git a/Penumbra/Api/IpcTester/ModSettingsIpcTester.cs b/Penumbra/Api/IpcTester/ModSettingsIpcTester.cs index 2d9a9cb2..d2f7aba9 100644 --- a/Penumbra/Api/IpcTester/ModSettingsIpcTester.cs +++ b/Penumbra/Api/IpcTester/ModSettingsIpcTester.cs @@ -41,9 +41,7 @@ public class ModSettingsIpcTester : Luna.IUiService, IDisposable } public void Dispose() - { - SettingChanged.Dispose(); - } + => SettingChanged.Dispose(); public void Draw() { @@ -53,7 +51,7 @@ public class ModSettingsIpcTester : Luna.IUiService, IDisposable Im.Input.Text("##settingsDir"u8, ref _settingsModDirectory, "Mod Directory Name..."u8); Im.Input.Text("##settingsName"u8, ref _settingsModName, "Mod Name..."u8); - ImEx.GuidInput("##settingsCollection"u8, ref _settingsCollection, "Collection..."u8); + ImEx.GuidInput("Collection ID##settingsCollection"u8, ref _settingsCollection); Im.Checkbox("Ignore Inheritance"u8, ref _settingsIgnoreInheritance); Im.Checkbox("Ignore Temporary"u8, ref _settingsIgnoreTemporary); Im.Input.Scalar("Key"u8, ref _settingsKey); @@ -63,148 +61,178 @@ public class ModSettingsIpcTester : Luna.IUiService, IDisposable if (!table) return; - IpcTester.DrawIntro("Last Error"u8, $"{_lastSettingsError}"); + IpcTester.DrawIntro("Last Error"u8, $"{_lastSettingsError}").Dispose(); - IpcTester.DrawIntro(ModSettingChanged.Label, "Last Mod Setting Changed"u8); - Im.Text(_lastSettingChangeMod.Length > 0 - ? $"{_lastSettingChangeType} of {_lastSettingChangeMod} in {_lastSettingChangeCollection}{(_lastSettingChangeInherited ? " (Inherited)" : string.Empty)} at {_lastSettingChange}" - : "None"u8); - - IpcTester.DrawIntro(GetAvailableModSettings.Label, "Get Available Settings"u8); - if (Im.Button("Get##Available"u8)) + using (IpcTester.DrawIntro(ModSettingChanged.Label, "Last Mod Setting Changed"u8)) { - _availableSettings = new GetAvailableModSettings(_pi).Invoke(_settingsModDirectory, _settingsModName); - _lastSettingsError = _availableSettings == null ? PenumbraApiEc.ModMissing : PenumbraApiEc.Success; + table.DrawColumn(_lastSettingChangeMod.Length > 0 + ? $"{_lastSettingChangeType} of {_lastSettingChangeMod} in {_lastSettingChangeCollection}{(_lastSettingChangeInherited ? " (Inherited)" : string.Empty)} at {_lastSettingChange}" + : "None"u8); } - IpcTester.DrawIntro(GetCurrentModSettings.Label, "Get Current Settings"u8); - if (Im.Button("Get##Current"u8)) + using (IpcTester.DrawIntro(GetAvailableModSettings.Label, "Get Available Settings"u8)) { - var ret = new GetCurrentModSettings(_pi) - .Invoke(collection, _settingsModDirectory, _settingsModName, _settingsIgnoreInheritance); - _lastSettingsError = ret.Item1; - if (ret.Item1 is PenumbraApiEc.Success) + table.NextColumn(); + if (Im.SmallButton("Get##Available"u8)) { - _settingsEnabled = ret.Item2?.Item1 ?? false; - _settingsInherit = ret.Item2?.Item4 ?? true; - _settingsTemporary = false; - _settingsPriority = ret.Item2?.Item2 ?? 0; - _currentSettings = ret.Item2?.Item3; - } - else - { - _currentSettings = null; + _availableSettings = new GetAvailableModSettings(_pi).Invoke(_settingsModDirectory, _settingsModName); + _lastSettingsError = _availableSettings == null ? PenumbraApiEc.ModMissing : PenumbraApiEc.Success; } } - IpcTester.DrawIntro(GetCurrentModSettingsWithTemp.Label, "Get Current Settings With Temp"u8); - if (Im.Button("Get##CurrentTemp"u8)) + using (IpcTester.DrawIntro(GetCurrentModSettings.Label, "Get Current Settings"u8)) { - var ret = new GetCurrentModSettingsWithTemp(_pi) - .Invoke(collection, _settingsModDirectory, _settingsModName, _settingsIgnoreInheritance, _settingsIgnoreTemporary, - _settingsKey); - _lastSettingsError = ret.Item1; - if (ret.Item1 is PenumbraApiEc.Success) + table.NextColumn(); + if (Im.SmallButton("Get##Current"u8)) { - _settingsEnabled = ret.Item2?.Item1 ?? false; - _settingsInherit = ret.Item2?.Item4 ?? true; - _settingsTemporary = ret.Item2?.Item5 ?? false; - _settingsPriority = ret.Item2?.Item2 ?? 0; - _currentSettings = ret.Item2?.Item3; - } - else - { - _currentSettings = null; + var ret = new GetCurrentModSettings(_pi) + .Invoke(collection, _settingsModDirectory, _settingsModName, _settingsIgnoreInheritance); + _lastSettingsError = ret.Item1; + if (ret.Item1 is PenumbraApiEc.Success) + { + _settingsEnabled = ret.Item2?.Item1 ?? false; + _settingsInherit = ret.Item2?.Item4 ?? true; + _settingsTemporary = false; + _settingsPriority = ret.Item2?.Item2 ?? 0; + _currentSettings = ret.Item2?.Item3; + } + else + { + _currentSettings = null; + } } } - IpcTester.DrawIntro(GetAllModSettings.Label, "Get All Mod Settings"u8); - if (Im.Button("Get##All"u8)) + using (IpcTester.DrawIntro(GetCurrentModSettingsWithTemp.Label, "Get Current Settings With Temp"u8)) { - var ret = new GetAllModSettings(_pi).Invoke(collection, _settingsIgnoreInheritance, _settingsIgnoreTemporary, _settingsKey); - _lastSettingsError = ret.Item1; - _allSettings = ret.Item2; + table.NextColumn(); + if (Im.SmallButton("Get##CurrentTemp"u8)) + { + var ret = new GetCurrentModSettingsWithTemp(_pi) + .Invoke(collection, _settingsModDirectory, _settingsModName, _settingsIgnoreInheritance, _settingsIgnoreTemporary, + _settingsKey); + _lastSettingsError = ret.Item1; + if (ret.Item1 is PenumbraApiEc.Success) + { + _settingsEnabled = ret.Item2?.Item1 ?? false; + _settingsInherit = ret.Item2?.Item4 ?? true; + _settingsTemporary = ret.Item2?.Item5 ?? false; + _settingsPriority = ret.Item2?.Item2 ?? 0; + _currentSettings = ret.Item2?.Item3; + } + else + { + _currentSettings = null; + } + } } - if (_allSettings is not null) + using (IpcTester.DrawIntro(GetAllModSettings.Label, "Get All Mod Settings"u8)) { + table.NextColumn(); + if (Im.SmallButton("Get##All"u8)) + { + var ret = new GetAllModSettings(_pi).Invoke(collection, _settingsIgnoreInheritance, _settingsIgnoreTemporary, _settingsKey); + _lastSettingsError = ret.Item1; + _allSettings = ret.Item2; + } + + if (_allSettings is not null) + { + Im.Line.Same(); + Im.Text($"{_allSettings.Count} Mods"); + } + } + + using (IpcTester.DrawIntro(TryInheritMod.Label, "Inherit Mod"u8)) + { + table.NextColumn(); + Im.Checkbox("##inherit"u8, ref _settingsInherit); Im.Line.Same(); - Im.Text($"{_allSettings.Count} Mods"); + if (Im.SmallButton("Set##Inherit"u8)) + _lastSettingsError = new TryInheritMod(_pi) + .Invoke(collection, _settingsModDirectory, _settingsInherit, _settingsModName); } - IpcTester.DrawIntro(TryInheritMod.Label, "Inherit Mod"u8); - Im.Checkbox("##inherit"u8, ref _settingsInherit); - Im.Line.Same(); - if (Im.Button("Set##Inherit"u8)) - _lastSettingsError = new TryInheritMod(_pi) - .Invoke(collection, _settingsModDirectory, _settingsInherit, _settingsModName); - - IpcTester.DrawIntro(TrySetMod.Label, "Set Enabled"u8); - Im.Checkbox("##enabled"u8, ref _settingsEnabled); - Im.Line.Same(); - if (Im.Button("Set##Enabled"u8)) - _lastSettingsError = new TrySetMod(_pi) - .Invoke(collection, _settingsModDirectory, _settingsEnabled, _settingsModName); - - IpcTester.DrawIntro(TrySetModPriority.Label, "Set Priority"u8); - Im.Item.SetNextWidthScaled(200); - Im.Drag("##Priority"u8, ref _settingsPriority); - Im.Line.Same(); - if (Im.Button("Set##Priority"u8)) - _lastSettingsError = new TrySetModPriority(_pi) - .Invoke(collection, _settingsModDirectory, _settingsPriority, _settingsModName); - - IpcTester.DrawIntro(CopyModSettings.Label, "Copy Mod Settings"u8); - if (Im.Button("Copy Settings"u8)) - _lastSettingsError = new CopyModSettings(_pi) - .Invoke(_settingsCollection, _settingsModDirectory, _settingsModName); - - Im.Tooltip.OnHover("Copy settings from Mod Directory Name to Mod Name (as directory) in collection."u8); - - IpcTester.DrawIntro(TrySetModSetting.Label, "Set Setting(s)"u8); - if (_availableSettings == null) - return; - - foreach (var (group, (list, type)) in _availableSettings) + using (IpcTester.DrawIntro(TrySetMod.Label, "Set Enabled"u8)) { - using var id = Im.Id.Push(group); - var preview = list.Length > 0 ? list[0] : string.Empty; - if (_currentSettings is not null && _currentSettings.TryGetValue(group, out var current) && current.Count > 0) - { - preview = current[0]; - } - else - { - current = []; - _currentSettings?[group] = current; - } + table.NextColumn(); + Im.Checkbox("##enabled"u8, ref _settingsEnabled); + Im.Line.Same(); + if (Im.SmallButton("Set##Enabled"u8)) + _lastSettingsError = new TrySetMod(_pi) + .Invoke(collection, _settingsModDirectory, _settingsEnabled, _settingsModName); + } + using (IpcTester.DrawIntro(TrySetModPriority.Label, "Set Priority"u8)) + { + table.NextColumn(); Im.Item.SetNextWidthScaled(200); - using (var c = Im.Combo.Begin("##group"u8, preview)) + Im.Drag("##Priority"u8, ref _settingsPriority); + Im.Line.Same(); + if (Im.SmallButton("Set##Priority"u8)) + _lastSettingsError = new TrySetModPriority(_pi) + .Invoke(collection, _settingsModDirectory, _settingsPriority, _settingsModName); + } + + using (IpcTester.DrawIntro(CopyModSettings.Label, "Copy Mod Settings"u8)) + { + table.NextColumn(); + if (Im.SmallButton("Copy Settings"u8)) + _lastSettingsError = new CopyModSettings(_pi) + .Invoke(_settingsCollection, _settingsModDirectory, _settingsModName); + Im.Tooltip.OnHover("Copy settings from Mod Directory Name to Mod Name (as directory) in collection."u8); + } + + + using (IpcTester.DrawIntro(TrySetModSetting.Label, "Set Setting(s)"u8)) + { + if (_availableSettings == null) + return; + + table.NextColumn(); + foreach (var (group, (list, type)) in _availableSettings) { - if (c) - foreach (var s in list) - { - var contained = current.Contains(s); - if (Im.Checkbox(s, ref contained)) + using var id = Im.Id.Push(group); + var preview = list.Length > 0 ? list[0] : string.Empty; + if (_currentSettings is not null && _currentSettings.TryGetValue(group, out var current) && current.Count > 0) + { + preview = current[0]; + } + else + { + current = []; + _currentSettings?[group] = current; + } + + Im.Item.SetNextWidthScaled(200); + using (var c = Im.Combo.Begin("##group"u8, preview)) + { + if (c) + foreach (var s in list) { - if (contained) - current.Add(s); - else - current.Remove(s); + var contained = current.Contains(s); + if (Im.Checkbox(s, ref contained)) + { + if (contained) + current.Add(s); + else + current.Remove(s); + } } - } + } + + Im.Line.Same(); + if (Im.SmallButton("Set##setting"u8)) + _lastSettingsError = type is GroupType.Single + ? new TrySetModSetting(_pi).Invoke(collection, _settingsModDirectory, group, + current.Count > 0 ? current[0] : string.Empty, + _settingsModName) + : new TrySetModSettings(_pi).Invoke(collection, _settingsModDirectory, group, current.ToArray(), _settingsModName); + + Im.Line.Same(); + Im.Text(group); } - - Im.Line.Same(); - if (Im.Button("Set##setting"u8)) - _lastSettingsError = type is GroupType.Single - ? new TrySetModSetting(_pi).Invoke(collection, _settingsModDirectory, group, current.Count > 0 ? current[0] : string.Empty, - _settingsModName) - : new TrySetModSettings(_pi).Invoke(collection, _settingsModDirectory, group, current.ToArray(), _settingsModName); - - Im.Line.Same(); - Im.Text(group); } } diff --git a/Penumbra/Api/IpcTester/ModsIpcTester.cs b/Penumbra/Api/IpcTester/ModsIpcTester.cs index 3765d52a..9cc32d26 100644 --- a/Penumbra/Api/IpcTester/ModsIpcTester.cs +++ b/Penumbra/Api/IpcTester/ModsIpcTester.cs @@ -75,79 +75,106 @@ public class ModsIpcTester : Luna.IUiService, IDisposable return; Im.Input.Text("##install"u8, ref _newInstallPath, "Install File Path..."u8); - Im.Input.Text("##modDir"u8, ref _modDirectory, "Mod Directory Name..."u8); - Im.Input.Text("##modName"u8, ref _modName, "Mod Name..."u8); - Im.Input.Text("##path"u8, ref _pathInput, "New Path..."u8); + Im.Input.Text("##modDir"u8, ref _modDirectory, "Mod Directory Name..."u8); + Im.Input.Text("##modName"u8, ref _modName, "Mod Name..."u8); + Im.Input.Text("##path"u8, ref _pathInput, "New Path..."u8); using var table = Im.Table.Begin(StringU8.Empty, 3, TableFlags.SizingFixedFit); if (!table) return; - IpcTester.DrawIntro(GetModList.Label, "Mods"u8); - DrawModsPopup(); - if (Im.Button("Get##Mods"u8)) + using (IpcTester.DrawIntro(GetModList.Label, "Mods"u8)) { - _mods = new GetModList(_pi).Invoke(); - Im.Popup.Open("Mods"u8); + DrawModsPopup(); + table.NextColumn(); + if (Im.SmallButton("Get##Mods"u8)) + { + _mods = new GetModList(_pi).Invoke(); + Im.Popup.Open("Mods"u8); + } } - IpcTester.DrawIntro(ReloadMod.Label, "Reload Mod"u8); - if (Im.Button("Reload"u8)) - _lastReloadEc = new ReloadMod(_pi).Invoke(_modDirectory, _modName); - - Im.Line.Same(); - Im.Text($"{_lastReloadEc}"); - - IpcTester.DrawIntro(InstallMod.Label, "Install Mod"u8); - if (Im.Button("Install"u8)) - _lastInstallEc = new InstallMod(_pi).Invoke(_newInstallPath); - - Im.Line.Same(); - Im.Text($"{_lastInstallEc}"); - - IpcTester.DrawIntro(AddMod.Label, "Add Mod"u8); - if (Im.Button("Add"u8)) - _lastAddEc = new AddMod(_pi).Invoke(_modDirectory); - - Im.Line.Same(); - Im.Text($"{_lastAddEc}"); - - IpcTester.DrawIntro(DeleteMod.Label, "Delete Mod"u8); - if (Im.Button("Delete"u8)) - _lastDeleteEc = new DeleteMod(_pi).Invoke(_modDirectory, _modName); - - Im.Line.Same(); - Im.Text(_lastDeleteEc.ToString()); - - IpcTester.DrawIntro(GetChangedItems.Label, "Get Changed Items"u8); - DrawChangedItemsPopup(); - if (Im.Button("Get##ChangedItems"u8)) + using (IpcTester.DrawIntro(ReloadMod.Label, "Reload Mod"u8)) { - _changedItems = new GetChangedItems(_pi).Invoke(_modDirectory, _modName); - Im.Popup.Open("ChangedItems"u8); + table.NextColumn(); + if (Im.SmallButton("Reload"u8)) + _lastReloadEc = new ReloadMod(_pi).Invoke(_modDirectory, _modName); + + Im.Line.Same(); + Im.Text($"{_lastReloadEc}"); } - IpcTester.DrawIntro(GetModPath.Label, "Current Path"u8); - var (ec, path, def, nameDef) = new GetModPath(_pi).Invoke(_modDirectory, _modName); - Im.Text($"{path} ({(def ? "Custom" : "Default")} Path, {(nameDef ? "Custom" : "Default")} Name) [{ec}]"); - IpcTester.DrawIntro(SetModPath.Label, "Set Path"u8); - if (Im.Button("Set"u8)) - _lastSetPathEc = new SetModPath(_pi).Invoke(_modDirectory, _pathInput, _modName); + using (IpcTester.DrawIntro(InstallMod.Label, "Install Mod"u8)) + { + table.NextColumn(); + if (Im.SmallButton("Install"u8)) + _lastInstallEc = new InstallMod(_pi).Invoke(_newInstallPath); + Im.Line.Same(); + Im.Text($"{_lastInstallEc}"); + } - Im.Line.Same(); - Im.Text($"{_lastSetPathEc}"); + using (IpcTester.DrawIntro(AddMod.Label, "Add Mod"u8)) + { + table.NextColumn(); + if (Im.SmallButton("Add"u8)) + _lastAddEc = new AddMod(_pi).Invoke(_modDirectory); + Im.Line.Same(); + Im.Text($"{_lastAddEc}"); + } - IpcTester.DrawIntro(ModDeleted.Label, "Last Mod Deleted"u8); - if (_lastDeletedModTime > DateTimeOffset.UnixEpoch) - Im.Text($"{_lastDeletedMod} at {_lastDeletedModTime}"); + using (IpcTester.DrawIntro(DeleteMod.Label, "Delete Mod"u8)) + { + table.NextColumn(); + if (Im.SmallButton("Delete"u8)) + _lastDeleteEc = new DeleteMod(_pi).Invoke(_modDirectory, _modName); + Im.Line.Same(); + Im.Text(_lastDeleteEc.ToString()); + } - IpcTester.DrawIntro(ModAdded.Label, "Last Mod Added"u8); - if (_lastAddedModTime > DateTimeOffset.UnixEpoch) - Im.Text($"{_lastAddedMod} at {_lastAddedModTime}"); + using (IpcTester.DrawIntro(GetChangedItems.Label, "Get Changed Items"u8)) + { + DrawChangedItemsPopup(); + table.NextColumn(); + if (Im.SmallButton("Get##ChangedItems"u8)) + { + _changedItems = new GetChangedItems(_pi).Invoke(_modDirectory, _modName); + Im.Popup.Open("ChangedItems"u8); + } + } - IpcTester.DrawIntro(ModMoved.Label, "Last Mod Moved"); - if (_lastMovedModTime > DateTimeOffset.UnixEpoch) - Im.Text($"{_lastMovedModFrom} -> {_lastMovedModTo} at {_lastMovedModTime}"); + using (IpcTester.DrawIntro(GetModPath.Label, "Current Path"u8)) + { + var (ec, path, def, nameDef) = new GetModPath(_pi).Invoke(_modDirectory, _modName); + table.DrawColumn($"{path} ({(def ? "Custom" : "Default")} Path, {(nameDef ? "Custom" : "Default")} Name) [{ec}]"); + } + + using (IpcTester.DrawIntro(SetModPath.Label, "Set Path"u8)) + { + table.NextColumn(); + if (Im.SmallButton("Set"u8)) + _lastSetPathEc = new SetModPath(_pi).Invoke(_modDirectory, _pathInput, _modName); + + Im.Line.Same(); + Im.Text($"{_lastSetPathEc}"); + } + + using (IpcTester.DrawIntro(ModDeleted.Label, "Last Mod Deleted"u8)) + { + if (_lastDeletedModTime > DateTimeOffset.UnixEpoch) + table.DrawColumn($"{_lastDeletedMod} at {_lastDeletedModTime}"); + } + + using (IpcTester.DrawIntro(ModAdded.Label, "Last Mod Added"u8)) + { + if (_lastAddedModTime > DateTimeOffset.UnixEpoch) + table.DrawColumn($"{_lastAddedMod} at {_lastAddedModTime}"); + } + + using (IpcTester.DrawIntro(ModMoved.Label, "Last Mod Moved")) + { + if (_lastMovedModTime > DateTimeOffset.UnixEpoch) + table.DrawColumn($"{_lastMovedModFrom} -> {_lastMovedModTo} at {_lastMovedModTime}"); + } } private void DrawModsPopup() diff --git a/Penumbra/Api/IpcTester/PluginStateIpcTester.cs b/Penumbra/Api/IpcTester/PluginStateIpcTester.cs index 86cb14b5..0c111a77 100644 --- a/Penumbra/Api/IpcTester/PluginStateIpcTester.cs +++ b/Penumbra/Api/IpcTester/PluginStateIpcTester.cs @@ -1,3 +1,4 @@ +using Dalamud.Interface.Utility.Table; using Dalamud.Plugin; using ImSharp; using Luna; @@ -63,48 +64,65 @@ public class PluginStateIpcTester : IUiService, IDisposable DrawList(IpcSubscribers.Initialized.Label, "Last Initialized"u8, _initializedList); DrawList(IpcSubscribers.Disposed.Label, "Last Disposed"u8, _disposedList); - IpcTester.DrawIntro(ApiVersion.Label, "Current Version"u8); - var (breaking, features) = new ApiVersion(_pi).Invoke(); - Im.Text($"{breaking}.{features:D4}"); - - IpcTester.DrawIntro(GetEnabledState.Label, "Current State"u8); - Im.Text($"{new GetEnabledState(_pi).Invoke()}"); - - IpcTester.DrawIntro(IpcSubscribers.EnabledChange.Label, "Last Change"u8); - Im.Text(_lastEnabledValue is { } v ? $"{_lastEnabledChange} (to {v})" : "Never"u8); - - IpcTester.DrawIntro(SupportedFeatures.Label, "Supported Features"u8); - Im.Text(StringU8.Join(", "u8, new SupportedFeatures(_pi).Invoke())); - - IpcTester.DrawIntro(CheckSupportedFeatures.Label, "Missing Features"u8); - Im.Text(StringU8.Join(", "u8, new CheckSupportedFeatures(_pi).Invoke(_requiredFeatures))); - - DrawConfigPopup(); - IpcTester.DrawIntro(GetConfiguration.Label, "Configuration"u8); - if (Im.Button("Get"u8)) + using (IpcTester.DrawIntro(ApiVersion.Label, "Current Version"u8)) { - _currentConfiguration = new GetConfiguration(_pi).Invoke(); - Im.Popup.Open("Config Popup"u8); + var (breaking, features) = new ApiVersion(_pi).Invoke(); + table.DrawColumn($"{breaking}.{features:D4}"); } - IpcTester.DrawIntro(GetModDirectory.Label, "Current Mod Directory"u8); - Im.Text(new GetModDirectory(_pi).Invoke()); - - IpcTester.DrawIntro(IpcSubscribers.ModDirectoryChanged.Label, "Last Mod Directory Change"u8); - Im.Text(_lastModDirectoryTime > DateTimeOffset.MinValue - ? $"{_lastModDirectory} ({(_lastModDirectoryValid ? "Valid" : "Invalid")}) at {_lastModDirectoryTime}" - : "None"u8); - - void DrawList(string label, ReadOnlySpan text, List list) + using (IpcTester.DrawIntro(GetEnabledState.Label, "Current State"u8)) { - IpcTester.DrawIntro(label, text); + table.DrawColumn($"{new GetEnabledState(_pi).Invoke()}"); + } + + using (IpcTester.DrawIntro(IpcSubscribers.EnabledChange.Label, "Last Change"u8)) + { + table.DrawColumn(_lastEnabledValue is { } v ? $"{_lastEnabledChange} (to {v})" : "Never"u8); + } + + using (IpcTester.DrawIntro(SupportedFeatures.Label, "Supported Features"u8)) + { + table.DrawColumn(StringU8.Join(", "u8, new SupportedFeatures(_pi).Invoke())); + } + + using (IpcTester.DrawIntro(CheckSupportedFeatures.Label, "Missing Features"u8)) + table.DrawColumn(StringU8.Join(", "u8, new CheckSupportedFeatures(_pi).Invoke(_requiredFeatures))); + + using (IpcTester.DrawIntro(GetConfiguration.Label, "Configuration"u8)) + { + DrawConfigPopup(); + table.NextColumn(); + if (Im.SmallButton("Get"u8)) + { + _currentConfiguration = new GetConfiguration(_pi).Invoke(); + Im.Popup.Open("Config Popup"u8); + } + } + + using (IpcTester.DrawIntro(GetModDirectory.Label, "Current Mod Directory"u8)) + { + table.DrawColumn(new GetModDirectory(_pi).Invoke()); + } + + using (IpcTester.DrawIntro(IpcSubscribers.ModDirectoryChanged.Label, "Last Mod Directory Change"u8)) + { + table.DrawColumn(_lastModDirectoryTime > DateTimeOffset.MinValue + ? $"{_lastModDirectory} ({(_lastModDirectoryValid ? "Valid" : "Invalid")}) at {_lastModDirectoryTime}" + : "None"u8); + } + + return; + + static void DrawList(string label, ReadOnlySpan text, List list) + { + using var _ = IpcTester.DrawIntro(label, text); if (list.Count is 0) { - Im.Text("Never"u8); + Im.Table.DrawColumn("Never"u8); } else { - Im.Text(list[^1].LocalDateTime.ToString(CultureInfo.CurrentCulture)); + Im.Table.DrawColumn(list[^1].LocalDateTime.ToString(CultureInfo.CurrentCulture)); if (list.Count > 1 && Im.Item.Hovered()) Im.Tooltip.Set( StringU8.Join((byte)'\n', list.SkipLast(1).Select(t => t.LocalDateTime.ToString(CultureInfo.CurrentCulture)))); diff --git a/Penumbra/Api/IpcTester/RedrawingIpcTester.cs b/Penumbra/Api/IpcTester/RedrawingIpcTester.cs index e3eb528b..6834d03d 100644 --- a/Penumbra/Api/IpcTester/RedrawingIpcTester.cs +++ b/Penumbra/Api/IpcTester/RedrawingIpcTester.cs @@ -38,21 +38,29 @@ public class RedrawingIpcTester : Luna.IUiService, IDisposable if (!table) return; - IpcTester.DrawIntro(RedrawObject.Label, "Redraw by Index"u8); - var tmp = _redrawIndex; - Im.Item.SetNextWidthScaled(100); - if (Im.Drag("##redrawIndex"u8, ref tmp, 0, _objects.TotalCount, 0.1f)) - _redrawIndex = Math.Clamp(tmp, 0, _objects.TotalCount); - Im.Line.Same(); - if (Im.Button("Redraw##Index"u8)) - new RedrawObject(_pi).Invoke(_redrawIndex); + using (IpcTester.DrawIntro(RedrawObject.Label, "Redraw by Index"u8)) + { + var tmp = _redrawIndex; + table.NextColumn(); + Im.Item.SetNextWidthScaled(100); + if (Im.Drag("##redrawIndex"u8, ref tmp, 0, _objects.TotalCount, 0.1f)) + _redrawIndex = Math.Clamp(tmp, 0, _objects.TotalCount); + Im.Line.Same(); + if (Im.Button("Redraw##Index"u8)) + new RedrawObject(_pi).Invoke(_redrawIndex); + } - IpcTester.DrawIntro(RedrawAll.Label, "Redraw All"u8); - if (Im.Button("Redraw##All"u8)) - new RedrawAll(_pi).Invoke(); + using (IpcTester.DrawIntro(RedrawAll.Label, "Redraw All"u8)) + { + table.NextColumn(); + if (Im.SmallButton("Redraw##All"u8)) + new RedrawAll(_pi).Invoke(); + } - IpcTester.DrawIntro(GameObjectRedrawn.Label, "Last Redrawn Object:"u8); - Im.Text(_lastRedrawnString); + using (IpcTester.DrawIntro(GameObjectRedrawn.Label, "Last Redrawn Object:"u8)) + { + table.DrawColumn(_lastRedrawnString); + } } private void SetLastRedrawn(nint address, int index) diff --git a/Penumbra/Api/IpcTester/ResolveIpcTester.cs b/Penumbra/Api/IpcTester/ResolveIpcTester.cs index 734e02bd..0f95dc38 100644 --- a/Penumbra/Api/IpcTester/ResolveIpcTester.cs +++ b/Penumbra/Api/IpcTester/ResolveIpcTester.cs @@ -24,64 +24,82 @@ public class ResolveIpcTester(IDalamudPluginInterface pi) : Luna.IUiService if (!table) return; - IpcTester.DrawIntro(ResolveDefaultPath.Label, "Default Collection Resolve"u8); - if (_currentResolvePath.Length is not 0) - Im.Text(new ResolveDefaultPath(pi).Invoke(_currentResolvePath)); - - IpcTester.DrawIntro(ResolveInterfacePath.Label, "Interface Collection Resolve"u8); - if (_currentResolvePath.Length is not 0) - Im.Text(new ResolveInterfacePath(pi).Invoke(_currentResolvePath)); - - IpcTester.DrawIntro(ResolvePlayerPath.Label, "Player Collection Resolve"u8); - if (_currentResolvePath.Length is not 0) - Im.Text(new ResolvePlayerPath(pi).Invoke(_currentResolvePath)); - - IpcTester.DrawIntro(ResolveGameObjectPath.Label, "Game Object Collection Resolve"u8); - if (_currentResolvePath.Length is not 0) - Im.Text(new ResolveGameObjectPath(pi).Invoke(_currentResolvePath, _currentReverseIdx)); - - IpcTester.DrawIntro(ReverseResolvePlayerPath.Label, "Reversed Game Paths (Player)"u8); - if (_currentReversePath.Length is not 0) + using (IpcTester.DrawIntro(ResolveDefaultPath.Label, "Default Collection Resolve"u8)) { - var list = new ReverseResolvePlayerPath(pi).Invoke(_currentReversePath); - if (list.Length > 0) + if (_currentResolvePath.Length is not 0) + table.DrawColumn(new ResolveDefaultPath(pi).Invoke(_currentResolvePath)); + } + + using (IpcTester.DrawIntro(ResolveInterfacePath.Label, "Interface Collection Resolve"u8)) + { + if (_currentResolvePath.Length is not 0) + table.DrawColumn(new ResolveInterfacePath(pi).Invoke(_currentResolvePath)); + } + + using (IpcTester.DrawIntro(ResolvePlayerPath.Label, "Player Collection Resolve"u8)) + { + if (_currentResolvePath.Length is not 0) + table.DrawColumn(new ResolvePlayerPath(pi).Invoke(_currentResolvePath)); + } + + using (IpcTester.DrawIntro(ResolveGameObjectPath.Label, "Game Object Collection Resolve"u8)) + { + if (_currentResolvePath.Length is not 0) + table.DrawColumn(new ResolveGameObjectPath(pi).Invoke(_currentResolvePath, _currentReverseIdx)); + } + + using (IpcTester.DrawIntro(ReverseResolvePlayerPath.Label, "Reversed Game Paths (Player)"u8)) + { + if (_currentReversePath.Length is not 0) { - Im.Text(list[0]); - if (list.Length > 1 && Im.Item.Hovered()) - Im.Tooltip.Set(StringU8.Join((byte)'\n', list.Skip(1))); + var list = new ReverseResolvePlayerPath(pi).Invoke(_currentReversePath); + if (list.Length > 0) + { + table.DrawColumn(list[0]); + if (list.Length > 1 && Im.Item.Hovered()) + Im.Tooltip.Set(StringU8.Join((byte)'\n', list.Skip(1))); + } } } - IpcTester.DrawIntro(ReverseResolveGameObjectPath.Label, "Reversed Game Paths (Game Object)"u8); - if (_currentReversePath.Length is not 0) + using (IpcTester.DrawIntro(ReverseResolveGameObjectPath.Label, "Reversed Game Paths (Game Object)"u8)) { - var list = new ReverseResolveGameObjectPath(pi).Invoke(_currentReversePath, _currentReverseIdx); - if (list.Length > 0) + if (_currentReversePath.Length is not 0) { - Im.Text(list[0]); - if (list.Length > 1 && Im.Item.Hovered()) - Im.Tooltip.Set(StringU8.Join((byte)'\n', list.Skip(1))); + var list = new ReverseResolveGameObjectPath(pi).Invoke(_currentReversePath, _currentReverseIdx); + if (list.Length > 0) + { + table.DrawColumn(list[0]); + if (list.Length > 1 && Im.Item.Hovered()) + Im.Tooltip.Set(StringU8.Join((byte)'\n', list.Skip(1))); + } } } string[] forwardArray = _currentResolvePath.Length > 0 ? [_currentResolvePath] : []; string[] reverseArray = _currentReversePath.Length > 0 ? [_currentReversePath] : []; - IpcTester.DrawIntro(ResolvePlayerPaths.Label, "Resolved Paths (Player)"u8); - if (forwardArray.Length > 0 || reverseArray.Length > 0) + using (IpcTester.DrawIntro(ResolvePlayerPaths.Label, "Resolved Paths (Player)"u8)) { - var ret = new ResolvePlayerPaths(pi).Invoke(forwardArray, reverseArray); - Im.Text(ConvertText(ret)); + if (forwardArray.Length > 0 || reverseArray.Length > 0) + { + var ret = new ResolvePlayerPaths(pi).Invoke(forwardArray, reverseArray); + table.DrawColumn(ConvertText(ret)); + } + } + + using (IpcTester.DrawIntro(ResolvePlayerPathsAsync.Label, "Resolved Paths Async (Player)"u8)) + { + table.NextColumn(); + if (Im.SmallButton("Start"u8)) + _task = new ResolvePlayerPathsAsync(pi).Invoke(forwardArray, reverseArray); + var hovered = Im.Item.Hovered(); + Im.Line.Same(); + ImEx.TextFrameAligned($"{_task.Status}"); + if ((hovered || Im.Item.Hovered()) && _task.IsCompletedSuccessfully && _task.Result.Item1.Length > 0) + Im.Tooltip.Set(ConvertText(_task.Result)); } - IpcTester.DrawIntro(ResolvePlayerPathsAsync.Label, "Resolved Paths Async (Player)"u8); - if (Im.Button("Start"u8)) - _task = new ResolvePlayerPathsAsync(pi).Invoke(forwardArray, reverseArray); - var hovered = Im.Item.Hovered(); - Im.Line.Same(); - ImEx.TextFrameAligned($"{_task.Status}"); - if ((hovered || Im.Item.Hovered()) && _task.IsCompletedSuccessfully) - Im.Tooltip.Set(ConvertText(_task.Result)); return; static StringU8 ConvertText((string[], string[][]) data) diff --git a/Penumbra/Api/IpcTester/ResourceTreeIpcTester.cs b/Penumbra/Api/IpcTester/ResourceTreeIpcTester.cs index dbad6500..12c3fd94 100644 --- a/Penumbra/Api/IpcTester/ResourceTreeIpcTester.cs +++ b/Penumbra/Api/IpcTester/ResourceTreeIpcTester.cs @@ -34,121 +34,136 @@ public class ResourceTreeIpcTester(IDalamudPluginInterface pi, ObjectManager obj return; Im.Input.Text("GameObject indices"u8, ref _gameObjectIndices); - EnumCombo.Instance.Draw("Resource type"u8, ref _type, default, Im.Item.Size.X); + EnumCombo.Instance.Draw("Resource type"u8, ref _type, default, Im.Item.CalculateWidth()); Im.Checkbox("Also get names and icons"u8, ref _withUiData); using var table = Im.Table.Begin(StringU8.Empty, 3, TableFlags.SizingFixedFit); if (!table) return; - IpcTester.DrawIntro(GetGameObjectResourcePaths.Label, "Get GameObject resource paths"u8); - if (Im.Button("Get##GameObjectResourcePaths"u8)) + using (IpcTester.DrawIntro(GetGameObjectResourcePaths.Label, "Get GameObject resource paths"u8)) { - var gameObjects = GetSelectedGameObjects(); - var subscriber = new GetGameObjectResourcePaths(pi); - _stopwatch.Restart(); - var resourcePaths = subscriber.Invoke(gameObjects); + DrawPopup("GetGameObjectResourcePaths"u8, ref _lastGameObjectResourcePaths, DrawResourcePaths, + _lastCallDuration); + table.NextColumn(); + if (Im.SmallButton("Get##GameObjectResourcePaths"u8)) + { + var gameObjects = GetSelectedGameObjects(); + var subscriber = new GetGameObjectResourcePaths(pi); + _stopwatch.Restart(); + var resourcePaths = subscriber.Invoke(gameObjects); - _lastCallDuration = _stopwatch.Elapsed; - _lastGameObjectResourcePaths = gameObjects - .Select(i => GameObjectToString(i)) - .Zip(resourcePaths) - .ToArray(); + _lastCallDuration = _stopwatch.Elapsed; + _lastGameObjectResourcePaths = gameObjects + .Select(i => GameObjectToString(i)) + .Zip(resourcePaths) + .ToArray(); - Im.Popup.Open("GetGameObjectResourcePaths"u8); + Im.Popup.Open("GetGameObjectResourcePaths"u8); + } } - IpcTester.DrawIntro(GetPlayerResourcePaths.Label, "Get local player resource paths"u8); - if (Im.Button("Get##PlayerResourcePaths"u8)) + using (IpcTester.DrawIntro(GetPlayerResourcePaths.Label, "Get local player resource paths"u8)) { - var subscriber = new GetPlayerResourcePaths(pi); - _stopwatch.Restart(); - var resourcePaths = subscriber.Invoke(); + DrawPopup("GetPlayerResourcePaths"u8, ref _lastPlayerResourcePaths!, DrawResourcePaths, _lastCallDuration); + table.NextColumn(); + if (Im.SmallButton("Get##PlayerResourcePaths"u8)) + { + var subscriber = new GetPlayerResourcePaths(pi); + _stopwatch.Restart(); + var resourcePaths = subscriber.Invoke(); - _lastCallDuration = _stopwatch.Elapsed; - _lastPlayerResourcePaths = resourcePaths - .Select(pair => (GameObjectToString(pair.Key), pair.Value)) - .ToArray()!; + _lastCallDuration = _stopwatch.Elapsed; + _lastPlayerResourcePaths = resourcePaths + .Select(pair => (GameObjectToString(pair.Key), pair.Value)) + .ToArray()!; - Im.Popup.Open("GetPlayerResourcePaths"u8); + Im.Popup.Open("GetPlayerResourcePaths"u8); + } } - IpcTester.DrawIntro(GetGameObjectResourcesOfType.Label, "Get GameObject resources of type"u8); - if (Im.Button("Get##GameObjectResourcesOfType"u8)) + using (IpcTester.DrawIntro(GetGameObjectResourcesOfType.Label, "Get GameObject resources of type"u8)) { - var gameObjects = GetSelectedGameObjects(); - var subscriber = new GetGameObjectResourcesOfType(pi); - _stopwatch.Restart(); - var resourcesOfType = subscriber.Invoke(_type, _withUiData, gameObjects); + DrawPopup("GetGameObjectResourcesOfType"u8, ref _lastGameObjectResourcesOfType, DrawResourcesOfType, + _lastCallDuration); + table.NextColumn(); + if (Im.SmallButton("Get##GameObjectResourcesOfType"u8)) + { + var gameObjects = GetSelectedGameObjects(); + var subscriber = new GetGameObjectResourcesOfType(pi); + _stopwatch.Restart(); + var resourcesOfType = subscriber.Invoke(_type, _withUiData, gameObjects); - _lastCallDuration = _stopwatch.Elapsed; - _lastGameObjectResourcesOfType = gameObjects - .Select(i => GameObjectToString(i)) - .Zip(resourcesOfType) - .ToArray(); + _lastCallDuration = _stopwatch.Elapsed; + _lastGameObjectResourcesOfType = gameObjects + .Select(i => GameObjectToString(i)) + .Zip(resourcesOfType) + .ToArray(); - Im.Popup.Open("GetGameObjectResourcesOfType"u8); + Im.Popup.Open("GetGameObjectResourcesOfType"u8); + } } - IpcTester.DrawIntro(GetPlayerResourcesOfType.Label, "Get local player resources of type"u8); - if (Im.Button("Get##PlayerResourcesOfType"u8)) + using (IpcTester.DrawIntro(GetPlayerResourcesOfType.Label, "Get local player resources of type"u8)) { - var subscriber = new GetPlayerResourcesOfType(pi); - _stopwatch.Restart(); - var resourcesOfType = subscriber.Invoke(_type, _withUiData); + DrawPopup("GetPlayerResourcesOfType"u8, ref _lastPlayerResourcesOfType, DrawResourcesOfType, + _lastCallDuration); + table.NextColumn(); + if (Im.SmallButton("Get##PlayerResourcesOfType"u8)) + { + var subscriber = new GetPlayerResourcesOfType(pi); + _stopwatch.Restart(); + var resourcesOfType = subscriber.Invoke(_type, _withUiData); - _lastCallDuration = _stopwatch.Elapsed; - _lastPlayerResourcesOfType = resourcesOfType - .Select(pair => (GameObjectToString(pair.Key), (IReadOnlyDictionary?)pair.Value)) - .ToArray(); + _lastCallDuration = _stopwatch.Elapsed; + _lastPlayerResourcesOfType = resourcesOfType + .Select(pair => (GameObjectToString(pair.Key), (IReadOnlyDictionary?)pair.Value)) + .ToArray(); - Im.Popup.Open("GetPlayerResourcesOfType"u8); + Im.Popup.Open("GetPlayerResourcesOfType"u8); + } } - IpcTester.DrawIntro(GetGameObjectResourceTrees.Label, "Get GameObject resource trees"u8); - if (Im.Button("Get##GameObjectResourceTrees"u8)) + using (IpcTester.DrawIntro(GetGameObjectResourceTrees.Label, "Get GameObject resource trees"u8)) { - var gameObjects = GetSelectedGameObjects(); - var subscriber = new GetGameObjectResourceTrees(pi); - _stopwatch.Restart(); - var trees = subscriber.Invoke(_withUiData, gameObjects); + DrawPopup("GetGameObjectResourceTrees"u8, ref _lastGameObjectResourceTrees, DrawResourceTrees, + _lastCallDuration); + table.NextColumn(); + if (Im.SmallButton("Get##GameObjectResourceTrees"u8)) + { + var gameObjects = GetSelectedGameObjects(); + var subscriber = new GetGameObjectResourceTrees(pi); + _stopwatch.Restart(); + var trees = subscriber.Invoke(_withUiData, gameObjects); - _lastCallDuration = _stopwatch.Elapsed; - _lastGameObjectResourceTrees = gameObjects - .Select(i => GameObjectToString(i)) - .Zip(trees) - .ToArray(); + _lastCallDuration = _stopwatch.Elapsed; + _lastGameObjectResourceTrees = gameObjects + .Select(i => GameObjectToString(i)) + .Zip(trees) + .ToArray(); - Im.Popup.Open("GetGameObjectResourceTrees"u8); + Im.Popup.Open("GetGameObjectResourceTrees"u8); + } } - IpcTester.DrawIntro(GetPlayerResourceTrees.Label, "Get local player resource trees"u8); - if (Im.Button("Get##PlayerResourceTrees"u8)) + using (IpcTester.DrawIntro(GetPlayerResourceTrees.Label, "Get local player resource trees"u8)) { - var subscriber = new GetPlayerResourceTrees(pi); - _stopwatch.Restart(); - var trees = subscriber.Invoke(_withUiData); + DrawPopup("GetPlayerResourceTrees"u8, ref _lastPlayerResourceTrees, DrawResourceTrees!, _lastCallDuration); + table.NextColumn(); + if (Im.SmallButton("Get##PlayerResourceTrees"u8)) + { + var subscriber = new GetPlayerResourceTrees(pi); + _stopwatch.Restart(); + var trees = subscriber.Invoke(_withUiData); - _lastCallDuration = _stopwatch.Elapsed; - _lastPlayerResourceTrees = trees - .Select(pair => (GameObjectToString(pair.Key), pair.Value)) - .ToArray(); + _lastCallDuration = _stopwatch.Elapsed; + _lastPlayerResourceTrees = trees + .Select(pair => (GameObjectToString(pair.Key), pair.Value)) + .ToArray(); - Im.Popup.Open("GetPlayerResourceTrees"u8); + Im.Popup.Open("GetPlayerResourceTrees"u8); + } } - - DrawPopup("GetGameObjectResourcePaths"u8, ref _lastGameObjectResourcePaths, DrawResourcePaths, - _lastCallDuration); - DrawPopup("GetPlayerResourcePaths"u8, ref _lastPlayerResourcePaths!, DrawResourcePaths, _lastCallDuration); - - DrawPopup("GetGameObjectResourcesOfType"u8, ref _lastGameObjectResourcesOfType, DrawResourcesOfType, - _lastCallDuration); - DrawPopup("GetPlayerResourcesOfType"u8, ref _lastPlayerResourcesOfType, DrawResourcesOfType, - _lastCallDuration); - - DrawPopup("GetGameObjectResourceTrees"u8, ref _lastGameObjectResourceTrees, DrawResourceTrees, - _lastCallDuration); - DrawPopup("GetPlayerResourceTrees"u8, ref _lastPlayerResourceTrees, DrawResourceTrees!, _lastCallDuration); } private static void DrawPopup(ReadOnlySpan popupId, ref T? result, Action drawResult, TimeSpan duration) where T : class diff --git a/Penumbra/Api/IpcTester/TemporaryIpcTester.cs b/Penumbra/Api/IpcTester/TemporaryIpcTester.cs index 1e665d06..bbd317d0 100644 --- a/Penumbra/Api/IpcTester/TemporaryIpcTester.cs +++ b/Penumbra/Api/IpcTester/TemporaryIpcTester.cs @@ -45,7 +45,7 @@ public class TemporaryIpcTester( Im.Input.Text("##identity"u8, ref _identity, "Identity..."u8); Im.Input.Text("##tempCollection"u8, ref _tempCollectionName, "Collection Name..."u8); - ImEx.GuidInput("##guid"u8, ref _tempGuid, "Collection GUID..."u8); + ImEx.GuidInput("Collection ID##guid"u8, ref _tempGuid); Im.Input.Scalar("##tempActorIndex"u8, ref _tempActorIndex); Im.Input.Text("##tempMod"u8, ref _tempModName, "Temporary Mod Name..."u8); Im.Input.Text("##mod"u8, ref _modDirectory, "Existing Mod Name..."u8); @@ -58,134 +58,186 @@ public class TemporaryIpcTester( if (!table) return; - IpcTester.DrawIntro("Last Error", $"{_lastTempError}"); - table.DrawColumn("Last Created Collection"u8); - table.NextColumn(); - LunaStyle.DrawGuid(LastCreatedCollectionId); - - IpcTester.DrawIntro(CreateTemporaryCollection.Label, "Create Temporary Collection"u8); - if (Im.Button("Create##Collection"u8)) + using (IpcTester.DrawIntro("Last Error", $"{_lastTempError}")) { - _lastTempError = new CreateTemporaryCollection(pi).Invoke(_identity, _tempCollectionName, out LastCreatedCollectionId); - if (_tempGuid is null) - _tempGuid = LastCreatedCollectionId; + table.DrawColumn("Last Created Collection"u8); + table.NextColumn(); + LunaStyle.DrawGuid(LastCreatedCollectionId); + } + + using (IpcTester.DrawIntro(CreateTemporaryCollection.Label, "Create Temporary Collection"u8)) + { + table.NextColumn(); + if (Im.SmallButton("Create##Collection"u8)) + { + _lastTempError = new CreateTemporaryCollection(pi).Invoke(_identity, _tempCollectionName, out LastCreatedCollectionId); + if (_tempGuid is null) + _tempGuid = LastCreatedCollectionId; + } } var guid = _tempGuid.GetValueOrDefault(Guid.Empty); - IpcTester.DrawIntro(DeleteTemporaryCollection.Label, "Delete Temporary Collection"u8); - if (Im.Button("Delete##Collection"u8)) - _lastTempError = new DeleteTemporaryCollection(pi).Invoke(guid); - Im.Line.Same(); - if (Im.Button("Delete Last##Collection"u8)) - _lastTempError = new DeleteTemporaryCollection(pi).Invoke(LastCreatedCollectionId); - - IpcTester.DrawIntro(AssignTemporaryCollection.Label, "Assign Temporary Collection"u8); - if (Im.Button("Assign##NamedCollection"u8)) - _lastTempError = new AssignTemporaryCollection(pi).Invoke(guid, _tempActorIndex, _forceOverwrite); - - IpcTester.DrawIntro(AddTemporaryMod.Label, "Add Temporary Mod to specific Collection"u8); - if (Im.Button("Add##Mod"u8)) - _lastTempError = new AddTemporaryMod(pi).Invoke(_tempModName, guid, - new Dictionary { { _tempGamePath, _tempFilePath } }, - _tempManipulation.Length > 0 ? _tempManipulation : string.Empty, int.MaxValue); - - IpcTester.DrawIntro(CreateTemporaryCollection.Label, "Copy Existing Collection"u8); - if (ImEx.Button("Copy##Collection"u8, Vector2.Zero, "Copies the effective list from the collection named in Temporary Mod Name..."u8, - !collections.Storage.ByName(_tempModName, out var copyCollection)) - && copyCollection is { HasCache: true }) + using (IpcTester.DrawIntro(DeleteTemporaryCollection.Label, "Delete Temporary Collection"u8)) { - var files = copyCollection.ResolvedFiles.ToDictionary(kvp => kvp.Key.ToString(), kvp => kvp.Value.Path.ToString()); - var manips = MetaApi.CompressMetaManipulations(copyCollection); - _lastTempError = new AddTemporaryMod(pi).Invoke(_tempModName, guid, files, manips, 999); + table.NextColumn(); + if (Im.SmallButton("Delete##Collection"u8)) + _lastTempError = new DeleteTemporaryCollection(pi).Invoke(guid); + Im.Line.Same(); + if (Im.SmallButton("Delete Last##Collection"u8)) + _lastTempError = new DeleteTemporaryCollection(pi).Invoke(LastCreatedCollectionId); } - IpcTester.DrawIntro(AddTemporaryModAll.Label, "Add Temporary Mod to all Collections"u8); - if (Im.Button("Add##All"u8)) - _lastTempError = new AddTemporaryModAll(pi).Invoke(_tempModName, - new Dictionary { { _tempGamePath, _tempFilePath } }, - _tempManipulation.Length > 0 ? _tempManipulation : string.Empty, int.MaxValue); - - IpcTester.DrawIntro(RemoveTemporaryMod.Label, "Remove Temporary Mod from specific Collection"u8); - if (Im.Button("Remove##Mod"u8)) - _lastTempError = new RemoveTemporaryMod(pi).Invoke(_tempModName, guid, int.MaxValue); - - IpcTester.DrawIntro(RemoveTemporaryModAll.Label, "Remove Temporary Mod from all Collections"u8); - if (Im.Button("Remove##ModAll"u8)) - _lastTempError = new RemoveTemporaryModAll(pi).Invoke(_tempModName, int.MaxValue); - - IpcTester.DrawIntro(SetTemporaryModSettings.Label, "Set Temporary Mod Settings (to default) in specific Collection"u8); - if (Im.Button("Set##SetTemporary"u8)) - _lastTempError = new SetTemporaryModSettings(pi).Invoke(guid, _modDirectory, false, true, 1337, - new Dictionary>(), - "IPC Tester", 1337); - - IpcTester.DrawIntro(SetTemporaryModSettingsPlayer.Label, "Set Temporary Mod Settings (to default) in game object collection"u8); - if (Im.Button("Set##SetTemporaryPlayer"u8)) - _lastTempError = new SetTemporaryModSettingsPlayer(pi).Invoke(_tempActorIndex, _modDirectory, false, true, 1337, - new Dictionary>(), - "IPC Tester", 1337); - - IpcTester.DrawIntro(RemoveTemporaryModSettings.Label, "Remove Temporary Mod Settings from specific Collection"u8); - if (Im.Button("Remove##RemoveTemporary"u8)) - _lastTempError = new RemoveTemporaryModSettings(pi).Invoke(guid, _modDirectory, 1337); - Im.Line.Same(); - if (Im.Button("Remove (Wrong Key)##RemoveTemporary"u8)) - _lastTempError = new RemoveTemporaryModSettings(pi).Invoke(guid, _modDirectory, 1338); - - IpcTester.DrawIntro(RemoveTemporaryModSettingsPlayer.Label, "Remove Temporary Mod Settings from game object Collection"u8); - if (Im.Button("Remove##RemoveTemporaryPlayer"u8)) - _lastTempError = new RemoveTemporaryModSettingsPlayer(pi).Invoke(_tempActorIndex, _modDirectory, 1337); - Im.Line.Same(); - if (Im.Button("Remove (Wrong Key)##RemoveTemporaryPlayer"u8)) - _lastTempError = new RemoveTemporaryModSettingsPlayer(pi).Invoke(_tempActorIndex, _modDirectory, 1338); - - IpcTester.DrawIntro(RemoveAllTemporaryModSettings.Label, "Remove All Temporary Mod Settings from specific Collection"u8); - if (Im.Button("Remove##RemoveAllTemporary"u8)) - _lastTempError = new RemoveAllTemporaryModSettings(pi).Invoke(guid, 1337); - Im.Line.Same(); - if (Im.Button("Remove (Wrong Key)##RemoveAllTemporary"u8)) - _lastTempError = new RemoveAllTemporaryModSettings(pi).Invoke(guid, 1338); - - IpcTester.DrawIntro(RemoveAllTemporaryModSettingsPlayer.Label, "Remove All Temporary Mod Settings from game object Collection"u8); - if (Im.Button("Remove##RemoveAllTemporaryPlayer"u8)) - _lastTempError = new RemoveAllTemporaryModSettingsPlayer(pi).Invoke(_tempActorIndex, 1337); - Im.Line.Same(); - if (Im.Button("Remove (Wrong Key)##RemoveAllTemporaryPlayer"u8)) - _lastTempError = new RemoveAllTemporaryModSettingsPlayer(pi).Invoke(_tempActorIndex, 1338); - - IpcTester.DrawIntro(QueryTemporaryModSettings.Label, "Query Temporary Mod Settings from specific Collection"u8); - Im.Button("Query##QueryTemporaryModSettings"u8); - if (Im.Item.Hovered()) + using (IpcTester.DrawIntro(AssignTemporaryCollection.Label, "Assign Temporary Collection"u8)) { - _lastTempError = new QueryTemporaryModSettings(pi).Invoke(guid, _modDirectory, out var settings, out var source, 1337); - DrawTooltip(settings, source); + table.NextColumn(); + if (Im.SmallButton("Assign##NamedCollection"u8)) + _lastTempError = new AssignTemporaryCollection(pi).Invoke(guid, _tempActorIndex, _forceOverwrite); } - Im.Line.Same(); - Im.Button("Query (Wrong Key)##RemoveAllTemporary"u8); - if (Im.Item.Hovered()) + using (IpcTester.DrawIntro(AddTemporaryMod.Label, "Add Temporary Mod to specific Collection"u8)) { - _lastTempError = new QueryTemporaryModSettings(pi).Invoke(guid, _modDirectory, out var settings, out var source, 1338); - DrawTooltip(settings, source); + table.NextColumn(); + if (Im.SmallButton("Add##Mod"u8)) + _lastTempError = new AddTemporaryMod(pi).Invoke(_tempModName, guid, + new Dictionary { { _tempGamePath, _tempFilePath } }, + _tempManipulation.Length > 0 ? _tempManipulation : string.Empty, int.MaxValue); } - IpcTester.DrawIntro(QueryTemporaryModSettingsPlayer.Label, "Query Temporary Mod Settings from game object Collection"u8); - Im.Button("Query##QueryTemporaryModSettingsPlayer"u8); - if (Im.Item.Hovered()) + using (IpcTester.DrawIntro(CreateTemporaryCollection.Label, "Copy Existing Collection"u8)) { - _lastTempError = - new QueryTemporaryModSettingsPlayer(pi).Invoke(_tempActorIndex, _modDirectory, out var settings, out var source, 1337); - DrawTooltip(settings, source); + table.NextColumn(); + if (ImEx.Button("Copy##Collection"u8, Vector2.Zero, + "Copies the effective list from the collection named in Temporary Mod Name..."u8, + !collections.Storage.ByName(_tempModName, out var copyCollection)) + && copyCollection is { HasCache: true }) + { + var files = copyCollection.ResolvedFiles.ToDictionary(kvp => kvp.Key.ToString(), kvp => kvp.Value.Path.ToString()); + var manips = MetaApi.CompressMetaManipulations(copyCollection); + _lastTempError = new AddTemporaryMod(pi).Invoke(_tempModName, guid, files, manips, 999); + } } - Im.Line.Same(); - Im.Button("Query (Wrong Key)##RemoveAllTemporaryPlayer"u8); - if (Im.Item.Hovered()) + using (IpcTester.DrawIntro(AddTemporaryModAll.Label, "Add Temporary Mod to all Collections"u8)) { - _lastTempError = - new QueryTemporaryModSettingsPlayer(pi).Invoke(_tempActorIndex, _modDirectory, out var settings, out var source, 1338); - DrawTooltip(settings, source); + table.NextColumn(); + if (Im.SmallButton("Add##All"u8)) + _lastTempError = new AddTemporaryModAll(pi).Invoke(_tempModName, + new Dictionary { { _tempGamePath, _tempFilePath } }, + _tempManipulation.Length > 0 ? _tempManipulation : string.Empty, int.MaxValue); + } + + using (IpcTester.DrawIntro(RemoveTemporaryMod.Label, "Remove Temporary Mod from specific Collection"u8)) + { + table.NextColumn(); + if (Im.SmallButton("Remove##Mod"u8)) + _lastTempError = new RemoveTemporaryMod(pi).Invoke(_tempModName, guid, int.MaxValue); + } + + using (IpcTester.DrawIntro(RemoveTemporaryModAll.Label, "Remove Temporary Mod from all Collections"u8)) + { + table.NextColumn(); + if (Im.SmallButton("Remove##ModAll"u8)) + _lastTempError = new RemoveTemporaryModAll(pi).Invoke(_tempModName, int.MaxValue); + } + + using (IpcTester.DrawIntro(SetTemporaryModSettings.Label, "Set Temporary Mod Settings (to default) in specific Collection"u8)) + { + table.NextColumn(); + if (Im.SmallButton("Set##SetTemporary"u8)) + _lastTempError = new SetTemporaryModSettings(pi).Invoke(guid, _modDirectory, false, true, 1337, + new Dictionary>(), + "IPC Tester", 1337); + } + + using (IpcTester.DrawIntro(SetTemporaryModSettingsPlayer.Label, "Set Temporary Mod Settings (to default) in game object collection"u8)) + { + table.NextColumn(); + if (Im.SmallButton("Set##SetTemporaryPlayer"u8)) + _lastTempError = new SetTemporaryModSettingsPlayer(pi).Invoke(_tempActorIndex, _modDirectory, false, true, 1337, + new Dictionary>(), + "IPC Tester", 1337); + } + + using (IpcTester.DrawIntro(RemoveTemporaryModSettings.Label, "Remove Temporary Mod Settings from specific Collection"u8)) + { + table.NextColumn(); + if (Im.SmallButton("Remove##RemoveTemporary"u8)) + _lastTempError = new RemoveTemporaryModSettings(pi).Invoke(guid, _modDirectory, 1337); + Im.Line.Same(); + if (Im.SmallButton("Remove (Wrong Key)##RemoveTemporary"u8)) + _lastTempError = new RemoveTemporaryModSettings(pi).Invoke(guid, _modDirectory, 1338); + } + + using (IpcTester.DrawIntro(RemoveTemporaryModSettingsPlayer.Label, "Remove Temporary Mod Settings from game object Collection"u8)) + { + table.NextColumn(); + if (Im.SmallButton("Remove##RemoveTemporaryPlayer"u8)) + _lastTempError = new RemoveTemporaryModSettingsPlayer(pi).Invoke(_tempActorIndex, _modDirectory, 1337); + Im.Line.Same(); + if (Im.SmallButton("Remove (Wrong Key)##RemoveTemporaryPlayer"u8)) + _lastTempError = new RemoveTemporaryModSettingsPlayer(pi).Invoke(_tempActorIndex, _modDirectory, 1338); + } + + using (IpcTester.DrawIntro(RemoveAllTemporaryModSettings.Label, "Remove All Temporary Mod Settings from specific Collection"u8)) + { + table.NextColumn(); + if (Im.SmallButton("Remove##RemoveAllTemporary"u8)) + _lastTempError = new RemoveAllTemporaryModSettings(pi).Invoke(guid, 1337); + Im.Line.Same(); + if (Im.SmallButton("Remove (Wrong Key)##RemoveAllTemporary"u8)) + _lastTempError = new RemoveAllTemporaryModSettings(pi).Invoke(guid, 1338); + } + + using (IpcTester.DrawIntro(RemoveAllTemporaryModSettingsPlayer.Label, + "Remove All Temporary Mod Settings from game object Collection"u8)) + { + table.NextColumn(); + if (Im.SmallButton("Remove##RemoveAllTemporaryPlayer"u8)) + _lastTempError = new RemoveAllTemporaryModSettingsPlayer(pi).Invoke(_tempActorIndex, 1337); + Im.Line.Same(); + if (Im.SmallButton("Remove (Wrong Key)##RemoveAllTemporaryPlayer"u8)) + _lastTempError = new RemoveAllTemporaryModSettingsPlayer(pi).Invoke(_tempActorIndex, 1338); + } + + using (IpcTester.DrawIntro(QueryTemporaryModSettings.Label, "Query Temporary Mod Settings from specific Collection"u8)) + { + table.NextColumn(); + Im.SmallButton("Query##QueryTemporaryModSettings"u8); + if (Im.Item.Hovered()) + { + _lastTempError = new QueryTemporaryModSettings(pi).Invoke(guid, _modDirectory, out var settings, out var source, 1337); + DrawTooltip(settings, source); + } + + Im.Line.Same(); + Im.SmallButton("Query (Wrong Key)##RemoveAllTemporary"u8); + if (Im.Item.Hovered()) + { + _lastTempError = new QueryTemporaryModSettings(pi).Invoke(guid, _modDirectory, out var settings, out var source, 1338); + DrawTooltip(settings, source); + } + } + + using (IpcTester.DrawIntro(QueryTemporaryModSettingsPlayer.Label, "Query Temporary Mod Settings from game object Collection"u8)) + { + table.NextColumn(); + Im.SmallButton("Query##QueryTemporaryModSettingsPlayer"u8); + if (Im.Item.Hovered()) + { + _lastTempError = + new QueryTemporaryModSettingsPlayer(pi).Invoke(_tempActorIndex, _modDirectory, out var settings, out var source, 1337); + DrawTooltip(settings, source); + } + + Im.Line.Same(); + Im.SmallButton("Query (Wrong Key)##RemoveAllTemporaryPlayer"u8); + if (Im.Item.Hovered()) + { + _lastTempError = + new QueryTemporaryModSettingsPlayer(pi).Invoke(_tempActorIndex, _modDirectory, out var settings, out var source, 1338); + DrawTooltip(settings, source); + } } return; diff --git a/Penumbra/Api/IpcTester/UiIpcTester.cs b/Penumbra/Api/IpcTester/UiIpcTester.cs index c69eaa4e..bfecc7dc 100644 --- a/Penumbra/Api/IpcTester/UiIpcTester.cs +++ b/Penumbra/Api/IpcTester/UiIpcTester.cs @@ -60,48 +60,63 @@ public class UiIpcTester : Luna.IUiService, IDisposable if (!_) return; - EnumCombo.Instance.Draw("Tab to Open at"u8, ref _selectTab, default, 0); Im.Input.Text("##openMod"u8, ref _modName, "Mod to Open at..."u8); + EnumCombo.Instance.Draw("Tab to Open at"u8, ref _selectTab, default, Im.Item.CalculateWidth()); using var table = Im.Table.Begin(StringU8.Empty, 3, TableFlags.SizingFixedFit); if (!table) return; - IpcTester.DrawIntro(PostSettingsDraw.Label, "Last Drawn Mod"u8); - Im.Text(_lastDrawnMod.Length > 0 ? $"{_lastDrawnMod} at {_lastDrawnModTime}" : "None"u8); - - IpcTester.DrawIntro(IpcSubscribers.ChangedItemTooltip.Label, "Add Tooltip"u8); - if (Im.Checkbox("##tooltip"u8, ref _subscribedToTooltip)) + using (IpcTester.DrawIntro(PostSettingsDraw.Label, "Last Drawn Mod"u8)) { - if (_subscribedToTooltip) - ChangedItemTooltip.Enable(); - else - ChangedItemTooltip.Disable(); + table.DrawColumn(_lastDrawnMod.Length > 0 ? $"{_lastDrawnMod} at {_lastDrawnModTime}" : "None"u8); } - Im.Line.Same(); - Im.Text(_lastHovered); - - IpcTester.DrawIntro(IpcSubscribers.ChangedItemClicked.Label, "Subscribe Click"u8); - if (Im.Checkbox("##click"u8, ref _subscribedToClick)) + using (IpcTester.DrawIntro(IpcSubscribers.ChangedItemTooltip.Label, "Add Tooltip"u8)) { - if (_subscribedToClick) - ChangedItemClicked.Enable(); - else - ChangedItemClicked.Disable(); + table.NextColumn(); + if (Im.Checkbox("##tooltip"u8, ref _subscribedToTooltip)) + { + if (_subscribedToTooltip) + ChangedItemTooltip.Enable(); + else + ChangedItemTooltip.Disable(); + } + + Im.Line.Same(); + ImEx.TextFrameAligned(_lastHovered); } - Im.Line.Same(); - Im.Text(_lastClicked); - IpcTester.DrawIntro(OpenMainWindow.Label, "Open Mod Window"u8); - if (Im.Button("Open##window"u8)) - _ec = new OpenMainWindow(_pi).Invoke(_selectTab, _modName, _modName); + using (IpcTester.DrawIntro(IpcSubscribers.ChangedItemClicked.Label, "Subscribe Click"u8)) + { + table.NextColumn(); + if (Im.Checkbox("##click"u8, ref _subscribedToClick)) + { + if (_subscribedToClick) + ChangedItemClicked.Enable(); + else + ChangedItemClicked.Disable(); + } - Im.Line.Same(); - Im.Text($"{_ec}"); + Im.Line.Same(); + ImEx.TextFrameAligned(_lastClicked); + } - IpcTester.DrawIntro(CloseMainWindow.Label, "Close Mod Window"u8); - if (Im.Button("Close##window"u8)) - new CloseMainWindow(_pi).Invoke(); + using (IpcTester.DrawIntro(OpenMainWindow.Label, "Open Mod Window"u8)) + { + table.NextColumn(); + if (Im.SmallButton("Open##window"u8)) + _ec = new OpenMainWindow(_pi).Invoke(_selectTab, _modName, _modName); + + Im.Line.Same(); + Im.Text($"{_ec}"); + } + + using (IpcTester.DrawIntro(CloseMainWindow.Label, "Close Mod Window"u8)) + { + table.NextColumn(); + if (Im.SmallButton("Close##window"u8)) + new CloseMainWindow(_pi).Invoke(); + } } private void UpdateLastDrawnMod(string name)