Experimental option for non-async player applications

This commit is contained in:
Loporrit
2025-06-30 20:13:30 +00:00
parent 833fbd0e25
commit 8843add155
4 changed files with 49 additions and 14 deletions

View File

@@ -115,15 +115,26 @@ public sealed class IpcCallerGlamourer : DisposableMediatorSubscriberBase, IIpcC
} }
} }
public async Task ApplyAllAsync(ILogger logger, GameObjectHandler handler, string? customization, Guid applicationId, CancellationToken token, bool fireAndForget = false) public async Task ApplyAllAsync(ILogger logger, GameObjectHandler handler, string? customization, Guid applicationId, CancellationToken token, bool allowImmediate = false)
{ {
if (!APIAvailable || string.IsNullOrEmpty(customization) || _dalamudUtil.IsZoning) return; if (!APIAvailable || string.IsNullOrEmpty(customization) || _dalamudUtil.IsZoning) return;
// Call immediately if possible
if (allowImmediate && _dalamudUtil.IsOnFrameworkThread && !await handler.IsBeingDrawnRunOnFrameworkAsync().ConfigureAwait(false))
{
var gameObj = await _dalamudUtil.CreateGameObjectAsync(handler.Address).ConfigureAwait(false);
if (gameObj is ICharacter chara)
{
logger.LogDebug("[{appid}] Calling on IPC: GlamourerApplyAll", applicationId);
_glamourerApplyAll!.Invoke(customization, chara.ObjectIndex, LockCode);
return;
}
}
await _redrawManager.RedrawSemaphore.WaitAsync(token).ConfigureAwait(false); await _redrawManager.RedrawSemaphore.WaitAsync(token).ConfigureAwait(false);
try try
{ {
await _redrawManager.PenumbraRedrawInternalAsync(logger, handler, applicationId, (chara) => await _redrawManager.PenumbraRedrawInternalAsync(logger, handler, applicationId, (chara) =>
{ {
try try

View File

@@ -48,6 +48,7 @@ public class MareConfig : IMareConfiguration
public bool ShowOfflineUsersSeparately { get; set; } = true; public bool ShowOfflineUsersSeparately { get; set; } = true;
public bool ShowSyncshellOfflineUsersSeparately { get; set; } = true; public bool ShowSyncshellOfflineUsersSeparately { get; set; } = true;
public bool GroupUpSyncshells { get; set; } = true; public bool GroupUpSyncshells { get; set; } = true;
public bool SerialApplication { get; set; } = false;
public bool ShowOnlineNotifications { get; set; } = false; public bool ShowOnlineNotifications { get; set; } = false;
public bool ShowOnlineNotificationsOnlyForIndividualPairs { get; set; } = true; public bool ShowOnlineNotificationsOnlyForIndividualPairs { get; set; } = true;
public bool ShowOnlineNotificationsOnlyForNamedPairs { get; set; } = false; public bool ShowOnlineNotificationsOnlyForNamedPairs { get; set; } = false;

View File

@@ -388,19 +388,11 @@ public sealed class PairHandler : DisposableMediatorSubscriberBase
_ => throw new NotSupportedException("ObjectKind not supported: " + changes.Key) _ => throw new NotSupportedException("ObjectKind not supported: " + changes.Key)
}; };
try async Task processApplication(IEnumerable<PlayerChanges> changeList)
{ {
if (handler.Address == nint.Zero) foreach (var change in changeList)
{ {
return; Logger.LogDebug("[{applicationId}{ft}] Processing {change} for {handler}", applicationId, _dalamudUtil.IsOnFrameworkThread ? "*" : "", change, handler);
}
Logger.LogDebug("[{applicationId}] Applying Customization Data for {handler}", applicationId, handler);
await _dalamudUtil.WaitWhileCharacterIsDrawing(Logger, handler, applicationId, 30000, token).ConfigureAwait(false);
token.ThrowIfCancellationRequested();
foreach (var change in changes.Value.OrderBy(p => (int)p))
{
Logger.LogDebug("[{applicationId}] Processing {change} for {handler}", applicationId, change, handler);
switch (change) switch (change)
{ {
case PlayerChanges.Customize: case PlayerChanges.Customize:
@@ -426,7 +418,7 @@ public sealed class PairHandler : DisposableMediatorSubscriberBase
case PlayerChanges.Glamourer: case PlayerChanges.Glamourer:
if (charaData.GlamourerData.TryGetValue(changes.Key, out var glamourerData)) if (charaData.GlamourerData.TryGetValue(changes.Key, out var glamourerData))
{ {
await _ipcManager.Glamourer.ApplyAllAsync(Logger, handler, glamourerData, applicationId, token).ConfigureAwait(false); await _ipcManager.Glamourer.ApplyAllAsync(Logger, handler, glamourerData, applicationId, token, allowImmediate: true).ConfigureAwait(false);
} }
break; break;
@@ -448,6 +440,29 @@ public sealed class PairHandler : DisposableMediatorSubscriberBase
token.ThrowIfCancellationRequested(); token.ThrowIfCancellationRequested();
} }
} }
try
{
if (handler.Address == nint.Zero)
{
return;
}
Logger.LogDebug("[{applicationId}] Applying Customization Data for {handler}", applicationId, handler);
await _dalamudUtil.WaitWhileCharacterIsDrawing(Logger, handler, applicationId, 30000, token).ConfigureAwait(false);
token.ThrowIfCancellationRequested();
if (_configService.Current.SerialApplication)
{
var serialChangeList = changes.Value.Where(p => p <= PlayerChanges.ForcedRedraw).OrderBy(p => (int)p);
var asyncChangeList = changes.Value.Where(p => p > PlayerChanges.ForcedRedraw).OrderBy(p => (int)p);
await _dalamudUtil.RunOnFrameworkThread(async () => await processApplication(serialChangeList).ConfigureAwait(false)).ConfigureAwait(false);
await Task.Run(async () => await processApplication(asyncChangeList).ConfigureAwait(false), CancellationToken.None).ConfigureAwait(false);
}
else
{
_ = processApplication(changes.Value.OrderBy(p => (int)p));
}
}
finally finally
{ {
if (handler != _charaHandler) handler.Dispose(); if (handler != _charaHandler) handler.Dispose();

View File

@@ -635,6 +635,14 @@ public class SettingsUi : WindowMediatorSubscriberBase
_configService.Save(); _configService.Save();
} }
bool serializedApplications = _configService.Current.SerialApplication;
if (ImGui.Checkbox("Serialized player applications", ref serializedApplications))
{
_configService.Current.SerialApplication = serializedApplications;
_configService.Save();
}
_uiShared.DrawHelpText("Experimental - May reduce issues in crowded areas");
ImGui.Separator(); ImGui.Separator();
_uiShared.BigText("Debug"); _uiShared.BigText("Debug");
#if DEBUG #if DEBUG