Continue renames, some cleanup.

This commit is contained in:
Ottermandias 2025-01-24 17:50:58 +01:00
parent 7be283ca30
commit d9f9937d41
18 changed files with 175 additions and 134 deletions

View file

@ -183,7 +183,7 @@ public sealed class DesignQuickBar : Window, IDisposable
}
using var _ = design!.TemporarilyRestrictApplication(ApplicationCollection.FromKeys());
_stateManager.ApplyDesign(state, design, ApplySettings.ManualWithLinks with { SendStateUpdate = true });
_stateManager.ApplyDesign(state, design, ApplySettings.ManualWithLinks with { IsFinal = true });
}
private void DrawRevertButton(Vector2 buttonSize)
@ -213,7 +213,7 @@ public sealed class DesignQuickBar : Window, IDisposable
var (clicked, _, _, state) = ResolveTarget(FontAwesomeIcon.UndoAlt, buttonSize, tooltip, available);
ImGui.SameLine();
if (clicked)
_stateManager.ResetState(state!, StateSource.Manual, stateUpdate: true);
_stateManager.ResetState(state!, StateSource.Manual, isFinal: true);
}
private void DrawRevertAutomationButton(Vector2 buttonSize)

View file

@ -385,7 +385,7 @@ public class ActorPanel
{
if (ImGuiUtil.DrawDisabledButton("Revert to Game", Vector2.Zero, "Revert the character to its actual state in the game.",
_state!.IsLocked))
_stateManager.ResetState(_state!, StateSource.Manual, stateUpdate: true);
_stateManager.ResetState(_state!, StateSource.Manual, isFinal: true);
ImGui.SameLine();
@ -423,7 +423,7 @@ public class ActorPanel
if (_stateManager.GetOrCreate(id, data.Objects[0], out var state))
_stateManager.ApplyDesign(state, _converter.Convert(_state!, ApplicationRules.FromModifiers(_state!)),
ApplySettings.Manual with { SendStateUpdate = true });
ApplySettings.Manual with { IsFinal = true });
}
private void DrawApplyToTarget()
@ -440,7 +440,7 @@ public class ActorPanel
if (_stateManager.GetOrCreate(id, data.Objects[0], out var state))
_stateManager.ApplyDesign(state, _converter.Convert(_state!, ApplicationRules.FromModifiers(_state!)),
ApplySettings.Manual with { SendStateUpdate = true });
ApplySettings.Manual with { IsFinal = true });
}
@ -467,7 +467,7 @@ public class ActorPanel
var text = ImGui.GetClipboardText();
var design = panel._converter.FromBase64(text, applyCustomize, applyGear, out _)
?? throw new Exception("The clipboard did not contain valid data.");
panel._stateManager.ApplyDesign(panel._state!, design, ApplySettings.ManualWithLinks with { SendStateUpdate = true });
panel._stateManager.ApplyDesign(panel._state!, design, ApplySettings.ManualWithLinks with { IsFinal = true });
}
catch (Exception ex)
{

View file

@ -79,7 +79,7 @@ public unsafe class GlamourPlatePanel : IGameDataDrawer
if (ImGuiUtil.DrawDisabledButton("Apply to Player", Vector2.Zero, string.Empty, !enabled))
{
var design = CreateDesign(plate);
_state.ApplyDesign(state!, design, ApplySettings.Manual with { SendStateUpdate = true });
_state.ApplyDesign(state!, design, ApplySettings.Manual with { IsFinal = true });
}
using (ImRaii.Group())

View file

@ -51,6 +51,7 @@ public class IpcTesterPanel(
Glamourer.Log.Debug("[IPCTester] Subscribed to IPC events for IPC tester.");
state.GPoseChanged.Enable();
state.StateChanged.Enable();
state.StateFinalized.Enable();
framework.Update += CheckUnsubscribe;
_subscribed = true;
}
@ -73,5 +74,6 @@ public class IpcTesterPanel(
_subscribed = false;
state.GPoseChanged.Disable();
state.StateChanged.Disable();
state.StateFinalized.Disable();
}
}

View file

@ -11,6 +11,7 @@ using Newtonsoft.Json.Linq;
using OtterGui;
using OtterGui.Raii;
using OtterGui.Services;
using OtterGui.Text;
using Penumbra.GameData.Interop;
using Penumbra.String;
@ -31,9 +32,16 @@ public class StateIpcTester : IUiService, IDisposable
private string? _getStateString;
public readonly EventSubscriber<nint, StateChangeType> StateChanged;
private nint _lastStateChangeActor;
private ByteString _lastStateChangeName = ByteString.Empty;
private DateTime _lastStateChangeTime;
private nint _lastStateChangeActor;
private ByteString _lastStateChangeName = ByteString.Empty;
private DateTime _lastStateChangeTime;
private StateChangeType _lastStateChangeType;
public readonly EventSubscriber<nint, StateFinalizationType> StateFinalized;
private nint _lastStateFinalizeActor;
private ByteString _lastStateFinalizeName = ByteString.Empty;
private DateTime _lastStateFinalizeTime;
private StateFinalizationType _lastStateFinalizeType;
public readonly EventSubscriber<bool> GPoseChanged;
private bool _lastGPoseChangeValue;
@ -44,15 +52,18 @@ public class StateIpcTester : IUiService, IDisposable
public StateIpcTester(IDalamudPluginInterface pluginInterface)
{
_pluginInterface = pluginInterface;
StateChanged = Api.IpcSubscribers.StateChangedWithType.Subscriber(_pluginInterface, OnStateChanged);
StateChanged = StateChangedWithType.Subscriber(_pluginInterface, OnStateChanged);
StateFinalized = Api.IpcSubscribers.StateFinalized.Subscriber(_pluginInterface, OnStateFinalized);
GPoseChanged = Api.IpcSubscribers.GPoseChanged.Subscriber(_pluginInterface, OnGPoseChange);
StateChanged.Disable();
StateFinalized.Disable();
GPoseChanged.Disable();
}
public void Dispose()
{
StateChanged.Dispose();
StateFinalized.Dispose();
GPoseChanged.Dispose();
}
@ -73,86 +84,88 @@ public class StateIpcTester : IUiService, IDisposable
IpcTesterHelpers.DrawIntro("Last Error");
ImGui.TextUnformatted(_lastError.ToString());
IpcTesterHelpers.DrawIntro("Last State Change");
PrintName();
PrintChangeName();
IpcTesterHelpers.DrawIntro("Last State Finalization");
PrintFinalizeName();
IpcTesterHelpers.DrawIntro("Last GPose Change");
ImGui.TextUnformatted($"{_lastGPoseChangeValue} at {_lastGPoseChangeTime.ToLocalTime().TimeOfDay}");
IpcTesterHelpers.DrawIntro(GetState.Label);
DrawStatePopup();
if (ImGui.Button("Get##Idx"))
if (ImUtf8.Button("Get##Idx"u8))
{
(_lastError, _state) = new GetState(_pluginInterface).Invoke(_gameObjectIndex, _key);
_stateString = _state?.ToString(Formatting.Indented) ?? "No State Available";
ImGui.OpenPopup("State");
ImUtf8.OpenPopup("State"u8);
}
IpcTesterHelpers.DrawIntro(GetStateName.Label);
if (ImGui.Button("Get##Name"))
if (ImUtf8.Button("Get##Name"u8))
{
(_lastError, _state) = new GetStateName(_pluginInterface).Invoke(_gameObjectName, _key);
_stateString = _state?.ToString(Formatting.Indented) ?? "No State Available";
ImGui.OpenPopup("State");
ImUtf8.OpenPopup("State"u8);
}
IpcTesterHelpers.DrawIntro(GetStateBase64.Label);
if (ImGui.Button("Get##Base64Idx"))
if (ImUtf8.Button("Get##Base64Idx"u8))
{
(_lastError, _getStateString) = new GetStateBase64(_pluginInterface).Invoke(_gameObjectIndex, _key);
_stateString = _getStateString ?? "No State Available";
ImGui.OpenPopup("State");
ImUtf8.OpenPopup("State"u8);
}
IpcTesterHelpers.DrawIntro(GetStateBase64Name.Label);
if (ImGui.Button("Get##Base64Idx"))
if (ImUtf8.Button("Get##Base64Idx"u8))
{
(_lastError, _getStateString) = new GetStateBase64Name(_pluginInterface).Invoke(_gameObjectName, _key);
_stateString = _getStateString ?? "No State Available";
ImGui.OpenPopup("State");
ImUtf8.OpenPopup("State"u8);
}
IpcTesterHelpers.DrawIntro(ApplyState.Label);
if (ImGuiUtil.DrawDisabledButton("Apply Last##Idx", Vector2.Zero, string.Empty, _state == null))
_lastError = new ApplyState(_pluginInterface).Invoke(_state!, _gameObjectIndex, _key, _flags);
ImGui.SameLine();
if (ImGui.Button("Apply Base64##Idx"))
if (ImUtf8.Button("Apply Base64##Idx"u8))
_lastError = new ApplyState(_pluginInterface).Invoke(_base64State, _gameObjectIndex, _key, _flags);
IpcTesterHelpers.DrawIntro(ApplyStateName.Label);
if (ImGuiUtil.DrawDisabledButton("Apply Last##Name", Vector2.Zero, string.Empty, _state == null))
_lastError = new ApplyStateName(_pluginInterface).Invoke(_state!, _gameObjectName, _key, _flags);
ImGui.SameLine();
if (ImGui.Button("Apply Base64##Name"))
if (ImUtf8.Button("Apply Base64##Name"u8))
_lastError = new ApplyStateName(_pluginInterface).Invoke(_base64State, _gameObjectName, _key, _flags);
IpcTesterHelpers.DrawIntro(RevertState.Label);
if (ImGui.Button("Revert##Idx"))
if (ImUtf8.Button("Revert##Idx"u8))
_lastError = new RevertState(_pluginInterface).Invoke(_gameObjectIndex, _key, _flags);
IpcTesterHelpers.DrawIntro(RevertStateName.Label);
if (ImGui.Button("Revert##Name"))
if (ImUtf8.Button("Revert##Name"u8))
_lastError = new RevertStateName(_pluginInterface).Invoke(_gameObjectName, _key, _flags);
IpcTesterHelpers.DrawIntro(UnlockState.Label);
if (ImGui.Button("Unlock##Idx"))
if (ImUtf8.Button("Unlock##Idx"u8))
_lastError = new UnlockState(_pluginInterface).Invoke(_gameObjectIndex, _key);
IpcTesterHelpers.DrawIntro(UnlockStateName.Label);
if (ImGui.Button("Unlock##Name"))
if (ImUtf8.Button("Unlock##Name"u8))
_lastError = new UnlockStateName(_pluginInterface).Invoke(_gameObjectName, _key);
IpcTesterHelpers.DrawIntro(UnlockAll.Label);
if (ImGui.Button("Unlock##All"))
if (ImUtf8.Button("Unlock##All"u8))
_numUnlocked = new UnlockAll(_pluginInterface).Invoke(_key);
ImGui.SameLine();
ImGui.TextUnformatted($"Unlocked {_numUnlocked}");
IpcTesterHelpers.DrawIntro(RevertToAutomation.Label);
if (ImGui.Button("Revert##AutomationIdx"))
if (ImUtf8.Button("Revert##AutomationIdx"u8))
_lastError = new RevertToAutomation(_pluginInterface).Invoke(_gameObjectIndex, _key, _flags);
IpcTesterHelpers.DrawIntro(RevertToAutomationName.Label);
if (ImGui.Button("Revert##AutomationName"))
if (ImUtf8.Button("Revert##AutomationName"u8))
_lastError = new RevertToAutomationName(_pluginInterface).Invoke(_gameObjectName, _key, _flags);
}
@ -162,44 +175,70 @@ public class StateIpcTester : IUiService, IDisposable
if (_stateString == null)
return;
using var p = ImRaii.Popup("State");
using var p = ImUtf8.Popup("State"u8);
if (!p)
return;
if (ImGui.Button("Copy to Clipboard"))
ImGui.SetClipboardText(_stateString);
if (ImUtf8.Button("Copy to Clipboard"u8))
ImUtf8.SetClipboardText(_stateString);
if (_stateString[0] is '{')
{
ImGui.SameLine();
if (ImGui.Button("Copy as Base64") && _state != null)
ImGui.SetClipboardText(DesignConverter.ToBase64(_state));
if (ImUtf8.Button("Copy as Base64"u8) && _state != null)
ImUtf8.SetClipboardText(DesignConverter.ToBase64(_state));
}
using var font = ImRaii.PushFont(UiBuilder.MonoFont);
ImGuiUtil.TextWrapped(_stateString ?? string.Empty);
ImUtf8.TextWrapped(_stateString ?? string.Empty);
if (ImGui.Button("Close", -Vector2.UnitX) || !ImGui.IsWindowFocused())
if (ImUtf8.Button("Close"u8, -Vector2.UnitX) || !ImGui.IsWindowFocused())
ImGui.CloseCurrentPopup();
}
private unsafe void PrintName()
private unsafe void PrintChangeName()
{
ImGuiNative.igTextUnformatted(_lastStateChangeName.Path, _lastStateChangeName.Path + _lastStateChangeName.Length);
ImUtf8.Text(_lastStateChangeName.Span);
ImGui.SameLine(0, 0);
ImUtf8.Text($" ({_lastStateChangeType})");
ImGui.SameLine();
using (ImRaii.PushFont(UiBuilder.MonoFont))
{
ImGuiUtil.CopyOnClickSelectable($"0x{_lastStateChangeActor:X}");
ImUtf8.CopyOnClickSelectable($"0x{_lastStateChangeActor:X}");
}
ImGui.SameLine();
ImGui.TextUnformatted($"at {_lastStateChangeTime.ToLocalTime().TimeOfDay}");
ImUtf8.Text($"at {_lastStateChangeTime.ToLocalTime().TimeOfDay}");
}
private void OnStateChanged(nint actor, StateChangeType _)
private unsafe void PrintFinalizeName()
{
ImUtf8.Text(_lastStateFinalizeName.Span);
ImGui.SameLine(0, 0);
ImUtf8.Text($" ({_lastStateFinalizeType})");
ImGui.SameLine();
using (ImRaii.PushFont(UiBuilder.MonoFont))
{
ImUtf8.CopyOnClickSelectable($"0x{_lastStateFinalizeActor:X}");
}
ImGui.SameLine();
ImUtf8.Text($"at {_lastStateFinalizeTime.ToLocalTime().TimeOfDay}");
}
private void OnStateChanged(nint actor, StateChangeType type)
{
_lastStateChangeActor = actor;
_lastStateChangeTime = DateTime.UtcNow;
_lastStateChangeName = actor != nint.Zero ? ((Actor)actor).Utf8Name.Clone() : ByteString.Empty;
_lastStateChangeType = type;
}
private void OnStateFinalized(nint actor, StateFinalizationType type)
{
_lastStateFinalizeActor = actor;
_lastStateFinalizeTime = DateTime.UtcNow;
_lastStateFinalizeName = actor != nint.Zero ? ((Actor)actor).Utf8Name.Clone() : ByteString.Empty;
_lastStateFinalizeType = type;
}
private void OnGPoseChange(bool value)

View file

@ -460,7 +460,7 @@ public class DesignPanel
if (_state.GetOrCreate(id, data.Objects[0], out var state))
{
using var _ = _selector.Selected!.TemporarilyRestrictApplication(ApplicationCollection.FromKeys());
_state.ApplyDesign(state, _selector.Selected!, ApplySettings.ManualWithLinks with { SendStateUpdate = true });
_state.ApplyDesign(state, _selector.Selected!, ApplySettings.ManualWithLinks with { IsFinal = true });
}
}
@ -478,7 +478,7 @@ public class DesignPanel
if (_state.GetOrCreate(id, data.Objects[0], out var state))
{
using var _ = _selector.Selected!.TemporarilyRestrictApplication(ApplicationCollection.FromKeys());
_state.ApplyDesign(state, _selector.Selected!, ApplySettings.ManualWithLinks with { SendStateUpdate = true });
_state.ApplyDesign(state, _selector.Selected!, ApplySettings.ManualWithLinks with { IsFinal = true });
}
}

View file

@ -196,7 +196,7 @@ public class NpcPanel
if (_state.GetOrCreate(id, data.Objects[0], out var state))
{
var design = _converter.Convert(ToDesignData(), new StateMaterialManager(), ApplicationRules.NpcFromModifiers());
_state.ApplyDesign(state, design, ApplySettings.Manual with { SendStateUpdate = true });
_state.ApplyDesign(state, design, ApplySettings.Manual with { IsFinal = true });
}
}
@ -214,7 +214,7 @@ public class NpcPanel
if (_state.GetOrCreate(id, data.Objects[0], out var state))
{
var design = _converter.Convert(ToDesignData(), new StateMaterialManager(), ApplicationRules.NpcFromModifiers());
_state.ApplyDesign(state, design, ApplySettings.Manual with { SendStateUpdate = true });
_state.ApplyDesign(state, design, ApplySettings.Manual with { IsFinal = true });
}
}