Client rework for API change and paradigm shift (#39)
* most of the groups refactoring on client * register OnMethods for group stuff * start implementing client (still pretty broken) * finish implementing new api first iteration * idk rework everything for pair shit (still WIP); goal is to remove PairedClients and GroupPairClients from ApiController * move everything to PairManager, remove dictionaries from APiController * remove admin stuff from client, cleanup * adjust reconnection handling, add new settings, todo still to remove access from old stuff that's marked obsolete from config * add back adding servers, fix intro ui * fix obsolete calls * adjust config namespace * add UI for setting animation/sound permissions to syncshells * add ConfigurationService to hot reload config on change from external * move transient data cache to configuration * add deleting service to ui * fix saving of transient resources * fix group pair user assignments * halt scanner when penumbra inactive, add visible/online/offline split to individual pairs and tags * add presence to syncshell ui * move fullpause from config to server config * fixes in code style * more codestyle * show info icon on player in shells, don't show icon when no changes from default state are made, add online notifs * fixes to intro UI --------- Co-authored-by: rootdarkarchon <root.darkarchon@outlook.com>
This commit is contained in:
@@ -1,7 +1,5 @@
|
||||
using Dalamud.Plugin;
|
||||
using Dalamud.Plugin.Ipc;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Dalamud.Game.ClientState.Objects.Types;
|
||||
using MareSynchronos.Utils;
|
||||
using Action = System.Action;
|
||||
@@ -9,14 +7,11 @@ using System.Collections.Concurrent;
|
||||
using System.Text;
|
||||
using Penumbra.Api.Enums;
|
||||
using Penumbra.Api.Helpers;
|
||||
using System.Threading.Tasks;
|
||||
using MareSynchronos.Delegates;
|
||||
|
||||
namespace MareSynchronos.Managers;
|
||||
|
||||
public delegate void PenumbraRedrawEvent(IntPtr address, int objTblIdx);
|
||||
public delegate void HeelsOffsetChange(float change);
|
||||
public delegate void PenumbraResourceLoadEvent(IntPtr drawObject, string gamePath, string filePath);
|
||||
public delegate void CustomizePlusScaleChange(string? scale);
|
||||
|
||||
public class IpcManager : IDisposable
|
||||
{
|
||||
private readonly ICallGateSubscriber<int> _glamourerApiVersion;
|
||||
@@ -57,10 +52,10 @@ public class IpcManager : IDisposable
|
||||
private readonly ICallGateSubscriber<string?, object> _customizePlusOnScaleUpdate;
|
||||
|
||||
private readonly DalamudUtil _dalamudUtil;
|
||||
private bool inGposeQueueMode = false;
|
||||
private ConcurrentQueue<Action> actionQueue => inGposeQueueMode ? gposeActionQueue : normalQueue;
|
||||
private readonly ConcurrentQueue<Action> normalQueue = new();
|
||||
private readonly ConcurrentQueue<Action> gposeActionQueue = new();
|
||||
private bool _inGposeQueueMode = false;
|
||||
private ConcurrentQueue<Action> ActionQueue => _inGposeQueueMode ? _gposeActionQueue : _normalQueue;
|
||||
private readonly ConcurrentQueue<Action> _normalQueue = new();
|
||||
private readonly ConcurrentQueue<Action> _gposeActionQueue = new();
|
||||
|
||||
public IpcManager(DalamudPluginInterface pi, DalamudUtil dalamudUtil)
|
||||
{
|
||||
@@ -121,7 +116,7 @@ public class IpcManager : IDisposable
|
||||
|
||||
private void HandleGposeActionQueue()
|
||||
{
|
||||
if (gposeActionQueue.TryDequeue(out var action))
|
||||
if (_gposeActionQueue.TryDequeue(out var action))
|
||||
{
|
||||
if (action == null) return;
|
||||
Logger.Debug("Execution action in gpose queue: " + action.Method);
|
||||
@@ -131,7 +126,7 @@ public class IpcManager : IDisposable
|
||||
|
||||
public void ToggleGposeQueueMode(bool on)
|
||||
{
|
||||
inGposeQueueMode = on;
|
||||
_inGposeQueueMode = on;
|
||||
}
|
||||
|
||||
private void PenumbraModSettingChangedHandler()
|
||||
@@ -141,15 +136,15 @@ public class IpcManager : IDisposable
|
||||
|
||||
private void ClearActionQueue()
|
||||
{
|
||||
actionQueue.Clear();
|
||||
gposeActionQueue.Clear();
|
||||
ActionQueue.Clear();
|
||||
_gposeActionQueue.Clear();
|
||||
}
|
||||
|
||||
private void ResourceLoaded(IntPtr ptr, string arg1, string arg2)
|
||||
{
|
||||
Task.Run(() =>
|
||||
{
|
||||
if (ptr != IntPtr.Zero && string.Compare(arg1, arg2, true, System.Globalization.CultureInfo.InvariantCulture) != 0)
|
||||
if (ptr != IntPtr.Zero && string.Compare(arg1, arg2, ignoreCase: true, System.Globalization.CultureInfo.InvariantCulture) != 0)
|
||||
{
|
||||
PenumbraResourceLoadEvent?.Invoke(ptr, arg1, arg2);
|
||||
}
|
||||
@@ -158,7 +153,7 @@ public class IpcManager : IDisposable
|
||||
|
||||
private void HandleActionQueue()
|
||||
{
|
||||
if (actionQueue.TryDequeue(out var action))
|
||||
if (ActionQueue.TryDequeue(out var action))
|
||||
{
|
||||
if (action == null) return;
|
||||
Logger.Debug("Execution action in queue: " + action.Method);
|
||||
@@ -169,10 +164,10 @@ public class IpcManager : IDisposable
|
||||
public event VoidDelegate? PenumbraModSettingChanged;
|
||||
public event VoidDelegate? PenumbraInitialized;
|
||||
public event VoidDelegate? PenumbraDisposed;
|
||||
public event PenumbraRedrawEvent? PenumbraRedrawEvent;
|
||||
public event HeelsOffsetChange? HeelsOffsetChangeEvent;
|
||||
public event PenumbraResourceLoadEvent? PenumbraResourceLoadEvent;
|
||||
public event CustomizePlusScaleChange? CustomizePlusScaleChange;
|
||||
public event DrawObjectDelegate? PenumbraRedrawEvent;
|
||||
public event FloatDelegate? HeelsOffsetChangeEvent;
|
||||
public event PenumbraFileResourceDelegate? PenumbraResourceLoadEvent;
|
||||
public event StringDelegate? CustomizePlusScaleChange;
|
||||
|
||||
public bool Initialized => CheckPenumbraApi();
|
||||
public bool CheckGlamourerApi()
|
||||
@@ -228,11 +223,11 @@ public class IpcManager : IDisposable
|
||||
Logger.Verbose("Disposing " + nameof(IpcManager));
|
||||
|
||||
int totalSleepTime = 0;
|
||||
while (actionQueue.Count > 0 && totalSleepTime < 2000)
|
||||
while (!ActionQueue.IsEmpty && totalSleepTime < 2000)
|
||||
{
|
||||
Logger.Verbose("Waiting for actionqueue to clear...");
|
||||
HandleActionQueue();
|
||||
System.Threading.Thread.Sleep(16);
|
||||
Thread.Sleep(16);
|
||||
totalSleepTime += 16;
|
||||
}
|
||||
|
||||
@@ -244,7 +239,7 @@ public class IpcManager : IDisposable
|
||||
_dalamudUtil.FrameworkUpdate -= HandleActionQueue;
|
||||
_dalamudUtil.ZoneSwitchEnd -= ClearActionQueue;
|
||||
_dalamudUtil.GposeFrameworkUpdate -= HandleGposeActionQueue;
|
||||
actionQueue.Clear();
|
||||
ActionQueue.Clear();
|
||||
|
||||
_penumbraGameObjectResourcePathResolved.Dispose();
|
||||
_penumbraDispose.Dispose();
|
||||
@@ -263,7 +258,7 @@ public class IpcManager : IDisposable
|
||||
public void HeelsSetOffsetForPlayer(float offset, IntPtr character)
|
||||
{
|
||||
if (!CheckHeelsApi()) return;
|
||||
actionQueue.Enqueue(() =>
|
||||
ActionQueue.Enqueue(() =>
|
||||
{
|
||||
var gameObj = _dalamudUtil.CreateGameObject(character);
|
||||
if (gameObj != null)
|
||||
@@ -277,7 +272,7 @@ public class IpcManager : IDisposable
|
||||
public void HeelsRestoreOffsetForPlayer(IntPtr character)
|
||||
{
|
||||
if (!CheckHeelsApi()) return;
|
||||
actionQueue.Enqueue(() =>
|
||||
ActionQueue.Enqueue(() =>
|
||||
{
|
||||
var gameObj = _dalamudUtil.CreateGameObject(character);
|
||||
if (gameObj != null)
|
||||
@@ -299,7 +294,7 @@ public class IpcManager : IDisposable
|
||||
public void CustomizePlusSetBodyScale(IntPtr character, string scale)
|
||||
{
|
||||
if (!CheckCustomizePlusApi() || string.IsNullOrEmpty(scale)) return;
|
||||
actionQueue.Enqueue(() =>
|
||||
ActionQueue.Enqueue(() =>
|
||||
{
|
||||
var gameObj = _dalamudUtil.CreateGameObject(character);
|
||||
if (gameObj is Character c)
|
||||
@@ -314,7 +309,7 @@ public class IpcManager : IDisposable
|
||||
public void CustomizePlusRevert(IntPtr character)
|
||||
{
|
||||
if (!CheckCustomizePlusApi()) return;
|
||||
actionQueue.Enqueue(() =>
|
||||
ActionQueue.Enqueue(() =>
|
||||
{
|
||||
var gameObj = _dalamudUtil.CreateGameObject(character);
|
||||
if (gameObj is Character c)
|
||||
@@ -328,7 +323,7 @@ public class IpcManager : IDisposable
|
||||
public void GlamourerApplyAll(string? customization, IntPtr obj)
|
||||
{
|
||||
if (!CheckGlamourerApi() || string.IsNullOrEmpty(customization)) return;
|
||||
actionQueue.Enqueue(() =>
|
||||
ActionQueue.Enqueue(() =>
|
||||
{
|
||||
var gameObj = _dalamudUtil.CreateGameObject(obj);
|
||||
if (gameObj is Character c)
|
||||
@@ -342,7 +337,7 @@ public class IpcManager : IDisposable
|
||||
public void GlamourerApplyOnlyEquipment(string customization, IntPtr character)
|
||||
{
|
||||
if (!CheckGlamourerApi() || string.IsNullOrEmpty(customization)) return;
|
||||
actionQueue.Enqueue(() =>
|
||||
ActionQueue.Enqueue(() =>
|
||||
{
|
||||
var gameObj = _dalamudUtil.CreateGameObject(character);
|
||||
if (gameObj is Character c)
|
||||
@@ -356,7 +351,7 @@ public class IpcManager : IDisposable
|
||||
public void GlamourerApplyOnlyCustomization(string customization, IntPtr character)
|
||||
{
|
||||
if (!CheckGlamourerApi() || string.IsNullOrEmpty(customization)) return;
|
||||
actionQueue.Enqueue(() =>
|
||||
ActionQueue.Enqueue(() =>
|
||||
{
|
||||
var gameObj = _dalamudUtil.CreateGameObject(character);
|
||||
if (gameObj is Character c)
|
||||
@@ -393,7 +388,7 @@ public class IpcManager : IDisposable
|
||||
public void GlamourerRevertCharacterCustomization(GameObject character)
|
||||
{
|
||||
if (!CheckGlamourerApi()) return;
|
||||
actionQueue.Enqueue(() => _glamourerRevertCustomization!.InvokeAction(character));
|
||||
ActionQueue.Enqueue(() => _glamourerRevertCustomization!.InvokeAction(character));
|
||||
}
|
||||
|
||||
public string PenumbraGetMetaManipulations()
|
||||
@@ -411,7 +406,7 @@ public class IpcManager : IDisposable
|
||||
public void PenumbraRedraw(IntPtr obj)
|
||||
{
|
||||
if (!CheckPenumbraApi()) return;
|
||||
actionQueue.Enqueue(() =>
|
||||
ActionQueue.Enqueue(() =>
|
||||
{
|
||||
var gameObj = _dalamudUtil.CreateGameObject(obj);
|
||||
if (gameObj != null)
|
||||
@@ -425,13 +420,13 @@ public class IpcManager : IDisposable
|
||||
public void PenumbraRedraw(string actorName)
|
||||
{
|
||||
if (!CheckPenumbraApi()) return;
|
||||
actionQueue.Enqueue(() => _penumbraRedraw!.Invoke(actorName, RedrawType.Redraw));
|
||||
ActionQueue.Enqueue(() => _penumbraRedraw!.Invoke(actorName, RedrawType.Redraw));
|
||||
}
|
||||
|
||||
public void PenumbraRemoveTemporaryCollection(string characterName)
|
||||
{
|
||||
if (!CheckPenumbraApi()) return;
|
||||
actionQueue.Enqueue(() =>
|
||||
ActionQueue.Enqueue(() =>
|
||||
{
|
||||
var collName = "Mare_" + characterName;
|
||||
Logger.Verbose("Removing temp collection for " + collName);
|
||||
@@ -464,7 +459,7 @@ public class IpcManager : IDisposable
|
||||
{
|
||||
if (!CheckPenumbraApi()) return;
|
||||
|
||||
actionQueue.Enqueue(() =>
|
||||
ActionQueue.Enqueue(() =>
|
||||
{
|
||||
var idx = _dalamudUtil.GetIndexFromObjectTableByName(characterName);
|
||||
if (idx == null)
|
||||
@@ -474,7 +469,7 @@ public class IpcManager : IDisposable
|
||||
var collName = "Mare_" + characterName;
|
||||
var ret = _penumbraCreateNamedTemporaryCollection.Invoke(collName);
|
||||
Logger.Verbose("Creating Temp Collection " + collName + ", Success: " + ret);
|
||||
var retAssign = _penumbraAssignTemporaryCollection.Invoke(collName, idx.Value, true);
|
||||
var retAssign = _penumbraAssignTemporaryCollection.Invoke(collName, idx.Value, c: true);
|
||||
Logger.Verbose("Assigning Temp Collection " + collName + " to index " + idx.Value);
|
||||
foreach (var mod in modPaths)
|
||||
{
|
||||
@@ -511,6 +506,6 @@ public class IpcManager : IDisposable
|
||||
private void PenumbraDispose()
|
||||
{
|
||||
PenumbraDisposed?.Invoke();
|
||||
actionQueue.Clear();
|
||||
ActionQueue.Clear();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user