mirror of
https://github.com/Ottermandias/Glamourer.git
synced 2025-12-12 18:27:24 +01:00
Adjust new IPC methods + added testing methods
This commit is contained in:
parent
6fe68c59d1
commit
9395072bee
4 changed files with 47 additions and 35 deletions
|
|
@ -12,27 +12,27 @@ namespace Glamourer.Api;
|
|||
|
||||
public partial class GlamourerIpc
|
||||
{
|
||||
public const string LabelApplyByGuidAll = "Glamourer.ApplyByGuidAll";
|
||||
public const string LabelApplyByGuidAllToCharacter = "Glamourer.ApplyByGuidAllToCharacter";
|
||||
public const string LabelApplyByGuid = "Glamourer.ApplyByGuid";
|
||||
public const string LabelApplyByGuidToCharacter = "Glamourer.ApplyByGuidToCharacter";
|
||||
|
||||
private readonly ActionProvider<Guid, string> _applyByGuidAllProvider;
|
||||
private readonly ActionProvider<Guid, Character?> _applyByGuidAllToCharacterProvider;
|
||||
private readonly ActionProvider<Guid, string> _applyByGuidProvider;
|
||||
private readonly ActionProvider<Guid, Character?> _applyByGuidToCharacterProvider;
|
||||
|
||||
public static ActionSubscriber<Guid, string> ApplyByGuidAllSubscriber(DalamudPluginInterface pi)
|
||||
=> new(pi, LabelApplyByGuidAll);
|
||||
public static ActionSubscriber<Guid, string> ApplyByGuidSubscriber(DalamudPluginInterface pi)
|
||||
=> new(pi, LabelApplyByGuid);
|
||||
|
||||
public static ActionSubscriber<Guid, Character?> ApplyByGuidAllToCharacterSubscriber(DalamudPluginInterface pi)
|
||||
=> new(pi, LabelApplyByGuidAllToCharacter);
|
||||
public static ActionSubscriber<Guid, Character?> ApplyByGuidToCharacterSubscriber(DalamudPluginInterface pi)
|
||||
=> new(pi, LabelApplyByGuidToCharacter);
|
||||
|
||||
public void ApplyByGuidAll(Guid GUID, string characterName)
|
||||
=> ApplyDesignByGuid(GUID, FindActors(characterName), 0);
|
||||
public void ApplyByGuid(Guid Identifier, string characterName)
|
||||
=> ApplyDesignByGuid(Identifier, FindActors(characterName), 0);
|
||||
|
||||
public void ApplyByGuidAllToCharacter(Guid GUID, Character? character)
|
||||
=> ApplyDesignByGuid(GUID, FindActors(character), 0);
|
||||
public void ApplyByGuidToCharacter(Guid Identifier, Character? character)
|
||||
=> ApplyDesignByGuid(Identifier, FindActors(character), 0);
|
||||
|
||||
private void ApplyDesignByGuid(Guid GUID, IEnumerable<ActorIdentifier> actors, uint lockCode)
|
||||
private void ApplyDesignByGuid(Guid Identifier, IEnumerable<ActorIdentifier> actors, uint lockCode)
|
||||
{
|
||||
var design = _designManager.Designs.FirstOrDefault(x => x.Identifier == GUID);
|
||||
var design = _designManager.Designs.FirstOrDefault(x => x.Identifier == Identifier);
|
||||
if (design == null)
|
||||
return;
|
||||
|
||||
|
|
|
|||
|
|
@ -16,23 +16,11 @@ public partial class GlamourerIpc
|
|||
{
|
||||
public const string LabelGetDesignList = "Glamourer.GetDesignList";
|
||||
|
||||
private readonly FuncProvider<DesignListEntry[]> _getDesignListProvider;
|
||||
private readonly FuncProvider<(string Name, Guid Identifier)[]> _getDesignListProvider;
|
||||
|
||||
public static FuncSubscriber<DesignListEntry[]> GetDesignListSubscriber(DalamudPluginInterface pi)
|
||||
public static FuncSubscriber<(string Name, Guid Identifier)[]> GetDesignListSubscriber(DalamudPluginInterface pi)
|
||||
=> new(pi, LabelGetDesignList);
|
||||
|
||||
public DesignListEntry[] GetDesignList()
|
||||
=> _designManager.Designs.Select(x => new DesignListEntry(x)).ToArray();
|
||||
|
||||
public record class DesignListEntry
|
||||
{
|
||||
public string Name;
|
||||
public Guid Identifier;
|
||||
|
||||
public DesignListEntry(Design design)
|
||||
{
|
||||
Name = design.Name;
|
||||
Identifier = design.Identifier;
|
||||
}
|
||||
}
|
||||
public (string Name, Guid Identifier)[] GetDesignList()
|
||||
=> _designManager.Designs.Select(x => (x.Name.Text, x.Identifier)).ToArray();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -81,10 +81,10 @@ public partial class GlamourerIpc : IDisposable
|
|||
_stateChangedEvent.Subscribe(OnStateChanged, StateChanged.Priority.GlamourerIpc);
|
||||
_gPose.Subscribe(OnGPoseChanged, GPoseService.Priority.GlamourerIpc);
|
||||
|
||||
_applyByGuidAllProvider = new ActionProvider<Guid, string>(pi, LabelApplyByGuidAll, ApplyByGuidAll);
|
||||
_applyByGuidAllToCharacterProvider = new ActionProvider<Guid, Character?>(pi, LabelApplyByGuidAllToCharacter, ApplyByGuidAllToCharacter);
|
||||
_applyByGuidProvider = new ActionProvider<Guid, string>(pi, LabelApplyByGuid, ApplyByGuid);
|
||||
_applyByGuidToCharacterProvider = new ActionProvider<Guid, Character?>(pi, LabelApplyByGuidToCharacter, ApplyByGuidToCharacter);
|
||||
|
||||
_getDesignListProvider = new FuncProvider<DesignListEntry[]>(pi, LabelGetDesignList, GetDesignList);
|
||||
_getDesignListProvider = new FuncProvider<(string Name, Guid Identifier)[]>(pi, LabelGetDesignList, GetDesignList);
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
|
|
@ -122,8 +122,8 @@ public partial class GlamourerIpc : IDisposable
|
|||
_gPose.Unsubscribe(OnGPoseChanged);
|
||||
_gPoseChangedProvider.Dispose();
|
||||
|
||||
_applyByGuidAllProvider.Dispose();
|
||||
_applyByGuidAllToCharacterProvider.Dispose();
|
||||
_applyByGuidProvider.Dispose();
|
||||
_applyByGuidToCharacterProvider.Dispose();
|
||||
_getDesignListProvider.Dispose();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -5,6 +5,8 @@ using Glamourer.Interop;
|
|||
using ImGuiNET;
|
||||
using OtterGui;
|
||||
using OtterGui.Raii;
|
||||
using System;
|
||||
using System.Linq;
|
||||
|
||||
namespace Glamourer.Gui.Tabs.DebugTab;
|
||||
|
||||
|
|
@ -19,12 +21,14 @@ public class IpcTesterPanel(DalamudPluginInterface _pluginInterface, ObjectManag
|
|||
private int _gameObjectIndex;
|
||||
private string _gameObjectName = string.Empty;
|
||||
private string _base64Apply = string.Empty;
|
||||
private string _designIdentifier = string.Empty;
|
||||
|
||||
public void Draw()
|
||||
{
|
||||
ImGui.InputInt("Game Object Index", ref _gameObjectIndex, 0, 0);
|
||||
ImGui.InputTextWithHint("##gameObject", "Character Name...", ref _gameObjectName, 64);
|
||||
ImGui.InputTextWithHint("##base64", "Design Base64...", ref _base64Apply, 2047);
|
||||
ImGui.InputTextWithHint("##identifier", "Design identifier...", ref _designIdentifier, 36);
|
||||
using var table = ImRaii.Table("##ipc", 2, ImGuiTableFlags.SizingFixedFit | ImGuiTableFlags.RowBg);
|
||||
if (!table)
|
||||
return;
|
||||
|
|
@ -50,6 +54,15 @@ public class IpcTesterPanel(DalamudPluginInterface _pluginInterface, ObjectManag
|
|||
else
|
||||
ImGui.TextUnformatted("Error");
|
||||
|
||||
ImGuiUtil.DrawTableColumn(GlamourerIpc.LabelGetDesignList);
|
||||
ImGui.TableNextColumn();
|
||||
var designList = GlamourerIpc.GetDesignListSubscriber(_pluginInterface)
|
||||
.Invoke();
|
||||
if (designList != null)
|
||||
ImGuiUtil.CopyOnClickSelectable(string.Join(", ", designList));
|
||||
else
|
||||
ImGui.TextUnformatted("Error");
|
||||
|
||||
ImGuiUtil.DrawTableColumn(GlamourerIpc.LabelRevert);
|
||||
ImGui.TableNextColumn();
|
||||
if (ImGui.Button("Revert##Name"))
|
||||
|
|
@ -104,5 +117,16 @@ public class IpcTesterPanel(DalamudPluginInterface _pluginInterface, ObjectManag
|
|||
if (ImGui.Button("Revert##CustomizeCharacter"))
|
||||
GlamourerIpc.RevertToAutomationCharacterSubscriber(_pluginInterface)
|
||||
.Invoke(_objectManager.Objects[_gameObjectIndex] as Character, 1337);
|
||||
|
||||
ImGuiUtil.DrawTableColumn(GlamourerIpc.LabelApplyByGuid);
|
||||
ImGui.TableNextColumn();
|
||||
if (ImGui.Button("Apply##ByGuidName"))
|
||||
GlamourerIpc.ApplyByGuidSubscriber(_pluginInterface).Invoke(Guid.Parse(_designIdentifier), _gameObjectName);
|
||||
|
||||
ImGuiUtil.DrawTableColumn(GlamourerIpc.LabelApplyByGuidToCharacter);
|
||||
ImGui.TableNextColumn();
|
||||
if (ImGui.Button("Apply##ByGuidCharacter"))
|
||||
GlamourerIpc.ApplyByGuidToCharacterSubscriber(_pluginInterface)
|
||||
.Invoke(Guid.Parse(_designIdentifier), _objectManager.Objects[_gameObjectIndex] as Character);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue