mirror of
https://github.com/Caraxi/mare.client.git
synced 2025-12-12 21:37:22 +01:00
Mare 0.9 (#65)
* add jwt expiry * start of 0.9 api impl * some stuff idk * some more impl * some cleanup * remove grouppair, add configuration, rework some pair drawing stuff * do some stuff * rework some ui * I don't even know anymore * add cancellationtoken * token bla * ui fixes etc * probably individual adding/removing now working fully as expected * add working report popup * I guess it's more syncshell shit or so * popup shit idk * work out most of the syncshell bullshit I guess * delete some old crap * are we actually getting closer to the end * update pair info stuff * more fixes/adjustments, idk * refactor some things * some rework * some more cleanup * cleanup * make menu buttons w i d e * better icon text buttons * add all syncshell folder and ordering fixes --------- Co-authored-by: rootdarkarchon <root.darkarchon@outlook.com>
This commit is contained in:
parent
f15b8f6bbd
commit
14575a4a6b
111 changed files with 3456 additions and 3174 deletions
|
|
@ -8,8 +8,8 @@ namespace MareSynchronos.Interop;
|
|||
internal sealed class DalamudLogger : ILogger
|
||||
{
|
||||
private readonly MareConfigService _mareConfigService;
|
||||
private readonly IPluginLog _pluginLog;
|
||||
private readonly string _name;
|
||||
private readonly IPluginLog _pluginLog;
|
||||
|
||||
public DalamudLogger(string name, MareConfigService mareConfigService, IPluginLog pluginLog)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,8 +1,9 @@
|
|||
using System.Collections.Concurrent;
|
||||
using Dalamud.Plugin.Services;
|
||||
using Dalamud.Plugin.Services;
|
||||
using MareSynchronos.MareConfiguration;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
using System.Collections.Concurrent;
|
||||
|
||||
namespace MareSynchronos.Interop;
|
||||
|
||||
[ProviderAlias("Dalamud")]
|
||||
|
|
@ -32,7 +33,7 @@ public sealed class DalamudLoggingProvider : ILoggerProvider
|
|||
catName = string.Join("", Enumerable.Range(0, 15 - catName.Length).Select(_ => " ")) + catName;
|
||||
}
|
||||
|
||||
return _loggers.GetOrAdd(catName, name => new DalamudLogger(catName, _mareConfigService, _pluginLog));
|
||||
return _loggers.GetOrAdd(catName, name => new DalamudLogger(name, _mareConfigService, _pluginLog));
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
|
|
|
|||
|
|
@ -1,24 +1,22 @@
|
|||
using Dalamud.Plugin;
|
||||
using Dalamud.Plugin.Ipc;
|
||||
using Dalamud.Game.ClientState.Objects.SubKinds;
|
||||
using Dalamud.Game.ClientState.Objects.SubKinds;
|
||||
using Dalamud.Game.ClientState.Objects.Types;
|
||||
using System.Collections.Concurrent;
|
||||
using System.Text;
|
||||
using Dalamud.Interface.Internal.Notifications;
|
||||
using Dalamud.Plugin;
|
||||
using Dalamud.Plugin.Ipc;
|
||||
using Dalamud.Utility;
|
||||
using MareSynchronos.PlayerData.Handlers;
|
||||
using MareSynchronos.Services;
|
||||
using MareSynchronos.Services.Mediator;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Penumbra.Api.Enums;
|
||||
using Penumbra.Api.Helpers;
|
||||
using Dalamud.Interface.Internal.Notifications;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using MareSynchronos.PlayerData.Handlers;
|
||||
using MareSynchronos.Services.Mediator;
|
||||
using MareSynchronos.Services;
|
||||
using Dalamud.Utility;
|
||||
using System.Collections.Concurrent;
|
||||
using System.Text;
|
||||
|
||||
namespace MareSynchronos.Interop;
|
||||
|
||||
public sealed class IpcManager : DisposableMediatorSubscriberBase
|
||||
{
|
||||
private readonly uint LockCode = 0x6D617265;
|
||||
|
||||
private readonly ICallGateSubscriber<(int, int)> _customizePlusApiVersion;
|
||||
private readonly ICallGateSubscriber<Character?, string?> _customizePlusGetBodyScale;
|
||||
private readonly ICallGateSubscriber<string?, string?, object> _customizePlusOnScaleUpdate;
|
||||
|
|
@ -51,6 +49,7 @@ public sealed class IpcManager : DisposableMediatorSubscriberBase
|
|||
private readonly FuncSubscriber<string, string, Dictionary<string, string>, string, int, PenumbraApiEc> _penumbraAddTemporaryMod;
|
||||
private readonly FuncSubscriber<(int, int)> _penumbraApiVersion;
|
||||
private readonly FuncSubscriber<string, int, bool, PenumbraApiEc> _penumbraAssignTemporaryCollection;
|
||||
private readonly FuncSubscriber<string, string, TextureType, bool, Task> _penumbraConvertTextureFile;
|
||||
private readonly FuncSubscriber<string, PenumbraApiEc> _penumbraCreateNamedTemporaryCollection;
|
||||
private readonly EventSubscriber _penumbraDispose;
|
||||
private readonly FuncSubscriber<bool> _penumbraEnabled;
|
||||
|
|
@ -58,7 +57,6 @@ public sealed class IpcManager : DisposableMediatorSubscriberBase
|
|||
private readonly FuncSubscriber<string> _penumbraGetMetaManipulations;
|
||||
private readonly EventSubscriber _penumbraInit;
|
||||
private readonly EventSubscriber<ModSettingChange, string, string, bool> _penumbraModSettingChanged;
|
||||
private readonly FuncSubscriber<string, string, TextureType, bool, Task> _penumbraConvertTextureFile;
|
||||
private readonly EventSubscriber<nint, int> _penumbraObjectIsRedrawn;
|
||||
private readonly ActionSubscriber<string, RedrawType> _penumbraRedraw;
|
||||
private readonly ActionSubscriber<GameObject, RedrawType> _penumbraRedrawObject;
|
||||
|
|
@ -69,6 +67,7 @@ public sealed class IpcManager : DisposableMediatorSubscriberBase
|
|||
private readonly FuncSubscriber<string[], string[], (string[], string[][])> _penumbraResolvePaths;
|
||||
private readonly ParamsFuncSubscriber<ushort, IReadOnlyDictionary<string, string[]>?[]> _penumbraResourcePaths;
|
||||
private readonly SemaphoreSlim _redrawSemaphore = new(2);
|
||||
private readonly uint LockCode = 0x6D617265;
|
||||
private bool _customizePlusAvailable = false;
|
||||
private CancellationTokenSource _disposalCts = new();
|
||||
private bool _glamourerAvailable = false;
|
||||
|
|
@ -253,7 +252,6 @@ public sealed class IpcManager : DisposableMediatorSubscriberBase
|
|||
{
|
||||
logger.LogWarning("[{appid}] Failed to apply Glamourer data", applicationId);
|
||||
}
|
||||
|
||||
}).ConfigureAwait(false);
|
||||
}
|
||||
finally
|
||||
|
|
@ -262,52 +260,6 @@ public sealed class IpcManager : DisposableMediatorSubscriberBase
|
|||
}
|
||||
}
|
||||
|
||||
public async Task GlamourerRevert(ILogger logger, GameObjectHandler handler, Guid applicationId, CancellationToken token)
|
||||
{
|
||||
if ((!CheckGlamourerApi()) || _dalamudUtil.IsZoning) return;
|
||||
try
|
||||
{
|
||||
await _redrawSemaphore.WaitAsync(token).ConfigureAwait(false);
|
||||
await PenumbraRedrawInternalAsync(logger, handler, applicationId, (chara) =>
|
||||
{
|
||||
try
|
||||
{
|
||||
logger.LogDebug("[{appid}] Calling On IPC: GlamourerUnlockName", applicationId);
|
||||
_glamourerUnlock.InvokeFunc(handler.Name, LockCode);
|
||||
logger.LogDebug("[{appid}] Calling On IPC: GlamourerRevert", applicationId);
|
||||
_glamourerRevert.InvokeAction(chara, LockCode);
|
||||
logger.LogDebug("[{appid}] Calling On IPC: PenumbraRedraw", applicationId);
|
||||
_penumbraRedrawObject.Invoke(chara, RedrawType.AfterGPose);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
logger.LogWarning(ex, "[{appid}] Error during GlamourerRevert", applicationId);
|
||||
}
|
||||
|
||||
}).ConfigureAwait(false);
|
||||
}
|
||||
finally
|
||||
{
|
||||
_redrawSemaphore.Release();
|
||||
}
|
||||
}
|
||||
|
||||
public void GlamourerRevertByName(ILogger logger, string name, Guid applicationId)
|
||||
{
|
||||
if ((!CheckGlamourerApi()) || _dalamudUtil.IsZoning) return;
|
||||
try
|
||||
{
|
||||
logger.LogDebug("[{appid}] Calling On IPC: GlamourerRevertByName", applicationId);
|
||||
_glamourerRevertByName.InvokeAction(name, LockCode);
|
||||
logger.LogDebug("[{appid}] Calling On IPC: GlamourerUnlockName", applicationId);
|
||||
_glamourerUnlock.InvokeFunc(name, LockCode);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logger.LogWarning(ex, "Error during Glamourer RevertByName");
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<string> GlamourerGetCharacterCustomizationAsync(IntPtr character)
|
||||
{
|
||||
if (!CheckGlamourerApi()) return string.Empty;
|
||||
|
|
@ -334,6 +286,51 @@ public sealed class IpcManager : DisposableMediatorSubscriberBase
|
|||
}
|
||||
}
|
||||
|
||||
public async Task GlamourerRevert(ILogger logger, GameObjectHandler handler, Guid applicationId, CancellationToken token)
|
||||
{
|
||||
if ((!CheckGlamourerApi()) || _dalamudUtil.IsZoning) return;
|
||||
try
|
||||
{
|
||||
await _redrawSemaphore.WaitAsync(token).ConfigureAwait(false);
|
||||
await PenumbraRedrawInternalAsync(logger, handler, applicationId, (chara) =>
|
||||
{
|
||||
try
|
||||
{
|
||||
logger.LogDebug("[{appid}] Calling On IPC: GlamourerUnlockName", applicationId);
|
||||
_glamourerUnlock.InvokeFunc(handler.Name, LockCode);
|
||||
logger.LogDebug("[{appid}] Calling On IPC: GlamourerRevert", applicationId);
|
||||
_glamourerRevert.InvokeAction(chara, LockCode);
|
||||
logger.LogDebug("[{appid}] Calling On IPC: PenumbraRedraw", applicationId);
|
||||
_penumbraRedrawObject.Invoke(chara, RedrawType.AfterGPose);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
logger.LogWarning(ex, "[{appid}] Error during GlamourerRevert", applicationId);
|
||||
}
|
||||
}).ConfigureAwait(false);
|
||||
}
|
||||
finally
|
||||
{
|
||||
_redrawSemaphore.Release();
|
||||
}
|
||||
}
|
||||
|
||||
public void GlamourerRevertByName(ILogger logger, string name, Guid applicationId)
|
||||
{
|
||||
if ((!CheckGlamourerApi()) || _dalamudUtil.IsZoning) return;
|
||||
try
|
||||
{
|
||||
logger.LogDebug("[{appid}] Calling On IPC: GlamourerRevertByName", applicationId);
|
||||
_glamourerRevertByName.InvokeAction(name, LockCode);
|
||||
logger.LogDebug("[{appid}] Calling On IPC: GlamourerUnlockName", applicationId);
|
||||
_glamourerUnlock.InvokeFunc(name, LockCode);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logger.LogWarning(ex, "Error during Glamourer RevertByName");
|
||||
}
|
||||
}
|
||||
|
||||
public async Task HeelsRestoreOffsetForPlayerAsync(IntPtr character)
|
||||
{
|
||||
if (!CheckHeelsApi()) return;
|
||||
|
|
@ -469,6 +466,46 @@ public sealed class IpcManager : DisposableMediatorSubscriberBase
|
|||
}).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
public async Task PenumbraConvertTextureFiles(ILogger logger, Dictionary<string, string[]> textures, IProgress<(string, int)> progress, CancellationToken token)
|
||||
{
|
||||
if (!CheckPenumbraApi()) return;
|
||||
|
||||
Mediator.Publish(new HaltScanMessage("TextureConversion"));
|
||||
int currentTexture = 0;
|
||||
foreach (var texture in textures)
|
||||
{
|
||||
if (token.IsCancellationRequested) break;
|
||||
|
||||
progress.Report((texture.Key, ++currentTexture));
|
||||
|
||||
logger.LogInformation("Converting Texture {path} to {type}", texture.Key, TextureType.Bc7Tex);
|
||||
var convertTask = _penumbraConvertTextureFile.Invoke(texture.Key, texture.Key, TextureType.Bc7Tex, d: true);
|
||||
await convertTask.ConfigureAwait(false);
|
||||
if (convertTask.IsCompletedSuccessfully && texture.Value.Any())
|
||||
{
|
||||
foreach (var duplicatedTexture in texture.Value)
|
||||
{
|
||||
logger.LogInformation("Migrating duplicate {dup}", duplicatedTexture);
|
||||
try
|
||||
{
|
||||
File.Copy(texture.Key, duplicatedTexture, overwrite: true);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
logger.LogError(ex, "Failed to copy duplicate {dup}", duplicatedTexture);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Mediator.Publish(new ResumeScanMessage("TextureConversion"));
|
||||
|
||||
await _dalamudUtil.RunOnFrameworkThread(async () =>
|
||||
{
|
||||
var gameObject = await _dalamudUtil.CreateGameObjectAsync(await _dalamudUtil.GetPlayerPointerAsync().ConfigureAwait(false)).ConfigureAwait(false);
|
||||
_penumbraRedrawObject.Invoke(gameObject!, RedrawType.Redraw);
|
||||
}).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
public async Task<string> PenumbraCreateTemporaryCollectionAsync(ILogger logger, string uid)
|
||||
{
|
||||
if (!CheckPenumbraApi()) return string.Empty;
|
||||
|
|
@ -482,6 +519,19 @@ public sealed class IpcManager : DisposableMediatorSubscriberBase
|
|||
}).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
public async Task<IReadOnlyDictionary<string, string[]>?[]?> PenumbraGetCharacterData(ILogger logger, GameObjectHandler handler)
|
||||
{
|
||||
if (!CheckPenumbraApi()) return null;
|
||||
|
||||
return await _dalamudUtil.RunOnFrameworkThread(() =>
|
||||
{
|
||||
logger.LogTrace("Calling On IPC: Penumbra.GetGameObjectResourcePaths");
|
||||
var idx = handler.GetGameObject()?.ObjectIndex;
|
||||
if (idx == null) return null;
|
||||
return _penumbraResourcePaths.Invoke(idx.Value);
|
||||
}).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
public string PenumbraGetMetaManipulations()
|
||||
{
|
||||
if (!CheckPenumbraApi()) return string.Empty;
|
||||
|
|
@ -529,7 +579,7 @@ public sealed class IpcManager : DisposableMediatorSubscriberBase
|
|||
await _dalamudUtil.RunOnFrameworkThread(() =>
|
||||
{
|
||||
logger.LogTrace("[{applicationId}] Manip: {data}", applicationId, manipulationData);
|
||||
var retAdd = _penumbraAddTemporaryMod.Invoke("MareChara_Meta", collName, new Dictionary<string, string>(), manipulationData, 0);
|
||||
var retAdd = _penumbraAddTemporaryMod.Invoke("MareChara_Meta", collName, [], manipulationData, 0);
|
||||
logger.LogTrace("[{applicationId}] Setting temp meta mod for {collName}, Success: {ret}", applicationId, collName, retAdd);
|
||||
}).ConfigureAwait(false);
|
||||
}
|
||||
|
|
@ -551,59 +601,6 @@ public sealed class IpcManager : DisposableMediatorSubscriberBase
|
|||
}).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
public async Task PenumbraConvertTextureFiles(ILogger logger, Dictionary<string, string[]> textures, IProgress<(string, int)> progress, CancellationToken token)
|
||||
{
|
||||
if (!CheckPenumbraApi()) return;
|
||||
|
||||
Mediator.Publish(new HaltScanMessage("TextureConversion"));
|
||||
int currentTexture = 0;
|
||||
foreach (var texture in textures)
|
||||
{
|
||||
if (token.IsCancellationRequested) break;
|
||||
|
||||
progress.Report((texture.Key, ++currentTexture));
|
||||
|
||||
logger.LogInformation("Converting Texture {path} to {type}", texture.Key, TextureType.Bc7Tex);
|
||||
var convertTask = _penumbraConvertTextureFile.Invoke(texture.Key, texture.Key, TextureType.Bc7Tex, true);
|
||||
await convertTask.ConfigureAwait(false);
|
||||
if (convertTask.IsCompletedSuccessfully && texture.Value.Any())
|
||||
{
|
||||
foreach (var duplicatedTexture in texture.Value)
|
||||
{
|
||||
logger.LogInformation("Migrating duplicate {dup}", duplicatedTexture);
|
||||
try
|
||||
{
|
||||
File.Copy(texture.Key, duplicatedTexture, true);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
logger.LogError(ex, "Failed to copy duplicate {dup}", duplicatedTexture);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Mediator.Publish(new ResumeScanMessage("TextureConversion"));
|
||||
|
||||
await _dalamudUtil.RunOnFrameworkThread(async () =>
|
||||
{
|
||||
var gameObject = await _dalamudUtil.CreateGameObjectAsync(await _dalamudUtil.GetPlayerPointerAsync().ConfigureAwait(false)).ConfigureAwait(false);
|
||||
_penumbraRedrawObject.Invoke(gameObject!, RedrawType.Redraw);
|
||||
}).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
public async Task<IReadOnlyDictionary<string, string[]>?[]?> PenumbraGetCharacterData(ILogger logger, GameObjectHandler handler)
|
||||
{
|
||||
if (!CheckPenumbraApi()) return null;
|
||||
|
||||
return await _dalamudUtil.RunOnFrameworkThread(() =>
|
||||
{
|
||||
logger.LogTrace("Calling On IPC: Penumbra.GetGameObjectResourcePaths");
|
||||
var idx = handler.GetGameObject()?.ObjectIndex;
|
||||
if (idx == null) return null;
|
||||
return _penumbraResourcePaths.Invoke(idx.Value);
|
||||
}).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
base.Dispose(disposing);
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ using FFXIVClientStructs.FFXIV.Client.Graphics.Render;
|
|||
using FFXIVClientStructs.FFXIV.Client.System.Resource.Handle;
|
||||
|
||||
namespace MareSynchronos.Interop;
|
||||
|
||||
#pragma warning disable MA0048
|
||||
[StructLayout(LayoutKind.Explicit)]
|
||||
public unsafe struct RenderModel
|
||||
{
|
||||
|
|
@ -25,7 +25,6 @@ public unsafe struct RenderModel
|
|||
[FieldOffset(0x60)]
|
||||
public int BoneListCount;
|
||||
|
||||
|
||||
[FieldOffset(0x98)]
|
||||
public void** Materials;
|
||||
|
||||
|
|
@ -47,3 +46,4 @@ public unsafe struct WeaponDrawObject
|
|||
{
|
||||
[FieldOffset(0x00)] public RenderModel* RenderModel;
|
||||
}
|
||||
#pragma warning restore MA0048
|
||||
Loading…
Add table
Add a link
Reference in a new issue