Compare commits
19 Commits
fe731ff670
...
2.0
| Author | SHA1 | Date | |
|---|---|---|---|
|
d777dc599f
|
|||
|
e3d9300ca3
|
|||
|
699678f641
|
|||
|
7a391e6253
|
|||
|
620ebf9195
|
|||
|
8cc4f34c55
|
|||
|
513845b811
|
|||
|
84586cac3d
|
|||
|
b4108c7803
|
|||
|
d891dceb28
|
|||
|
89fa1a999f
|
|||
|
1f6e86ec2d
|
|||
|
d225a3844a
|
|||
|
d4a46910f9
|
|||
|
b59a579f56
|
|||
|
7706ef1fa7
|
|||
|
fca730557e
|
|||
|
6572fdcc27
|
|||
|
bf770f19d9
|
3
.gitignore
vendored
3
.gitignore
vendored
@@ -3,6 +3,7 @@
|
||||
##
|
||||
## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
|
||||
.idea
|
||||
qodana.yaml
|
||||
# User-specific files
|
||||
*.rsuser
|
||||
*.suo
|
||||
@@ -13,6 +14,8 @@
|
||||
MareSynchronos/.DS_Store
|
||||
*.zip
|
||||
UmbraServer_extracted/
|
||||
NuGet.config
|
||||
Directory.Build.props
|
||||
|
||||
# User-specific files (MonoDevelop/Xamarin Studio)
|
||||
*.userprefs
|
||||
|
||||
Submodule Glamourer.Api updated: 54c1944dc7...59a7ab5fa9
2
MareAPI
2
MareAPI
Submodule MareAPI updated: fa9b7bce43...d105d20507
@@ -1,4 +1,5 @@
|
||||
using MareSynchronos.Interop.Ipc;
|
||||
using System;
|
||||
using MareSynchronos.Interop.Ipc;
|
||||
using MareSynchronos.MareConfiguration;
|
||||
using MareSynchronos.Services;
|
||||
using MareSynchronos.Services.Mediator;
|
||||
@@ -606,14 +607,35 @@ public sealed class CacheMonitor : DisposableMediatorSubscriberBase
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
base.Dispose(disposing);
|
||||
_scanCancellationTokenSource?.Cancel();
|
||||
try
|
||||
{
|
||||
_scanCancellationTokenSource.Cancel();
|
||||
}
|
||||
catch (ObjectDisposedException)
|
||||
{
|
||||
}
|
||||
_scanCancellationTokenSource.Dispose();
|
||||
PenumbraWatcher?.Dispose();
|
||||
MareWatcher?.Dispose();
|
||||
SubstWatcher?.Dispose();
|
||||
_penumbraFswCts?.CancelDispose();
|
||||
_mareFswCts?.CancelDispose();
|
||||
_substFswCts?.CancelDispose();
|
||||
_periodicCalculationTokenSource?.CancelDispose();
|
||||
TryCancelAndDispose(_penumbraFswCts);
|
||||
TryCancelAndDispose(_mareFswCts);
|
||||
TryCancelAndDispose(_substFswCts);
|
||||
TryCancelAndDispose(_periodicCalculationTokenSource);
|
||||
}
|
||||
|
||||
private static void TryCancelAndDispose(CancellationTokenSource? cts)
|
||||
{
|
||||
if (cts == null) return;
|
||||
try
|
||||
{
|
||||
cts.Cancel();
|
||||
}
|
||||
catch (ObjectDisposedException)
|
||||
{
|
||||
}
|
||||
|
||||
cts.Dispose();
|
||||
}
|
||||
|
||||
private void FullFileScan(CancellationToken ct)
|
||||
|
||||
@@ -12,7 +12,7 @@ public sealed class FileCompactor
|
||||
|
||||
private readonly Dictionary<string, int> _clusterSizes;
|
||||
|
||||
private readonly WOF_FILE_COMPRESSION_INFO_V1 _efInfo;
|
||||
private readonly WofFileCompressionInfoV1 _efInfo;
|
||||
private readonly ILogger<FileCompactor> _logger;
|
||||
|
||||
private readonly MareConfigService _mareConfigService;
|
||||
@@ -24,7 +24,7 @@ public sealed class FileCompactor
|
||||
_logger = logger;
|
||||
_mareConfigService = mareConfigService;
|
||||
_dalamudUtilService = dalamudUtilService;
|
||||
_efInfo = new WOF_FILE_COMPRESSION_INFO_V1
|
||||
_efInfo = new WofFileCompressionInfoV1
|
||||
{
|
||||
Algorithm = CompressionAlgorithm.XPRESS8K,
|
||||
Flags = 0
|
||||
@@ -123,7 +123,7 @@ public sealed class FileCompactor
|
||||
out uint lpTotalNumberOfClusters);
|
||||
|
||||
[DllImport("WoFUtil.dll")]
|
||||
private static extern int WofIsExternalFile([MarshalAs(UnmanagedType.LPWStr)] string Filepath, out int IsExternalFile, out uint Provider, out WOF_FILE_COMPRESSION_INFO_V1 Info, ref uint BufferLength);
|
||||
private static extern int WofIsExternalFile([MarshalAs(UnmanagedType.LPWStr)] string Filepath, out int IsExternalFile, out uint Provider, out WofFileCompressionInfoV1 Info, ref uint BufferLength);
|
||||
|
||||
[DllImport("WofUtil.dll")]
|
||||
private static extern int WofSetFileDataLocation(IntPtr FileHandle, ulong Provider, IntPtr ExternalFileInfo, ulong Length);
|
||||
@@ -242,7 +242,7 @@ public sealed class FileCompactor
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
private struct WOF_FILE_COMPRESSION_INFO_V1
|
||||
private struct WofFileCompressionInfoV1
|
||||
{
|
||||
public CompressionAlgorithm Algorithm;
|
||||
public ulong Flags;
|
||||
|
||||
@@ -17,8 +17,8 @@ namespace MareSynchronos.Interop;
|
||||
|
||||
public record ChatChannelOverride
|
||||
{
|
||||
public string ChannelName = string.Empty;
|
||||
public Action<byte[]>? ChatMessageHandler;
|
||||
public string ChannelName { get; set; } = string.Empty;
|
||||
public Action<byte[]>? ChatMessageHandler { get; set; }
|
||||
}
|
||||
|
||||
public unsafe sealed class GameChatHooks : IDisposable
|
||||
|
||||
@@ -31,11 +31,11 @@ public class MdlFile
|
||||
public ushort Unknown9;
|
||||
|
||||
// Offsets are stored relative to RuntimeSize instead of file start.
|
||||
public uint[] VertexOffset = [0, 0, 0];
|
||||
public uint[] IndexOffset = [0, 0, 0];
|
||||
public uint[] VertexOffset;
|
||||
public uint[] IndexOffset;
|
||||
|
||||
public uint[] VertexBufferSize = [0, 0, 0];
|
||||
public uint[] IndexBufferSize = [0, 0, 0];
|
||||
public uint[] VertexBufferSize;
|
||||
public uint[] IndexBufferSize;
|
||||
public byte LodCount;
|
||||
public bool EnableIndexBufferStreaming;
|
||||
public bool EnableEdgeGeometry;
|
||||
@@ -43,15 +43,26 @@ public class MdlFile
|
||||
public ModelFlags1 Flags1;
|
||||
public ModelFlags2 Flags2;
|
||||
|
||||
public VertexDeclarationStruct[] VertexDeclarations = [];
|
||||
public ElementIdStruct[] ElementIds = [];
|
||||
public MeshStruct[] Meshes = [];
|
||||
public BoundingBoxStruct[] BoneBoundingBoxes = [];
|
||||
public LodStruct[] Lods = [];
|
||||
public ExtraLodStruct[] ExtraLods = [];
|
||||
public VertexDeclarationStruct[] VertexDeclarations;
|
||||
public ElementIdStruct[] ElementIds;
|
||||
public MeshStruct[] Meshes;
|
||||
public BoundingBoxStruct[] BoneBoundingBoxes;
|
||||
public LodStruct[] Lods;
|
||||
public ExtraLodStruct[] ExtraLods;
|
||||
|
||||
public MdlFile(string filePath)
|
||||
{
|
||||
VertexOffset = Array.Empty<uint>();
|
||||
IndexOffset = Array.Empty<uint>();
|
||||
VertexBufferSize = Array.Empty<uint>();
|
||||
IndexBufferSize = Array.Empty<uint>();
|
||||
VertexDeclarations = Array.Empty<VertexDeclarationStruct>();
|
||||
ElementIds = Array.Empty<ElementIdStruct>();
|
||||
Meshes = Array.Empty<MeshStruct>();
|
||||
BoneBoundingBoxes = Array.Empty<BoundingBoxStruct>();
|
||||
Lods = Array.Empty<LodStruct>();
|
||||
ExtraLods = Array.Empty<ExtraLodStruct>();
|
||||
|
||||
using var stream = new FileStream(filePath, FileMode.Open, FileAccess.Read);
|
||||
using var r = new LuminaBinaryReader(stream);
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using Dalamud.Game.ClientState.Objects.Types;
|
||||
using System;
|
||||
using Dalamud.Plugin;
|
||||
using Dalamud.Plugin.Ipc;
|
||||
using MareSynchronos.MareConfiguration;
|
||||
@@ -29,7 +30,7 @@ public class IpcProvider : IHostedService, IMediatorSubscriber
|
||||
private bool _marePluginEnabled = false;
|
||||
private bool _impersonating = false;
|
||||
private DateTime _unregisterTime = DateTime.UtcNow;
|
||||
private CancellationTokenSource _registerDelayCts = new();
|
||||
private CancellationTokenSource? _registerDelayCts = new();
|
||||
|
||||
public bool MarePluginEnabled => _marePluginEnabled;
|
||||
public bool ImpersonationActive => _impersonating;
|
||||
@@ -100,7 +101,7 @@ public class IpcProvider : IHostedService, IMediatorSubscriber
|
||||
{
|
||||
if (_mareConfig.Current.MareAPI)
|
||||
{
|
||||
var cancelToken = _registerDelayCts.Token;
|
||||
var cancelToken = EnsureFreshCts(ref _registerDelayCts).Token;
|
||||
Task.Run(async () =>
|
||||
{
|
||||
// Wait before registering to reduce the chance of a race condition
|
||||
@@ -125,7 +126,7 @@ public class IpcProvider : IHostedService, IMediatorSubscriber
|
||||
}
|
||||
else
|
||||
{
|
||||
_registerDelayCts = _registerDelayCts.CancelRecreate();
|
||||
EnsureFreshCts(ref _registerDelayCts);
|
||||
if (_impersonating)
|
||||
{
|
||||
_loadFileProviderMare?.UnregisterFunc();
|
||||
@@ -146,7 +147,7 @@ public class IpcProvider : IHostedService, IMediatorSubscriber
|
||||
_loadFileAsyncProvider?.UnregisterFunc();
|
||||
_handledGameAddresses?.UnregisterFunc();
|
||||
|
||||
_registerDelayCts.Cancel();
|
||||
TryCancel(_registerDelayCts);
|
||||
if (_impersonating)
|
||||
{
|
||||
_loadFileProviderMare?.UnregisterFunc();
|
||||
@@ -155,6 +156,7 @@ public class IpcProvider : IHostedService, IMediatorSubscriber
|
||||
}
|
||||
|
||||
Mediator.UnsubscribeAll(this);
|
||||
CancelAndDispose(ref _registerDelayCts);
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
@@ -193,4 +195,31 @@ public class IpcProvider : IHostedService, IMediatorSubscriber
|
||||
|
||||
return _activeGameObjectHandlers.Where(g => g.Address != nint.Zero).Select(g => g.Address).Distinct().ToList();
|
||||
}
|
||||
|
||||
private static CancellationTokenSource EnsureFreshCts(ref CancellationTokenSource? cts)
|
||||
{
|
||||
CancelAndDispose(ref cts);
|
||||
cts = new CancellationTokenSource();
|
||||
return cts;
|
||||
}
|
||||
|
||||
private static void CancelAndDispose(ref CancellationTokenSource? cts)
|
||||
{
|
||||
if (cts == null) return;
|
||||
TryCancel(cts);
|
||||
cts.Dispose();
|
||||
cts = null;
|
||||
}
|
||||
|
||||
private static void TryCancel(CancellationTokenSource? cts)
|
||||
{
|
||||
if (cts == null) return;
|
||||
try
|
||||
{
|
||||
cts.Cancel();
|
||||
}
|
||||
catch (ObjectDisposedException)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,19 +1,20 @@
|
||||
using Dalamud.Game.ClientState.Objects.Types;
|
||||
using System;
|
||||
using MareSynchronos.PlayerData.Handlers;
|
||||
using MareSynchronos.Services;
|
||||
using MareSynchronos.Services.Mediator;
|
||||
using MareSynchronos.Utils;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System.Collections.Concurrent;
|
||||
|
||||
namespace MareSynchronos.Interop.Ipc;
|
||||
|
||||
public class RedrawManager
|
||||
public class RedrawManager : IDisposable
|
||||
{
|
||||
private readonly MareMediator _mareMediator;
|
||||
private readonly DalamudUtilService _dalamudUtil;
|
||||
private readonly ConcurrentDictionary<nint, bool> _penumbraRedrawRequests = [];
|
||||
private CancellationTokenSource _disposalCts = new();
|
||||
private CancellationTokenSource? _disposalCts = new();
|
||||
private bool _disposed;
|
||||
|
||||
public SemaphoreSlim RedrawSemaphore { get; init; } = new(2, 2);
|
||||
|
||||
@@ -32,12 +33,12 @@ public class RedrawManager
|
||||
try
|
||||
{
|
||||
using CancellationTokenSource cancelToken = new CancellationTokenSource();
|
||||
using CancellationTokenSource combinedCts = CancellationTokenSource.CreateLinkedTokenSource(cancelToken.Token, token, _disposalCts.Token);
|
||||
using CancellationTokenSource combinedCts = CancellationTokenSource.CreateLinkedTokenSource(cancelToken.Token, token, EnsureFreshCts(ref _disposalCts).Token);
|
||||
var combinedToken = combinedCts.Token;
|
||||
cancelToken.CancelAfter(TimeSpan.FromSeconds(15));
|
||||
await handler.ActOnFrameworkAfterEnsureNoDrawAsync(action, combinedToken).ConfigureAwait(false);
|
||||
|
||||
if (!_disposalCts.Token.IsCancellationRequested)
|
||||
if (!_disposalCts!.Token.IsCancellationRequested)
|
||||
await _dalamudUtil.WaitWhileCharacterIsDrawing(logger, handler, applicationId, 30000, combinedToken).ConfigureAwait(false);
|
||||
}
|
||||
finally
|
||||
@@ -49,6 +50,45 @@ public class RedrawManager
|
||||
|
||||
internal void Cancel()
|
||||
{
|
||||
_disposalCts = _disposalCts.CancelRecreate();
|
||||
EnsureFreshCts(ref _disposalCts);
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
Dispose(true);
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
|
||||
protected virtual void Dispose(bool disposing)
|
||||
{
|
||||
if (_disposed) return;
|
||||
if (disposing)
|
||||
{
|
||||
CancelAndDispose(ref _disposalCts);
|
||||
}
|
||||
|
||||
_disposed = true;
|
||||
}
|
||||
|
||||
private static CancellationTokenSource EnsureFreshCts(ref CancellationTokenSource? cts)
|
||||
{
|
||||
CancelAndDispose(ref cts);
|
||||
cts = new CancellationTokenSource();
|
||||
return cts;
|
||||
}
|
||||
|
||||
private static void CancelAndDispose(ref CancellationTokenSource? cts)
|
||||
{
|
||||
if (cts == null) return;
|
||||
try
|
||||
{
|
||||
cts.Cancel();
|
||||
}
|
||||
catch (ObjectDisposedException)
|
||||
{
|
||||
}
|
||||
|
||||
cts.Dispose();
|
||||
cts = null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,48 +0,0 @@
|
||||
using System.Globalization;
|
||||
|
||||
namespace MareSynchronos.Localization;
|
||||
|
||||
public static class LocalizationExtensions
|
||||
{
|
||||
public static string Loc(this string fallbackEnglish, params object[] formatArgs)
|
||||
{
|
||||
var service = LocalizationService.Instance;
|
||||
if (service == null) return FormatFallback(fallbackEnglish, formatArgs);
|
||||
return service.GetString(fallbackEnglish, formatArgs);
|
||||
}
|
||||
|
||||
public static string LocKey(this string key, string fallbackEnglish, params object[] formatArgs)
|
||||
{
|
||||
var service = LocalizationService.Instance;
|
||||
if (service == null) return FormatFallback(fallbackEnglish, formatArgs);
|
||||
return service.GetString(key, fallbackEnglish, formatArgs);
|
||||
}
|
||||
|
||||
public static string LocLabel(this string labelWithId, params object[] formatArgs)
|
||||
{
|
||||
if (string.IsNullOrEmpty(labelWithId)) return labelWithId;
|
||||
|
||||
var separatorIndex = labelWithId.IndexOf("##", StringComparison.Ordinal);
|
||||
if (separatorIndex < 0)
|
||||
{
|
||||
return labelWithId.Loc(formatArgs);
|
||||
}
|
||||
|
||||
var label = labelWithId[..separatorIndex];
|
||||
var id = labelWithId[separatorIndex..];
|
||||
return string.Concat(label.Loc(formatArgs), id);
|
||||
}
|
||||
|
||||
private static string FormatFallback(string fallback, params object[] args)
|
||||
{
|
||||
if (args == null || args.Length == 0) return fallback;
|
||||
try
|
||||
{
|
||||
return string.Format(CultureInfo.CurrentCulture, fallback, args);
|
||||
}
|
||||
catch
|
||||
{
|
||||
return fallback;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,231 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
using System.Text.Json;
|
||||
using System.Threading;
|
||||
using Dalamud.Plugin;
|
||||
using MareSynchronos.MareConfiguration;
|
||||
using MareSynchronos.MareConfiguration.Models;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace MareSynchronos.Localization;
|
||||
|
||||
public class LocalizationService
|
||||
{
|
||||
private readonly ILogger<LocalizationService> _logger;
|
||||
private readonly IDalamudPluginInterface _pluginInterface;
|
||||
private readonly MareConfigService _configService;
|
||||
private readonly Dictionary<LocalizationLanguage, Dictionary<string, string>> _translations = new();
|
||||
private readonly HashSet<string> _missingLocalizationsLogged = new(StringComparer.Ordinal);
|
||||
private readonly Lock _missingLocalizationsLock = new();
|
||||
|
||||
private static readonly JsonSerializerOptions JsonOptions = new()
|
||||
{
|
||||
AllowTrailingCommas = true
|
||||
};
|
||||
|
||||
public static LocalizationService? Instance { get; private set; }
|
||||
|
||||
public LocalizationService(ILogger<LocalizationService> logger, IDalamudPluginInterface pluginInterface, MareConfigService configService)
|
||||
{
|
||||
_logger = logger;
|
||||
_pluginInterface = pluginInterface;
|
||||
_configService = configService;
|
||||
|
||||
Instance = this;
|
||||
|
||||
foreach (var language in Enum.GetValues<LocalizationLanguage>())
|
||||
{
|
||||
_translations[language] = LoadLanguage(language);
|
||||
}
|
||||
}
|
||||
|
||||
public LocalizationLanguage CurrentLanguage => _configService.Current.Language;
|
||||
|
||||
public static IEnumerable<LocalizationLanguage> SupportedLanguages => Enum.GetValues<LocalizationLanguage>();
|
||||
|
||||
public string GetString(string fallbackEnglish, params object[] formatArgs)
|
||||
{
|
||||
return GetStringInternal(null, fallbackEnglish, formatArgs);
|
||||
}
|
||||
|
||||
public string GetString(string key, string fallbackEnglish, params object[] formatArgs)
|
||||
{
|
||||
return GetStringInternal(key, fallbackEnglish, formatArgs);
|
||||
}
|
||||
|
||||
public string GetLanguageDisplayName(LocalizationLanguage language)
|
||||
{
|
||||
var fallback = language switch
|
||||
{
|
||||
LocalizationLanguage.French => "Français",
|
||||
LocalizationLanguage.English => "English",
|
||||
_ => language.ToString()
|
||||
};
|
||||
|
||||
return GetRawString($"Language.DisplayName.{language}", fallback);
|
||||
}
|
||||
|
||||
public void ReloadLanguage(LocalizationLanguage language)
|
||||
{
|
||||
_translations[language] = LoadLanguage(language);
|
||||
}
|
||||
|
||||
public void ReloadAll()
|
||||
{
|
||||
foreach (var language in Enum.GetValues<LocalizationLanguage>())
|
||||
{
|
||||
ReloadLanguage(language);
|
||||
}
|
||||
}
|
||||
|
||||
private string GetStringInternal(string? key, string fallbackEnglish, params object[] formatArgs)
|
||||
{
|
||||
var usedKey = string.IsNullOrWhiteSpace(key) ? fallbackEnglish : key;
|
||||
var text = GetRawString(usedKey, fallbackEnglish);
|
||||
|
||||
if (formatArgs != null && formatArgs.Length > 0)
|
||||
{
|
||||
try
|
||||
{
|
||||
return string.Format(CultureInfo.CurrentCulture, text, formatArgs);
|
||||
}
|
||||
catch (FormatException ex)
|
||||
{
|
||||
_logger.LogWarning(ex, "Localization format mismatch for key {Key} with text '{Text}'", usedKey, text);
|
||||
try
|
||||
{
|
||||
return string.Format(CultureInfo.CurrentCulture, fallbackEnglish, formatArgs);
|
||||
}
|
||||
catch
|
||||
{
|
||||
return fallbackEnglish;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return text;
|
||||
}
|
||||
|
||||
private string GetRawString(string key, string fallbackEnglish)
|
||||
{
|
||||
if (TryGetString(CurrentLanguage, key, out var localized))
|
||||
{
|
||||
return localized;
|
||||
}
|
||||
|
||||
LogMissingLocalization(CurrentLanguage, key, fallbackEnglish);
|
||||
|
||||
if (TryGetString(LocalizationLanguage.English, key, out var english))
|
||||
{
|
||||
return english;
|
||||
}
|
||||
|
||||
if (CurrentLanguage != LocalizationLanguage.English)
|
||||
{
|
||||
LogMissingLocalization(LocalizationLanguage.English, key, fallbackEnglish);
|
||||
}
|
||||
|
||||
return fallbackEnglish;
|
||||
}
|
||||
|
||||
private bool TryGetString(LocalizationLanguage language, string key, out string value)
|
||||
{
|
||||
var dictionary = GetDictionary(language);
|
||||
if (dictionary.TryGetValue(key, out var text) && !string.IsNullOrWhiteSpace(text))
|
||||
{
|
||||
value = text;
|
||||
return true;
|
||||
}
|
||||
|
||||
value = string.Empty;
|
||||
return false;
|
||||
}
|
||||
|
||||
private Dictionary<string, string> GetDictionary(LocalizationLanguage language)
|
||||
{
|
||||
if (!_translations.TryGetValue(language, out var dictionary))
|
||||
{
|
||||
dictionary = LoadLanguage(language);
|
||||
_translations[language] = dictionary;
|
||||
}
|
||||
|
||||
return dictionary;
|
||||
}
|
||||
|
||||
private Dictionary<string, string> LoadLanguage(LocalizationLanguage language)
|
||||
{
|
||||
var baseDirectory = _pluginInterface.AssemblyLocation.DirectoryName ?? string.Empty;
|
||||
var localizationDirectory = Path.Combine(baseDirectory, "Localization");
|
||||
var languageCode = GetLanguageCode(language);
|
||||
var filePath = Path.Combine(localizationDirectory, $"{languageCode}.json");
|
||||
|
||||
Dictionary<string, string>? translations = null;
|
||||
|
||||
if (File.Exists(filePath))
|
||||
{
|
||||
try
|
||||
{
|
||||
using var stream = File.OpenRead(filePath);
|
||||
translations = DeserializeTranslations(stream);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogWarning(ex, "Failed to load localization data from {FilePath}", filePath);
|
||||
}
|
||||
}
|
||||
|
||||
if (translations == null)
|
||||
{
|
||||
var assembly = Assembly.GetExecutingAssembly();
|
||||
var resourceName = $"{assembly.GetName().Name}.Localization.{languageCode}.json";
|
||||
using var resourceStream = assembly.GetManifestResourceStream(resourceName);
|
||||
if (resourceStream != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
translations = DeserializeTranslations(resourceStream);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogWarning(ex, "Failed to load embedded localization resource {Resource}", resourceName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (translations == null)
|
||||
{
|
||||
_logger.LogDebug("Localization data for {Language} not found on disk or embedded, using empty dictionary.", language);
|
||||
translations = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);
|
||||
}
|
||||
|
||||
return translations;
|
||||
}
|
||||
|
||||
private void LogMissingLocalization(LocalizationLanguage language, string key, string fallback)
|
||||
{
|
||||
var marker = $"{language}:{key}";
|
||||
using var scope = _missingLocalizationsLock.EnterScope();
|
||||
if (_missingLocalizationsLogged.Contains(marker)) return;
|
||||
_missingLocalizationsLogged.Add(marker);
|
||||
|
||||
_logger.LogDebug("Missing localization for {Language} ({Key}). Using fallback '{Fallback}'.", language, key, fallback);
|
||||
}
|
||||
|
||||
private static string GetLanguageCode(LocalizationLanguage language) => language switch
|
||||
{
|
||||
LocalizationLanguage.French => "fr",
|
||||
LocalizationLanguage.English => "en",
|
||||
_ => language.ToString().ToLowerInvariant(),
|
||||
};
|
||||
|
||||
private static Dictionary<string, string>? DeserializeTranslations(Stream stream)
|
||||
{
|
||||
var translations = JsonSerializer.Deserialize<Dictionary<string, string>>(stream, JsonOptions);
|
||||
return translations != null
|
||||
? new Dictionary<string, string>(translations, StringComparer.OrdinalIgnoreCase)
|
||||
: null;
|
||||
}
|
||||
}
|
||||
@@ -1,579 +0,0 @@
|
||||
{
|
||||
"Language.DisplayName.French": "French",
|
||||
"Language.DisplayName.English": "English",
|
||||
"Settings.Plugins.MandatoryHeading": "Mandatory Plugins",
|
||||
"Settings.Plugins.MandatoryLabel": "Mandatory Plugins:",
|
||||
"Settings.Plugins.OptionalHeading": "Optional Addons",
|
||||
"Settings.Plugins.OptionalLabel": "Optional Addons:",
|
||||
"Settings.Plugins.OptionalDescription": "These addons are not required for basic operation, but without them you may not see others as intended.",
|
||||
"Settings.Plugins.Tooltip.Available": "{0} is available and up to date.",
|
||||
"Settings.Plugins.Tooltip.Unavailable": "{0} is unavailable or not up to date.",
|
||||
"Settings.Plugins.WarningMandatoryMissing": "You need to install both Penumbra and Glamourer and keep them up to date to use Umbra.",
|
||||
"Settings.General.LocalizationHeading": "Localization",
|
||||
"Settings.General.Language": "Language",
|
||||
"Settings.General.Language.Description": "Select the plugin language. Any missing translations will be shown in English.",
|
||||
"Settings.General.NotesHeading": "Notes",
|
||||
"Settings.General.Notes.Export": "Export all your user notes to clipboard",
|
||||
"Settings.General.Notes.Import": "Import notes from clipboard",
|
||||
"Settings.General.Notes.Overwrite": "Overwrite existing notes",
|
||||
"Settings.General.Notes.Overwrite.Description": "If this option is selected all already existing notes for UIDs will be overwritten by the imported notes.",
|
||||
"Settings.General.Notes.Import.Success": "User Notes successfully imported",
|
||||
"Settings.General.Notes.Import.Failure": "Attempt to import notes from clipboard failed. Check formatting and try again",
|
||||
"Settings.General.Notes.OpenPopup": "Open Notes Popup on user addition",
|
||||
"Settings.General.Notes.OpenPopup.Description": "This will open a popup that allows you to set the notes for a user after successfully adding them to your individual pairs.",
|
||||
"Settings.Transfers.Blocked.Description": "Files that you attempted to upload or download that were forbidden to be transferred by their creators will appear here. If you see file paths from your drive here, then those files were not allowed to be uploaded. If you see hashes, those files were not allowed to be downloaded. Ask your paired friend to send you the mod in question through other means or acquire the mod yourself.",
|
||||
"Settings.Transfers.Blocked.Column.Hash": "Hash/Filename",
|
||||
"Settings.Transfers.Blocked.Column.ForbiddenBy": "Forbidden by",
|
||||
"Settings.Transfers.Blocked.Tab": "Blocked Transfers",
|
||||
"Settings.Transfers.Heading": "Transfer Settings",
|
||||
"Settings.Transfers.GlobalLimit.Label": "Global Download Speed Limit",
|
||||
"Settings.Transfers.GlobalLimit.Unit.BytePerSec": "Byte/s",
|
||||
"Settings.Transfers.GlobalLimit.Unit.KiloBytePerSec": "KB/s",
|
||||
"Settings.Transfers.GlobalLimit.Unit.MegaBytePerSec": "MB/s",
|
||||
"Settings.Transfers.GlobalLimit.Hint": "0 = No limit/infinite",
|
||||
"Settings.Transfers.MaxParallelDownloads": "Maximum Parallel Downloads",
|
||||
"Settings.Transfers.AutoDetect.Heading": "AutoDetect",
|
||||
"Settings.Transfers.AutoDetect.EnableNearby": "Enable Nearby detection (beta)",
|
||||
"Settings.Transfers.AutoDetect.AllowRequests": "Allow pair requests",
|
||||
"Settings.Transfers.AutoDetect.Notification.Title": "Nearby Detection",
|
||||
"Settings.Transfers.AutoDetect.Notification.Enabled": "Pair requests enabled: others can invite you.",
|
||||
"Settings.Transfers.AutoDetect.Notification.Disabled": "Pair requests disabled: others cannot invite you.",
|
||||
"Settings.Transfers.AutoDetect.MaxDistance": "Max distance (meters)",
|
||||
"Settings.Transfers.UI.Heading": "Transfer UI",
|
||||
"Settings.Transfers.UI.ShowWindow": "Show separate transfer window",
|
||||
"Settings.Transfers.UI.ShowWindow.Description": "The download window will show the current progress of outstanding downloads.\n\nWhat do W/Q/P/D stand for?\nW = Waiting for Slot (see Maximum Parallel Downloads)\nQ = Queued on Server, waiting for queue ready signal\nP = Processing download (aka downloading)\nD = Decompressing download",
|
||||
"Settings.Transfers.UI.EditWindowPosition": "Edit Transfer Window position",
|
||||
"Settings.Transfers.UI.ShowTransferBars": "Show transfer bars rendered below players",
|
||||
"Settings.Transfers.UI.ShowTransferBars.Description": "This will render a progress bar during the download at the feet of the player you are downloading from.",
|
||||
"Settings.Transfers.UI.ShowDownloadText": "Show Download Text",
|
||||
"Settings.Transfers.UI.ShowDownloadText.Description": "Shows download text (amount of MiB downloaded) in the transfer bars",
|
||||
"Settings.Transfers.UI.BarWidth": "Transfer Bar Width",
|
||||
"Settings.Transfers.UI.BarWidth.Description": "Width of the displayed transfer bars (will never be less wide than the displayed text)",
|
||||
"Settings.Transfers.UI.BarHeight": "Transfer Bar Height",
|
||||
"Settings.Transfers.UI.BarHeight.Description": "Height of the displayed transfer bars (will never be less tall than the displayed text)",
|
||||
"Settings.Transfers.UI.ShowUploading": "Show 'Uploading' text below players that are currently uploading",
|
||||
"Settings.Transfers.UI.ShowUploading.Description": "This will render an 'Uploading' text at the feet of the player that is in progress of uploading data.",
|
||||
"Settings.Transfers.UI.ShowUploadingBigText": "Large font for 'Uploading' text",
|
||||
"Settings.Transfers.UI.ShowUploadingBigText.Description": "This will render an 'Uploading' text in a larger font.",
|
||||
"Settings.Transfers.Current.Heading": "Current Transfers",
|
||||
"Settings.Transfers.Current.Tab": "Transfers",
|
||||
"Settings.Transfers.Current.Uploads": "Uploads",
|
||||
"Settings.Transfers.Current.Uploads.Column.File": "File",
|
||||
"Settings.Transfers.Current.Uploads.Column.Uploaded": "Uploaded",
|
||||
"Settings.Transfers.Current.Uploads.Column.Size": "Size",
|
||||
"Settings.Transfers.Current.Downloads": "Downloads",
|
||||
"Settings.Transfers.Current.Downloads.Column.User": "User",
|
||||
"Settings.Transfers.Current.Downloads.Column.Server": "Server",
|
||||
"Settings.Transfers.Current.Downloads.Column.Files": "Files",
|
||||
"Settings.Transfers.Current.Downloads.Column.Download": "Download",
|
||||
"Settings.Storage.Heading": "Storage",
|
||||
"Settings.Storage.Description": "Umbra stores downloaded files from paired people permanently. This is to improve loading performance and requiring less downloads. The storage governs itself by clearing data beyond the set storage size. Please set the storage size accordingly. It is not necessary to manually clear the storage.",
|
||||
"Settings.Service.ActionsHeading": "Service Actions",
|
||||
"Settings.Service.Actions.DeleteAccount": "Delete account",
|
||||
"Settings.Service.Actions.DeleteAccountPopup": "Delete your account?",
|
||||
"Settings.Service.Actions.DeleteAccount.Description": "Completely deletes your currently connected account.",
|
||||
"Settings.Service.Actions.DeleteAccount.Popup.Body1": "Your account and all associated files and data on the service will be deleted.",
|
||||
"Settings.Service.Actions.DeleteAccount.Popup.Body2": "Your UID will be removed from all pairing lists.",
|
||||
"Settings.Service.Actions.DeleteAccount.Popup.Confirm": "Are you sure you want to continue?",
|
||||
"Settings.Service.Actions.DeleteAccount.Popup.Cancel": "Cancel",
|
||||
"Settings.Service.SettingsHeading": "Service & Character Settings",
|
||||
"Settings.Service.ReconnectWarning": "For any changes to be applied to the current service you need to reconnect to the service.",
|
||||
"Settings.Service.Tabs.CharacterAssignments": "Character Assignments",
|
||||
"Settings.Service.Tabs.SecretKey": "Secret Key Management",
|
||||
"Settings.Service.Tabs.ServiceSettings": "Service Settings",
|
||||
"Settings.Service.Character.Assignments.Description": "Characters listed here will connect with the specified secret key.",
|
||||
"Settings.Service.Character.Assignments.TooltipCurrent": "Current character",
|
||||
"Settings.Service.Character.Assignments.DeleteTooltip": "Delete character assignment",
|
||||
"Settings.Service.Character.Assignments.AddCurrent": "Add current character",
|
||||
"Settings.Service.Character.Assignments.NoKeys": "You need to add a Secret Key first before adding Characters.",
|
||||
"Settings.Service.SecretKey.DisplayName": "Secret Key Display Name",
|
||||
"Settings.Service.SecretKey.Value": "Secret Key",
|
||||
"Settings.Service.SecretKey.AssignCurrent": "Assign current character",
|
||||
"Settings.Service.SecretKey.AssignTooltip": "Use this secret key for {0} @ {1}",
|
||||
"Settings.Service.SecretKey.Delete": "Delete Secret Key",
|
||||
"Settings.Service.SecretKey.DeleteTooltip": "Hold CTRL to delete this secret key entry",
|
||||
"Settings.Service.SecretKey.InUse": "This key is currently assigned to a character and cannot be edited or deleted.",
|
||||
"Settings.Service.SecretKey.Add": "Add new Secret Key",
|
||||
"Settings.Service.SecretKey.NewFriendlyName": "New Secret Key",
|
||||
"Settings.Service.SecretKey.RegisterAccount": "Register a new Umbra account",
|
||||
"Settings.Service.SecretKey.RegisterFailed": "An unknown error occured. Please try again later.",
|
||||
"Settings.Service.SecretKey.RegisterSuccess": "New account registered.\nPlease keep a copy of your secret key in case you need to reset your plugins, or to use it on another PC.",
|
||||
"Settings.Service.SecretKey.RegisteredFriendlyName": "{0} (registered {1})",
|
||||
"Settings.Service.SecretKey.Registering": "Sending request...",
|
||||
"Settings.Service.ServiceTab.Uri": "Service URI",
|
||||
"Settings.Service.ServiceTab.UriReadOnlyHint": "You cannot edit the URI of the main service.",
|
||||
"Settings.Service.ServiceTab.Name": "Service Name",
|
||||
"Settings.Service.ServiceTab.NameReadOnlyHint": "You cannot edit the name of the main service.",
|
||||
"Settings.Service.ServiceTab.Delete": "Delete Service",
|
||||
"Settings.Service.ServiceTab.DeleteHint": "Hold CTRL to delete this service",
|
||||
"Settings.Advanced.Heading": "Advanced",
|
||||
"Settings.Advanced.Tab": "Advanced",
|
||||
"Settings.Advanced.Api.Enable": "Enable Umbra Sync API",
|
||||
"Settings.Advanced.Api.Description": "Enables handling of the Umbra Sync API. This currently includes:\n\n - MCDF loading support for other plugins\n - Blocking Moodles applications to paired users\n\nIf the Umbra Sync plugin is loaded while this option is enabled, control of its API will be relinquished.",
|
||||
"Settings.Advanced.Api.Status.Active": "Umbra API active!",
|
||||
"Settings.Advanced.Api.Status.Disabled": "Umbra API inactive: Option is disabled",
|
||||
"Settings.Advanced.Api.Status.PluginLoaded": "Umbra API inactive: Umbra plugin is loaded",
|
||||
"Settings.Advanced.Api.Status.Unknown": "Umbra API inactive: Unknown reason",
|
||||
"Settings.Advanced.EventViewer.LogToDisk": "Log Event Viewer data to disk",
|
||||
"Settings.Advanced.EventViewer.Open": "Open Event Viewer",
|
||||
"Settings.Advanced.HoldCombat": "Hold application during combat",
|
||||
"Settings.Advanced.SerializedApplications": "Serialized player applications",
|
||||
"Settings.Advanced.SerializedApplications.Description": "Experimental - May reduce issues in crowded areas",
|
||||
"Settings.Advanced.DebugHeading": "Debug",
|
||||
"Settings.Advanced.Debug.LastCreatedTree": "Last created character data",
|
||||
"Settings.Advanced.Debug.CopyButton": "[DEBUG] Copy Last created Character Data to clipboard",
|
||||
"Settings.Advanced.Debug.CopyError": "ERROR: No created character data, cannot copy.",
|
||||
"Settings.Advanced.Debug.CopyTooltip": "Use this when reporting mods being rejected from the server.",
|
||||
"Settings.Advanced.LogLevel": "Log Level",
|
||||
"Settings.Advanced.Performance.LogCounters": "Log Performance Counters",
|
||||
"Settings.Advanced.Performance.LogCounters.Description": "Enabling this can incur a (slight) performance impact. Enabling this for extended periods of time is not recommended.",
|
||||
"Settings.Advanced.Performance.PrintStats": "Print Performance Stats to /xllog",
|
||||
"Settings.Advanced.Performance.PrintStatsRecent": "Print Performance Stats (last 60s) to /xllog",
|
||||
"Settings.Advanced.ActiveBlocks": "Active Character Blocks",
|
||||
"Settings.UI.Heading": "UI",
|
||||
"Settings.UI.EnableRightClick": "Enable Game Right Click Menu Entries",
|
||||
"Settings.UI.EnableRightClick.Description": "This will add Umbra related right click menu entries in the game UI on paired players.",
|
||||
"Settings.UI.EnableDtrEntry": "Display status and visible pair count in Server Info Bar",
|
||||
"Settings.UI.EnableDtrEntry.Description": "This will add Umbra connection status and visible pair count in the Server Info Bar.\nYou can further configure this through your Dalamud Settings.",
|
||||
"Settings.UI.Dtr.ShowUid": "Show visible character's UID in tooltip",
|
||||
"Settings.UI.Dtr.PreferNotes": "Prefer notes over player names in tooltip",
|
||||
"Settings.UI.Dtr.UseColors": "Color-code the Server Info Bar entry according to status",
|
||||
"Settings.UI.Dtr.ColorDefault": "Default",
|
||||
"Settings.UI.Dtr.ColorNotConnected": "Not Connected",
|
||||
"Settings.UI.Dtr.ColorPairsInRange": "Pairs in Range",
|
||||
"Settings.UI.NameColors.Enable": "Color nameplates of paired players",
|
||||
"Settings.UI.NameColors.Character": "Character Name Color",
|
||||
"Settings.UI.NameColors.Blocked": "Blocked Character Color",
|
||||
"Settings.UI.VisibleGroup": "Show separate Visible group",
|
||||
"Settings.UI.VisibleGroup.Description": "This will show all currently visible users in a special 'Visible' group in the main UI.",
|
||||
"Settings.UI.OfflineGroup": "Show separate Offline group",
|
||||
"Settings.UI.OfflineGroup.Description": "This will show all currently offline users in a special 'Offline' group in the main UI.",
|
||||
"Settings.UI.ShowPlayerNames": "Show player names",
|
||||
"Settings.UI.ShowPlayerNames.Description": "This will show character names instead of UIDs when possible",
|
||||
"Settings.UI.Profiles.Show": "Show Profiles on Hover",
|
||||
"Settings.UI.Profiles.Show.Description": "This will show the configured user profile after a set delay",
|
||||
"Settings.UI.Profiles.PopoutRight": "Popout profiles on the right",
|
||||
"Settings.UI.Profiles.PopoutRight.Description": "Will show profiles on the right side of the main UI",
|
||||
"Settings.UI.Profiles.HoverDelay": "Hover Delay",
|
||||
"Settings.UI.Profiles.HoverDelay.Description": "Delay until the profile should be displayed",
|
||||
"Settings.UI.Profiles.ShowNsfw": "Show profiles marked as NSFW",
|
||||
"Settings.UI.Profiles.ShowNsfw.Description": "Will show profiles that have the NSFW tag enabled",
|
||||
"Settings.Notifications.Heading": "Notifications",
|
||||
"Settings.Notifications.InfoDisplay": "Info Notification Display",
|
||||
"Settings.Notifications.InfoDisplay.Description": "The location where \"Info\" notifications will display.\n'Nowhere' will not show any Info notifications\n'Chat' will print Info notifications in chat\n'Toast' will show Warning toast notifications in the bottom right corner\n'Both' will show chat as well as the toast notification",
|
||||
"Settings.Notifications.WarningDisplay": "Warning Notification Display",
|
||||
"Settings.Notifications.WarningDisplay.Description": "The location where \"Warning\" notifications will display.\n'Nowhere' will not show any Warning notifications\n'Chat' will print Warning notifications in chat\n'Toast' will show Warning toast notifications in the bottom right corner\n'Both' will show chat as well as the toast notification",
|
||||
"Settings.Notifications.ErrorDisplay": "Error Notification Display",
|
||||
"Settings.Notifications.ErrorDisplay.Description": "The location where \"Error\" notifications will display.\n'Nowhere' will not show any Error notifications\n'Chat' will print Error notifications in chat\n'Toast' will show Error toast notifications in the bottom right corner\n'Both' will show chat as well as the toast notification",
|
||||
"Settings.Notifications.Location.Nowhere": "Nowhere",
|
||||
"Settings.Notifications.Location.Chat": "Chat",
|
||||
"Settings.Notifications.Location.Toast": "Toast",
|
||||
"Settings.Notifications.Location.Both": "Both",
|
||||
"Settings.Notifications.DisableOptionalWarnings": "Disable optional plugin warnings",
|
||||
"Settings.Notifications.DisableOptionalWarnings.Description": "Enabling this will not show any \"Warning\" labeled messages for missing optional plugins.",
|
||||
"Settings.Notifications.EnableOnlineNotifications": "Enable online notifications",
|
||||
"Settings.Notifications.EnableOnlineNotifications.Description": "Enabling this will show a small notification (type: Info) in the bottom right corner when pairs go online.",
|
||||
"Settings.Notifications.IndividualPairsOnly": "Notify only for individual pairs",
|
||||
"Settings.Notifications.IndividualPairsOnly.Description": "Enabling this will only show online notifications (type: Info) for individual pairs.",
|
||||
"Settings.Notifications.NamedPairsOnly": "Notify only for named pairs",
|
||||
"Settings.Notifications.NamedPairsOnly.Description": "Enabling this will only show online notifications (type: Info) for pairs where you have set an individual note.",
|
||||
"Compact.Version.UnsupportedTitle": "UNSUPPORTED VERSION",
|
||||
"Compact.Version.Outdated": "Your UmbraSync installation is out of date, the current version is {0}.{1}.{2}. It is highly recommended to keep UmbraSync up to date. Open /xlplugins and update the plugin.",
|
||||
"Compact.Toggle.IndividualPairs": "Individual pairs",
|
||||
"Compact.Toggle.Syncshells": "Syncshells",
|
||||
"Compact.AddUser.ModalTitle": "Set Notes for New User",
|
||||
"Compact.AddUser.Description": "You have successfully added {0}. Set a local note for the user in the field below:",
|
||||
"Compact.AddUser.NoteHint": "Note for {0}",
|
||||
"Compact.AddUser.Save": "Save Note",
|
||||
"Compact.AddCharacter.Button": "Add current character with secret key",
|
||||
"Compact.AddCharacter.SecretKeyLabel": "Secret Key",
|
||||
"Compact.AddCharacter.NoKeys": "No secret keys are configured for the current server.",
|
||||
"Compact.AddPair.Hint": "Other player's UID/Alias",
|
||||
"Compact.AddPair.Tooltip": "Pair with {0}",
|
||||
"Compact.AddPair.Tooltip.DefaultUser": "other user",
|
||||
"Compact.Filter.Hint": "Filter for UID/notes",
|
||||
"Compact.Filter.ToggleTooltip": "Hold Control to {0} pairing with {1} out of {2} displayed users.",
|
||||
"Compact.Filter.ToggleTooltip.Resume": "resume",
|
||||
"Compact.Filter.ToggleTooltip.Pause": "pause",
|
||||
"Compact.Filter.CooldownTooltip": "Next execution is available at {0} seconds",
|
||||
"Compact.Nearby.Title": "Nearby ({0})",
|
||||
"Compact.Nearby.Button": "Nearby",
|
||||
"Compact.Nearby.None": "No nearby players detected.",
|
||||
"Compact.Nearby.Tooltip.AlreadyPaired": "Already paired on Umbra",
|
||||
"Compact.Nearby.Tooltip.RequestsDisabled": "Pair requests are disabled for this player",
|
||||
"Compact.Nearby.Tooltip.SendInvite": "Send Umbra invitation",
|
||||
"Compact.Nearby.Tooltip.CannotInvite": "Unable to invite this player",
|
||||
"Compact.Nearby.Incoming": "Incoming requests",
|
||||
"Compact.Nearby.Incoming.Entry": "{0} [{1}]",
|
||||
"Compact.Nearby.Incoming.Accept": "Accept and add as pair",
|
||||
"Compact.Nearby.Incoming.Dismiss": "Dismiss request",
|
||||
"Compact.Header.SettingsTooltip": "Open the UmbraSync settings",
|
||||
"Compact.Header.CopyUid": "Copy your UID to clipboard",
|
||||
"Compact.ServerStatus.UsersOnline": "Users Online",
|
||||
"Compact.ServerStatus.Shard": "Shard: {0}",
|
||||
"Compact.ServerStatus.NotConnected": "Not connected to any server",
|
||||
"Compact.ServerStatus.EditProfile": "Edit your Profile",
|
||||
"Compact.ServerStatus.Disconnect": "Disconnect from {0}",
|
||||
"Compact.ServerStatus.Connect": "Connect to {0}",
|
||||
"Compact.ServerError.Connecting": "Attempting to connect to the server.",
|
||||
"Compact.ServerError.Reconnecting": "Connection to server interrupted, attempting to reconnect to the server.",
|
||||
"Compact.ServerError.Disconnected": "You are currently disconnected from the sync server.",
|
||||
"Compact.ServerError.Disconnecting": "Disconnecting from the server",
|
||||
"Compact.ServerError.Unauthorized": "Server Response: {0}",
|
||||
"Compact.ServerError.Offline": "Your selected sync server is currently offline.",
|
||||
"Compact.ServerError.VersionMismatch": "Your plugin or the server you are connecting to is out of date. Please update your plugin now. If you already did so, contact the server provider to update their server to the latest version.",
|
||||
"Compact.ServerError.RateLimited": "You are rate limited for (re)connecting too often. Disconnect, wait 10 minutes and try again.",
|
||||
"Compact.ServerError.NoSecretKey": "You have no secret key set for this current character. Use the button below or open the settings and set a secret key for the current character. You can reuse the same secret key for multiple characters.",
|
||||
"Compact.ServerError.MultiChara": "Your Character Configuration has multiple characters configured with same name and world. You will not be able to connect until you fix this issue. Remove the duplicates from the configuration in Settings -> Service Settings -> Character Management and reconnect manually after.",
|
||||
"Compact.Transfers.CharacterAnalysis": "Character Analysis",
|
||||
"Compact.Transfers.CharacterDataHub": "Character Data Hub",
|
||||
"Compact.UidText.Reconnecting": "Reconnecting",
|
||||
"Compact.UidText.Connecting": "Connecting",
|
||||
"Compact.UidText.Disconnected": "Disconnected",
|
||||
"Compact.UidText.Disconnecting": "Disconnecting",
|
||||
"Compact.UidText.Unauthorized": "Unauthorized",
|
||||
"Compact.UidText.VersionMismatch": "Version mismatch",
|
||||
"Compact.UidText.Offline": "Unavailable",
|
||||
"Compact.UidText.RateLimited": "Rate Limited",
|
||||
"Compact.UidText.NoSecretKey": "No Secret Key",
|
||||
"Compact.UidText.MultiChara": "Duplicate Characters",
|
||||
"UserPair.Status.Online": "User is online",
|
||||
"UserPair.Status.Offline": "User is offline",
|
||||
"UserPair.Tooltip.NotAddedBack": "{0} has not added you back",
|
||||
"UserPair.Tooltip.Paused": "Pairing with {0} is paused",
|
||||
"UserPair.Tooltip.Visible": "{0} is visible: {1}\nClick to target this player",
|
||||
"UserPair.Tooltip.Visible.LastPrefix": "(Last) ",
|
||||
"UserPair.Tooltip.Visible.ModsInfo": "Mods Info",
|
||||
"UserPair.Tooltip.Visible.FilesSize": "Files Size: {0}",
|
||||
"UserPair.Tooltip.Visible.Vram": "Approx. VRAM Usage: {0}",
|
||||
"UserPair.Tooltip.Visible.Tris": "Triangle Count (excl. Vanilla): {0}",
|
||||
"UserPair.Tooltip.Pause": "Pause pairing with {0}",
|
||||
"UserPair.Tooltip.Resume": "Resume pairing with {0}",
|
||||
"UserPair.Tooltip.Permission.Header": "Individual user permissions",
|
||||
"UserPair.Tooltip.Permission.Sound": "Sound sync disabled with {0}",
|
||||
"UserPair.Tooltip.Permission.Animation": "Animation sync disabled with {0}",
|
||||
"UserPair.Tooltip.Permission.Vfx": "VFX sync disabled with {0}",
|
||||
"UserPair.Tooltip.Permission.Status": "You: {0}, They: {1}",
|
||||
"UserPair.Tooltip.Permission.State.Disabled": "Disabled",
|
||||
"UserPair.Tooltip.Permission.State.Enabled": "Enabled",
|
||||
"UserPair.Tooltip.SharedData": "This user has shared {0} Character Data Sets with you.",
|
||||
"UserPair.Tooltip.SharedData.OpenHub": "Click to open the Character Data Hub and show the entries.",
|
||||
"UserPair.Menu.Target": "Target player",
|
||||
"UserPair.Menu.OpenProfile": "Open Profile",
|
||||
"UserPair.Menu.OpenProfile.Tooltip": "Opens the profile for this user in a new window",
|
||||
"UserPair.Menu.OpenAnalysis": "Open Analysis",
|
||||
"UserPair.Menu.ReloadData": "Reload last data",
|
||||
"UserPair.Menu.ReloadData.Tooltip": "This reapplies the last received character data to this character",
|
||||
"UserPair.Menu.CyclePause": "Cycle pause state",
|
||||
"UserPair.Menu.PairGroups": "Pair Groups",
|
||||
"UserPair.Menu.PairGroups.Tooltip": "Choose pair groups for {0}",
|
||||
"UserPair.Menu.EnableSoundSync": "Enable sound sync",
|
||||
"UserPair.Menu.DisableSoundSync": "Disable sound sync",
|
||||
"UserPair.Menu.EnableAnimationSync": "Enable animation sync",
|
||||
"UserPair.Menu.DisableAnimationSync": "Disable animation sync",
|
||||
"UserPair.Menu.EnableVfxSync": "Enable VFX sync",
|
||||
"UserPair.Menu.DisableVfxSync": "Disable VFX sync",
|
||||
"UserPair.Menu.Unpair": "Unpair Permanently",
|
||||
"UserPair.Menu.Unpair.Tooltip": "Hold CTRL and click to unpair permanently from {0}",
|
||||
"Popup.Generic.Close": "Close",
|
||||
"Popup.BanUser.Description": "User {0} will be banned and removed from this Syncshell.",
|
||||
"Popup.BanUser.ReasonHint": "Ban Reason",
|
||||
"Popup.BanUser.Button": "Ban User",
|
||||
"Popup.BanUser.ReasonNote": "The reason will be displayed in the banlist. The current server-side alias if present (Vanity ID) will automatically be attached to the reason.",
|
||||
"Popup.Report.Title": "Report {0} Profile",
|
||||
"Popup.Report.Note": "Note: Sending a report will disable the offending profile globally.\nThe report will be sent to the team of your currently connected server.\nDepending on the severity of the offense the users profile or account can be permanently disabled or banned.",
|
||||
"Popup.Report.Warning": "Report spam and wrong reports will not be tolerated and can lead to permanent account suspension.",
|
||||
"Popup.Report.Scope": "This is not for reporting misbehavior but solely for the actual profile. Reports that are not solely for the profile will be ignored.",
|
||||
"Popup.Report.Button": "Send Report",
|
||||
"PairGroups.Popup.Title": "Choose Groups for {0}",
|
||||
"PairGroups.Popup.SelectPrompt": "Select the groups you want {0} to be in.",
|
||||
"PairGroups.Popup.CreatePrompt": "Create a new group for {0}.",
|
||||
"PairGroups.Popup.NewGroupHint": "New Group",
|
||||
"PairGroups.SelectPairs.Title": "Choose Users for Group {0}",
|
||||
"PairGroups.SelectPairs.SelectPrompt": "Select users for group {0}",
|
||||
"PairGroups.SelectPairs.FilterHint": "Filter",
|
||||
"UidDisplay.Tooltip": "Left click to switch between UID display and nick\nRight click to change nick for {0}\nMiddle Mouse Button to open their profile in a separate window",
|
||||
"UidDisplay.EditNotes.Hint": "Nick/Notes",
|
||||
"DataAnalysis.WindowTitle": "Character Data Analysis",
|
||||
"DataAnalysis.Bc7.ModalTitle": "BC7 Conversion in Progress",
|
||||
"DataAnalysis.Bc7.Status": "BC7 Conversion in progress: {0}/{1}",
|
||||
"DataAnalysis.Bc7.CurrentFile": "Current file: {0}",
|
||||
"DataAnalysis.Bc7.Cancel": "Cancel conversion",
|
||||
"DataAnalysis.Description": "This window shows you all files and their sizes that are currently in use through your character and associated entities",
|
||||
"DataAnalysis.Analyzing": "Analyzing {0}/{1}",
|
||||
"DataAnalysis.Button.CancelAnalysis": "Cancel analysis",
|
||||
"DataAnalysis.Analyze.MissingNotice": "Some entries in the analysis have file size not determined yet, press the button below to analyze your current data",
|
||||
"DataAnalysis.Button.StartMissing": "Start analysis (missing entries)",
|
||||
"DataAnalysis.Button.StartAll": "Start analysis (recalculate all entries)",
|
||||
"DataAnalysis.TotalFiles": "Total files:",
|
||||
"DataAnalysis.Tooltip.FileSummary": "{0}: {1} files, size: {2}, compressed: {3}",
|
||||
"DataAnalysis.TotalSizeActual": "Total size (actual):",
|
||||
"DataAnalysis.TotalSizeDownload": "Total size (download size):",
|
||||
"DataAnalysis.Tooltip.CalculateDownloadSize": "Click \"Start analysis\" to calculate download size",
|
||||
"DataAnalysis.TotalTriangles": "Total modded model triangles: {0}",
|
||||
"DataAnalysis.FilesFor": "Files for {0}",
|
||||
"DataAnalysis.Object.SizeActual": "{0} size (actual):",
|
||||
"DataAnalysis.Object.SizeDownload": "{0} size (download size):",
|
||||
"DataAnalysis.Object.Vram": "{0} VRAM usage:",
|
||||
"DataAnalysis.Object.Triangles": "{0} modded model triangles: {1}",
|
||||
"DataAnalysis.FileGroup.Count": "{0} files",
|
||||
"DataAnalysis.FileGroup.SizeActual": "{0} files size (actual):",
|
||||
"DataAnalysis.FileGroup.SizeDownload": "{0} files size (download size):",
|
||||
"DataAnalysis.Bc7.EnableMode": "Enable BC7 Conversion Mode",
|
||||
"DataAnalysis.Bc7.WarningTitle": "WARNING BC7 CONVERSION:",
|
||||
"DataAnalysis.Bc7.WarningIrreversible": "Converting textures to BC7 is irreversible!",
|
||||
"DataAnalysis.Bc7.WarningDetails": "- Converting textures to BC7 will reduce their size (compressed and uncompressed) drastically. It is recommended to be used for large (4k+) textures.\n- Some textures, especially ones utilizing colorsets, might not be suited for BC7 conversion and might produce visual artifacts.\n- Before converting textures, make sure to have the original files of the mod you are converting so you can reimport it in case of issues.\n- Conversion will convert all found texture duplicates (entries with more than 1 file path) automatically.\n- Converting textures to BC7 is a very expensive operation and, depending on the amount of textures to convert, will take a while to complete.",
|
||||
"DataAnalysis.Bc7.StartConversion": "Start conversion of {0} texture(s)",
|
||||
"DataAnalysis.Table.Hash": "Hash",
|
||||
"DataAnalysis.Table.Filepaths": "Filepaths",
|
||||
"DataAnalysis.Table.Gamepaths": "Gamepaths",
|
||||
"DataAnalysis.Table.FileSize": "File Size",
|
||||
"DataAnalysis.Table.DownloadSize": "Download Size",
|
||||
"DataAnalysis.Table.Format": "Format",
|
||||
"DataAnalysis.Table.ConvertToBc7": "Convert to BC7",
|
||||
"DataAnalysis.Table.Triangles": "Triangles",
|
||||
"DataAnalysis.SelectedFile": "Selected file:",
|
||||
"DataAnalysis.LocalFilePath": "Local file path:",
|
||||
"DataAnalysis.MoreCount": "(and {0} more)",
|
||||
"DataAnalysis.GamePath": "Used by game path:",
|
||||
"DownloadUi.WindowTitle": "Umbra Downloads",
|
||||
"DownloadUi.UploadStatus": "Compressing+Uploading {0}/{1}",
|
||||
"DownloadUi.DownloadStatus": "{0} [W:{1}/Q:{2}/P:{3}/D:{4}]",
|
||||
"DownloadUi.UploadingLabel": "Uploading",
|
||||
"EventViewer.WindowTitle": "Event Viewer",
|
||||
"EventViewer.Button.Unfreeze": "Unfreeze View",
|
||||
"EventViewer.Button.Freeze": "Freeze View",
|
||||
"EventViewer.Tooltip.NewEvents": "New events are available. Click to resume updating.",
|
||||
"EventViewer.FilterLabel": "Filter lines",
|
||||
"EventViewer.Button.OpenLog": "Open EventLog folder",
|
||||
"EventViewer.Column.Time": "Time",
|
||||
"EventViewer.Column.Source": "Source",
|
||||
"EventViewer.Column.Uid": "UID",
|
||||
"EventViewer.Column.Character": "Character",
|
||||
"EventViewer.Column.Event": "Event",
|
||||
"EventViewer.Severity.Informational": "Informational",
|
||||
"EventViewer.Severity.Warning": "Warning",
|
||||
"EventViewer.Severity.Error": "Error",
|
||||
"EventViewer.NoValue": "--",
|
||||
"DtrEntry.EntryName": "Umbra",
|
||||
"DtrEntry.Tooltip.Connected": "Umbra: Connected",
|
||||
"DtrEntry.Tooltip.Disconnected": "Umbra: Not Connected",
|
||||
"PermissionWindow.Title": "Permissions for {0}",
|
||||
"PermissionWindow.Pause.Label": "Pause Sync",
|
||||
"PermissionWindow.Pause.HelpMain": "Pausing will completely cease any sync with this user.",
|
||||
"PermissionWindow.Pause.HelpNote": "Note: this is bidirectional, either user pausing will cease sync completely.",
|
||||
"PermissionWindow.OtherPaused.True": "{0} has paused you",
|
||||
"PermissionWindow.OtherPaused.False": "{0} has not paused you",
|
||||
"PermissionWindow.Sounds.Label": "Disable Sounds",
|
||||
"PermissionWindow.Sounds.HelpMain": "Disabling sounds will remove all sounds synced with this user on both sides.",
|
||||
"PermissionWindow.Sounds.HelpNote": "Note: this is bidirectional, either user disabling sound sync will stop sound sync on both sides.",
|
||||
"PermissionWindow.OtherSoundDisabled.True": "{0} has disabled sound sync with you",
|
||||
"PermissionWindow.OtherSoundDisabled.False": "{0} has not disabled sound sync with you",
|
||||
"PermissionWindow.Animations.Label": "Disable Animations",
|
||||
"PermissionWindow.Animations.HelpMain": "Disabling sounds will remove all animations synced with this user on both sides.",
|
||||
"PermissionWindow.Animations.HelpNote": "Note: this is bidirectional, either user disabling animation sync will stop animation sync on both sides.",
|
||||
"PermissionWindow.OtherAnimationDisabled.True": "{0} has disabled animation sync with you",
|
||||
"PermissionWindow.OtherAnimationDisabled.False": "{0} has not disabled animation sync with you",
|
||||
"PermissionWindow.Vfx.Label": "Disable VFX",
|
||||
"PermissionWindow.Vfx.HelpMain": "Disabling sounds will remove all VFX synced with this user on both sides.",
|
||||
"PermissionWindow.Vfx.HelpNote": "Note: this is bidirectional, either user disabling VFX sync will stop VFX sync on both sides.",
|
||||
"PermissionWindow.OtherVfxDisabled.True": "{0} has disabled VFX sync with you",
|
||||
"PermissionWindow.OtherVfxDisabled.False": "{0} has not disabled VFX sync with you",
|
||||
"PermissionWindow.Button.Save": "Save",
|
||||
"PermissionWindow.Tooltip.Save": "Save and apply all changes",
|
||||
"PermissionWindow.Button.Revert": "Revert",
|
||||
"PermissionWindow.Tooltip.Revert": "Revert all changes",
|
||||
"PermissionWindow.Button.Reset": "Reset to Default",
|
||||
"PermissionWindow.Tooltip.Reset": "This will set all permissions to their default setting",
|
||||
"EditProfile.WindowTitle": "Umbra Edit Profile",
|
||||
"EditProfile.CurrentProfile": "Current Profile (as saved on server)",
|
||||
"EditProfile.Button.UploadPicture": "Upload new profile picture",
|
||||
"EditProfile.Dialog.PictureTitle": "Select new Profile picture",
|
||||
"EditProfile.Tooltip.UploadPicture": "Select and upload a new profile picture",
|
||||
"EditProfile.Button.ClearPicture": "Clear uploaded profile picture",
|
||||
"EditProfile.Tooltip.ClearPicture": "Clear your currently uploaded profile picture",
|
||||
"EditProfile.Error.PictureTooLarge": "The profile picture must be a PNG file with a maximum height and width of 256px and 250KiB size",
|
||||
"EditProfile.Checkbox.Nsfw": "Profile is NSFW",
|
||||
"EditProfile.Help.Nsfw": "If your profile description or image can be considered NSFW, toggle this to ON",
|
||||
"EditProfile.DescriptionCounter": "Description {0}/1500",
|
||||
"EditProfile.PreviewLabel": "Preview (approximate)",
|
||||
"EditProfile.Button.SaveDescription": "Save Description",
|
||||
"EditProfile.Tooltip.SaveDescription": "Sets your profile description text",
|
||||
"EditProfile.Button.ClearDescription": "Clear Description",
|
||||
"EditProfile.Tooltip.ClearDescription": "Clears your profile description text",
|
||||
"Intro.Welcome.Title": "Welcome to Umbra",
|
||||
"Intro.Welcome.Paragraph1": "Umbra is a plugin that will replicate your full current character state including all Penumbra mods to other paired users. Note that you will have to have Penumbra as well as Glamourer installed to use this plugin.",
|
||||
"Intro.Welcome.Paragraph2": "We will have to setup a few things first before you can start using this plugin. Click on next to continue.",
|
||||
"Intro.Welcome.Note": "Note: Any modifications you have applied through anything but Penumbra cannot be shared and your character state on other clients might look broken because of this or others players mods might not apply on your end altogether. If you want to use this plugin you will have to move your mods to Penumbra.",
|
||||
"Intro.Welcome.Next": "Next",
|
||||
"Intro.Agreement.Title": "Agreement of Usage of Service",
|
||||
"Intro.Agreement.Callout": "READ THIS CAREFULLY",
|
||||
"Intro.Agreement.Timeout": "'I agree' button will be available in {0}s",
|
||||
"Intro.Agreement.Paragraph1": "To use Umbra, you must be over the age of 18, or 21 in some jurisdictions.",
|
||||
"Intro.Agreement.Paragraph2": "All of the mod files currently active on your character as well as your current character state will be uploaded to the service you registered yourself at automatically. The plugin will exclusively upload the necessary mod files and not the whole mod.",
|
||||
"Intro.Agreement.Paragraph3": "If you are on a data capped internet connection, higher fees due to data usage depending on the amount of downloaded and uploaded mod files might occur. Mod files will be compressed on up- and download to save on bandwidth usage. Due to varying up- and download speeds, changes in characters might not be visible immediately. Files present on the service that already represent your active mod files will not be uploaded again.",
|
||||
"Intro.Agreement.Paragraph4": "The mod files you are uploading are confidential and will not be distributed to parties other than the ones who are requesting the exact same mod files. Please think about who you are going to pair since it is unavoidable that they will receive and locally cache the necessary mod files that you have currently in use. Locally cached mod files will have arbitrary file names to discourage attempts at replicating the original mod.",
|
||||
"Intro.Agreement.Paragraph5": "The plugin creator tried their best to keep you secure. However, there is no guarantee for 100% security. Do not blindly pair your client with everyone.",
|
||||
"Intro.Agreement.Paragraph6": "Mod files that are saved on the service will remain on the service as long as there are requests for the files from clients. After a period of not being used, the mod files will be automatically deleted.",
|
||||
"Intro.Agreement.Paragraph7": "Accounts that are inactive for ninety (90) days will be deleted for privacy reasons.",
|
||||
"Intro.Agreement.Paragraph8": "Umbra is operated from servers located in the European Union. You agree not to upload any content to the service that violates EU law; and more specifically, German law.",
|
||||
"Intro.Agreement.Paragraph9": "You may delete your account at any time from within the Settings panel of the plugin. Any mods unique to you will then be removed from the server within 14 days.",
|
||||
"Intro.Agreement.Paragraph10": "This service is provided as-is.",
|
||||
"Intro.Agreement.Accept": "I agree",
|
||||
"Intro.Storage.Title": "File Storage Setup",
|
||||
"Intro.Storage.Description": "To not unnecessarily download files already present on your computer, Umbra will have to scan your Penumbra mod directory. Additionally, a local storage folder must be set where Umbra will download other character files to. Once the storage folder is set and the scan complete, this page will automatically forward to registration at a service.",
|
||||
"Intro.Storage.ScanNote": "Note: The initial scan, depending on the amount of mods you have, might take a while. Please wait until it is completed.",
|
||||
"Intro.Storage.Warning.FileCache": "Warning: once past this step you should not delete the FileCache.csv of Umbra in the Plugin Configurations folder of Dalamud. Otherwise on the next launch a full re-scan of the file cache database will be initiated.",
|
||||
"Intro.Storage.Warning.ScanHang": "Warning: if the scan is hanging and does nothing for a long time, chances are high your Penumbra folder is not set up properly.",
|
||||
"Intro.Storage.NoPenumbra": "You do not have a valid Penumbra path set. Open Penumbra and set up a valid path for the mod directory.",
|
||||
"Intro.Storage.StartScan": "Start Scan",
|
||||
"Intro.Storage.UseCompactor": "Use File Compactor",
|
||||
"Intro.Storage.CompactorDescription": "The File Compactor can save a tremendous amount of space on the hard disk for downloads through Umbra. It will incur a minor CPU penalty on download but can speed up loading of other characters. It is recommended to keep it enabled. You can change this setting later anytime in the Umbra settings.",
|
||||
"Intro.Registration.Title": "Service Registration",
|
||||
"Intro.Registration.Description": "To be able to use Umbra you will have to register an account.",
|
||||
"Intro.Registration.Support": "Refer to the instructions at the location you obtained this plugin for more information or support.",
|
||||
"Intro.Registration.NewAccountInfo": "If you have not used Umbra before, click below to register a new account.",
|
||||
"Intro.Registration.RegisterButton": "Register a new Umbra account",
|
||||
"Intro.Registration.SendingRequest": "Sending request...",
|
||||
"Intro.Registration.Success": "New account registered.\nPlease keep a copy of your secret key in case you need to reset your plugins, or to use it on another PC.",
|
||||
"Intro.Registration.UnknownError": "An unknown error occured. Please try again later.",
|
||||
"Intro.Registration.SecretKeyLabel": "Enter Secret Key",
|
||||
"Intro.Registration.SecretKeyLabelRegistered": "Secret Key",
|
||||
"Intro.Registration.SecretKeyInstructions": "If you already have a registered account, you can enter its secret key below to use it instead.",
|
||||
"Intro.Registration.SecretKeyLength": "Your secret key must be exactly 64 characters long.",
|
||||
"Intro.Registration.SecretKeyCharacters": "Your secret key can only contain ABCDEF and the numbers 0-9.",
|
||||
"Intro.Registration.SaveAndConnect": "Save and Connect",
|
||||
"Intro.Registration.SavedKeyRegistered": "(registered {0})",
|
||||
"Intro.Registration.SavedKeySetup": "Secret Key added on Setup ({0})",
|
||||
"Intro.ConnectionStatus.Connected": "Connected",
|
||||
"AutoDetect.Disabled": "Nearby detection is disabled. Enable it in Settings to start detecting nearby Umbra users.",
|
||||
"AutoDetect.MaxDistance": "Max distance (m)",
|
||||
"AutoDetect.Table.Name": "Name",
|
||||
"AutoDetect.Table.World": "World",
|
||||
"AutoDetect.Table.Distance": "Distance",
|
||||
"AutoDetect.Table.Status": "Status",
|
||||
"AutoDetect.Table.Action": "Action",
|
||||
"AutoDetect.World.Unknown": "-",
|
||||
"AutoDetect.Distance.Unknown": "-",
|
||||
"AutoDetect.Distance.Format": "{0:0.0} m",
|
||||
"AutoDetect.Status.Paired": "Paired",
|
||||
"AutoDetect.Status.RequestsDisabled": "Requests disabled",
|
||||
"AutoDetect.Status.OnUmbra": "On Umbra",
|
||||
"AutoDetect.Action.AlreadySynced": "Already sync",
|
||||
"AutoDetect.Action.RequestsDisabled": "Requests disabled",
|
||||
"AutoDetect.Action.SendRequest": "Send request",
|
||||
"PairGroups.ResumeAll": "Resume pairing with all pairs in {0}",
|
||||
"PairGroups.PauseAll": "Pause pairing with all pairs in {0}",
|
||||
"PairGroups.Menu.Title": "Group Flyout Menu",
|
||||
"PairGroups.Menu.AddPeople": "Add people to {0}",
|
||||
"PairGroups.Menu.AddPeople.Tooltip": "Add more users to Group {0}",
|
||||
"PairGroups.Menu.Delete": "Delete {0}",
|
||||
"PairGroups.Menu.Delete.Tooltip": "Delete Group {0} (Will not delete the pairs)\nHold CTRL to delete",
|
||||
"PairGroups.Tag.Unpaired": "Unpaired",
|
||||
"PairGroups.Tag.Offline": "Offline",
|
||||
"PairGroups.Tag.Online": "Online",
|
||||
"PairGroups.Tag.Contacts": "Contacts",
|
||||
"PairGroups.Tag.Visible": "Visible",
|
||||
"PairGroups.Header.WithCounts": "{0} ({1}/{2}/{3} Pairs)",
|
||||
"PairGroups.Header.Special": "{0} ({1} Pairs)",
|
||||
"PairGroups.Tooltip.Title": "Group {0}",
|
||||
"PairGroups.Tooltip.Visible": "{0} Pairs visible",
|
||||
"PairGroups.Tooltip.Online": "{0} Pairs online/paused",
|
||||
"PairGroups.Tooltip.Total": "{0} Pairs total",
|
||||
"GroupPanel.Join.InputHint": "Syncshell GID/Alias (leave empty to create)",
|
||||
"GroupPanel.Join.PasswordPopup": "Enter Syncshell Password",
|
||||
"GroupPanel.Create.PopupTitle": "Create Syncshell",
|
||||
"GroupPanel.Create.Tooltip": "Create Syncshell",
|
||||
"GroupPanel.Create.TooMany": "You cannot create more than {0} Syncshells",
|
||||
"GroupPanel.Join.Tooltip": "Join Syncshell {0}",
|
||||
"GroupPanel.Join.TooMany": "You cannot join more than {0} Syncshells",
|
||||
"GroupPanel.Join.Warning": "Before joining any Syncshells please be aware that you will be automatically paired with everyone in the Syncshell.",
|
||||
"GroupPanel.Join.EnterPassword": "Enter the password for Syncshell {0}:",
|
||||
"GroupPanel.Join.PasswordHint": "{0} Password",
|
||||
"GroupPanel.Join.Error": "An error occured during joining of this Syncshell: you either have joined the maximum amount of Syncshells ({0}), it does not exist, the password you entered is wrong, you already joined the Syncshell, the Syncshell is full ({1} users) or the Syncshell has closed invites.",
|
||||
"GroupPanel.Join.Button": "Join {0}",
|
||||
"GroupPanel.Create.ChooseType": "Choisissez le type de Syncshell \u00e0 cr\u00e9er.",
|
||||
"GroupPanel.Create.Permanent": "Permanente",
|
||||
"GroupPanel.Create.Temporary": "Temporaire",
|
||||
"GroupPanel.Create.AliasPrompt": "Donnez un nom \u00e0 votre Syncshell (optionnel) puis cr\u00e9ez-la.",
|
||||
"GroupPanel.Create.AliasHint": "Nom du Syncshell",
|
||||
"GroupPanel.Create.TempMaxDuration": "Dur\u00e9e maximale d'une Syncshell temporaire : 7 jours.",
|
||||
"GroupPanel.Create.TempExpires": "Expiration le {0:g} (heure locale).",
|
||||
"GroupPanel.Create.Instruction": "Appuyez sur le bouton ci-dessous pour cr\u00e9er une nouvelle Syncshell.",
|
||||
"GroupPanel.Create.Button": "Create Syncshell",
|
||||
"GroupPanel.Create.Error.NameInUse": "Le nom de la Syncshell est d\u00e9j\u00e0 utilis\u00e9.",
|
||||
"GroupPanel.Create.Result.Name": "Syncshell Name: {0}",
|
||||
"GroupPanel.Create.Result.Id": "Syncshell ID: {0}",
|
||||
"GroupPanel.Create.Result.Password": "Syncshell Password: {0}",
|
||||
"GroupPanel.Create.Result.ChangeLater": "You can change the Syncshell password later at any time.",
|
||||
"GroupPanel.Create.Result.TempExpires": "Cette Syncshell expirera le {0:g} (heure locale).",
|
||||
"GroupPanel.Create.Error.Generic": "You are already owner of the maximum amount of Syncshells (3) or joined the maximum amount of Syncshells (6). Relinquish ownership of your own Syncshells to someone else or leave existing Syncshells.",
|
||||
"GroupPanel.CommentHint": "Comment/Notes",
|
||||
"GroupPanel.CommentTooltip": "Hit ENTER to save\\nRight click to cancel",
|
||||
"GroupPanel.Banlist.Title": "Manage Banlist for {0}",
|
||||
"GroupPanel.Banlist.Refresh": "Refresh Banlist from Server",
|
||||
"GroupPanel.Banlist.Column.Uid": "UID",
|
||||
"GroupPanel.Banlist.Column.Alias": "Alias",
|
||||
"GroupPanel.Banlist.Column.By": "By",
|
||||
"GroupPanel.Banlist.Column.Date": "Date",
|
||||
"GroupPanel.Banlist.Column.Reason": "Reason",
|
||||
"GroupPanel.Banlist.Column.Actions": "Actions",
|
||||
"GroupPanel.Banlist.Unban": "Unban",
|
||||
"GroupPanel.Password.Title": "Change Syncshell Password",
|
||||
"GroupPanel.Password.Description": "Enter the new Syncshell password for Syncshell {0} here.",
|
||||
"GroupPanel.Password.Warning": "This action is irreversible",
|
||||
"GroupPanel.Password.Hint": "New password for {0}",
|
||||
"GroupPanel.Password.Button": "Change password",
|
||||
"GroupPanel.Password.Error.TooShort": "The selected password is too short. It must be at least 10 characters.",
|
||||
"GroupPanel.Invites.Title": "Create Bulk One-Time Invites",
|
||||
"GroupPanel.Invites.Description": "This allows you to create up to 100 one-time invites at once for the Syncshell {0}.\\nThe invites are valid for 24h after creation and will automatically expire.",
|
||||
"GroupPanel.Invites.CreateButton": "Create invites",
|
||||
"GroupPanel.Invites.Result": "A total of {0} invites have been created.",
|
||||
"GroupPanel.Invites.Copy": "Copy invites to clipboard",
|
||||
"GroupPanel.List.Visible": "Visible",
|
||||
"GroupPanel.List.Online": "Online",
|
||||
"GroupPanel.List.Offline": "Offline/Unknown",
|
||||
"GroupPanel.List.OfflineOmitted": "{0} offline users omitted from display.",
|
||||
"GroupPanel.Permissions.Header": "Syncshell permissions",
|
||||
"GroupPanel.Permissions.InvitesDisabled": "Syncshell is closed for joining",
|
||||
"GroupPanel.Permissions.SoundDisabledOwner": "Sound sync disabled through owner",
|
||||
"GroupPanel.Permissions.AnimationDisabledOwner": "Animation sync disabled through owner",
|
||||
"GroupPanel.Permissions.VfxDisabledOwner": "VFX sync disabled through owner",
|
||||
"GroupPanel.Permissions.OwnHeader": "Your permissions",
|
||||
"GroupPanel.Permissions.SoundDisabledSelf": "Sound sync disabled through you",
|
||||
"GroupPanel.Permissions.AnimationDisabledSelf": "Animation sync disabled through you",
|
||||
"GroupPanel.Permissions.VfxDisabledSelf": "VFX sync disabled through you",
|
||||
"GroupPanel.Permissions.NotePriority": "Note that syncshell permissions for disabling take precedence over your own set permissions",
|
||||
"GroupPanel.PauseToggle.Tooltip": "{0} pairing with all users in this Syncshell",
|
||||
"GroupPanel.PauseToggle.Resume": "Resume",
|
||||
"GroupPanel.PauseToggle.Pause": "Pause",
|
||||
"GroupPanel.Popup.Leave": "Leave Syncshell",
|
||||
"GroupPanel.Popup.LeaveTooltip": "Hold CTRL and click to leave this Syncshell{0}",
|
||||
"GroupPanel.Popup.LeaveWarning": "WARNING: This action is irreversible\\nLeaving an owned Syncshell will transfer the ownership to a random person in the Syncshell.",
|
||||
"GroupPanel.Popup.CopyId": "Copy ID",
|
||||
"GroupPanel.Popup.CopyIdTooltip": "Copy Syncshell ID to Clipboard",
|
||||
"GroupPanel.Popup.CopyNotes": "Copy Notes",
|
||||
"GroupPanel.Popup.CopyNotesTooltip": "Copies all your notes for all users in this Syncshell to the clipboard.\\nThey can be imported via Settings -> General -> Notes -> Import notes from clipboard",
|
||||
"GroupPanel.Popup.EnableSound": "Enable sound sync",
|
||||
"GroupPanel.Popup.DisableSound": "Disable sound sync",
|
||||
"GroupPanel.Popup.SoundTooltip": "Sets your allowance for sound synchronization for users of this syncshell.\\nDisabling the synchronization will stop applying sound modifications for users of this syncshell.\\nNote: this setting can be forcefully overridden to 'disabled' through the syncshell owner.\\nNote: this setting does not apply to individual pairs that are also in the syncshell.",
|
||||
"GroupPanel.Popup.EnableAnimations": "Enable animations sync",
|
||||
"GroupPanel.Popup.DisableAnimations": "Disable animations sync",
|
||||
"GroupPanel.Popup.AnimTooltip": "Sets your allowance for animations synchronization for users of this syncshell.\\nDisabling the synchronization will stop applying animations modifications for users of this syncshell.\\nNote: this setting might also affect sound synchronization\\nNote: this setting can be forcefully overridden to 'disabled' through the syncshell owner.\\nNote: this setting does not apply to individual pairs that are also in the syncshell.",
|
||||
"GroupPanel.Popup.EnableVfx": "Enable VFX sync",
|
||||
"GroupPanel.Popup.DisableVfx": "Disable VFX sync",
|
||||
"GroupPanel.Popup.VfxTooltip": "Sets your allowance for VFX synchronization for users of this syncshell.\\nDisabling the synchronization will stop applying VFX modifications for users of this syncshell.\\nNote: this setting might also affect animation synchronization to some degree\\nNote: this setting can be forcefully overridden to 'disabled' through the syncshell owner.\\nNote: this setting does not apply to individual pairs that are also in the syncshell.",
|
||||
"GroupPanel.Syncshell.OwnerTooltip": "You are the owner of Syncshell {0}",
|
||||
"GroupPanel.Syncshell.ModeratorTooltip": "You are a moderator of Syncshell {0}",
|
||||
"GroupPanel.Syncshell.MemberCount": "{0}/{1}",
|
||||
"GroupPanel.Syncshell.MemberCountTooltip": "Membres connect\u00e9s / membres totaux\\nCapacit\u00e9 maximale : {0}\\nSyncshell ID: {1}",
|
||||
"GroupPanel.Syncshell.NameTooltip": "Left click to switch between GID display and comment\\nRight click to change comment for {0}\\n\\nUsers: {1}, Owner: {2}",
|
||||
"GroupPanel.Syncshell.TempTag": "(Temp)",
|
||||
"GroupPanel.Syncshell.TempExpires": "Expire le {0:g}",
|
||||
"GroupPanel.Syncshell.TempTooltip": "Syncshell temporaire",
|
||||
"GroupPanel.Create.Duration.SingleDay": "24h",
|
||||
"GroupPanel.Create.Duration.Days": "{0}j",
|
||||
"GroupPanel.Create.Duration.Hours": "{0}h",
|
||||
"GroupPanel.Invites.AmountLabel": "Amount",
|
||||
"GroupPanel.Popup.OpenAdmin": "Open Admin Panel"
|
||||
}
|
||||
@@ -1,579 +0,0 @@
|
||||
{
|
||||
"Language.DisplayName.French": "Français",
|
||||
"Language.DisplayName.English": "Anglais",
|
||||
"Settings.Plugins.MandatoryHeading": "",
|
||||
"Settings.Plugins.MandatoryLabel": "",
|
||||
"Settings.Plugins.OptionalHeading": "",
|
||||
"Settings.Plugins.OptionalLabel": "",
|
||||
"Settings.Plugins.OptionalDescription": "",
|
||||
"Settings.Plugins.Tooltip.Available": "",
|
||||
"Settings.Plugins.Tooltip.Unavailable": "",
|
||||
"Settings.Plugins.WarningMandatoryMissing": "",
|
||||
"Settings.General.LocalizationHeading": "Langue du plugin",
|
||||
"Settings.General.Language": "Langue",
|
||||
"Settings.General.Language.Description": "Sélectionnez la langue du plugin. Les traductions manquantes seront affichées en anglais.",
|
||||
"Settings.General.NotesHeading": "",
|
||||
"Settings.General.Notes.Export": "",
|
||||
"Settings.General.Notes.Import": "",
|
||||
"Settings.General.Notes.Overwrite": "",
|
||||
"Settings.General.Notes.Overwrite.Description": "",
|
||||
"Settings.General.Notes.Import.Success": "",
|
||||
"Settings.General.Notes.Import.Failure": "",
|
||||
"Settings.General.Notes.OpenPopup": "",
|
||||
"Settings.General.Notes.OpenPopup.Description": "",
|
||||
"Settings.Transfers.Blocked.Description": "",
|
||||
"Settings.Transfers.Blocked.Column.Hash": "",
|
||||
"Settings.Transfers.Blocked.Column.ForbiddenBy": "",
|
||||
"Settings.Transfers.Blocked.Tab": "",
|
||||
"Settings.Transfers.Heading": "",
|
||||
"Settings.Transfers.GlobalLimit.Label": "",
|
||||
"Settings.Transfers.GlobalLimit.Unit.BytePerSec": "",
|
||||
"Settings.Transfers.GlobalLimit.Unit.KiloBytePerSec": "",
|
||||
"Settings.Transfers.GlobalLimit.Unit.MegaBytePerSec": "",
|
||||
"Settings.Transfers.GlobalLimit.Hint": "",
|
||||
"Settings.Transfers.MaxParallelDownloads": "",
|
||||
"Settings.Transfers.AutoDetect.Heading": "",
|
||||
"Settings.Transfers.AutoDetect.EnableNearby": "",
|
||||
"Settings.Transfers.AutoDetect.AllowRequests": "",
|
||||
"Settings.Transfers.AutoDetect.Notification.Title": "",
|
||||
"Settings.Transfers.AutoDetect.Notification.Enabled": "",
|
||||
"Settings.Transfers.AutoDetect.Notification.Disabled": "",
|
||||
"Settings.Transfers.AutoDetect.MaxDistance": "",
|
||||
"Settings.Transfers.UI.Heading": "",
|
||||
"Settings.Transfers.UI.ShowWindow": "",
|
||||
"Settings.Transfers.UI.ShowWindow.Description": "",
|
||||
"Settings.Transfers.UI.EditWindowPosition": "",
|
||||
"Settings.Transfers.UI.ShowTransferBars": "",
|
||||
"Settings.Transfers.UI.ShowTransferBars.Description": "",
|
||||
"Settings.Transfers.UI.ShowDownloadText": "",
|
||||
"Settings.Transfers.UI.ShowDownloadText.Description": "",
|
||||
"Settings.Transfers.UI.BarWidth": "",
|
||||
"Settings.Transfers.UI.BarWidth.Description": "",
|
||||
"Settings.Transfers.UI.BarHeight": "",
|
||||
"Settings.Transfers.UI.BarHeight.Description": "",
|
||||
"Settings.Transfers.UI.ShowUploading": "",
|
||||
"Settings.Transfers.UI.ShowUploading.Description": "",
|
||||
"Settings.Transfers.UI.ShowUploadingBigText": "",
|
||||
"Settings.Transfers.UI.ShowUploadingBigText.Description": "",
|
||||
"Settings.Transfers.Current.Heading": "",
|
||||
"Settings.Transfers.Current.Tab": "",
|
||||
"Settings.Transfers.Current.Uploads": "",
|
||||
"Settings.Transfers.Current.Uploads.Column.File": "",
|
||||
"Settings.Transfers.Current.Uploads.Column.Uploaded": "",
|
||||
"Settings.Transfers.Current.Uploads.Column.Size": "",
|
||||
"Settings.Transfers.Current.Downloads": "",
|
||||
"Settings.Transfers.Current.Downloads.Column.User": "",
|
||||
"Settings.Transfers.Current.Downloads.Column.Server": "",
|
||||
"Settings.Transfers.Current.Downloads.Column.Files": "",
|
||||
"Settings.Transfers.Current.Downloads.Column.Download": "",
|
||||
"Settings.Storage.Heading": "",
|
||||
"Settings.Storage.Description": "",
|
||||
"Settings.Service.ActionsHeading": "",
|
||||
"Settings.Service.Actions.DeleteAccount": "",
|
||||
"Settings.Service.Actions.DeleteAccountPopup": "",
|
||||
"Settings.Service.Actions.DeleteAccount.Description": "",
|
||||
"Settings.Service.Actions.DeleteAccount.Popup.Body1": "",
|
||||
"Settings.Service.Actions.DeleteAccount.Popup.Body2": "",
|
||||
"Settings.Service.Actions.DeleteAccount.Popup.Confirm": "",
|
||||
"Settings.Service.Actions.DeleteAccount.Popup.Cancel": "",
|
||||
"Settings.Service.SettingsHeading": "",
|
||||
"Settings.Service.ReconnectWarning": "",
|
||||
"Settings.Service.Tabs.CharacterAssignments": "",
|
||||
"Settings.Service.Tabs.SecretKey": "",
|
||||
"Settings.Service.Tabs.ServiceSettings": "",
|
||||
"Settings.Service.Character.Assignments.Description": "",
|
||||
"Settings.Service.Character.Assignments.TooltipCurrent": "",
|
||||
"Settings.Service.Character.Assignments.DeleteTooltip": "",
|
||||
"Settings.Service.Character.Assignments.AddCurrent": "",
|
||||
"Settings.Service.Character.Assignments.NoKeys": "",
|
||||
"Settings.Service.SecretKey.DisplayName": "",
|
||||
"Settings.Service.SecretKey.Value": "",
|
||||
"Settings.Service.SecretKey.AssignCurrent": "",
|
||||
"Settings.Service.SecretKey.AssignTooltip": "",
|
||||
"Settings.Service.SecretKey.Delete": "",
|
||||
"Settings.Service.SecretKey.DeleteTooltip": "",
|
||||
"Settings.Service.SecretKey.InUse": "",
|
||||
"Settings.Service.SecretKey.Add": "",
|
||||
"Settings.Service.SecretKey.NewFriendlyName": "",
|
||||
"Settings.Service.SecretKey.RegisterAccount": "",
|
||||
"Settings.Service.SecretKey.RegisterFailed": "",
|
||||
"Settings.Service.SecretKey.RegisterSuccess": "",
|
||||
"Settings.Service.SecretKey.RegisteredFriendlyName": "",
|
||||
"Settings.Service.SecretKey.Registering": "",
|
||||
"Settings.Service.ServiceTab.Uri": "",
|
||||
"Settings.Service.ServiceTab.UriReadOnlyHint": "",
|
||||
"Settings.Service.ServiceTab.Name": "",
|
||||
"Settings.Service.ServiceTab.NameReadOnlyHint": "",
|
||||
"Settings.Service.ServiceTab.Delete": "",
|
||||
"Settings.Service.ServiceTab.DeleteHint": "",
|
||||
"Settings.Advanced.Heading": "",
|
||||
"Settings.Advanced.Tab": "",
|
||||
"Settings.Advanced.Api.Enable": "",
|
||||
"Settings.Advanced.Api.Description": "",
|
||||
"Settings.Advanced.Api.Status.Active": "",
|
||||
"Settings.Advanced.Api.Status.Disabled": "",
|
||||
"Settings.Advanced.Api.Status.PluginLoaded": "",
|
||||
"Settings.Advanced.Api.Status.Unknown": "",
|
||||
"Settings.Advanced.EventViewer.LogToDisk": "",
|
||||
"Settings.Advanced.EventViewer.Open": "",
|
||||
"Settings.Advanced.HoldCombat": "",
|
||||
"Settings.Advanced.SerializedApplications": "",
|
||||
"Settings.Advanced.SerializedApplications.Description": "",
|
||||
"Settings.Advanced.DebugHeading": "",
|
||||
"Settings.Advanced.Debug.LastCreatedTree": "",
|
||||
"Settings.Advanced.Debug.CopyButton": "",
|
||||
"Settings.Advanced.Debug.CopyError": "",
|
||||
"Settings.Advanced.Debug.CopyTooltip": "",
|
||||
"Settings.Advanced.LogLevel": "",
|
||||
"Settings.Advanced.Performance.LogCounters": "",
|
||||
"Settings.Advanced.Performance.LogCounters.Description": "",
|
||||
"Settings.Advanced.Performance.PrintStats": "",
|
||||
"Settings.Advanced.Performance.PrintStatsRecent": "",
|
||||
"Settings.Advanced.ActiveBlocks": "",
|
||||
"Settings.UI.Heading": "",
|
||||
"Settings.UI.EnableRightClick": "",
|
||||
"Settings.UI.EnableRightClick.Description": "",
|
||||
"Settings.UI.EnableDtrEntry": "",
|
||||
"Settings.UI.EnableDtrEntry.Description": "",
|
||||
"Settings.UI.Dtr.ShowUid": "",
|
||||
"Settings.UI.Dtr.PreferNotes": "",
|
||||
"Settings.UI.Dtr.UseColors": "",
|
||||
"Settings.UI.Dtr.ColorDefault": "",
|
||||
"Settings.UI.Dtr.ColorNotConnected": "",
|
||||
"Settings.UI.Dtr.ColorPairsInRange": "",
|
||||
"Settings.UI.NameColors.Enable": "",
|
||||
"Settings.UI.NameColors.Character": "",
|
||||
"Settings.UI.NameColors.Blocked": "",
|
||||
"Settings.UI.VisibleGroup": "",
|
||||
"Settings.UI.VisibleGroup.Description": "",
|
||||
"Settings.UI.OfflineGroup": "",
|
||||
"Settings.UI.OfflineGroup.Description": "",
|
||||
"Settings.UI.ShowPlayerNames": "",
|
||||
"Settings.UI.ShowPlayerNames.Description": "",
|
||||
"Settings.UI.Profiles.Show": "",
|
||||
"Settings.UI.Profiles.Show.Description": "",
|
||||
"Settings.UI.Profiles.PopoutRight": "",
|
||||
"Settings.UI.Profiles.PopoutRight.Description": "",
|
||||
"Settings.UI.Profiles.HoverDelay": "",
|
||||
"Settings.UI.Profiles.HoverDelay.Description": "",
|
||||
"Settings.UI.Profiles.ShowNsfw": "",
|
||||
"Settings.UI.Profiles.ShowNsfw.Description": "",
|
||||
"Settings.Notifications.Heading": "",
|
||||
"Settings.Notifications.InfoDisplay": "",
|
||||
"Settings.Notifications.InfoDisplay.Description": "",
|
||||
"Settings.Notifications.WarningDisplay": "",
|
||||
"Settings.Notifications.WarningDisplay.Description": "",
|
||||
"Settings.Notifications.ErrorDisplay": "",
|
||||
"Settings.Notifications.ErrorDisplay.Description": "",
|
||||
"Settings.Notifications.Location.Nowhere": "",
|
||||
"Settings.Notifications.Location.Chat": "",
|
||||
"Settings.Notifications.Location.Toast": "",
|
||||
"Settings.Notifications.Location.Both": "",
|
||||
"Settings.Notifications.DisableOptionalWarnings": "",
|
||||
"Settings.Notifications.DisableOptionalWarnings.Description": "",
|
||||
"Settings.Notifications.EnableOnlineNotifications": "",
|
||||
"Settings.Notifications.EnableOnlineNotifications.Description": "",
|
||||
"Settings.Notifications.IndividualPairsOnly": "",
|
||||
"Settings.Notifications.IndividualPairsOnly.Description": "",
|
||||
"Settings.Notifications.NamedPairsOnly": "",
|
||||
"Settings.Notifications.NamedPairsOnly.Description": "",
|
||||
"Compact.Version.UnsupportedTitle": "",
|
||||
"Compact.Version.Outdated": "",
|
||||
"Compact.Toggle.IndividualPairs": "",
|
||||
"Compact.Toggle.Syncshells": "",
|
||||
"Compact.AddUser.ModalTitle": "",
|
||||
"Compact.AddUser.Description": "",
|
||||
"Compact.AddUser.NoteHint": "",
|
||||
"Compact.AddUser.Save": "",
|
||||
"Compact.AddCharacter.Button": "",
|
||||
"Compact.AddCharacter.SecretKeyLabel": "",
|
||||
"Compact.AddCharacter.NoKeys": "",
|
||||
"Compact.AddPair.Hint": "",
|
||||
"Compact.AddPair.Tooltip": "",
|
||||
"Compact.AddPair.Tooltip.DefaultUser": "",
|
||||
"Compact.Filter.Hint": "",
|
||||
"Compact.Filter.ToggleTooltip": "",
|
||||
"Compact.Filter.ToggleTooltip.Resume": "",
|
||||
"Compact.Filter.ToggleTooltip.Pause": "",
|
||||
"Compact.Filter.CooldownTooltip": "",
|
||||
"Compact.Nearby.Title": "",
|
||||
"Compact.Nearby.Button": "",
|
||||
"Compact.Nearby.None": "",
|
||||
"Compact.Nearby.Tooltip.AlreadyPaired": "",
|
||||
"Compact.Nearby.Tooltip.RequestsDisabled": "",
|
||||
"Compact.Nearby.Tooltip.SendInvite": "",
|
||||
"Compact.Nearby.Tooltip.CannotInvite": "",
|
||||
"Compact.Nearby.Incoming": "",
|
||||
"Compact.Nearby.Incoming.Entry": "",
|
||||
"Compact.Nearby.Incoming.Accept": "",
|
||||
"Compact.Nearby.Incoming.Dismiss": "",
|
||||
"Compact.Header.SettingsTooltip": "",
|
||||
"Compact.Header.CopyUid": "",
|
||||
"Compact.ServerStatus.UsersOnline": "",
|
||||
"Compact.ServerStatus.Shard": "",
|
||||
"Compact.ServerStatus.NotConnected": "",
|
||||
"Compact.ServerStatus.EditProfile": "",
|
||||
"Compact.ServerStatus.Disconnect": "",
|
||||
"Compact.ServerStatus.Connect": "",
|
||||
"Compact.ServerError.Connecting": "",
|
||||
"Compact.ServerError.Reconnecting": "",
|
||||
"Compact.ServerError.Disconnected": "",
|
||||
"Compact.ServerError.Disconnecting": "",
|
||||
"Compact.ServerError.Unauthorized": "",
|
||||
"Compact.ServerError.Offline": "",
|
||||
"Compact.ServerError.VersionMismatch": "",
|
||||
"Compact.ServerError.RateLimited": "",
|
||||
"Compact.ServerError.NoSecretKey": "",
|
||||
"Compact.ServerError.MultiChara": "",
|
||||
"Compact.Transfers.CharacterAnalysis": "",
|
||||
"Compact.Transfers.CharacterDataHub": "",
|
||||
"Compact.UidText.Reconnecting": "",
|
||||
"Compact.UidText.Connecting": "",
|
||||
"Compact.UidText.Disconnected": "",
|
||||
"Compact.UidText.Disconnecting": "",
|
||||
"Compact.UidText.Unauthorized": "",
|
||||
"Compact.UidText.VersionMismatch": "",
|
||||
"Compact.UidText.Offline": "",
|
||||
"Compact.UidText.RateLimited": "",
|
||||
"Compact.UidText.NoSecretKey": "",
|
||||
"Compact.UidText.MultiChara": "",
|
||||
"UserPair.Status.Online": "",
|
||||
"UserPair.Status.Offline": "",
|
||||
"UserPair.Tooltip.NotAddedBack": "",
|
||||
"UserPair.Tooltip.Paused": "",
|
||||
"UserPair.Tooltip.Visible": "",
|
||||
"UserPair.Tooltip.Visible.LastPrefix": "",
|
||||
"UserPair.Tooltip.Visible.ModsInfo": "",
|
||||
"UserPair.Tooltip.Visible.FilesSize": "",
|
||||
"UserPair.Tooltip.Visible.Vram": "",
|
||||
"UserPair.Tooltip.Visible.Tris": "",
|
||||
"UserPair.Tooltip.Pause": "",
|
||||
"UserPair.Tooltip.Resume": "",
|
||||
"UserPair.Tooltip.Permission.Header": "",
|
||||
"UserPair.Tooltip.Permission.Sound": "",
|
||||
"UserPair.Tooltip.Permission.Animation": "",
|
||||
"UserPair.Tooltip.Permission.Vfx": "",
|
||||
"UserPair.Tooltip.Permission.Status": "",
|
||||
"UserPair.Tooltip.Permission.State.Disabled": "",
|
||||
"UserPair.Tooltip.Permission.State.Enabled": "",
|
||||
"UserPair.Tooltip.SharedData": "",
|
||||
"UserPair.Tooltip.SharedData.OpenHub": "",
|
||||
"UserPair.Menu.Target": "",
|
||||
"UserPair.Menu.OpenProfile": "",
|
||||
"UserPair.Menu.OpenProfile.Tooltip": "",
|
||||
"UserPair.Menu.OpenAnalysis": "",
|
||||
"UserPair.Menu.ReloadData": "",
|
||||
"UserPair.Menu.ReloadData.Tooltip": "",
|
||||
"UserPair.Menu.CyclePause": "",
|
||||
"UserPair.Menu.PairGroups": "",
|
||||
"UserPair.Menu.PairGroups.Tooltip": "",
|
||||
"UserPair.Menu.EnableSoundSync": "",
|
||||
"UserPair.Menu.DisableSoundSync": "",
|
||||
"UserPair.Menu.EnableAnimationSync": "",
|
||||
"UserPair.Menu.DisableAnimationSync": "",
|
||||
"UserPair.Menu.EnableVfxSync": "",
|
||||
"UserPair.Menu.DisableVfxSync": "",
|
||||
"UserPair.Menu.Unpair": "",
|
||||
"UserPair.Menu.Unpair.Tooltip": "",
|
||||
"Popup.Generic.Close": "",
|
||||
"Popup.BanUser.Description": "",
|
||||
"Popup.BanUser.ReasonHint": "",
|
||||
"Popup.BanUser.Button": "",
|
||||
"Popup.BanUser.ReasonNote": "",
|
||||
"Popup.Report.Title": "",
|
||||
"Popup.Report.Note": "",
|
||||
"Popup.Report.Warning": "",
|
||||
"Popup.Report.Scope": "",
|
||||
"Popup.Report.Button": "",
|
||||
"PairGroups.Popup.Title": "",
|
||||
"PairGroups.Popup.SelectPrompt": "",
|
||||
"PairGroups.Popup.CreatePrompt": "",
|
||||
"PairGroups.Popup.NewGroupHint": "",
|
||||
"PairGroups.SelectPairs.Title": "",
|
||||
"PairGroups.SelectPairs.SelectPrompt": "",
|
||||
"PairGroups.SelectPairs.FilterHint": "",
|
||||
"UidDisplay.Tooltip": "",
|
||||
"UidDisplay.EditNotes.Hint": "",
|
||||
"DataAnalysis.WindowTitle": "",
|
||||
"DataAnalysis.Bc7.ModalTitle": "",
|
||||
"DataAnalysis.Bc7.Status": "",
|
||||
"DataAnalysis.Bc7.CurrentFile": "",
|
||||
"DataAnalysis.Bc7.Cancel": "",
|
||||
"DataAnalysis.Description": "",
|
||||
"DataAnalysis.Analyzing": "",
|
||||
"DataAnalysis.Button.CancelAnalysis": "",
|
||||
"DataAnalysis.Analyze.MissingNotice": "",
|
||||
"DataAnalysis.Button.StartMissing": "",
|
||||
"DataAnalysis.Button.StartAll": "",
|
||||
"DataAnalysis.TotalFiles": "",
|
||||
"DataAnalysis.Tooltip.FileSummary": "",
|
||||
"DataAnalysis.TotalSizeActual": "",
|
||||
"DataAnalysis.TotalSizeDownload": "",
|
||||
"DataAnalysis.Tooltip.CalculateDownloadSize": "",
|
||||
"DataAnalysis.TotalTriangles": "",
|
||||
"DataAnalysis.FilesFor": "",
|
||||
"DataAnalysis.Object.SizeActual": "",
|
||||
"DataAnalysis.Object.SizeDownload": "",
|
||||
"DataAnalysis.Object.Vram": "",
|
||||
"DataAnalysis.Object.Triangles": "",
|
||||
"DataAnalysis.FileGroup.Count": "",
|
||||
"DataAnalysis.FileGroup.SizeActual": "",
|
||||
"DataAnalysis.FileGroup.SizeDownload": "",
|
||||
"DataAnalysis.Bc7.EnableMode": "",
|
||||
"DataAnalysis.Bc7.WarningTitle": "",
|
||||
"DataAnalysis.Bc7.WarningIrreversible": "",
|
||||
"DataAnalysis.Bc7.WarningDetails": "",
|
||||
"DataAnalysis.Bc7.StartConversion": "",
|
||||
"DataAnalysis.Table.Hash": "",
|
||||
"DataAnalysis.Table.Filepaths": "",
|
||||
"DataAnalysis.Table.Gamepaths": "",
|
||||
"DataAnalysis.Table.FileSize": "",
|
||||
"DataAnalysis.Table.DownloadSize": "",
|
||||
"DataAnalysis.Table.Format": "",
|
||||
"DataAnalysis.Table.ConvertToBc7": "",
|
||||
"DataAnalysis.Table.Triangles": "",
|
||||
"DataAnalysis.SelectedFile": "",
|
||||
"DataAnalysis.LocalFilePath": "",
|
||||
"DataAnalysis.MoreCount": "",
|
||||
"DataAnalysis.GamePath": "",
|
||||
"DownloadUi.WindowTitle": "",
|
||||
"DownloadUi.UploadStatus": "",
|
||||
"DownloadUi.DownloadStatus": "",
|
||||
"DownloadUi.UploadingLabel": "",
|
||||
"EventViewer.WindowTitle": "",
|
||||
"EventViewer.Button.Unfreeze": "",
|
||||
"EventViewer.Button.Freeze": "",
|
||||
"EventViewer.Tooltip.NewEvents": "",
|
||||
"EventViewer.FilterLabel": "",
|
||||
"EventViewer.Button.OpenLog": "",
|
||||
"EventViewer.Column.Time": "",
|
||||
"EventViewer.Column.Source": "",
|
||||
"EventViewer.Column.Uid": "",
|
||||
"EventViewer.Column.Character": "",
|
||||
"EventViewer.Column.Event": "",
|
||||
"EventViewer.Severity.Informational": "",
|
||||
"EventViewer.Severity.Warning": "",
|
||||
"EventViewer.Severity.Error": "",
|
||||
"EventViewer.NoValue": "",
|
||||
"DtrEntry.EntryName": "",
|
||||
"DtrEntry.Tooltip.Connected": "",
|
||||
"DtrEntry.Tooltip.Disconnected": "",
|
||||
"PermissionWindow.Title": "",
|
||||
"PermissionWindow.Pause.Label": "",
|
||||
"PermissionWindow.Pause.HelpMain": "",
|
||||
"PermissionWindow.Pause.HelpNote": "",
|
||||
"PermissionWindow.OtherPaused.True": "",
|
||||
"PermissionWindow.OtherPaused.False": "",
|
||||
"PermissionWindow.Sounds.Label": "",
|
||||
"PermissionWindow.Sounds.HelpMain": "",
|
||||
"PermissionWindow.Sounds.HelpNote": "",
|
||||
"PermissionWindow.OtherSoundDisabled.True": "",
|
||||
"PermissionWindow.OtherSoundDisabled.False": "",
|
||||
"PermissionWindow.Animations.Label": "",
|
||||
"PermissionWindow.Animations.HelpMain": "",
|
||||
"PermissionWindow.Animations.HelpNote": "",
|
||||
"PermissionWindow.OtherAnimationDisabled.True": "",
|
||||
"PermissionWindow.OtherAnimationDisabled.False": "",
|
||||
"PermissionWindow.Vfx.Label": "",
|
||||
"PermissionWindow.Vfx.HelpMain": "",
|
||||
"PermissionWindow.Vfx.HelpNote": "",
|
||||
"PermissionWindow.OtherVfxDisabled.True": "",
|
||||
"PermissionWindow.OtherVfxDisabled.False": "",
|
||||
"PermissionWindow.Button.Save": "",
|
||||
"PermissionWindow.Tooltip.Save": "",
|
||||
"PermissionWindow.Button.Revert": "",
|
||||
"PermissionWindow.Tooltip.Revert": "",
|
||||
"PermissionWindow.Button.Reset": "",
|
||||
"PermissionWindow.Tooltip.Reset": "",
|
||||
"EditProfile.WindowTitle": "",
|
||||
"EditProfile.CurrentProfile": "",
|
||||
"EditProfile.Button.UploadPicture": "",
|
||||
"EditProfile.Dialog.PictureTitle": "",
|
||||
"EditProfile.Tooltip.UploadPicture": "",
|
||||
"EditProfile.Button.ClearPicture": "",
|
||||
"EditProfile.Tooltip.ClearPicture": "",
|
||||
"EditProfile.Error.PictureTooLarge": "",
|
||||
"EditProfile.Checkbox.Nsfw": "",
|
||||
"EditProfile.Help.Nsfw": "",
|
||||
"EditProfile.DescriptionCounter": "",
|
||||
"EditProfile.PreviewLabel": "",
|
||||
"EditProfile.Button.SaveDescription": "",
|
||||
"EditProfile.Tooltip.SaveDescription": "",
|
||||
"EditProfile.Button.ClearDescription": "",
|
||||
"EditProfile.Tooltip.ClearDescription": "",
|
||||
"Intro.Welcome.Title": "",
|
||||
"Intro.Welcome.Paragraph1": "",
|
||||
"Intro.Welcome.Paragraph2": "",
|
||||
"Intro.Welcome.Note": "",
|
||||
"Intro.Welcome.Next": "",
|
||||
"Intro.Agreement.Title": "",
|
||||
"Intro.Agreement.Callout": "",
|
||||
"Intro.Agreement.Timeout": "",
|
||||
"Intro.Agreement.Paragraph1": "",
|
||||
"Intro.Agreement.Paragraph2": "",
|
||||
"Intro.Agreement.Paragraph3": "",
|
||||
"Intro.Agreement.Paragraph4": "",
|
||||
"Intro.Agreement.Paragraph5": "",
|
||||
"Intro.Agreement.Paragraph6": "",
|
||||
"Intro.Agreement.Paragraph7": "",
|
||||
"Intro.Agreement.Paragraph8": "",
|
||||
"Intro.Agreement.Paragraph9": "",
|
||||
"Intro.Agreement.Paragraph10": "",
|
||||
"Intro.Agreement.Accept": "",
|
||||
"Intro.Storage.Title": "",
|
||||
"Intro.Storage.Description": "",
|
||||
"Intro.Storage.ScanNote": "",
|
||||
"Intro.Storage.Warning.FileCache": "",
|
||||
"Intro.Storage.Warning.ScanHang": "",
|
||||
"Intro.Storage.NoPenumbra": "",
|
||||
"Intro.Storage.StartScan": "",
|
||||
"Intro.Storage.UseCompactor": "",
|
||||
"Intro.Storage.CompactorDescription": "",
|
||||
"Intro.Registration.Title": "",
|
||||
"Intro.Registration.Description": "",
|
||||
"Intro.Registration.Support": "",
|
||||
"Intro.Registration.NewAccountInfo": "",
|
||||
"Intro.Registration.RegisterButton": "",
|
||||
"Intro.Registration.SendingRequest": "",
|
||||
"Intro.Registration.Success": "",
|
||||
"Intro.Registration.UnknownError": "",
|
||||
"Intro.Registration.SecretKeyLabel": "",
|
||||
"Intro.Registration.SecretKeyLabelRegistered": "",
|
||||
"Intro.Registration.SecretKeyInstructions": "",
|
||||
"Intro.Registration.SecretKeyLength": "",
|
||||
"Intro.Registration.SecretKeyCharacters": "",
|
||||
"Intro.Registration.SaveAndConnect": "",
|
||||
"Intro.Registration.SavedKeyRegistered": "",
|
||||
"Intro.Registration.SavedKeySetup": "",
|
||||
"Intro.ConnectionStatus.Connected": "",
|
||||
"AutoDetect.Disabled": "",
|
||||
"AutoDetect.MaxDistance": "",
|
||||
"AutoDetect.Table.Name": "",
|
||||
"AutoDetect.Table.World": "",
|
||||
"AutoDetect.Table.Distance": "",
|
||||
"AutoDetect.Table.Status": "",
|
||||
"AutoDetect.Table.Action": "",
|
||||
"AutoDetect.World.Unknown": "",
|
||||
"AutoDetect.Distance.Unknown": "",
|
||||
"AutoDetect.Distance.Format": "",
|
||||
"AutoDetect.Status.Paired": "",
|
||||
"AutoDetect.Status.RequestsDisabled": "",
|
||||
"AutoDetect.Status.OnUmbra": "",
|
||||
"AutoDetect.Action.AlreadySynced": "",
|
||||
"AutoDetect.Action.RequestsDisabled": "",
|
||||
"AutoDetect.Action.SendRequest": "",
|
||||
"PairGroups.ResumeAll": "",
|
||||
"PairGroups.PauseAll": "",
|
||||
"PairGroups.Menu.Title": "",
|
||||
"PairGroups.Menu.AddPeople": "",
|
||||
"PairGroups.Menu.AddPeople.Tooltip": "",
|
||||
"PairGroups.Menu.Delete": "",
|
||||
"PairGroups.Menu.Delete.Tooltip": "",
|
||||
"PairGroups.Tag.Unpaired": "",
|
||||
"PairGroups.Tag.Offline": "",
|
||||
"PairGroups.Tag.Online": "",
|
||||
"PairGroups.Tag.Contacts": "",
|
||||
"PairGroups.Tag.Visible": "",
|
||||
"PairGroups.Header.WithCounts": "",
|
||||
"PairGroups.Header.Special": "",
|
||||
"PairGroups.Tooltip.Title": "",
|
||||
"PairGroups.Tooltip.Visible": "",
|
||||
"PairGroups.Tooltip.Online": "",
|
||||
"PairGroups.Tooltip.Total": "",
|
||||
"GroupPanel.Join.InputHint": "",
|
||||
"GroupPanel.Join.PasswordPopup": "",
|
||||
"GroupPanel.Create.PopupTitle": "",
|
||||
"GroupPanel.Create.Tooltip": "",
|
||||
"GroupPanel.Create.TooMany": "",
|
||||
"GroupPanel.Join.Tooltip": "",
|
||||
"GroupPanel.Join.TooMany": "",
|
||||
"GroupPanel.Join.Warning": "",
|
||||
"GroupPanel.Join.EnterPassword": "",
|
||||
"GroupPanel.Join.PasswordHint": "",
|
||||
"GroupPanel.Join.Error": "",
|
||||
"GroupPanel.Join.Button": "",
|
||||
"GroupPanel.Create.ChooseType": "",
|
||||
"GroupPanel.Create.Permanent": "",
|
||||
"GroupPanel.Create.Temporary": "",
|
||||
"GroupPanel.Create.AliasPrompt": "",
|
||||
"GroupPanel.Create.AliasHint": "",
|
||||
"GroupPanel.Create.TempMaxDuration": "",
|
||||
"GroupPanel.Create.TempExpires": "",
|
||||
"GroupPanel.Create.Instruction": "",
|
||||
"GroupPanel.Create.Button": "",
|
||||
"GroupPanel.Create.Error.NameInUse": "",
|
||||
"GroupPanel.Create.Result.Name": "",
|
||||
"GroupPanel.Create.Result.Id": "",
|
||||
"GroupPanel.Create.Result.Password": "",
|
||||
"GroupPanel.Create.Result.ChangeLater": "",
|
||||
"GroupPanel.Create.Result.TempExpires": "",
|
||||
"GroupPanel.Create.Error.Generic": "",
|
||||
"GroupPanel.CommentHint": "",
|
||||
"GroupPanel.CommentTooltip": "",
|
||||
"GroupPanel.Banlist.Title": "",
|
||||
"GroupPanel.Banlist.Refresh": "",
|
||||
"GroupPanel.Banlist.Column.Uid": "",
|
||||
"GroupPanel.Banlist.Column.Alias": "",
|
||||
"GroupPanel.Banlist.Column.By": "",
|
||||
"GroupPanel.Banlist.Column.Date": "",
|
||||
"GroupPanel.Banlist.Column.Reason": "",
|
||||
"GroupPanel.Banlist.Column.Actions": "",
|
||||
"GroupPanel.Banlist.Unban": "",
|
||||
"GroupPanel.Password.Title": "",
|
||||
"GroupPanel.Password.Description": "",
|
||||
"GroupPanel.Password.Warning": "",
|
||||
"GroupPanel.Password.Hint": "",
|
||||
"GroupPanel.Password.Button": "",
|
||||
"GroupPanel.Password.Error.TooShort": "",
|
||||
"GroupPanel.Invites.Title": "",
|
||||
"GroupPanel.Invites.Description": "",
|
||||
"GroupPanel.Invites.CreateButton": "",
|
||||
"GroupPanel.Invites.Result": "",
|
||||
"GroupPanel.Invites.Copy": "",
|
||||
"GroupPanel.List.Visible": "",
|
||||
"GroupPanel.List.Online": "",
|
||||
"GroupPanel.List.Offline": "",
|
||||
"GroupPanel.List.OfflineOmitted": "",
|
||||
"GroupPanel.Permissions.Header": "",
|
||||
"GroupPanel.Permissions.InvitesDisabled": "",
|
||||
"GroupPanel.Permissions.SoundDisabledOwner": "",
|
||||
"GroupPanel.Permissions.AnimationDisabledOwner": "",
|
||||
"GroupPanel.Permissions.VfxDisabledOwner": "",
|
||||
"GroupPanel.Permissions.OwnHeader": "",
|
||||
"GroupPanel.Permissions.SoundDisabledSelf": "",
|
||||
"GroupPanel.Permissions.AnimationDisabledSelf": "",
|
||||
"GroupPanel.Permissions.VfxDisabledSelf": "",
|
||||
"GroupPanel.Permissions.NotePriority": "",
|
||||
"GroupPanel.PauseToggle.Tooltip": "",
|
||||
"GroupPanel.PauseToggle.Resume": "",
|
||||
"GroupPanel.PauseToggle.Pause": "",
|
||||
"GroupPanel.Popup.Leave": "",
|
||||
"GroupPanel.Popup.LeaveTooltip": "",
|
||||
"GroupPanel.Popup.LeaveWarning": "",
|
||||
"GroupPanel.Popup.CopyId": "",
|
||||
"GroupPanel.Popup.CopyIdTooltip": "",
|
||||
"GroupPanel.Popup.CopyNotes": "",
|
||||
"GroupPanel.Popup.CopyNotesTooltip": "",
|
||||
"GroupPanel.Popup.EnableSound": "",
|
||||
"GroupPanel.Popup.DisableSound": "",
|
||||
"GroupPanel.Popup.SoundTooltip": "",
|
||||
"GroupPanel.Popup.EnableAnimations": "",
|
||||
"GroupPanel.Popup.DisableAnimations": "",
|
||||
"GroupPanel.Popup.AnimTooltip": "",
|
||||
"GroupPanel.Popup.EnableVfx": "",
|
||||
"GroupPanel.Popup.DisableVfx": "",
|
||||
"GroupPanel.Popup.VfxTooltip": "",
|
||||
"GroupPanel.Syncshell.OwnerTooltip": "",
|
||||
"GroupPanel.Syncshell.ModeratorTooltip": "",
|
||||
"GroupPanel.Syncshell.MemberCount": "",
|
||||
"GroupPanel.Syncshell.MemberCountTooltip": "",
|
||||
"GroupPanel.Syncshell.NameTooltip": "",
|
||||
"GroupPanel.Syncshell.TempTag": "",
|
||||
"GroupPanel.Syncshell.TempExpires": "",
|
||||
"GroupPanel.Syncshell.TempTooltip": "",
|
||||
"GroupPanel.Create.Duration.SingleDay": "",
|
||||
"GroupPanel.Create.Duration.Days": "",
|
||||
"GroupPanel.Create.Duration.Hours": "",
|
||||
"GroupPanel.Invites.AmountLabel": "",
|
||||
"GroupPanel.Popup.OpenAdmin": ""
|
||||
}
|
||||
@@ -12,6 +12,7 @@ public class CharaDataConfig : IMareConfiguration
|
||||
public bool NearbyOwnServerOnly { get; set; } = false;
|
||||
public bool NearbyIgnoreHousingLimitations { get; set; } = false;
|
||||
public bool NearbyDrawWisps { get; set; } = true;
|
||||
public int NearbyMaxWisps { get; set; } = 20;
|
||||
public int NearbyDistanceFilter { get; set; } = 100;
|
||||
public bool NearbyShowOwnData { get; set; } = false;
|
||||
public bool ShowHelpTexts { get; set; } = true;
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using MareSynchronos.MareConfiguration.Models;
|
||||
using System.Collections.Generic;
|
||||
using MareSynchronos.MareConfiguration.Models;
|
||||
using MareSynchronos.UI;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
@@ -12,7 +13,6 @@ public class MareConfig : IMareConfiguration
|
||||
public bool AcceptedAgreement { get; set; } = false;
|
||||
public string CacheFolder { get; set; } = string.Empty;
|
||||
public bool DisableOptionalPluginWarnings { get; set; } = false;
|
||||
public LocalizationLanguage Language { get; set; } = LocalizationLanguage.French;
|
||||
public bool EnableDtrEntry { get; set; } = true;
|
||||
public int DtrStyle { get; set; } = 0;
|
||||
public bool ShowUidInDtrTooltip { get; set; } = true;
|
||||
@@ -20,7 +20,7 @@ public class MareConfig : IMareConfiguration
|
||||
public bool UseColorsInDtr { get; set; } = true;
|
||||
public DtrEntry.Colors DtrColorsDefault { get; set; } = default;
|
||||
public DtrEntry.Colors DtrColorsNotConnected { get; set; } = new(Glow: 0x0428FFu);
|
||||
public DtrEntry.Colors DtrColorsPairsInRange { get; set; } = new(Glow: 0xFFBA47u);
|
||||
public DtrEntry.Colors DtrColorsPairsInRange { get; set; } = new(Glow: 0x8D37C0u);
|
||||
public bool UseNameColors { get; set; } = false;
|
||||
public DtrEntry.Colors NameColors { get; set; } = new(Foreground: 0x67EBF5u, Glow: 0x00303Cu);
|
||||
public DtrEntry.Colors BlockedNameColors { get; set; } = new(Foreground: 0x8AADC7, Glow: 0x000080u);
|
||||
@@ -38,6 +38,7 @@ public class MareConfig : IMareConfiguration
|
||||
public bool OpenGposeImportOnGposeStart { get; set; } = false;
|
||||
public bool OpenPopupOnAdd { get; set; } = true;
|
||||
public int ParallelDownloads { get; set; } = 10;
|
||||
public bool EnableDownloadQueue { get; set; } = false;
|
||||
public int DownloadSpeedLimitInBytes { get; set; } = 0;
|
||||
public DownloadSpeeds DownloadSpeedType { get; set; } = DownloadSpeeds.MBps;
|
||||
[Obsolete] public bool PreferNotesOverNamesForVisible { get; set; } = false;
|
||||
@@ -60,8 +61,14 @@ public class MareConfig : IMareConfiguration
|
||||
public bool ShowUploading { get; set; } = true;
|
||||
public bool ShowUploadingBigText { get; set; } = true;
|
||||
public bool ShowVisibleUsersSeparately { get; set; } = true;
|
||||
public bool EnableAutoDetectDiscovery { get; set; } = false;
|
||||
public bool AllowAutoDetectPairRequests { get; set; } = false;
|
||||
public string LastChangelogVersionSeen { get; set; } = string.Empty;
|
||||
public bool DefaultDisableSounds { get; set; } = false;
|
||||
public bool DefaultDisableAnimations { get; set; } = false;
|
||||
public bool DefaultDisableVfx { get; set; } = false;
|
||||
public Dictionary<string, SyncOverrideEntry> PairSyncOverrides { get; set; } = new(StringComparer.Ordinal);
|
||||
public Dictionary<string, SyncOverrideEntry> GroupSyncOverrides { get; set; } = new(StringComparer.Ordinal);
|
||||
public bool EnableAutoDetectDiscovery { get; set; } = true;
|
||||
public bool AllowAutoDetectPairRequests { get; set; } = true;
|
||||
public int AutoDetectMaxDistanceMeters { get; set; } = 40;
|
||||
public int AutoDetectMuteMinutes { get; set; } = 5;
|
||||
public int TimeSpanBetweenScansInSeconds { get; set; } = 30;
|
||||
@@ -78,6 +85,11 @@ public class MareConfig : IMareConfiguration
|
||||
public int ChatLogKind { get; set; } = 1; // XivChatType.Debug
|
||||
public bool ExtraChatAPI { get; set; } = false;
|
||||
public bool ExtraChatTags { get; set; } = false;
|
||||
public bool TypingIndicatorShowOnNameplates { get; set; } = true;
|
||||
public bool TypingIndicatorShowOnPartyList { get; set; } = true;
|
||||
public bool TypingIndicatorEnabled { get; set; } = true;
|
||||
public bool TypingIndicatorShowSelf { get; set; } = true;
|
||||
public TypingIndicatorBubbleSize TypingIndicatorBubbleSize { get; set; } = TypingIndicatorBubbleSize.Large;
|
||||
|
||||
public bool MareAPI { get; set; } = true;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using MareSynchronos.MareConfiguration.Models;
|
||||
|
||||
namespace MareSynchronos.MareConfiguration.Configurations;
|
||||
|
||||
[Serializable]
|
||||
public class NotificationsConfig : IMareConfiguration
|
||||
{
|
||||
public List<StoredNotification> Notifications { get; set; } = new();
|
||||
public int Version { get; set; } = 1;
|
||||
}
|
||||
@@ -8,6 +8,7 @@ public class PlayerPerformanceConfig : IMareConfiguration
|
||||
public bool AutoPausePlayersExceedingThresholds { get; set; } = true;
|
||||
public bool NotifyAutoPauseDirectPairs { get; set; } = true;
|
||||
public bool NotifyAutoPauseGroupPairs { get; set; } = true;
|
||||
public bool ShowSelfAnalysisWarnings { get; set; } = true;
|
||||
public int VRAMSizeAutoPauseThresholdMiB { get; set; } = 500;
|
||||
public int TrisAutoPauseThresholdThousands { get; set; } = 400;
|
||||
public bool IgnoreDirectPairs { get; set; } = true;
|
||||
|
||||
@@ -1,7 +0,0 @@
|
||||
namespace MareSynchronos.MareConfiguration.Models;
|
||||
|
||||
public enum LocalizationLanguage
|
||||
{
|
||||
French = 0,
|
||||
English = 1,
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace MareSynchronos.MareConfiguration.Models;
|
||||
|
||||
[Serializable]
|
||||
public class StoredNotification
|
||||
{
|
||||
public string Category { get; set; } = string.Empty; // name of enum NotificationCategory
|
||||
public string Id { get; set; } = string.Empty;
|
||||
public string Title { get; set; } = string.Empty;
|
||||
public string? Description { get; set; }
|
||||
public DateTime CreatedAtUtc { get; set; } = DateTime.UtcNow;
|
||||
}
|
||||
13
MareSynchronos/MareConfiguration/Models/SyncOverrideEntry.cs
Normal file
13
MareSynchronos/MareConfiguration/Models/SyncOverrideEntry.cs
Normal file
@@ -0,0 +1,13 @@
|
||||
using System;
|
||||
|
||||
namespace MareSynchronos.MareConfiguration.Models;
|
||||
|
||||
[Serializable]
|
||||
public class SyncOverrideEntry
|
||||
{
|
||||
public bool? DisableSounds { get; set; }
|
||||
public bool? DisableAnimations { get; set; }
|
||||
public bool? DisableVfx { get; set; }
|
||||
|
||||
public bool IsEmpty => DisableSounds is null && DisableAnimations is null && DisableVfx is null;
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
namespace MareSynchronos.MareConfiguration.Models;
|
||||
|
||||
public enum TypingIndicatorBubbleSize
|
||||
{
|
||||
Small,
|
||||
Medium,
|
||||
Large
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
using MareSynchronos.MareConfiguration.Configurations;
|
||||
|
||||
namespace MareSynchronos.MareConfiguration;
|
||||
|
||||
public class NotificationsConfigService : ConfigurationServiceBase<NotificationsConfig>
|
||||
{
|
||||
public const string ConfigName = "notifications.json";
|
||||
|
||||
public NotificationsConfigService(string configDir) : base(configDir)
|
||||
{
|
||||
}
|
||||
|
||||
public override string ConfigurationName => ConfigName;
|
||||
}
|
||||
@@ -5,6 +5,7 @@ using MareSynchronos.PlayerData.Services;
|
||||
using MareSynchronos.Services;
|
||||
using MareSynchronos.Services.Mediator;
|
||||
using MareSynchronos.Services.ServerConfiguration;
|
||||
using MareSynchronos.Interop;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
using Microsoft.Extensions.Logging;
|
||||
@@ -150,8 +151,12 @@ public class MarePlugin : MediatorSubscriberBase, IHostedService
|
||||
_runtimeServiceScope.ServiceProvider.GetRequiredService<TransientResourceManager>();
|
||||
_runtimeServiceScope.ServiceProvider.GetRequiredService<OnlinePlayerManager>();
|
||||
_runtimeServiceScope.ServiceProvider.GetRequiredService<NotificationService>();
|
||||
_runtimeServiceScope.ServiceProvider.GetRequiredService<SyncDefaultsService>();
|
||||
_runtimeServiceScope.ServiceProvider.GetRequiredService<ChatService>();
|
||||
_runtimeServiceScope.ServiceProvider.GetRequiredService<ChatTypingDetectionService>();
|
||||
_runtimeServiceScope.ServiceProvider.GetRequiredService<GuiHookService>();
|
||||
var characterAnalyzer = _runtimeServiceScope.ServiceProvider.GetRequiredService<CharacterAnalyzer>();
|
||||
_ = characterAnalyzer.ComputeAnalysis(print: false);
|
||||
|
||||
#if !DEBUG
|
||||
if (_mareConfigService.Current.LogLevel != LogLevel.Information)
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<PropertyGroup>
|
||||
<AssemblyName>UmbraSync</AssemblyName>
|
||||
<RootNamespace>UmbraSync</RootNamespace>
|
||||
<Version>0.1.8.0</Version>
|
||||
<Version>0.1.9.9</Version>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
@@ -50,6 +50,8 @@
|
||||
<PropertyGroup>
|
||||
<SourceRevisionId>build$([System.DateTime]::UtcNow.ToString("yyyy-MM-ddTHH:mm:ss:fffZ"))</SourceRevisionId>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<DisablePackageVulnerabilityAnalysis>true</DisablePackageVulnerabilityAnalysis>
|
||||
<NoWarn>$(NoWarn);NU1900</NoWarn>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
@@ -60,14 +62,4 @@
|
||||
<None Include="..\.editorconfig" Link=".editorconfig" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="Localization\\*.json" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Content Include="Localization\\*.json">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using MareSynchronos.FileCache;
|
||||
using MareSynchronos.MareConfiguration;
|
||||
using MareSynchronos.Services.Mediator;
|
||||
using MareSynchronos.WebAPI.Files;
|
||||
using Microsoft.Extensions.Logging;
|
||||
@@ -10,21 +11,23 @@ public class FileDownloadManagerFactory
|
||||
private readonly FileCacheManager _fileCacheManager;
|
||||
private readonly FileCompactor _fileCompactor;
|
||||
private readonly FileTransferOrchestrator _fileTransferOrchestrator;
|
||||
private readonly MareConfigService _mareConfigService;
|
||||
private readonly ILoggerFactory _loggerFactory;
|
||||
private readonly MareMediator _mareMediator;
|
||||
|
||||
public FileDownloadManagerFactory(ILoggerFactory loggerFactory, MareMediator mareMediator, FileTransferOrchestrator fileTransferOrchestrator,
|
||||
FileCacheManager fileCacheManager, FileCompactor fileCompactor)
|
||||
FileCacheManager fileCacheManager, FileCompactor fileCompactor, MareConfigService mareConfigService)
|
||||
{
|
||||
_loggerFactory = loggerFactory;
|
||||
_mareMediator = mareMediator;
|
||||
_fileTransferOrchestrator = fileTransferOrchestrator;
|
||||
_fileCacheManager = fileCacheManager;
|
||||
_fileCompactor = fileCompactor;
|
||||
_mareConfigService = mareConfigService;
|
||||
}
|
||||
|
||||
public FileDownloadManager Create()
|
||||
{
|
||||
return new FileDownloadManager(_loggerFactory.CreateLogger<FileDownloadManager>(), _mareMediator, _fileTransferOrchestrator, _fileCacheManager, _fileCompactor);
|
||||
return new FileDownloadManager(_loggerFactory.CreateLogger<FileDownloadManager>(), _mareMediator, _fileTransferOrchestrator, _fileCacheManager, _fileCompactor, _mareConfigService);
|
||||
}
|
||||
}
|
||||
@@ -5,7 +5,6 @@ using MareSynchronos.PlayerData.Handlers;
|
||||
using MareSynchronos.PlayerData.Pairs;
|
||||
using MareSynchronos.Services;
|
||||
using MareSynchronos.Services.Mediator;
|
||||
using MareSynchronos.Services.ServerConfiguration;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
@@ -23,7 +22,6 @@ public class PairHandlerFactory
|
||||
private readonly ILoggerFactory _loggerFactory;
|
||||
private readonly MareMediator _mareMediator;
|
||||
private readonly PlayerPerformanceService _playerPerformanceService;
|
||||
private readonly ServerConfigurationManager _serverConfigManager;
|
||||
private readonly PluginWarningNotificationService _pluginWarningNotificationManager;
|
||||
private readonly PairAnalyzerFactory _pairAnalyzerFactory;
|
||||
private readonly VisibilityService _visibilityService;
|
||||
@@ -32,7 +30,7 @@ public class PairHandlerFactory
|
||||
FileDownloadManagerFactory fileDownloadManagerFactory, DalamudUtilService dalamudUtilService,
|
||||
PluginWarningNotificationService pluginWarningNotificationManager, IHostApplicationLifetime hostApplicationLifetime,
|
||||
FileCacheManager fileCacheManager, MareMediator mareMediator, PlayerPerformanceService playerPerformanceService,
|
||||
ServerConfigurationManager serverConfigManager, PairAnalyzerFactory pairAnalyzerFactory,
|
||||
PairAnalyzerFactory pairAnalyzerFactory,
|
||||
MareConfigService configService, VisibilityService visibilityService)
|
||||
{
|
||||
_loggerFactory = loggerFactory;
|
||||
@@ -45,7 +43,6 @@ public class PairHandlerFactory
|
||||
_fileCacheManager = fileCacheManager;
|
||||
_mareMediator = mareMediator;
|
||||
_playerPerformanceService = playerPerformanceService;
|
||||
_serverConfigManager = serverConfigManager;
|
||||
_pairAnalyzerFactory = pairAnalyzerFactory;
|
||||
_configService = configService;
|
||||
_visibilityService = visibilityService;
|
||||
@@ -55,6 +52,6 @@ public class PairHandlerFactory
|
||||
{
|
||||
return new PairHandler(_loggerFactory.CreateLogger<PairHandler>(), pair, _pairAnalyzerFactory.Create(pair), _gameObjectHandlerFactory,
|
||||
_ipcManager, _fileDownloadManagerFactory.Create(), _pluginWarningNotificationManager, _dalamudUtilService, _hostApplicationLifetime,
|
||||
_fileCacheManager, _mareMediator, _playerPerformanceService, _serverConfigManager, _configService, _visibilityService);
|
||||
_fileCacheManager, _mareMediator, _playerPerformanceService, _configService, _visibilityService);
|
||||
}
|
||||
}
|
||||
@@ -7,7 +7,6 @@ using MareSynchronos.PlayerData.Pairs;
|
||||
using MareSynchronos.Services;
|
||||
using MareSynchronos.Services.Events;
|
||||
using MareSynchronos.Services.Mediator;
|
||||
using MareSynchronos.Services.ServerConfiguration;
|
||||
using MareSynchronos.Utils;
|
||||
using MareSynchronos.WebAPI.Files;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
@@ -29,7 +28,6 @@ public sealed class PairHandler : DisposableMediatorSubscriberBase
|
||||
private readonly GameObjectHandlerFactory _gameObjectHandlerFactory;
|
||||
private readonly IpcManager _ipcManager;
|
||||
private readonly PlayerPerformanceService _playerPerformanceService;
|
||||
private readonly ServerConfigurationManager _serverConfigManager;
|
||||
private readonly PluginWarningNotificationService _pluginWarningNotificationManager;
|
||||
private readonly VisibilityService _visibilityService;
|
||||
private CancellationTokenSource? _applicationCancellationTokenSource = new();
|
||||
@@ -53,7 +51,6 @@ public sealed class PairHandler : DisposableMediatorSubscriberBase
|
||||
DalamudUtilService dalamudUtil, IHostApplicationLifetime lifetime,
|
||||
FileCacheManager fileDbManager, MareMediator mediator,
|
||||
PlayerPerformanceService playerPerformanceService,
|
||||
ServerConfigurationManager serverConfigManager,
|
||||
MareConfigService configService, VisibilityService visibilityService) : base(logger, mediator)
|
||||
{
|
||||
Pair = pair;
|
||||
@@ -65,7 +62,6 @@ public sealed class PairHandler : DisposableMediatorSubscriberBase
|
||||
_dalamudUtil = dalamudUtil;
|
||||
_fileDbManager = fileDbManager;
|
||||
_playerPerformanceService = playerPerformanceService;
|
||||
_serverConfigManager = serverConfigManager;
|
||||
_configService = configService;
|
||||
_visibilityService = visibilityService;
|
||||
|
||||
|
||||
@@ -270,6 +270,20 @@ public class Pair : DisposableMediatorSubscriberBase
|
||||
}
|
||||
}
|
||||
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
base.Dispose(disposing);
|
||||
try
|
||||
{
|
||||
_applicationCts.Cancel();
|
||||
}
|
||||
catch (ObjectDisposedException)
|
||||
{
|
||||
}
|
||||
|
||||
_applicationCts.Dispose();
|
||||
}
|
||||
|
||||
public void SetNote(string note)
|
||||
{
|
||||
_serverConfigurationManager.SetNoteForUid(UserData.UID, note);
|
||||
|
||||
@@ -51,7 +51,7 @@ public sealed class PairManager : DisposableMediatorSubscriberBase
|
||||
RecreateLazy();
|
||||
}
|
||||
|
||||
public void AddGroupPair(GroupPairFullInfoDto dto)
|
||||
public void AddGroupPair(GroupPairFullInfoDto dto, bool isInitialLoad = false)
|
||||
{
|
||||
if (!_allClientPairs.ContainsKey(dto.User))
|
||||
_allClientPairs[dto.User] = _pairFactory.Create(dto.User);
|
||||
@@ -59,6 +59,11 @@ public sealed class PairManager : DisposableMediatorSubscriberBase
|
||||
var group = _allGroups[dto.Group];
|
||||
_allClientPairs[dto.User].GroupPair[group] = dto;
|
||||
RecreateLazy();
|
||||
|
||||
if (!isInitialLoad)
|
||||
{
|
||||
Mediator.Publish(new ApplyDefaultGroupPermissionsMessage(dto));
|
||||
}
|
||||
}
|
||||
|
||||
public Pair? GetPairByUID(string uid)
|
||||
@@ -88,6 +93,11 @@ public sealed class PairManager : DisposableMediatorSubscriberBase
|
||||
LastAddedUser = _allClientPairs[dto.User];
|
||||
_allClientPairs[dto.User].ApplyLastReceivedData();
|
||||
RecreateLazy();
|
||||
|
||||
if (addToLastAddedUser)
|
||||
{
|
||||
Mediator.Publish(new ApplyDefaultPairPermissionsMessage(dto));
|
||||
}
|
||||
}
|
||||
|
||||
public void ClearPairs()
|
||||
|
||||
@@ -6,7 +6,6 @@ using Dalamud.Plugin.Services;
|
||||
using MareSynchronos.FileCache;
|
||||
using MareSynchronos.Interop;
|
||||
using MareSynchronos.Interop.Ipc;
|
||||
using MareSynchronos.Localization;
|
||||
using MareSynchronos.MareConfiguration;
|
||||
using MareSynchronos.MareConfiguration.Configurations;
|
||||
using MareSynchronos.PlayerData.Factories;
|
||||
@@ -16,6 +15,7 @@ using MareSynchronos.Services;
|
||||
using MareSynchronos.Services.Events;
|
||||
using MareSynchronos.Services.Mediator;
|
||||
using MareSynchronos.Services.ServerConfiguration;
|
||||
using MareSynchronos.Services.Notifications;
|
||||
using MareSynchronos.UI;
|
||||
using MareSynchronos.UI.Components;
|
||||
using MareSynchronos.UI.Components.Popup;
|
||||
@@ -92,7 +92,6 @@ public sealed class Plugin : IDalamudPlugin
|
||||
collection.AddSingleton<MareMediator>();
|
||||
collection.AddSingleton<FileCacheManager>();
|
||||
collection.AddSingleton<ServerConfigurationManager>();
|
||||
collection.AddSingleton<LocalizationService>();
|
||||
collection.AddSingleton<ApiController>();
|
||||
collection.AddSingleton<PerformanceCollectorService>();
|
||||
collection.AddSingleton<HubFactory>();
|
||||
@@ -103,6 +102,8 @@ public sealed class Plugin : IDalamudPlugin
|
||||
collection.AddSingleton<MareSynchronos.Services.AutoDetect.AutoDetectRequestService>();
|
||||
collection.AddSingleton<MareSynchronos.Services.AutoDetect.NearbyDiscoveryService>();
|
||||
collection.AddSingleton<MareSynchronos.Services.AutoDetect.NearbyPendingService>();
|
||||
collection.AddSingleton<MareSynchronos.Services.AutoDetect.AutoDetectSuppressionService>();
|
||||
collection.AddSingleton<MareSynchronos.Services.AutoDetect.SyncshellDiscoveryService>();
|
||||
collection.AddSingleton<MarePlugin>();
|
||||
collection.AddSingleton<MareProfileManager>();
|
||||
collection.AddSingleton<GameObjectHandlerFactory>();
|
||||
@@ -117,6 +118,7 @@ public sealed class Plugin : IDalamudPlugin
|
||||
collection.AddSingleton<PluginWarningNotificationService>();
|
||||
collection.AddSingleton<FileCompactor>();
|
||||
collection.AddSingleton<TagHandler>();
|
||||
collection.AddSingleton<SyncDefaultsService>();
|
||||
collection.AddSingleton<UidDisplayHandler>();
|
||||
collection.AddSingleton<PluginWatcherService>();
|
||||
collection.AddSingleton<PlayerPerformanceService>();
|
||||
@@ -126,6 +128,7 @@ public sealed class Plugin : IDalamudPlugin
|
||||
collection.AddSingleton<CharaDataCharacterHandler>();
|
||||
collection.AddSingleton<CharaDataNearbyManager>();
|
||||
collection.AddSingleton<CharaDataGposeTogetherManager>();
|
||||
collection.AddSingleton<McdfShareManager>();
|
||||
|
||||
collection.AddSingleton<VfxSpawnManager>();
|
||||
collection.AddSingleton<BlockedCharacterHandler>();
|
||||
@@ -148,6 +151,10 @@ public sealed class Plugin : IDalamudPlugin
|
||||
collection.AddSingleton<IpcManager>();
|
||||
collection.AddSingleton<NotificationService>();
|
||||
collection.AddSingleton<TemporarySyncshellNotificationService>();
|
||||
collection.AddSingleton<PartyListTypingService>();
|
||||
collection.AddSingleton<TypingIndicatorStateService>();
|
||||
collection.AddSingleton<ChatTwoCompatibilityService>();
|
||||
collection.AddSingleton<NotificationTracker>();
|
||||
|
||||
collection.AddSingleton((s) => new MareConfigService(pluginInterface.ConfigDirectory.FullName));
|
||||
collection.AddSingleton((s) => new ServerConfigService(pluginInterface.ConfigDirectory.FullName));
|
||||
@@ -160,6 +167,7 @@ public sealed class Plugin : IDalamudPlugin
|
||||
collection.AddSingleton((s) => new ServerBlockConfigService(pluginInterface.ConfigDirectory.FullName));
|
||||
collection.AddSingleton((s) => new CharaDataConfigService(pluginInterface.ConfigDirectory.FullName));
|
||||
collection.AddSingleton((s) => new RemoteConfigCacheService(pluginInterface.ConfigDirectory.FullName));
|
||||
collection.AddSingleton((s) => new NotificationsConfigService(pluginInterface.ConfigDirectory.FullName));
|
||||
collection.AddSingleton<IConfigService<IMareConfiguration>>(s => s.GetRequiredService<MareConfigService>());
|
||||
collection.AddSingleton<IConfigService<IMareConfiguration>>(s => s.GetRequiredService<ServerConfigService>());
|
||||
collection.AddSingleton<IConfigService<IMareConfiguration>>(s => s.GetRequiredService<NotesConfigService>());
|
||||
@@ -171,6 +179,7 @@ public sealed class Plugin : IDalamudPlugin
|
||||
collection.AddSingleton<IConfigService<IMareConfiguration>>(s => s.GetRequiredService<ServerBlockConfigService>());
|
||||
collection.AddSingleton<IConfigService<IMareConfiguration>>(s => s.GetRequiredService<CharaDataConfigService>());
|
||||
collection.AddSingleton<IConfigService<IMareConfiguration>>(s => s.GetRequiredService<RemoteConfigCacheService>());
|
||||
collection.AddSingleton<IConfigService<IMareConfiguration>>(s => s.GetRequiredService<NotificationsConfigService>());
|
||||
collection.AddSingleton<ConfigurationMigrator>();
|
||||
collection.AddSingleton<ConfigurationSaveService>();
|
||||
|
||||
@@ -179,17 +188,25 @@ public sealed class Plugin : IDalamudPlugin
|
||||
// add scoped services
|
||||
collection.AddScoped<CacheMonitor>();
|
||||
collection.AddScoped<UiFactory>();
|
||||
collection.AddScoped<WindowMediatorSubscriberBase, SettingsUi>();
|
||||
collection.AddScoped<WindowMediatorSubscriberBase, CompactUi>();
|
||||
collection.AddScoped<SettingsUi>();
|
||||
collection.AddScoped<CompactUi>();
|
||||
collection.AddScoped<EditProfileUi>();
|
||||
collection.AddScoped<DataAnalysisUi>();
|
||||
collection.AddScoped<CharaDataHubUi>();
|
||||
collection.AddScoped<AutoDetectUi>();
|
||||
collection.AddScoped<WindowMediatorSubscriberBase>(sp => sp.GetRequiredService<SettingsUi>());
|
||||
collection.AddScoped<WindowMediatorSubscriberBase>(sp => sp.GetRequiredService<CompactUi>());
|
||||
collection.AddScoped<WindowMediatorSubscriberBase, IntroUi>();
|
||||
collection.AddScoped<WindowMediatorSubscriberBase, DownloadUi>();
|
||||
collection.AddScoped<WindowMediatorSubscriberBase, AutoDetectUi>();
|
||||
collection.AddScoped<WindowMediatorSubscriberBase>(sp => sp.GetRequiredService<AutoDetectUi>());
|
||||
collection.AddScoped<WindowMediatorSubscriberBase, ChangelogUi>();
|
||||
collection.AddScoped<WindowMediatorSubscriberBase, PopoutProfileUi>();
|
||||
collection.AddScoped<WindowMediatorSubscriberBase, DataAnalysisUi>();
|
||||
collection.AddScoped<WindowMediatorSubscriberBase>(sp => sp.GetRequiredService<DataAnalysisUi>());
|
||||
collection.AddScoped<WindowMediatorSubscriberBase, EventViewerUI>();
|
||||
collection.AddScoped<WindowMediatorSubscriberBase, CharaDataHubUi>();
|
||||
collection.AddScoped<WindowMediatorSubscriberBase, EditProfileUi>();
|
||||
collection.AddScoped<WindowMediatorSubscriberBase>(sp => sp.GetRequiredService<EditProfileUi>());
|
||||
collection.AddScoped<WindowMediatorSubscriberBase, PopupHandler>();
|
||||
collection.AddScoped<WindowMediatorSubscriberBase, TypingIndicatorOverlay>();
|
||||
collection.AddScoped<IPopupHandler, ReportPopupHandler>();
|
||||
collection.AddScoped<IPopupHandler, BanUserPopupHandler>();
|
||||
collection.AddScoped<CacheCreationService>();
|
||||
@@ -201,6 +218,7 @@ public sealed class Plugin : IDalamudPlugin
|
||||
collection.AddScoped<UiSharedService>();
|
||||
collection.AddScoped<ChatService>();
|
||||
collection.AddScoped<GuiHookService>();
|
||||
collection.AddScoped<ChatTypingDetectionService>();
|
||||
|
||||
collection.AddHostedService(p => p.GetRequiredService<PluginWatcherService>());
|
||||
collection.AddHostedService(p => p.GetRequiredService<ConfigurationSaveService>());
|
||||
@@ -216,9 +234,22 @@ public sealed class Plugin : IDalamudPlugin
|
||||
collection.AddHostedService(p => p.GetRequiredService<MarePlugin>());
|
||||
collection.AddHostedService(p => p.GetRequiredService<IpcProvider>());
|
||||
collection.AddHostedService(p => p.GetRequiredService<MareSynchronos.Services.AutoDetect.NearbyDiscoveryService>());
|
||||
collection.AddHostedService(p => p.GetRequiredService<MareSynchronos.Services.AutoDetect.SyncshellDiscoveryService>());
|
||||
collection.AddHostedService(p => p.GetRequiredService<ChatTwoCompatibilityService>());
|
||||
collection.AddHostedService(p => p.GetRequiredService<MareSynchronos.Services.AutoDetect.AutoDetectSuppressionService>());
|
||||
})
|
||||
.Build();
|
||||
|
||||
try
|
||||
{
|
||||
var partyListTypingService = _host.Services.GetRequiredService<PartyListTypingService>();
|
||||
pluginInterface.UiBuilder.Draw += partyListTypingService.Draw;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
pluginLog.Warning(e, "Failed to initialize PartyListTypingService draw hook");
|
||||
}
|
||||
|
||||
_ = Task.Run(async () => {
|
||||
try
|
||||
{
|
||||
|
||||
@@ -1,9 +1,17 @@
|
||||
using System;
|
||||
using System.Collections.Concurrent;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using MareSynchronos.WebAPI.AutoDetect;
|
||||
using MareSynchronos.MareConfiguration;
|
||||
using MareSynchronos.Services;
|
||||
using MareSynchronos.Services.Mediator;
|
||||
using NotificationType = MareSynchronos.MareConfiguration.Models.NotificationType;
|
||||
using MareSynchronos.WebAPI;
|
||||
using MareSynchronos.API.Dto.User;
|
||||
using MareSynchronos.API.Data;
|
||||
|
||||
namespace MareSynchronos.Services.AutoDetect;
|
||||
|
||||
@@ -15,8 +23,15 @@ public class AutoDetectRequestService
|
||||
private readonly MareConfigService _configService;
|
||||
private readonly DalamudUtilService _dalamud;
|
||||
private readonly MareMediator _mediator;
|
||||
private readonly object _syncRoot = new();
|
||||
private readonly Dictionary<string, DateTime> _activeCooldowns = new(StringComparer.Ordinal);
|
||||
private readonly Dictionary<string, RefusalTracker> _refusalTrackers = new(StringComparer.Ordinal);
|
||||
private readonly ConcurrentDictionary<string, PendingRequestInfo> _pendingRequests = new(StringComparer.Ordinal);
|
||||
private static readonly TimeSpan RequestCooldown = TimeSpan.FromMinutes(5);
|
||||
private static readonly TimeSpan RefusalLockDuration = TimeSpan.FromMinutes(15);
|
||||
private readonly ApiController _apiController;
|
||||
|
||||
public AutoDetectRequestService(ILogger<AutoDetectRequestService> logger, DiscoveryConfigProvider configProvider, DiscoveryApiClient client, MareConfigService configService, MareMediator mediator, DalamudUtilService dalamudUtilService)
|
||||
public AutoDetectRequestService(ILogger<AutoDetectRequestService> logger, DiscoveryConfigProvider configProvider, DiscoveryApiClient client, MareConfigService configService, MareMediator mediator, DalamudUtilService dalamudUtilService, ApiController apiController)
|
||||
{
|
||||
_logger = logger;
|
||||
_configProvider = configProvider;
|
||||
@@ -24,9 +39,10 @@ public class AutoDetectRequestService
|
||||
_configService = configService;
|
||||
_mediator = mediator;
|
||||
_dalamud = dalamudUtilService;
|
||||
_apiController = apiController;
|
||||
}
|
||||
|
||||
public async Task<bool> SendRequestAsync(string token, CancellationToken ct = default)
|
||||
public async Task<bool> SendRequestAsync(string? token, string? uid = null, string? targetDisplayName = null, CancellationToken ct = default)
|
||||
{
|
||||
if (!_configService.Current.AllowAutoDetectPairRequests)
|
||||
{
|
||||
@@ -34,6 +50,54 @@ public class AutoDetectRequestService
|
||||
_mediator.Publish(new NotificationMessage("Nearby request blocked", "Enable 'Allow pair requests' in Settings to send requests.", NotificationType.Info));
|
||||
return false;
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(token) && string.IsNullOrEmpty(uid))
|
||||
{
|
||||
_logger.LogDebug("Nearby request blocked: no token or UID provided");
|
||||
return false;
|
||||
}
|
||||
|
||||
var targetKey = BuildTargetKey(uid, token, targetDisplayName);
|
||||
if (!string.IsNullOrEmpty(targetKey))
|
||||
{
|
||||
var now = DateTime.UtcNow;
|
||||
lock (_syncRoot)
|
||||
{
|
||||
if (_refusalTrackers.TryGetValue(targetKey, out var tracker))
|
||||
{
|
||||
if (tracker.LockUntil.HasValue && tracker.LockUntil.Value > now)
|
||||
{
|
||||
PublishLockNotification(tracker.LockUntil.Value - now);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (tracker.LockUntil.HasValue && tracker.LockUntil.Value <= now)
|
||||
{
|
||||
tracker.LockUntil = null;
|
||||
tracker.Count = 0;
|
||||
if (tracker.Count == 0 && tracker.LockUntil == null)
|
||||
{
|
||||
_refusalTrackers.Remove(targetKey);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (_activeCooldowns.TryGetValue(targetKey, out var lastSent))
|
||||
{
|
||||
var elapsed = now - lastSent;
|
||||
if (elapsed < RequestCooldown)
|
||||
{
|
||||
PublishCooldownNotification(RequestCooldown - elapsed);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (elapsed >= RequestCooldown)
|
||||
{
|
||||
_activeCooldowns.Remove(targetKey);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
var endpoint = _configProvider.RequestEndpoint;
|
||||
if (string.IsNullOrEmpty(endpoint))
|
||||
{
|
||||
@@ -49,14 +113,64 @@ public class AutoDetectRequestService
|
||||
}
|
||||
catch { }
|
||||
|
||||
var requestToken = string.IsNullOrEmpty(token) ? null : token;
|
||||
var requestUid = requestToken == null ? uid : null;
|
||||
|
||||
_logger.LogInformation("Nearby: sending pair request via {endpoint}", endpoint);
|
||||
var ok = await _client.SendRequestAsync(endpoint!, token, displayName, ct).ConfigureAwait(false);
|
||||
var ok = await _client.SendRequestAsync(endpoint!, requestToken, requestUid, displayName, ct).ConfigureAwait(false);
|
||||
if (ok)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(targetKey))
|
||||
{
|
||||
lock (_syncRoot)
|
||||
{
|
||||
_activeCooldowns[targetKey] = DateTime.UtcNow;
|
||||
if (_refusalTrackers.TryGetValue(targetKey, out var tracker))
|
||||
{
|
||||
tracker.Count = 0;
|
||||
tracker.LockUntil = null;
|
||||
if (tracker.Count == 0 && tracker.LockUntil == null)
|
||||
{
|
||||
_refusalTrackers.Remove(targetKey);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
_mediator.Publish(new NotificationMessage("Nearby request sent", "The other user will receive a request notification.", NotificationType.Info));
|
||||
var pendingKey = EnsureTargetKey(targetKey);
|
||||
var label = !string.IsNullOrWhiteSpace(targetDisplayName)
|
||||
? targetDisplayName!
|
||||
: (!string.IsNullOrEmpty(uid) ? uid : (!string.IsNullOrEmpty(token) ? token : pendingKey));
|
||||
_pendingRequests[pendingKey] = new PendingRequestInfo(pendingKey, uid, token, label, DateTime.UtcNow);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!string.IsNullOrEmpty(targetKey))
|
||||
{
|
||||
var now = DateTime.UtcNow;
|
||||
lock (_syncRoot)
|
||||
{
|
||||
_activeCooldowns.Remove(targetKey);
|
||||
if (!_refusalTrackers.TryGetValue(targetKey, out var tracker))
|
||||
{
|
||||
tracker = new RefusalTracker();
|
||||
_refusalTrackers[targetKey] = tracker;
|
||||
}
|
||||
|
||||
if (tracker.LockUntil.HasValue && tracker.LockUntil.Value <= now)
|
||||
{
|
||||
tracker.LockUntil = null;
|
||||
tracker.Count = 0;
|
||||
}
|
||||
|
||||
tracker.Count++;
|
||||
if (tracker.Count >= 3)
|
||||
{
|
||||
tracker.LockUntil = now.Add(RefusalLockDuration);
|
||||
}
|
||||
}
|
||||
_pendingRequests.TryRemove(targetKey, out _);
|
||||
}
|
||||
_mediator.Publish(new NotificationMessage("Nearby request failed", "The server rejected the request. Try again soon.", NotificationType.Warning));
|
||||
}
|
||||
return ok;
|
||||
@@ -80,4 +194,193 @@ public class AutoDetectRequestService
|
||||
_logger.LogInformation("Nearby: sending accept notify via {endpoint}", endpoint);
|
||||
return await _client.SendAcceptAsync(endpoint!, targetUid, displayName, ct).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
public async Task<bool> SendDirectUidRequestAsync(string uid, string? targetDisplayName = null, CancellationToken ct = default)
|
||||
{
|
||||
if (!_configService.Current.AllowAutoDetectPairRequests)
|
||||
{
|
||||
_logger.LogDebug("Nearby request blocked: AllowAutoDetectPairRequests is disabled");
|
||||
_mediator.Publish(new NotificationMessage("Nearby request blocked", "Enable 'Allow pair requests' in Settings to send requests.", NotificationType.Info));
|
||||
return false;
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(uid))
|
||||
{
|
||||
_logger.LogDebug("Direct pair request aborted: UID is empty");
|
||||
return false;
|
||||
}
|
||||
|
||||
var targetKey = BuildTargetKey(uid, null, targetDisplayName);
|
||||
if (!string.IsNullOrEmpty(targetKey))
|
||||
{
|
||||
var now = DateTime.UtcNow;
|
||||
lock (_syncRoot)
|
||||
{
|
||||
if (_refusalTrackers.TryGetValue(targetKey, out var tracker))
|
||||
{
|
||||
if (tracker.LockUntil.HasValue && tracker.LockUntil.Value > now)
|
||||
{
|
||||
PublishLockNotification(tracker.LockUntil.Value - now);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (tracker.LockUntil.HasValue && tracker.LockUntil.Value <= now)
|
||||
{
|
||||
tracker.LockUntil = null;
|
||||
tracker.Count = 0;
|
||||
if (tracker.Count == 0 && tracker.LockUntil == null)
|
||||
{
|
||||
_refusalTrackers.Remove(targetKey);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (_activeCooldowns.TryGetValue(targetKey, out var lastSent))
|
||||
{
|
||||
var elapsed = now - lastSent;
|
||||
if (elapsed < RequestCooldown)
|
||||
{
|
||||
PublishCooldownNotification(RequestCooldown - elapsed);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (elapsed >= RequestCooldown)
|
||||
{
|
||||
_activeCooldowns.Remove(targetKey);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
await _apiController.UserAddPair(new UserDto(new UserData(uid))).ConfigureAwait(false);
|
||||
|
||||
if (!string.IsNullOrEmpty(targetKey))
|
||||
{
|
||||
lock (_syncRoot)
|
||||
{
|
||||
_activeCooldowns[targetKey] = DateTime.UtcNow;
|
||||
if (_refusalTrackers.TryGetValue(targetKey, out var tracker))
|
||||
{
|
||||
tracker.Count = 0;
|
||||
tracker.LockUntil = null;
|
||||
if (tracker.Count == 0 && tracker.LockUntil == null)
|
||||
{
|
||||
_refusalTrackers.Remove(targetKey);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
_mediator.Publish(new NotificationMessage("Nearby request sent", "The other user will receive a request notification.", NotificationType.Info));
|
||||
var pendingKey = EnsureTargetKey(targetKey);
|
||||
var label = !string.IsNullOrWhiteSpace(targetDisplayName) ? targetDisplayName! : uid;
|
||||
_pendingRequests[pendingKey] = new PendingRequestInfo(pendingKey, uid, null, label, DateTime.UtcNow);
|
||||
|
||||
return true;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogWarning(ex, "Direct pair request failed for {uid}", uid);
|
||||
if (!string.IsNullOrEmpty(targetKey))
|
||||
{
|
||||
var now = DateTime.UtcNow;
|
||||
lock (_syncRoot)
|
||||
{
|
||||
_activeCooldowns.Remove(targetKey);
|
||||
if (!_refusalTrackers.TryGetValue(targetKey, out var tracker))
|
||||
{
|
||||
tracker = new RefusalTracker();
|
||||
_refusalTrackers[targetKey] = tracker;
|
||||
}
|
||||
|
||||
if (tracker.LockUntil.HasValue && tracker.LockUntil.Value <= now)
|
||||
{
|
||||
tracker.LockUntil = null;
|
||||
tracker.Count = 0;
|
||||
}
|
||||
|
||||
tracker.Count++;
|
||||
if (tracker.Count >= 3)
|
||||
{
|
||||
tracker.LockUntil = now.Add(RefusalLockDuration);
|
||||
}
|
||||
}
|
||||
_pendingRequests.TryRemove(targetKey, out _);
|
||||
}
|
||||
|
||||
_mediator.Publish(new NotificationMessage("Nearby request failed", "The server rejected the request. Try again soon.", NotificationType.Warning));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private static string? BuildTargetKey(string? uid, string? token, string? displayName)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(uid)) return "uid:" + uid;
|
||||
if (!string.IsNullOrEmpty(token)) return "token:" + token;
|
||||
if (!string.IsNullOrEmpty(displayName)) return "name:" + displayName;
|
||||
return null;
|
||||
}
|
||||
|
||||
private void PublishCooldownNotification(TimeSpan remaining)
|
||||
{
|
||||
var durationText = FormatDuration(remaining);
|
||||
_mediator.Publish(new NotificationMessage("Nearby request en attente", $"Nearby request déjà envoyée. Merci d'attendre environ {durationText} avant de réessayer.", NotificationType.Info, TimeSpan.FromSeconds(5)));
|
||||
}
|
||||
|
||||
private void PublishLockNotification(TimeSpan remaining)
|
||||
{
|
||||
var durationText = FormatDuration(remaining);
|
||||
_mediator.Publish(new NotificationMessage("Nearby request bloquée", $"Nearby request bloquée après plusieurs refus. Réessayez dans {durationText}.", NotificationType.Warning, TimeSpan.FromSeconds(5)));
|
||||
}
|
||||
|
||||
private static string FormatDuration(TimeSpan remaining)
|
||||
{
|
||||
if (remaining.TotalMinutes >= 1)
|
||||
{
|
||||
var minutes = Math.Max(1, (int)Math.Ceiling(remaining.TotalMinutes));
|
||||
return minutes == 1 ? "1 minute" : minutes + " minutes";
|
||||
}
|
||||
|
||||
var seconds = Math.Max(1, (int)Math.Ceiling(remaining.TotalSeconds));
|
||||
return seconds == 1 ? "1 seconde" : seconds + " secondes";
|
||||
}
|
||||
|
||||
private sealed class RefusalTracker
|
||||
{
|
||||
public int Count;
|
||||
public DateTime? LockUntil;
|
||||
}
|
||||
|
||||
public IReadOnlyCollection<PendingRequestInfo> GetPendingRequestsSnapshot()
|
||||
{
|
||||
return _pendingRequests.Values.OrderByDescending(v => v.SentAt).ToList();
|
||||
}
|
||||
|
||||
public void RemovePendingRequestByUid(string uid)
|
||||
{
|
||||
if (string.IsNullOrEmpty(uid)) return;
|
||||
foreach (var kvp in _pendingRequests)
|
||||
{
|
||||
if (string.Equals(kvp.Value.Uid, uid, StringComparison.Ordinal))
|
||||
{
|
||||
_pendingRequests.TryRemove(kvp.Key, out _);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void RemovePendingRequestByKey(string key)
|
||||
{
|
||||
if (string.IsNullOrEmpty(key)) return;
|
||||
_pendingRequests.TryRemove(key, out _);
|
||||
}
|
||||
|
||||
private static string EnsureTargetKey(string? targetKey)
|
||||
{
|
||||
return !string.IsNullOrEmpty(targetKey) ? targetKey! : "target:" + Guid.NewGuid().ToString("N");
|
||||
}
|
||||
|
||||
public sealed record PendingRequestInfo(string Key, string? Uid, string? Token, string TargetDisplayName, DateTime SentAt);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,209 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Dalamud.Plugin.Services;
|
||||
using Lumina.Excel.Sheets;
|
||||
using MareSynchronos.MareConfiguration;
|
||||
using MareSynchronos.MareConfiguration.Models;
|
||||
using MareSynchronos.Services;
|
||||
using MareSynchronos.Services.Mediator;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace MareSynchronos.Services.AutoDetect;
|
||||
|
||||
public sealed class AutoDetectSuppressionService : IHostedService, IMediatorSubscriber
|
||||
{
|
||||
private static readonly string[] ContentTypeKeywords =
|
||||
[
|
||||
"dungeon",
|
||||
"donjon",
|
||||
"raid",
|
||||
"trial",
|
||||
"défi",
|
||||
"front",
|
||||
"frontline",
|
||||
"pvp",
|
||||
"jcj",
|
||||
"conflict",
|
||||
"conflit"
|
||||
];
|
||||
|
||||
private readonly ILogger<AutoDetectSuppressionService> _logger;
|
||||
private readonly MareConfigService _configService;
|
||||
private readonly IClientState _clientState;
|
||||
private readonly IDataManager _dataManager;
|
||||
private readonly MareMediator _mediator;
|
||||
private readonly DalamudUtilService _dalamudUtilService;
|
||||
|
||||
private bool _isSuppressed;
|
||||
private bool _hasSavedState;
|
||||
private bool _savedDiscoveryEnabled;
|
||||
private bool _savedAllowRequests;
|
||||
private bool _suppressionWarningShown;
|
||||
public bool IsSuppressed => _isSuppressed;
|
||||
|
||||
public AutoDetectSuppressionService(ILogger<AutoDetectSuppressionService> logger,
|
||||
MareConfigService configService, IClientState clientState,
|
||||
IDataManager dataManager, DalamudUtilService dalamudUtilService, MareMediator mediator)
|
||||
{
|
||||
_logger = logger;
|
||||
_configService = configService;
|
||||
_clientState = clientState;
|
||||
_dataManager = dataManager;
|
||||
_dalamudUtilService = dalamudUtilService;
|
||||
_mediator = mediator;
|
||||
}
|
||||
|
||||
public MareMediator Mediator => _mediator;
|
||||
|
||||
public Task StartAsync(CancellationToken cancellationToken)
|
||||
{
|
||||
_mediator.Subscribe<ZoneSwitchEndMessage>(this, _ => UpdateSuppressionState());
|
||||
_mediator.Subscribe<DalamudLoginMessage>(this, _ => UpdateSuppressionState());
|
||||
_mediator.Subscribe<DalamudLogoutMessage>(this, _ => ClearSuppression());
|
||||
UpdateSuppressionState();
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
public Task StopAsync(CancellationToken cancellationToken)
|
||||
{
|
||||
_mediator.UnsubscribeAll(this);
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
private void UpdateSuppressionState()
|
||||
{
|
||||
_ = _dalamudUtilService.RunOnFrameworkThread(() =>
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!_clientState.IsLoggedIn || _clientState.LocalPlayer == null)
|
||||
{
|
||||
ClearSuppression();
|
||||
return;
|
||||
}
|
||||
|
||||
uint territoryId = _clientState.TerritoryType;
|
||||
bool shouldSuppress = ShouldSuppressForTerritory(territoryId);
|
||||
ApplySuppression(shouldSuppress, territoryId);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogWarning(ex, "Failed to update AutoDetect suppression state");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void ApplySuppression(bool shouldSuppress, uint territoryId)
|
||||
{
|
||||
if (shouldSuppress)
|
||||
{
|
||||
if (!_isSuppressed)
|
||||
{
|
||||
_savedDiscoveryEnabled = _configService.Current.EnableAutoDetectDiscovery;
|
||||
_savedAllowRequests = _configService.Current.AllowAutoDetectPairRequests;
|
||||
_hasSavedState = true;
|
||||
_isSuppressed = true;
|
||||
}
|
||||
|
||||
bool changed = false;
|
||||
if (_configService.Current.EnableAutoDetectDiscovery)
|
||||
{
|
||||
_configService.Current.EnableAutoDetectDiscovery = false;
|
||||
changed = true;
|
||||
}
|
||||
if (_configService.Current.AllowAutoDetectPairRequests)
|
||||
{
|
||||
_configService.Current.AllowAutoDetectPairRequests = false;
|
||||
changed = true;
|
||||
}
|
||||
|
||||
if (changed)
|
||||
{
|
||||
_logger.LogInformation("AutoDetect temporarily disabled in instanced content (territory {territoryId}).", territoryId);
|
||||
if (!_suppressionWarningShown)
|
||||
{
|
||||
_suppressionWarningShown = true;
|
||||
const string warningText = "Zone instanciée détectée : les fonctions AutoDetect/Nearby sont coupées pour économiser de la bande passante.";
|
||||
_mediator.Publish(new DualNotificationMessage("AutoDetect désactivé",
|
||||
warningText,
|
||||
NotificationType.Warning, TimeSpan.FromSeconds(5)));
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!_isSuppressed) return;
|
||||
|
||||
bool changed = false;
|
||||
bool wasSuppressed = _suppressionWarningShown;
|
||||
if (_hasSavedState)
|
||||
{
|
||||
if (_configService.Current.EnableAutoDetectDiscovery != _savedDiscoveryEnabled)
|
||||
{
|
||||
_configService.Current.EnableAutoDetectDiscovery = _savedDiscoveryEnabled;
|
||||
changed = true;
|
||||
}
|
||||
if (_configService.Current.AllowAutoDetectPairRequests != _savedAllowRequests)
|
||||
{
|
||||
_configService.Current.AllowAutoDetectPairRequests = _savedAllowRequests;
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
|
||||
_isSuppressed = false;
|
||||
_hasSavedState = false;
|
||||
_suppressionWarningShown = false;
|
||||
|
||||
if (changed || wasSuppressed)
|
||||
{
|
||||
_logger.LogInformation("AutoDetect restored after leaving instanced content (territory {territoryId}).", territoryId);
|
||||
const string restoredText = "Vous avez quitté la zone instanciée : AutoDetect/Nearby fonctionnent de nouveau.";
|
||||
_mediator.Publish(new DualNotificationMessage("AutoDetect réactivé",
|
||||
restoredText,
|
||||
NotificationType.Info, TimeSpan.FromSeconds(5)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void ClearSuppression()
|
||||
{
|
||||
if (!_isSuppressed) return;
|
||||
_isSuppressed = false;
|
||||
if (_hasSavedState)
|
||||
{
|
||||
_configService.Current.EnableAutoDetectDiscovery = _savedDiscoveryEnabled;
|
||||
_configService.Current.AllowAutoDetectPairRequests = _savedAllowRequests;
|
||||
}
|
||||
_hasSavedState = false;
|
||||
_suppressionWarningShown = false;
|
||||
}
|
||||
|
||||
private bool ShouldSuppressForTerritory(uint territoryId)
|
||||
{
|
||||
if (territoryId == 0) return false;
|
||||
|
||||
var cfcSheet = _dataManager.GetExcelSheet<ContentFinderCondition>();
|
||||
if (cfcSheet == null) return false;
|
||||
|
||||
var cfc = cfcSheet.FirstOrDefault(c => c.TerritoryType.RowId == territoryId);
|
||||
if (cfc.RowId == 0) return false;
|
||||
|
||||
if (MatchesSuppressionKeyword(cfc.Name.ToString())) return true;
|
||||
|
||||
var contentType = cfc.ContentType.Value;
|
||||
if (contentType.RowId == 0) return false;
|
||||
|
||||
return MatchesSuppressionKeyword(contentType.Name.ToString());
|
||||
}
|
||||
|
||||
private static bool MatchesSuppressionKeyword(string? text)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(text)) return false;
|
||||
return ContentTypeKeywords.Any(keyword => text.Contains(keyword, StringComparison.OrdinalIgnoreCase));
|
||||
}
|
||||
}
|
||||
@@ -17,7 +17,6 @@ public class DiscoveryConfigProvider
|
||||
private readonly TokenProvider _tokenProvider;
|
||||
|
||||
private WellKnownRoot? _config;
|
||||
private DateTimeOffset _lastLoad = DateTimeOffset.MinValue;
|
||||
|
||||
public DiscoveryConfigProvider(ILogger<DiscoveryConfigProvider> logger, ServerConfigurationManager serverManager, TokenProvider tokenProvider)
|
||||
{
|
||||
@@ -51,7 +50,6 @@ public class DiscoveryConfigProvider
|
||||
|
||||
root.NearbyDiscovery?.Hydrate();
|
||||
_config = root;
|
||||
_lastLoad = DateTimeOffset.UtcNow;
|
||||
_logger.LogDebug("Loaded Nearby well-known (stapled), enabled={enabled}, expires={exp}", NearbyEnabled, _config?.NearbyDiscovery?.SaltExpiresAt);
|
||||
return true;
|
||||
}
|
||||
@@ -97,7 +95,6 @@ public class DiscoveryConfigProvider
|
||||
|
||||
root.NearbyDiscovery?.Hydrate();
|
||||
_config = root;
|
||||
_lastLoad = DateTimeOffset.UtcNow;
|
||||
_logger.LogInformation("Loaded Nearby well-known (http {path}), enabled={enabled}", path, NearbyEnabled);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
using System;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
using MareSynchronos.Services.Mediator;
|
||||
@@ -7,6 +8,7 @@ using MareSynchronos.WebAPI.AutoDetect;
|
||||
using Dalamud.Plugin.Services;
|
||||
using System.Numerics;
|
||||
using System.Linq;
|
||||
using System.Collections.Generic;
|
||||
using MareSynchronos.Utils;
|
||||
|
||||
namespace MareSynchronos.Services.AutoDetect;
|
||||
@@ -34,6 +36,8 @@ public class NearbyDiscoveryService : IHostedService, IMediatorSubscriber
|
||||
private bool _lastAutoDetectState;
|
||||
private DateTime _lastHeartbeat = DateTime.MinValue;
|
||||
private static readonly TimeSpan HeartbeatInterval = TimeSpan.FromSeconds(75);
|
||||
private readonly object _entriesLock = new();
|
||||
private List<NearbyEntry> _lastEntries = [];
|
||||
|
||||
public NearbyDiscoveryService(ILogger<NearbyDiscoveryService> logger, MareMediator mediator,
|
||||
MareConfigService config, DiscoveryConfigProvider configProvider, DalamudUtilService dalamudUtilService,
|
||||
@@ -52,6 +56,7 @@ public class NearbyDiscoveryService : IHostedService, IMediatorSubscriber
|
||||
|
||||
public Task StartAsync(CancellationToken cancellationToken)
|
||||
{
|
||||
CancelAndDispose(ref _loopCts);
|
||||
_loopCts = new CancellationTokenSource();
|
||||
_mediator.Subscribe<ConnectedMessage>(this, _ => { _isConnected = true; _configProvider.TryLoadFromStapled(); });
|
||||
_mediator.Subscribe<DisconnectedMessage>(this, _ => { _isConnected = false; _lastPublishedSignature = null; });
|
||||
@@ -128,10 +133,41 @@ public class NearbyDiscoveryService : IHostedService, IMediatorSubscriber
|
||||
public Task StopAsync(CancellationToken cancellationToken)
|
||||
{
|
||||
_mediator.UnsubscribeAll(this);
|
||||
try { _loopCts?.Cancel(); } catch { }
|
||||
CancelAndDispose(ref _loopCts);
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
public List<NearbyEntry> SnapshotEntries()
|
||||
{
|
||||
lock (_entriesLock)
|
||||
{
|
||||
return _lastEntries.ToList();
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateSnapshot(List<NearbyEntry> entries)
|
||||
{
|
||||
lock (_entriesLock)
|
||||
{
|
||||
_lastEntries = entries.ToList();
|
||||
}
|
||||
}
|
||||
|
||||
private static void CancelAndDispose(ref CancellationTokenSource? cts)
|
||||
{
|
||||
if (cts == null) return;
|
||||
try
|
||||
{
|
||||
cts.Cancel();
|
||||
}
|
||||
catch (ObjectDisposedException)
|
||||
{
|
||||
}
|
||||
|
||||
cts.Dispose();
|
||||
cts = null;
|
||||
}
|
||||
|
||||
private async Task Loop(CancellationToken ct)
|
||||
{
|
||||
_configProvider.TryLoadFromStapled();
|
||||
@@ -426,6 +462,7 @@ public class NearbyDiscoveryService : IHostedService, IMediatorSubscriber
|
||||
_logger.LogDebug("Nearby: well-known not available or disabled; running in local-only mode");
|
||||
}
|
||||
}
|
||||
UpdateSnapshot(entries);
|
||||
_mediator.Publish(new DiscoveryListUpdated(entries));
|
||||
|
||||
var delayMs = Math.Max(1000, _configProvider.MinQueryIntervalMs);
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
using System;
|
||||
using System.Collections.Concurrent;
|
||||
using System.Text.RegularExpressions;
|
||||
using MareSynchronos.MareConfiguration.Models;
|
||||
using MareSynchronos.Services.Mediator;
|
||||
using MareSynchronos.Services.Notifications;
|
||||
using MareSynchronos.WebAPI;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
@@ -12,17 +15,21 @@ public sealed class NearbyPendingService : IMediatorSubscriber
|
||||
private readonly MareMediator _mediator;
|
||||
private readonly ApiController _api;
|
||||
private readonly AutoDetectRequestService _requestService;
|
||||
private readonly NotificationTracker _notificationTracker;
|
||||
private readonly ConcurrentDictionary<string, string> _pending = new(StringComparer.Ordinal);
|
||||
private static readonly Regex ReqRegex = new(@"^Nearby Request: (.+) \[(?<uid>[A-Z0-9]+)\]$", RegexOptions.Compiled);
|
||||
private static readonly Regex AcceptRegex = new(@"^Nearby Accept: (.+) \[(?<uid>[A-Z0-9]+)\]$", RegexOptions.Compiled);
|
||||
private static readonly TimeSpan RegexTimeout = TimeSpan.FromSeconds(1);
|
||||
private static readonly Regex ReqRegex = new(@"^Nearby Request: .+ \[(?<uid>[A-Z0-9]+)\]$", RegexOptions.Compiled | RegexOptions.ExplicitCapture, RegexTimeout);
|
||||
private static readonly Regex AcceptRegex = new(@"^Nearby Accept: .+ \[(?<uid>[A-Z0-9]+)\]$", RegexOptions.Compiled | RegexOptions.ExplicitCapture, RegexTimeout);
|
||||
|
||||
public NearbyPendingService(ILogger<NearbyPendingService> logger, MareMediator mediator, ApiController api, AutoDetectRequestService requestService)
|
||||
public NearbyPendingService(ILogger<NearbyPendingService> logger, MareMediator mediator, ApiController api, AutoDetectRequestService requestService, NotificationTracker notificationTracker)
|
||||
{
|
||||
_logger = logger;
|
||||
_mediator = mediator;
|
||||
_api = api;
|
||||
_requestService = requestService;
|
||||
_notificationTracker = notificationTracker;
|
||||
_mediator.Subscribe<NotificationMessage>(this, OnNotification);
|
||||
_mediator.Subscribe<ManualPairInviteMessage>(this, OnManualPairInvite);
|
||||
}
|
||||
|
||||
public MareMediator Mediator => _mediator;
|
||||
@@ -41,6 +48,8 @@ public sealed class NearbyPendingService : IMediatorSubscriber
|
||||
{
|
||||
_ = _api.UserAddPair(new MareSynchronos.API.Dto.User.UserDto(new MareSynchronos.API.Data.UserData(uidA)));
|
||||
_pending.TryRemove(uidA, out _);
|
||||
_requestService.RemovePendingRequestByUid(uidA);
|
||||
_notificationTracker.Remove(NotificationCategory.AutoDetect, uidA);
|
||||
_logger.LogInformation("NearbyPending: auto-accepted pairing with {uid}", uidA);
|
||||
}
|
||||
return;
|
||||
@@ -62,11 +71,29 @@ public sealed class NearbyPendingService : IMediatorSubscriber
|
||||
catch { name = uid; }
|
||||
_pending[uid] = name;
|
||||
_logger.LogInformation("NearbyPending: received request from {uid} ({name})", uid, name);
|
||||
_notificationTracker.Upsert(NotificationEntry.AutoDetect(uid, name));
|
||||
}
|
||||
|
||||
private void OnManualPairInvite(ManualPairInviteMessage msg)
|
||||
{
|
||||
if (!string.Equals(msg.TargetUid, _api.UID, StringComparison.Ordinal))
|
||||
return;
|
||||
|
||||
var display = !string.IsNullOrWhiteSpace(msg.DisplayName)
|
||||
? msg.DisplayName!
|
||||
: (!string.IsNullOrWhiteSpace(msg.SourceAlias) ? msg.SourceAlias : msg.SourceUid);
|
||||
|
||||
_pending[msg.SourceUid] = display;
|
||||
_logger.LogInformation("NearbyPending: received manual invite from {uid} ({name})", msg.SourceUid, display);
|
||||
_mediator.Publish(new NotificationMessage("Nearby request", $"{display} vous a envoyé une invitation de pair.", NotificationType.Info, TimeSpan.FromSeconds(5)));
|
||||
_notificationTracker.Upsert(NotificationEntry.AutoDetect(msg.SourceUid, display));
|
||||
}
|
||||
|
||||
public void Remove(string uid)
|
||||
{
|
||||
_pending.TryRemove(uid, out _);
|
||||
_requestService.RemovePendingRequestByUid(uid);
|
||||
_notificationTracker.Remove(NotificationCategory.AutoDetect, uid);
|
||||
}
|
||||
|
||||
public async Task<bool> AcceptAsync(string uid)
|
||||
@@ -75,7 +102,9 @@ public sealed class NearbyPendingService : IMediatorSubscriber
|
||||
{
|
||||
await _api.UserAddPair(new MareSynchronos.API.Dto.User.UserDto(new MareSynchronos.API.Data.UserData(uid))).ConfigureAwait(false);
|
||||
_pending.TryRemove(uid, out _);
|
||||
_requestService.RemovePendingRequestByUid(uid);
|
||||
_ = _requestService.SendAcceptNotifyAsync(uid);
|
||||
_notificationTracker.Remove(NotificationCategory.AutoDetect, uid);
|
||||
return true;
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
||||
158
MareSynchronos/Services/AutoDetect/SyncshellDiscoveryService.cs
Normal file
158
MareSynchronos/Services/AutoDetect/SyncshellDiscoveryService.cs
Normal file
@@ -0,0 +1,158 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using MareSynchronos.API.Data;
|
||||
using MareSynchronos.API.Dto.Group;
|
||||
using MareSynchronos.Services.Mediator;
|
||||
using MareSynchronos.WebAPI;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace MareSynchronos.Services.AutoDetect;
|
||||
|
||||
public sealed class SyncshellDiscoveryService : IHostedService, IMediatorSubscriber
|
||||
{
|
||||
private readonly ILogger<SyncshellDiscoveryService> _logger;
|
||||
private readonly MareMediator _mediator;
|
||||
private readonly ApiController _apiController;
|
||||
private readonly SemaphoreSlim _refreshSemaphore = new(1, 1);
|
||||
private readonly object _entriesLock = new();
|
||||
private List<SyncshellDiscoveryEntryDto> _entries = [];
|
||||
private string? _lastError;
|
||||
private bool _isRefreshing;
|
||||
|
||||
public SyncshellDiscoveryService(ILogger<SyncshellDiscoveryService> logger, MareMediator mediator, ApiController apiController)
|
||||
{
|
||||
_logger = logger;
|
||||
_mediator = mediator;
|
||||
_apiController = apiController;
|
||||
}
|
||||
|
||||
public MareMediator Mediator => _mediator;
|
||||
|
||||
public IReadOnlyList<SyncshellDiscoveryEntryDto> Entries
|
||||
{
|
||||
get
|
||||
{
|
||||
lock (_entriesLock)
|
||||
{
|
||||
return _entries.ToList();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsRefreshing => _isRefreshing;
|
||||
public string? LastError => _lastError;
|
||||
|
||||
public async Task<bool> JoinAsync(string gid, CancellationToken ct)
|
||||
{
|
||||
try
|
||||
{
|
||||
return await _apiController.SyncshellDiscoveryJoin(new GroupDto(new GroupData(gid))).ConfigureAwait(false);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogWarning(ex, "Join syncshell discovery failed for {gid}", gid);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<SyncshellDiscoveryStateDto?> GetStateAsync(string gid, CancellationToken ct)
|
||||
{
|
||||
try
|
||||
{
|
||||
return await _apiController.SyncshellDiscoveryGetState(new GroupDto(new GroupData(gid))).ConfigureAwait(false);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogWarning(ex, "Failed to fetch syncshell discovery state for {gid}", gid);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<bool> SetVisibilityAsync(string gid, bool visible, CancellationToken ct)
|
||||
{
|
||||
return await SetVisibilityAsync(gid, visible, null, null, null, null, null, ct).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
public async Task<bool> SetVisibilityAsync(string gid, bool visible, int? displayDurationHours,
|
||||
int[]? activeWeekdays, TimeSpan? timeStartLocal, TimeSpan? timeEndLocal, string? timeZone,
|
||||
CancellationToken ct)
|
||||
{
|
||||
try
|
||||
{
|
||||
var request = new SyncshellDiscoveryVisibilityRequestDto
|
||||
{
|
||||
GID = gid,
|
||||
AutoDetectVisible = visible,
|
||||
DisplayDurationHours = displayDurationHours,
|
||||
ActiveWeekdays = activeWeekdays,
|
||||
TimeStartLocal = timeStartLocal.HasValue ? new DateTime(timeStartLocal.Value.Ticks).ToString("HH:mm") : null,
|
||||
TimeEndLocal = timeEndLocal.HasValue ? new DateTime(timeEndLocal.Value.Ticks).ToString("HH:mm") : null,
|
||||
TimeZone = timeZone,
|
||||
};
|
||||
var success = await _apiController.SyncshellDiscoverySetVisibility(request).ConfigureAwait(false);
|
||||
if (!success) return false;
|
||||
|
||||
var state = await GetStateAsync(gid, ct).ConfigureAwait(false);
|
||||
if (state != null)
|
||||
{
|
||||
_mediator.Publish(new SyncshellAutoDetectStateChanged(state.GID, state.AutoDetectVisible, state.PasswordTemporarilyDisabled));
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogWarning(ex, "Failed to set syncshell visibility for {gid}", gid);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public async Task RefreshAsync(CancellationToken ct)
|
||||
{
|
||||
if (!await _refreshSemaphore.WaitAsync(0, ct).ConfigureAwait(false))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
_isRefreshing = true;
|
||||
var discovered = await _apiController.SyncshellDiscoveryList().ConfigureAwait(false);
|
||||
lock (_entriesLock)
|
||||
{
|
||||
_entries = discovered ?? [];
|
||||
}
|
||||
_lastError = null;
|
||||
_mediator.Publish(new SyncshellDiscoveryUpdated(Entries.ToList()));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogWarning(ex, "Failed to refresh syncshell discovery list");
|
||||
_lastError = ex.Message;
|
||||
}
|
||||
finally
|
||||
{
|
||||
_isRefreshing = false;
|
||||
_refreshSemaphore.Release();
|
||||
}
|
||||
}
|
||||
|
||||
public Task StartAsync(CancellationToken cancellationToken)
|
||||
{
|
||||
_mediator.Subscribe<ConnectedMessage>(this, msg =>
|
||||
{
|
||||
_ = RefreshAsync(CancellationToken.None);
|
||||
});
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
public Task StopAsync(CancellationToken cancellationToken)
|
||||
{
|
||||
_mediator.UnsubscribeAll(this);
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
}
|
||||
@@ -11,6 +11,7 @@ using MareSynchronos.Services.CharaData.Models;
|
||||
using MareSynchronos.Utils;
|
||||
using MareSynchronos.WebAPI.Files;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System.Threading;
|
||||
|
||||
namespace MareSynchronos.Services;
|
||||
|
||||
@@ -295,6 +296,32 @@ public sealed class CharaDataFileHandler : IDisposable
|
||||
}
|
||||
}
|
||||
|
||||
internal async Task<byte[]?> CreateCharaFileBytesAsync(string description, CancellationToken token = default)
|
||||
{
|
||||
var tempFilePath = Path.Combine(Path.GetTempPath(), "umbra_mcdfshare_" + Guid.NewGuid().ToString("N") + ".mcdf");
|
||||
try
|
||||
{
|
||||
await SaveCharaFileAsync(description, tempFilePath).ConfigureAwait(false);
|
||||
if (!File.Exists(tempFilePath)) return null;
|
||||
token.ThrowIfCancellationRequested();
|
||||
return await File.ReadAllBytesAsync(tempFilePath, token).ConfigureAwait(false);
|
||||
}
|
||||
finally
|
||||
{
|
||||
try
|
||||
{
|
||||
if (File.Exists(tempFilePath))
|
||||
{
|
||||
File.Delete(tempFilePath);
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
// ignored
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
internal async Task<List<string>> UploadFiles(List<string> fileList, ValueProgress<string> uploadProgress, CancellationToken token)
|
||||
{
|
||||
return await _fileUploadManager.UploadFiles(fileList, uploadProgress, token).ConfigureAwait(false);
|
||||
|
||||
@@ -13,7 +13,9 @@ using MareSynchronos.Utils;
|
||||
using MareSynchronos.WebAPI;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System.Collections.Concurrent;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
|
||||
namespace MareSynchronos.Services;
|
||||
|
||||
@@ -457,6 +459,14 @@ public sealed partial class CharaDataManager : DisposableMediatorSubscriberBase
|
||||
LoadedMcdfHeader = _fileHandler.LoadCharaFileHeader(filePath);
|
||||
}
|
||||
|
||||
public async Task<string> LoadMcdfFromBytes(byte[] data, CancellationToken token = default)
|
||||
{
|
||||
var tempFilePath = Path.Combine(Path.GetTempPath(), "umbra_mcdfshare_" + Guid.NewGuid().ToString("N") + ".mcdf");
|
||||
await File.WriteAllBytesAsync(tempFilePath, data, token).ConfigureAwait(false);
|
||||
LoadedMcdfHeader = _fileHandler.LoadCharaFileHeader(tempFilePath);
|
||||
return tempFilePath;
|
||||
}
|
||||
|
||||
public void McdfApplyToTarget(string charaName)
|
||||
{
|
||||
if (LoadedMcdfHeader == null || !LoadedMcdfHeader.IsCompletedSuccessfully) return;
|
||||
|
||||
@@ -28,7 +28,7 @@ public sealed class CharaDataNearbyManager : DisposableMediatorSubscriberBase
|
||||
private Task? _filterEntriesRunningTask;
|
||||
private (Guid VfxId, PoseEntryExtended Pose)? _hoveredVfx = null;
|
||||
private DateTime _lastExecutionTime = DateTime.UtcNow;
|
||||
private SemaphoreSlim _sharedDataUpdateSemaphore = new(1, 1);
|
||||
private readonly SemaphoreSlim _sharedDataUpdateSemaphore = new(1, 1);
|
||||
public CharaDataNearbyManager(ILogger<CharaDataNearbyManager> logger, MareMediator mediator,
|
||||
DalamudUtilService dalamudUtilService, VfxSpawnManager vfxSpawnManager,
|
||||
ServerConfigurationManager serverConfigurationManager,
|
||||
@@ -201,7 +201,7 @@ public sealed class CharaDataNearbyManager : DisposableMediatorSubscriberBase
|
||||
foreach (var data in _metaInfoCache.Where(d => (string.IsNullOrWhiteSpace(UserNoteFilter)
|
||||
|| ((d.Key.Alias ?? string.Empty).Contains(UserNoteFilter, StringComparison.OrdinalIgnoreCase)
|
||||
|| d.Key.UID.Contains(UserNoteFilter, StringComparison.OrdinalIgnoreCase)
|
||||
|| (_serverConfigurationManager.GetNoteForUid(UserNoteFilter) ?? string.Empty).Contains(UserNoteFilter, StringComparison.OrdinalIgnoreCase))))
|
||||
|| (_serverConfigurationManager.GetNoteForUid(d.Key.UID) ?? string.Empty).Contains(UserNoteFilter, StringComparison.OrdinalIgnoreCase))))
|
||||
.ToDictionary(k => k.Key, k => k.Value))
|
||||
{
|
||||
// filter all poses based on territory, that always must be correct
|
||||
@@ -266,26 +266,47 @@ public sealed class CharaDataNearbyManager : DisposableMediatorSubscriberBase
|
||||
|
||||
private void ManageWispsNearby(List<PoseEntryExtended> previousPoses)
|
||||
{
|
||||
foreach (var data in _nearbyData.Keys)
|
||||
int maxWisps = _charaDataConfigService.Current.NearbyMaxWisps;
|
||||
if (maxWisps <= 0)
|
||||
{
|
||||
if (_poseVfx.TryGetValue(data, out var _)) continue;
|
||||
ClearAllVfx();
|
||||
return;
|
||||
}
|
||||
|
||||
Guid? vfxGuid;
|
||||
if (data.MetaInfo.IsOwnData)
|
||||
const int hardLimit = 200;
|
||||
if (maxWisps > hardLimit) maxWisps = hardLimit;
|
||||
|
||||
var orderedAllowedPoses = _nearbyData
|
||||
.OrderBy(kvp => kvp.Value.Distance)
|
||||
.Take(maxWisps)
|
||||
.Select(kvp => kvp.Key)
|
||||
.ToList();
|
||||
|
||||
var allowedPoseSet = orderedAllowedPoses.ToHashSet();
|
||||
|
||||
foreach (var data in orderedAllowedPoses)
|
||||
{
|
||||
vfxGuid = _vfxSpawnManager.SpawnObject(data.Position, data.Rotation, Vector3.One * 2, 0.8f, 0.5f, 0.0f, 0.7f);
|
||||
}
|
||||
else
|
||||
{
|
||||
vfxGuid = _vfxSpawnManager.SpawnObject(data.Position, data.Rotation, Vector3.One * 2);
|
||||
}
|
||||
if (_poseVfx.TryGetValue(data, out _)) continue;
|
||||
|
||||
Guid? vfxGuid = data.MetaInfo.IsOwnData
|
||||
? _vfxSpawnManager.SpawnObject(data.Position, data.Rotation, Vector3.One * 2, 0.8f, 0.5f, 0.0f, 0.7f)
|
||||
: _vfxSpawnManager.SpawnObject(data.Position, data.Rotation, Vector3.One * 2);
|
||||
|
||||
if (vfxGuid != null)
|
||||
{
|
||||
_poseVfx[data] = vfxGuid.Value;
|
||||
}
|
||||
}
|
||||
|
||||
foreach (var data in previousPoses.Except(_nearbyData.Keys))
|
||||
foreach (var data in previousPoses.Except(allowedPoseSet))
|
||||
{
|
||||
if (_poseVfx.Remove(data, out var guid))
|
||||
{
|
||||
_vfxSpawnManager.DespawnObject(guid);
|
||||
}
|
||||
}
|
||||
|
||||
foreach (var data in _poseVfx.Keys.Except(allowedPoseSet).ToList())
|
||||
{
|
||||
if (_poseVfx.Remove(data, out var guid))
|
||||
{
|
||||
|
||||
309
MareSynchronos/Services/CharaData/McdfShareManager.cs
Normal file
309
MareSynchronos/Services/CharaData/McdfShareManager.cs
Normal file
@@ -0,0 +1,309 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Security.Cryptography;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using MareSynchronos.API.Dto.McdfShare;
|
||||
using MareSynchronos.MareConfiguration.Models;
|
||||
using MareSynchronos.Services.ServerConfiguration;
|
||||
using MareSynchronos.WebAPI;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace MareSynchronos.Services.CharaData;
|
||||
|
||||
public sealed class McdfShareManager
|
||||
{
|
||||
private readonly ILogger<McdfShareManager> _logger;
|
||||
private readonly ApiController _apiController;
|
||||
private readonly CharaDataFileHandler _fileHandler;
|
||||
private readonly CharaDataManager _charaDataManager;
|
||||
private readonly ServerConfigurationManager _serverConfigurationManager;
|
||||
private readonly SemaphoreSlim _operationSemaphore = new(1, 1);
|
||||
private readonly List<McdfShareEntryDto> _ownShares = new();
|
||||
private readonly List<McdfShareEntryDto> _sharedWithMe = new();
|
||||
private Task? _currentTask;
|
||||
|
||||
public McdfShareManager(ILogger<McdfShareManager> logger, ApiController apiController,
|
||||
CharaDataFileHandler fileHandler, CharaDataManager charaDataManager,
|
||||
ServerConfigurationManager serverConfigurationManager)
|
||||
{
|
||||
_logger = logger;
|
||||
_apiController = apiController;
|
||||
_fileHandler = fileHandler;
|
||||
_charaDataManager = charaDataManager;
|
||||
_serverConfigurationManager = serverConfigurationManager;
|
||||
}
|
||||
|
||||
public IReadOnlyList<McdfShareEntryDto> OwnShares => _ownShares;
|
||||
public IReadOnlyList<McdfShareEntryDto> SharedShares => _sharedWithMe;
|
||||
public bool IsBusy => _currentTask is { IsCompleted: false };
|
||||
public string? LastError { get; private set; }
|
||||
public string? LastSuccess { get; private set; }
|
||||
|
||||
public Task RefreshAsync(CancellationToken token)
|
||||
{
|
||||
return RunOperation(() => InternalRefreshAsync(token));
|
||||
}
|
||||
|
||||
public Task CreateShareAsync(string description, IReadOnlyList<string> allowedIndividuals, IReadOnlyList<string> allowedSyncshells, DateTime? expiresAtUtc, CancellationToken token)
|
||||
{
|
||||
return RunOperation(async () =>
|
||||
{
|
||||
token.ThrowIfCancellationRequested();
|
||||
|
||||
var mcdfBytes = await _fileHandler.CreateCharaFileBytesAsync(description, token).ConfigureAwait(false);
|
||||
if (mcdfBytes == null || mcdfBytes.Length == 0)
|
||||
{
|
||||
LastError = "Impossible de préparer les données MCDF.";
|
||||
return;
|
||||
}
|
||||
|
||||
var secretKey = _serverConfigurationManager.GetSecretKey(out bool hasMultiple);
|
||||
if (hasMultiple)
|
||||
{
|
||||
LastError = "Plusieurs clés secrètes sont configurées pour ce personnage. Corrigez cela dans les paramètres.";
|
||||
return;
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(secretKey))
|
||||
{
|
||||
LastError = "Aucune clé secrète n'est configurée pour ce personnage.";
|
||||
return;
|
||||
}
|
||||
|
||||
var shareId = Guid.NewGuid();
|
||||
byte[] salt = RandomNumberGenerator.GetBytes(16);
|
||||
byte[] nonce = RandomNumberGenerator.GetBytes(12);
|
||||
byte[] key = DeriveKey(secretKey, shareId, salt);
|
||||
|
||||
byte[] cipher = new byte[mcdfBytes.Length];
|
||||
byte[] tag = new byte[16];
|
||||
|
||||
using (var aes = new AesGcm(key, 16))
|
||||
{
|
||||
aes.Encrypt(nonce, mcdfBytes, cipher, tag);
|
||||
}
|
||||
|
||||
var uploadDto = new McdfShareUploadRequestDto
|
||||
{
|
||||
ShareId = shareId,
|
||||
Description = description,
|
||||
CipherData = cipher,
|
||||
Nonce = nonce,
|
||||
Salt = salt,
|
||||
Tag = tag,
|
||||
ExpiresAtUtc = expiresAtUtc,
|
||||
AllowedIndividuals = allowedIndividuals.ToList(),
|
||||
AllowedSyncshells = allowedSyncshells.ToList()
|
||||
};
|
||||
|
||||
await _apiController.McdfShareUpload(uploadDto).ConfigureAwait(false);
|
||||
await InternalRefreshAsync(token).ConfigureAwait(false);
|
||||
LastSuccess = "Partage MCDF créé.";
|
||||
});
|
||||
}
|
||||
|
||||
public Task DeleteShareAsync(Guid shareId)
|
||||
{
|
||||
return RunOperation(async () =>
|
||||
{
|
||||
var result = await _apiController.McdfShareDelete(shareId).ConfigureAwait(false);
|
||||
if (!result)
|
||||
{
|
||||
LastError = "Le serveur a refusé de supprimer le partage MCDF.";
|
||||
return;
|
||||
}
|
||||
|
||||
_ownShares.RemoveAll(s => s.Id == shareId);
|
||||
_sharedWithMe.RemoveAll(s => s.Id == shareId);
|
||||
await InternalRefreshAsync(CancellationToken.None).ConfigureAwait(false);
|
||||
LastSuccess = "Partage MCDF supprimé.";
|
||||
});
|
||||
}
|
||||
|
||||
public Task UpdateShareAsync(McdfShareUpdateRequestDto updateRequest)
|
||||
{
|
||||
return RunOperation(async () =>
|
||||
{
|
||||
var updated = await _apiController.McdfShareUpdate(updateRequest).ConfigureAwait(false);
|
||||
if (updated == null)
|
||||
{
|
||||
LastError = "Le serveur a refusé de mettre à jour le partage MCDF.";
|
||||
return;
|
||||
}
|
||||
|
||||
var idx = _ownShares.FindIndex(s => s.Id == updated.Id);
|
||||
if (idx >= 0)
|
||||
{
|
||||
_ownShares[idx] = updated;
|
||||
}
|
||||
LastSuccess = "Partage MCDF mis à jour.";
|
||||
});
|
||||
}
|
||||
|
||||
public Task ApplyShareAsync(Guid shareId, CancellationToken token)
|
||||
{
|
||||
return RunOperation(async () =>
|
||||
{
|
||||
token.ThrowIfCancellationRequested();
|
||||
var plainBytes = await DownloadAndDecryptShareAsync(shareId, token).ConfigureAwait(false);
|
||||
if (plainBytes == null)
|
||||
{
|
||||
LastError ??= "Échec du téléchargement du partage MCDF.";
|
||||
return;
|
||||
}
|
||||
|
||||
var tempPath = await _charaDataManager.LoadMcdfFromBytes(plainBytes, token).ConfigureAwait(false);
|
||||
try
|
||||
{
|
||||
await _charaDataManager.McdfApplyToGposeTarget().ConfigureAwait(false);
|
||||
}
|
||||
finally
|
||||
{
|
||||
try
|
||||
{
|
||||
if (File.Exists(tempPath))
|
||||
{
|
||||
File.Delete(tempPath);
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
// ignored
|
||||
}
|
||||
}
|
||||
LastSuccess = "Partage MCDF appliqué sur la cible GPose.";
|
||||
});
|
||||
}
|
||||
|
||||
public Task ExportShareAsync(Guid shareId, string filePath, CancellationToken token)
|
||||
{
|
||||
return RunOperation(async () =>
|
||||
{
|
||||
token.ThrowIfCancellationRequested();
|
||||
var plainBytes = await DownloadAndDecryptShareAsync(shareId, token).ConfigureAwait(false);
|
||||
if (plainBytes == null)
|
||||
{
|
||||
LastError ??= "Échec du téléchargement du partage MCDF.";
|
||||
return;
|
||||
}
|
||||
|
||||
var directory = Path.GetDirectoryName(filePath);
|
||||
if (!string.IsNullOrEmpty(directory))
|
||||
{
|
||||
Directory.CreateDirectory(directory);
|
||||
}
|
||||
|
||||
await File.WriteAllBytesAsync(filePath, plainBytes, token).ConfigureAwait(false);
|
||||
LastSuccess = "Partage MCDF exporté.";
|
||||
});
|
||||
}
|
||||
|
||||
public Task DownloadShareToFileAsync(McdfShareEntryDto entry, string filePath, CancellationToken token)
|
||||
{
|
||||
return ExportShareAsync(entry.Id, filePath, token);
|
||||
}
|
||||
|
||||
private async Task<byte[]?> DownloadAndDecryptShareAsync(Guid shareId, CancellationToken token)
|
||||
{
|
||||
var payload = await _apiController.McdfShareDownload(shareId).ConfigureAwait(false);
|
||||
if (payload == null)
|
||||
{
|
||||
LastError = "Partage indisponible.";
|
||||
return null;
|
||||
}
|
||||
|
||||
var secretKey = _serverConfigurationManager.GetSecretKey(out bool hasMultiple);
|
||||
if (hasMultiple)
|
||||
{
|
||||
LastError = "Plusieurs clés secrètes sont configurées pour ce personnage.";
|
||||
return null;
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(secretKey))
|
||||
{
|
||||
LastError = "Aucune clé secrète n'est configurée pour ce personnage.";
|
||||
return null;
|
||||
}
|
||||
|
||||
byte[] key = DeriveKey(secretKey, payload.ShareId, payload.Salt);
|
||||
byte[] plaintext = new byte[payload.CipherData.Length];
|
||||
try
|
||||
{
|
||||
using var aes = new AesGcm(key, 16);
|
||||
aes.Decrypt(payload.Nonce, payload.CipherData, payload.Tag, plaintext);
|
||||
}
|
||||
catch (CryptographicException ex)
|
||||
{
|
||||
_logger.LogWarning(ex, "Failed to decrypt MCDF share {ShareId}", shareId);
|
||||
LastError = "Impossible de déchiffrer le partage MCDF.";
|
||||
return null;
|
||||
}
|
||||
|
||||
token.ThrowIfCancellationRequested();
|
||||
return plaintext;
|
||||
}
|
||||
|
||||
private async Task InternalRefreshAsync(CancellationToken token)
|
||||
{
|
||||
token.ThrowIfCancellationRequested();
|
||||
var own = await _apiController.McdfShareGetOwn().ConfigureAwait(false);
|
||||
token.ThrowIfCancellationRequested();
|
||||
var shared = await _apiController.McdfShareGetShared().ConfigureAwait(false);
|
||||
_ownShares.Clear();
|
||||
_ownShares.AddRange(own);
|
||||
_sharedWithMe.Clear();
|
||||
_sharedWithMe.AddRange(shared);
|
||||
LastSuccess = "Partages MCDF actualisés.";
|
||||
}
|
||||
|
||||
private Task RunOperation(Func<Task> operation)
|
||||
{
|
||||
async Task Wrapper()
|
||||
{
|
||||
await _operationSemaphore.WaitAsync().ConfigureAwait(false);
|
||||
try
|
||||
{
|
||||
LastError = null;
|
||||
LastSuccess = null;
|
||||
await operation().ConfigureAwait(false);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Error during MCDF share operation");
|
||||
LastError = ex.Message;
|
||||
}
|
||||
finally
|
||||
{
|
||||
_operationSemaphore.Release();
|
||||
}
|
||||
}
|
||||
|
||||
var task = Wrapper();
|
||||
_currentTask = task;
|
||||
return task;
|
||||
}
|
||||
|
||||
private static byte[] DeriveKey(string secretKey, Guid shareId, byte[] salt)
|
||||
{
|
||||
byte[] secretBytes;
|
||||
try
|
||||
{
|
||||
secretBytes = Convert.FromHexString(secretKey);
|
||||
}
|
||||
catch (FormatException)
|
||||
{
|
||||
// fallback to UTF8 if not hex
|
||||
secretBytes = System.Text.Encoding.UTF8.GetBytes(secretKey);
|
||||
}
|
||||
|
||||
byte[] shareBytes = shareId.ToByteArray();
|
||||
byte[] material = new byte[secretBytes.Length + shareBytes.Length + salt.Length];
|
||||
Buffer.BlockCopy(secretBytes, 0, material, 0, secretBytes.Length);
|
||||
Buffer.BlockCopy(shareBytes, 0, material, secretBytes.Length, shareBytes.Length);
|
||||
Buffer.BlockCopy(salt, 0, material, secretBytes.Length + shareBytes.Length, salt.Length);
|
||||
return SHA256.HashData(material);
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,11 @@
|
||||
using Lumina.Data.Files;
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using Lumina.Data.Files;
|
||||
using MareSynchronos.API.Data;
|
||||
using MareSynchronos.API.Data.Enum;
|
||||
using MareSynchronos.FileCache;
|
||||
using MareSynchronos.MareConfiguration;
|
||||
using MareSynchronos.MareConfiguration.Models;
|
||||
using MareSynchronos.Services.Mediator;
|
||||
using MareSynchronos.UI;
|
||||
using MareSynchronos.Utils;
|
||||
@@ -14,40 +18,52 @@ public sealed class CharacterAnalyzer : DisposableMediatorSubscriberBase
|
||||
private readonly FileCacheManager _fileCacheManager;
|
||||
private readonly XivDataAnalyzer _xivDataAnalyzer;
|
||||
private CancellationTokenSource? _analysisCts;
|
||||
private CancellationTokenSource _baseAnalysisCts = new();
|
||||
private CancellationTokenSource? _baseAnalysisCts = new();
|
||||
private string _lastDataHash = string.Empty;
|
||||
private CharacterAnalysisSummary _previousSummary = CharacterAnalysisSummary.Empty;
|
||||
private DateTime _lastAutoAnalysis = DateTime.MinValue;
|
||||
private string _lastAutoAnalysisHash = string.Empty;
|
||||
private const int AutoAnalysisFileDeltaThreshold = 25;
|
||||
private const long AutoAnalysisSizeDeltaThreshold = 50L * 1024 * 1024;
|
||||
private static readonly TimeSpan AutoAnalysisCooldown = TimeSpan.FromMinutes(2);
|
||||
private const long NotificationSizeThreshold = 300L * 1024 * 1024;
|
||||
private const long NotificationTriangleThreshold = 150_000;
|
||||
private bool _sizeWarningShown;
|
||||
private bool _triangleWarningShown;
|
||||
private readonly PlayerPerformanceConfigService _playerPerformanceConfigService;
|
||||
|
||||
public CharacterAnalyzer(ILogger<CharacterAnalyzer> logger, MareMediator mediator, FileCacheManager fileCacheManager, XivDataAnalyzer modelAnalyzer)
|
||||
public CharacterAnalyzer(ILogger<CharacterAnalyzer> logger, MareMediator mediator, FileCacheManager fileCacheManager, XivDataAnalyzer modelAnalyzer, PlayerPerformanceConfigService playerPerformanceConfigService)
|
||||
: base(logger, mediator)
|
||||
{
|
||||
Mediator.Subscribe<CharacterDataCreatedMessage>(this, (msg) =>
|
||||
{
|
||||
_baseAnalysisCts = _baseAnalysisCts.CancelRecreate();
|
||||
var token = _baseAnalysisCts.Token;
|
||||
var tokenSource = EnsureFreshCts(ref _baseAnalysisCts);
|
||||
var token = tokenSource.Token;
|
||||
_ = BaseAnalysis(msg.CharacterData, token);
|
||||
});
|
||||
_fileCacheManager = fileCacheManager;
|
||||
_xivDataAnalyzer = modelAnalyzer;
|
||||
_playerPerformanceConfigService = playerPerformanceConfigService;
|
||||
}
|
||||
|
||||
public int CurrentFile { get; internal set; }
|
||||
public bool IsAnalysisRunning => _analysisCts != null;
|
||||
public int TotalFiles { get; internal set; }
|
||||
public CharacterAnalysisSummary CurrentSummary { get; private set; } = CharacterAnalysisSummary.Empty;
|
||||
public DateTime? LastCompletedAnalysis { get; private set; }
|
||||
internal Dictionary<ObjectKind, Dictionary<string, FileDataEntry>> LastAnalysis { get; } = [];
|
||||
|
||||
public void CancelAnalyze()
|
||||
{
|
||||
_analysisCts?.CancelDispose();
|
||||
_analysisCts = null;
|
||||
CancelAndDispose(ref _analysisCts);
|
||||
}
|
||||
|
||||
public async Task ComputeAnalysis(bool print = true, bool recalculate = false)
|
||||
{
|
||||
Logger.LogDebug("=== Calculating Character Analysis ===");
|
||||
|
||||
_analysisCts = _analysisCts?.CancelRecreate() ?? new();
|
||||
|
||||
var cancelToken = _analysisCts.Token;
|
||||
var analysisCts = EnsureFreshCts(ref _analysisCts);
|
||||
var cancelToken = analysisCts.Token;
|
||||
|
||||
var allFiles = LastAnalysis.SelectMany(v => v.Value.Select(d => d.Value)).ToList();
|
||||
if (allFiles.Exists(c => !c.IsComputed || recalculate))
|
||||
@@ -80,10 +96,16 @@ public sealed class CharacterAnalyzer : DisposableMediatorSubscriberBase
|
||||
}
|
||||
}
|
||||
|
||||
RefreshSummary(false, _lastDataHash);
|
||||
|
||||
Mediator.Publish(new CharacterDataAnalyzedMessage());
|
||||
|
||||
_analysisCts.CancelDispose();
|
||||
_analysisCts = null;
|
||||
if (!cancelToken.IsCancellationRequested)
|
||||
{
|
||||
LastCompletedAnalysis = DateTime.UtcNow;
|
||||
}
|
||||
|
||||
CancelAndDispose(ref _analysisCts);
|
||||
|
||||
if (print) PrintAnalysis();
|
||||
}
|
||||
@@ -94,8 +116,8 @@ public sealed class CharacterAnalyzer : DisposableMediatorSubscriberBase
|
||||
|
||||
if (!disposing) return;
|
||||
|
||||
_analysisCts?.CancelDispose();
|
||||
_baseAnalysisCts.CancelDispose();
|
||||
CancelAndDispose(ref _analysisCts);
|
||||
CancelAndDispose(ref _baseAnalysisCts);
|
||||
}
|
||||
|
||||
private async Task BaseAnalysis(CharacterData charaData, CancellationToken token)
|
||||
@@ -142,9 +164,11 @@ public sealed class CharacterAnalyzer : DisposableMediatorSubscriberBase
|
||||
LastAnalysis[obj.Key] = data;
|
||||
}
|
||||
|
||||
_lastDataHash = charaData.DataHash.Value;
|
||||
RefreshSummary(true, _lastDataHash);
|
||||
|
||||
Mediator.Publish(new CharacterDataAnalyzedMessage());
|
||||
|
||||
_lastDataHash = charaData.DataHash.Value;
|
||||
}
|
||||
|
||||
private void PrintAnalysis()
|
||||
@@ -193,6 +217,169 @@ public sealed class CharacterAnalyzer : DisposableMediatorSubscriberBase
|
||||
Logger.LogInformation("IMPORTANT NOTES:\n\r- For uploads and downloads only the compressed size is relevant.\n\r- An unusually high total files count beyond 200 and up will also increase your download time to others significantly.");
|
||||
}
|
||||
|
||||
private void RefreshSummary(bool evaluateAutoAnalysis, string dataHash)
|
||||
{
|
||||
var summary = CalculateSummary();
|
||||
CurrentSummary = summary;
|
||||
|
||||
if (evaluateAutoAnalysis)
|
||||
{
|
||||
EvaluateAutoAnalysis(summary, dataHash);
|
||||
}
|
||||
else
|
||||
{
|
||||
_previousSummary = summary;
|
||||
|
||||
if (!summary.HasUncomputedEntries && string.Equals(_lastAutoAnalysisHash, dataHash, StringComparison.Ordinal))
|
||||
{
|
||||
_lastAutoAnalysisHash = string.Empty;
|
||||
}
|
||||
}
|
||||
|
||||
EvaluateThresholdNotifications(summary);
|
||||
}
|
||||
|
||||
private CharacterAnalysisSummary CalculateSummary()
|
||||
{
|
||||
if (LastAnalysis.Count == 0)
|
||||
{
|
||||
return CharacterAnalysisSummary.Empty;
|
||||
}
|
||||
|
||||
long original = 0;
|
||||
long compressed = 0;
|
||||
long triangles = 0;
|
||||
int files = 0;
|
||||
bool hasUncomputed = false;
|
||||
|
||||
foreach (var obj in LastAnalysis.Values)
|
||||
{
|
||||
foreach (var entry in obj.Values)
|
||||
{
|
||||
files++;
|
||||
original += entry.OriginalSize;
|
||||
compressed += entry.CompressedSize;
|
||||
triangles += entry.Triangles;
|
||||
hasUncomputed |= !entry.IsComputed;
|
||||
}
|
||||
}
|
||||
|
||||
return new CharacterAnalysisSummary(files, original, compressed, triangles, hasUncomputed);
|
||||
}
|
||||
|
||||
private void EvaluateAutoAnalysis(CharacterAnalysisSummary newSummary, string dataHash)
|
||||
{
|
||||
var previous = _previousSummary;
|
||||
_previousSummary = newSummary;
|
||||
|
||||
if (newSummary.TotalFiles == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (string.Equals(_lastAutoAnalysisHash, dataHash, StringComparison.Ordinal))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (IsAnalysisRunning)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var now = DateTime.UtcNow;
|
||||
if (now - _lastAutoAnalysis < AutoAnalysisCooldown)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
bool firstSummary = previous.TotalFiles == 0;
|
||||
bool filesIncreased = newSummary.TotalFiles - previous.TotalFiles >= AutoAnalysisFileDeltaThreshold;
|
||||
bool sizeIncreased = newSummary.TotalCompressedSize - previous.TotalCompressedSize >= AutoAnalysisSizeDeltaThreshold;
|
||||
bool needsCompute = newSummary.HasUncomputedEntries;
|
||||
|
||||
if (!firstSummary && !filesIncreased && !sizeIncreased && !needsCompute)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_lastAutoAnalysis = now;
|
||||
_lastAutoAnalysisHash = dataHash;
|
||||
_ = ComputeAnalysis(print: false);
|
||||
}
|
||||
|
||||
private void EvaluateThresholdNotifications(CharacterAnalysisSummary summary)
|
||||
{
|
||||
if (summary.IsEmpty || summary.HasUncomputedEntries)
|
||||
{
|
||||
ResetThresholdFlagsIfNeeded(summary);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!_playerPerformanceConfigService.Current.ShowSelfAnalysisWarnings)
|
||||
{
|
||||
ResetThresholdFlagsIfNeeded(summary);
|
||||
return;
|
||||
}
|
||||
|
||||
bool sizeExceeded = summary.TotalCompressedSize >= NotificationSizeThreshold;
|
||||
bool trianglesExceeded = summary.TotalTriangles >= NotificationTriangleThreshold;
|
||||
List<string> exceededReasons = new();
|
||||
|
||||
if (sizeExceeded && !_sizeWarningShown)
|
||||
{
|
||||
exceededReasons.Add($"un poids partagé de {UiSharedService.ByteToString(summary.TotalCompressedSize)} (≥ 300 MiB)");
|
||||
_sizeWarningShown = true;
|
||||
}
|
||||
else if (!sizeExceeded && _sizeWarningShown)
|
||||
{
|
||||
_sizeWarningShown = false;
|
||||
}
|
||||
|
||||
if (trianglesExceeded && !_triangleWarningShown)
|
||||
{
|
||||
exceededReasons.Add($"un total de {UiSharedService.TrisToString(summary.TotalTriangles)} triangles (≥ 150k)");
|
||||
_triangleWarningShown = true;
|
||||
}
|
||||
else if (!trianglesExceeded && _triangleWarningShown)
|
||||
{
|
||||
_triangleWarningShown = false;
|
||||
}
|
||||
|
||||
if (exceededReasons.Count == 0) return;
|
||||
|
||||
string combined = string.Join(" et ", exceededReasons);
|
||||
string message = $"Attention : votre self-analysis indique {combined}. Des joueurs risquent de ne pas vous voir et UmbraSync peut activer un auto-pause. Pensez à réduire textures ou modèles lourds.";
|
||||
Mediator.Publish(new DualNotificationMessage("Self Analysis", message, NotificationType.Warning));
|
||||
}
|
||||
|
||||
private void ResetThresholdFlagsIfNeeded(CharacterAnalysisSummary summary)
|
||||
{
|
||||
if (summary.IsEmpty)
|
||||
{
|
||||
_sizeWarningShown = false;
|
||||
_triangleWarningShown = false;
|
||||
return;
|
||||
}
|
||||
|
||||
if (summary.TotalCompressedSize < NotificationSizeThreshold)
|
||||
{
|
||||
_sizeWarningShown = false;
|
||||
}
|
||||
|
||||
if (summary.TotalTriangles < NotificationTriangleThreshold)
|
||||
{
|
||||
_triangleWarningShown = false;
|
||||
}
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Auto)]
|
||||
public readonly record struct CharacterAnalysisSummary(int TotalFiles, long TotalOriginalSize, long TotalCompressedSize, long TotalTriangles, bool HasUncomputedEntries)
|
||||
{
|
||||
public static CharacterAnalysisSummary Empty => new();
|
||||
public bool IsEmpty => TotalFiles == 0 && TotalOriginalSize == 0 && TotalCompressedSize == 0 && TotalTriangles == 0;
|
||||
}
|
||||
|
||||
internal sealed record FileDataEntry(string Hash, string FileType, List<string> GamePaths, List<string> FilePaths, long OriginalSize, long CompressedSize, long Triangles)
|
||||
{
|
||||
public bool IsComputed => OriginalSize > 0 && CompressedSize > 0;
|
||||
@@ -239,4 +426,26 @@ public sealed class CharacterAnalyzer : DisposableMediatorSubscriberBase
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private static CancellationTokenSource EnsureFreshCts(ref CancellationTokenSource? cts)
|
||||
{
|
||||
CancelAndDispose(ref cts);
|
||||
cts = new CancellationTokenSource();
|
||||
return cts;
|
||||
}
|
||||
|
||||
private static void CancelAndDispose(ref CancellationTokenSource? cts)
|
||||
{
|
||||
if (cts == null) return;
|
||||
try
|
||||
{
|
||||
cts.Cancel();
|
||||
}
|
||||
catch (ObjectDisposedException)
|
||||
{
|
||||
}
|
||||
|
||||
cts.Dispose();
|
||||
cts = null;
|
||||
}
|
||||
}
|
||||
@@ -1,3 +1,6 @@
|
||||
using System;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using Dalamud.Game.Text;
|
||||
using Dalamud.Game.Text.SeStringHandling;
|
||||
using Dalamud.Game.Text.SeStringHandling.Payloads;
|
||||
@@ -5,6 +8,7 @@ using Dalamud.Plugin.Services;
|
||||
using MareSynchronos.API.Data;
|
||||
using MareSynchronos.Interop;
|
||||
using MareSynchronos.MareConfiguration;
|
||||
using MareSynchronos.API.Data.Enum;
|
||||
using MareSynchronos.MareConfiguration.Models;
|
||||
using MareSynchronos.PlayerData.Pairs;
|
||||
using MareSynchronos.Services.Mediator;
|
||||
@@ -18,6 +22,7 @@ namespace MareSynchronos.Services;
|
||||
public class ChatService : DisposableMediatorSubscriberBase
|
||||
{
|
||||
public const int DefaultColor = 710;
|
||||
private const string ManualPairInvitePrefix = "[UmbraPairInvite|";
|
||||
public const int CommandMaxNumber = 50;
|
||||
|
||||
private readonly ILogger<ChatService> _logger;
|
||||
@@ -30,6 +35,14 @@ public class ChatService : DisposableMediatorSubscriberBase
|
||||
|
||||
private readonly Lazy<GameChatHooks> _gameChatHooks;
|
||||
|
||||
private readonly object _typingLock = new();
|
||||
private CancellationTokenSource? _typingCts;
|
||||
private bool _isTypingAnnounced;
|
||||
private DateTime _lastTypingSent = DateTime.MinValue;
|
||||
private TypingScope _lastScope = TypingScope.Unknown;
|
||||
private static readonly TimeSpan TypingIdle = TimeSpan.FromSeconds(2);
|
||||
private static readonly TimeSpan TypingResendInterval = TimeSpan.FromMilliseconds(750);
|
||||
|
||||
public ChatService(ILogger<ChatService> logger, DalamudUtilService dalamudUtil, MareMediator mediator, ApiController apiController,
|
||||
PairManager pairManager, ILoggerFactory loggerFactory, IGameInteropProvider gameInteropProvider, IChatGui chatGui,
|
||||
MareConfigService mareConfig, ServerConfigurationManager serverConfigurationManager) : base(logger, mediator)
|
||||
@@ -46,13 +59,12 @@ public class ChatService : DisposableMediatorSubscriberBase
|
||||
Mediator.Subscribe<GroupChatMsgMessage>(this, HandleGroupChat);
|
||||
|
||||
_gameChatHooks = new(() => new GameChatHooks(loggerFactory.CreateLogger<GameChatHooks>(), gameInteropProvider, SendChatShell));
|
||||
|
||||
// Initialize chat hooks in advance
|
||||
_ = Task.Run(() =>
|
||||
{
|
||||
try
|
||||
{
|
||||
_ = _gameChatHooks.Value;
|
||||
_isTypingAnnounced = false;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@@ -64,9 +76,81 @@ public class ChatService : DisposableMediatorSubscriberBase
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
base.Dispose(disposing);
|
||||
_typingCts?.Cancel();
|
||||
_typingCts?.Dispose();
|
||||
if (_gameChatHooks.IsValueCreated)
|
||||
_gameChatHooks.Value!.Dispose();
|
||||
}
|
||||
public void NotifyTypingKeystroke(TypingScope scope)
|
||||
{
|
||||
lock (_typingLock)
|
||||
{
|
||||
var now = DateTime.UtcNow;
|
||||
if (!_isTypingAnnounced || (now - _lastTypingSent) >= TypingResendInterval)
|
||||
{
|
||||
_ = Task.Run(async () =>
|
||||
{
|
||||
try { await _apiController.UserSetTypingState(true, scope).ConfigureAwait(false); }
|
||||
catch (Exception ex) { _logger.LogDebug(ex, "NotifyTypingKeystroke: failed to send typing=true"); }
|
||||
});
|
||||
_isTypingAnnounced = true;
|
||||
_lastTypingSent = now;
|
||||
_lastScope = scope;
|
||||
}
|
||||
|
||||
_typingCts?.Cancel();
|
||||
_typingCts?.Dispose();
|
||||
_typingCts = new CancellationTokenSource();
|
||||
var token = _typingCts.Token;
|
||||
|
||||
_ = Task.Run(async () =>
|
||||
{
|
||||
try
|
||||
{
|
||||
await Task.Delay(TypingIdle, token).ConfigureAwait(false);
|
||||
await _apiController.UserSetTypingState(false, _lastScope).ConfigureAwait(false);
|
||||
}
|
||||
catch (TaskCanceledException)
|
||||
{
|
||||
// reset timer
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogDebug(ex, "NotifyTypingKeystroke: failed to send typing=false");
|
||||
}
|
||||
finally
|
||||
{
|
||||
lock (_typingLock)
|
||||
{
|
||||
if (!token.IsCancellationRequested)
|
||||
{
|
||||
_isTypingAnnounced = false;
|
||||
_lastTypingSent = DateTime.MinValue;
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
public void ClearTypingState()
|
||||
{
|
||||
lock (_typingLock)
|
||||
{
|
||||
_typingCts?.Cancel();
|
||||
_typingCts?.Dispose();
|
||||
_typingCts = null;
|
||||
if (_isTypingAnnounced)
|
||||
{
|
||||
_ = Task.Run(async () =>
|
||||
{
|
||||
try { await _apiController.UserSetTypingState(false, _lastScope).ConfigureAwait(false); }
|
||||
catch (Exception ex) { _logger.LogDebug(ex, "ClearTypingState: failed to send typing=false"); }
|
||||
});
|
||||
_isTypingAnnounced = false;
|
||||
_lastTypingSent = DateTime.MinValue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void HandleUserChat(UserChatMsgMessage message)
|
||||
{
|
||||
@@ -113,6 +197,10 @@ public class ChatService : DisposableMediatorSubscriberBase
|
||||
var extraChatTags = _mareConfig.Current.ExtraChatTags;
|
||||
var logKind = ResolveShellLogKind(shellConfig.LogKind);
|
||||
|
||||
var payload = SeString.Parse(message.ChatMsg.PayloadContent);
|
||||
if (TryHandleManualPairInvite(message, payload))
|
||||
return;
|
||||
|
||||
var msg = new SeStringBuilder();
|
||||
if (extraChatTags)
|
||||
{
|
||||
@@ -124,7 +212,6 @@ public class ChatService : DisposableMediatorSubscriberBase
|
||||
msg.AddText($"[SS{shellNumber}]<");
|
||||
if (message.ChatMsg.Sender.UID.Equals(_apiController.UID, StringComparison.Ordinal))
|
||||
{
|
||||
// Don't link to your own character
|
||||
msg.AddText(chatMsg.SenderName);
|
||||
}
|
||||
else
|
||||
@@ -132,7 +219,7 @@ public class ChatService : DisposableMediatorSubscriberBase
|
||||
msg.Add(new PlayerPayload(chatMsg.SenderName, chatMsg.SenderHomeWorldId));
|
||||
}
|
||||
msg.AddText("> ");
|
||||
msg.Append(SeString.Parse(message.ChatMsg.PayloadContent));
|
||||
msg.Append(payload);
|
||||
if (color != 0)
|
||||
msg.AddUiForegroundOff();
|
||||
|
||||
@@ -143,7 +230,51 @@ public class ChatService : DisposableMediatorSubscriberBase
|
||||
});
|
||||
}
|
||||
|
||||
// Print an example message to the configured global chat channel
|
||||
private bool TryHandleManualPairInvite(GroupChatMsgMessage message, SeString payload)
|
||||
{
|
||||
var textValue = payload.TextValue;
|
||||
if (string.IsNullOrEmpty(textValue) || !textValue.StartsWith(ManualPairInvitePrefix, StringComparison.Ordinal))
|
||||
return false;
|
||||
|
||||
var content = textValue[ManualPairInvitePrefix.Length..];
|
||||
if (content.EndsWith("]", StringComparison.Ordinal))
|
||||
{
|
||||
content = content[..^1];
|
||||
}
|
||||
|
||||
var parts = content.Split('|');
|
||||
if (parts.Length < 4)
|
||||
return true;
|
||||
|
||||
var sourceUid = parts[0];
|
||||
var sourceAlias = DecodeInviteField(parts[1]);
|
||||
var targetUid = parts[2];
|
||||
var displayName = DecodeInviteField(parts[3]);
|
||||
var inviteId = parts.Length > 4 ? parts[4] : Guid.NewGuid().ToString("N");
|
||||
|
||||
if (!string.Equals(targetUid, _apiController.UID, StringComparison.Ordinal))
|
||||
return true;
|
||||
|
||||
Mediator.Publish(new ManualPairInviteMessage(sourceUid, sourceAlias, targetUid, string.IsNullOrEmpty(displayName) ? null : displayName, inviteId));
|
||||
_logger.LogDebug("Received manual pair invite from {source} via syncshell", sourceUid);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private static string DecodeInviteField(string encoded)
|
||||
{
|
||||
if (string.IsNullOrEmpty(encoded)) return string.Empty;
|
||||
|
||||
try
|
||||
{
|
||||
var bytes = Convert.FromBase64String(encoded);
|
||||
return Encoding.UTF8.GetString(bytes);
|
||||
}
|
||||
catch
|
||||
{
|
||||
return encoded;
|
||||
}
|
||||
}
|
||||
public void PrintChannelExample(string message, string gid = "")
|
||||
{
|
||||
int chatType = _mareConfig.Current.ChatLogKind;
|
||||
@@ -164,8 +295,6 @@ public class ChatService : DisposableMediatorSubscriberBase
|
||||
Type = (XivChatType)chatType
|
||||
});
|
||||
}
|
||||
|
||||
// Called to update the active chat shell name if its renamed
|
||||
public void MaybeUpdateShellName(int shellNumber)
|
||||
{
|
||||
if (_mareConfig.Current.DisableSyncshellChat)
|
||||
@@ -178,7 +307,6 @@ public class ChatService : DisposableMediatorSubscriberBase
|
||||
{
|
||||
if (_gameChatHooks.IsValueCreated && _gameChatHooks.Value.ChatChannelOverride != null)
|
||||
{
|
||||
// Very dumb and won't handle re-numbering -- need to identify the active chat channel more reliably later
|
||||
if (_gameChatHooks.Value.ChatChannelOverride.ChannelName.StartsWith($"SS [{shellNumber}]", StringComparison.Ordinal))
|
||||
SwitchChatShell(shellNumber);
|
||||
}
|
||||
@@ -197,7 +325,6 @@ public class ChatService : DisposableMediatorSubscriberBase
|
||||
if (shellConfig.Enabled && shellConfig.ShellNumber == shellNumber)
|
||||
{
|
||||
var name = _serverConfigurationManager.GetNoteForGid(group.Key.GID) ?? group.Key.AliasOrGID;
|
||||
// BUG: This doesn't always update the chat window e.g. when renaming a group
|
||||
_gameChatHooks.Value.ChatChannelOverride = new()
|
||||
{
|
||||
ChannelName = $"SS [{shellNumber}]: {name}",
|
||||
@@ -221,7 +348,6 @@ public class ChatService : DisposableMediatorSubscriberBase
|
||||
if (shellConfig.Enabled && shellConfig.ShellNumber == shellNumber)
|
||||
{
|
||||
_ = Task.Run(async () => {
|
||||
// Should cache the name and home world instead of fetching it every time
|
||||
var chatMsg = await _dalamudUtil.RunOnFrameworkThread(() => {
|
||||
return new ChatMessage()
|
||||
{
|
||||
@@ -230,6 +356,7 @@ public class ChatService : DisposableMediatorSubscriberBase
|
||||
PayloadContent = chatBytes
|
||||
};
|
||||
}).ConfigureAwait(false);
|
||||
ClearTypingState();
|
||||
await _apiController.GroupChatSendMsg(new(group.Key), chatMsg).ConfigureAwait(false);
|
||||
}).ConfigureAwait(false);
|
||||
return;
|
||||
|
||||
68
MareSynchronos/Services/ChatTwoCompatibilityService.cs
Normal file
68
MareSynchronos/Services/ChatTwoCompatibilityService.cs
Normal file
@@ -0,0 +1,68 @@
|
||||
using System;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Dalamud.Plugin;
|
||||
using MareSynchronos.MareConfiguration.Models;
|
||||
using MareSynchronos.Services.Mediator;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace MareSynchronos.Services;
|
||||
|
||||
public sealed class ChatTwoCompatibilityService : MediatorSubscriberBase, IHostedService
|
||||
{
|
||||
private const string ChatTwoInternalName = "ChatTwo";
|
||||
private readonly IDalamudPluginInterface _pluginInterface;
|
||||
private bool _warningShown;
|
||||
|
||||
public ChatTwoCompatibilityService(ILogger<ChatTwoCompatibilityService> logger, IDalamudPluginInterface pluginInterface, MareMediator mediator)
|
||||
: base(logger, mediator)
|
||||
{
|
||||
_pluginInterface = pluginInterface;
|
||||
|
||||
Mediator.SubscribeKeyed<PluginChangeMessage>(this, ChatTwoInternalName, OnChatTwoStateChanged);
|
||||
}
|
||||
|
||||
public Task StartAsync(CancellationToken cancellationToken)
|
||||
{
|
||||
try
|
||||
{
|
||||
var initialState = PluginWatcherService.GetInitialPluginState(_pluginInterface, ChatTwoInternalName);
|
||||
if (initialState?.IsLoaded == true)
|
||||
{
|
||||
ShowWarning();
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logger.LogDebug(ex, "Failed to inspect ChatTwo initial state");
|
||||
}
|
||||
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
public Task StopAsync(CancellationToken cancellationToken)
|
||||
{
|
||||
Mediator.UnsubscribeAll(this);
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
private void OnChatTwoStateChanged(PluginChangeMessage message)
|
||||
{
|
||||
if (message.IsLoaded)
|
||||
{
|
||||
ShowWarning();
|
||||
}
|
||||
}
|
||||
|
||||
private void ShowWarning()
|
||||
{
|
||||
if (_warningShown) return;
|
||||
_warningShown = true;
|
||||
|
||||
const string warningTitle = "ChatTwo détecté";
|
||||
const string warningBody = "Actuellement, le plugin ChatTwo n'est pas compatible avec la bulle d'écriture d'UmbraSync. Désactivez ChatTwo si vous souhaitez conserver l'indicateur de saisie.";
|
||||
|
||||
Mediator.Publish(new NotificationMessage(warningTitle, warningBody, NotificationType.Warning, TimeSpan.FromSeconds(10)));
|
||||
}
|
||||
}
|
||||
373
MareSynchronos/Services/ChatTypingDetectionService.cs
Normal file
373
MareSynchronos/Services/ChatTypingDetectionService.cs
Normal file
@@ -0,0 +1,373 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Runtime.CompilerServices;
|
||||
using Dalamud.Plugin.Services;
|
||||
using Dalamud.Utility;
|
||||
using Dalamud.Game.Text;
|
||||
using FFXIVClientStructs.FFXIV.Component.GUI;
|
||||
using FFXIVClientStructs.FFXIV.Client.UI.Shell;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using MareSynchronos.PlayerData.Pairs;
|
||||
using MareSynchronos.WebAPI;
|
||||
using MareSynchronos.MareConfiguration;
|
||||
using MareSynchronos.API.Data.Enum;
|
||||
|
||||
namespace MareSynchronos.Services;
|
||||
|
||||
public sealed class ChatTypingDetectionService : IDisposable
|
||||
{
|
||||
private readonly ILogger<ChatTypingDetectionService> _logger;
|
||||
private readonly IFramework _framework;
|
||||
private readonly IClientState _clientState;
|
||||
private readonly IGameGui _gameGui;
|
||||
private readonly ChatService _chatService;
|
||||
private readonly TypingIndicatorStateService _typingStateService;
|
||||
private readonly ApiController _apiController;
|
||||
private readonly PairManager _pairManager;
|
||||
private readonly IPartyList _partyList;
|
||||
private readonly MareConfigService _configService;
|
||||
|
||||
private string _lastChatText = string.Empty;
|
||||
private bool _isTyping;
|
||||
private bool _notifyingRemote;
|
||||
private bool _serverSupportWarnLogged;
|
||||
private bool _remoteNotificationsEnabled;
|
||||
private bool _subscribed;
|
||||
|
||||
public ChatTypingDetectionService(ILogger<ChatTypingDetectionService> logger, IFramework framework,
|
||||
IClientState clientState, IGameGui gameGui, ChatService chatService, PairManager pairManager, IPartyList partyList,
|
||||
TypingIndicatorStateService typingStateService, ApiController apiController, MareConfigService configService)
|
||||
{
|
||||
_logger = logger;
|
||||
_framework = framework;
|
||||
_clientState = clientState;
|
||||
_gameGui = gameGui;
|
||||
_chatService = chatService;
|
||||
_pairManager = pairManager;
|
||||
_partyList = partyList;
|
||||
_typingStateService = typingStateService;
|
||||
_apiController = apiController;
|
||||
_configService = configService;
|
||||
|
||||
Subscribe();
|
||||
_logger.LogInformation("ChatTypingDetectionService initialized");
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
Unsubscribe();
|
||||
ResetTypingState();
|
||||
}
|
||||
|
||||
public void SoftRestart()
|
||||
{
|
||||
try
|
||||
{
|
||||
_logger.LogInformation("TypingDetection: soft restarting");
|
||||
Unsubscribe();
|
||||
ResetTypingState();
|
||||
_chatService.ClearTypingState();
|
||||
_typingStateService.ClearAll();
|
||||
Subscribe();
|
||||
_logger.LogInformation("TypingDetection: soft restart completed");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogWarning(ex, "TypingDetection: soft restart failed");
|
||||
}
|
||||
}
|
||||
|
||||
private void Subscribe()
|
||||
{
|
||||
if (_subscribed) return;
|
||||
_framework.Update += OnFrameworkUpdate;
|
||||
_subscribed = true;
|
||||
}
|
||||
|
||||
private void Unsubscribe()
|
||||
{
|
||||
if (!_subscribed) return;
|
||||
_framework.Update -= OnFrameworkUpdate;
|
||||
_subscribed = false;
|
||||
}
|
||||
|
||||
private void OnFrameworkUpdate(IFramework framework)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!_clientState.IsLoggedIn)
|
||||
{
|
||||
ResetTypingState();
|
||||
return;
|
||||
}
|
||||
|
||||
if (!_configService.Current.TypingIndicatorEnabled)
|
||||
{
|
||||
ResetTypingState();
|
||||
_chatService.ClearTypingState();
|
||||
return;
|
||||
}
|
||||
|
||||
if (!TryGetChatInput(out var chatText) || string.IsNullOrEmpty(chatText))
|
||||
{
|
||||
ResetTypingState();
|
||||
return;
|
||||
}
|
||||
|
||||
if (IsIgnoredCommand(chatText))
|
||||
{
|
||||
ResetTypingState();
|
||||
return;
|
||||
}
|
||||
|
||||
var notifyRemote = ShouldNotifyRemote();
|
||||
UpdateRemoteNotificationLogState(notifyRemote);
|
||||
if (!notifyRemote && _notifyingRemote)
|
||||
{
|
||||
_chatService.ClearTypingState();
|
||||
_notifyingRemote = false;
|
||||
}
|
||||
|
||||
if (!_isTyping || !string.Equals(chatText, _lastChatText, StringComparison.Ordinal))
|
||||
{
|
||||
if (notifyRemote)
|
||||
{
|
||||
var scope = GetCurrentTypingScope();
|
||||
_chatService.NotifyTypingKeystroke(scope);
|
||||
_notifyingRemote = true;
|
||||
}
|
||||
|
||||
_typingStateService.SetSelfTypingLocal(true);
|
||||
_isTyping = true;
|
||||
}
|
||||
|
||||
_lastChatText = chatText;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogTrace(ex, "ChatTypingDetectionService tick failed");
|
||||
}
|
||||
}
|
||||
|
||||
private void ResetTypingState()
|
||||
{
|
||||
if (!_isTyping)
|
||||
{
|
||||
_lastChatText = string.Empty;
|
||||
return;
|
||||
}
|
||||
|
||||
_isTyping = false;
|
||||
_lastChatText = string.Empty;
|
||||
_chatService.ClearTypingState();
|
||||
_notifyingRemote = false;
|
||||
_typingStateService.SetSelfTypingLocal(false);
|
||||
}
|
||||
|
||||
private unsafe TypingScope GetCurrentTypingScope()
|
||||
{
|
||||
try
|
||||
{
|
||||
var shellModule = RaptureShellModule.Instance();
|
||||
if (shellModule == null)
|
||||
return TypingScope.Unknown;
|
||||
|
||||
var chatType = (XivChatType)shellModule->ChatType;
|
||||
switch (chatType)
|
||||
{
|
||||
case XivChatType.Say:
|
||||
case XivChatType.Shout:
|
||||
case XivChatType.Yell:
|
||||
return TypingScope.Proximity;
|
||||
case XivChatType.Party:
|
||||
return TypingScope.Party;
|
||||
case XivChatType.CrossParty:
|
||||
return TypingScope.CrossParty;
|
||||
default:
|
||||
return TypingScope.Unknown;
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
return TypingScope.Unknown;
|
||||
}
|
||||
}
|
||||
|
||||
private static bool IsIgnoredCommand(string chatText)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(chatText))
|
||||
return false;
|
||||
|
||||
var trimmed = chatText.TrimStart();
|
||||
if (!trimmed.StartsWith('/'))
|
||||
return false;
|
||||
|
||||
var firstTokenEnd = trimmed.IndexOf(' ');
|
||||
var command = firstTokenEnd >= 0 ? trimmed[..firstTokenEnd] : trimmed;
|
||||
command = command.TrimEnd();
|
||||
|
||||
var comparison = StringComparison.OrdinalIgnoreCase;
|
||||
return command.StartsWith("/tell", comparison)
|
||||
|| command.StartsWith("/t", comparison)
|
||||
|| command.StartsWith("/xllog", comparison)
|
||||
|| command.StartsWith("/umbra", comparison)
|
||||
|| command.StartsWith("/fc", comparison)
|
||||
|| command.StartsWith("/freecompany", comparison);
|
||||
}
|
||||
|
||||
private unsafe bool ShouldNotifyRemote()
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!_configService.Current.TypingIndicatorEnabled)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
var supportsTypingState = _apiController.SystemInfoDto.SupportsTypingState;
|
||||
var connected = _apiController.IsConnected;
|
||||
if (!connected || !supportsTypingState)
|
||||
{
|
||||
if (!_serverSupportWarnLogged)
|
||||
{
|
||||
_logger.LogDebug("TypingDetection: server support unavailable (connected={connected}, supports={supports})", connected, supportsTypingState);
|
||||
_serverSupportWarnLogged = true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
_serverSupportWarnLogged = false;
|
||||
|
||||
var shellModule = RaptureShellModule.Instance();
|
||||
if (shellModule == null)
|
||||
{
|
||||
_logger.LogDebug("TypingDetection: shell module null");
|
||||
return true;
|
||||
}
|
||||
|
||||
var chatType = (XivChatType)shellModule->ChatType;
|
||||
switch (chatType)
|
||||
{
|
||||
case XivChatType.Say:
|
||||
case XivChatType.Shout:
|
||||
case XivChatType.Yell:
|
||||
return true;
|
||||
case XivChatType.Party:
|
||||
case XivChatType.CrossParty:
|
||||
var eligible = PartyContainsPairedMember();
|
||||
return eligible;
|
||||
case XivChatType.Debug:
|
||||
return true;
|
||||
default:
|
||||
_logger.LogTrace("TypingDetection: channel {type} rejected", chatType);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogTrace(ex, "ChatTypingDetectionService: failed to evaluate chat channel");
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private bool PartyContainsPairedMember()
|
||||
{
|
||||
try
|
||||
{
|
||||
var pairedNames = new HashSet<string>(StringComparer.OrdinalIgnoreCase);
|
||||
foreach (var pair in _pairManager.GetOnlineUserPairs())
|
||||
{
|
||||
if (!string.IsNullOrEmpty(pair.PlayerName))
|
||||
pairedNames.Add(pair.PlayerName);
|
||||
}
|
||||
|
||||
if (pairedNames.Count == 0)
|
||||
{
|
||||
_logger.LogDebug("TypingDetection: no paired names online");
|
||||
return false;
|
||||
}
|
||||
|
||||
foreach (var member in _partyList)
|
||||
{
|
||||
var name = member?.Name?.TextValue;
|
||||
if (string.IsNullOrEmpty(name))
|
||||
continue;
|
||||
|
||||
if (pairedNames.Contains(name))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogDebug(ex, "ChatTypingDetectionService: failed to check party composition");
|
||||
}
|
||||
|
||||
_logger.LogDebug("TypingDetection: no paired members in party");
|
||||
return false;
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
private unsafe bool TryGetChatInput(out string chatText)
|
||||
{
|
||||
chatText = string.Empty;
|
||||
|
||||
var addon = _gameGui.GetAddonByName("ChatLog", 1);
|
||||
if (addon.Address == nint.Zero)
|
||||
return false;
|
||||
|
||||
var chatLog = (AtkUnitBase*)addon.Address;
|
||||
if (chatLog == null || !chatLog->IsVisible)
|
||||
return false;
|
||||
|
||||
var textInputNode = chatLog->UldManager.NodeList[16];
|
||||
if (textInputNode == null)
|
||||
return false;
|
||||
|
||||
var componentNode = textInputNode->GetAsAtkComponentNode();
|
||||
if (componentNode == null || componentNode->Component == null)
|
||||
return false;
|
||||
|
||||
var cursorNode = componentNode->Component->UldManager.NodeList[14];
|
||||
if (cursorNode == null)
|
||||
return false;
|
||||
|
||||
var cursorVisible = cursorNode->IsVisible();
|
||||
if (!cursorVisible)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
var chatInputNode = componentNode->Component->UldManager.NodeList[1];
|
||||
if (chatInputNode == null)
|
||||
return false;
|
||||
|
||||
var textNode = chatInputNode->GetAsAtkTextNode();
|
||||
if (textNode == null)
|
||||
return false;
|
||||
|
||||
var rawText = textNode->GetText();
|
||||
if (rawText == null)
|
||||
return false;
|
||||
|
||||
chatText = rawText.AsDalamudSeString().ToString();
|
||||
return true;
|
||||
}
|
||||
|
||||
private void UpdateRemoteNotificationLogState(bool notifyRemote)
|
||||
{
|
||||
if (notifyRemote && !_remoteNotificationsEnabled)
|
||||
{
|
||||
_remoteNotificationsEnabled = true;
|
||||
_logger.LogInformation("TypingDetection: remote notifications enabled");
|
||||
}
|
||||
else if (!notifyRemote && _remoteNotificationsEnabled)
|
||||
{
|
||||
_remoteNotificationsEnabled = false;
|
||||
_logger.LogInformation("TypingDetection: remote notifications disabled");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -9,12 +9,14 @@ using MareSynchronos.UI;
|
||||
using MareSynchronos.WebAPI;
|
||||
using System.Globalization;
|
||||
using System.Text;
|
||||
using System.Numerics;
|
||||
|
||||
namespace MareSynchronos.Services;
|
||||
|
||||
public sealed class CommandManagerService : IDisposable
|
||||
{
|
||||
private const string _commandName = "/usync";
|
||||
private const string _autoDetectCommand = "/autodetect";
|
||||
private const string _ssCommandPrefix = "/ums";
|
||||
|
||||
private readonly ApiController _apiController;
|
||||
@@ -43,6 +45,11 @@ public sealed class CommandManagerService : IDisposable
|
||||
HelpMessage = "Opens the UmbraSync UI"
|
||||
});
|
||||
|
||||
_commandManager.AddHandler(_autoDetectCommand, new CommandInfo(OnAutoDetectCommand)
|
||||
{
|
||||
HelpMessage = "Opens the AutoDetect window"
|
||||
});
|
||||
|
||||
// Lazy registration of all possible /ss# commands which tbf is what the game does for linkshells anyway
|
||||
for (int i = 1; i <= ChatService.CommandMaxNumber; ++i)
|
||||
{
|
||||
@@ -56,12 +63,21 @@ public sealed class CommandManagerService : IDisposable
|
||||
public void Dispose()
|
||||
{
|
||||
_commandManager.RemoveHandler(_commandName);
|
||||
|
||||
_commandManager.RemoveHandler(_autoDetectCommand);
|
||||
|
||||
for (int i = 1; i <= ChatService.CommandMaxNumber; ++i)
|
||||
_commandManager.RemoveHandler($"{_ssCommandPrefix}{i}");
|
||||
}
|
||||
|
||||
private void OnAutoDetectCommand(string command, string args)
|
||||
{
|
||||
UiSharedService.AccentColor = new Vector4(0x8D / 255f, 0x37 / 255f, 0xC0 / 255f, 1f);
|
||||
UiSharedService.AccentHoverColor = new Vector4(0x3A / 255f, 0x15 / 255f, 0x50 / 255f, 1f);
|
||||
UiSharedService.AccentActiveColor = UiSharedService.AccentHoverColor;
|
||||
_mediator.Publish(new UiToggleMessage(typeof(AutoDetectUi)));
|
||||
}
|
||||
|
||||
|
||||
private void OnCommand(string command, string args)
|
||||
{
|
||||
var splitArgs = args.ToLowerInvariant().Trim().Split(" ", StringSplitOptions.RemoveEmptyEntries);
|
||||
|
||||
@@ -20,6 +20,8 @@ using Microsoft.Extensions.Logging;
|
||||
using System.Numerics;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Text;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using GameObject = FFXIVClientStructs.FFXIV.Client.Game.Object.GameObject;
|
||||
using DalamudGameObject = Dalamud.Game.ClientState.Objects.Types.IGameObject;
|
||||
|
||||
@@ -52,6 +54,7 @@ public class DalamudUtilService : IHostedService, IMediatorSubscriber
|
||||
private readonly ILogger<DalamudUtilService> _logger;
|
||||
private readonly IObjectTable _objectTable;
|
||||
private readonly PerformanceCollectorService _performanceCollector;
|
||||
private readonly Dictionary<string, ConditionFlag> _conditionLookup = new(StringComparer.OrdinalIgnoreCase);
|
||||
private uint? _classJobId = 0;
|
||||
private DateTime _delayedFrameworkUpdateCheck = DateTime.UtcNow;
|
||||
private string _lastGlobalBlockPlayer = string.Empty;
|
||||
@@ -172,6 +175,20 @@ public class DalamudUtilService : IHostedService, IMediatorSubscriber
|
||||
public bool IsInCombatOrPerforming { get; private set; } = false;
|
||||
public bool HasModifiedGameFiles => _gameData.HasModifiedGameDataFiles;
|
||||
|
||||
public bool IsConditionActive(string flagName)
|
||||
{
|
||||
if (_conditionLookup.TryGetValue(flagName, out var cachedFlag))
|
||||
return _condition[cachedFlag];
|
||||
|
||||
if (Enum.TryParse<ConditionFlag>(flagName, true, out var flag))
|
||||
{
|
||||
_conditionLookup[flagName] = flag;
|
||||
return _condition[flag];
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public Lazy<Dictionary<ushort, string>> WorldData { get; private set; }
|
||||
public Lazy<Dictionary<int, Lumina.Excel.Sheets.UIColor>> UiColors { get; private set; }
|
||||
public Lazy<Dictionary<uint, string>> TerritoryData { get; private set; }
|
||||
|
||||
@@ -1,18 +1,21 @@
|
||||
using System;
|
||||
using Dalamud.Game.Gui.NamePlate;
|
||||
using Dalamud.Game.Text.SeStringHandling;
|
||||
using Dalamud.Game.Text.SeStringHandling.Payloads;
|
||||
using Dalamud.Plugin.Services;
|
||||
using MareSynchronos.API.Dto.User;
|
||||
using MareSynchronos.MareConfiguration;
|
||||
using MareSynchronos.PlayerData.Pairs;
|
||||
using MareSynchronos.Services.Mediator;
|
||||
using MareSynchronos.UI;
|
||||
using MareSynchronos.WebAPI;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Dalamud.Game.Text;
|
||||
|
||||
namespace MareSynchronos.Services;
|
||||
|
||||
public class GuiHookService : DisposableMediatorSubscriberBase
|
||||
{
|
||||
private readonly ILogger<GuiHookService> _logger;
|
||||
private readonly DalamudUtilService _dalamudUtil;
|
||||
private readonly MareConfigService _configService;
|
||||
private readonly INamePlateGui _namePlateGui;
|
||||
@@ -27,7 +30,6 @@ public class GuiHookService : DisposableMediatorSubscriberBase
|
||||
INamePlateGui namePlateGui, IGameConfig gameConfig, IPartyList partyList, PairManager pairManager)
|
||||
: base(logger, mediator)
|
||||
{
|
||||
_logger = logger;
|
||||
_dalamudUtil = dalamudUtil;
|
||||
_configService = configService;
|
||||
_namePlateGui = namePlateGui;
|
||||
@@ -41,11 +43,14 @@ public class GuiHookService : DisposableMediatorSubscriberBase
|
||||
Mediator.Subscribe<DelayedFrameworkUpdateMessage>(this, (_) => GameSettingsCheck());
|
||||
Mediator.Subscribe<PairHandlerVisibleMessage>(this, (_) => RequestRedraw());
|
||||
Mediator.Subscribe<NameplateRedrawMessage>(this, (_) => RequestRedraw());
|
||||
Mediator.Subscribe<UserTypingStateMessage>(this, (_) => RequestRedraw());
|
||||
}
|
||||
|
||||
public void RequestRedraw(bool force = false)
|
||||
{
|
||||
if (!_configService.Current.UseNameColors)
|
||||
var useColors = _configService.Current.UseNameColors;
|
||||
|
||||
if (!useColors)
|
||||
{
|
||||
if (!_isModified && !force)
|
||||
return;
|
||||
@@ -69,7 +74,8 @@ public class GuiHookService : DisposableMediatorSubscriberBase
|
||||
|
||||
private void OnNamePlateUpdate(INamePlateUpdateContext context, IReadOnlyList<INamePlateUpdateHandler> handlers)
|
||||
{
|
||||
if (!_configService.Current.UseNameColors)
|
||||
var applyColors = _configService.Current.UseNameColors;
|
||||
if (!applyColors)
|
||||
return;
|
||||
|
||||
var visibleUsers = _pairManager.GetOnlineUserPairs().Where(u => u.IsVisible && u.PlayerCharacterId != uint.MaxValue);
|
||||
@@ -89,6 +95,8 @@ public class GuiHookService : DisposableMediatorSubscriberBase
|
||||
if (_namePlateRoleColorsEnabled && partyMembers.Contains(handler.GameObject?.Address ?? nint.MaxValue))
|
||||
continue;
|
||||
var pair = visibleUsersDict[handler.GameObjectId];
|
||||
if (applyColors)
|
||||
{
|
||||
var colors = !pair.IsApplicationBlocked ? _configService.Current.NameColors : _configService.Current.BlockedNameColors;
|
||||
handler.NameParts.TextWrap = (
|
||||
BuildColorStartSeString(colors),
|
||||
@@ -96,6 +104,9 @@ public class GuiHookService : DisposableMediatorSubscriberBase
|
||||
);
|
||||
_isModified = true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
using MareSynchronos.API.Data.Comparer;
|
||||
using MareSynchronos.MareConfiguration;
|
||||
using MareSynchronos.Services.Mediator;
|
||||
using MareSynchronos.Services.ServerConfiguration;
|
||||
using MareSynchronos.WebAPI;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System.Collections.Concurrent;
|
||||
@@ -15,7 +14,6 @@ public class MareProfileManager : MediatorSubscriberBase
|
||||
private const string _nsfw = "Profile not displayed - NSFW";
|
||||
private readonly ApiController _apiController;
|
||||
private readonly MareConfigService _mareConfigService;
|
||||
private readonly ServerConfigurationManager _serverConfigurationManager;
|
||||
private readonly ConcurrentDictionary<UserData, MareProfileData> _mareProfiles = new(UserDataComparer.Instance);
|
||||
|
||||
private readonly MareProfileData _defaultProfileData = new(IsFlagged: false, IsNSFW: false, string.Empty, _noDescription);
|
||||
@@ -23,11 +21,10 @@ public class MareProfileManager : MediatorSubscriberBase
|
||||
private readonly MareProfileData _nsfwProfileData = new(IsFlagged: false, IsNSFW: false, string.Empty, _nsfw);
|
||||
|
||||
public MareProfileManager(ILogger<MareProfileManager> logger, MareConfigService mareConfigService,
|
||||
MareMediator mediator, ApiController apiController, ServerConfigurationManager serverConfigurationManager) : base(logger, mediator)
|
||||
MareMediator mediator, ApiController apiController) : base(logger, mediator)
|
||||
{
|
||||
_mareConfigService = mareConfigService;
|
||||
_apiController = apiController;
|
||||
_serverConfigurationManager = serverConfigurationManager;
|
||||
|
||||
Mediator.Subscribe<ClearProfileDataMessage>(this, (msg) =>
|
||||
{
|
||||
|
||||
@@ -7,7 +7,7 @@ using System.Text;
|
||||
|
||||
namespace MareSynchronos.Services.Mediator;
|
||||
|
||||
public sealed class MareMediator : IHostedService
|
||||
public sealed class MareMediator : IHostedService, IDisposable
|
||||
{
|
||||
private readonly Lock _addRemoveLock = new();
|
||||
private readonly ConcurrentDictionary<SubscriberAction, DateTime> _lastErrorTime = [];
|
||||
@@ -109,6 +109,26 @@ public sealed class MareMediator : IHostedService
|
||||
}
|
||||
}
|
||||
|
||||
private bool _disposed;
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
if (_disposed) return;
|
||||
_disposed = true;
|
||||
if (!_loopCts.IsCancellationRequested)
|
||||
{
|
||||
try
|
||||
{
|
||||
_loopCts.Cancel();
|
||||
}
|
||||
catch (ObjectDisposedException)
|
||||
{
|
||||
// already disposed, swallow
|
||||
}
|
||||
}
|
||||
_loopCts.Dispose();
|
||||
}
|
||||
|
||||
public void SubscribeKeyed<T>(IMediatorSubscriber subscriber, string key, Action<T> action) where T : MessageBase
|
||||
{
|
||||
lock (_addRemoveLock)
|
||||
|
||||
@@ -3,6 +3,7 @@ using MareSynchronos.API.Data;
|
||||
using MareSynchronos.API.Dto;
|
||||
using MareSynchronos.API.Dto.CharaData;
|
||||
using MareSynchronos.API.Dto.Group;
|
||||
using MareSynchronos.API.Dto.User;
|
||||
using MareSynchronos.MareConfiguration.Models;
|
||||
using MareSynchronos.PlayerData.Handlers;
|
||||
using MareSynchronos.PlayerData.Pairs;
|
||||
@@ -52,6 +53,7 @@ public record HaltScanMessage(string Source) : MessageBase;
|
||||
public record ResumeScanMessage(string Source) : MessageBase;
|
||||
public record NotificationMessage
|
||||
(string Title, string Message, NotificationType Type, TimeSpan? TimeShownOnScreen = null) : MessageBase;
|
||||
public record DualNotificationMessage(string Title, string Message, NotificationType Type, TimeSpan? ToastDuration = null) : MessageBase;
|
||||
public record CreateCacheForObjectMessage(GameObjectHandler ObjectToCreateFor) : MessageBase;
|
||||
public record ClearCacheForObjectMessage(GameObjectHandler ObjectToCreateFor) : MessageBase;
|
||||
public record CharacterDataCreatedMessage(CharacterData CharacterData) : SameThreadMessage;
|
||||
@@ -90,6 +92,7 @@ public record PenumbraDirectoryChangedMessage(string? ModDirectory) : MessageBas
|
||||
public record PenumbraRedrawCharacterMessage(ICharacter Character) : SameThreadMessage;
|
||||
public record UserChatMsgMessage(SignedChatMessage ChatMsg) : MessageBase;
|
||||
public record GroupChatMsgMessage(GroupDto GroupInfo, SignedChatMessage ChatMsg) : MessageBase;
|
||||
public record UserTypingStateMessage(TypingStateDto Typing) : MessageBase;
|
||||
public record RecalculatePerformanceMessage(string? UID) : MessageBase;
|
||||
public record NameplateRedrawMessage : MessageBase;
|
||||
public record HoldPairApplicationMessage(string UID, string Source) : KeyedMessage(UID);
|
||||
@@ -112,6 +115,15 @@ public record NearbyEntry(string Name, ushort WorldId, float Distance, bool IsMa
|
||||
public record DiscoveryListUpdated(List<NearbyEntry> Entries) : MessageBase;
|
||||
public record NearbyDetectionToggled(bool Enabled) : MessageBase;
|
||||
public record AllowPairRequestsToggled(bool Enabled) : MessageBase;
|
||||
public record SyncshellDiscoveryUpdated(List<SyncshellDiscoveryEntryDto> Entries) : MessageBase;
|
||||
public record SyncshellAutoDetectStateChanged(string Gid, bool Visible, bool PasswordTemporarilyDisabled) : MessageBase;
|
||||
public record ManualPairInviteMessage(string SourceUid, string SourceAlias, string TargetUid, string? DisplayName, string InviteId) : MessageBase;
|
||||
public record ApplyDefaultPairPermissionsMessage(UserPairDto Pair) : MessageBase;
|
||||
public record ApplyDefaultGroupPermissionsMessage(GroupPairFullInfoDto GroupPair) : MessageBase;
|
||||
public record ApplyDefaultsToAllSyncsMessage(string? Context = null, bool? Disabled = null) : MessageBase;
|
||||
public record PairSyncOverrideChanged(string Uid, bool? DisableSounds, bool? DisableAnimations, bool? DisableVfx) : MessageBase;
|
||||
public record GroupSyncOverrideChanged(string Gid, bool? DisableSounds, bool? DisableAnimations, bool? DisableVfx) : MessageBase;
|
||||
public record NotificationStateChanged(int TotalCount) : MessageBase;
|
||||
|
||||
public record PluginChangeMessage(string InternalName, Version Version, bool IsLoaded) : KeyedMessage(InternalName);
|
||||
#pragma warning restore S2094
|
||||
|
||||
144
MareSynchronos/Services/Notification/NotificationTracker.cs
Normal file
144
MareSynchronos/Services/Notification/NotificationTracker.cs
Normal file
@@ -0,0 +1,144 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using MareSynchronos.Services.Mediator;
|
||||
using MareSynchronos.MareConfiguration;
|
||||
using MareSynchronos.MareConfiguration.Configurations;
|
||||
using MareSynchronos.MareConfiguration.Models;
|
||||
|
||||
namespace MareSynchronos.Services.Notifications;
|
||||
|
||||
public enum NotificationCategory
|
||||
{
|
||||
AutoDetect,
|
||||
Syncshell,
|
||||
}
|
||||
|
||||
public sealed record NotificationEntry(NotificationCategory Category, string Id, string Title, string? Description, DateTime CreatedAt)
|
||||
{
|
||||
public static NotificationEntry AutoDetect(string uid, string displayName)
|
||||
=> new(NotificationCategory.AutoDetect, uid, displayName, "Nouvelle demande d'appairage via AutoDetect.", DateTime.UtcNow);
|
||||
|
||||
public static NotificationEntry SyncshellPublic(string gid, string aliasOrGid)
|
||||
=> new(NotificationCategory.Syncshell, gid, $"Syncshell publique: {aliasOrGid}", "La Syncshell est désormais visible via AutoDetect.", DateTime.UtcNow);
|
||||
|
||||
public static NotificationEntry SyncshellNotPublic(string gid, string aliasOrGid)
|
||||
=> new(NotificationCategory.Syncshell, gid, $"Syncshell non publique: {aliasOrGid}", "La Syncshell n'est plus visible via AutoDetect.", DateTime.UtcNow);
|
||||
}
|
||||
|
||||
public sealed class NotificationTracker
|
||||
{
|
||||
private const int MaxStored = 100;
|
||||
|
||||
private readonly MareMediator _mediator;
|
||||
private readonly NotificationsConfigService _configService;
|
||||
private readonly Dictionary<(NotificationCategory Category, string Id), NotificationEntry> _entries = new();
|
||||
private readonly object _lock = new();
|
||||
|
||||
public NotificationTracker(MareMediator mediator, NotificationsConfigService configService)
|
||||
{
|
||||
_mediator = mediator;
|
||||
_configService = configService;
|
||||
LoadPersisted();
|
||||
PublishState();
|
||||
}
|
||||
|
||||
public void Upsert(NotificationEntry entry)
|
||||
{
|
||||
lock (_lock)
|
||||
{
|
||||
_entries[(entry.Category, entry.Id)] = entry;
|
||||
TrimIfNecessary_NoLock();
|
||||
Persist_NoLock();
|
||||
}
|
||||
PublishState();
|
||||
}
|
||||
|
||||
public void Remove(NotificationCategory category, string id)
|
||||
{
|
||||
lock (_lock)
|
||||
{
|
||||
_entries.Remove((category, id));
|
||||
Persist_NoLock();
|
||||
}
|
||||
PublishState();
|
||||
}
|
||||
|
||||
public IReadOnlyList<NotificationEntry> GetEntries()
|
||||
{
|
||||
lock (_lock)
|
||||
{
|
||||
return _entries.Values
|
||||
.OrderBy(e => e.CreatedAt)
|
||||
.ToList();
|
||||
}
|
||||
}
|
||||
|
||||
public int Count
|
||||
{
|
||||
get
|
||||
{
|
||||
lock (_lock)
|
||||
{
|
||||
return _entries.Count;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void PublishState()
|
||||
{
|
||||
_mediator.Publish(new NotificationStateChanged(Count));
|
||||
}
|
||||
|
||||
private void LoadPersisted()
|
||||
{
|
||||
try
|
||||
{
|
||||
var list = _configService.Current.Notifications ?? new List<StoredNotification>();
|
||||
foreach (var s in list)
|
||||
{
|
||||
if (!Enum.TryParse<NotificationCategory>(s.Category, out var cat)) continue;
|
||||
var entry = new NotificationEntry(cat, s.Id, s.Title, s.Description, s.CreatedAtUtc);
|
||||
_entries[(entry.Category, entry.Id)] = entry;
|
||||
}
|
||||
TrimIfNecessary_NoLock();
|
||||
}
|
||||
catch
|
||||
{
|
||||
// ignore load errors, start empty
|
||||
}
|
||||
}
|
||||
|
||||
private void Persist_NoLock()
|
||||
{
|
||||
try
|
||||
{
|
||||
var stored = _entries.Values
|
||||
.OrderBy(e => e.CreatedAt)
|
||||
.Select(e => new StoredNotification
|
||||
{
|
||||
Category = e.Category.ToString(),
|
||||
Id = e.Id,
|
||||
Title = e.Title,
|
||||
Description = e.Description,
|
||||
CreatedAtUtc = e.CreatedAt
|
||||
})
|
||||
.ToList();
|
||||
_configService.Current.Notifications = stored;
|
||||
_configService.Save();
|
||||
}
|
||||
catch
|
||||
{
|
||||
// ignore persistence errors
|
||||
}
|
||||
}
|
||||
|
||||
private void TrimIfNecessary_NoLock()
|
||||
{
|
||||
if (_entries.Count <= MaxStored) return;
|
||||
foreach (var kv in _entries.Values.OrderByDescending(v => v.CreatedAt).Skip(MaxStored).ToList())
|
||||
{
|
||||
_entries.Remove((kv.Category, kv.Id));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,6 @@
|
||||
using Dalamud.Game.Text.SeStringHandling;
|
||||
using System;
|
||||
using System.Linq;
|
||||
using Dalamud.Game.Text.SeStringHandling;
|
||||
using Dalamud.Interface.ImGuiNotification;
|
||||
using Dalamud.Plugin.Services;
|
||||
using MareSynchronos.MareConfiguration;
|
||||
@@ -16,21 +18,29 @@ public class NotificationService : DisposableMediatorSubscriberBase, IHostedServ
|
||||
private readonly INotificationManager _notificationManager;
|
||||
private readonly IChatGui _chatGui;
|
||||
private readonly MareConfigService _configurationService;
|
||||
private readonly Services.Notifications.NotificationTracker _notificationTracker;
|
||||
private readonly PlayerData.Pairs.PairManager _pairManager;
|
||||
|
||||
public NotificationService(ILogger<NotificationService> logger, MareMediator mediator,
|
||||
DalamudUtilService dalamudUtilService,
|
||||
INotificationManager notificationManager,
|
||||
IChatGui chatGui, MareConfigService configurationService) : base(logger, mediator)
|
||||
IChatGui chatGui, MareConfigService configurationService,
|
||||
Services.Notifications.NotificationTracker notificationTracker,
|
||||
PlayerData.Pairs.PairManager pairManager) : base(logger, mediator)
|
||||
{
|
||||
_dalamudUtilService = dalamudUtilService;
|
||||
_notificationManager = notificationManager;
|
||||
_chatGui = chatGui;
|
||||
_configurationService = configurationService;
|
||||
_notificationTracker = notificationTracker;
|
||||
_pairManager = pairManager;
|
||||
}
|
||||
|
||||
public Task StartAsync(CancellationToken cancellationToken)
|
||||
{
|
||||
Mediator.Subscribe<NotificationMessage>(this, ShowNotification);
|
||||
Mediator.Subscribe<DualNotificationMessage>(this, ShowDualNotification);
|
||||
Mediator.Subscribe<Services.Mediator.SyncshellAutoDetectStateChanged>(this, OnSyncshellAutoDetectStateChanged);
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
@@ -81,41 +91,128 @@ public class NotificationService : DisposableMediatorSubscriberBase, IHostedServ
|
||||
|
||||
if (!_dalamudUtilService.IsLoggedIn) return;
|
||||
|
||||
switch (msg.Type)
|
||||
bool appendInstruction;
|
||||
bool forceChat = ShouldForceChat(msg, out appendInstruction);
|
||||
var effectiveMessage = forceChat && appendInstruction ? AppendAutoDetectInstruction(msg.Message) : msg.Message;
|
||||
var adjustedMsg = forceChat && appendInstruction ? msg with { Message = effectiveMessage } : msg;
|
||||
|
||||
switch (adjustedMsg.Type)
|
||||
{
|
||||
case NotificationType.Info:
|
||||
ShowNotificationLocationBased(msg, _configurationService.Current.InfoNotification);
|
||||
ShowNotificationLocationBased(adjustedMsg, _configurationService.Current.InfoNotification, forceChat);
|
||||
break;
|
||||
|
||||
case NotificationType.Warning:
|
||||
ShowNotificationLocationBased(msg, _configurationService.Current.WarningNotification);
|
||||
ShowNotificationLocationBased(adjustedMsg, _configurationService.Current.WarningNotification, forceChat);
|
||||
break;
|
||||
|
||||
case NotificationType.Error:
|
||||
ShowNotificationLocationBased(msg, _configurationService.Current.ErrorNotification);
|
||||
ShowNotificationLocationBased(adjustedMsg, _configurationService.Current.ErrorNotification, forceChat);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void ShowNotificationLocationBased(NotificationMessage msg, NotificationLocation location)
|
||||
private void ShowDualNotification(DualNotificationMessage message)
|
||||
{
|
||||
switch (location)
|
||||
if (!_dalamudUtilService.IsLoggedIn) return;
|
||||
|
||||
var baseMsg = new NotificationMessage(message.Title, message.Message, message.Type, message.ToastDuration);
|
||||
ShowToast(baseMsg);
|
||||
ShowChat(baseMsg);
|
||||
}
|
||||
|
||||
private void OnSyncshellAutoDetectStateChanged(SyncshellAutoDetectStateChanged msg)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (msg.Visible) return; // only handle transition to not visible
|
||||
|
||||
var gid = msg.Gid;
|
||||
// Try to resolve alias from PairManager snapshot; fallback to gid
|
||||
var alias = _pairManager.Groups.Values.FirstOrDefault(g => string.Equals(g.GID, gid, StringComparison.OrdinalIgnoreCase))?.GroupAliasOrGID ?? gid;
|
||||
|
||||
var title = $"Syncshell non publique: {alias}";
|
||||
var message = "La Syncshell n'est plus visible via AutoDetect.";
|
||||
|
||||
// Show toast + chat
|
||||
ShowDualNotification(new DualNotificationMessage(title, message, NotificationType.Info, TimeSpan.FromSeconds(4)));
|
||||
|
||||
// Persist into notification center
|
||||
_notificationTracker.Upsert(Services.Notifications.NotificationEntry.SyncshellNotPublic(gid, alias));
|
||||
}
|
||||
catch
|
||||
{
|
||||
// ignore failures
|
||||
}
|
||||
}
|
||||
|
||||
private static bool ShouldForceChat(NotificationMessage msg, out bool appendInstruction)
|
||||
{
|
||||
appendInstruction = false;
|
||||
|
||||
bool IsNearbyRequestText(string? text)
|
||||
{
|
||||
if (string.IsNullOrEmpty(text)) return false;
|
||||
return text.Contains("Nearby request", StringComparison.OrdinalIgnoreCase)
|
||||
|| text.Contains("Nearby Request", StringComparison.Ordinal);
|
||||
}
|
||||
|
||||
bool IsNearbyAcceptText(string? text)
|
||||
{
|
||||
if (string.IsNullOrEmpty(text)) return false;
|
||||
return text.Contains("Nearby Accept", StringComparison.OrdinalIgnoreCase);
|
||||
}
|
||||
|
||||
bool isAccept = IsNearbyAcceptText(msg.Title) || IsNearbyAcceptText(msg.Message);
|
||||
if (isAccept)
|
||||
return false;
|
||||
|
||||
bool isRequest = IsNearbyRequestText(msg.Title) || IsNearbyRequestText(msg.Message);
|
||||
if (isRequest)
|
||||
{
|
||||
appendInstruction = !IsRequestSentConfirmation(msg);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private static bool IsRequestSentConfirmation(NotificationMessage msg)
|
||||
{
|
||||
if (string.Equals(msg.Title, "Nearby request sent", StringComparison.OrdinalIgnoreCase))
|
||||
return true;
|
||||
|
||||
if (!string.IsNullOrEmpty(msg.Message) && msg.Message.Contains("The other user will receive a request notification.", StringComparison.OrdinalIgnoreCase))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private static string AppendAutoDetectInstruction(string? message)
|
||||
{
|
||||
const string suffix = " | Ouvrez /autodetect pour gérer l'invitation.";
|
||||
if (string.IsNullOrWhiteSpace(message))
|
||||
return suffix.TrimStart(' ', '|');
|
||||
|
||||
if (message.Contains("/autodetect", StringComparison.OrdinalIgnoreCase))
|
||||
return message;
|
||||
|
||||
return message.TrimEnd() + suffix;
|
||||
}
|
||||
|
||||
private void ShowNotificationLocationBased(NotificationMessage msg, NotificationLocation location, bool forceChat)
|
||||
{
|
||||
bool showToast = location is NotificationLocation.Toast or NotificationLocation.Both;
|
||||
bool showChat = forceChat || location is NotificationLocation.Chat or NotificationLocation.Both;
|
||||
|
||||
if (showToast)
|
||||
{
|
||||
case NotificationLocation.Toast:
|
||||
ShowToast(msg);
|
||||
break;
|
||||
}
|
||||
|
||||
case NotificationLocation.Chat:
|
||||
if (showChat)
|
||||
{
|
||||
ShowChat(msg);
|
||||
break;
|
||||
|
||||
case NotificationLocation.Both:
|
||||
ShowToast(msg);
|
||||
ShowChat(msg);
|
||||
break;
|
||||
|
||||
case NotificationLocation.Nowhere:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using MareSynchronos.API.Data;
|
||||
using System;
|
||||
using MareSynchronos.API.Data;
|
||||
using MareSynchronos.API.Data.Enum;
|
||||
using MareSynchronos.FileCache;
|
||||
using MareSynchronos.PlayerData.Pairs;
|
||||
@@ -14,7 +15,7 @@ public sealed class PairAnalyzer : DisposableMediatorSubscriberBase
|
||||
private readonly FileCacheManager _fileCacheManager;
|
||||
private readonly XivDataAnalyzer _xivDataAnalyzer;
|
||||
private CancellationTokenSource? _analysisCts;
|
||||
private CancellationTokenSource _baseAnalysisCts = new();
|
||||
private CancellationTokenSource? _baseAnalysisCts = new();
|
||||
private string _lastDataHash = string.Empty;
|
||||
|
||||
public PairAnalyzer(ILogger<PairAnalyzer> logger, Pair pair, MareMediator mediator, FileCacheManager fileCacheManager, XivDataAnalyzer modelAnalyzer)
|
||||
@@ -24,8 +25,8 @@ public sealed class PairAnalyzer : DisposableMediatorSubscriberBase
|
||||
#if DEBUG
|
||||
Mediator.SubscribeKeyed<PairDataAppliedMessage>(this, pair.UserData.UID, (msg) =>
|
||||
{
|
||||
_baseAnalysisCts = _baseAnalysisCts.CancelRecreate();
|
||||
var token = _baseAnalysisCts.Token;
|
||||
var tokenSource = EnsureFreshCts(ref _baseAnalysisCts);
|
||||
var token = tokenSource.Token;
|
||||
if (msg.CharacterData != null)
|
||||
{
|
||||
_ = BaseAnalysis(msg.CharacterData, token);
|
||||
@@ -56,17 +57,15 @@ public sealed class PairAnalyzer : DisposableMediatorSubscriberBase
|
||||
|
||||
public void CancelAnalyze()
|
||||
{
|
||||
_analysisCts?.CancelDispose();
|
||||
_analysisCts = null;
|
||||
CancelAndDispose(ref _analysisCts);
|
||||
}
|
||||
|
||||
public async Task ComputeAnalysis(bool print = true, bool recalculate = false)
|
||||
{
|
||||
Logger.LogDebug("=== Calculating Character Analysis ===");
|
||||
|
||||
_analysisCts = _analysisCts?.CancelRecreate() ?? new();
|
||||
|
||||
var cancelToken = _analysisCts.Token;
|
||||
var analysisCts = EnsureFreshCts(ref _analysisCts);
|
||||
var cancelToken = analysisCts.Token;
|
||||
|
||||
var allFiles = LastAnalysis.SelectMany(v => v.Value.Select(d => d.Value)).ToList();
|
||||
if (allFiles.Exists(c => !c.IsComputed || recalculate))
|
||||
@@ -102,8 +101,7 @@ public sealed class PairAnalyzer : DisposableMediatorSubscriberBase
|
||||
LastPlayerName = Pair.PlayerName ?? string.Empty;
|
||||
Mediator.Publish(new PairDataAnalyzedMessage(Pair.UserData.UID));
|
||||
|
||||
_analysisCts.CancelDispose();
|
||||
_analysisCts = null;
|
||||
CancelAndDispose(ref _analysisCts);
|
||||
|
||||
if (print) PrintAnalysis();
|
||||
}
|
||||
@@ -114,8 +112,8 @@ public sealed class PairAnalyzer : DisposableMediatorSubscriberBase
|
||||
|
||||
if (!disposing) return;
|
||||
|
||||
_analysisCts?.CancelDispose();
|
||||
_baseAnalysisCts.CancelDispose();
|
||||
CancelAndDispose(ref _analysisCts);
|
||||
CancelAndDispose(ref _baseAnalysisCts);
|
||||
}
|
||||
|
||||
private async Task BaseAnalysis(CharacterData charaData, CancellationToken token)
|
||||
@@ -211,4 +209,26 @@ public sealed class PairAnalyzer : DisposableMediatorSubscriberBase
|
||||
UiSharedService.ByteToString(LastAnalysis.Values.Sum(c => c.Values.Sum(v => v.OriginalSize))),
|
||||
UiSharedService.ByteToString(LastAnalysis.Values.Sum(c => c.Values.Sum(v => v.CompressedSize))));
|
||||
}
|
||||
|
||||
private static CancellationTokenSource EnsureFreshCts(ref CancellationTokenSource? cts)
|
||||
{
|
||||
CancelAndDispose(ref cts);
|
||||
cts = new CancellationTokenSource();
|
||||
return cts;
|
||||
}
|
||||
|
||||
private static void CancelAndDispose(ref CancellationTokenSource? cts)
|
||||
{
|
||||
if (cts == null) return;
|
||||
try
|
||||
{
|
||||
cts.Cancel();
|
||||
}
|
||||
catch (ObjectDisposedException)
|
||||
{
|
||||
}
|
||||
|
||||
cts.Dispose();
|
||||
cts = null;
|
||||
}
|
||||
}
|
||||
77
MareSynchronos/Services/PartyListTypingService.cs
Normal file
77
MareSynchronos/Services/PartyListTypingService.cs
Normal file
@@ -0,0 +1,77 @@
|
||||
using MareSynchronos.MareConfiguration;
|
||||
using System.Collections.Generic;
|
||||
using MareSynchronos.PlayerData.Pairs;
|
||||
using System;
|
||||
using System.Linq;
|
||||
using Dalamud.Game.Text;
|
||||
using Dalamud.Game.Text.SeStringHandling;
|
||||
using Dalamud.Game.Text.SeStringHandling.Payloads;
|
||||
using Dalamud.Plugin.Services;
|
||||
using MareSynchronos.API.Dto.User;
|
||||
using MareSynchronos.Services.Mediator;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace MareSynchronos.Services;
|
||||
|
||||
public class PartyListTypingService : DisposableMediatorSubscriberBase
|
||||
{
|
||||
private readonly ILogger<PartyListTypingService> _logger;
|
||||
private readonly IPartyList _partyList;
|
||||
private readonly MareConfigService _configService;
|
||||
private readonly PairManager _pairManager;
|
||||
private readonly TypingIndicatorStateService _typingStateService;
|
||||
private static readonly TimeSpan TypingDisplayTime = TimeSpan.FromSeconds(2);
|
||||
private static readonly TimeSpan TypingDisplayFade = TypingDisplayTime;
|
||||
|
||||
public PartyListTypingService(ILogger<PartyListTypingService> logger,
|
||||
MareMediator mediator,
|
||||
IPartyList partyList,
|
||||
PairManager pairManager,
|
||||
MareConfigService configService,
|
||||
TypingIndicatorStateService typingStateService)
|
||||
: base(logger, mediator)
|
||||
{
|
||||
_logger = logger;
|
||||
_partyList = partyList;
|
||||
_pairManager = pairManager;
|
||||
_configService = configService;
|
||||
_typingStateService = typingStateService;
|
||||
|
||||
}
|
||||
|
||||
public void Draw()
|
||||
{
|
||||
if (!_configService.Current.TypingIndicatorEnabled) return;
|
||||
if (!_configService.Current.TypingIndicatorShowOnPartyList) return;
|
||||
var visibleByAlias = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);
|
||||
try
|
||||
{
|
||||
var visibleUsers = _pairManager.GetVisibleUsers();
|
||||
foreach (var u in visibleUsers)
|
||||
{
|
||||
var alias = string.IsNullOrEmpty(u.AliasOrUID) ? u.UID : u.AliasOrUID;
|
||||
if (!visibleByAlias.ContainsKey(alias)) visibleByAlias[alias] = u.UID;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogDebug(ex, "PartyListTypingService: failed to get visible users");
|
||||
}
|
||||
|
||||
var activeTypers = _typingStateService.GetActiveTypers(TypingDisplayTime);
|
||||
var now = DateTime.UtcNow;
|
||||
|
||||
foreach (var member in _partyList)
|
||||
{
|
||||
if (string.IsNullOrEmpty(member.Name?.TextValue)) continue;
|
||||
|
||||
var displayName = member.Name.TextValue;
|
||||
if (visibleByAlias.TryGetValue(displayName, out var uid)
|
||||
&& activeTypers.TryGetValue(uid, out var entry)
|
||||
&& (now - entry.LastUpdate) <= TypingDisplayFade)
|
||||
{
|
||||
_logger.LogDebug("PartyListTypingService: bubble would be shown for {name}", displayName);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -23,7 +23,6 @@ public class PlayerPerformanceService : DisposableMediatorSubscriberBase
|
||||
private readonly MareMediator _mediator;
|
||||
private readonly ServerConfigurationManager _serverConfigurationManager;
|
||||
private readonly PlayerPerformanceConfigService _playerPerformanceConfigService;
|
||||
private readonly Dictionary<string, bool> _warnedForPlayers = new(StringComparer.Ordinal);
|
||||
|
||||
public PlayerPerformanceService(ILogger<PlayerPerformanceService> logger, MareMediator mediator,
|
||||
ServerConfigurationManager serverConfigurationManager,
|
||||
|
||||
358
MareSynchronos/Services/SyncDefaultsService.cs
Normal file
358
MareSynchronos/Services/SyncDefaultsService.cs
Normal file
@@ -0,0 +1,358 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using MareSynchronos.API.Data;
|
||||
using MareSynchronos.API.Data.Enum;
|
||||
using MareSynchronos.API.Data.Extensions;
|
||||
using MareSynchronos.API.Dto.Group;
|
||||
using MareSynchronos.API.Dto.User;
|
||||
using MareSynchronos.MareConfiguration;
|
||||
using MareSynchronos.MareConfiguration.Configurations;
|
||||
using MareSynchronos.MareConfiguration.Models;
|
||||
using MareSynchronos.PlayerData.Pairs;
|
||||
using MareSynchronos.Services.Mediator;
|
||||
using MareSynchronos.WebAPI;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using NotificationType = MareSynchronos.MareConfiguration.Models.NotificationType;
|
||||
|
||||
namespace MareSynchronos.Services;
|
||||
|
||||
public sealed class SyncDefaultsService : DisposableMediatorSubscriberBase
|
||||
{
|
||||
private readonly ApiController _apiController;
|
||||
private readonly MareConfigService _configService;
|
||||
private readonly PairManager _pairManager;
|
||||
|
||||
public SyncDefaultsService(ILogger<SyncDefaultsService> logger, MareMediator mediator,
|
||||
MareConfigService configService, ApiController apiController, PairManager pairManager) : base(logger, mediator)
|
||||
{
|
||||
_configService = configService;
|
||||
_apiController = apiController;
|
||||
_pairManager = pairManager;
|
||||
|
||||
Mediator.Subscribe<ApplyDefaultPairPermissionsMessage>(this, OnApplyPairDefaults);
|
||||
Mediator.Subscribe<ApplyDefaultGroupPermissionsMessage>(this, OnApplyGroupDefaults);
|
||||
Mediator.Subscribe<ApplyDefaultsToAllSyncsMessage>(this, msg => ApplyDefaultsToAll(msg));
|
||||
Mediator.Subscribe<PairSyncOverrideChanged>(this, OnPairOverrideChanged);
|
||||
Mediator.Subscribe<GroupSyncOverrideChanged>(this, OnGroupOverrideChanged);
|
||||
}
|
||||
|
||||
private void OnApplyPairDefaults(ApplyDefaultPairPermissionsMessage message)
|
||||
{
|
||||
var config = _configService.Current;
|
||||
var permissions = message.Pair.OwnPermissions;
|
||||
var overrides = TryGetPairOverride(message.Pair.User.UID);
|
||||
if (!ApplyDefaults(ref permissions, config, overrides))
|
||||
return;
|
||||
|
||||
_ = _apiController.UserSetPairPermissions(new UserPermissionsDto(message.Pair.User, permissions));
|
||||
}
|
||||
|
||||
private void OnApplyGroupDefaults(ApplyDefaultGroupPermissionsMessage message)
|
||||
{
|
||||
if (!string.Equals(message.GroupPair.User.UID, _apiController.UID, StringComparison.Ordinal))
|
||||
return;
|
||||
|
||||
var config = _configService.Current;
|
||||
var permissions = message.GroupPair.GroupUserPermissions;
|
||||
var overrides = TryGetGroupOverride(message.GroupPair.Group.GID);
|
||||
if (!ApplyDefaults(ref permissions, config, overrides))
|
||||
return;
|
||||
|
||||
_ = _apiController.GroupChangeIndividualPermissionState(new GroupPairUserPermissionDto(message.GroupPair.Group, message.GroupPair.User, permissions));
|
||||
}
|
||||
|
||||
private async Task ApplyDefaultsToAllAsync(ApplyDefaultsToAllSyncsMessage message)
|
||||
{
|
||||
try
|
||||
{
|
||||
var config = _configService.Current;
|
||||
var tasks = new List<Task>();
|
||||
int updatedPairs = 0;
|
||||
int updatedGroups = 0;
|
||||
|
||||
foreach (var pair in _pairManager.DirectPairs.Where(p => p.UserPair != null).ToList())
|
||||
{
|
||||
var permissions = pair.UserPair!.OwnPermissions;
|
||||
var overrides = TryGetPairOverride(pair.UserData.UID);
|
||||
if (!ApplyDefaults(ref permissions, config, overrides))
|
||||
continue;
|
||||
|
||||
updatedPairs++;
|
||||
tasks.Add(_apiController.UserSetPairPermissions(new UserPermissionsDto(pair.UserData, permissions)));
|
||||
}
|
||||
|
||||
var selfUser = new UserData(_apiController.UID);
|
||||
foreach (var groupInfo in _pairManager.Groups.Values.ToList())
|
||||
{
|
||||
var permissions = groupInfo.GroupUserPermissions;
|
||||
var overrides = TryGetGroupOverride(groupInfo.Group.GID);
|
||||
if (!ApplyDefaults(ref permissions, config, overrides))
|
||||
continue;
|
||||
|
||||
updatedGroups++;
|
||||
tasks.Add(_apiController.GroupChangeIndividualPermissionState(new GroupPairUserPermissionDto(groupInfo.Group, selfUser, permissions)));
|
||||
}
|
||||
|
||||
if (tasks.Count > 0)
|
||||
{
|
||||
try
|
||||
{
|
||||
await Task.WhenAll(tasks).ConfigureAwait(false);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logger.LogWarning(ex, "Failed applying default sync settings to all pairs/groups");
|
||||
}
|
||||
}
|
||||
|
||||
var summary = BuildSummaryMessage(updatedPairs, updatedGroups);
|
||||
var primary = BuildPrimaryMessage(message);
|
||||
var combined = string.IsNullOrEmpty(primary) ? summary : string.Concat(primary, ' ', summary);
|
||||
Mediator.Publish(new DualNotificationMessage("Préférences appliquées", combined, NotificationType.Info));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logger.LogError(ex, "Unexpected error while applying default sync settings to all pairs/groups");
|
||||
Mediator.Publish(new DualNotificationMessage("Préférences appliquées", "Une erreur est survenue lors de l'application des paramètres par défaut.", NotificationType.Error));
|
||||
}
|
||||
}
|
||||
|
||||
private void ApplyDefaultsToAll(ApplyDefaultsToAllSyncsMessage message) => _ = ApplyDefaultsToAllAsync(message);
|
||||
|
||||
private static string? BuildPrimaryMessage(ApplyDefaultsToAllSyncsMessage message)
|
||||
{
|
||||
if (string.IsNullOrEmpty(message.Context) || message.Disabled == null)
|
||||
return null;
|
||||
|
||||
var state = message.Disabled.Value ? "désactivée" : "activée";
|
||||
return $"Synchronisation {message.Context} par défaut {state}.";
|
||||
}
|
||||
|
||||
private static string BuildSummaryMessage(int pairs, int groups)
|
||||
{
|
||||
if (pairs == 0 && groups == 0)
|
||||
return "Aucun pair ou syncshell n'avait besoin d'être modifié.";
|
||||
|
||||
if (pairs > 0 && groups > 0)
|
||||
return $"Mise à jour de {pairs} pair(s) et {groups} syncshell(s).";
|
||||
|
||||
if (pairs > 0)
|
||||
return $"Mise à jour de {pairs} pair(s).";
|
||||
|
||||
return $"Mise à jour de {groups} syncshell(s).";
|
||||
}
|
||||
|
||||
private void OnPairOverrideChanged(PairSyncOverrideChanged message)
|
||||
{
|
||||
var overrides = _configService.Current.PairSyncOverrides ??= new(StringComparer.Ordinal);
|
||||
var entry = overrides.TryGetValue(message.Uid, out var existing) ? existing : new SyncOverrideEntry();
|
||||
bool changed = false;
|
||||
|
||||
if (message.DisableSounds.HasValue)
|
||||
{
|
||||
var val = message.DisableSounds.Value;
|
||||
var defaultVal = _configService.Current.DefaultDisableSounds;
|
||||
var newValue = val == defaultVal ? (bool?)null : val;
|
||||
if (entry.DisableSounds != newValue)
|
||||
{
|
||||
entry.DisableSounds = newValue;
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (message.DisableAnimations.HasValue)
|
||||
{
|
||||
var val = message.DisableAnimations.Value;
|
||||
var defaultVal = _configService.Current.DefaultDisableAnimations;
|
||||
var newValue = val == defaultVal ? (bool?)null : val;
|
||||
if (entry.DisableAnimations != newValue)
|
||||
{
|
||||
entry.DisableAnimations = newValue;
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (message.DisableVfx.HasValue)
|
||||
{
|
||||
var val = message.DisableVfx.Value;
|
||||
var defaultVal = _configService.Current.DefaultDisableVfx;
|
||||
var newValue = val == defaultVal ? (bool?)null : val;
|
||||
if (entry.DisableVfx != newValue)
|
||||
{
|
||||
entry.DisableVfx = newValue;
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!changed) return;
|
||||
|
||||
if (entry.IsEmpty)
|
||||
overrides.Remove(message.Uid);
|
||||
else
|
||||
overrides[message.Uid] = entry;
|
||||
|
||||
_configService.Save();
|
||||
}
|
||||
|
||||
private void OnGroupOverrideChanged(GroupSyncOverrideChanged message)
|
||||
{
|
||||
var overrides = _configService.Current.GroupSyncOverrides ??= new(StringComparer.Ordinal);
|
||||
var entry = overrides.TryGetValue(message.Gid, out var existing) ? existing : new SyncOverrideEntry();
|
||||
bool changed = false;
|
||||
|
||||
if (message.DisableSounds.HasValue)
|
||||
{
|
||||
var val = message.DisableSounds.Value;
|
||||
var defaultVal = _configService.Current.DefaultDisableSounds;
|
||||
var newValue = val == defaultVal ? (bool?)null : val;
|
||||
if (entry.DisableSounds != newValue)
|
||||
{
|
||||
entry.DisableSounds = newValue;
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (message.DisableAnimations.HasValue)
|
||||
{
|
||||
var val = message.DisableAnimations.Value;
|
||||
var defaultVal = _configService.Current.DefaultDisableAnimations;
|
||||
var newValue = val == defaultVal ? (bool?)null : val;
|
||||
if (entry.DisableAnimations != newValue)
|
||||
{
|
||||
entry.DisableAnimations = newValue;
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (message.DisableVfx.HasValue)
|
||||
{
|
||||
var val = message.DisableVfx.Value;
|
||||
var defaultVal = _configService.Current.DefaultDisableVfx;
|
||||
var newValue = val == defaultVal ? (bool?)null : val;
|
||||
if (entry.DisableVfx != newValue)
|
||||
{
|
||||
entry.DisableVfx = newValue;
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!changed) return;
|
||||
|
||||
if (entry.IsEmpty)
|
||||
overrides.Remove(message.Gid);
|
||||
else
|
||||
overrides[message.Gid] = entry;
|
||||
|
||||
_configService.Save();
|
||||
}
|
||||
|
||||
private SyncOverrideEntry? TryGetPairOverride(string uid)
|
||||
{
|
||||
var overrides = _configService.Current.PairSyncOverrides;
|
||||
return overrides != null && overrides.TryGetValue(uid, out var entry) ? entry : null;
|
||||
}
|
||||
|
||||
private SyncOverrideEntry? TryGetGroupOverride(string gid)
|
||||
{
|
||||
var overrides = _configService.Current.GroupSyncOverrides;
|
||||
return overrides != null && overrides.TryGetValue(gid, out var entry) ? entry : null;
|
||||
}
|
||||
|
||||
private static bool ApplyDefaults(ref UserPermissions permissions, MareConfig config, SyncOverrideEntry? overrides)
|
||||
{
|
||||
bool changed = false;
|
||||
if (overrides?.DisableSounds is bool overrideSounds)
|
||||
{
|
||||
if (permissions.IsDisableSounds() != overrideSounds)
|
||||
{
|
||||
permissions.SetDisableSounds(overrideSounds);
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
else if (permissions.IsDisableSounds() != config.DefaultDisableSounds)
|
||||
{
|
||||
permissions.SetDisableSounds(config.DefaultDisableSounds);
|
||||
changed = true;
|
||||
}
|
||||
|
||||
if (overrides?.DisableAnimations is bool overrideAnims)
|
||||
{
|
||||
if (permissions.IsDisableAnimations() != overrideAnims)
|
||||
{
|
||||
permissions.SetDisableAnimations(overrideAnims);
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
else if (permissions.IsDisableAnimations() != config.DefaultDisableAnimations)
|
||||
{
|
||||
permissions.SetDisableAnimations(config.DefaultDisableAnimations);
|
||||
changed = true;
|
||||
}
|
||||
|
||||
if (overrides?.DisableVfx is bool overrideVfx)
|
||||
{
|
||||
if (permissions.IsDisableVFX() != overrideVfx)
|
||||
{
|
||||
permissions.SetDisableVFX(overrideVfx);
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
else if (permissions.IsDisableVFX() != config.DefaultDisableVfx)
|
||||
{
|
||||
permissions.SetDisableVFX(config.DefaultDisableVfx);
|
||||
changed = true;
|
||||
}
|
||||
|
||||
return changed;
|
||||
}
|
||||
|
||||
private static bool ApplyDefaults(ref GroupUserPermissions permissions, MareConfig config, SyncOverrideEntry? overrides)
|
||||
{
|
||||
bool changed = false;
|
||||
if (overrides?.DisableSounds is bool overrideSounds)
|
||||
{
|
||||
if (permissions.IsDisableSounds() != overrideSounds)
|
||||
{
|
||||
permissions.SetDisableSounds(overrideSounds);
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
else if (permissions.IsDisableSounds() != config.DefaultDisableSounds)
|
||||
{
|
||||
permissions.SetDisableSounds(config.DefaultDisableSounds);
|
||||
changed = true;
|
||||
}
|
||||
|
||||
if (overrides?.DisableAnimations is bool overrideAnims)
|
||||
{
|
||||
if (permissions.IsDisableAnimations() != overrideAnims)
|
||||
{
|
||||
permissions.SetDisableAnimations(overrideAnims);
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
else if (permissions.IsDisableAnimations() != config.DefaultDisableAnimations)
|
||||
{
|
||||
permissions.SetDisableAnimations(config.DefaultDisableAnimations);
|
||||
changed = true;
|
||||
}
|
||||
|
||||
if (overrides?.DisableVfx is bool overrideVfx)
|
||||
{
|
||||
if (permissions.IsDisableVFX() != overrideVfx)
|
||||
{
|
||||
permissions.SetDisableVFX(overrideVfx);
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
else if (permissions.IsDisableVFX() != config.DefaultDisableVfx)
|
||||
{
|
||||
permissions.SetDisableVFX(config.DefaultDisableVfx);
|
||||
changed = true;
|
||||
}
|
||||
|
||||
return changed;
|
||||
}
|
||||
}
|
||||
131
MareSynchronos/Services/TypingIndicatorStateService.cs
Normal file
131
MareSynchronos/Services/TypingIndicatorStateService.cs
Normal file
@@ -0,0 +1,131 @@
|
||||
using System;
|
||||
using System.Collections.Concurrent;
|
||||
using System.Linq;
|
||||
using MareSynchronos.Services.Mediator;
|
||||
using MareSynchronos.WebAPI;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using MareSynchronos.API.Data;
|
||||
using MareSynchronos.MareConfiguration;
|
||||
|
||||
namespace MareSynchronos.Services;
|
||||
|
||||
public sealed class TypingIndicatorStateService : IMediatorSubscriber, IDisposable
|
||||
{
|
||||
private sealed record TypingEntry(UserData User, DateTime FirstSeen, DateTime LastUpdate, MareSynchronos.API.Data.Enum.TypingScope Scope);
|
||||
|
||||
private readonly ConcurrentDictionary<string, TypingEntry> _typingUsers = new(StringComparer.Ordinal);
|
||||
private readonly ApiController _apiController;
|
||||
private readonly ILogger<TypingIndicatorStateService> _logger;
|
||||
private readonly MareConfigService _configService;
|
||||
private DateTime _selfTypingLast = DateTime.MinValue;
|
||||
private DateTime _selfTypingStart = DateTime.MinValue;
|
||||
private bool _selfTypingActive;
|
||||
|
||||
public TypingIndicatorStateService(ILogger<TypingIndicatorStateService> logger, MareMediator mediator, ApiController apiController, MareConfigService configService)
|
||||
{
|
||||
_logger = logger;
|
||||
_apiController = apiController;
|
||||
_configService = configService;
|
||||
Mediator = mediator;
|
||||
|
||||
mediator.Subscribe<UserTypingStateMessage>(this, OnTypingState);
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
Mediator.UnsubscribeAll(this);
|
||||
}
|
||||
|
||||
public MareMediator Mediator { get; }
|
||||
|
||||
public void SetSelfTypingLocal(bool isTyping)
|
||||
{
|
||||
if (isTyping)
|
||||
{
|
||||
if (!_selfTypingActive)
|
||||
_selfTypingStart = DateTime.UtcNow;
|
||||
_selfTypingLast = DateTime.UtcNow;
|
||||
}
|
||||
else
|
||||
{
|
||||
_selfTypingStart = DateTime.MinValue;
|
||||
}
|
||||
|
||||
_selfTypingActive = isTyping;
|
||||
}
|
||||
|
||||
public void ClearAll()
|
||||
{
|
||||
_typingUsers.Clear();
|
||||
_selfTypingActive = false;
|
||||
_selfTypingStart = DateTime.MinValue;
|
||||
_selfTypingLast = DateTime.MinValue;
|
||||
_logger.LogDebug("TypingIndicatorStateService: cleared all typing state");
|
||||
}
|
||||
|
||||
private void OnTypingState(UserTypingStateMessage msg)
|
||||
{
|
||||
if (!_configService.Current.TypingIndicatorEnabled)
|
||||
return;
|
||||
var uid = msg.Typing.User.UID;
|
||||
var now = DateTime.UtcNow;
|
||||
|
||||
if (string.Equals(uid, _apiController.UID, StringComparison.Ordinal))
|
||||
{
|
||||
_selfTypingActive = msg.Typing.IsTyping;
|
||||
if (_selfTypingActive)
|
||||
{
|
||||
if (_selfTypingStart == DateTime.MinValue)
|
||||
_selfTypingStart = now;
|
||||
_selfTypingLast = now;
|
||||
}
|
||||
else
|
||||
{
|
||||
_selfTypingStart = DateTime.MinValue;
|
||||
}
|
||||
_logger.LogInformation("Typing state self -> {state}", _selfTypingActive);
|
||||
}
|
||||
else if (msg.Typing.IsTyping)
|
||||
{
|
||||
_typingUsers.AddOrUpdate(uid,
|
||||
_ => new TypingEntry(msg.Typing.User, now, now, msg.Typing.Scope),
|
||||
(_, existing) => new TypingEntry(msg.Typing.User, existing.FirstSeen, now, msg.Typing.Scope));
|
||||
}
|
||||
else
|
||||
{
|
||||
_typingUsers.TryRemove(uid, out _);
|
||||
}
|
||||
}
|
||||
|
||||
public bool TryGetSelfTyping(TimeSpan maxAge, out DateTime startTyping, out DateTime lastTyping)
|
||||
{
|
||||
startTyping = _selfTypingStart;
|
||||
lastTyping = _selfTypingLast;
|
||||
if (!_selfTypingActive)
|
||||
return false;
|
||||
|
||||
var now = DateTime.UtcNow;
|
||||
if ((now - _selfTypingLast) >= maxAge)
|
||||
{
|
||||
_selfTypingActive = false;
|
||||
_selfTypingStart = DateTime.MinValue;
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public IReadOnlyDictionary<string, (UserData User, DateTime FirstSeen, DateTime LastUpdate, MareSynchronos.API.Data.Enum.TypingScope Scope)> GetActiveTypers(TimeSpan maxAge)
|
||||
{
|
||||
var now = DateTime.UtcNow;
|
||||
foreach (var kvp in _typingUsers.ToArray())
|
||||
{
|
||||
if ((now - kvp.Value.LastUpdate) >= maxAge)
|
||||
{
|
||||
_typingUsers.TryRemove(kvp.Key, out _);
|
||||
}
|
||||
}
|
||||
|
||||
return _typingUsers.ToDictionary(k => k.Key, v => (v.Value.User, v.Value.FirstSeen, v.Value.LastUpdate, v.Value.Scope), StringComparer.Ordinal);
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,9 @@
|
||||
using MareSynchronos.API.Dto.Group;
|
||||
using MareSynchronos.PlayerData.Pairs;
|
||||
using MareSynchronos.Services.AutoDetect;
|
||||
using MareSynchronos.Services.Mediator;
|
||||
using MareSynchronos.Services.ServerConfiguration;
|
||||
using MareSynchronos.Services.Notifications;
|
||||
using MareSynchronos.UI;
|
||||
using MareSynchronos.UI.Components.Popup;
|
||||
using MareSynchronos.WebAPI;
|
||||
@@ -19,31 +21,35 @@ public class UiFactory
|
||||
private readonly ServerConfigurationManager _serverConfigManager;
|
||||
private readonly MareProfileManager _mareProfileManager;
|
||||
private readonly PerformanceCollectorService _performanceCollectorService;
|
||||
private readonly SyncshellDiscoveryService _syncshellDiscoveryService;
|
||||
private readonly NotificationTracker _notificationTracker;
|
||||
|
||||
public UiFactory(ILoggerFactory loggerFactory, MareMediator mareMediator, ApiController apiController,
|
||||
UiSharedService uiSharedService, PairManager pairManager, ServerConfigurationManager serverConfigManager,
|
||||
MareProfileManager mareProfileManager, PerformanceCollectorService performanceCollectorService)
|
||||
UiSharedService uiSharedService, PairManager pairManager, SyncshellDiscoveryService syncshellDiscoveryService, ServerConfigurationManager serverConfigManager,
|
||||
MareProfileManager mareProfileManager, PerformanceCollectorService performanceCollectorService, NotificationTracker notificationTracker)
|
||||
{
|
||||
_loggerFactory = loggerFactory;
|
||||
_mareMediator = mareMediator;
|
||||
_apiController = apiController;
|
||||
_uiSharedService = uiSharedService;
|
||||
_pairManager = pairManager;
|
||||
_syncshellDiscoveryService = syncshellDiscoveryService;
|
||||
_serverConfigManager = serverConfigManager;
|
||||
_mareProfileManager = mareProfileManager;
|
||||
_performanceCollectorService = performanceCollectorService;
|
||||
_notificationTracker = notificationTracker;
|
||||
}
|
||||
|
||||
public SyncshellAdminUI CreateSyncshellAdminUi(GroupFullInfoDto dto)
|
||||
{
|
||||
return new SyncshellAdminUI(_loggerFactory.CreateLogger<SyncshellAdminUI>(), _mareMediator,
|
||||
_apiController, _uiSharedService, _pairManager, dto, _performanceCollectorService);
|
||||
_apiController, _uiSharedService, _pairManager, _syncshellDiscoveryService, dto, _performanceCollectorService, _notificationTracker);
|
||||
}
|
||||
|
||||
public StandaloneProfileUi CreateStandaloneProfileUi(Pair pair)
|
||||
{
|
||||
return new StandaloneProfileUi(_loggerFactory.CreateLogger<StandaloneProfileUi>(), _mareMediator,
|
||||
_uiSharedService, _serverConfigManager, _mareProfileManager, _pairManager, pair, _performanceCollectorService);
|
||||
_uiSharedService, _serverConfigManager, _mareProfileManager, pair, _performanceCollectorService);
|
||||
}
|
||||
|
||||
public PermissionWindowUI CreatePermissionPopupUi(Pair pair)
|
||||
|
||||
@@ -1,18 +1,23 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Dalamud.Bindings.ImGui;
|
||||
using Dalamud.Interface.Colors;
|
||||
using Dalamud.Game.ClientState.Objects.SubKinds;
|
||||
using Dalamud.Interface.Utility;
|
||||
using Dalamud.Interface.Utility.Raii;
|
||||
using Dalamud.Plugin.Services;
|
||||
using MareSynchronos.Localization;
|
||||
using MareSynchronos.API.Dto.Group;
|
||||
using MareSynchronos.MareConfiguration;
|
||||
using MareSynchronos.Services;
|
||||
using MareSynchronos.PlayerData.Pairs;
|
||||
using MareSynchronos.Services.Mediator;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System.Numerics;
|
||||
using System.Globalization;
|
||||
using System.Text;
|
||||
using MareSynchronos.Services;
|
||||
using MareSynchronos.Services.AutoDetect;
|
||||
using NotificationType = MareSynchronos.MareConfiguration.Models.NotificationType;
|
||||
|
||||
namespace MareSynchronos.UI;
|
||||
|
||||
@@ -20,26 +25,35 @@ public class AutoDetectUi : WindowMediatorSubscriberBase
|
||||
{
|
||||
private readonly MareConfigService _configService;
|
||||
private readonly DalamudUtilService _dalamud;
|
||||
private readonly IObjectTable _objectTable;
|
||||
private readonly Services.AutoDetect.AutoDetectRequestService _requestService;
|
||||
private readonly AutoDetectRequestService _requestService;
|
||||
private readonly NearbyDiscoveryService _discoveryService;
|
||||
private readonly NearbyPendingService _pendingService;
|
||||
private readonly PairManager _pairManager;
|
||||
private List<Services.Mediator.NearbyEntry> _entries = new();
|
||||
|
||||
private static string L(string key, string fallback, params object[] args)
|
||||
=> LocalizationService.Instance?.GetString(key, fallback, args)
|
||||
?? string.Format(CultureInfo.CurrentCulture, fallback, args);
|
||||
private List<Services.Mediator.NearbyEntry> _entries;
|
||||
private readonly HashSet<string> _acceptInFlight = new(StringComparer.Ordinal);
|
||||
private readonly SyncshellDiscoveryService _syncshellDiscoveryService;
|
||||
private List<SyncshellDiscoveryEntryDto> _syncshellEntries = [];
|
||||
private bool _syncshellInitialized;
|
||||
private readonly HashSet<string> _syncshellJoinInFlight = new(StringComparer.OrdinalIgnoreCase);
|
||||
private string? _syncshellLastError;
|
||||
|
||||
public AutoDetectUi(ILogger<AutoDetectUi> logger, MareMediator mediator,
|
||||
MareConfigService configService, DalamudUtilService dalamudUtilService, IObjectTable objectTable,
|
||||
Services.AutoDetect.AutoDetectRequestService requestService, PairManager pairManager,
|
||||
MareConfigService configService, DalamudUtilService dalamudUtilService,
|
||||
AutoDetectRequestService requestService, NearbyPendingService pendingService, PairManager pairManager,
|
||||
NearbyDiscoveryService discoveryService, SyncshellDiscoveryService syncshellDiscoveryService,
|
||||
PerformanceCollectorService performanceCollectorService)
|
||||
: base(logger, mediator, "AutoDetect", performanceCollectorService)
|
||||
{
|
||||
_configService = configService;
|
||||
_dalamud = dalamudUtilService;
|
||||
_objectTable = objectTable;
|
||||
_requestService = requestService;
|
||||
_pendingService = pendingService;
|
||||
_pairManager = pairManager;
|
||||
_discoveryService = discoveryService;
|
||||
_syncshellDiscoveryService = syncshellDiscoveryService;
|
||||
Mediator.Subscribe<Services.Mediator.DiscoveryListUpdated>(this, OnDiscoveryUpdated);
|
||||
Mediator.Subscribe<SyncshellDiscoveryUpdated>(this, OnSyncshellDiscoveryUpdated);
|
||||
_entries = _discoveryService.SnapshotEntries();
|
||||
|
||||
Flags |= ImGuiWindowFlags.NoScrollbar;
|
||||
SizeConstraints = new WindowSizeConstraints()
|
||||
@@ -58,15 +72,145 @@ public class AutoDetectUi : WindowMediatorSubscriberBase
|
||||
{
|
||||
using var idScope = ImRaii.PushId("autodetect-ui");
|
||||
|
||||
var incomingInvites = _pendingService.Pending.ToList();
|
||||
var outgoingInvites = _requestService.GetPendingRequestsSnapshot();
|
||||
|
||||
Vector4 accent = UiSharedService.AccentColor;
|
||||
if (accent.W <= 0f) accent = ImGuiColors.ParsedPurple;
|
||||
Vector4 inactiveTab = new(accent.X * 0.45f, accent.Y * 0.45f, accent.Z * 0.45f, Math.Clamp(accent.W + 0.15f, 0f, 1f));
|
||||
Vector4 hoverTab = UiSharedService.AccentHoverColor;
|
||||
|
||||
using var tabs = ImRaii.TabBar("AutoDetectTabs");
|
||||
if (!tabs.Success) return;
|
||||
|
||||
var incomingCount = incomingInvites.Count;
|
||||
DrawStyledTab($"Invitations ({incomingCount})", accent, inactiveTab, hoverTab, () =>
|
||||
{
|
||||
DrawInvitationsTab(incomingInvites, outgoingInvites);
|
||||
});
|
||||
|
||||
DrawStyledTab("Proximité", accent, inactiveTab, hoverTab, DrawNearbyTab);
|
||||
DrawStyledTab("Syncshell", accent, inactiveTab, hoverTab, DrawSyncshellTab);
|
||||
}
|
||||
|
||||
public void DrawInline()
|
||||
{
|
||||
DrawInternal();
|
||||
}
|
||||
|
||||
private static void DrawStyledTab(string label, Vector4 accent, Vector4 inactive, Vector4 hover, Action draw, bool disabled = false)
|
||||
{
|
||||
var tabColor = disabled ? ImGuiColors.DalamudGrey3 : inactive;
|
||||
var tabHover = disabled ? ImGuiColors.DalamudGrey3 : hover;
|
||||
var tabActive = disabled ? ImGuiColors.DalamudGrey2 : accent;
|
||||
using var baseColor = ImRaii.PushColor(ImGuiCol.Tab, tabColor);
|
||||
using var hoverColor = ImRaii.PushColor(ImGuiCol.TabHovered, tabHover);
|
||||
using var activeColor = ImRaii.PushColor(ImGuiCol.TabActive, tabActive);
|
||||
using var activeText = ImRaii.PushColor(ImGuiCol.Text, disabled ? ImGuiColors.DalamudGrey2 : Vector4.One, false);
|
||||
using var tab = ImRaii.TabItem(label);
|
||||
if (tab.Success)
|
||||
{
|
||||
draw();
|
||||
}
|
||||
}
|
||||
|
||||
private void DrawInvitationsTab(List<KeyValuePair<string, string>> incomingInvites, IReadOnlyCollection<AutoDetectRequestService.PendingRequestInfo> outgoingInvites)
|
||||
{
|
||||
if (incomingInvites.Count == 0 && outgoingInvites.Count == 0)
|
||||
{
|
||||
UiSharedService.ColorTextWrapped("Aucune invitation en attente. Cette page regroupera les demandes reçues et celles que vous avez envoyées.", ImGuiColors.DalamudGrey3);
|
||||
return;
|
||||
}
|
||||
|
||||
if (incomingInvites.Count == 0)
|
||||
{
|
||||
UiSharedService.ColorTextWrapped("Vous n'avez aucune invitation de pair en attente pour le moment.", ImGuiColors.DalamudGrey3);
|
||||
}
|
||||
|
||||
ImGuiHelpers.ScaledDummy(4);
|
||||
float leftWidth = Math.Max(220f * ImGuiHelpers.GlobalScale, ImGui.CalcTextSize("Invitations reçues (00)").X + ImGui.GetStyle().FramePadding.X * 4f);
|
||||
var avail = ImGui.GetContentRegionAvail();
|
||||
|
||||
ImGui.BeginChild("incoming-requests", new Vector2(leftWidth, avail.Y), true);
|
||||
ImGui.TextColored(ImGuiColors.DalamudOrange, $"Invitations reçues ({incomingInvites.Count})");
|
||||
ImGui.Separator();
|
||||
if (incomingInvites.Count == 0)
|
||||
{
|
||||
ImGui.TextDisabled("Aucune invitation reçue.");
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach (var (uid, name) in incomingInvites.OrderBy(k => k.Value, StringComparer.OrdinalIgnoreCase))
|
||||
{
|
||||
using var id = ImRaii.PushId(uid);
|
||||
bool processing = _acceptInFlight.Contains(uid);
|
||||
ImGui.TextUnformatted(name);
|
||||
ImGui.TextDisabled(uid);
|
||||
if (processing)
|
||||
{
|
||||
ImGui.TextDisabled("Traitement en cours...");
|
||||
}
|
||||
else
|
||||
{
|
||||
if (ImGui.Button("Accepter"))
|
||||
{
|
||||
TriggerAccept(uid);
|
||||
}
|
||||
ImGui.SameLine();
|
||||
if (ImGui.Button("Refuser"))
|
||||
{
|
||||
_pendingService.Remove(uid);
|
||||
}
|
||||
}
|
||||
ImGui.Separator();
|
||||
}
|
||||
}
|
||||
ImGui.EndChild();
|
||||
|
||||
ImGui.SameLine();
|
||||
|
||||
ImGui.BeginChild("outgoing-requests", new Vector2(0, avail.Y), true);
|
||||
ImGui.TextColored(ImGuiColors.DalamudOrange, $"Invitations envoyées ({outgoingInvites.Count})");
|
||||
ImGui.Separator();
|
||||
if (outgoingInvites.Count == 0)
|
||||
{
|
||||
ImGui.TextDisabled("Aucune invitation envoyée en attente.");
|
||||
ImGui.EndChild();
|
||||
return;
|
||||
}
|
||||
|
||||
foreach (var info in outgoingInvites.OrderByDescending(i => i.SentAt))
|
||||
{
|
||||
using var id = ImRaii.PushId(info.Key);
|
||||
ImGui.TextUnformatted(info.TargetDisplayName);
|
||||
if (!string.IsNullOrEmpty(info.Uid))
|
||||
{
|
||||
ImGui.TextDisabled(info.Uid);
|
||||
}
|
||||
|
||||
ImGui.TextDisabled($"Envoyée il y a {FormatDuration(DateTime.UtcNow - info.SentAt)}");
|
||||
if (ImGui.Button("Retirer"))
|
||||
{
|
||||
_requestService.RemovePendingRequestByKey(info.Key);
|
||||
}
|
||||
UiSharedService.AttachToolTip("Retire uniquement cette entrée locale de suivi.");
|
||||
ImGui.Separator();
|
||||
}
|
||||
|
||||
ImGui.EndChild();
|
||||
}
|
||||
|
||||
private void DrawNearbyTab()
|
||||
{
|
||||
if (!_configService.Current.EnableAutoDetectDiscovery)
|
||||
{
|
||||
UiSharedService.ColorTextWrapped(L("AutoDetect.Disabled", "Nearby detection is disabled. Enable it in Settings to start detecting nearby Umbra users."), ImGuiColors.DalamudYellow);
|
||||
UiSharedService.ColorTextWrapped("AutoDetect est désactivé. Activez-le dans les paramètres pour détecter les utilisateurs Umbra à proximité.", ImGuiColors.DalamudYellow);
|
||||
ImGuiHelpers.ScaledDummy(6);
|
||||
}
|
||||
|
||||
int maxDist = Math.Clamp(_configService.Current.AutoDetectMaxDistanceMeters, 5, 100);
|
||||
ImGui.AlignTextToFramePadding();
|
||||
ImGui.TextUnformatted(L("AutoDetect.MaxDistance", "Max distance (m)"));
|
||||
ImGui.TextUnformatted("Max distance (m)");
|
||||
ImGui.SameLine();
|
||||
ImGui.SetNextItemWidth(120 * ImGuiHelpers.GlobalScale);
|
||||
if (ImGui.SliderInt("##autodetect-dist", ref maxDist, 5, 100))
|
||||
@@ -77,67 +221,229 @@ public class AutoDetectUi : WindowMediatorSubscriberBase
|
||||
|
||||
ImGuiHelpers.ScaledDummy(6);
|
||||
|
||||
// Table header
|
||||
if (ImGui.BeginTable("autodetect-nearby", 5, ImGuiTableFlags.SizingStretchProp))
|
||||
var sourceEntries = _entries.Count > 0 ? _entries : _discoveryService.SnapshotEntries();
|
||||
var orderedEntries = sourceEntries
|
||||
.Where(e => e.IsMatch)
|
||||
.OrderBy(e => float.IsNaN(e.Distance) ? float.MaxValue : e.Distance)
|
||||
.ToList();
|
||||
|
||||
if (orderedEntries.Count == 0)
|
||||
{
|
||||
ImGui.TableSetupColumn(L("AutoDetect.Table.Name", "Name"));
|
||||
ImGui.TableSetupColumn(L("AutoDetect.Table.World", "World"));
|
||||
ImGui.TableSetupColumn(L("AutoDetect.Table.Distance", "Distance"));
|
||||
ImGui.TableSetupColumn(L("AutoDetect.Table.Status", "Status"));
|
||||
ImGui.TableSetupColumn(L("AutoDetect.Table.Action", "Action"));
|
||||
UiSharedService.ColorTextWrapped("Aucune présence UmbraSync détectée à proximité pour le moment.", ImGuiColors.DalamudGrey3);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!ImGui.BeginTable("autodetect-nearby", 5, ImGuiTableFlags.SizingStretchProp | ImGuiTableFlags.RowBg))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
ImGui.TableSetupColumn("Nom");
|
||||
ImGui.TableSetupColumn("Monde");
|
||||
ImGui.TableSetupColumn("Distance");
|
||||
ImGui.TableSetupColumn("Statut");
|
||||
ImGui.TableSetupColumn("Action");
|
||||
ImGui.TableHeadersRow();
|
||||
|
||||
var data = _entries.Count > 0 ? _entries.Where(e => e.IsMatch).ToList() : new List<Services.Mediator.NearbyEntry>();
|
||||
foreach (var e in data)
|
||||
for (int i = 0; i < orderedEntries.Count; i++)
|
||||
{
|
||||
ImGui.TableNextColumn();
|
||||
ImGui.TextUnformatted(e.Name);
|
||||
ImGui.TableNextColumn();
|
||||
ImGui.TextUnformatted(e.WorldId == 0 ? L("AutoDetect.World.Unknown", "-") : (_dalamud.WorldData.Value.TryGetValue(e.WorldId, out var w) ? w : e.WorldId.ToString()));
|
||||
ImGui.TableNextColumn();
|
||||
ImGui.TextUnformatted(float.IsNaN(e.Distance)
|
||||
? L("AutoDetect.Distance.Unknown", "-")
|
||||
: string.Format(CultureInfo.CurrentCulture, L("AutoDetect.Distance.Format", "{0:0.0} m"), e.Distance));
|
||||
ImGui.TableNextColumn();
|
||||
bool alreadyPaired = IsAlreadyPairedByUidOrAlias(e);
|
||||
var entry = orderedEntries[i];
|
||||
bool alreadyPaired = IsAlreadyPairedByUidOrAlias(entry);
|
||||
bool overDistance = !float.IsNaN(entry.Distance) && entry.Distance > maxDist;
|
||||
bool canRequest = entry.AcceptPairRequests && !string.IsNullOrEmpty(entry.Token) && !alreadyPaired;
|
||||
|
||||
string displayName = entry.DisplayName ?? entry.Name;
|
||||
string worldName = entry.WorldId == 0
|
||||
? "-"
|
||||
: (_dalamud.WorldData.Value.TryGetValue(entry.WorldId, out var mappedWorld) ? mappedWorld : entry.WorldId.ToString(CultureInfo.InvariantCulture));
|
||||
string distanceText = float.IsNaN(entry.Distance) ? "-" : $"{entry.Distance:0.0} m";
|
||||
|
||||
string status = alreadyPaired
|
||||
? L("AutoDetect.Status.Paired", "Paired")
|
||||
: (string.IsNullOrEmpty(e.Token)
|
||||
? L("AutoDetect.Status.RequestsDisabled", "Requests disabled")
|
||||
: L("AutoDetect.Status.OnUmbra", "On Umbra"));
|
||||
ImGui.TextUnformatted(status);
|
||||
? "Déjà appairé"
|
||||
: overDistance
|
||||
? $"Hors portée (> {maxDist} m)"
|
||||
: !entry.AcceptPairRequests
|
||||
? "Invitations refusées"
|
||||
: string.IsNullOrEmpty(entry.Token)
|
||||
? "Indisponible"
|
||||
: "Disponible";
|
||||
|
||||
ImGui.TableNextColumn();
|
||||
using (ImRaii.Disabled(alreadyPaired || string.IsNullOrEmpty(e.Token)))
|
||||
ImGui.TextUnformatted(displayName);
|
||||
|
||||
ImGui.TableNextColumn();
|
||||
ImGui.TextUnformatted(worldName);
|
||||
|
||||
ImGui.TableNextColumn();
|
||||
ImGui.TextUnformatted(distanceText);
|
||||
|
||||
ImGui.TableNextColumn();
|
||||
ImGui.TextUnformatted(status);
|
||||
|
||||
ImGui.TableNextColumn();
|
||||
using (ImRaii.PushId(i))
|
||||
{
|
||||
if (alreadyPaired)
|
||||
if (canRequest && !overDistance)
|
||||
{
|
||||
ImGui.Button(L("AutoDetect.Action.AlreadySynced", "Already sync") + "##" + e.Name);
|
||||
if (ImGui.Button("Envoyer invitation"))
|
||||
{
|
||||
_ = _requestService.SendRequestAsync(entry.Token!, entry.Uid, entry.DisplayName);
|
||||
}
|
||||
else if (string.IsNullOrEmpty(e.Token))
|
||||
{
|
||||
ImGui.Button(L("AutoDetect.Action.RequestsDisabled", "Requests disabled") + "##" + e.Name);
|
||||
UiSharedService.AttachToolTip("Envoie une demande d'appairage via AutoDetect.");
|
||||
}
|
||||
else if (ImGui.Button(L("AutoDetect.Action.SendRequest", "Send request") + "##" + e.Name))
|
||||
else
|
||||
{
|
||||
_ = _requestService.SendRequestAsync(e.Token!);
|
||||
string reason = alreadyPaired
|
||||
? "Vous êtes déjà appairé avec ce joueur."
|
||||
: overDistance
|
||||
? $"Ce joueur est au-delà de la distance maximale configurée ({maxDist} m)."
|
||||
: !entry.AcceptPairRequests
|
||||
? "Ce joueur a désactivé la réception automatique des invitations."
|
||||
: string.IsNullOrEmpty(entry.Token)
|
||||
? "Impossible d'obtenir un jeton d'invitation pour ce joueur."
|
||||
: string.Empty;
|
||||
|
||||
ImGui.TextDisabled(status);
|
||||
if (!string.IsNullOrEmpty(reason))
|
||||
{
|
||||
UiSharedService.AttachToolTip(reason);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ImGui.EndTable();
|
||||
}
|
||||
|
||||
private async Task JoinSyncshellAsync(SyncshellDiscoveryEntryDto entry)
|
||||
{
|
||||
if (!_syncshellJoinInFlight.Add(entry.GID))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
public override void OnOpen()
|
||||
try
|
||||
{
|
||||
base.OnOpen();
|
||||
Mediator.Subscribe<Services.Mediator.DiscoveryListUpdated>(this, OnDiscoveryUpdated);
|
||||
var joined = await _syncshellDiscoveryService.JoinAsync(entry.GID, CancellationToken.None).ConfigureAwait(false);
|
||||
if (joined)
|
||||
{
|
||||
Mediator.Publish(new NotificationMessage("AutoDetect Syncshell", $"Rejoint {entry.Alias ?? entry.GID}.", NotificationType.Info, TimeSpan.FromSeconds(5)));
|
||||
await _syncshellDiscoveryService.RefreshAsync(CancellationToken.None).ConfigureAwait(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
_syncshellLastError = $"Impossible de rejoindre {entry.Alias ?? entry.GID}.";
|
||||
Mediator.Publish(new NotificationMessage("AutoDetect Syncshell", _syncshellLastError, NotificationType.Warning, TimeSpan.FromSeconds(5)));
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_syncshellLastError = $"Erreur lors de l'adhésion : {ex.Message}";
|
||||
Mediator.Publish(new NotificationMessage("AutoDetect Syncshell", _syncshellLastError, NotificationType.Error, TimeSpan.FromSeconds(5)));
|
||||
}
|
||||
finally
|
||||
{
|
||||
_syncshellJoinInFlight.Remove(entry.GID);
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnClose()
|
||||
private void DrawSyncshellTab()
|
||||
{
|
||||
Mediator.Unsubscribe<Services.Mediator.DiscoveryListUpdated>(this);
|
||||
base.OnClose();
|
||||
if (!_syncshellInitialized)
|
||||
{
|
||||
_syncshellInitialized = true;
|
||||
_ = _syncshellDiscoveryService.RefreshAsync(CancellationToken.None);
|
||||
}
|
||||
|
||||
bool isRefreshing = _syncshellDiscoveryService.IsRefreshing;
|
||||
var serviceError = _syncshellDiscoveryService.LastError;
|
||||
|
||||
if (ImGui.Button("Actualiser la liste"))
|
||||
{
|
||||
_ = _syncshellDiscoveryService.RefreshAsync(CancellationToken.None);
|
||||
}
|
||||
UiSharedService.AttachToolTip("Met à jour la liste des Syncshells ayant activé l'AutoDetect.");
|
||||
|
||||
if (isRefreshing)
|
||||
{
|
||||
ImGui.SameLine();
|
||||
ImGui.TextDisabled("Actualisation...");
|
||||
}
|
||||
|
||||
ImGuiHelpers.ScaledDummy(4);
|
||||
UiSharedService.TextWrapped("Les Syncshells affichées ont temporairement désactivé leur mot de passe pour permettre un accès direct via AutoDetect. Rejoignez-les uniquement si vous faites confiance aux administrateurs.");
|
||||
|
||||
if (!string.IsNullOrEmpty(serviceError))
|
||||
{
|
||||
UiSharedService.ColorTextWrapped(serviceError, ImGuiColors.DalamudRed);
|
||||
}
|
||||
else if (!string.IsNullOrEmpty(_syncshellLastError))
|
||||
{
|
||||
UiSharedService.ColorTextWrapped(_syncshellLastError!, ImGuiColors.DalamudOrange);
|
||||
}
|
||||
|
||||
var entries = _syncshellEntries.Count > 0 ? _syncshellEntries : _syncshellDiscoveryService.Entries.ToList();
|
||||
if (entries.Count == 0)
|
||||
{
|
||||
ImGuiHelpers.ScaledDummy(4);
|
||||
UiSharedService.ColorTextWrapped("Aucune Syncshell n'est actuellement visible dans AutoDetect.", ImGuiColors.DalamudGrey3);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!ImGui.BeginTable("autodetect-syncshells", 5, ImGuiTableFlags.SizingStretchProp | ImGuiTableFlags.RowBg))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
ImGui.TableSetupColumn("Nom");
|
||||
ImGui.TableSetupColumn("Propriétaire");
|
||||
ImGui.TableSetupColumn("Membres");
|
||||
ImGui.TableSetupColumn("Invitations");
|
||||
ImGui.TableSetupColumn("Action");
|
||||
ImGui.TableHeadersRow();
|
||||
|
||||
foreach (var entry in entries.OrderBy(e => e.Alias ?? e.GID, StringComparer.OrdinalIgnoreCase))
|
||||
{
|
||||
bool alreadyMember = _pairManager.Groups.Keys.Any(g => string.Equals(g.GID, entry.GID, StringComparison.OrdinalIgnoreCase));
|
||||
bool joining = _syncshellJoinInFlight.Contains(entry.GID);
|
||||
|
||||
ImGui.TableNextColumn();
|
||||
ImGui.TextUnformatted(string.IsNullOrEmpty(entry.Alias) ? entry.GID : $"{entry.Alias} ({entry.GID})");
|
||||
|
||||
ImGui.TableNextColumn();
|
||||
ImGui.TextUnformatted(string.IsNullOrEmpty(entry.OwnerAlias) ? entry.OwnerUID : $"{entry.OwnerAlias} ({entry.OwnerUID})");
|
||||
|
||||
ImGui.TableNextColumn();
|
||||
ImGui.TextUnformatted(entry.MemberCount.ToString(CultureInfo.InvariantCulture));
|
||||
|
||||
ImGui.TableNextColumn();
|
||||
string inviteMode = entry.AutoAcceptPairs ? "Auto" : "Manuel";
|
||||
ImGui.TextUnformatted(inviteMode);
|
||||
if (!entry.AutoAcceptPairs)
|
||||
{
|
||||
UiSharedService.AttachToolTip("L'administrateur doit approuver manuellement les nouveaux membres.");
|
||||
}
|
||||
|
||||
ImGui.TableNextColumn();
|
||||
using (ImRaii.Disabled(alreadyMember || joining))
|
||||
{
|
||||
if (alreadyMember)
|
||||
{
|
||||
ImGui.TextDisabled("Déjà membre");
|
||||
}
|
||||
else if (joining)
|
||||
{
|
||||
ImGui.TextDisabled("Connexion...");
|
||||
}
|
||||
else if (ImGui.Button("Rejoindre"))
|
||||
{
|
||||
_syncshellLastError = null;
|
||||
_ = JoinSyncshellAsync(entry);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ImGui.EndTable();
|
||||
}
|
||||
|
||||
private void OnDiscoveryUpdated(Services.Mediator.DiscoveryListUpdated msg)
|
||||
@@ -145,24 +451,9 @@ public class AutoDetectUi : WindowMediatorSubscriberBase
|
||||
_entries = msg.Entries;
|
||||
}
|
||||
|
||||
private List<Services.Mediator.NearbyEntry> BuildLocalSnapshot(int maxDist)
|
||||
private void OnSyncshellDiscoveryUpdated(SyncshellDiscoveryUpdated msg)
|
||||
{
|
||||
var list = new List<Services.Mediator.NearbyEntry>();
|
||||
var local = _dalamud.GetPlayerCharacter();
|
||||
var localPos = local?.Position ?? Vector3.Zero;
|
||||
for (int i = 0; i < 200; i += 2)
|
||||
{
|
||||
var obj = _objectTable[i];
|
||||
if (obj == null || obj.ObjectKind != Dalamud.Game.ClientState.Objects.Enums.ObjectKind.Player) continue;
|
||||
if (local != null && obj.Address == local.Address) continue;
|
||||
float dist = local == null ? float.NaN : Vector3.Distance(localPos, obj.Position);
|
||||
if (!float.IsNaN(dist) && dist > maxDist) continue;
|
||||
string name = obj.Name.ToString();
|
||||
ushort worldId = 0;
|
||||
if (obj is IPlayerCharacter pc) worldId = (ushort)pc.HomeWorld.RowId;
|
||||
list.Add(new Services.Mediator.NearbyEntry(name, worldId, dist, false, null, null, null));
|
||||
}
|
||||
return list;
|
||||
_syncshellEntries = msg.Entries;
|
||||
}
|
||||
|
||||
private bool IsAlreadyPairedByUidOrAlias(Services.Mediator.NearbyEntry e)
|
||||
@@ -205,4 +496,37 @@ public class AutoDetectUi : WindowMediatorSubscriberBase
|
||||
}
|
||||
return sb.ToString();
|
||||
}
|
||||
|
||||
private void TriggerAccept(string uid)
|
||||
{
|
||||
if (!_acceptInFlight.Add(uid)) return;
|
||||
|
||||
Task.Run(async () =>
|
||||
{
|
||||
try
|
||||
{
|
||||
bool ok = await _pendingService.AcceptAsync(uid).ConfigureAwait(false);
|
||||
if (!ok)
|
||||
{
|
||||
Mediator.Publish(new NotificationMessage("AutoDetect", $"Impossible d'accepter l'invitation {uid}.", NotificationType.Warning, TimeSpan.FromSeconds(5)));
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
_acceptInFlight.Remove(uid);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private static string FormatDuration(TimeSpan span)
|
||||
{
|
||||
if (span.TotalMinutes >= 1)
|
||||
{
|
||||
var minutes = Math.Max(1, (int)Math.Round(span.TotalMinutes));
|
||||
return minutes == 1 ? "1 minute" : $"{minutes} minutes";
|
||||
}
|
||||
|
||||
var seconds = Math.Max(1, (int)Math.Round(span.TotalSeconds));
|
||||
return seconds == 1 ? "1 seconde" : $"{seconds} secondes";
|
||||
}
|
||||
}
|
||||
|
||||
245
MareSynchronos/UI/ChangelogUi.cs
Normal file
245
MareSynchronos/UI/ChangelogUi.cs
Normal file
@@ -0,0 +1,245 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Numerics;
|
||||
using System.Reflection;
|
||||
using Dalamud.Bindings.ImGui;
|
||||
using Dalamud.Interface;
|
||||
using Dalamud.Interface.Colors;
|
||||
using Dalamud.Interface.Utility.Raii;
|
||||
using MareSynchronos.MareConfiguration;
|
||||
using MareSynchronos.Services;
|
||||
using MareSynchronos.Services.Mediator;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace MareSynchronos.UI;
|
||||
|
||||
public sealed class ChangelogUi : WindowMediatorSubscriberBase
|
||||
{
|
||||
private const int AlwaysExpandedEntryCount = 2;
|
||||
|
||||
private readonly MareConfigService _configService;
|
||||
private readonly UiSharedService _uiShared;
|
||||
private readonly Version _currentVersion;
|
||||
private readonly string _currentVersionLabel;
|
||||
private readonly IReadOnlyList<ChangelogEntry> _entries;
|
||||
|
||||
private bool _showAllEntries;
|
||||
private bool _hasAcknowledgedVersion;
|
||||
|
||||
public ChangelogUi(ILogger<ChangelogUi> logger, UiSharedService uiShared, MareConfigService configService,
|
||||
MareMediator mediator, PerformanceCollectorService performanceCollectorService)
|
||||
: base(logger, mediator, "Umbra Sync - Notes de version", performanceCollectorService)
|
||||
{
|
||||
_uiShared = uiShared;
|
||||
_configService = configService;
|
||||
_currentVersion = Assembly.GetExecutingAssembly().GetName().Version ?? new Version(0, 0, 0, 0);
|
||||
_currentVersionLabel = _currentVersion.ToString();
|
||||
_entries = BuildEntries();
|
||||
_hasAcknowledgedVersion = string.Equals(_configService.Current.LastChangelogVersionSeen, _currentVersionLabel, StringComparison.Ordinal);
|
||||
|
||||
RespectCloseHotkey = true;
|
||||
SizeConstraints = new()
|
||||
{
|
||||
MinimumSize = new(520, 360),
|
||||
MaximumSize = new(900, 1200)
|
||||
};
|
||||
Flags |= ImGuiWindowFlags.NoResize;
|
||||
ShowCloseButton = true;
|
||||
|
||||
if (!string.Equals(_configService.Current.LastChangelogVersionSeen, _currentVersionLabel, StringComparison.Ordinal))
|
||||
{
|
||||
IsOpen = true;
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnClose()
|
||||
{
|
||||
MarkCurrentVersionAsReadIfNeeded();
|
||||
base.OnClose();
|
||||
}
|
||||
|
||||
protected override void DrawInternal()
|
||||
{
|
||||
_ = _uiShared.DrawOtherPluginState();
|
||||
|
||||
DrawHeader();
|
||||
DrawEntries();
|
||||
DrawFooter();
|
||||
}
|
||||
|
||||
private void DrawHeader()
|
||||
{
|
||||
using (_uiShared.UidFont.Push())
|
||||
{
|
||||
ImGui.TextUnformatted("Notes de version");
|
||||
}
|
||||
|
||||
ImGui.TextColored(ImGuiColors.DalamudGrey, $"Version chargée : {_currentVersionLabel}");
|
||||
ImGui.Separator();
|
||||
}
|
||||
|
||||
private void DrawEntries()
|
||||
{
|
||||
bool expandedOldVersions = false;
|
||||
for (int index = 0; index < _entries.Count; index++)
|
||||
{
|
||||
var entry = _entries[index];
|
||||
if (!_showAllEntries && index >= AlwaysExpandedEntryCount)
|
||||
{
|
||||
if (!expandedOldVersions)
|
||||
{
|
||||
expandedOldVersions = ImGui.CollapsingHeader("Historique complet");
|
||||
}
|
||||
|
||||
if (!expandedOldVersions)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
DrawEntry(entry);
|
||||
}
|
||||
}
|
||||
|
||||
private void DrawEntry(ChangelogEntry entry)
|
||||
{
|
||||
using (ImRaii.PushId(entry.VersionLabel))
|
||||
{
|
||||
ImGui.Spacing();
|
||||
UiSharedService.ColorText(entry.VersionLabel, entry.Version == _currentVersion
|
||||
? ImGuiColors.HealerGreen
|
||||
: ImGuiColors.DalamudWhite);
|
||||
|
||||
ImGui.Spacing();
|
||||
|
||||
foreach (var line in entry.Lines)
|
||||
{
|
||||
DrawLine(line);
|
||||
}
|
||||
|
||||
ImGui.Spacing();
|
||||
ImGui.Separator();
|
||||
}
|
||||
}
|
||||
|
||||
private static void DrawLine(ChangelogLine line)
|
||||
{
|
||||
using var indent = line.IndentLevel > 0 ? ImRaii.PushIndent(line.IndentLevel) : null;
|
||||
if (line.Color != null)
|
||||
{
|
||||
ImGui.TextColored(line.Color.Value, $"- {line.Text}");
|
||||
}
|
||||
else
|
||||
{
|
||||
ImGui.TextUnformatted($"- {line.Text}");
|
||||
}
|
||||
}
|
||||
|
||||
private void DrawFooter()
|
||||
{
|
||||
ImGui.Spacing();
|
||||
if (!_showAllEntries && _entries.Count > AlwaysExpandedEntryCount)
|
||||
{
|
||||
if (ImGui.Button("Tout afficher"))
|
||||
{
|
||||
_showAllEntries = true;
|
||||
}
|
||||
|
||||
ImGui.SameLine();
|
||||
}
|
||||
|
||||
if (ImGui.Button("Marquer comme lu"))
|
||||
{
|
||||
MarkCurrentVersionAsReadIfNeeded();
|
||||
IsOpen = false;
|
||||
}
|
||||
}
|
||||
|
||||
private void MarkCurrentVersionAsReadIfNeeded()
|
||||
{
|
||||
if (_hasAcknowledgedVersion)
|
||||
return;
|
||||
|
||||
_configService.Current.LastChangelogVersionSeen = _currentVersionLabel;
|
||||
_configService.Save();
|
||||
_hasAcknowledgedVersion = true;
|
||||
}
|
||||
|
||||
private static IReadOnlyList<ChangelogEntry> BuildEntries()
|
||||
{
|
||||
return new List<ChangelogEntry>
|
||||
{
|
||||
new(new Version(0, 1, 9, 5), "0.1.9.5", new List<ChangelogLine>
|
||||
{
|
||||
new("Fix l'affichage de la bulle dans la liste du groupe."),
|
||||
new("Amélioration de l'ajout des utilisateurs via le bouton +."),
|
||||
new("Possibilité de mettre en pause individuellement des utilisateurs d'une syncshell."),
|
||||
new("Amélioration de la stabilité du plugin en cas de petite connexion / petite configuration."),
|
||||
new("Divers fix de l'interface."),
|
||||
}),
|
||||
new(new Version(0, 1, 9, 4), "0.1.9.4", new List<ChangelogLine>
|
||||
{
|
||||
new("Réécriture complète de la bulle de frappe avec la possibilité de choisir la taille de la bulle."),
|
||||
new("Désactivation de l'AutoDetect en zone instanciée."),
|
||||
new("Réécriture interface AutoDetect pour acceuillir les invitations en attente et préparer les synchsells publiques."),
|
||||
new("Amélioration de la compréhension des activations / désactivations des préférences de synchronisation par défaut."),
|
||||
new("Mise en avant du Self Analyse avec une alerte lorsqu'un seuil de donnée a été atteint."),
|
||||
new("Ajout de l'alerte de la non-compatibilité du plugin Chat2."),
|
||||
new("Divers fix de l'interface."),
|
||||
}),
|
||||
new(new Version(0, 1, 9, 3), "0.1.9.3", new List<ChangelogLine>
|
||||
{
|
||||
new("Correctif de l'affichage de la bulle de frappe quand l'interface est à + de 100%."),
|
||||
}),
|
||||
new(new Version(0, 1, 9, 2), "0.1.9.2", new List<ChangelogLine>
|
||||
{
|
||||
new("Correctif de l'affichage de la bulle de frappe."),
|
||||
}),
|
||||
new(new Version(0, 1, 9, 1), "0.1.9.1", new List<ChangelogLine>
|
||||
{
|
||||
new("Début correctif pour la bulle de frappe."),
|
||||
new("Les bascules de synchronisation n'affichent plus qu'une seule notification résumée."),
|
||||
|
||||
}),
|
||||
new(new Version(0, 1, 9, 0), "0.1.9.0", new List<ChangelogLine>
|
||||
{
|
||||
new("Il est désormais possible de configurer par défaut nos choix de synchronisation (VFX, Music, Animation)."),
|
||||
new("La catégorie 'En attente' ne s'affiche uniquement que si une invitation est en attente"),
|
||||
new("(EN PRÉ VERSION) Il est désormais possible de voir quand une personne appairée est en train d'écrire avec une bulle qui s'affiche."),
|
||||
new("(EN PRÉ VERSION) La bulle de frappe s'affiche également sur votre propre plaque de nom lorsque vous écrivez."),
|
||||
new("Les bascules de synchronisation n'affichent plus qu'une seule notification résumée."),
|
||||
new("Correctif : Désormais, les invitation entrantes ne s'affichent qu'une seule fois au lieu de deux."),
|
||||
}),
|
||||
new(new Version(0, 1, 8, 2), "0.1.8.2", new List<ChangelogLine>
|
||||
{
|
||||
new("Détection Nearby : la liste rapide ne montre plus que les joueurs réellement invitables."),
|
||||
new("Sont filtrés automatiquement les personnes refusées ou déjà appairées."),
|
||||
new("Invitations Nearby : anti-spam de 5 minutes par personne, blocage 15 minutes après trois refus."),
|
||||
new("Affichage : Correction de l'affichage des notes par défaut plutôt que de l'ID si disponible."),
|
||||
new("Les notifications de blocage sont envoyées directement dans le tchat."),
|
||||
new("Overlay DTR : affiche le nombre d'invitations Nearby disponibles dans le titre et l'infobulle."),
|
||||
new("Poses Nearby : le filtre re-fonctionne avec vos notes locales pour retrouver les entrées correspondantes."),
|
||||
}),
|
||||
new(new Version(0, 1, 8, 1), "0.1.8.1", new List<ChangelogLine>
|
||||
{
|
||||
new("Correctif 'Vu sous' : l'infobulle affiche désormais le dernier personnage observé."),
|
||||
new("Invitations AutoDetect : triées en tête de liste pour mieux les repérer."),
|
||||
new("Invitations AutoDetect : conservées entre les redémarrages du plugin ou du jeu."),
|
||||
new("Barre de statut serveur : couleur violette adoptée par défaut."),
|
||||
}),
|
||||
new(new Version(0, 1, 8, 0), "0.1.8.0", new List<ChangelogLine>
|
||||
{
|
||||
new("AutoDetect : détection automatique des joueurs Umbra autour de vous et propositions d'appairage."),
|
||||
new("AutoDetect : désactivé par défaut pour préserver la confidentialité.", 1, ImGuiColors.DalamudGrey),
|
||||
new("AutoDetect : activez-le dans 'Transfers' avec les options Nearby detection et Allow pair requests.", 1, ImGuiColors.DalamudGrey),
|
||||
new("Syncshell temporaire : durée configurable de 1 h à 7 jours, expiration automatique."),
|
||||
new("Syncshell permanente : possibilité de nommer et d'organiser vos groupes sur la durée."),
|
||||
new("Interface : palette UmbraSync harmonisée et menus allégés pour l'usage RP."),
|
||||
}),
|
||||
};
|
||||
}
|
||||
|
||||
private readonly record struct ChangelogEntry(Version Version, string VersionLabel, IReadOnlyList<ChangelogLine> Lines);
|
||||
|
||||
private readonly record struct ChangelogLine(string Text, int IndentLevel = 0, System.Numerics.Vector4? Color = null);
|
||||
}
|
||||
@@ -6,7 +6,7 @@ using System.Text;
|
||||
|
||||
namespace MareSynchronos.UI;
|
||||
|
||||
internal sealed partial class CharaDataHubUi
|
||||
public sealed partial class CharaDataHubUi
|
||||
{
|
||||
private static string GetAccessTypeString(AccessTypeDto dto) => dto switch
|
||||
{
|
||||
|
||||
@@ -7,7 +7,7 @@ using MareSynchronos.Services.CharaData.Models;
|
||||
|
||||
namespace MareSynchronos.UI;
|
||||
|
||||
internal sealed partial class CharaDataHubUi
|
||||
public sealed partial class CharaDataHubUi
|
||||
{
|
||||
private string _joinLobbyId = string.Empty;
|
||||
private void DrawGposeTogether()
|
||||
@@ -15,14 +15,14 @@ internal sealed partial class CharaDataHubUi
|
||||
if (!_charaDataManager.BrioAvailable)
|
||||
{
|
||||
ImGuiHelpers.ScaledDummy(5);
|
||||
UiSharedService.DrawGroupedCenteredColorText("BRIO IS MANDATORY FOR GPOSE TOGETHER.", ImGuiColors.DalamudRed);
|
||||
UiSharedService.DrawGroupedCenteredColorText("BRIO IS MANDATORY FOR GPOSE TOGETHER.", UiSharedService.AccentColor);
|
||||
ImGuiHelpers.ScaledDummy(5);
|
||||
}
|
||||
|
||||
if (!_uiSharedService.ApiController.IsConnected)
|
||||
{
|
||||
ImGuiHelpers.ScaledDummy(5);
|
||||
UiSharedService.DrawGroupedCenteredColorText("CANNOT USE GPOSE TOGETHER WHILE DISCONNECTED FROM THE SERVER.", ImGuiColors.DalamudRed);
|
||||
UiSharedService.DrawGroupedCenteredColorText("CANNOT USE GPOSE TOGETHER WHILE DISCONNECTED FROM THE SERVER.", UiSharedService.AccentColor);
|
||||
ImGuiHelpers.ScaledDummy(5);
|
||||
}
|
||||
|
||||
@@ -90,7 +90,7 @@ internal sealed partial class CharaDataHubUi
|
||||
if (!_uiSharedService.IsInGpose)
|
||||
{
|
||||
ImGuiHelpers.ScaledDummy(5);
|
||||
UiSharedService.DrawGroupedCenteredColorText("Assigning users to characters is only available in GPose.", ImGuiColors.DalamudYellow, 300);
|
||||
UiSharedService.DrawGroupedCenteredColorText("Assigning users to characters is only available in GPose.", UiSharedService.AccentColor, 300);
|
||||
}
|
||||
UiSharedService.DistanceSeparator();
|
||||
ImGui.TextUnformatted("Users In Lobby");
|
||||
@@ -104,7 +104,7 @@ internal sealed partial class CharaDataHubUi
|
||||
|
||||
if (!_charaDataGposeTogetherManager.UsersInLobby.Any() && !string.IsNullOrEmpty(_charaDataGposeTogetherManager.CurrentGPoseLobbyId))
|
||||
{
|
||||
UiSharedService.DrawGroupedCenteredColorText("No other users in current GPose lobby", ImGuiColors.DalamudYellow);
|
||||
UiSharedService.DrawGroupedCenteredColorText("No other users in current GPose lobby", UiSharedService.AccentColor);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -165,7 +165,7 @@ internal sealed partial class CharaDataHubUi
|
||||
UiSharedService.AttachToolTip(user.WorldDataDescriptor + UiSharedService.TooltipSeparator);
|
||||
|
||||
ImGui.SameLine();
|
||||
_uiSharedService.IconText(FontAwesomeIcon.Map, sameMapAndServer.SameMap ? ImGuiColors.ParsedGreen : ImGuiColors.DalamudRed);
|
||||
_uiSharedService.IconText(FontAwesomeIcon.Map, sameMapAndServer.SameMap ? ImGuiColors.ParsedGreen : UiSharedService.AccentColor);
|
||||
if (ImGui.IsItemClicked(ImGuiMouseButton.Left) && user.WorldData != null)
|
||||
{
|
||||
_dalamudUtilService.SetMarkerAndOpenMap(new(user.WorldData.Value.PositionX, user.WorldData.Value.PositionY, user.WorldData.Value.PositionZ), user.Map);
|
||||
@@ -175,12 +175,12 @@ internal sealed partial class CharaDataHubUi
|
||||
+ "Note: For GPose synchronization to work properly, you must be on the same map.");
|
||||
|
||||
ImGui.SameLine();
|
||||
_uiSharedService.IconText(FontAwesomeIcon.Globe, sameMapAndServer.SameServer ? ImGuiColors.ParsedGreen : ImGuiColors.DalamudRed);
|
||||
_uiSharedService.IconText(FontAwesomeIcon.Globe, sameMapAndServer.SameServer ? ImGuiColors.ParsedGreen : UiSharedService.AccentColor);
|
||||
UiSharedService.AttachToolTip((sameMapAndServer.SameMap ? "You are on the same server." : "You are not on the same server.") + UiSharedService.TooltipSeparator
|
||||
+ "Note: GPose synchronization is not dependent on the current server, but you will have to spawn a character for the other lobby users.");
|
||||
|
||||
ImGui.SameLine();
|
||||
_uiSharedService.IconText(FontAwesomeIcon.Running, sameMapAndServer.SameEverything ? ImGuiColors.ParsedGreen : ImGuiColors.DalamudRed);
|
||||
_uiSharedService.IconText(FontAwesomeIcon.Running, sameMapAndServer.SameEverything ? ImGuiColors.ParsedGreen : UiSharedService.AccentColor);
|
||||
UiSharedService.AttachToolTip(sameMapAndServer.SameEverything ? "You are in the same instanced area." : "You are not the same instanced area." + UiSharedService.TooltipSeparator +
|
||||
"Note: Users not in your instance, but on the same map, will be drawn as floating wisps." + Environment.NewLine
|
||||
+ "Note: GPose synchronization is not dependent on the current instance, but you will have to spawn a character for the other lobby users.");
|
||||
@@ -217,7 +217,7 @@ internal sealed partial class CharaDataHubUi
|
||||
if (_uiSharedService.IsInGpose && user.Address == nint.Zero)
|
||||
{
|
||||
ImGui.SameLine();
|
||||
_uiSharedService.IconText(FontAwesomeIcon.ExclamationTriangle, ImGuiColors.DalamudRed);
|
||||
_uiSharedService.IconText(FontAwesomeIcon.ExclamationTriangle, UiSharedService.AccentColor);
|
||||
UiSharedService.AttachToolTip("No valid character assigned for this user. Pose data will not be applied.");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ using System.Numerics;
|
||||
|
||||
namespace MareSynchronos.UI;
|
||||
|
||||
internal sealed partial class CharaDataHubUi
|
||||
public sealed partial class CharaDataHubUi
|
||||
{
|
||||
private void DrawEditCharaData(CharaDataFullExtendedDto? dataDto)
|
||||
{
|
||||
@@ -18,7 +18,7 @@ internal sealed partial class CharaDataHubUi
|
||||
if (dataDto == null)
|
||||
{
|
||||
ImGuiHelpers.ScaledDummy(5);
|
||||
UiSharedService.DrawGroupedCenteredColorText("Select an entry above to edit its data.", ImGuiColors.DalamudYellow);
|
||||
UiSharedService.DrawGroupedCenteredColorText("Select an entry above to edit its data.", UiSharedService.AccentColor);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ internal sealed partial class CharaDataHubUi
|
||||
|
||||
if (updateDto == null)
|
||||
{
|
||||
UiSharedService.DrawGroupedCenteredColorText("Something went awfully wrong and there's no update DTO. Try updating Character Data via the button above.", ImGuiColors.DalamudYellow);
|
||||
UiSharedService.DrawGroupedCenteredColorText("Something went awfully wrong and there's no update DTO. Try updating Character Data via the button above.", UiSharedService.AccentColor);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -45,7 +45,7 @@ internal sealed partial class CharaDataHubUi
|
||||
if (canUpdate)
|
||||
{
|
||||
ImGui.AlignTextToFramePadding();
|
||||
UiSharedService.ColorTextWrapped("Warning: You have unsaved changes!", ImGuiColors.DalamudRed);
|
||||
UiSharedService.ColorTextWrapped("Warning: You have unsaved changes!", UiSharedService.AccentColor);
|
||||
ImGui.SameLine();
|
||||
using (ImRaii.Disabled(_charaDataManager.CharaUpdateTask != null && !_charaDataManager.CharaUpdateTask.IsCompleted))
|
||||
{
|
||||
@@ -61,7 +61,7 @@ internal sealed partial class CharaDataHubUi
|
||||
}
|
||||
if (_charaDataManager.CharaUpdateTask != null && !_charaDataManager.CharaUpdateTask.IsCompleted)
|
||||
{
|
||||
UiSharedService.ColorTextWrapped("Updating data on server, please wait.", ImGuiColors.DalamudYellow);
|
||||
UiSharedService.ColorTextWrapped("Updating data on server, please wait.", UiSharedService.AccentColor);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -71,7 +71,7 @@ internal sealed partial class CharaDataHubUi
|
||||
{
|
||||
if (_charaDataManager.UploadProgress != null)
|
||||
{
|
||||
UiSharedService.ColorTextWrapped(_charaDataManager.UploadProgress.Value ?? string.Empty, ImGuiColors.DalamudYellow);
|
||||
UiSharedService.ColorTextWrapped(_charaDataManager.UploadProgress.Value ?? string.Empty, UiSharedService.AccentColor);
|
||||
}
|
||||
if ((!_charaDataManager.UploadTask?.IsCompleted ?? false) && _uiSharedService.IconTextButton(FontAwesomeIcon.Ban, "Cancel Upload"))
|
||||
{
|
||||
@@ -216,7 +216,7 @@ internal sealed partial class CharaDataHubUi
|
||||
}
|
||||
else
|
||||
{
|
||||
UiSharedService.ColorTextWrapped($"{dataDto.MissingFiles.DistinctBy(k => k.HashOrFileSwap).Count()} files to download this character data are missing on the server", ImGuiColors.DalamudRed);
|
||||
UiSharedService.ColorTextWrapped($"{dataDto.MissingFiles.DistinctBy(k => k.HashOrFileSwap).Count()} files to download this character data are missing on the server", UiSharedService.AccentColor);
|
||||
ImGui.NewLine();
|
||||
ImGui.SameLine(pos);
|
||||
if (_uiSharedService.IconTextButton(FontAwesomeIcon.ArrowCircleUp, "Attempt to upload missing files and restore Character Data"))
|
||||
@@ -230,7 +230,7 @@ internal sealed partial class CharaDataHubUi
|
||||
ImGui.SameLine();
|
||||
ImGuiHelpers.ScaledDummy(20, 1);
|
||||
ImGui.SameLine();
|
||||
UiSharedService.ColorTextWrapped("New data was set. It may contain files that require to be uploaded (will happen on Saving to server)", ImGuiColors.DalamudYellow);
|
||||
UiSharedService.ColorTextWrapped("New data was set. It may contain files that require to be uploaded (will happen on Saving to server)", UiSharedService.AccentColor);
|
||||
}
|
||||
|
||||
ImGui.TextUnformatted("Contains Manipulation Data");
|
||||
@@ -385,7 +385,7 @@ internal sealed partial class CharaDataHubUi
|
||||
}
|
||||
}
|
||||
ImGui.SameLine();
|
||||
using (ImRaii.PushColor(ImGuiCol.Text, ImGuiColors.DalamudYellow, poseCount == maxPoses))
|
||||
using (ImRaii.PushColor(ImGuiCol.Text, UiSharedService.AccentColor, poseCount == maxPoses))
|
||||
ImGui.TextUnformatted($"{poseCount}/{maxPoses} poses attached");
|
||||
ImGuiHelpers.ScaledDummy(5);
|
||||
|
||||
@@ -395,13 +395,13 @@ internal sealed partial class CharaDataHubUi
|
||||
if (!_uiSharedService.IsInGpose && _charaDataManager.BrioAvailable)
|
||||
{
|
||||
ImGuiHelpers.ScaledDummy(5);
|
||||
UiSharedService.DrawGroupedCenteredColorText("To attach pose and world data you need to be in GPose.", ImGuiColors.DalamudYellow);
|
||||
UiSharedService.DrawGroupedCenteredColorText("To attach pose and world data you need to be in GPose.", UiSharedService.AccentColor);
|
||||
ImGuiHelpers.ScaledDummy(5);
|
||||
}
|
||||
else if (!_charaDataManager.BrioAvailable)
|
||||
{
|
||||
ImGuiHelpers.ScaledDummy(5);
|
||||
UiSharedService.DrawGroupedCenteredColorText("To attach pose and world data Brio requires to be installed.", ImGuiColors.DalamudRed);
|
||||
UiSharedService.DrawGroupedCenteredColorText("To attach pose and world data Brio requires to be installed.", UiSharedService.AccentColor);
|
||||
ImGuiHelpers.ScaledDummy(5);
|
||||
}
|
||||
|
||||
@@ -414,7 +414,7 @@ internal sealed partial class CharaDataHubUi
|
||||
if (pose.Id == null)
|
||||
{
|
||||
ImGui.SameLine(50);
|
||||
_uiSharedService.IconText(FontAwesomeIcon.Plus, ImGuiColors.DalamudYellow);
|
||||
_uiSharedService.IconText(FontAwesomeIcon.Plus, UiSharedService.AccentColor);
|
||||
UiSharedService.AttachToolTip("This pose has not been added to the server yet. Save changes to upload this Pose data.");
|
||||
}
|
||||
|
||||
@@ -422,14 +422,14 @@ internal sealed partial class CharaDataHubUi
|
||||
if (poseHasChanges)
|
||||
{
|
||||
ImGui.SameLine(50);
|
||||
_uiSharedService.IconText(FontAwesomeIcon.ExclamationTriangle, ImGuiColors.DalamudYellow);
|
||||
_uiSharedService.IconText(FontAwesomeIcon.ExclamationTriangle, UiSharedService.AccentColor);
|
||||
UiSharedService.AttachToolTip("This pose has changes that have not been saved to the server yet.");
|
||||
}
|
||||
|
||||
ImGui.SameLine(75);
|
||||
if (pose.Description == null && pose.WorldData == null && pose.PoseData == null)
|
||||
{
|
||||
UiSharedService.ColorText("Pose scheduled for deletion", ImGuiColors.DalamudYellow);
|
||||
UiSharedService.ColorText("Pose scheduled for deletion", UiSharedService.AccentColor);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -544,7 +544,8 @@ internal sealed partial class CharaDataHubUi
|
||||
{
|
||||
if (_uiSharedService.IconTextButton(FontAwesomeIcon.ArrowCircleDown, "Download your Online Character Data from Server"))
|
||||
{
|
||||
_ = _charaDataManager.GetAllData(_disposalCts.Token);
|
||||
var cts = EnsureFreshCts(ref _disposalCts);
|
||||
_ = _charaDataManager.GetAllData(cts.Token);
|
||||
}
|
||||
}
|
||||
if (_charaDataManager.DataGetTimeoutTask != null && !_charaDataManager.DataGetTimeoutTask.IsCompleted)
|
||||
@@ -585,7 +586,7 @@ internal sealed partial class CharaDataHubUi
|
||||
var idText = entry.FullId;
|
||||
if (uDto?.HasChanges ?? false)
|
||||
{
|
||||
UiSharedService.ColorText(idText, ImGuiColors.DalamudYellow);
|
||||
UiSharedService.ColorText(idText, UiSharedService.AccentColor);
|
||||
UiSharedService.AttachToolTip("This entry has unsaved changes");
|
||||
}
|
||||
else
|
||||
@@ -640,7 +641,7 @@ internal sealed partial class CharaDataHubUi
|
||||
FontAwesomeIcon eIcon = FontAwesomeIcon.None;
|
||||
if (!Equals(DateTime.MaxValue, entry.ExpiryDate))
|
||||
eIcon = FontAwesomeIcon.Clock;
|
||||
_uiSharedService.IconText(eIcon, ImGuiColors.DalamudYellow);
|
||||
_uiSharedService.IconText(eIcon, UiSharedService.AccentColor);
|
||||
if (ImGui.IsItemClicked()) SelectedDtoId = entry.Id;
|
||||
if (eIcon != FontAwesomeIcon.None)
|
||||
{
|
||||
@@ -654,7 +655,8 @@ internal sealed partial class CharaDataHubUi
|
||||
{
|
||||
if (_uiSharedService.IconTextButton(FontAwesomeIcon.Plus, "New Character Data Entry"))
|
||||
{
|
||||
_charaDataManager.CreateCharaDataEntry(_closalCts.Token);
|
||||
var cts = EnsureFreshCts(ref _closalCts);
|
||||
_charaDataManager.CreateCharaDataEntry(cts.Token);
|
||||
_selectNewEntry = true;
|
||||
}
|
||||
}
|
||||
@@ -675,17 +677,17 @@ internal sealed partial class CharaDataHubUi
|
||||
if (_charaDataManager.OwnCharaData.Count == _charaDataManager.MaxCreatableCharaData)
|
||||
{
|
||||
ImGui.AlignTextToFramePadding();
|
||||
UiSharedService.ColorTextWrapped("You have reached the maximum Character Data entries and cannot create more.", ImGuiColors.DalamudYellow);
|
||||
UiSharedService.ColorTextWrapped("You have reached the maximum Character Data entries and cannot create more.", UiSharedService.AccentColor);
|
||||
}
|
||||
}
|
||||
|
||||
if (_charaDataManager.DataCreationTask != null && !_charaDataManager.DataCreationTask.IsCompleted)
|
||||
{
|
||||
UiSharedService.ColorTextWrapped("Creating new character data entry on server...", ImGuiColors.DalamudYellow);
|
||||
UiSharedService.ColorTextWrapped("Creating new character data entry on server...", UiSharedService.AccentColor);
|
||||
}
|
||||
else if (_charaDataManager.DataCreationTask != null && _charaDataManager.DataCreationTask.IsCompleted)
|
||||
{
|
||||
var color = _charaDataManager.DataCreationTask.Result.Success ? ImGuiColors.HealerGreen : ImGuiColors.DalamudRed;
|
||||
var color = _charaDataManager.DataCreationTask.Result.Success ? ImGuiColors.HealerGreen : UiSharedService.AccentColor;
|
||||
UiSharedService.ColorTextWrapped(_charaDataManager.DataCreationTask.Result.Output, color);
|
||||
}
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ using System.Numerics;
|
||||
|
||||
namespace MareSynchronos.UI;
|
||||
|
||||
internal partial class CharaDataHubUi
|
||||
public sealed partial class CharaDataHubUi
|
||||
{
|
||||
private void DrawNearbyPoses()
|
||||
{
|
||||
@@ -57,6 +57,14 @@ internal partial class CharaDataHubUi
|
||||
_configService.Save();
|
||||
}
|
||||
_uiSharedService.DrawHelpText("Draw floating wisps where other's poses are in the world.");
|
||||
int maxWisps = _configService.Current.NearbyMaxWisps;
|
||||
ImGui.SetNextItemWidth(140);
|
||||
if (ImGui.SliderInt("Maximum wisps", ref maxWisps, 0, 200))
|
||||
{
|
||||
_configService.Current.NearbyMaxWisps = maxWisps;
|
||||
_configService.Save();
|
||||
}
|
||||
_uiSharedService.DrawHelpText("Limit how many wisps are active at once. Set to 0 to disable wisps even when enabled above.");
|
||||
int poseDetectionDistance = _configService.Current.NearbyDistanceFilter;
|
||||
ImGui.SetNextItemWidth(100);
|
||||
if (ImGui.SliderInt("Detection Distance", ref poseDetectionDistance, 5, 1000))
|
||||
@@ -78,7 +86,7 @@ internal partial class CharaDataHubUi
|
||||
if (!_uiSharedService.IsInGpose)
|
||||
{
|
||||
ImGuiHelpers.ScaledDummy(5);
|
||||
UiSharedService.DrawGroupedCenteredColorText("Spawning and applying pose data is only available in GPose.", ImGuiColors.DalamudYellow);
|
||||
UiSharedService.DrawGroupedCenteredColorText("Spawning and applying pose data is only available in GPose.", UiSharedService.AccentColor);
|
||||
ImGuiHelpers.ScaledDummy(5);
|
||||
}
|
||||
|
||||
@@ -93,7 +101,7 @@ internal partial class CharaDataHubUi
|
||||
using var indent = ImRaii.PushIndent(5f);
|
||||
if (_charaDataNearbyManager.NearbyData.Count == 0)
|
||||
{
|
||||
UiSharedService.DrawGroupedCenteredColorText("No Shared World Poses found nearby.", ImGuiColors.DalamudYellow);
|
||||
UiSharedService.DrawGroupedCenteredColorText("No Shared World Poses found nearby.", UiSharedService.AccentColor);
|
||||
}
|
||||
|
||||
bool wasAnythingHovered = false;
|
||||
@@ -196,7 +204,8 @@ internal partial class CharaDataHubUi
|
||||
{
|
||||
if (_uiSharedService.IconTextButton(FontAwesomeIcon.ArrowCircleDown, "Update Data Shared With You"))
|
||||
{
|
||||
_ = _charaDataManager.GetAllSharedData(_disposalCts.Token).ContinueWith(u => UpdateFilteredItems());
|
||||
var cts = EnsureFreshCts(ref _disposalCts);
|
||||
_ = _charaDataManager.GetAllSharedData(cts.Token).ContinueWith(u => UpdateFilteredItems());
|
||||
}
|
||||
}
|
||||
if (_charaDataManager.GetSharedWithYouTimeoutTask != null && !_charaDataManager.GetSharedWithYouTimeoutTask.IsCompleted)
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
using Dalamud.Bindings.ImGui;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Dalamud.Bindings.ImGui;
|
||||
using Dalamud.Interface;
|
||||
using Dalamud.Interface.Colors;
|
||||
using Dalamud.Interface.ImGuiFileDialog;
|
||||
@@ -15,10 +17,13 @@ using MareSynchronos.Services.Mediator;
|
||||
using MareSynchronos.Services.ServerConfiguration;
|
||||
using MareSynchronos.Utils;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
|
||||
namespace MareSynchronos.UI;
|
||||
|
||||
internal sealed partial class CharaDataHubUi : WindowMediatorSubscriberBase
|
||||
public sealed partial class CharaDataHubUi : WindowMediatorSubscriberBase
|
||||
{
|
||||
private const int maxPoses = 10;
|
||||
private readonly CharaDataManager _charaDataManager;
|
||||
@@ -30,9 +35,10 @@ internal sealed partial class CharaDataHubUi : WindowMediatorSubscriberBase
|
||||
private readonly CharaDataGposeTogetherManager _charaDataGposeTogetherManager;
|
||||
private readonly ServerConfigurationManager _serverConfigurationManager;
|
||||
private readonly UiSharedService _uiSharedService;
|
||||
private CancellationTokenSource _closalCts = new();
|
||||
private readonly McdfShareManager _mcdfShareManager;
|
||||
private CancellationTokenSource? _closalCts = new();
|
||||
private bool _disableUI = false;
|
||||
private CancellationTokenSource _disposalCts = new();
|
||||
private CancellationTokenSource? _disposalCts = new();
|
||||
private string _exportDescription = string.Empty;
|
||||
private string _filterCodeNote = string.Empty;
|
||||
private string _filterDescription = string.Empty;
|
||||
@@ -62,6 +68,15 @@ internal sealed partial class CharaDataHubUi : WindowMediatorSubscriberBase
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private static string SanitizeFileName(string? candidate, string fallback)
|
||||
{
|
||||
var invalidChars = Path.GetInvalidFileNameChars();
|
||||
if (string.IsNullOrWhiteSpace(candidate)) return fallback;
|
||||
|
||||
var sanitized = new string(candidate.Select(ch => invalidChars.Contains(ch) ? '_' : ch).ToArray()).Trim('_');
|
||||
return string.IsNullOrWhiteSpace(sanitized) ? fallback : sanitized;
|
||||
}
|
||||
private string _selectedSpecificUserIndividual = string.Empty;
|
||||
private string _selectedSpecificGroupIndividual = string.Empty;
|
||||
private string _sharedWithYouDescriptionFilter = string.Empty;
|
||||
@@ -73,12 +88,21 @@ internal sealed partial class CharaDataHubUi : WindowMediatorSubscriberBase
|
||||
private string? _openComboHybridId = null;
|
||||
private (string Id, string? Alias, string AliasOrId, string? Note)[]? _openComboHybridEntries = null;
|
||||
private bool _comboHybridUsedLastFrame = false;
|
||||
private bool _mcdfShareInitialized;
|
||||
private string _mcdfShareDescription = string.Empty;
|
||||
private readonly List<string> _mcdfShareAllowedIndividuals = new();
|
||||
private readonly List<string> _mcdfShareAllowedSyncshells = new();
|
||||
private string _mcdfShareIndividualDropdownSelection = string.Empty;
|
||||
private string _mcdfShareIndividualInput = string.Empty;
|
||||
private string _mcdfShareSyncshellDropdownSelection = string.Empty;
|
||||
private string _mcdfShareSyncshellInput = string.Empty;
|
||||
private int _mcdfShareExpireDays;
|
||||
|
||||
public CharaDataHubUi(ILogger<CharaDataHubUi> logger, MareMediator mediator, PerformanceCollectorService performanceCollectorService,
|
||||
CharaDataManager charaDataManager, CharaDataNearbyManager charaDataNearbyManager, CharaDataConfigService configService,
|
||||
UiSharedService uiSharedService, ServerConfigurationManager serverConfigurationManager,
|
||||
DalamudUtilService dalamudUtilService, FileDialogManager fileDialogManager, PairManager pairManager,
|
||||
CharaDataGposeTogetherManager charaDataGposeTogetherManager)
|
||||
CharaDataGposeTogetherManager charaDataGposeTogetherManager, McdfShareManager mcdfShareManager)
|
||||
: base(logger, mediator, "Umbra Character Data Hub###UmbraCharaDataUI", performanceCollectorService)
|
||||
{
|
||||
SetWindowSizeConstraints();
|
||||
@@ -92,6 +116,7 @@ internal sealed partial class CharaDataHubUi : WindowMediatorSubscriberBase
|
||||
_fileDialogManager = fileDialogManager;
|
||||
_pairManager = pairManager;
|
||||
_charaDataGposeTogetherManager = charaDataGposeTogetherManager;
|
||||
_mcdfShareManager = mcdfShareManager;
|
||||
Mediator.Subscribe<GposeStartMessage>(this, (_) => IsOpen |= _configService.Current.OpenMareHubOnGposeStart);
|
||||
Mediator.Subscribe<OpenCharaDataHubWithFilterMessage>(this, (msg) =>
|
||||
{
|
||||
@@ -123,7 +148,14 @@ internal sealed partial class CharaDataHubUi : WindowMediatorSubscriberBase
|
||||
return;
|
||||
}
|
||||
|
||||
_closalCts.Cancel();
|
||||
try
|
||||
{
|
||||
_closalCts?.Cancel();
|
||||
}
|
||||
catch (ObjectDisposedException)
|
||||
{
|
||||
}
|
||||
EnsureFreshCts(ref _closalCts);
|
||||
SelectedDtoId = string.Empty;
|
||||
_filteredDict = null;
|
||||
_sharedWithYouOwnerFilter = string.Empty;
|
||||
@@ -135,21 +167,34 @@ internal sealed partial class CharaDataHubUi : WindowMediatorSubscriberBase
|
||||
|
||||
public override void OnOpen()
|
||||
{
|
||||
_closalCts = _closalCts.CancelRecreate();
|
||||
EnsureFreshCts(ref _closalCts);
|
||||
}
|
||||
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing)
|
||||
{
|
||||
_closalCts.CancelDispose();
|
||||
_disposalCts.CancelDispose();
|
||||
CancelAndDispose(ref _closalCts);
|
||||
CancelAndDispose(ref _disposalCts);
|
||||
}
|
||||
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
protected override void DrawInternal()
|
||||
{
|
||||
DrawHubContent();
|
||||
}
|
||||
|
||||
public void DrawInline()
|
||||
{
|
||||
using (ImRaii.PushId("CharaDataHubInline"))
|
||||
{
|
||||
DrawHubContent();
|
||||
}
|
||||
}
|
||||
|
||||
private void DrawHubContent()
|
||||
{
|
||||
if (!_comboHybridUsedLastFrame)
|
||||
{
|
||||
@@ -170,7 +215,7 @@ internal sealed partial class CharaDataHubUi : WindowMediatorSubscriberBase
|
||||
if (!_charaDataManager.BrioAvailable)
|
||||
{
|
||||
ImGuiHelpers.ScaledDummy(3);
|
||||
UiSharedService.DrawGroupedCenteredColorText("To utilize any features related to posing or spawning characters you require to have Brio installed.", ImGuiColors.DalamudRed);
|
||||
UiSharedService.DrawGroupedCenteredColorText("To utilize any features related to posing or spawning characters you require to have Brio installed.", UiSharedService.AccentColor);
|
||||
UiSharedService.DistanceSeparator();
|
||||
}
|
||||
|
||||
@@ -190,18 +235,22 @@ internal sealed partial class CharaDataHubUi : WindowMediatorSubscriberBase
|
||||
}
|
||||
if (!string.IsNullOrEmpty(_charaDataManager.DataApplicationProgress))
|
||||
{
|
||||
UiSharedService.ColorTextWrapped(_charaDataManager.DataApplicationProgress, ImGuiColors.DalamudYellow);
|
||||
UiSharedService.ColorTextWrapped(_charaDataManager.DataApplicationProgress, UiSharedService.AccentColor);
|
||||
}
|
||||
if (_charaDataManager.DataApplicationTask != null)
|
||||
{
|
||||
UiSharedService.ColorTextWrapped("WARNING: During the data application avoid interacting with this actor to prevent potential crashes.", ImGuiColors.DalamudRed);
|
||||
UiSharedService.ColorTextWrapped("WARNING: During the data application avoid interacting with this actor to prevent potential crashes.", UiSharedService.AccentColor);
|
||||
ImGuiHelpers.ScaledDummy(5);
|
||||
ImGui.Separator();
|
||||
}
|
||||
});
|
||||
|
||||
using var tabs = ImRaii.TabBar("TabsTopLevel");
|
||||
bool smallUi = false;
|
||||
using (var topTabColor = ImRaii.PushColor(ImGuiCol.Tab, UiSharedService.AccentColor))
|
||||
using (var topTabHoverColor = ImRaii.PushColor(ImGuiCol.TabHovered, UiSharedService.AccentHoverColor))
|
||||
using (var topTabActiveColor = ImRaii.PushColor(ImGuiCol.TabActive, UiSharedService.AccentActiveColor))
|
||||
{
|
||||
using var tabs = ImRaii.TabBar("TabsTopLevel");
|
||||
|
||||
_isHandlingSelf = _charaDataManager.HandledCharaData.Any(c => c.Value.IsSelf);
|
||||
if (_isHandlingSelf) _openMcdOnlineOnNextRun = false;
|
||||
@@ -221,6 +270,10 @@ internal sealed partial class CharaDataHubUi : WindowMediatorSubscriberBase
|
||||
if (applicationTabItem)
|
||||
{
|
||||
smallUi = true;
|
||||
using (var appTabColor = ImRaii.PushColor(ImGuiCol.Tab, UiSharedService.AccentColor))
|
||||
using (var appTabHoverColor = ImRaii.PushColor(ImGuiCol.TabHovered, UiSharedService.AccentHoverColor))
|
||||
using (var appTabActiveColor = ImRaii.PushColor(ImGuiCol.TabActive, UiSharedService.AccentActiveColor))
|
||||
{
|
||||
using var appTabs = ImRaii.TabBar("TabsApplicationLevel");
|
||||
|
||||
using (ImRaii.Disabled(!_uiSharedService.IsInGpose))
|
||||
@@ -262,6 +315,7 @@ internal sealed partial class CharaDataHubUi : WindowMediatorSubscriberBase
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_charaDataNearbyManager.ComputeNearbyData = false;
|
||||
@@ -280,6 +334,10 @@ internal sealed partial class CharaDataHubUi : WindowMediatorSubscriberBase
|
||||
using (var creationTabItem = ImRaii.TabItem("Data Creation", flagsTopLevel))
|
||||
{
|
||||
if (creationTabItem)
|
||||
{
|
||||
using (var creationTabColor = ImRaii.PushColor(ImGuiCol.Tab, UiSharedService.AccentColor))
|
||||
using (var creationTabHoverColor = ImRaii.PushColor(ImGuiCol.TabHovered, UiSharedService.AccentHoverColor))
|
||||
using (var creationTabActiveColor = ImRaii.PushColor(ImGuiCol.TabActive, UiSharedService.AccentActiveColor))
|
||||
{
|
||||
using var creationTabs = ImRaii.TabBar("TabsCreationLevel");
|
||||
|
||||
@@ -306,9 +364,21 @@ internal sealed partial class CharaDataHubUi : WindowMediatorSubscriberBase
|
||||
DrawMcdfExport();
|
||||
}
|
||||
}
|
||||
|
||||
using (var mcdfShareTabItem = ImRaii.TabItem("Partage MCDF"))
|
||||
{
|
||||
if (mcdfShareTabItem)
|
||||
{
|
||||
using var id = ImRaii.PushId("mcdfShare");
|
||||
DrawMcdfShare();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (_isHandlingSelf)
|
||||
{
|
||||
UiSharedService.AttachToolTip("Cannot use creation tools while having Character Data applied to self.");
|
||||
@@ -436,11 +506,15 @@ internal sealed partial class CharaDataHubUi : WindowMediatorSubscriberBase
|
||||
if (!_hasValidGposeTarget)
|
||||
{
|
||||
ImGuiHelpers.ScaledDummy(3);
|
||||
UiSharedService.DrawGroupedCenteredColorText("Applying data is only available in GPose with a valid selected GPose target.", ImGuiColors.DalamudYellow, 350);
|
||||
UiSharedService.DrawGroupedCenteredColorText("Applying data is only available in GPose with a valid selected GPose target.", UiSharedService.AccentColor, 350);
|
||||
}
|
||||
|
||||
ImGuiHelpers.ScaledDummy(10);
|
||||
|
||||
using (var applyTabColor = ImRaii.PushColor(ImGuiCol.Tab, UiSharedService.AccentColor))
|
||||
using (var applyTabHoverColor = ImRaii.PushColor(ImGuiCol.TabHovered, UiSharedService.AccentHoverColor))
|
||||
using (var applyTabActiveColor = ImRaii.PushColor(ImGuiCol.TabActive, UiSharedService.AccentActiveColor))
|
||||
{
|
||||
using var tabs = ImRaii.TabBar("Tabs");
|
||||
|
||||
using (var byFavoriteTabItem = ImRaii.TabItem("Favorites"))
|
||||
@@ -595,7 +669,7 @@ internal sealed partial class CharaDataHubUi : WindowMediatorSubscriberBase
|
||||
|
||||
if (_configService.Current.FavoriteCodes.Count == 0)
|
||||
{
|
||||
UiSharedService.ColorTextWrapped("You have no favorites added. Add Favorites through the other tabs before you can use this tab.", ImGuiColors.DalamudYellow);
|
||||
UiSharedService.ColorTextWrapped("You have no favorites added. Add Favorites through the other tabs before you can use this tab.", UiSharedService.AccentColor);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -644,11 +718,11 @@ internal sealed partial class CharaDataHubUi : WindowMediatorSubscriberBase
|
||||
ImGui.NewLine();
|
||||
if (!_charaDataManager.DownloadMetaInfoTask?.IsCompleted ?? false)
|
||||
{
|
||||
UiSharedService.ColorTextWrapped("Downloading meta info. Please wait.", ImGuiColors.DalamudYellow);
|
||||
UiSharedService.ColorTextWrapped("Downloading meta info. Please wait.", UiSharedService.AccentColor);
|
||||
}
|
||||
if ((_charaDataManager.DownloadMetaInfoTask?.IsCompleted ?? false) && !_charaDataManager.DownloadMetaInfoTask.Result.Success)
|
||||
{
|
||||
UiSharedService.ColorTextWrapped(_charaDataManager.DownloadMetaInfoTask.Result.Result, ImGuiColors.DalamudRed);
|
||||
UiSharedService.ColorTextWrapped(_charaDataManager.DownloadMetaInfoTask.Result.Result, UiSharedService.AccentColor);
|
||||
}
|
||||
|
||||
using (ImRaii.Disabled(_charaDataManager.LastDownloadedMetaInfo == null))
|
||||
@@ -689,7 +763,8 @@ internal sealed partial class CharaDataHubUi : WindowMediatorSubscriberBase
|
||||
{
|
||||
if (_uiSharedService.IconTextButton(FontAwesomeIcon.ArrowCircleDown, "Download your Character Data"))
|
||||
{
|
||||
_ = _charaDataManager.GetAllData(_disposalCts.Token);
|
||||
var cts = EnsureFreshCts(ref _disposalCts);
|
||||
_ = _charaDataManager.GetAllData(cts.Token);
|
||||
}
|
||||
}
|
||||
if (_charaDataManager.DataGetTimeoutTask != null && !_charaDataManager.DataGetTimeoutTask.IsCompleted)
|
||||
@@ -848,14 +923,15 @@ internal sealed partial class CharaDataHubUi : WindowMediatorSubscriberBase
|
||||
if ((_charaDataManager.LoadedMcdfHeader?.IsFaulted ?? false) || (_charaDataManager.McdfApplicationTask?.IsFaulted ?? false))
|
||||
{
|
||||
UiSharedService.ColorTextWrapped("Failure to read MCDF file. MCDF file is possibly corrupt. Re-export the MCDF file and try again.",
|
||||
ImGuiColors.DalamudRed);
|
||||
UiSharedService.AccentColor);
|
||||
UiSharedService.ColorTextWrapped("Note: if this is your MCDF, try redrawing yourself, wait and re-export the file. " +
|
||||
"If you received it from someone else have them do the same.", ImGuiColors.DalamudYellow);
|
||||
"If you received it from someone else have them do the same.", UiSharedService.AccentColor);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
UiSharedService.ColorTextWrapped("Loading Character...", ImGuiColors.DalamudYellow);
|
||||
UiSharedService.ColorTextWrapped("Loading Character...", UiSharedService.AccentColor);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -883,7 +959,7 @@ internal sealed partial class CharaDataHubUi : WindowMediatorSubscriberBase
|
||||
{
|
||||
string defaultFileName = string.IsNullOrEmpty(_exportDescription)
|
||||
? "export.mcdf"
|
||||
: string.Join('_', $"{_exportDescription}.mcdf".Split(Path.GetInvalidFileNameChars()));
|
||||
: SanitizeFileName(_exportDescription, "export") + ".mcdf";
|
||||
_uiSharedService.FileDialogManager.SaveFileDialog("Export Character to file", ".mcdf", defaultFileName, ".mcdf", (success, path) =>
|
||||
{
|
||||
if (!success) return;
|
||||
@@ -896,12 +972,469 @@ internal sealed partial class CharaDataHubUi : WindowMediatorSubscriberBase
|
||||
}, Directory.Exists(_configService.Current.LastSavedCharaDataLocation) ? _configService.Current.LastSavedCharaDataLocation : null);
|
||||
}
|
||||
UiSharedService.ColorTextWrapped("Note: For best results make sure you have everything you want to be shared as well as the correct character appearance" +
|
||||
" equipped and redraw your character before exporting.", ImGuiColors.DalamudYellow);
|
||||
" equipped and redraw your character before exporting.", UiSharedService.AccentColor);
|
||||
|
||||
ImGui.Unindent();
|
||||
}
|
||||
}
|
||||
|
||||
private void DrawMcdfShare()
|
||||
{
|
||||
if (!_mcdfShareInitialized && !_mcdfShareManager.IsBusy)
|
||||
{
|
||||
_mcdfShareInitialized = true;
|
||||
_ = _mcdfShareManager.RefreshAsync(CancellationToken.None);
|
||||
}
|
||||
|
||||
if (_mcdfShareManager.IsBusy)
|
||||
{
|
||||
UiSharedService.ColorTextWrapped("Traitement en cours...", ImGuiColors.DalamudYellow);
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(_mcdfShareManager.LastError))
|
||||
{
|
||||
UiSharedService.ColorTextWrapped(_mcdfShareManager.LastError!, ImGuiColors.DalamudRed);
|
||||
}
|
||||
else if (!string.IsNullOrEmpty(_mcdfShareManager.LastSuccess))
|
||||
{
|
||||
UiSharedService.ColorTextWrapped(_mcdfShareManager.LastSuccess!, ImGuiColors.HealerGreen);
|
||||
}
|
||||
|
||||
if (ImGui.Button("Actualiser les partages"))
|
||||
{
|
||||
_ = _mcdfShareManager.RefreshAsync(CancellationToken.None);
|
||||
}
|
||||
|
||||
ImGui.Separator();
|
||||
_uiSharedService.BigText("Créer un partage MCDF");
|
||||
|
||||
ImGui.InputTextWithHint("##mcdfShareDescription", "Description", ref _mcdfShareDescription, 128);
|
||||
ImGui.InputInt("Expiration (jours, 0 = jamais)", ref _mcdfShareExpireDays);
|
||||
|
||||
DrawMcdfShareIndividualDropdown();
|
||||
ImGui.SameLine();
|
||||
ImGui.SetNextItemWidth(220f);
|
||||
if (ImGui.InputTextWithHint("##mcdfShareUidInput", "UID ou vanity", ref _mcdfShareIndividualInput, 32))
|
||||
{
|
||||
_mcdfShareIndividualDropdownSelection = string.Empty;
|
||||
}
|
||||
ImGui.SameLine();
|
||||
var normalizedUid = NormalizeUidCandidate(_mcdfShareIndividualInput);
|
||||
using (ImRaii.Disabled(string.IsNullOrEmpty(normalizedUid)
|
||||
|| _mcdfShareAllowedIndividuals.Any(p => string.Equals(p, normalizedUid, StringComparison.OrdinalIgnoreCase))))
|
||||
{
|
||||
if (ImGui.SmallButton("Ajouter"))
|
||||
{
|
||||
_mcdfShareAllowedIndividuals.Add(normalizedUid);
|
||||
_mcdfShareIndividualInput = string.Empty;
|
||||
_mcdfShareIndividualDropdownSelection = string.Empty;
|
||||
}
|
||||
}
|
||||
ImGui.SameLine();
|
||||
ImGui.TextUnformatted("UID synchronisé à ajouter");
|
||||
_uiSharedService.DrawHelpText("Choisissez un pair synchronisé dans la liste ou saisissez un UID. Les utilisateurs listés pourront récupérer ce partage MCDF.");
|
||||
|
||||
foreach (var uid in _mcdfShareAllowedIndividuals.ToArray())
|
||||
{
|
||||
using (ImRaii.PushId("mcdfShareUid" + uid))
|
||||
{
|
||||
ImGui.BulletText(FormatPairLabel(uid));
|
||||
ImGui.SameLine();
|
||||
if (ImGui.SmallButton("Retirer"))
|
||||
{
|
||||
_mcdfShareAllowedIndividuals.Remove(uid);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
DrawMcdfShareSyncshellDropdown();
|
||||
ImGui.SameLine();
|
||||
ImGui.SetNextItemWidth(220f);
|
||||
if (ImGui.InputTextWithHint("##mcdfShareSyncshellInput", "GID ou alias", ref _mcdfShareSyncshellInput, 32))
|
||||
{
|
||||
_mcdfShareSyncshellDropdownSelection = string.Empty;
|
||||
}
|
||||
ImGui.SameLine();
|
||||
var normalizedSyncshell = NormalizeSyncshellCandidate(_mcdfShareSyncshellInput);
|
||||
using (ImRaii.Disabled(string.IsNullOrEmpty(normalizedSyncshell)
|
||||
|| _mcdfShareAllowedSyncshells.Any(p => string.Equals(p, normalizedSyncshell, StringComparison.OrdinalIgnoreCase))))
|
||||
{
|
||||
if (ImGui.SmallButton("Ajouter"))
|
||||
{
|
||||
_mcdfShareAllowedSyncshells.Add(normalizedSyncshell);
|
||||
_mcdfShareSyncshellInput = string.Empty;
|
||||
_mcdfShareSyncshellDropdownSelection = string.Empty;
|
||||
}
|
||||
}
|
||||
ImGui.SameLine();
|
||||
ImGui.TextUnformatted("Syncshell à ajouter");
|
||||
_uiSharedService.DrawHelpText("Sélectionnez une syncshell synchronisée ou saisissez un identifiant. Les syncshells listées auront accès au partage.");
|
||||
|
||||
foreach (var shell in _mcdfShareAllowedSyncshells.ToArray())
|
||||
{
|
||||
using (ImRaii.PushId("mcdfShareShell" + shell))
|
||||
{
|
||||
ImGui.BulletText(FormatSyncshellLabel(shell));
|
||||
ImGui.SameLine();
|
||||
if (ImGui.SmallButton("Retirer"))
|
||||
{
|
||||
_mcdfShareAllowedSyncshells.Remove(shell);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
using (ImRaii.Disabled(_mcdfShareManager.IsBusy))
|
||||
{
|
||||
if (ImGui.Button("Créer"))
|
||||
{
|
||||
DateTime? expiresAt = _mcdfShareExpireDays <= 0 ? null : DateTime.UtcNow.AddDays(_mcdfShareExpireDays);
|
||||
_ = _mcdfShareManager.CreateShareAsync(_mcdfShareDescription, _mcdfShareAllowedIndividuals.ToList(), _mcdfShareAllowedSyncshells.ToList(), expiresAt, CancellationToken.None);
|
||||
_mcdfShareDescription = string.Empty;
|
||||
_mcdfShareAllowedIndividuals.Clear();
|
||||
_mcdfShareAllowedSyncshells.Clear();
|
||||
_mcdfShareIndividualInput = string.Empty;
|
||||
_mcdfShareIndividualDropdownSelection = string.Empty;
|
||||
_mcdfShareSyncshellInput = string.Empty;
|
||||
_mcdfShareSyncshellDropdownSelection = string.Empty;
|
||||
_mcdfShareExpireDays = 0;
|
||||
}
|
||||
}
|
||||
|
||||
ImGui.Separator();
|
||||
_uiSharedService.BigText("Mes partages : ");
|
||||
|
||||
if (_mcdfShareManager.OwnShares.Count == 0)
|
||||
{
|
||||
ImGui.TextDisabled("Aucun partage MCDF créé.");
|
||||
}
|
||||
else if (ImGui.BeginTable("mcdf-own-shares", 6, ImGuiTableFlags.SizingStretchProp | ImGuiTableFlags.RowBg | ImGuiTableFlags.BordersOuter))
|
||||
{
|
||||
ImGui.TableSetupColumn("Description");
|
||||
ImGui.TableSetupColumn("Créé le");
|
||||
ImGui.TableSetupColumn("Expire");
|
||||
ImGui.TableSetupColumn("Téléchargements");
|
||||
ImGui.TableSetupColumn("Accès");
|
||||
var style = ImGui.GetStyle();
|
||||
float BtnWidth(string label) => ImGui.CalcTextSize(label).X + style.FramePadding.X * 2f;
|
||||
float ownActionsWidth = BtnWidth("Appliquer en GPose") + style.ItemSpacing.X + BtnWidth("Enregistrer") + style.ItemSpacing.X + BtnWidth("Supprimer") + 2f; // small margin
|
||||
ImGui.TableSetupColumn("Actions", ImGuiTableColumnFlags.WidthFixed, ownActionsWidth);
|
||||
ImGui.TableHeadersRow();
|
||||
|
||||
foreach (var entry in _mcdfShareManager.OwnShares)
|
||||
{
|
||||
ImGui.TableNextRow();
|
||||
ImGui.TableNextColumn();
|
||||
ImGui.TextUnformatted(string.IsNullOrEmpty(entry.Description) ? entry.Id.ToString() : entry.Description);
|
||||
|
||||
ImGui.TableNextColumn();
|
||||
ImGui.TextUnformatted(entry.CreatedUtc.ToLocalTime().ToString("g"));
|
||||
|
||||
ImGui.TableNextColumn();
|
||||
ImGui.TextUnformatted(entry.ExpiresAtUtc.HasValue ? entry.ExpiresAtUtc.Value.ToLocalTime().ToString("g") : "Jamais");
|
||||
|
||||
ImGui.TableNextColumn();
|
||||
ImGui.TextUnformatted(entry.DownloadCount.ToString());
|
||||
|
||||
ImGui.TableNextColumn();
|
||||
ImGui.TextUnformatted($"UID : {entry.AllowedIndividuals.Count}, Syncshells : {entry.AllowedSyncshells.Count}");
|
||||
if (ImGui.IsItemHovered())
|
||||
{
|
||||
ImGui.BeginTooltip();
|
||||
if (entry.AllowedIndividuals.Count > 0)
|
||||
{
|
||||
ImGui.TextUnformatted("UID autorisés:");
|
||||
foreach (var uid in entry.AllowedIndividuals)
|
||||
ImGui.BulletText(FormatUidWithName(uid));
|
||||
}
|
||||
else
|
||||
{
|
||||
ImGui.TextDisabled("Aucun UID autorisé");
|
||||
}
|
||||
ImGui.Separator();
|
||||
if (entry.AllowedSyncshells.Count > 0)
|
||||
{
|
||||
ImGui.TextUnformatted("Syncshells autorisées:");
|
||||
foreach (var gid in entry.AllowedSyncshells)
|
||||
ImGui.BulletText(FormatSyncshellLabel(gid));
|
||||
}
|
||||
else
|
||||
{
|
||||
ImGui.TextDisabled("Aucune syncshell autorisée");
|
||||
}
|
||||
ImGui.EndTooltip();
|
||||
}
|
||||
|
||||
ImGui.TableNextColumn();
|
||||
using (ImRaii.PushId("ownShare" + entry.Id))
|
||||
{
|
||||
if (ImGui.SmallButton("Appliquer en GPose"))
|
||||
{
|
||||
_ = _mcdfShareManager.ApplyShareAsync(entry.Id, CancellationToken.None);
|
||||
}
|
||||
ImGui.SameLine();
|
||||
if (ImGui.SmallButton("Enregistrer"))
|
||||
{
|
||||
var baseName = SanitizeFileName(entry.Description, entry.Id.ToString());
|
||||
var defaultName = baseName + ".mcdf";
|
||||
_fileDialogManager.SaveFileDialog("Enregistrer le partage MCDF", ".mcdf", defaultName, ".mcdf", async (success, path) =>
|
||||
{
|
||||
if (!success || string.IsNullOrEmpty(path)) return;
|
||||
await _mcdfShareManager.ExportShareAsync(entry.Id, path, CancellationToken.None).ConfigureAwait(false);
|
||||
});
|
||||
}
|
||||
ImGui.SameLine();
|
||||
if (ImGui.SmallButton("Supprimer"))
|
||||
{
|
||||
_ = _mcdfShareManager.DeleteShareAsync(entry.Id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ImGui.EndTable();
|
||||
}
|
||||
|
||||
ImGui.Separator();
|
||||
_uiSharedService.BigText("Partagés avec moi : ");
|
||||
|
||||
if (_mcdfShareManager.SharedShares.Count == 0)
|
||||
{
|
||||
ImGui.TextDisabled("Aucun partage MCDF reçu.");
|
||||
}
|
||||
else if (ImGui.BeginTable("mcdf-shared-shares", 5, ImGuiTableFlags.SizingStretchProp | ImGuiTableFlags.RowBg | ImGuiTableFlags.BordersOuter))
|
||||
{
|
||||
ImGui.TableSetupColumn("Description");
|
||||
ImGui.TableSetupColumn("Propriétaire");
|
||||
ImGui.TableSetupColumn("Expire");
|
||||
ImGui.TableSetupColumn("Téléchargements");
|
||||
var style2 = ImGui.GetStyle();
|
||||
float BtnWidth2(string label) => ImGui.CalcTextSize(label).X + style2.FramePadding.X * 2f;
|
||||
float sharedActionsWidth = BtnWidth2("Appliquer") + style2.ItemSpacing.X + BtnWidth2("Enregistrer") + 2f;
|
||||
ImGui.TableSetupColumn("Actions", ImGuiTableColumnFlags.WidthFixed, sharedActionsWidth);
|
||||
ImGui.TableHeadersRow();
|
||||
|
||||
foreach (var entry in _mcdfShareManager.SharedShares)
|
||||
{
|
||||
ImGui.TableNextRow();
|
||||
ImGui.TableNextColumn();
|
||||
ImGui.TextUnformatted(string.IsNullOrEmpty(entry.Description) ? entry.Id.ToString() : entry.Description);
|
||||
|
||||
ImGui.TableNextColumn();
|
||||
ImGui.TextUnformatted(string.IsNullOrEmpty(entry.OwnerAlias) ? entry.OwnerUid : entry.OwnerAlias);
|
||||
if (ImGui.IsItemHovered())
|
||||
{
|
||||
ImGui.BeginTooltip();
|
||||
ImGui.TextUnformatted($"UID propriétaire: {entry.OwnerUid}");
|
||||
if (!string.IsNullOrEmpty(entry.OwnerAlias))
|
||||
{
|
||||
ImGui.Separator();
|
||||
ImGui.TextUnformatted($"Alias: {entry.OwnerAlias}");
|
||||
}
|
||||
ImGui.EndTooltip();
|
||||
}
|
||||
|
||||
ImGui.TableNextColumn();
|
||||
ImGui.TextUnformatted(entry.ExpiresAtUtc.HasValue ? entry.ExpiresAtUtc.Value.ToLocalTime().ToString("g") : "Jamais");
|
||||
|
||||
ImGui.TableNextColumn();
|
||||
ImGui.TextUnformatted(entry.DownloadCount.ToString());
|
||||
|
||||
ImGui.TableNextColumn();
|
||||
using (ImRaii.PushId("sharedShare" + entry.Id))
|
||||
{
|
||||
if (ImGui.SmallButton("Appliquer"))
|
||||
{
|
||||
_ = _mcdfShareManager.ApplyShareAsync(entry.Id, CancellationToken.None);
|
||||
}
|
||||
ImGui.SameLine();
|
||||
if (ImGui.SmallButton("Enregistrer"))
|
||||
{
|
||||
var baseName = SanitizeFileName(entry.Description, entry.Id.ToString());
|
||||
var defaultName = baseName + ".mcdf";
|
||||
_fileDialogManager.SaveFileDialog("Enregistrer le partage MCDF", ".mcdf", defaultName, ".mcdf", async (success, path) =>
|
||||
{
|
||||
if (!success || string.IsNullOrEmpty(path)) return;
|
||||
await _mcdfShareManager.ExportShareAsync(entry.Id, path, CancellationToken.None).ConfigureAwait(false);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ImGui.EndTable();
|
||||
}
|
||||
}
|
||||
|
||||
private void DrawMcdfShareIndividualDropdown()
|
||||
{
|
||||
ImGui.SetNextItemWidth(220f);
|
||||
var previewSource = string.IsNullOrEmpty(_mcdfShareIndividualDropdownSelection)
|
||||
? _mcdfShareIndividualInput
|
||||
: _mcdfShareIndividualDropdownSelection;
|
||||
var previewLabel = string.IsNullOrEmpty(previewSource)
|
||||
? "Sélectionner un pair synchronisé..."
|
||||
: FormatPairLabel(previewSource);
|
||||
|
||||
using var combo = ImRaii.Combo("##mcdfShareUidDropdown", previewLabel, ImGuiComboFlags.None);
|
||||
if (!combo)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
foreach (var pair in _pairManager.DirectPairs
|
||||
.OrderBy(p => p.GetNoteOrName() ?? p.UserData.AliasOrUID, StringComparer.OrdinalIgnoreCase))
|
||||
{
|
||||
var normalized = pair.UserData.UID;
|
||||
var display = FormatPairLabel(normalized);
|
||||
bool selected = string.Equals(normalized, _mcdfShareIndividualDropdownSelection, StringComparison.OrdinalIgnoreCase);
|
||||
if (ImGui.Selectable(display, selected))
|
||||
{
|
||||
_mcdfShareIndividualDropdownSelection = normalized;
|
||||
_mcdfShareIndividualInput = normalized;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void DrawMcdfShareSyncshellDropdown()
|
||||
{
|
||||
ImGui.SetNextItemWidth(220f);
|
||||
var previewSource = string.IsNullOrEmpty(_mcdfShareSyncshellDropdownSelection)
|
||||
? _mcdfShareSyncshellInput
|
||||
: _mcdfShareSyncshellDropdownSelection;
|
||||
var previewLabel = string.IsNullOrEmpty(previewSource)
|
||||
? "Sélectionner une syncshell..."
|
||||
: FormatSyncshellLabel(previewSource);
|
||||
|
||||
using var combo = ImRaii.Combo("##mcdfShareSyncshellDropdown", previewLabel, ImGuiComboFlags.None);
|
||||
if (!combo)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
foreach (var group in _pairManager.Groups.Values
|
||||
.OrderBy(g => _serverConfigurationManager.GetNoteForGid(g.GID) ?? g.GroupAliasOrGID, StringComparer.OrdinalIgnoreCase))
|
||||
{
|
||||
var gid = group.GID;
|
||||
var display = FormatSyncshellLabel(gid);
|
||||
bool selected = string.Equals(gid, _mcdfShareSyncshellDropdownSelection, StringComparison.OrdinalIgnoreCase);
|
||||
if (ImGui.Selectable(display, selected))
|
||||
{
|
||||
_mcdfShareSyncshellDropdownSelection = gid;
|
||||
_mcdfShareSyncshellInput = gid;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private string NormalizeUidCandidate(string candidate)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(candidate))
|
||||
{
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
var trimmed = candidate.Trim();
|
||||
|
||||
foreach (var pair in _pairManager.DirectPairs)
|
||||
{
|
||||
var alias = pair.UserData.Alias;
|
||||
var aliasOrUid = pair.UserData.AliasOrUID;
|
||||
var note = pair.GetNoteOrName();
|
||||
|
||||
if (string.Equals(pair.UserData.UID, trimmed, StringComparison.OrdinalIgnoreCase)
|
||||
|| (!string.IsNullOrEmpty(alias) && string.Equals(alias, trimmed, StringComparison.OrdinalIgnoreCase))
|
||||
|| string.Equals(aliasOrUid, trimmed, StringComparison.OrdinalIgnoreCase)
|
||||
|| (!string.IsNullOrEmpty(note) && string.Equals(note, trimmed, StringComparison.OrdinalIgnoreCase)))
|
||||
{
|
||||
return pair.UserData.UID;
|
||||
}
|
||||
}
|
||||
|
||||
return trimmed.ToUpperInvariant();
|
||||
}
|
||||
|
||||
private string NormalizeSyncshellCandidate(string candidate)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(candidate))
|
||||
{
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
var trimmed = candidate.Trim();
|
||||
|
||||
foreach (var group in _pairManager.Groups.Values)
|
||||
{
|
||||
var alias = group.GroupAlias;
|
||||
var aliasOrGid = group.GroupAliasOrGID;
|
||||
var note = _serverConfigurationManager.GetNoteForGid(group.GID);
|
||||
|
||||
if (string.Equals(group.GID, trimmed, StringComparison.OrdinalIgnoreCase)
|
||||
|| (!string.IsNullOrEmpty(alias) && string.Equals(alias, trimmed, StringComparison.OrdinalIgnoreCase))
|
||||
|| string.Equals(aliasOrGid, trimmed, StringComparison.OrdinalIgnoreCase)
|
||||
|| (!string.IsNullOrEmpty(note) && string.Equals(note, trimmed, StringComparison.OrdinalIgnoreCase)))
|
||||
{
|
||||
return group.GID;
|
||||
}
|
||||
}
|
||||
|
||||
return trimmed.ToUpperInvariant();
|
||||
}
|
||||
|
||||
private string FormatUidWithName(string uid)
|
||||
{
|
||||
if (string.IsNullOrEmpty(uid)) return string.Empty;
|
||||
var note = _serverConfigurationManager.GetNoteForUid(uid);
|
||||
if (!string.IsNullOrEmpty(note)) return $"{uid} ({note})";
|
||||
return uid;
|
||||
}
|
||||
|
||||
private string FormatPairLabel(string candidate)
|
||||
{
|
||||
if (string.IsNullOrEmpty(candidate))
|
||||
{
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
foreach (var pair in _pairManager.DirectPairs)
|
||||
{
|
||||
var alias = pair.UserData.Alias;
|
||||
var aliasOrUid = pair.UserData.AliasOrUID;
|
||||
var note = pair.GetNoteOrName();
|
||||
|
||||
if (string.Equals(pair.UserData.UID, candidate, StringComparison.OrdinalIgnoreCase)
|
||||
|| (!string.IsNullOrEmpty(alias) && string.Equals(alias, candidate, StringComparison.OrdinalIgnoreCase))
|
||||
|| string.Equals(aliasOrUid, candidate, StringComparison.OrdinalIgnoreCase)
|
||||
|| (!string.IsNullOrEmpty(note) && string.Equals(note, candidate, StringComparison.OrdinalIgnoreCase)))
|
||||
{
|
||||
return string.IsNullOrEmpty(note) ? aliasOrUid : $"{note} ({aliasOrUid})";
|
||||
}
|
||||
}
|
||||
|
||||
return candidate;
|
||||
}
|
||||
|
||||
private string FormatSyncshellLabel(string candidate)
|
||||
{
|
||||
if (string.IsNullOrEmpty(candidate))
|
||||
{
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
foreach (var group in _pairManager.Groups.Values)
|
||||
{
|
||||
var alias = group.GroupAlias;
|
||||
var aliasOrGid = group.GroupAliasOrGID;
|
||||
var note = _serverConfigurationManager.GetNoteForGid(group.GID);
|
||||
|
||||
if (string.Equals(group.GID, candidate, StringComparison.OrdinalIgnoreCase)
|
||||
|| (!string.IsNullOrEmpty(alias) && string.Equals(alias, candidate, StringComparison.OrdinalIgnoreCase))
|
||||
|| string.Equals(aliasOrGid, candidate, StringComparison.OrdinalIgnoreCase)
|
||||
|| (!string.IsNullOrEmpty(note) && string.Equals(note, candidate, StringComparison.OrdinalIgnoreCase)))
|
||||
{
|
||||
return string.IsNullOrEmpty(note) ? aliasOrGid : $"{note} ({aliasOrGid})";
|
||||
}
|
||||
}
|
||||
|
||||
return candidate;
|
||||
}
|
||||
|
||||
private void DrawMetaInfoData(string selectedGposeActor, bool hasValidGposeTarget, CharaDataMetaInfoExtendedDto data, bool canOpen = false)
|
||||
{
|
||||
ImGuiHelpers.ScaledDummy(5);
|
||||
@@ -1104,4 +1637,26 @@ internal sealed partial class CharaDataHubUi : WindowMediatorSubscriberBase
|
||||
drawAction();
|
||||
if (_disableUI) ImGui.BeginDisabled();
|
||||
}
|
||||
|
||||
private static CancellationTokenSource EnsureFreshCts(ref CancellationTokenSource? cts)
|
||||
{
|
||||
CancelAndDispose(ref cts);
|
||||
cts = new CancellationTokenSource();
|
||||
return cts;
|
||||
}
|
||||
|
||||
private static void CancelAndDispose(ref CancellationTokenSource? cts)
|
||||
{
|
||||
if (cts == null) return;
|
||||
try
|
||||
{
|
||||
cts.Cancel();
|
||||
}
|
||||
catch (ObjectDisposedException)
|
||||
{
|
||||
}
|
||||
|
||||
cts.Dispose();
|
||||
cts = null;
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,19 +1,23 @@
|
||||
using System;
|
||||
using System.Numerics;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Dalamud.Game.Text.SeStringHandling;
|
||||
using Dalamud.Bindings.ImGui;
|
||||
using Dalamud.Interface;
|
||||
using Dalamud.Interface.Colors;
|
||||
using Dalamud.Interface.Utility;
|
||||
using MareSynchronos.API.Data;
|
||||
using MareSynchronos.API.Data.Enum;
|
||||
using MareSynchronos.API.Data.Extensions;
|
||||
using MareSynchronos.API.Dto.Group;
|
||||
using MareSynchronos.API.Dto.User;
|
||||
using MareSynchronos.PlayerData.Pairs;
|
||||
using MareSynchronos.Services;
|
||||
using MareSynchronos.Services.AutoDetect;
|
||||
using MareSynchronos.Services.Mediator;
|
||||
using MareSynchronos.Services.ServerConfiguration;
|
||||
using MareSynchronos.UI.Handlers;
|
||||
using MareSynchronos.WebAPI;
|
||||
using MareSynchronos.Localization;
|
||||
|
||||
namespace MareSynchronos.UI.Components;
|
||||
|
||||
@@ -23,23 +27,61 @@ public class DrawGroupPair : DrawPairBase
|
||||
private readonly GroupPairFullInfoDto _fullInfoDto;
|
||||
private readonly GroupFullInfoDto _group;
|
||||
private readonly CharaDataManager _charaDataManager;
|
||||
|
||||
private static string L(string key, string fallback, params object[] args)
|
||||
{
|
||||
var safeArgs = args ?? Array.Empty<object>();
|
||||
return LocalizationService.Instance?.GetString(key, fallback, safeArgs)
|
||||
?? string.Format(System.Globalization.CultureInfo.CurrentCulture, fallback, safeArgs);
|
||||
}
|
||||
private readonly AutoDetectRequestService _autoDetectRequestService;
|
||||
private readonly ServerConfigurationManager _serverConfigurationManager;
|
||||
private const string ManualPairInvitePrefix = "[UmbraPairInvite|";
|
||||
|
||||
public DrawGroupPair(string id, Pair entry, ApiController apiController,
|
||||
MareMediator mareMediator, GroupFullInfoDto group, GroupPairFullInfoDto fullInfoDto,
|
||||
UidDisplayHandler handler, UiSharedService uiSharedService, CharaDataManager charaDataManager)
|
||||
UidDisplayHandler handler, UiSharedService uiSharedService, CharaDataManager charaDataManager,
|
||||
AutoDetectRequestService autoDetectRequestService, ServerConfigurationManager serverConfigurationManager)
|
||||
: base(id, entry, apiController, handler, uiSharedService)
|
||||
{
|
||||
_group = group;
|
||||
_fullInfoDto = fullInfoDto;
|
||||
_mediator = mareMediator;
|
||||
_charaDataManager = charaDataManager;
|
||||
_autoDetectRequestService = autoDetectRequestService;
|
||||
_serverConfigurationManager = serverConfigurationManager;
|
||||
}
|
||||
|
||||
protected override float GetRightSideExtraWidth()
|
||||
{
|
||||
float width = 0f;
|
||||
float spacing = ImGui.GetStyle().ItemSpacing.X;
|
||||
|
||||
var soundsDisabled = _fullInfoDto.GroupUserPermissions.IsDisableSounds();
|
||||
var animDisabled = _fullInfoDto.GroupUserPermissions.IsDisableAnimations();
|
||||
var vfxDisabled = _fullInfoDto.GroupUserPermissions.IsDisableVFX();
|
||||
var individualSoundsDisabled = (_pair.UserPair?.OwnPermissions.IsDisableSounds() ?? false) || (_pair.UserPair?.OtherPermissions.IsDisableSounds() ?? false);
|
||||
var individualAnimDisabled = (_pair.UserPair?.OwnPermissions.IsDisableAnimations() ?? false) || (_pair.UserPair?.OtherPermissions.IsDisableAnimations() ?? false);
|
||||
var individualVFXDisabled = (_pair.UserPair?.OwnPermissions.IsDisableVFX() ?? false) || (_pair.UserPair?.OtherPermissions.IsDisableVFX() ?? false);
|
||||
|
||||
bool showInfo = individualAnimDisabled || individualSoundsDisabled || individualVFXDisabled || animDisabled || soundsDisabled || vfxDisabled;
|
||||
bool showShared = _charaDataManager.SharedWithYouData.TryGetValue(_pair.UserData, out var sharedData);
|
||||
bool showPlus = _pair.UserPair == null && _pair.IsOnline;
|
||||
|
||||
if (showShared)
|
||||
{
|
||||
width += _uiSharedService.GetIconButtonSize(FontAwesomeIcon.Running).X + spacing;
|
||||
}
|
||||
|
||||
if (showInfo)
|
||||
{
|
||||
var icon = (individualAnimDisabled || individualSoundsDisabled || individualVFXDisabled)
|
||||
? FontAwesomeIcon.ExclamationTriangle
|
||||
: FontAwesomeIcon.InfoCircle;
|
||||
width += UiSharedService.GetIconSize(icon).X + spacing;
|
||||
}
|
||||
|
||||
if (showPlus)
|
||||
{
|
||||
width += _uiSharedService.GetIconButtonSize(FontAwesomeIcon.Plus).X + spacing;
|
||||
}
|
||||
|
||||
width += spacing * 1.2f;
|
||||
|
||||
return width;
|
||||
}
|
||||
|
||||
protected override void DrawLeftSide(float textPosY, float originalY)
|
||||
@@ -50,20 +92,20 @@ public class DrawGroupPair : DrawPairBase
|
||||
var entryIsPinned = _fullInfoDto.GroupPairStatusInfo.IsPinned();
|
||||
var presenceIcon = _pair.IsVisible ? FontAwesomeIcon.Eye : FontAwesomeIcon.CloudMoon;
|
||||
var presenceColor = (_pair.IsOnline || _pair.IsVisible) ? new Vector4(0.63f, 0.25f, 1f, 1f) : ImGuiColors.DalamudGrey;
|
||||
var presenceText = L("GroupPair.Presence.Offline", "{0} is offline", entryUID);
|
||||
var presenceText = entryUID + " is offline";
|
||||
|
||||
ImGui.SetCursorPosY(textPosY);
|
||||
bool drewPrefixIcon = false;
|
||||
|
||||
if (_pair.IsPaused)
|
||||
{
|
||||
presenceText = L("GroupPair.Presence.Paused", "{0} online status is unknown (paused)", entryUID);
|
||||
presenceText = entryUID + " online status is unknown (paused)";
|
||||
|
||||
ImGui.PushFont(UiBuilder.IconFont);
|
||||
UiSharedService.ColorText(FontAwesomeIcon.PauseCircle.ToIconString(), ImGuiColors.DalamudYellow);
|
||||
ImGui.PopFont();
|
||||
|
||||
UiSharedService.AttachToolTip(L("GroupPair.Tooltip.Paused", "Pairing status with {0} is paused", entryUID));
|
||||
UiSharedService.AttachToolTip("Pairing status with " + entryUID + " is paused");
|
||||
drewPrefixIcon = true;
|
||||
}
|
||||
else
|
||||
@@ -75,7 +117,7 @@ public class DrawGroupPair : DrawPairBase
|
||||
ImGui.PushFont(UiBuilder.IconFont);
|
||||
UiSharedService.ColorText(FontAwesomeIcon.Moon.ToIconString(), violet);
|
||||
ImGui.PopFont();
|
||||
UiSharedService.AttachToolTip(L("GroupPair.Tooltip.IndividuallyPaired", "You are individually paired with {0}", entryUID));
|
||||
UiSharedService.AttachToolTip("You are individually paired with " + entryUID);
|
||||
drewPrefixIcon = true;
|
||||
}
|
||||
}
|
||||
@@ -87,10 +129,8 @@ public class DrawGroupPair : DrawPairBase
|
||||
UiSharedService.ColorText(presenceIcon.ToIconString(), presenceColor);
|
||||
ImGui.PopFont();
|
||||
|
||||
if (_pair.IsOnline && !_pair.IsVisible)
|
||||
presenceText = L("GroupPair.Presence.Online", "{0} is online", entryUID);
|
||||
else if (_pair.IsOnline && _pair.IsVisible)
|
||||
presenceText = L("GroupPair.Presence.Visible", "{0} is visible: {1}\nClick to target this player", entryUID, _pair.PlayerName);
|
||||
if (_pair.IsOnline && !_pair.IsVisible) presenceText = entryUID + " is online";
|
||||
else if (_pair.IsOnline && _pair.IsVisible) presenceText = entryUID + " is visible: " + _pair.PlayerName + Environment.NewLine + "Click to target this player";
|
||||
|
||||
if (_pair.IsVisible)
|
||||
{
|
||||
@@ -101,19 +141,16 @@ public class DrawGroupPair : DrawPairBase
|
||||
if (_pair.LastAppliedDataBytes >= 0)
|
||||
{
|
||||
presenceText += UiSharedService.TooltipSeparator;
|
||||
presenceText += (!_pair.IsVisible ? L("GroupPair.Presence.LastPrefix", "(Last) ") : string.Empty)
|
||||
+ L("GroupPair.Presence.ModsInfo", "Mods Info") + Environment.NewLine;
|
||||
presenceText += L("GroupPair.Presence.FilesSize", "Files Size: {0}", UiSharedService.ByteToString(_pair.LastAppliedDataBytes, true));
|
||||
presenceText += ((!_pair.IsVisible) ? "(Last) " : string.Empty) + "Mods Info" + Environment.NewLine;
|
||||
presenceText += "Files Size: " + UiSharedService.ByteToString(_pair.LastAppliedDataBytes, true);
|
||||
if (_pair.LastAppliedApproximateVRAMBytes >= 0)
|
||||
{
|
||||
presenceText += Environment.NewLine + L("GroupPair.Presence.Vram", "Approx. VRAM Usage: {0}", UiSharedService.ByteToString(_pair.LastAppliedApproximateVRAMBytes, true));
|
||||
presenceText += Environment.NewLine + "Approx. VRAM Usage: " + UiSharedService.ByteToString(_pair.LastAppliedApproximateVRAMBytes, true);
|
||||
}
|
||||
if (_pair.LastAppliedDataTris >= 0)
|
||||
{
|
||||
var trisValue = _pair.LastAppliedDataTris > 1000
|
||||
? (_pair.LastAppliedDataTris / 1000d).ToString("0.0'k'", System.Globalization.CultureInfo.CurrentCulture)
|
||||
: _pair.LastAppliedDataTris.ToString(System.Globalization.CultureInfo.CurrentCulture);
|
||||
presenceText += Environment.NewLine + L("GroupPair.Presence.Tris", "Triangle Count (excl. Vanilla): {0}", trisValue);
|
||||
presenceText += Environment.NewLine + "Triangle Count (excl. Vanilla): "
|
||||
+ (_pair.LastAppliedDataTris > 1000 ? (_pair.LastAppliedDataTris / 1000d).ToString("0.0'k'") : _pair.LastAppliedDataTris);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -127,7 +164,7 @@ public class DrawGroupPair : DrawPairBase
|
||||
ImGui.PushFont(UiBuilder.IconFont);
|
||||
ImGui.TextUnformatted(FontAwesomeIcon.Crown.ToIconString());
|
||||
ImGui.PopFont();
|
||||
UiSharedService.AttachToolTip(L("GroupPair.Tooltip.Owner", "User is owner of this Syncshell"));
|
||||
UiSharedService.AttachToolTip("User is owner of this Syncshell");
|
||||
}
|
||||
else if (entryIsMod)
|
||||
{
|
||||
@@ -136,7 +173,7 @@ public class DrawGroupPair : DrawPairBase
|
||||
ImGui.PushFont(UiBuilder.IconFont);
|
||||
ImGui.TextUnformatted(FontAwesomeIcon.UserShield.ToIconString());
|
||||
ImGui.PopFont();
|
||||
UiSharedService.AttachToolTip(L("GroupPair.Tooltip.Moderator", "User is moderator of this Syncshell"));
|
||||
UiSharedService.AttachToolTip("User is moderator of this Syncshell");
|
||||
}
|
||||
else if (entryIsPinned)
|
||||
{
|
||||
@@ -145,7 +182,7 @@ public class DrawGroupPair : DrawPairBase
|
||||
ImGui.PushFont(UiBuilder.IconFont);
|
||||
ImGui.TextUnformatted(FontAwesomeIcon.Thumbtack.ToIconString());
|
||||
ImGui.PopFont();
|
||||
UiSharedService.AttachToolTip(L("GroupPair.Tooltip.Pinned", "User is pinned in this Syncshell"));
|
||||
UiSharedService.AttachToolTip("User is pinned in this Syncshell");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -166,44 +203,85 @@ public class DrawGroupPair : DrawPairBase
|
||||
var individualVFXDisabled = (_pair.UserPair?.OwnPermissions.IsDisableVFX() ?? false) || (_pair.UserPair?.OtherPermissions.IsDisableVFX() ?? false);
|
||||
|
||||
bool showShared = _charaDataManager.SharedWithYouData.TryGetValue(_pair.UserData, out var sharedData);
|
||||
bool showInfo = (individualAnimDisabled || individualSoundsDisabled || animDisabled || soundsDisabled);
|
||||
bool showPlus = _pair.UserPair == null;
|
||||
bool showInfo = (individualAnimDisabled || individualSoundsDisabled || individualVFXDisabled || animDisabled || soundsDisabled || vfxDisabled);
|
||||
bool showPlus = _pair.UserPair == null && _pair.IsOnline;
|
||||
bool showBars = (userIsOwner || (userIsModerator && !entryIsMod && !entryIsOwner)) || !_pair.IsPaused;
|
||||
bool showPause = true;
|
||||
|
||||
var spacing = ImGui.GetStyle().ItemSpacing.X;
|
||||
var permIcon = (individualAnimDisabled || individualSoundsDisabled || individualVFXDisabled) ? FontAwesomeIcon.ExclamationTriangle
|
||||
: ((soundsDisabled || animDisabled || vfxDisabled) ? FontAwesomeIcon.InfoCircle : FontAwesomeIcon.None);
|
||||
var runningIconWidth = _uiSharedService.GetIconButtonSize(FontAwesomeIcon.Running).X;
|
||||
var infoIconWidth = UiSharedService.GetIconSize(permIcon).X;
|
||||
var infoIconWidth = showInfo && permIcon != FontAwesomeIcon.None ? UiSharedService.GetIconSize(permIcon).X : 0f;
|
||||
var plusButtonWidth = _uiSharedService.GetIconButtonSize(FontAwesomeIcon.Plus).X;
|
||||
var pauseIcon = _fullInfoDto.GroupUserPermissions.IsPaused() ? FontAwesomeIcon.Play : FontAwesomeIcon.Pause;
|
||||
var pauseButtonWidth = _uiSharedService.GetIconButtonSize(pauseIcon).X;
|
||||
var barButtonWidth = _uiSharedService.GetIconButtonSize(FontAwesomeIcon.Bars).X;
|
||||
var rightEdgeGap = spacing * 1.2f;
|
||||
|
||||
var pos = ImGui.GetWindowContentRegionMin().X + UiSharedService.GetWindowContentRegionWidth() + spacing
|
||||
- (showShared ? (runningIconWidth + spacing) : 0)
|
||||
- (showInfo ? (infoIconWidth + spacing) : 0)
|
||||
- (showPlus ? (plusButtonWidth + spacing) : 0)
|
||||
- (showBars ? (barButtonWidth + spacing) : 0);
|
||||
float totalWidth = 0f;
|
||||
void Accumulate(bool condition, float width)
|
||||
{
|
||||
if (!condition || width <= 0f) return;
|
||||
if (totalWidth > 0f) totalWidth += spacing;
|
||||
totalWidth += width;
|
||||
}
|
||||
|
||||
ImGui.SameLine(pos);
|
||||
Accumulate(showShared, runningIconWidth);
|
||||
Accumulate(showInfo && infoIconWidth > 0f, infoIconWidth);
|
||||
Accumulate(showPlus, plusButtonWidth);
|
||||
Accumulate(showPause, pauseButtonWidth);
|
||||
if (showBars)
|
||||
{
|
||||
if (totalWidth > 0f) totalWidth += spacing;
|
||||
totalWidth += barButtonWidth;
|
||||
}
|
||||
if (showPause && showBars)
|
||||
{
|
||||
totalWidth -= spacing * 0.5f;
|
||||
if (totalWidth < 0f) totalWidth = 0f;
|
||||
}
|
||||
|
||||
float cardPaddingX = UiSharedService.GetCardContentPaddingX();
|
||||
float rightMargin = cardPaddingX + 6f * ImGuiHelpers.GlobalScale;
|
||||
float baseX = MathF.Max(ImGui.GetCursorPosX(),
|
||||
ImGui.GetWindowContentRegionMin().X + UiSharedService.GetWindowContentRegionWidth() - rightMargin - rightEdgeGap - totalWidth);
|
||||
float currentX = baseX;
|
||||
|
||||
ImGui.SameLine();
|
||||
ImGui.SetCursorPosX(baseX);
|
||||
|
||||
if (showShared)
|
||||
{
|
||||
ImGui.SetCursorPosY(textPosY);
|
||||
_uiSharedService.IconText(FontAwesomeIcon.Running);
|
||||
|
||||
UiSharedService.AttachToolTip(L("GroupPair.Tooltip.SharedData", "This user has shared {0} Character Data Sets with you.", sharedData!.Count)
|
||||
+ UiSharedService.TooltipSeparator
|
||||
+ L("GroupPair.Tooltip.SharedData.OpenHub", "Click to open the Character Data Hub and show the entries."));
|
||||
UiSharedService.AttachToolTip($"This user has shared {sharedData!.Count} Character Data Sets with you." + UiSharedService.TooltipSeparator
|
||||
+ "Click to open the Character Data Hub and show the entries.");
|
||||
|
||||
if (ImGui.IsItemClicked(ImGuiMouseButton.Left))
|
||||
{
|
||||
_mediator.Publish(new OpenCharaDataHubWithFilterMessage(_pair.UserData));
|
||||
}
|
||||
ImGui.SameLine();
|
||||
currentX += runningIconWidth + spacing;
|
||||
ImGui.SetCursorPosX(currentX);
|
||||
}
|
||||
|
||||
if (showInfo && infoIconWidth > 0f)
|
||||
{
|
||||
bool centerWarning = permIcon == FontAwesomeIcon.ExclamationTriangle && showPause && showBars && !showShared && !showPlus;
|
||||
if (centerWarning)
|
||||
{
|
||||
float barsClusterWidth = showBars ? (barButtonWidth + spacing * 0.5f) : 0f;
|
||||
float leftAreaWidth = MathF.Max(totalWidth - pauseButtonWidth - barsClusterWidth, 0f);
|
||||
float warningX = baseX + MathF.Max((leftAreaWidth - infoIconWidth) / 2f, 0f);
|
||||
currentX = warningX;
|
||||
ImGui.SetCursorPosX(currentX);
|
||||
}
|
||||
|
||||
ImGui.SetCursorPosY(textPosY);
|
||||
if (individualAnimDisabled || individualSoundsDisabled || individualVFXDisabled)
|
||||
{
|
||||
ImGui.SetCursorPosY(textPosY);
|
||||
ImGui.PushStyleColor(ImGuiCol.Text, ImGuiColors.DalamudYellow);
|
||||
_uiSharedService.IconText(permIcon);
|
||||
ImGui.PopStyleColor();
|
||||
@@ -211,112 +289,128 @@ public class DrawGroupPair : DrawPairBase
|
||||
{
|
||||
ImGui.BeginTooltip();
|
||||
|
||||
ImGui.TextUnformatted(L("GroupPair.Tooltip.IndividualHeader", "Individual User permissions"));
|
||||
ImGui.TextUnformatted("Individual User permissions");
|
||||
|
||||
if (individualSoundsDisabled)
|
||||
{
|
||||
var userSoundsText = L("GroupPair.Tooltip.SoundWith", "Sound sync disabled with {0}", _pair.UserData.AliasOrUID);
|
||||
_uiSharedService.IconText(FontAwesomeIcon.VolumeOff);
|
||||
var userSoundsText = "Sound sync disabled with " + _pair.UserData.AliasOrUID;
|
||||
_uiSharedService.IconText(FontAwesomeIcon.VolumeMute);
|
||||
ImGui.SameLine(40 * ImGuiHelpers.GlobalScale);
|
||||
ImGui.TextUnformatted(userSoundsText);
|
||||
ImGui.NewLine();
|
||||
ImGui.SameLine(40 * ImGuiHelpers.GlobalScale);
|
||||
ImGui.TextUnformatted(L("GroupPair.Tooltip.YouThey", "You: {0}, They: {1}",
|
||||
_pair.UserPair!.OwnPermissions.IsDisableSounds() ? L("GroupPair.Toggle.Disabled", "Disabled") : L("GroupPair.Toggle.Enabled", "Enabled"),
|
||||
_pair.UserPair!.OtherPermissions.IsDisableSounds() ? L("GroupPair.Toggle.Disabled", "Disabled") : L("GroupPair.Toggle.Enabled", "Enabled")));
|
||||
ImGui.TextUnformatted("You: " + (_pair.UserPair!.OwnPermissions.IsDisableSounds() ? "Disabled" : "Enabled") + ", They: " + (_pair.UserPair!.OtherPermissions.IsDisableSounds() ? "Disabled" : "Enabled"));
|
||||
}
|
||||
|
||||
if (individualAnimDisabled)
|
||||
{
|
||||
var userAnimText = L("GroupPair.Tooltip.AnimWith", "Animation sync disabled with {0}", _pair.UserData.AliasOrUID);
|
||||
_uiSharedService.IconText(FontAwesomeIcon.Stop);
|
||||
var userAnimText = "Animation sync disabled with " + _pair.UserData.AliasOrUID;
|
||||
_uiSharedService.IconText(FontAwesomeIcon.WindowClose);
|
||||
ImGui.SameLine(40 * ImGuiHelpers.GlobalScale);
|
||||
ImGui.TextUnformatted(userAnimText);
|
||||
ImGui.NewLine();
|
||||
ImGui.SameLine(40 * ImGuiHelpers.GlobalScale);
|
||||
ImGui.TextUnformatted(L("GroupPair.Tooltip.YouThey", "You: {0}, They: {1}",
|
||||
_pair.UserPair!.OwnPermissions.IsDisableAnimations() ? L("GroupPair.Toggle.Disabled", "Disabled") : L("GroupPair.Toggle.Enabled", "Enabled"),
|
||||
_pair.UserPair!.OtherPermissions.IsDisableAnimations() ? L("GroupPair.Toggle.Disabled", "Disabled") : L("GroupPair.Toggle.Enabled", "Enabled")));
|
||||
ImGui.TextUnformatted("You: " + (_pair.UserPair!.OwnPermissions.IsDisableAnimations() ? "Disabled" : "Enabled") + ", They: " + (_pair.UserPair!.OtherPermissions.IsDisableAnimations() ? "Disabled" : "Enabled"));
|
||||
}
|
||||
|
||||
if (individualVFXDisabled)
|
||||
{
|
||||
var userVFXText = L("GroupPair.Tooltip.VfxWith", "VFX sync disabled with {0}", _pair.UserData.AliasOrUID);
|
||||
_uiSharedService.IconText(FontAwesomeIcon.Circle);
|
||||
var userVFXText = "VFX sync disabled with " + _pair.UserData.AliasOrUID;
|
||||
_uiSharedService.IconText(FontAwesomeIcon.TimesCircle);
|
||||
ImGui.SameLine(40 * ImGuiHelpers.GlobalScale);
|
||||
ImGui.TextUnformatted(userVFXText);
|
||||
ImGui.NewLine();
|
||||
ImGui.SameLine(40 * ImGuiHelpers.GlobalScale);
|
||||
ImGui.TextUnformatted(L("GroupPair.Tooltip.YouThey", "You: {0}, They: {1}",
|
||||
_pair.UserPair!.OwnPermissions.IsDisableVFX() ? L("GroupPair.Toggle.Disabled", "Disabled") : L("GroupPair.Toggle.Enabled", "Enabled"),
|
||||
_pair.UserPair!.OtherPermissions.IsDisableVFX() ? L("GroupPair.Toggle.Disabled", "Disabled") : L("GroupPair.Toggle.Enabled", "Enabled")));
|
||||
ImGui.TextUnformatted("You: " + (_pair.UserPair!.OwnPermissions.IsDisableVFX() ? "Disabled" : "Enabled") + ", They: " + (_pair.UserPair!.OtherPermissions.IsDisableVFX() ? "Disabled" : "Enabled"));
|
||||
}
|
||||
|
||||
ImGui.EndTooltip();
|
||||
}
|
||||
ImGui.SameLine();
|
||||
}
|
||||
else if ((animDisabled || soundsDisabled || vfxDisabled))
|
||||
else
|
||||
{
|
||||
ImGui.SetCursorPosY(textPosY);
|
||||
_uiSharedService.IconText(permIcon);
|
||||
if (ImGui.IsItemHovered())
|
||||
{
|
||||
ImGui.BeginTooltip();
|
||||
|
||||
ImGui.TextUnformatted(L("GroupPair.Tooltip.SyncshellHeader", "Syncshell User permissions"));
|
||||
ImGui.TextUnformatted("Syncshell User permissions");
|
||||
|
||||
if (soundsDisabled)
|
||||
{
|
||||
var userSoundsText = L("GroupPair.Tooltip.SoundBy", "Sound sync disabled by {0}", _pair.UserData.AliasOrUID);
|
||||
_uiSharedService.IconText(FontAwesomeIcon.VolumeOff);
|
||||
var userSoundsText = "Sound sync disabled by " + _pair.UserData.AliasOrUID;
|
||||
_uiSharedService.IconText(FontAwesomeIcon.VolumeMute);
|
||||
ImGui.SameLine(40 * ImGuiHelpers.GlobalScale);
|
||||
ImGui.TextUnformatted(userSoundsText);
|
||||
}
|
||||
|
||||
if (animDisabled)
|
||||
{
|
||||
var userAnimText = L("GroupPair.Tooltip.AnimBy", "Animation sync disabled by {0}", _pair.UserData.AliasOrUID);
|
||||
_uiSharedService.IconText(FontAwesomeIcon.Stop);
|
||||
var userAnimText = "Animation sync disabled by " + _pair.UserData.AliasOrUID;
|
||||
_uiSharedService.IconText(FontAwesomeIcon.WindowClose);
|
||||
ImGui.SameLine(40 * ImGuiHelpers.GlobalScale);
|
||||
ImGui.TextUnformatted(userAnimText);
|
||||
}
|
||||
|
||||
if (vfxDisabled)
|
||||
{
|
||||
var userVFXText = L("GroupPair.Tooltip.VfxBy", "VFX sync disabled by {0}", _pair.UserData.AliasOrUID);
|
||||
_uiSharedService.IconText(FontAwesomeIcon.Circle);
|
||||
var userVFXText = "VFX sync disabled by " + _pair.UserData.AliasOrUID;
|
||||
_uiSharedService.IconText(FontAwesomeIcon.TimesCircle);
|
||||
ImGui.SameLine(40 * ImGuiHelpers.GlobalScale);
|
||||
ImGui.TextUnformatted(userVFXText);
|
||||
}
|
||||
|
||||
ImGui.EndTooltip();
|
||||
}
|
||||
ImGui.SameLine();
|
||||
}
|
||||
|
||||
currentX += infoIconWidth + spacing;
|
||||
ImGui.SetCursorPosX(currentX);
|
||||
}
|
||||
|
||||
if (showPlus)
|
||||
{
|
||||
ImGui.SetCursorPosY(originalY);
|
||||
|
||||
if (_uiSharedService.IconButton(FontAwesomeIcon.Plus))
|
||||
if (_uiSharedService.IconPlusButtonCentered())
|
||||
{
|
||||
_ = _apiController.UserAddPair(new UserDto(new(_pair.UserData.UID)));
|
||||
var targetUid = _pair.UserData.UID;
|
||||
if (!string.IsNullOrEmpty(targetUid))
|
||||
{
|
||||
_ = SendGroupPairInviteAsync(targetUid, entryUID);
|
||||
}
|
||||
UiSharedService.AttachToolTip(L("GroupPair.Popup.PairIndividually", "Pair with {0} individually", entryUID));
|
||||
ImGui.SameLine();
|
||||
}
|
||||
UiSharedService.AttachToolTip(AppendSeenInfo("Send pairing invite to " + entryUID));
|
||||
currentX += plusButtonWidth + spacing;
|
||||
ImGui.SetCursorPosX(currentX);
|
||||
}
|
||||
|
||||
if (showPause)
|
||||
{
|
||||
float gapToBars = showBars ? spacing * 0.5f : spacing;
|
||||
ImGui.SetCursorPosY(originalY);
|
||||
if (pauseIcon == FontAwesomeIcon.Pause ? _uiSharedService.IconPauseButtonCentered() : _uiSharedService.IconButtonCentered(pauseIcon))
|
||||
{
|
||||
var newPermissions = _fullInfoDto.GroupUserPermissions ^ GroupUserPermissions.Paused;
|
||||
_fullInfoDto.GroupUserPermissions = newPermissions;
|
||||
_ = _apiController.GroupChangeIndividualPermissionState(new GroupPairUserPermissionDto(_group.Group, _pair.UserData, newPermissions));
|
||||
}
|
||||
|
||||
UiSharedService.AttachToolTip(AppendSeenInfo((_fullInfoDto.GroupUserPermissions.IsPaused() ? "Resume" : "Pause") + " syncing with " + entryUID));
|
||||
currentX += pauseButtonWidth + gapToBars;
|
||||
ImGui.SetCursorPosX(currentX);
|
||||
}
|
||||
|
||||
if (showBars)
|
||||
{
|
||||
ImGui.SetCursorPosY(originalY);
|
||||
|
||||
if (_uiSharedService.IconButton(FontAwesomeIcon.Bars))
|
||||
if (_uiSharedService.IconButtonCentered(FontAwesomeIcon.Bars))
|
||||
{
|
||||
ImGui.OpenPopup("Popup");
|
||||
ImGui.OpenPopup("Syncshell Flyout Menu");
|
||||
}
|
||||
currentX += barButtonWidth;
|
||||
ImGui.SetCursorPosX(currentX);
|
||||
}
|
||||
|
||||
if (ImGui.BeginPopup("Popup"))
|
||||
{
|
||||
if ((userIsModerator || userIsOwner) && !(entryIsMod || entryIsOwner))
|
||||
@@ -402,6 +496,76 @@ public class DrawGroupPair : DrawPairBase
|
||||
ImGui.EndPopup();
|
||||
}
|
||||
|
||||
return pos - spacing;
|
||||
return baseX - spacing;
|
||||
}
|
||||
|
||||
private string AppendSeenInfo(string tooltip)
|
||||
{
|
||||
if (_pair.IsVisible) return tooltip;
|
||||
|
||||
var lastSeen = _serverConfigurationManager.GetNameForUid(_pair.UserData.UID);
|
||||
if (string.IsNullOrWhiteSpace(lastSeen)) return tooltip;
|
||||
|
||||
return tooltip + " (Vu sous : " + lastSeen + ")";
|
||||
}
|
||||
|
||||
private async Task SendGroupPairInviteAsync(string targetUid, string displayName)
|
||||
{
|
||||
try
|
||||
{
|
||||
var ok = await _autoDetectRequestService.SendDirectUidRequestAsync(targetUid, displayName).ConfigureAwait(false);
|
||||
if (!ok) return;
|
||||
|
||||
await SendManualInviteSignalAsync(targetUid, displayName).ConfigureAwait(false);
|
||||
}
|
||||
catch
|
||||
{
|
||||
// errors are logged within the request service; ignore here
|
||||
}
|
||||
}
|
||||
|
||||
private async Task SendManualInviteSignalAsync(string targetUid, string displayName)
|
||||
{
|
||||
if (string.IsNullOrEmpty(_apiController.UID)) return;
|
||||
|
||||
var senderAliasRaw = string.IsNullOrEmpty(_apiController.DisplayName) ? _apiController.UID : _apiController.DisplayName;
|
||||
var senderAlias = EncodeInviteField(senderAliasRaw);
|
||||
var targetDisplay = EncodeInviteField(displayName);
|
||||
var inviteId = Guid.NewGuid().ToString("N");
|
||||
var payloadText = new StringBuilder()
|
||||
.Append(ManualPairInvitePrefix)
|
||||
.Append(_apiController.UID)
|
||||
.Append('|')
|
||||
.Append(senderAlias)
|
||||
.Append('|')
|
||||
.Append(targetUid)
|
||||
.Append('|')
|
||||
.Append(targetDisplay)
|
||||
.Append('|')
|
||||
.Append(inviteId)
|
||||
.Append(']')
|
||||
.ToString();
|
||||
|
||||
var payload = new SeStringBuilder().AddText(payloadText).Build().Encode();
|
||||
var chatMessage = new ChatMessage
|
||||
{
|
||||
SenderName = senderAlias,
|
||||
PayloadContent = payload
|
||||
};
|
||||
|
||||
try
|
||||
{
|
||||
await _apiController.GroupChatSendMsg(new GroupDto(_group.Group), chatMessage).ConfigureAwait(false);
|
||||
}
|
||||
catch
|
||||
{
|
||||
// ignore - invite remains tracked locally even if group chat signal fails
|
||||
}
|
||||
}
|
||||
|
||||
private static string EncodeInviteField(string value)
|
||||
{
|
||||
var bytes = Encoding.UTF8.GetBytes(value ?? string.Empty);
|
||||
return Convert.ToBase64String(bytes);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
using Dalamud.Bindings.ImGui;
|
||||
using System;
|
||||
using System.Numerics;
|
||||
using Dalamud.Bindings.ImGui;
|
||||
using Dalamud.Interface;
|
||||
using Dalamud.Interface.Utility;
|
||||
using MareSynchronos.PlayerData.Pairs;
|
||||
using MareSynchronos.UI.Handlers;
|
||||
using MareSynchronos.WebAPI;
|
||||
@@ -28,36 +31,81 @@ public abstract class DrawPairBase
|
||||
|
||||
public void DrawPairedClient()
|
||||
{
|
||||
var originalY = ImGui.GetCursorPosY();
|
||||
var pauseIconSize = _uiSharedService.GetIconButtonSize(FontAwesomeIcon.Play);
|
||||
var textSize = ImGui.CalcTextSize(_pair.UserData.AliasOrUID);
|
||||
var style = ImGui.GetStyle();
|
||||
var padding = style.FramePadding;
|
||||
var spacing = style.ItemSpacing;
|
||||
var rowStartCursor = ImGui.GetCursorPos();
|
||||
var rowStartScreen = ImGui.GetCursorScreenPos();
|
||||
|
||||
var startPos = ImGui.GetCursorStartPos();
|
||||
var pauseButtonSize = _uiSharedService.GetIconButtonSize(FontAwesomeIcon.Pause);
|
||||
var playButtonSize = _uiSharedService.GetIconButtonSize(FontAwesomeIcon.Play);
|
||||
var menuButtonSize = _uiSharedService.GetIconButtonSize(FontAwesomeIcon.Bars);
|
||||
|
||||
var framePadding = ImGui.GetStyle().FramePadding;
|
||||
var lineHeight = textSize.Y + framePadding.Y * 2;
|
||||
float pauseClusterWidth = Math.Max(pauseButtonSize.X, playButtonSize.X);
|
||||
float pauseClusterHeight = Math.Max(Math.Max(pauseButtonSize.Y, playButtonSize.Y), ImGui.GetFrameHeight());
|
||||
float reservedSpacing = style.ItemSpacing.X * 1.6f;
|
||||
float rightButtonWidth =
|
||||
menuButtonSize.X +
|
||||
pauseClusterWidth +
|
||||
reservedSpacing +
|
||||
GetRightSideExtraWidth();
|
||||
|
||||
var off = startPos.Y;
|
||||
var height = UiSharedService.GetWindowContentRegionHeight();
|
||||
float availableWidth = Math.Max(ImGui.GetContentRegionAvail().X - rightButtonWidth, 1f);
|
||||
float textHeight = ImGui.GetFontSize();
|
||||
var presenceIconSize = UiSharedService.GetIconSize(FontAwesomeIcon.Moon);
|
||||
float iconHeight = presenceIconSize.Y;
|
||||
float contentHeight = Math.Max(textHeight, Math.Max(iconHeight, pauseClusterHeight));
|
||||
float rowHeight = contentHeight + padding.Y * 2f;
|
||||
float totalHeight = rowHeight + spacing.Y;
|
||||
|
||||
if ((originalY + off) < -lineHeight || (originalY + off) > height)
|
||||
var origin = ImGui.GetCursorStartPos();
|
||||
var top = origin.Y + rowStartCursor.Y;
|
||||
var bottom = top + totalHeight;
|
||||
var visibleHeight = UiSharedService.GetWindowContentRegionHeight();
|
||||
if (bottom < 0 || top > visibleHeight)
|
||||
{
|
||||
ImGui.Dummy(new System.Numerics.Vector2(0f, lineHeight));
|
||||
ImGui.SetCursorPos(new Vector2(rowStartCursor.X, rowStartCursor.Y + totalHeight));
|
||||
return;
|
||||
}
|
||||
|
||||
var textPosY = originalY + pauseIconSize.Y / 2 - textSize.Y / 2;
|
||||
DrawLeftSide(textPosY, originalY);
|
||||
ImGui.SameLine();
|
||||
var posX = ImGui.GetCursorPosX();
|
||||
var rightSide = DrawRightSide(textPosY, originalY);
|
||||
DrawName(originalY, posX, rightSide);
|
||||
var drawList = ImGui.GetWindowDrawList();
|
||||
var backgroundColor = new Vector4(0.10f, 0.10f, 0.14f, 0.95f);
|
||||
var borderColor = new Vector4(0f, 0f, 0f, 0.9f);
|
||||
float rounding = Math.Max(style.FrameRounding, 7f * ImGuiHelpers.GlobalScale);
|
||||
|
||||
var panelMin = rowStartScreen + new Vector2(0f, spacing.Y * 0.15f);
|
||||
var panelMax = panelMin + new Vector2(availableWidth, rowHeight - spacing.Y * 0.3f);
|
||||
drawList.AddRectFilled(panelMin, panelMax, ImGui.ColorConvertFloat4ToU32(backgroundColor), rounding);
|
||||
drawList.AddRect(panelMin, panelMax, ImGui.ColorConvertFloat4ToU32(borderColor), rounding);
|
||||
|
||||
float iconTop = rowStartCursor.Y + (rowHeight - iconHeight) / 2f;
|
||||
float textTop = rowStartCursor.Y + (rowHeight - textHeight) / 2f - padding.Y * 0.6f;
|
||||
float buttonTop = rowStartCursor.Y + (rowHeight - pauseClusterHeight) / 2f;
|
||||
|
||||
ImGui.SetCursorPos(new Vector2(rowStartCursor.X + padding.X, iconTop));
|
||||
DrawLeftSide(iconTop, iconTop);
|
||||
|
||||
float leftReserved = GetLeftSideReservedWidth();
|
||||
float nameStartX = rowStartCursor.X + padding.X + leftReserved;
|
||||
|
||||
var rightSide = DrawRightSide(buttonTop, buttonTop);
|
||||
|
||||
ImGui.SameLine(nameStartX);
|
||||
ImGui.SetCursorPosY(textTop);
|
||||
DrawName(textTop + padding.Y * 0.15f, nameStartX, rightSide);
|
||||
|
||||
ImGui.SetCursorPos(new Vector2(rowStartCursor.X, rowStartCursor.Y + totalHeight));
|
||||
ImGui.SetCursorPosX(rowStartCursor.X);
|
||||
}
|
||||
|
||||
protected abstract void DrawLeftSide(float textPosY, float originalY);
|
||||
|
||||
protected abstract float DrawRightSide(float textPosY, float originalY);
|
||||
|
||||
protected virtual float GetRightSideExtraWidth() => 0f;
|
||||
|
||||
protected virtual float GetLeftSideReservedWidth() => UiSharedService.GetIconSize(FontAwesomeIcon.Moon).X * 2f + ImGui.GetStyle().ItemSpacing.X * 1.5f;
|
||||
|
||||
private void DrawName(float originalY, float leftSide, float rightSide)
|
||||
{
|
||||
_displayHandler.DrawPairText(_id, _pair, leftSide, originalY, () => rightSide - leftSide);
|
||||
|
||||
@@ -5,15 +5,13 @@ using Dalamud.Interface.Utility;
|
||||
using Dalamud.Interface.Utility.Raii;
|
||||
using MareSynchronos.API.Data.Extensions;
|
||||
using MareSynchronos.API.Dto.User;
|
||||
using MareSynchronos.Localization;
|
||||
using MareSynchronos.PlayerData.Pairs;
|
||||
using MareSynchronos.Services;
|
||||
using MareSynchronos.Services.Mediator;
|
||||
using MareSynchronos.UI.Handlers;
|
||||
using MareSynchronos.WebAPI;
|
||||
using System.Numerics;
|
||||
using System.Globalization;
|
||||
using System;
|
||||
using MareSynchronos.Services.ServerConfiguration;
|
||||
|
||||
namespace MareSynchronos.UI.Components;
|
||||
|
||||
@@ -23,17 +21,12 @@ public class DrawUserPair : DrawPairBase
|
||||
protected readonly MareMediator _mediator;
|
||||
private readonly SelectGroupForPairUi _selectGroupForPairUi;
|
||||
private readonly CharaDataManager _charaDataManager;
|
||||
|
||||
private static string L(string key, string fallback, params object[] args)
|
||||
{
|
||||
var safeArgs = args ?? Array.Empty<object>();
|
||||
return LocalizationService.Instance?.GetString(key, fallback, safeArgs)
|
||||
?? string.Format(CultureInfo.CurrentCulture, fallback, safeArgs);
|
||||
}
|
||||
private readonly ServerConfigurationManager _serverConfigurationManager;
|
||||
|
||||
public DrawUserPair(string id, Pair entry, UidDisplayHandler displayHandler, ApiController apiController,
|
||||
MareMediator mareMediator, SelectGroupForPairUi selectGroupForPairUi,
|
||||
UiSharedService uiSharedService, CharaDataManager charaDataManager)
|
||||
UiSharedService uiSharedService, CharaDataManager charaDataManager,
|
||||
ServerConfigurationManager serverConfigurationManager)
|
||||
: base(id, entry, apiController, displayHandler, uiSharedService)
|
||||
{
|
||||
if (_pair.UserPair == null) throw new ArgumentException("Pair must be UserPair", nameof(entry));
|
||||
@@ -41,12 +34,55 @@ public class DrawUserPair : DrawPairBase
|
||||
_selectGroupForPairUi = selectGroupForPairUi;
|
||||
_mediator = mareMediator;
|
||||
_charaDataManager = charaDataManager;
|
||||
_serverConfigurationManager = serverConfigurationManager;
|
||||
}
|
||||
|
||||
public bool IsOnline => _pair.IsOnline;
|
||||
public bool IsVisible => _pair.IsVisible;
|
||||
public UserPairDto UserPair => _pair.UserPair!;
|
||||
|
||||
protected override float GetRightSideExtraWidth()
|
||||
{
|
||||
float width = 0f;
|
||||
var spacingX = ImGui.GetStyle().ItemSpacing.X;
|
||||
|
||||
var individualSoundsDisabled = (_pair.UserPair?.OwnPermissions.IsDisableSounds() ?? false) || (_pair.UserPair?.OtherPermissions.IsDisableSounds() ?? false);
|
||||
var individualAnimDisabled = (_pair.UserPair?.OwnPermissions.IsDisableAnimations() ?? false) || (_pair.UserPair?.OtherPermissions.IsDisableAnimations() ?? false);
|
||||
var individualVFXDisabled = (_pair.UserPair?.OwnPermissions.IsDisableVFX() ?? false) || (_pair.UserPair?.OtherPermissions.IsDisableVFX() ?? false);
|
||||
|
||||
if (individualSoundsDisabled || individualAnimDisabled || individualVFXDisabled)
|
||||
{
|
||||
width += _uiSharedService.GetIconButtonSize(FontAwesomeIcon.ExclamationTriangle).X + spacingX * 0.5f;
|
||||
}
|
||||
|
||||
if (_charaDataManager.SharedWithYouData.TryGetValue(_pair.UserData, out var sharedData))
|
||||
{
|
||||
width += _uiSharedService.GetIconButtonSize(FontAwesomeIcon.Running).X + spacingX * 0.5f;
|
||||
}
|
||||
|
||||
width += spacingX * 1.2f;
|
||||
return width;
|
||||
}
|
||||
|
||||
protected override float GetLeftSideReservedWidth()
|
||||
{
|
||||
var style = ImGui.GetStyle();
|
||||
float spacing = style.ItemSpacing.X;
|
||||
float iconW = UiSharedService.GetIconSize(FontAwesomeIcon.Moon).X;
|
||||
|
||||
int icons = 1;
|
||||
if (!(_pair.UserPair!.OwnPermissions.IsPaired() && _pair.UserPair!.OtherPermissions.IsPaired()))
|
||||
icons++;
|
||||
else if (_pair.UserPair!.OwnPermissions.IsPaused() || _pair.UserPair!.OtherPermissions.IsPaused())
|
||||
icons++;
|
||||
if (_pair.IsOnline && _pair.IsVisible)
|
||||
icons++;
|
||||
|
||||
float iconsTotal = icons * iconW + Math.Max(0, icons - 1) * spacing;
|
||||
float cushion = spacing * 0.6f;
|
||||
return iconsTotal + cushion;
|
||||
}
|
||||
|
||||
protected override void DrawLeftSide(float textPosY, float originalY)
|
||||
{
|
||||
var online = _pair.IsOnline;
|
||||
@@ -57,16 +93,16 @@ public class DrawUserPair : DrawPairBase
|
||||
UiSharedService.ColorText(FontAwesomeIcon.Moon.ToIconString(), online ? Violet : offlineGrey);
|
||||
ImGui.PopFont();
|
||||
UiSharedService.AttachToolTip(online
|
||||
? L("UserPair.Status.Online", "User is online")
|
||||
: L("UserPair.Status.Offline", "User is offline"));
|
||||
? "User is online"
|
||||
: "User is offline");
|
||||
if (!(_pair.UserPair!.OwnPermissions.IsPaired() && _pair.UserPair!.OtherPermissions.IsPaired()))
|
||||
{
|
||||
ImGui.SameLine();
|
||||
ImGui.SetCursorPosY(textPosY);
|
||||
ImGui.PushFont(UiBuilder.IconFont);
|
||||
UiSharedService.ColorText(FontAwesomeIcon.ArrowUp.ToIconString(), ImGuiColors.DalamudRed);
|
||||
UiSharedService.ColorText(FontAwesomeIcon.ArrowUp.ToIconString(), UiSharedService.AccentColor);
|
||||
ImGui.PopFont();
|
||||
UiSharedService.AttachToolTip(L("UserPair.Tooltip.NotAddedBack", "{0} has not added you back", _pair.UserData.AliasOrUID));
|
||||
UiSharedService.AttachToolTip(_pair.UserData.AliasOrUID + " has not added you back");
|
||||
}
|
||||
else if (_pair.UserPair!.OwnPermissions.IsPaused() || _pair.UserPair!.OtherPermissions.IsPaused())
|
||||
{
|
||||
@@ -75,7 +111,7 @@ public class DrawUserPair : DrawPairBase
|
||||
ImGui.PushFont(UiBuilder.IconFont);
|
||||
UiSharedService.ColorText(FontAwesomeIcon.PauseCircle.ToIconString(), ImGuiColors.DalamudYellow);
|
||||
ImGui.PopFont();
|
||||
UiSharedService.AttachToolTip(L("UserPair.Tooltip.Paused", "Pairing with {0} is paused", _pair.UserData.AliasOrUID));
|
||||
UiSharedService.AttachToolTip("Pairing with " + _pair.UserData.AliasOrUID + " is paused");
|
||||
}
|
||||
if (_pair is { IsOnline: true, IsVisible: true })
|
||||
{
|
||||
@@ -88,23 +124,20 @@ public class DrawUserPair : DrawPairBase
|
||||
_mediator.Publish(new TargetPairMessage(_pair));
|
||||
}
|
||||
ImGui.PopFont();
|
||||
var visibleTooltip = L("UserPair.Tooltip.Visible", "{0} is visible: {1}\nClick to target this player", _pair.UserData.AliasOrUID, _pair.PlayerName!);
|
||||
var visibleTooltip = _pair.UserData.AliasOrUID + " is visible: " + _pair.PlayerName! + Environment.NewLine + "Click to target this player";
|
||||
if (_pair.LastAppliedDataBytes >= 0)
|
||||
{
|
||||
visibleTooltip += UiSharedService.TooltipSeparator;
|
||||
visibleTooltip += (!_pair.IsVisible ? L("UserPair.Tooltip.Visible.LastPrefix", "(Last) ") : string.Empty)
|
||||
+ L("UserPair.Tooltip.Visible.ModsInfo", "Mods Info") + Environment.NewLine;
|
||||
visibleTooltip += L("UserPair.Tooltip.Visible.FilesSize", "Files Size: {0}", UiSharedService.ByteToString(_pair.LastAppliedDataBytes, true));
|
||||
visibleTooltip += ((!_pair.IsVisible) ? "(Last) " : string.Empty) + "Mods Info" + Environment.NewLine;
|
||||
visibleTooltip += "Files Size: " + UiSharedService.ByteToString(_pair.LastAppliedDataBytes, true);
|
||||
if (_pair.LastAppliedApproximateVRAMBytes >= 0)
|
||||
{
|
||||
visibleTooltip += Environment.NewLine + L("UserPair.Tooltip.Visible.Vram", "Approx. VRAM Usage: {0}", UiSharedService.ByteToString(_pair.LastAppliedApproximateVRAMBytes, true));
|
||||
visibleTooltip += Environment.NewLine + "Approx. VRAM Usage: " + UiSharedService.ByteToString(_pair.LastAppliedApproximateVRAMBytes, true);
|
||||
}
|
||||
if (_pair.LastAppliedDataTris >= 0)
|
||||
{
|
||||
var trisValue = _pair.LastAppliedDataTris > 1000
|
||||
? (_pair.LastAppliedDataTris / 1000d).ToString("0.0'k'", CultureInfo.CurrentCulture)
|
||||
: _pair.LastAppliedDataTris.ToString(CultureInfo.CurrentCulture);
|
||||
visibleTooltip += Environment.NewLine + L("UserPair.Tooltip.Visible.Tris", "Triangle Count (excl. Vanilla): {0}", trisValue);
|
||||
visibleTooltip += Environment.NewLine + "Triangle Count (excl. Vanilla): "
|
||||
+ (_pair.LastAppliedDataTris > 1000 ? (_pair.LastAppliedDataTris / 1000d).ToString("0.0'k'") : _pair.LastAppliedDataTris);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -119,7 +152,9 @@ public class DrawUserPair : DrawPairBase
|
||||
var barButtonSize = _uiSharedService.GetIconButtonSize(FontAwesomeIcon.Bars);
|
||||
var entryUID = _pair.UserData.AliasOrUID;
|
||||
var spacingX = ImGui.GetStyle().ItemSpacing.X;
|
||||
var windowEndX = ImGui.GetWindowContentRegionMin().X + UiSharedService.GetWindowContentRegionWidth();
|
||||
var edgePadding = UiSharedService.GetCardContentPaddingX() + 6f * ImGuiHelpers.GlobalScale;
|
||||
var rightEdgeGap = spacingX * 1.2f;
|
||||
var windowEndX = ImGui.GetWindowContentRegionMin().X + UiSharedService.GetWindowContentRegionWidth() - edgePadding - rightEdgeGap;
|
||||
var rightSidePos = windowEndX - barButtonSize.X;
|
||||
|
||||
// Flyout Menu
|
||||
@@ -136,21 +171,20 @@ public class DrawUserPair : DrawPairBase
|
||||
ImGui.EndPopup();
|
||||
}
|
||||
|
||||
// Pause (mutual pairs only)
|
||||
if (_pair.UserPair!.OwnPermissions.IsPaired() && _pair.UserPair!.OtherPermissions.IsPaired())
|
||||
{
|
||||
rightSidePos -= pauseIconSize.X + spacingX;
|
||||
ImGui.SameLine(rightSidePos);
|
||||
ImGui.SetCursorPosY(originalY);
|
||||
if (_uiSharedService.IconButton(pauseIcon))
|
||||
if (pauseIcon == FontAwesomeIcon.Pause ? _uiSharedService.IconPauseButtonCentered() : _uiSharedService.IconButtonCentered(pauseIcon))
|
||||
{
|
||||
var perm = _pair.UserPair!.OwnPermissions;
|
||||
perm.SetPaused(!perm.IsPaused());
|
||||
_ = _apiController.UserSetPairPermissions(new(_pair.UserData, perm));
|
||||
}
|
||||
UiSharedService.AttachToolTip(!_pair.UserPair!.OwnPermissions.IsPaused()
|
||||
? L("UserPair.Tooltip.Pause", "Pause pairing with {0}", entryUID)
|
||||
: L("UserPair.Tooltip.Resume", "Resume pairing with {0}", entryUID));
|
||||
UiSharedService.AttachToolTip(AppendSeenInfo(!_pair.UserPair!.OwnPermissions.IsPaused()
|
||||
? "Pause pairing with " + entryUID
|
||||
: "Resume pairing with " + entryUID));
|
||||
|
||||
|
||||
var individualSoundsDisabled = (_pair.UserPair?.OwnPermissions.IsDisableSounds() ?? false) || (_pair.UserPair?.OtherPermissions.IsDisableSounds() ?? false);
|
||||
@@ -171,57 +205,39 @@ public class DrawUserPair : DrawPairBase
|
||||
{
|
||||
ImGui.BeginTooltip();
|
||||
|
||||
ImGui.TextUnformatted(L("UserPair.Tooltip.Permission.Header", "Individual user permissions"));
|
||||
ImGui.TextUnformatted("Individual User permissions");
|
||||
|
||||
if (individualSoundsDisabled)
|
||||
{
|
||||
var userSoundsText = L("UserPair.Tooltip.Permission.Sound", "Sound sync disabled with {0}", _pair.UserData.AliasOrUID);
|
||||
_uiSharedService.IconText(FontAwesomeIcon.VolumeOff);
|
||||
var userSoundsText = "Sound sync disabled with " + _pair.UserData.AliasOrUID;
|
||||
_uiSharedService.IconText(FontAwesomeIcon.VolumeMute);
|
||||
ImGui.SameLine(40 * ImGuiHelpers.GlobalScale);
|
||||
ImGui.TextUnformatted(userSoundsText);
|
||||
ImGui.NewLine();
|
||||
ImGui.SameLine(40 * ImGuiHelpers.GlobalScale);
|
||||
var youStatus = _pair.UserPair!.OwnPermissions.IsDisableSounds()
|
||||
? L("UserPair.Tooltip.Permission.State.Disabled", "Disabled")
|
||||
: L("UserPair.Tooltip.Permission.State.Enabled", "Enabled");
|
||||
var theyStatus = _pair.UserPair!.OtherPermissions.IsDisableSounds()
|
||||
? L("UserPair.Tooltip.Permission.State.Disabled", "Disabled")
|
||||
: L("UserPair.Tooltip.Permission.State.Enabled", "Enabled");
|
||||
ImGui.TextUnformatted(L("UserPair.Tooltip.Permission.Status", "You: {0}, They: {1}", youStatus, theyStatus));
|
||||
ImGui.TextUnformatted("You: " + (_pair.UserPair!.OwnPermissions.IsDisableSounds() ? "Disabled" : "Enabled") + ", They: " + (_pair.UserPair!.OtherPermissions.IsDisableSounds() ? "Disabled" : "Enabled"));
|
||||
}
|
||||
|
||||
if (individualAnimDisabled)
|
||||
{
|
||||
var userAnimText = L("UserPair.Tooltip.Permission.Animation", "Animation sync disabled with {0}", _pair.UserData.AliasOrUID);
|
||||
_uiSharedService.IconText(FontAwesomeIcon.Stop);
|
||||
var userAnimText = "Animation sync disabled with " + _pair.UserData.AliasOrUID;
|
||||
_uiSharedService.IconText(FontAwesomeIcon.WindowClose);
|
||||
ImGui.SameLine(40 * ImGuiHelpers.GlobalScale);
|
||||
ImGui.TextUnformatted(userAnimText);
|
||||
ImGui.NewLine();
|
||||
ImGui.SameLine(40 * ImGuiHelpers.GlobalScale);
|
||||
var youStatus = _pair.UserPair!.OwnPermissions.IsDisableAnimations()
|
||||
? L("UserPair.Tooltip.Permission.State.Disabled", "Disabled")
|
||||
: L("UserPair.Tooltip.Permission.State.Enabled", "Enabled");
|
||||
var theyStatus = _pair.UserPair!.OtherPermissions.IsDisableAnimations()
|
||||
? L("UserPair.Tooltip.Permission.State.Disabled", "Disabled")
|
||||
: L("UserPair.Tooltip.Permission.State.Enabled", "Enabled");
|
||||
ImGui.TextUnformatted(L("UserPair.Tooltip.Permission.Status", "You: {0}, They: {1}", youStatus, theyStatus));
|
||||
ImGui.TextUnformatted("You: " + (_pair.UserPair!.OwnPermissions.IsDisableAnimations() ? "Disabled" : "Enabled") + ", They: " + (_pair.UserPair!.OtherPermissions.IsDisableAnimations() ? "Disabled" : "Enabled"));
|
||||
}
|
||||
|
||||
if (individualVFXDisabled)
|
||||
{
|
||||
var userVFXText = L("UserPair.Tooltip.Permission.Vfx", "VFX sync disabled with {0}", _pair.UserData.AliasOrUID);
|
||||
_uiSharedService.IconText(FontAwesomeIcon.Circle);
|
||||
var userVFXText = "VFX sync disabled with " + _pair.UserData.AliasOrUID;
|
||||
_uiSharedService.IconText(FontAwesomeIcon.TimesCircle);
|
||||
ImGui.SameLine(40 * ImGuiHelpers.GlobalScale);
|
||||
ImGui.TextUnformatted(userVFXText);
|
||||
ImGui.NewLine();
|
||||
ImGui.SameLine(40 * ImGuiHelpers.GlobalScale);
|
||||
var youStatus = _pair.UserPair!.OwnPermissions.IsDisableVFX()
|
||||
? L("UserPair.Tooltip.Permission.State.Disabled", "Disabled")
|
||||
: L("UserPair.Tooltip.Permission.State.Enabled", "Enabled");
|
||||
var theyStatus = _pair.UserPair!.OtherPermissions.IsDisableVFX()
|
||||
? L("UserPair.Tooltip.Permission.State.Disabled", "Disabled")
|
||||
: L("UserPair.Tooltip.Permission.State.Enabled", "Enabled");
|
||||
ImGui.TextUnformatted(L("UserPair.Tooltip.Permission.Status", "You: {0}, They: {1}", youStatus, theyStatus));
|
||||
ImGui.TextUnformatted("You: " + (_pair.UserPair!.OwnPermissions.IsDisableVFX() ? "Disabled" : "Enabled") + ", They: " + (_pair.UserPair!.OtherPermissions.IsDisableVFX() ? "Disabled" : "Enabled"));
|
||||
}
|
||||
|
||||
ImGui.EndTooltip();
|
||||
@@ -236,9 +252,8 @@ public class DrawUserPair : DrawPairBase
|
||||
ImGui.SameLine(rightSidePos);
|
||||
_uiSharedService.IconText(icon);
|
||||
|
||||
UiSharedService.AttachToolTip(L("UserPair.Tooltip.SharedData", "This user has shared {0} Character Data Sets with you.", sharedData.Count)
|
||||
+ UiSharedService.TooltipSeparator
|
||||
+ L("UserPair.Tooltip.SharedData.OpenHub", "Click to open the Character Data Hub and show the entries."));
|
||||
UiSharedService.AttachToolTip($"This user has shared {sharedData.Count} Character Data Sets with you." + UiSharedService.TooltipSeparator
|
||||
+ "Click to open the Character Data Hub and show the entries.");
|
||||
|
||||
if (ImGui.IsItemClicked(ImGuiMouseButton.Left))
|
||||
{
|
||||
@@ -253,7 +268,7 @@ public class DrawUserPair : DrawPairBase
|
||||
{
|
||||
if (entry.IsVisible)
|
||||
{
|
||||
if (_uiSharedService.IconTextButton(FontAwesomeIcon.Eye, L("UserPair.Menu.Target", "Target player")))
|
||||
if (_uiSharedService.IconTextButton(FontAwesomeIcon.Eye, "Target player"))
|
||||
{
|
||||
_mediator.Publish(new TargetPairMessage(entry));
|
||||
ImGui.CloseCurrentPopup();
|
||||
@@ -261,82 +276,89 @@ public class DrawUserPair : DrawPairBase
|
||||
}
|
||||
if (!entry.IsPaused)
|
||||
{
|
||||
if (_uiSharedService.IconTextButton(FontAwesomeIcon.User, L("UserPair.Menu.OpenProfile", "Open Profile")))
|
||||
if (_uiSharedService.IconTextButton(FontAwesomeIcon.User, "Open Profile"))
|
||||
{
|
||||
_displayHandler.OpenProfile(entry);
|
||||
ImGui.CloseCurrentPopup();
|
||||
}
|
||||
UiSharedService.AttachToolTip(L("UserPair.Menu.OpenProfile.Tooltip", "Opens the profile for this user in a new window"));
|
||||
UiSharedService.AttachToolTip("Opens the profile for this user in a new window");
|
||||
}
|
||||
if (entry.IsVisible)
|
||||
{
|
||||
#if DEBUG
|
||||
if (_uiSharedService.IconTextButton(FontAwesomeIcon.PersonCircleQuestion, L("UserPair.Menu.OpenAnalysis", "Open Analysis")))
|
||||
if (_uiSharedService.IconTextButton(FontAwesomeIcon.PersonCircleQuestion, "Open Analysis"))
|
||||
{
|
||||
_displayHandler.OpenAnalysis(_pair);
|
||||
ImGui.CloseCurrentPopup();
|
||||
}
|
||||
#endif
|
||||
if (_uiSharedService.IconTextButton(FontAwesomeIcon.Sync, L("UserPair.Menu.ReloadData", "Reload last data")))
|
||||
if (_uiSharedService.IconTextButton(FontAwesomeIcon.Sync, "Reload last data"))
|
||||
{
|
||||
entry.ApplyLastReceivedData(forced: true);
|
||||
ImGui.CloseCurrentPopup();
|
||||
}
|
||||
UiSharedService.AttachToolTip(L("UserPair.Menu.ReloadData.Tooltip", "This reapplies the last received character data to this character"));
|
||||
UiSharedService.AttachToolTip("This reapplies the last received character data to this character");
|
||||
}
|
||||
|
||||
if (_uiSharedService.IconTextButton(FontAwesomeIcon.PlayCircle, L("UserPair.Menu.CyclePause", "Cycle pause state")))
|
||||
if (_uiSharedService.IconTextButton(FontAwesomeIcon.PlayCircle, "Cycle pause state"))
|
||||
{
|
||||
_ = _apiController.CyclePause(entry.UserData);
|
||||
ImGui.CloseCurrentPopup();
|
||||
}
|
||||
var entryUID = entry.UserData.AliasOrUID;
|
||||
if (_uiSharedService.IconTextButton(FontAwesomeIcon.Folder, L("UserPair.Menu.PairGroups", "Pair Groups")))
|
||||
if (_uiSharedService.IconTextButton(FontAwesomeIcon.Folder, "Pair Groups"))
|
||||
{
|
||||
_selectGroupForPairUi.Open(entry);
|
||||
}
|
||||
UiSharedService.AttachToolTip(L("UserPair.Menu.PairGroups.Tooltip", "Choose pair groups for {0}", entryUID));
|
||||
UiSharedService.AttachToolTip(AppendSeenInfo("Choose pair groups for " + entryUID));
|
||||
|
||||
var isDisableSounds = entry.UserPair!.OwnPermissions.IsDisableSounds();
|
||||
string disableSoundsText = isDisableSounds
|
||||
? L("UserPair.Menu.EnableSoundSync", "Enable sound sync")
|
||||
: L("UserPair.Menu.DisableSoundSync", "Disable sound sync");
|
||||
var disableSoundsIcon = isDisableSounds ? FontAwesomeIcon.VolumeUp : FontAwesomeIcon.VolumeMute;
|
||||
string disableSoundsText = isDisableSounds ? "Enable sound sync" : "Disable sound sync";
|
||||
var disableSoundsIcon = isDisableSounds ? FontAwesomeIcon.VolumeMute : FontAwesomeIcon.VolumeUp;
|
||||
if (_uiSharedService.IconTextButton(disableSoundsIcon, disableSoundsText))
|
||||
{
|
||||
var permissions = entry.UserPair.OwnPermissions;
|
||||
permissions.SetDisableSounds(!isDisableSounds);
|
||||
_mediator.Publish(new PairSyncOverrideChanged(entry.UserData.UID, permissions.IsDisableSounds(), null, null));
|
||||
_ = _apiController.UserSetPairPermissions(new UserPermissionsDto(entry.UserData, permissions));
|
||||
}
|
||||
|
||||
var isDisableAnims = entry.UserPair!.OwnPermissions.IsDisableAnimations();
|
||||
string disableAnimsText = isDisableAnims
|
||||
? L("UserPair.Menu.EnableAnimationSync", "Enable animation sync")
|
||||
: L("UserPair.Menu.DisableAnimationSync", "Disable animation sync");
|
||||
var disableAnimsIcon = isDisableAnims ? FontAwesomeIcon.Running : FontAwesomeIcon.Stop;
|
||||
string disableAnimsText = isDisableAnims ? "Enable animation sync" : "Disable animation sync";
|
||||
var disableAnimsIcon = isDisableAnims ? FontAwesomeIcon.WindowClose : FontAwesomeIcon.Running;
|
||||
if (_uiSharedService.IconTextButton(disableAnimsIcon, disableAnimsText))
|
||||
{
|
||||
var permissions = entry.UserPair.OwnPermissions;
|
||||
permissions.SetDisableAnimations(!isDisableAnims);
|
||||
_mediator.Publish(new PairSyncOverrideChanged(entry.UserData.UID, null, permissions.IsDisableAnimations(), null));
|
||||
_ = _apiController.UserSetPairPermissions(new UserPermissionsDto(entry.UserData, permissions));
|
||||
}
|
||||
|
||||
var isDisableVFX = entry.UserPair!.OwnPermissions.IsDisableVFX();
|
||||
string disableVFXText = isDisableVFX
|
||||
? L("UserPair.Menu.EnableVfxSync", "Enable VFX sync")
|
||||
: L("UserPair.Menu.DisableVfxSync", "Disable VFX sync");
|
||||
var disableVFXIcon = isDisableVFX ? FontAwesomeIcon.Sun : FontAwesomeIcon.Circle;
|
||||
string disableVFXText = isDisableVFX ? "Enable VFX sync" : "Disable VFX sync";
|
||||
var disableVFXIcon = isDisableVFX ? FontAwesomeIcon.TimesCircle : FontAwesomeIcon.Sun;
|
||||
if (_uiSharedService.IconTextButton(disableVFXIcon, disableVFXText))
|
||||
{
|
||||
var permissions = entry.UserPair.OwnPermissions;
|
||||
permissions.SetDisableVFX(!isDisableVFX);
|
||||
_mediator.Publish(new PairSyncOverrideChanged(entry.UserData.UID, null, null, permissions.IsDisableVFX()));
|
||||
_ = _apiController.UserSetPairPermissions(new UserPermissionsDto(entry.UserData, permissions));
|
||||
}
|
||||
|
||||
if (_uiSharedService.IconTextButton(FontAwesomeIcon.Trash, L("UserPair.Menu.Unpair", "Unpair Permanently")) && UiSharedService.CtrlPressed())
|
||||
if (_uiSharedService.IconTextButton(FontAwesomeIcon.Trash, "Unpair Permanently") && UiSharedService.CtrlPressed())
|
||||
{
|
||||
_ = _apiController.UserRemovePair(new(entry.UserData));
|
||||
}
|
||||
UiSharedService.AttachToolTip(L("UserPair.Menu.Unpair.Tooltip", "Hold CTRL and click to unpair permanently from {0}", entryUID));
|
||||
UiSharedService.AttachToolTip(AppendSeenInfo("Hold CTRL and click to unpair permanently from " + entryUID));
|
||||
}
|
||||
|
||||
private string AppendSeenInfo(string tooltip)
|
||||
{
|
||||
if (_pair.IsVisible) return tooltip;
|
||||
|
||||
var lastSeen = _serverConfigurationManager.GetNameForUid(_pair.UserData.UID);
|
||||
if (string.IsNullOrWhiteSpace(lastSeen)) return tooltip;
|
||||
|
||||
return tooltip + " (Vu sous : " + lastSeen + ")";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,12 +12,12 @@ using MareSynchronos.API.Dto.Group;
|
||||
using MareSynchronos.MareConfiguration;
|
||||
using MareSynchronos.PlayerData.Pairs;
|
||||
using MareSynchronos.Services;
|
||||
using MareSynchronos.Services.AutoDetect;
|
||||
using MareSynchronos.Services.Mediator;
|
||||
using MareSynchronos.Services.ServerConfiguration;
|
||||
using MareSynchronos.UI.Components;
|
||||
using MareSynchronos.UI.Handlers;
|
||||
using MareSynchronos.WebAPI;
|
||||
using MareSynchronos.Localization;
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.Numerics;
|
||||
@@ -30,9 +30,9 @@ internal sealed class GroupPanel
|
||||
private readonly CompactUi _mainUi;
|
||||
private readonly PairManager _pairManager;
|
||||
private readonly ChatService _chatService;
|
||||
private readonly MareConfigService _mareConfig;
|
||||
private readonly ServerConfigurationManager _serverConfigurationManager;
|
||||
private readonly CharaDataManager _charaDataManager;
|
||||
private readonly AutoDetectRequestService _autoDetectRequestService;
|
||||
private readonly Dictionary<string, bool> _showGidForEntry = new(StringComparer.Ordinal);
|
||||
private readonly UidDisplayHandler _uidDisplayHandler;
|
||||
private readonly UiSharedService _uiShared;
|
||||
@@ -73,31 +73,25 @@ internal sealed class GroupPanel
|
||||
private string _syncShellPassword = string.Empty;
|
||||
private string _syncShellToJoin = string.Empty;
|
||||
|
||||
private static string L(string key, string fallback, params object[] args)
|
||||
{
|
||||
var safeArgs = args ?? Array.Empty<object>();
|
||||
return LocalizationService.Instance?.GetString(key, fallback, safeArgs)
|
||||
?? string.Format(CultureInfo.CurrentCulture, fallback, safeArgs);
|
||||
}
|
||||
|
||||
public GroupPanel(CompactUi mainUi, UiSharedService uiShared, PairManager pairManager, ChatService chatServivce,
|
||||
UidDisplayHandler uidDisplayHandler, MareConfigService mareConfig, ServerConfigurationManager serverConfigurationManager,
|
||||
CharaDataManager charaDataManager)
|
||||
UidDisplayHandler uidDisplayHandler, ServerConfigurationManager serverConfigurationManager,
|
||||
CharaDataManager charaDataManager, AutoDetectRequestService autoDetectRequestService)
|
||||
{
|
||||
_mainUi = mainUi;
|
||||
_uiShared = uiShared;
|
||||
_pairManager = pairManager;
|
||||
_chatService = chatServivce;
|
||||
_uidDisplayHandler = uidDisplayHandler;
|
||||
_mareConfig = mareConfig;
|
||||
_serverConfigurationManager = serverConfigurationManager;
|
||||
_charaDataManager = charaDataManager;
|
||||
_autoDetectRequestService = autoDetectRequestService;
|
||||
}
|
||||
|
||||
private ApiController ApiController => _uiShared.ApiController;
|
||||
|
||||
public void DrawSyncshells()
|
||||
{
|
||||
using var fontScale = UiSharedService.PushFontScale(UiSharedService.ContentFontScale);
|
||||
using (ImRaii.PushId("addsyncshell")) DrawAddSyncshell();
|
||||
using (ImRaii.PushId("syncshelllist")) DrawSyncshellList();
|
||||
_mainUi.TransferPartHeight = ImGui.GetCursorPosY();
|
||||
@@ -107,15 +101,13 @@ internal sealed class GroupPanel
|
||||
{
|
||||
var buttonSize = _uiShared.GetIconButtonSize(FontAwesomeIcon.Plus);
|
||||
ImGui.SetNextItemWidth(UiSharedService.GetWindowContentRegionWidth() - ImGui.GetWindowContentRegionMin().X - buttonSize.X);
|
||||
ImGui.InputTextWithHint("##syncshellid", L("GroupPanel.Join.InputHint", "Syncshell GID/Alias (leave empty to create)"), ref _syncShellToJoin, 50);
|
||||
ImGui.InputTextWithHint("##syncshellid", "Syncshell GID/Alias (leave empty to create)", ref _syncShellToJoin, 50);
|
||||
ImGui.SameLine(ImGui.GetWindowContentRegionMin().X + UiSharedService.GetWindowContentRegionWidth() - buttonSize.X);
|
||||
|
||||
bool userCanJoinMoreGroups = _pairManager.GroupPairs.Count < ApiController.ServerInfo.MaxGroupsJoinedByUser;
|
||||
bool userCanCreateMoreGroups = _pairManager.GroupPairs.Count(u => string.Equals(u.Key.Owner.UID, ApiController.UID, StringComparison.Ordinal)) < ApiController.ServerInfo.MaxGroupsCreatedByUser;
|
||||
bool alreadyInGroup = _pairManager.GroupPairs.Select(p => p.Key).Any(p => string.Equals(p.Group.Alias, _syncShellToJoin, StringComparison.Ordinal)
|
||||
|| string.Equals(p.Group.GID, _syncShellToJoin, StringComparison.Ordinal));
|
||||
var enterPasswordPopupTitle = L("GroupPanel.Join.PasswordPopup", "Enter Syncshell Password");
|
||||
var createPopupTitle = L("GroupPanel.Create.PopupTitle", "Create Syncshell");
|
||||
|
||||
if (alreadyInGroup) ImGui.BeginDisabled();
|
||||
if (_uiShared.IconButton(FontAwesomeIcon.Plus))
|
||||
@@ -126,7 +118,7 @@ internal sealed class GroupPanel
|
||||
{
|
||||
_errorGroupJoin = false;
|
||||
_showModalEnterPassword = true;
|
||||
ImGui.OpenPopup(enterPasswordPopupTitle);
|
||||
ImGui.OpenPopup("Enter Syncshell Password");
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -140,37 +132,30 @@ internal sealed class GroupPanel
|
||||
_tempSyncshellDurationHours = 24;
|
||||
_errorGroupCreateMessage = string.Empty;
|
||||
_showModalCreateGroup = true;
|
||||
ImGui.OpenPopup(createPopupTitle);
|
||||
ImGui.OpenPopup("Create Syncshell");
|
||||
}
|
||||
}
|
||||
}
|
||||
UiSharedService.AttachToolTip(_syncShellToJoin.IsNullOrEmpty()
|
||||
? (userCanCreateMoreGroups
|
||||
? L("GroupPanel.Create.Tooltip", "Create Syncshell")
|
||||
: L("GroupPanel.Create.TooMany", "You cannot create more than {0} Syncshells", ApiController.ServerInfo.MaxGroupsCreatedByUser))
|
||||
: (userCanJoinMoreGroups
|
||||
? L("GroupPanel.Join.Tooltip", "Join Syncshell {0}", _syncShellToJoin)
|
||||
: L("GroupPanel.Join.TooMany", "You cannot join more than {0} Syncshells", ApiController.ServerInfo.MaxGroupsJoinedByUser)));
|
||||
? (userCanCreateMoreGroups ? "Create Syncshell" : $"You cannot create more than {ApiController.ServerInfo.MaxGroupsCreatedByUser} Syncshells")
|
||||
: (userCanJoinMoreGroups ? "Join Syncshell" + _syncShellToJoin : $"You cannot join more than {ApiController.ServerInfo.MaxGroupsJoinedByUser} Syncshells"));
|
||||
|
||||
if (alreadyInGroup) ImGui.EndDisabled();
|
||||
|
||||
if (ImGui.BeginPopupModal(enterPasswordPopupTitle, ref _showModalEnterPassword, UiSharedService.PopupWindowFlags))
|
||||
if (ImGui.BeginPopupModal("Enter Syncshell Password", ref _showModalEnterPassword, UiSharedService.PopupWindowFlags))
|
||||
{
|
||||
UiSharedService.TextWrapped(L("GroupPanel.Join.Warning", "Before joining any Syncshells please be aware that you will be automatically paired with everyone in the Syncshell."));
|
||||
UiSharedService.TextWrapped("Before joining any Syncshells please be aware that you will be automatically paired with everyone in the Syncshell.");
|
||||
ImGui.Separator();
|
||||
UiSharedService.TextWrapped(L("GroupPanel.Join.EnterPassword", "Enter the password for Syncshell {0}:", _syncShellToJoin));
|
||||
UiSharedService.TextWrapped("Enter the password for Syncshell " + _syncShellToJoin + ":");
|
||||
ImGui.SetNextItemWidth(-1);
|
||||
ImGui.InputTextWithHint("##password", L("GroupPanel.Join.PasswordHint", "{0} Password", _syncShellToJoin), ref _syncShellPassword, 255, ImGuiInputTextFlags.Password);
|
||||
ImGui.InputTextWithHint("##password", _syncShellToJoin + " Password", ref _syncShellPassword, 255, ImGuiInputTextFlags.Password);
|
||||
if (_errorGroupJoin)
|
||||
{
|
||||
UiSharedService.ColorTextWrapped(
|
||||
L("GroupPanel.Join.Error",
|
||||
"An error occured during joining of this Syncshell: you either have joined the maximum amount of Syncshells ({0}), it does not exist, the password you entered is wrong, you already joined the Syncshell, the Syncshell is full ({1} users) or the Syncshell has closed invites.",
|
||||
ApiController.ServerInfo.MaxGroupsJoinedByUser,
|
||||
ApiController.ServerInfo.MaxGroupUserCount),
|
||||
UiSharedService.ColorTextWrapped($"An error occured during joining of this Syncshell: you either have joined the maximum amount of Syncshells ({ApiController.ServerInfo.MaxGroupsJoinedByUser}), " +
|
||||
$"it does not exist, the password you entered is wrong, you already joined the Syncshell, the Syncshell is full ({ApiController.ServerInfo.MaxGroupUserCount} users) or the Syncshell has closed invites.",
|
||||
new Vector4(1, 0, 0, 1));
|
||||
}
|
||||
if (ImGui.Button(L("GroupPanel.Join.Button", "Join {0}", _syncShellToJoin)))
|
||||
if (ImGui.Button("Join " + _syncShellToJoin))
|
||||
{
|
||||
var shell = _syncShellToJoin;
|
||||
var pw = _syncShellPassword;
|
||||
@@ -186,16 +171,16 @@ internal sealed class GroupPanel
|
||||
ImGui.EndPopup();
|
||||
}
|
||||
|
||||
if (ImGui.BeginPopupModal(createPopupTitle, ref _showModalCreateGroup, UiSharedService.PopupWindowFlags))
|
||||
if (ImGui.BeginPopupModal("Create Syncshell", ref _showModalCreateGroup, UiSharedService.PopupWindowFlags))
|
||||
{
|
||||
UiSharedService.TextWrapped(L("GroupPanel.Create.ChooseType", "Choisissez le type de Syncshell à créer."));
|
||||
UiSharedService.TextWrapped("Choisissez le type de Syncshell à créer.");
|
||||
bool showPermanent = !_createIsTemporary;
|
||||
if (ImGui.RadioButton(L("GroupPanel.Create.Permanent", "Permanente"), showPermanent))
|
||||
if (ImGui.RadioButton("Permanente", showPermanent))
|
||||
{
|
||||
_createIsTemporary = false;
|
||||
}
|
||||
ImGui.SameLine();
|
||||
if (ImGui.RadioButton(L("GroupPanel.Create.Temporary", "Temporaire"), _createIsTemporary))
|
||||
if (ImGui.RadioButton("Temporaire", _createIsTemporary))
|
||||
{
|
||||
_createIsTemporary = true;
|
||||
_newSyncShellAlias = string.Empty;
|
||||
@@ -203,9 +188,9 @@ internal sealed class GroupPanel
|
||||
|
||||
if (!_createIsTemporary)
|
||||
{
|
||||
UiSharedService.TextWrapped(L("GroupPanel.Create.AliasPrompt", "Donnez un nom à votre Syncshell (optionnel) puis créez-la."));
|
||||
UiSharedService.TextWrapped("Donnez un nom à votre Syncshell (optionnel) puis créez-la.");
|
||||
ImGui.SetNextItemWidth(-1);
|
||||
ImGui.InputTextWithHint("##syncshellalias", L("GroupPanel.Create.AliasHint", "Nom du Syncshell"), ref _newSyncShellAlias, 50);
|
||||
ImGui.InputTextWithHint("##syncshellalias", "Nom du Syncshell", ref _newSyncShellAlias, 50);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -214,7 +199,7 @@ internal sealed class GroupPanel
|
||||
|
||||
if (_createIsTemporary)
|
||||
{
|
||||
UiSharedService.TextWrapped(L("GroupPanel.Create.TempMaxDuration", "Durée maximale d'une Syncshell temporaire : 7 jours."));
|
||||
UiSharedService.TextWrapped("Durée maximale d'une Syncshell temporaire : 7 jours.");
|
||||
if (_tempSyncshellDurationHours > 168) _tempSyncshellDurationHours = 168;
|
||||
for (int i = 0; i < _temporaryDurationOptions.Length; i++)
|
||||
{
|
||||
@@ -222,10 +207,8 @@ internal sealed class GroupPanel
|
||||
var isSelected = _tempSyncshellDurationHours == option;
|
||||
string label = option switch
|
||||
{
|
||||
>= 24 when option % 24 == 0 => option == 24
|
||||
? L("GroupPanel.Create.Duration.SingleDay", "24h")
|
||||
: L("GroupPanel.Create.Duration.Days", "{0}j", option / 24),
|
||||
_ => L("GroupPanel.Create.Duration.Hours", "{0}h", option)
|
||||
>= 24 when option % 24 == 0 => option == 24 ? "24h" : $"{option / 24}j",
|
||||
_ => option + "h"
|
||||
};
|
||||
|
||||
if (ImGui.RadioButton(label, isSelected))
|
||||
@@ -233,6 +216,7 @@ internal sealed class GroupPanel
|
||||
_tempSyncshellDurationHours = option;
|
||||
}
|
||||
|
||||
// Start a new line after every 3 buttons
|
||||
if ((i + 1) % 3 == 0)
|
||||
{
|
||||
ImGui.NewLine();
|
||||
@@ -244,12 +228,12 @@ internal sealed class GroupPanel
|
||||
}
|
||||
|
||||
var expiresLocal = DateTime.Now.AddHours(_tempSyncshellDurationHours);
|
||||
UiSharedService.TextWrapped(L("GroupPanel.Create.TempExpires", "Expiration le {0:g} (heure locale).", expiresLocal));
|
||||
UiSharedService.TextWrapped($"Expiration le {expiresLocal:g} (heure locale).");
|
||||
}
|
||||
|
||||
UiSharedService.TextWrapped(L("GroupPanel.Create.Instruction", "Appuyez sur le bouton ci-dessous pour créer une nouvelle Syncshell."));
|
||||
UiSharedService.TextWrapped("Appuyez sur le bouton ci-dessous pour créer une nouvelle Syncshell.");
|
||||
ImGui.SetNextItemWidth(200 * ImGuiHelpers.GlobalScale);
|
||||
if (ImGui.Button(L("GroupPanel.Create.Button", "Create Syncshell")))
|
||||
if (ImGui.Button("Create Syncshell"))
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -274,7 +258,7 @@ internal sealed class GroupPanel
|
||||
_errorGroupCreate = true;
|
||||
if (ex.Message.Contains("name is already in use", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
_errorGroupCreateMessage = L("GroupPanel.Create.Error.NameInUse", "Le nom de la Syncshell est déjà utilisé.");
|
||||
_errorGroupCreateMessage = "Le nom de la Syncshell est déjà utilisé.";
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -290,28 +274,28 @@ internal sealed class GroupPanel
|
||||
_errorGroupCreateMessage = string.Empty;
|
||||
if (!string.IsNullOrWhiteSpace(_lastCreatedGroup.Group.Alias))
|
||||
{
|
||||
ImGui.TextUnformatted(L("GroupPanel.Create.Result.Name", "Syncshell Name: {0}", _lastCreatedGroup.Group.Alias));
|
||||
ImGui.TextUnformatted("Syncshell Name: " + _lastCreatedGroup.Group.Alias);
|
||||
}
|
||||
ImGui.TextUnformatted(L("GroupPanel.Create.Result.Id", "Syncshell ID: {0}", _lastCreatedGroup.Group.GID));
|
||||
ImGui.TextUnformatted("Syncshell ID: " + _lastCreatedGroup.Group.GID);
|
||||
ImGui.AlignTextToFramePadding();
|
||||
ImGui.TextUnformatted(L("GroupPanel.Create.Result.Password", "Syncshell Password: {0}", _lastCreatedGroup.Password));
|
||||
ImGui.TextUnformatted("Syncshell Password: " + _lastCreatedGroup.Password);
|
||||
ImGui.SameLine();
|
||||
if (_uiShared.IconButton(FontAwesomeIcon.Copy))
|
||||
{
|
||||
ImGui.SetClipboardText(_lastCreatedGroup.Password);
|
||||
}
|
||||
UiSharedService.TextWrapped(L("GroupPanel.Create.Result.ChangeLater", "You can change the Syncshell password later at any time."));
|
||||
UiSharedService.TextWrapped("You can change the Syncshell password later at any time.");
|
||||
if (_lastCreatedGroup.IsTemporary && _lastCreatedGroup.ExpiresAt != null)
|
||||
{
|
||||
var expiresLocal = _lastCreatedGroup.ExpiresAt.Value.ToLocalTime();
|
||||
UiSharedService.TextWrapped(L("GroupPanel.Create.Result.TempExpires", "Cette Syncshell expirera le {0:g} (heure locale).", expiresLocal));
|
||||
UiSharedService.TextWrapped($"Cette Syncshell expirera le {expiresLocal:g} (heure locale).");
|
||||
}
|
||||
}
|
||||
|
||||
if (_errorGroupCreate)
|
||||
{
|
||||
var msg = string.IsNullOrWhiteSpace(_errorGroupCreateMessage)
|
||||
? L("GroupPanel.Create.Error.Generic", "You are already owner of the maximum amount of Syncshells (3) or joined the maximum amount of Syncshells (6). Relinquish ownership of your own Syncshells to someone else or leave existing Syncshells.")
|
||||
? "You are already owner of the maximum amount of Syncshells (3) or joined the maximum amount of Syncshells (6). Relinquish ownership of your own Syncshells to someone else or leave existing Syncshells."
|
||||
: _errorGroupCreateMessage;
|
||||
UiSharedService.ColorTextWrapped(msg, new Vector4(1, 0, 0, 1));
|
||||
}
|
||||
@@ -328,19 +312,20 @@ internal sealed class GroupPanel
|
||||
int shellNumber = _serverConfigurationManager.GetShellNumberForGid(groupDto.GID);
|
||||
|
||||
var name = groupDto.Group.Alias ?? groupDto.GID;
|
||||
if (!_expandedGroupState.TryGetValue(groupDto.GID, out bool isExpanded))
|
||||
if (!_expandedGroupState.ContainsKey(groupDto.GID))
|
||||
{
|
||||
isExpanded = false;
|
||||
_expandedGroupState.Add(groupDto.GID, isExpanded);
|
||||
_expandedGroupState[groupDto.GID] = false;
|
||||
}
|
||||
|
||||
var icon = isExpanded ? FontAwesomeIcon.CaretSquareDown : FontAwesomeIcon.CaretSquareRight;
|
||||
_uiShared.IconText(icon);
|
||||
if (ImGui.IsItemClicked(ImGuiMouseButton.Left))
|
||||
UiSharedService.DrawCard($"syncshell-card-{groupDto.GID}", () =>
|
||||
{
|
||||
_expandedGroupState[groupDto.GID] = !_expandedGroupState[groupDto.GID];
|
||||
bool expandedState = _expandedGroupState[groupDto.GID];
|
||||
UiSharedService.DrawArrowToggle(ref expandedState, $"##syncshell-toggle-{groupDto.GID}");
|
||||
if (expandedState != _expandedGroupState[groupDto.GID])
|
||||
{
|
||||
_expandedGroupState[groupDto.GID] = expandedState;
|
||||
}
|
||||
ImGui.SameLine();
|
||||
ImGui.SameLine(0f, 6f * ImGuiHelpers.GlobalScale);
|
||||
|
||||
var textIsGid = true;
|
||||
string groupName = groupDto.GroupAliasOrGID;
|
||||
@@ -350,7 +335,7 @@ internal sealed class GroupPanel
|
||||
ImGui.PushFont(UiBuilder.IconFont);
|
||||
ImGui.TextUnformatted(FontAwesomeIcon.Crown.ToIconString());
|
||||
ImGui.PopFont();
|
||||
UiSharedService.AttachToolTip(L("GroupPanel.Syncshell.OwnerTooltip", "You are the owner of Syncshell {0}", groupName));
|
||||
UiSharedService.AttachToolTip("You are the owner of Syncshell " + groupName);
|
||||
ImGui.SameLine();
|
||||
}
|
||||
else if (groupDto.GroupUserInfo.IsModerator())
|
||||
@@ -358,7 +343,7 @@ internal sealed class GroupPanel
|
||||
ImGui.PushFont(UiBuilder.IconFont);
|
||||
ImGui.TextUnformatted(FontAwesomeIcon.UserShield.ToIconString());
|
||||
ImGui.PopFont();
|
||||
UiSharedService.AttachToolTip(L("GroupPanel.Syncshell.ModeratorTooltip", "You are a moderator of Syncshell {0}", groupName));
|
||||
UiSharedService.AttachToolTip("You are a moderator of Syncshell " + groupName);
|
||||
ImGui.SameLine();
|
||||
}
|
||||
|
||||
@@ -376,33 +361,29 @@ internal sealed class GroupPanel
|
||||
var totalMembers = pairsInGroup.Count + 1;
|
||||
var connectedMembers = pairsInGroup.Count(p => p.IsOnline) + 1;
|
||||
var maxCapacity = ApiController.ServerInfo.MaxGroupUserCount;
|
||||
ImGui.TextUnformatted(L("GroupPanel.Syncshell.MemberCount", "{0}/{1}", connectedMembers, totalMembers));
|
||||
UiSharedService.AttachToolTip(
|
||||
L("GroupPanel.Syncshell.MemberCountTooltip",
|
||||
"Membres connectés / membres totaux\nCapacité maximale : {0}\nSyncshell ID: {1}",
|
||||
maxCapacity,
|
||||
groupDto.Group.GID));
|
||||
ImGui.TextUnformatted($"{connectedMembers}/{totalMembers}");
|
||||
UiSharedService.AttachToolTip("Membres connectés / membres totaux" + Environment.NewLine +
|
||||
$"Capacité maximale : {maxCapacity}" + Environment.NewLine +
|
||||
"Syncshell ID: " + groupDto.Group.GID);
|
||||
if (textIsGid) ImGui.PushFont(UiBuilder.MonoFont);
|
||||
ImGui.SameLine();
|
||||
ImGui.TextUnformatted(groupName);
|
||||
if (textIsGid) ImGui.PopFont();
|
||||
UiSharedService.AttachToolTip(L("GroupPanel.Syncshell.NameTooltip",
|
||||
"Left click to switch between GID display and comment\nRight click to change comment for {0}\n\nUsers: {1}, Owner: {2}",
|
||||
groupName,
|
||||
pairsInGroup.Count + 1,
|
||||
groupDto.OwnerAliasOrUID));
|
||||
UiSharedService.AttachToolTip("Left click to switch between GID display and comment" + Environment.NewLine +
|
||||
"Right click to change comment for " + groupName + Environment.NewLine + Environment.NewLine
|
||||
+ "Users: " + (pairsInGroup.Count + 1) + ", Owner: " + groupDto.OwnerAliasOrUID);
|
||||
if (groupDto.IsTemporary)
|
||||
{
|
||||
ImGui.SameLine();
|
||||
UiSharedService.ColorText(L("GroupPanel.Syncshell.TempTag", "(Temp)"), ImGuiColors.DalamudOrange);
|
||||
UiSharedService.ColorText("(Temp)", ImGuiColors.DalamudOrange);
|
||||
if (groupDto.ExpiresAt != null)
|
||||
{
|
||||
var tempExpireLocal = groupDto.ExpiresAt.Value.ToLocalTime();
|
||||
UiSharedService.AttachToolTip(L("GroupPanel.Syncshell.TempExpires", "Expire le {0:g}", tempExpireLocal));
|
||||
UiSharedService.AttachToolTip($"Expire le {tempExpireLocal:g}");
|
||||
}
|
||||
else
|
||||
{
|
||||
UiSharedService.AttachToolTip(L("GroupPanel.Syncshell.TempTooltip", "Syncshell temporaire"));
|
||||
UiSharedService.AttachToolTip("Syncshell temporaire");
|
||||
}
|
||||
}
|
||||
if (ImGui.IsItemClicked(ImGuiMouseButton.Left))
|
||||
@@ -428,7 +409,7 @@ internal sealed class GroupPanel
|
||||
{
|
||||
var buttonSizes = _uiShared.GetIconButtonSize(FontAwesomeIcon.Bars).X + _uiShared.GetIconButtonSize(FontAwesomeIcon.LockOpen).X;
|
||||
ImGui.SetNextItemWidth(UiSharedService.GetWindowContentRegionWidth() - ImGui.GetCursorPosX() - buttonSizes - ImGui.GetStyle().ItemSpacing.X * 2);
|
||||
if (ImGui.InputTextWithHint("", L("GroupPanel.CommentHint", "Comment/Notes"), ref _editGroupComment, 255, ImGuiInputTextFlags.EnterReturnsTrue))
|
||||
if (ImGui.InputTextWithHint("", "Comment/Notes", ref _editGroupComment, 255, ImGuiInputTextFlags.EnterReturnsTrue))
|
||||
{
|
||||
_serverConfigurationManager.SetNoteForGid(groupDto.GID, _editGroupComment);
|
||||
_editGroupEntry = string.Empty;
|
||||
@@ -439,7 +420,7 @@ internal sealed class GroupPanel
|
||||
{
|
||||
_editGroupEntry = string.Empty;
|
||||
}
|
||||
UiSharedService.AttachToolTip(L("GroupPanel.CommentTooltip", "Hit ENTER to save\nRight click to cancel"));
|
||||
UiSharedService.AttachToolTip("Hit ENTER to save\nRight click to cancel");
|
||||
}
|
||||
|
||||
|
||||
@@ -448,26 +429,26 @@ internal sealed class GroupPanel
|
||||
if (_showModalBanList && !_modalBanListOpened)
|
||||
{
|
||||
_modalBanListOpened = true;
|
||||
ImGui.OpenPopup(L("GroupPanel.Banlist.Title", "Manage Banlist for {0}", groupDto.GID));
|
||||
ImGui.OpenPopup("Manage Banlist for " + groupDto.GID);
|
||||
}
|
||||
|
||||
if (!_showModalBanList) _modalBanListOpened = false;
|
||||
|
||||
if (ImGui.BeginPopupModal(L("GroupPanel.Banlist.Title", "Manage Banlist for {0}", groupDto.GID), ref _showModalBanList, UiSharedService.PopupWindowFlags))
|
||||
if (ImGui.BeginPopupModal("Manage Banlist for " + groupDto.GID, ref _showModalBanList, UiSharedService.PopupWindowFlags))
|
||||
{
|
||||
if (_uiShared.IconTextButton(FontAwesomeIcon.Retweet, L("GroupPanel.Banlist.Refresh", "Refresh Banlist from Server")))
|
||||
if (_uiShared.IconTextButton(FontAwesomeIcon.Retweet, "Refresh Banlist from Server"))
|
||||
{
|
||||
_bannedUsers = ApiController.GroupGetBannedUsers(groupDto).Result;
|
||||
}
|
||||
|
||||
if (ImGui.BeginTable("bannedusertable" + groupDto.GID, 6, ImGuiTableFlags.RowBg | ImGuiTableFlags.SizingStretchProp | ImGuiTableFlags.ScrollY))
|
||||
{
|
||||
ImGui.TableSetupColumn(L("GroupPanel.Banlist.Column.Uid", "UID"), ImGuiTableColumnFlags.None, 1);
|
||||
ImGui.TableSetupColumn(L("GroupPanel.Banlist.Column.Alias", "Alias"), ImGuiTableColumnFlags.None, 1);
|
||||
ImGui.TableSetupColumn(L("GroupPanel.Banlist.Column.By", "By"), ImGuiTableColumnFlags.None, 1);
|
||||
ImGui.TableSetupColumn(L("GroupPanel.Banlist.Column.Date", "Date"), ImGuiTableColumnFlags.None, 2);
|
||||
ImGui.TableSetupColumn(L("GroupPanel.Banlist.Column.Reason", "Reason"), ImGuiTableColumnFlags.None, 3);
|
||||
ImGui.TableSetupColumn(L("GroupPanel.Banlist.Column.Actions", "Actions"), ImGuiTableColumnFlags.None, 1);
|
||||
ImGui.TableSetupColumn("UID", ImGuiTableColumnFlags.None, 1);
|
||||
ImGui.TableSetupColumn("Alias", ImGuiTableColumnFlags.None, 1);
|
||||
ImGui.TableSetupColumn("By", ImGuiTableColumnFlags.None, 1);
|
||||
ImGui.TableSetupColumn("Date", ImGuiTableColumnFlags.None, 2);
|
||||
ImGui.TableSetupColumn("Reason", ImGuiTableColumnFlags.None, 3);
|
||||
ImGui.TableSetupColumn("Actions", ImGuiTableColumnFlags.None, 1);
|
||||
|
||||
ImGui.TableHeadersRow();
|
||||
|
||||
@@ -484,7 +465,7 @@ internal sealed class GroupPanel
|
||||
ImGui.TableNextColumn();
|
||||
UiSharedService.TextWrapped(bannedUser.Reason);
|
||||
ImGui.TableNextColumn();
|
||||
if (_uiShared.IconTextButton(FontAwesomeIcon.Check, L("GroupPanel.Banlist.Unban", "Unban") + "#" + bannedUser.UID))
|
||||
if (_uiShared.IconTextButton(FontAwesomeIcon.Check, "Unban#" + bannedUser.UID))
|
||||
{
|
||||
_ = ApiController.GroupUnbanUser(bannedUser);
|
||||
_bannedUsers.RemoveAll(b => string.Equals(b.UID, bannedUser.UID, StringComparison.Ordinal));
|
||||
@@ -500,18 +481,18 @@ internal sealed class GroupPanel
|
||||
if (_showModalChangePassword && !_modalChangePwOpened)
|
||||
{
|
||||
_modalChangePwOpened = true;
|
||||
ImGui.OpenPopup(L("GroupPanel.Password.Title", "Change Syncshell Password"));
|
||||
ImGui.OpenPopup("Change Syncshell Password");
|
||||
}
|
||||
|
||||
if (!_showModalChangePassword) _modalChangePwOpened = false;
|
||||
|
||||
if (ImGui.BeginPopupModal(L("GroupPanel.Password.Title", "Change Syncshell Password"), ref _showModalChangePassword, UiSharedService.PopupWindowFlags))
|
||||
if (ImGui.BeginPopupModal("Change Syncshell Password", ref _showModalChangePassword, UiSharedService.PopupWindowFlags))
|
||||
{
|
||||
UiSharedService.TextWrapped(L("GroupPanel.Password.Description", "Enter the new Syncshell password for Syncshell {0} here.", name));
|
||||
UiSharedService.TextWrapped(L("GroupPanel.Password.Warning", "This action is irreversible"));
|
||||
UiSharedService.TextWrapped("Enter the new Syncshell password for Syncshell " + name + " here.");
|
||||
UiSharedService.TextWrapped("This action is irreversible");
|
||||
ImGui.SetNextItemWidth(-1);
|
||||
ImGui.InputTextWithHint("##changepw", L("GroupPanel.Password.Hint", "New password for {0}", name), ref _newSyncShellPassword, 255);
|
||||
if (ImGui.Button(L("GroupPanel.Password.Button", "Change password")))
|
||||
ImGui.InputTextWithHint("##changepw", "New password for " + name, ref _newSyncShellPassword, 255);
|
||||
if (ImGui.Button("Change password"))
|
||||
{
|
||||
var pw = _newSyncShellPassword;
|
||||
_isPasswordValid = ApiController.GroupChangePassword(new(groupDto.Group, pw)).Result;
|
||||
@@ -521,7 +502,7 @@ internal sealed class GroupPanel
|
||||
|
||||
if (!_isPasswordValid)
|
||||
{
|
||||
UiSharedService.ColorTextWrapped(L("GroupPanel.Password.Error.TooShort", "The selected password is too short. It must be at least 10 characters."), new Vector4(1, 0, 0, 1));
|
||||
UiSharedService.ColorTextWrapped("The selected password is too short. It must be at least 10 characters.", new Vector4(1, 0, 0, 1));
|
||||
}
|
||||
|
||||
UiSharedService.SetScaledWindowSize(290);
|
||||
@@ -531,28 +512,29 @@ internal sealed class GroupPanel
|
||||
if (_showModalBulkOneTimeInvites && !_modalBulkOneTimeInvitesOpened)
|
||||
{
|
||||
_modalBulkOneTimeInvitesOpened = true;
|
||||
ImGui.OpenPopup(L("GroupPanel.Invites.Title", "Create Bulk One-Time Invites"));
|
||||
ImGui.OpenPopup("Create Bulk One-Time Invites");
|
||||
}
|
||||
|
||||
if (!_showModalBulkOneTimeInvites) _modalBulkOneTimeInvitesOpened = false;
|
||||
|
||||
if (ImGui.BeginPopupModal(L("GroupPanel.Invites.Title", "Create Bulk One-Time Invites"), ref _showModalBulkOneTimeInvites, UiSharedService.PopupWindowFlags))
|
||||
if (ImGui.BeginPopupModal("Create Bulk One-Time Invites", ref _showModalBulkOneTimeInvites, UiSharedService.PopupWindowFlags))
|
||||
{
|
||||
UiSharedService.TextWrapped(L("GroupPanel.Invites.Description", "This allows you to create up to 100 one-time invites at once for the Syncshell {0}.\nThe invites are valid for 24h after creation and will automatically expire.", name));
|
||||
UiSharedService.TextWrapped("This allows you to create up to 100 one-time invites at once for the Syncshell " + name + "." + Environment.NewLine
|
||||
+ "The invites are valid for 24h after creation and will automatically expire.");
|
||||
ImGui.Separator();
|
||||
if (_bulkOneTimeInvites.Count == 0)
|
||||
{
|
||||
ImGui.SetNextItemWidth(-1);
|
||||
ImGui.SliderInt(L("GroupPanel.Invites.AmountLabel", "Amount") + "##bulkinvites", ref _bulkInviteCount, 1, 100);
|
||||
if (_uiShared.IconTextButton(FontAwesomeIcon.MailBulk, L("GroupPanel.Invites.CreateButton", "Create invites")))
|
||||
ImGui.SliderInt("Amount##bulkinvites", ref _bulkInviteCount, 1, 100);
|
||||
if (_uiShared.IconTextButton(FontAwesomeIcon.MailBulk, "Create invites"))
|
||||
{
|
||||
_bulkOneTimeInvites = ApiController.GroupCreateTempInvite(groupDto, _bulkInviteCount).Result;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
UiSharedService.TextWrapped(L("GroupPanel.Invites.Result", "A total of {0} invites have been created.", _bulkOneTimeInvites.Count));
|
||||
if (_uiShared.IconTextButton(FontAwesomeIcon.Copy, L("GroupPanel.Invites.Copy", "Copy invites to clipboard")))
|
||||
UiSharedService.TextWrapped("A total of " + _bulkOneTimeInvites.Count + " invites have been created.");
|
||||
if (_uiShared.IconTextButton(FontAwesomeIcon.Copy, "Copy invites to clipboard"))
|
||||
{
|
||||
ImGui.SetClipboardText(string.Join(Environment.NewLine, _bulkOneTimeInvites));
|
||||
}
|
||||
@@ -565,7 +547,7 @@ internal sealed class GroupPanel
|
||||
bool hideOfflineUsers = pairsInGroup.Count > 1000;
|
||||
|
||||
ImGui.Indent(20);
|
||||
if (_expandedGroupState[groupDto.GID])
|
||||
if (expandedState)
|
||||
{
|
||||
var sortedPairs = pairsInGroup
|
||||
.OrderByDescending(u => string.Equals(u.UserData.UID, groupDto.OwnerUID, StringComparison.Ordinal))
|
||||
@@ -587,7 +569,9 @@ internal sealed class GroupPanel
|
||||
).Value,
|
||||
_uidDisplayHandler,
|
||||
_uiShared,
|
||||
_charaDataManager);
|
||||
_charaDataManager,
|
||||
_autoDetectRequestService,
|
||||
_serverConfigurationManager);
|
||||
|
||||
if (pair.IsVisible)
|
||||
visibleUsers.Add(drawPair);
|
||||
@@ -599,14 +583,14 @@ internal sealed class GroupPanel
|
||||
|
||||
if (visibleUsers.Count > 0)
|
||||
{
|
||||
ImGui.TextUnformatted(L("GroupPanel.List.Visible", "Visible"));
|
||||
ImGui.TextUnformatted("Visible");
|
||||
ImGui.Separator();
|
||||
_uidDisplayHandler.RenderPairList(visibleUsers);
|
||||
}
|
||||
|
||||
if (onlineUsers.Count > 0)
|
||||
{
|
||||
ImGui.TextUnformatted(L("GroupPanel.List.Online", "Online"));
|
||||
ImGui.TextUnformatted("Online");
|
||||
ImGui.Separator();
|
||||
_uidDisplayHandler.RenderPairList(onlineUsers);
|
||||
}
|
||||
@@ -614,12 +598,12 @@ internal sealed class GroupPanel
|
||||
if (offlineUsers.Count > 0)
|
||||
{
|
||||
ImGui.PushStyleColor(ImGuiCol.Text, ImGuiColors.DalamudGrey);
|
||||
ImGui.TextUnformatted(L("GroupPanel.List.Offline", "Offline/Unknown"));
|
||||
ImGui.TextUnformatted("Offline/Unknown");
|
||||
ImGui.PopStyleColor();
|
||||
ImGui.Separator();
|
||||
if (hideOfflineUsers)
|
||||
{
|
||||
UiSharedService.ColorText(L("GroupPanel.List.OfflineOmitted", " {0} offline users omitted from display.", offlineUsers.Count), ImGuiColors.DalamudGrey);
|
||||
UiSharedService.ColorText($" {offlineUsers.Count} offline users omitted from display.", ImGuiColors.DalamudGrey);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -630,6 +614,9 @@ internal sealed class GroupPanel
|
||||
ImGui.Separator();
|
||||
}
|
||||
ImGui.Unindent(20);
|
||||
}, stretchWidth: true);
|
||||
|
||||
ImGuiHelpers.ScaledDummy(4f);
|
||||
}
|
||||
|
||||
private void DrawSyncShellButtons(GroupFullInfoDto groupDto, List<Pair> groupPairs)
|
||||
@@ -648,19 +635,20 @@ internal sealed class GroupPanel
|
||||
bool showInfoIcon = !invitesEnabled || soundsDisabled || animDisabled || vfxDisabled || userSoundsDisabled || userAnimDisabled || userVFXDisabled;
|
||||
|
||||
var lockedIcon = invitesEnabled ? FontAwesomeIcon.LockOpen : FontAwesomeIcon.Lock;
|
||||
var animIcon = animDisabled ? FontAwesomeIcon.Stop : FontAwesomeIcon.Running;
|
||||
var soundsIcon = soundsDisabled ? FontAwesomeIcon.VolumeOff : FontAwesomeIcon.VolumeUp;
|
||||
var vfxIcon = vfxDisabled ? FontAwesomeIcon.Circle : FontAwesomeIcon.Sun;
|
||||
var userAnimIcon = userAnimDisabled ? FontAwesomeIcon.Stop : FontAwesomeIcon.Running;
|
||||
var userSoundsIcon = userSoundsDisabled ? FontAwesomeIcon.VolumeOff : FontAwesomeIcon.VolumeUp;
|
||||
var userVFXIcon = userVFXDisabled ? FontAwesomeIcon.Circle : FontAwesomeIcon.Sun;
|
||||
var animIcon = animDisabled ? FontAwesomeIcon.WindowClose : FontAwesomeIcon.Running;
|
||||
var soundsIcon = soundsDisabled ? FontAwesomeIcon.VolumeMute : FontAwesomeIcon.VolumeUp;
|
||||
var vfxIcon = vfxDisabled ? FontAwesomeIcon.TimesCircle : FontAwesomeIcon.Sun;
|
||||
var userAnimIcon = userAnimDisabled ? FontAwesomeIcon.WindowClose : FontAwesomeIcon.Running;
|
||||
var userSoundsIcon = userSoundsDisabled ? FontAwesomeIcon.VolumeMute : FontAwesomeIcon.VolumeUp;
|
||||
var userVFXIcon = userVFXDisabled ? FontAwesomeIcon.TimesCircle : FontAwesomeIcon.Sun;
|
||||
|
||||
var iconSize = UiSharedService.GetIconSize(infoIcon);
|
||||
var barbuttonSize = _uiShared.GetIconButtonSize(FontAwesomeIcon.Bars);
|
||||
var isOwner = string.Equals(groupDto.OwnerUID, ApiController.UID, StringComparison.Ordinal);
|
||||
|
||||
var spacingX = ImGui.GetStyle().ItemSpacing.X;
|
||||
var windowEndX = ImGui.GetWindowContentRegionMin().X + UiSharedService.GetWindowContentRegionWidth();
|
||||
var cardPaddingX = UiSharedService.GetCardContentPaddingX();
|
||||
var windowEndX = ImGui.GetWindowContentRegionMin().X + UiSharedService.GetWindowContentRegionWidth() - cardPaddingX - 6f * ImGuiHelpers.GlobalScale;
|
||||
var pauseIcon = groupDto.GroupUserPermissions.IsPaused() ? FontAwesomeIcon.Play : FontAwesomeIcon.Pause;
|
||||
var pauseIconSize = _uiShared.GetIconButtonSize(pauseIcon);
|
||||
|
||||
@@ -674,11 +662,11 @@ internal sealed class GroupPanel
|
||||
ImGui.BeginTooltip();
|
||||
if (!invitesEnabled || soundsDisabled || animDisabled || vfxDisabled)
|
||||
{
|
||||
ImGui.TextUnformatted(L("GroupPanel.Permissions.Header", "Syncshell permissions"));
|
||||
ImGui.TextUnformatted("Syncshell permissions");
|
||||
|
||||
if (!invitesEnabled)
|
||||
{
|
||||
var lockedText = L("GroupPanel.Permissions.InvitesDisabled", "Syncshell is closed for joining");
|
||||
var lockedText = "Syncshell is closed for joining";
|
||||
_uiShared.IconText(lockedIcon);
|
||||
ImGui.SameLine(40 * ImGuiHelpers.GlobalScale);
|
||||
ImGui.TextUnformatted(lockedText);
|
||||
@@ -686,7 +674,7 @@ internal sealed class GroupPanel
|
||||
|
||||
if (soundsDisabled)
|
||||
{
|
||||
var soundsText = L("GroupPanel.Permissions.SoundDisabledOwner", "Sound sync disabled through owner");
|
||||
var soundsText = "Sound sync disabled through owner";
|
||||
_uiShared.IconText(soundsIcon);
|
||||
ImGui.SameLine(40 * ImGuiHelpers.GlobalScale);
|
||||
ImGui.TextUnformatted(soundsText);
|
||||
@@ -694,7 +682,7 @@ internal sealed class GroupPanel
|
||||
|
||||
if (animDisabled)
|
||||
{
|
||||
var animText = L("GroupPanel.Permissions.AnimationDisabledOwner", "Animation sync disabled through owner");
|
||||
var animText = "Animation sync disabled through owner";
|
||||
_uiShared.IconText(animIcon);
|
||||
ImGui.SameLine(40 * ImGuiHelpers.GlobalScale);
|
||||
ImGui.TextUnformatted(animText);
|
||||
@@ -702,7 +690,7 @@ internal sealed class GroupPanel
|
||||
|
||||
if (vfxDisabled)
|
||||
{
|
||||
var vfxText = L("GroupPanel.Permissions.VfxDisabledOwner", "VFX sync disabled through owner");
|
||||
var vfxText = "VFX sync disabled through owner";
|
||||
_uiShared.IconText(vfxIcon);
|
||||
ImGui.SameLine(40 * ImGuiHelpers.GlobalScale);
|
||||
ImGui.TextUnformatted(vfxText);
|
||||
@@ -714,11 +702,11 @@ internal sealed class GroupPanel
|
||||
if (!invitesEnabled || soundsDisabled || animDisabled || vfxDisabled)
|
||||
ImGui.Separator();
|
||||
|
||||
ImGui.TextUnformatted(L("GroupPanel.Permissions.OwnHeader", "Your permissions"));
|
||||
ImGui.TextUnformatted("Your permissions");
|
||||
|
||||
if (userSoundsDisabled)
|
||||
{
|
||||
var userSoundsText = L("GroupPanel.Permissions.SoundDisabledSelf", "Sound sync disabled through you");
|
||||
var userSoundsText = "Sound sync disabled through you";
|
||||
_uiShared.IconText(userSoundsIcon);
|
||||
ImGui.SameLine(40 * ImGuiHelpers.GlobalScale);
|
||||
ImGui.TextUnformatted(userSoundsText);
|
||||
@@ -726,7 +714,7 @@ internal sealed class GroupPanel
|
||||
|
||||
if (userAnimDisabled)
|
||||
{
|
||||
var userAnimText = L("GroupPanel.Permissions.AnimationDisabledSelf", "Animation sync disabled through you");
|
||||
var userAnimText = "Animation sync disabled through you";
|
||||
_uiShared.IconText(userAnimIcon);
|
||||
ImGui.SameLine(40 * ImGuiHelpers.GlobalScale);
|
||||
ImGui.TextUnformatted(userAnimText);
|
||||
@@ -734,14 +722,14 @@ internal sealed class GroupPanel
|
||||
|
||||
if (userVFXDisabled)
|
||||
{
|
||||
var userVFXText = L("GroupPanel.Permissions.VfxDisabledSelf", "VFX sync disabled through you");
|
||||
var userVFXText = "VFX sync disabled through you";
|
||||
_uiShared.IconText(userVFXIcon);
|
||||
ImGui.SameLine(40 * ImGuiHelpers.GlobalScale);
|
||||
ImGui.TextUnformatted(userVFXText);
|
||||
}
|
||||
|
||||
if (!invitesEnabled || soundsDisabled || animDisabled || vfxDisabled)
|
||||
UiSharedService.TextWrapped(L("GroupPanel.Permissions.NotePriority", "Note that syncshell permissions for disabling take precedence over your own set permissions"));
|
||||
UiSharedService.TextWrapped("Note that syncshell permissions for disabling take precedence over your own set permissions");
|
||||
}
|
||||
ImGui.EndTooltip();
|
||||
}
|
||||
@@ -753,8 +741,7 @@ internal sealed class GroupPanel
|
||||
var userPerm = groupDto.GroupUserPermissions ^ GroupUserPermissions.Paused;
|
||||
_ = ApiController.GroupChangeIndividualPermissionState(new GroupPairUserPermissionDto(groupDto.Group, new UserData(ApiController.UID), userPerm));
|
||||
}
|
||||
UiSharedService.AttachToolTip(L("GroupPanel.PauseToggle.Tooltip", "{0} pairing with all users in this Syncshell",
|
||||
groupDto.GroupUserPermissions.IsPaused() ? L("GroupPanel.PauseToggle.Resume", "Resume") : L("GroupPanel.PauseToggle.Pause", "Pause")));
|
||||
UiSharedService.AttachToolTip((groupDto.GroupUserPermissions.IsPaused() ? "Resume" : "Pause") + " pairing with all users in this Syncshell");
|
||||
ImGui.SameLine();
|
||||
|
||||
if (_uiShared.IconButton(FontAwesomeIcon.Bars))
|
||||
@@ -764,69 +751,75 @@ internal sealed class GroupPanel
|
||||
|
||||
if (ImGui.BeginPopup("ShellPopup"))
|
||||
{
|
||||
if (_uiShared.IconTextButton(FontAwesomeIcon.ArrowCircleLeft, L("GroupPanel.Popup.Leave", "Leave Syncshell")) && UiSharedService.CtrlPressed())
|
||||
if (_uiShared.IconTextButton(FontAwesomeIcon.ArrowCircleLeft, "Leave Syncshell") && UiSharedService.CtrlPressed())
|
||||
{
|
||||
_ = ApiController.GroupLeave(groupDto);
|
||||
}
|
||||
UiSharedService.AttachToolTip(L("GroupPanel.Popup.LeaveTooltip", "Hold CTRL and click to leave this Syncshell{0}",
|
||||
!string.Equals(groupDto.OwnerUID, ApiController.UID, StringComparison.Ordinal)
|
||||
? string.Empty
|
||||
: Environment.NewLine + L("GroupPanel.Popup.LeaveWarning", "WARNING: This action is irreversible\nLeaving an owned Syncshell will transfer the ownership to a random person in the Syncshell.")));
|
||||
UiSharedService.AttachToolTip("Hold CTRL and click to leave this Syncshell" + (!string.Equals(groupDto.OwnerUID, ApiController.UID, StringComparison.Ordinal) ? string.Empty : Environment.NewLine
|
||||
+ "WARNING: This action is irreversible" + Environment.NewLine + "Leaving an owned Syncshell will transfer the ownership to a random person in the Syncshell."));
|
||||
|
||||
if (_uiShared.IconTextButton(FontAwesomeIcon.Copy, L("GroupPanel.Popup.CopyId", "Copy ID")))
|
||||
if (_uiShared.IconTextButton(FontAwesomeIcon.Copy, "Copy ID"))
|
||||
{
|
||||
ImGui.CloseCurrentPopup();
|
||||
ImGui.SetClipboardText(groupDto.GroupAliasOrGID);
|
||||
}
|
||||
UiSharedService.AttachToolTip(L("GroupPanel.Popup.CopyIdTooltip", "Copy Syncshell ID to Clipboard"));
|
||||
UiSharedService.AttachToolTip("Copy Syncshell ID to Clipboard");
|
||||
|
||||
if (_uiShared.IconTextButton(FontAwesomeIcon.StickyNote, L("GroupPanel.Popup.CopyNotes", "Copy Notes")))
|
||||
if (_uiShared.IconTextButton(FontAwesomeIcon.StickyNote, "Copy Notes"))
|
||||
{
|
||||
ImGui.CloseCurrentPopup();
|
||||
ImGui.SetClipboardText(UiSharedService.GetNotes(groupPairs));
|
||||
}
|
||||
UiSharedService.AttachToolTip(L("GroupPanel.Popup.CopyNotesTooltip", "Copies all your notes for all users in this Syncshell to the clipboard.\nThey can be imported via Settings -> General -> Notes -> Import notes from clipboard"));
|
||||
UiSharedService.AttachToolTip("Copies all your notes for all users in this Syncshell to the clipboard." + Environment.NewLine + "They can be imported via Settings -> General -> Notes -> Import notes from clipboard");
|
||||
|
||||
var soundsText = userSoundsDisabled
|
||||
? L("GroupPanel.Popup.EnableSound", "Enable sound sync")
|
||||
: L("GroupPanel.Popup.DisableSound", "Disable sound sync");
|
||||
var soundsText = userSoundsDisabled ? "Enable sound sync" : "Disable sound sync";
|
||||
if (_uiShared.IconTextButton(userSoundsIcon, soundsText))
|
||||
{
|
||||
ImGui.CloseCurrentPopup();
|
||||
var perm = groupDto.GroupUserPermissions;
|
||||
perm.SetDisableSounds(!perm.IsDisableSounds());
|
||||
_mainUi.Mediator.Publish(new GroupSyncOverrideChanged(groupDto.Group.GID, perm.IsDisableSounds(), null, null));
|
||||
_ = ApiController.GroupChangeIndividualPermissionState(new(groupDto.Group, new UserData(ApiController.UID), perm));
|
||||
}
|
||||
UiSharedService.AttachToolTip(L("GroupPanel.Popup.SoundTooltip", "Sets your allowance for sound synchronization for users of this syncshell.\nDisabling the synchronization will stop applying sound modifications for users of this syncshell.\nNote: this setting can be forcefully overridden to 'disabled' through the syncshell owner.\nNote: this setting does not apply to individual pairs that are also in the syncshell."));
|
||||
UiSharedService.AttachToolTip("Sets your allowance for sound synchronization for users of this syncshell."
|
||||
+ Environment.NewLine + "Disabling the synchronization will stop applying sound modifications for users of this syncshell."
|
||||
+ Environment.NewLine + "Note: this setting can be forcefully overridden to 'disabled' through the syncshell owner."
|
||||
+ Environment.NewLine + "Note: this setting does not apply to individual pairs that are also in the syncshell.");
|
||||
|
||||
var animText = userAnimDisabled
|
||||
? L("GroupPanel.Popup.EnableAnimations", "Enable animations sync")
|
||||
: L("GroupPanel.Popup.DisableAnimations", "Disable animations sync");
|
||||
var animText = userAnimDisabled ? "Enable animations sync" : "Disable animations sync";
|
||||
if (_uiShared.IconTextButton(userAnimIcon, animText))
|
||||
{
|
||||
ImGui.CloseCurrentPopup();
|
||||
var perm = groupDto.GroupUserPermissions;
|
||||
perm.SetDisableAnimations(!perm.IsDisableAnimations());
|
||||
_mainUi.Mediator.Publish(new GroupSyncOverrideChanged(groupDto.Group.GID, null, perm.IsDisableAnimations(), null));
|
||||
_ = ApiController.GroupChangeIndividualPermissionState(new(groupDto.Group, new UserData(ApiController.UID), perm));
|
||||
}
|
||||
UiSharedService.AttachToolTip(L("GroupPanel.Popup.AnimTooltip", "Sets your allowance for animations synchronization for users of this syncshell.\nDisabling the synchronization will stop applying animations modifications for users of this syncshell.\nNote: this setting might also affect sound synchronization\nNote: this setting can be forcefully overridden to 'disabled' through the syncshell owner.\nNote: this setting does not apply to individual pairs that are also in the syncshell."));
|
||||
UiSharedService.AttachToolTip("Sets your allowance for animations synchronization for users of this syncshell."
|
||||
+ Environment.NewLine + "Disabling the synchronization will stop applying animations modifications for users of this syncshell."
|
||||
+ Environment.NewLine + "Note: this setting might also affect sound synchronization"
|
||||
+ Environment.NewLine + "Note: this setting can be forcefully overridden to 'disabled' through the syncshell owner."
|
||||
+ Environment.NewLine + "Note: this setting does not apply to individual pairs that are also in the syncshell.");
|
||||
|
||||
var vfxText = userVFXDisabled
|
||||
? L("GroupPanel.Popup.EnableVfx", "Enable VFX sync")
|
||||
: L("GroupPanel.Popup.DisableVfx", "Disable VFX sync");
|
||||
var vfxText = userVFXDisabled ? "Enable VFX sync" : "Disable VFX sync";
|
||||
if (_uiShared.IconTextButton(userVFXIcon, vfxText))
|
||||
{
|
||||
ImGui.CloseCurrentPopup();
|
||||
var perm = groupDto.GroupUserPermissions;
|
||||
perm.SetDisableVFX(!perm.IsDisableVFX());
|
||||
_mainUi.Mediator.Publish(new GroupSyncOverrideChanged(groupDto.Group.GID, null, null, perm.IsDisableVFX()));
|
||||
_ = ApiController.GroupChangeIndividualPermissionState(new(groupDto.Group, new UserData(ApiController.UID), perm));
|
||||
}
|
||||
UiSharedService.AttachToolTip(L("GroupPanel.Popup.VfxTooltip", "Sets your allowance for VFX synchronization for users of this syncshell.\nDisabling the synchronization will stop applying VFX modifications for users of this syncshell.\nNote: this setting might also affect animation synchronization to some degree\nNote: this setting can be forcefully overridden to 'disabled' through the syncshell owner.\nNote: this setting does not apply to individual pairs that are also in the syncshell."));
|
||||
UiSharedService.AttachToolTip("Sets your allowance for VFX synchronization for users of this syncshell."
|
||||
+ Environment.NewLine + "Disabling the synchronization will stop applying VFX modifications for users of this syncshell."
|
||||
+ Environment.NewLine + "Note: this setting might also affect animation synchronization to some degree"
|
||||
+ Environment.NewLine + "Note: this setting can be forcefully overridden to 'disabled' through the syncshell owner."
|
||||
+ Environment.NewLine + "Note: this setting does not apply to individual pairs that are also in the syncshell.");
|
||||
|
||||
if (isOwner || groupDto.GroupUserInfo.IsModerator())
|
||||
{
|
||||
ImGui.Separator();
|
||||
if (_uiShared.IconTextButton(FontAwesomeIcon.Cog, L("GroupPanel.Popup.OpenAdmin", "Open Admin Panel")))
|
||||
if (_uiShared.IconTextButton(FontAwesomeIcon.Cog, "Open Admin Panel"))
|
||||
{
|
||||
ImGui.CloseCurrentPopup();
|
||||
_mainUi.Mediator.Publish(new OpenSyncshellAdminPanel(groupDto));
|
||||
@@ -839,9 +832,22 @@ internal sealed class GroupPanel
|
||||
|
||||
private void DrawSyncshellList()
|
||||
{
|
||||
var ySize = _mainUi.TransferPartHeight == 0
|
||||
? 1
|
||||
: (ImGui.GetWindowContentRegionMax().Y - ImGui.GetWindowContentRegionMin().Y) - _mainUi.TransferPartHeight - ImGui.GetCursorPosY();
|
||||
float availableHeight = ImGui.GetContentRegionAvail().Y;
|
||||
float ySize;
|
||||
if (_mainUi.TransferPartHeight <= 0)
|
||||
{
|
||||
float reserve = ImGui.GetFrameHeightWithSpacing() * 2f;
|
||||
ySize = availableHeight - reserve;
|
||||
if (ySize <= 0)
|
||||
{
|
||||
ySize = System.Math.Max(availableHeight, 1f);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ySize = (ImGui.GetWindowContentRegionMax().Y - ImGui.GetWindowContentRegionMin().Y) - _mainUi.TransferPartHeight - ImGui.GetCursorPosY();
|
||||
}
|
||||
|
||||
ImGui.BeginChild("list", new Vector2(_mainUi.WindowContentWidth, ySize), border: false);
|
||||
foreach (var entry in _pairManager.GroupPairs.OrderBy(g => g.Key.Group.AliasOrGID, StringComparer.OrdinalIgnoreCase).ToList())
|
||||
{
|
||||
|
||||
@@ -1,12 +1,14 @@
|
||||
using System;
|
||||
using Dalamud.Bindings.ImGui;
|
||||
using Dalamud.Bindings.ImGui;
|
||||
using Dalamud.Interface;
|
||||
using Dalamud.Interface.Utility;
|
||||
using Dalamud.Interface.Utility.Raii;
|
||||
using MareSynchronos.API.Data.Extensions;
|
||||
using MareSynchronos.MareConfiguration;
|
||||
using MareSynchronos.UI.Handlers;
|
||||
using MareSynchronos.WebAPI;
|
||||
using MareSynchronos.Localization;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace MareSynchronos.UI.Components;
|
||||
|
||||
@@ -19,13 +21,6 @@ public class PairGroupsUi
|
||||
private readonly UidDisplayHandler _uidDisplayHandler;
|
||||
private readonly UiSharedService _uiSharedService;
|
||||
|
||||
private string L(string key, string fallback, params object[] args)
|
||||
{
|
||||
var safeArgs = args ?? Array.Empty<object>();
|
||||
return LocalizationService.Instance?.GetString(key, fallback, safeArgs)
|
||||
?? string.Format(System.Globalization.CultureInfo.CurrentCulture, fallback, safeArgs);
|
||||
}
|
||||
|
||||
public PairGroupsUi(MareConfigService mareConfig, TagHandler tagHandler, UidDisplayHandler uidDisplayHandler, ApiController apiController,
|
||||
SelectPairForGroupUi selectGroupForPairUi, UiSharedService uiSharedService)
|
||||
{
|
||||
@@ -37,7 +32,7 @@ public class PairGroupsUi
|
||||
_uiSharedService = uiSharedService;
|
||||
}
|
||||
|
||||
public void Draw<T>(List<T> visibleUsers, List<T> onlineUsers, List<T> offlineUsers) where T : DrawPairBase
|
||||
public void Draw<T>(List<T> visibleUsers, List<T> onlineUsers, List<T> offlineUsers, Action? drawVisibleExtras = null) where T : DrawPairBase
|
||||
{
|
||||
// Only render those tags that actually have pairs in them, otherwise
|
||||
// we can end up with a bunch of useless pair groups
|
||||
@@ -45,7 +40,7 @@ public class PairGroupsUi
|
||||
var allUsers = onlineUsers.Concat(offlineUsers).ToList();
|
||||
if (typeof(T) == typeof(DrawUserPair))
|
||||
{
|
||||
DrawUserPairs(tagsWithPairsInThem, allUsers.Cast<DrawUserPair>().ToList(), visibleUsers.Cast<DrawUserPair>(), onlineUsers.Cast<DrawUserPair>(), offlineUsers.Cast<DrawUserPair>());
|
||||
DrawUserPairs(tagsWithPairsInThem, allUsers.Cast<DrawUserPair>().ToList(), visibleUsers.Cast<DrawUserPair>(), onlineUsers.Cast<DrawUserPair>(), offlineUsers.Cast<DrawUserPair>(), drawVisibleExtras);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -53,14 +48,15 @@ public class PairGroupsUi
|
||||
{
|
||||
var allArePaused = availablePairsInThisTag.All(pair => pair.UserPair!.OwnPermissions.IsPaused());
|
||||
var pauseButton = allArePaused ? FontAwesomeIcon.Play : FontAwesomeIcon.Pause;
|
||||
var flyoutMenuX = _uiSharedService.GetIconButtonSize(FontAwesomeIcon.Bars).X;
|
||||
var pauseButtonX = _uiSharedService.GetIconButtonSize(pauseButton).X;
|
||||
var windowX = ImGui.GetWindowContentRegionMin().X;
|
||||
var windowWidth = UiSharedService.GetWindowContentRegionWidth();
|
||||
var flyoutMenuSize = _uiSharedService.GetIconButtonSize(FontAwesomeIcon.Bars);
|
||||
var pauseButtonSize = _uiSharedService.GetIconButtonSize(pauseButton);
|
||||
var spacingX = ImGui.GetStyle().ItemSpacing.X;
|
||||
var currentX = ImGui.GetCursorPosX();
|
||||
var availableWidth = ImGui.GetContentRegionAvail().X;
|
||||
var buttonsWidth = pauseButtonSize.X + flyoutMenuSize.X + spacingX;
|
||||
var pauseStart = Math.Max(currentX, currentX + availableWidth - buttonsWidth);
|
||||
|
||||
var buttonPauseOffset = windowX + windowWidth - flyoutMenuX - spacingX - pauseButtonX;
|
||||
ImGui.SameLine(buttonPauseOffset);
|
||||
ImGui.SameLine(pauseStart);
|
||||
if (_uiSharedService.IconButton(pauseButton))
|
||||
{
|
||||
if (allArePaused)
|
||||
@@ -74,28 +70,28 @@ public class PairGroupsUi
|
||||
}
|
||||
if (allArePaused)
|
||||
{
|
||||
UiSharedService.AttachToolTip(L("PairGroups.ResumeAll", "Resume pairing with all pairs in {0}", tag));
|
||||
UiSharedService.AttachToolTip($"Resume pairing with all pairs in {tag}");
|
||||
}
|
||||
else
|
||||
{
|
||||
UiSharedService.AttachToolTip(L("PairGroups.PauseAll", "Pause pairing with all pairs in {0}", tag));
|
||||
UiSharedService.AttachToolTip($"Pause pairing with all pairs in {tag}");
|
||||
}
|
||||
|
||||
var buttonDeleteOffset = windowX + windowWidth - flyoutMenuX;
|
||||
ImGui.SameLine(buttonDeleteOffset);
|
||||
var menuStart = Math.Max(pauseStart + pauseButtonSize.X + spacingX, currentX);
|
||||
ImGui.SameLine(menuStart);
|
||||
if (_uiSharedService.IconButton(FontAwesomeIcon.Bars))
|
||||
{
|
||||
ImGui.OpenPopup(L("PairGroups.Menu.Title", "Group Flyout Menu"));
|
||||
ImGui.OpenPopup("Group Flyout Menu");
|
||||
}
|
||||
|
||||
if (ImGui.BeginPopup(L("PairGroups.Menu.Title", "Group Flyout Menu")))
|
||||
if (ImGui.BeginPopup("Group Flyout Menu"))
|
||||
{
|
||||
using (ImRaii.PushId($"buttons-{tag}")) DrawGroupMenu(tag);
|
||||
ImGui.EndPopup();
|
||||
}
|
||||
}
|
||||
|
||||
private void DrawCategory(string tag, IEnumerable<DrawPairBase> onlineUsers, IEnumerable<DrawPairBase> allUsers, IEnumerable<DrawPairBase>? visibleUsers = null)
|
||||
private void DrawCategory(string tag, IEnumerable<DrawPairBase> onlineUsers, IEnumerable<DrawPairBase> allUsers, IEnumerable<DrawPairBase>? visibleUsers = null, Action? drawExtraContent = null)
|
||||
{
|
||||
IEnumerable<DrawPairBase> usersInThisTag;
|
||||
HashSet<string>? otherUidsTaggedWithTag = null;
|
||||
@@ -117,80 +113,79 @@ public class PairGroupsUi
|
||||
|
||||
if (isSpecialTag && !usersInThisTag.Any()) return;
|
||||
|
||||
UiSharedService.DrawCard($"pair-group-{tag}", () =>
|
||||
{
|
||||
DrawName(tag, isSpecialTag, visibleInThisTag, usersInThisTag.Count(), otherUidsTaggedWithTag?.Count);
|
||||
if (!isSpecialTag)
|
||||
{
|
||||
using (ImRaii.PushId($"group-{tag}-buttons")) DrawButtons(tag, allUsers.Cast<DrawUserPair>().Where(p => otherUidsTaggedWithTag!.Contains(p.UID)).ToList());
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!_tagHandler.IsTagOpen(tag))
|
||||
{
|
||||
var size = ImGui.CalcTextSize("").Y + ImGui.GetStyle().FramePadding.Y * 2f;
|
||||
ImGui.SameLine();
|
||||
ImGui.Dummy(new(size, size));
|
||||
}
|
||||
}
|
||||
|
||||
if (!_tagHandler.IsTagOpen(tag)) return;
|
||||
|
||||
ImGui.Indent(20);
|
||||
ImGuiHelpers.ScaledDummy(4f);
|
||||
var indent = 18f * ImGuiHelpers.GlobalScale;
|
||||
ImGui.Indent(indent);
|
||||
DrawPairs(tag, usersInThisTag);
|
||||
ImGui.Unindent(20);
|
||||
drawExtraContent?.Invoke();
|
||||
ImGui.Unindent(indent);
|
||||
}, stretchWidth: true);
|
||||
|
||||
ImGuiHelpers.ScaledDummy(4f);
|
||||
}
|
||||
|
||||
private void DrawGroupMenu(string tag)
|
||||
{
|
||||
if (_uiSharedService.IconTextButton(FontAwesomeIcon.Users, L("PairGroups.Menu.AddPeople", "Add people to {0}", tag)))
|
||||
if (_uiSharedService.IconTextButton(FontAwesomeIcon.Users, "Add people to " + tag))
|
||||
{
|
||||
_selectGroupForPairUi.Open(tag);
|
||||
}
|
||||
UiSharedService.AttachToolTip(L("PairGroups.Menu.AddPeople.Tooltip", "Add more users to Group {0}", tag));
|
||||
UiSharedService.AttachToolTip($"Add more users to Group {tag}");
|
||||
|
||||
if (_uiSharedService.IconTextButton(FontAwesomeIcon.Trash, L("PairGroups.Menu.Delete", "Delete {0}", tag)) && UiSharedService.CtrlPressed())
|
||||
if (_uiSharedService.IconTextButton(FontAwesomeIcon.Trash, "Delete " + tag) && UiSharedService.CtrlPressed())
|
||||
{
|
||||
_tagHandler.RemoveTag(tag);
|
||||
}
|
||||
UiSharedService.AttachToolTip(L("PairGroups.Menu.Delete.Tooltip", "Delete Group {0} (Will not delete the pairs)\nHold CTRL to delete", tag));
|
||||
UiSharedService.AttachToolTip($"Delete Group {tag} (Will not delete the pairs)" + Environment.NewLine + "Hold CTRL to delete");
|
||||
}
|
||||
|
||||
private void DrawName(string tag, bool isSpecialTag, int visible, int online, int? total)
|
||||
{
|
||||
string displayedName = tag switch
|
||||
{
|
||||
TagHandler.CustomUnpairedTag => L("PairGroups.Tag.Unpaired", "Unpaired"),
|
||||
TagHandler.CustomOfflineTag => L("PairGroups.Tag.Offline", "Offline"),
|
||||
TagHandler.CustomOnlineTag => _mareConfig.Current.ShowOfflineUsersSeparately
|
||||
? L("PairGroups.Tag.Online", "Online")
|
||||
: L("PairGroups.Tag.Contacts", "Contacts"),
|
||||
TagHandler.CustomVisibleTag => L("PairGroups.Tag.Visible", "Visible"),
|
||||
TagHandler.CustomUnpairedTag => "Unpaired",
|
||||
TagHandler.CustomOfflineTag => "Offline",
|
||||
TagHandler.CustomOnlineTag => _mareConfig.Current.ShowOfflineUsersSeparately ? "Online" : "Contacts",
|
||||
TagHandler.CustomVisibleTag => "Visible",
|
||||
_ => tag
|
||||
};
|
||||
|
||||
string resultFolderName = !isSpecialTag
|
||||
? L("PairGroups.Header.WithCounts", "{0} ({1}/{2}/{3} Pairs)", displayedName, visible, online, total ?? 0)
|
||||
: L("PairGroups.Header.Special", "{0} ({1} Pairs)", displayedName, online);
|
||||
var icon = _tagHandler.IsTagOpen(tag) ? FontAwesomeIcon.CaretSquareDown : FontAwesomeIcon.CaretSquareRight;
|
||||
_uiSharedService.IconText(icon);
|
||||
if (ImGui.IsItemClicked(ImGuiMouseButton.Left))
|
||||
string resultFolderName = !isSpecialTag ? $"{displayedName} ({visible}/{online}/{total} Pairs)" : $"{displayedName} ({online} Pairs)";
|
||||
bool isOpen = _tagHandler.IsTagOpen(tag);
|
||||
bool previousState = isOpen;
|
||||
UiSharedService.DrawArrowToggle(ref isOpen, $"##group-toggle-{tag}");
|
||||
if (isOpen != previousState)
|
||||
{
|
||||
ToggleTagOpen(tag);
|
||||
_tagHandler.SetTagOpen(tag, isOpen);
|
||||
}
|
||||
ImGui.SameLine();
|
||||
ImGui.SameLine(0f, 6f * ImGuiHelpers.GlobalScale);
|
||||
ImGui.AlignTextToFramePadding();
|
||||
ImGui.TextUnformatted(resultFolderName);
|
||||
if (ImGui.IsItemClicked(ImGuiMouseButton.Left))
|
||||
{
|
||||
ToggleTagOpen(tag);
|
||||
bool newState = !_tagHandler.IsTagOpen(tag);
|
||||
_tagHandler.SetTagOpen(tag, newState);
|
||||
isOpen = newState;
|
||||
}
|
||||
|
||||
if (!isSpecialTag && ImGui.IsItemHovered())
|
||||
{
|
||||
ImGui.BeginTooltip();
|
||||
ImGui.TextUnformatted(L("PairGroups.Tooltip.Title", "Group {0}", tag));
|
||||
ImGui.TextUnformatted($"Group {tag}");
|
||||
ImGui.Separator();
|
||||
ImGui.TextUnformatted(L("PairGroups.Tooltip.Visible", "{0} Pairs visible", visible));
|
||||
ImGui.TextUnformatted(L("PairGroups.Tooltip.Online", "{0} Pairs online/paused", online));
|
||||
ImGui.TextUnformatted(L("PairGroups.Tooltip.Total", "{0} Pairs total", total ?? 0));
|
||||
ImGui.TextUnformatted($"{visible} Pairs visible");
|
||||
ImGui.TextUnformatted($"{online} Pairs online/paused");
|
||||
ImGui.TextUnformatted($"{total} Pairs total");
|
||||
ImGui.EndTooltip();
|
||||
}
|
||||
}
|
||||
@@ -199,15 +194,11 @@ public class PairGroupsUi
|
||||
{
|
||||
// These are all the OtherUIDs that are tagged with this tag
|
||||
_uidDisplayHandler.RenderPairList(availablePairsInThisCategory);
|
||||
ImGui.Separator();
|
||||
}
|
||||
|
||||
private void DrawUserPairs(List<string> tagsWithPairsInThem, List<DrawUserPair> allUsers, IEnumerable<DrawUserPair> visibleUsers, IEnumerable<DrawUserPair> onlineUsers, IEnumerable<DrawUserPair> offlineUsers)
|
||||
private void DrawUserPairs(List<string> tagsWithPairsInThem, List<DrawUserPair> allUsers, IEnumerable<DrawUserPair> visibleUsers, IEnumerable<DrawUserPair> onlineUsers, IEnumerable<DrawUserPair> offlineUsers, Action? drawVisibleExtras)
|
||||
{
|
||||
if (_mareConfig.Current.ShowVisibleUsersSeparately)
|
||||
{
|
||||
using (ImRaii.PushId("$group-VisibleCustomTag")) DrawCategory(TagHandler.CustomVisibleTag, visibleUsers, allUsers);
|
||||
}
|
||||
// Visible section intentionally omitted for Individual Pairs view.
|
||||
foreach (var tag in tagsWithPairsInThem)
|
||||
{
|
||||
if (_mareConfig.Current.ShowOfflineUsersSeparately)
|
||||
@@ -255,9 +246,4 @@ public class PairGroupsUi
|
||||
}
|
||||
}
|
||||
|
||||
private void ToggleTagOpen(string tag)
|
||||
{
|
||||
bool open = !_tagHandler.IsTagOpen(tag);
|
||||
_tagHandler.SetTagOpen(tag, open);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,17 +28,17 @@ public class BanUserPopupHandler : IPopupHandler
|
||||
|
||||
public void DrawContent()
|
||||
{
|
||||
UiSharedService.TextWrapped(_uiSharedService.Localize("Popup.BanUser.Description", "User {0} will be banned and removed from this Syncshell.", _reportedPair.UserData.AliasOrUID));
|
||||
ImGui.InputTextWithHint("##banreason", _uiSharedService.Localize("Popup.BanUser.ReasonHint", "Ban Reason"), ref _banReason, 255);
|
||||
UiSharedService.TextWrapped("User " + (_reportedPair.UserData.AliasOrUID) + " will be banned and removed from this Syncshell.");
|
||||
ImGui.InputTextWithHint("##banreason", "Ban Reason", ref _banReason, 255);
|
||||
|
||||
if (_uiSharedService.IconTextButton(FontAwesomeIcon.UserSlash, _uiSharedService.Localize("Popup.BanUser.Button", "Ban User")))
|
||||
if (_uiSharedService.IconTextButton(FontAwesomeIcon.UserSlash, "Ban User"))
|
||||
{
|
||||
ImGui.CloseCurrentPopup();
|
||||
var reason = _banReason;
|
||||
_ = _apiController.GroupBanUser(new GroupPairDto(_group.Group, _reportedPair.UserData), reason);
|
||||
_banReason = string.Empty;
|
||||
}
|
||||
UiSharedService.TextWrapped(_uiSharedService.Localize("Popup.BanUser.ReasonNote", "The reason will be displayed in the banlist. The current server-side alias if present (Vanity ID) will automatically be attached to the reason."));
|
||||
UiSharedService.TextWrapped("The reason will be displayed in the banlist. The current server-side alias if present (Vanity ID) will automatically be attached to the reason.");
|
||||
}
|
||||
|
||||
public void Open(OpenBanUserPopupMessage message)
|
||||
|
||||
@@ -72,7 +72,7 @@ public class PopupHandler : WindowMediatorSubscriberBase
|
||||
if (_currentHandler.ShowClose)
|
||||
{
|
||||
ImGui.Separator();
|
||||
if (_uiSharedService.IconTextButton(FontAwesomeIcon.Times, _uiSharedService.Localize("Popup.Generic.Close", "Close")))
|
||||
if (_uiSharedService.IconTextButton(FontAwesomeIcon.Times, "Close"))
|
||||
{
|
||||
ImGui.CloseCurrentPopup();
|
||||
}
|
||||
|
||||
@@ -29,21 +29,23 @@ internal class ReportPopupHandler : IPopupHandler
|
||||
public void DrawContent()
|
||||
{
|
||||
using (_uiSharedService.UidFont.Push())
|
||||
UiSharedService.TextWrapped(_uiSharedService.Localize("Popup.Report.Title", "Report {0} Profile", _reportedPair!.UserData.AliasOrUID));
|
||||
UiSharedService.TextWrapped("Report " + _reportedPair!.UserData.AliasOrUID + " Profile");
|
||||
|
||||
ImGui.InputTextMultiline("##reportReason", ref _reportReason, 500, new Vector2(500 - ImGui.GetStyle().ItemSpacing.X * 2, 200));
|
||||
UiSharedService.TextWrapped(_uiSharedService.Localize("Popup.Report.Note", "Note: Sending a report will disable the offending profile globally.\nThe report will be sent to the team of your currently connected server.\nDepending on the severity of the offense the users profile or account can be permanently disabled or banned."));
|
||||
UiSharedService.ColorTextWrapped(_uiSharedService.Localize("Popup.Report.Warning", "Report spam and wrong reports will not be tolerated and can lead to permanent account suspension."), ImGuiColors.DalamudRed);
|
||||
UiSharedService.ColorTextWrapped(_uiSharedService.Localize("Popup.Report.Scope", "This is not for reporting misbehavior but solely for the actual profile. Reports that are not solely for the profile will be ignored."), ImGuiColors.DalamudYellow);
|
||||
UiSharedService.TextWrapped($"Note: Sending a report will disable the offending profile globally.{Environment.NewLine}" +
|
||||
$"The report will be sent to the team of your currently connected server.{Environment.NewLine}" +
|
||||
$"Depending on the severity of the offense the users profile or account can be permanently disabled or banned.");
|
||||
UiSharedService.ColorTextWrapped("Report spam and wrong reports will not be tolerated and can lead to permanent account suspension.", UiSharedService.AccentColor);
|
||||
UiSharedService.ColorTextWrapped("This is not for reporting misbehavior but solely for the actual profile. " +
|
||||
"Reports that are not solely for the profile will be ignored.", ImGuiColors.DalamudYellow);
|
||||
|
||||
using (ImRaii.Disabled(string.IsNullOrEmpty(_reportReason)))
|
||||
{
|
||||
if (_uiSharedService.IconTextButton(FontAwesomeIcon.ExclamationTriangle, _uiSharedService.Localize("Popup.Report.Button", "Send Report")))
|
||||
if (_uiSharedService.IconTextButton(FontAwesomeIcon.ExclamationTriangle, "Send Report"))
|
||||
{
|
||||
ImGui.CloseCurrentPopup();
|
||||
var reason = _reportReason;
|
||||
_ = _apiController.UserReportProfile(new(_reportedPair.UserData, reason));
|
||||
_reportReason = string.Empty;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,7 +36,7 @@ public class SelectGroupForPairUi
|
||||
}
|
||||
|
||||
var name = PairName(_pair);
|
||||
var popupName = _uiSharedService.Localize("PairGroups.Popup.Title", "Choose Groups for {0}", name);
|
||||
var popupName = $"Choose Groups for {name}";
|
||||
if (_show)
|
||||
{
|
||||
ImGui.OpenPopup(popupName);
|
||||
@@ -49,7 +49,7 @@ public class SelectGroupForPairUi
|
||||
var childHeight = tags.Count != 0 ? tags.Count * 25 : 1;
|
||||
var childSize = new Vector2(0, childHeight > 100 ? 100 : childHeight) * ImGuiHelpers.GlobalScale;
|
||||
|
||||
ImGui.TextUnformatted(_uiSharedService.Localize("PairGroups.Popup.SelectPrompt", "Select the groups you want {0} to be in.", name));
|
||||
ImGui.TextUnformatted($"Select the groups you want {name} to be in.");
|
||||
if (ImGui.BeginChild(name + "##listGroups", childSize))
|
||||
{
|
||||
foreach (var tag in tags)
|
||||
@@ -60,13 +60,13 @@ public class SelectGroupForPairUi
|
||||
}
|
||||
|
||||
ImGui.Separator();
|
||||
ImGui.TextUnformatted(_uiSharedService.Localize("PairGroups.Popup.CreatePrompt", "Create a new group for {0}.", name));
|
||||
ImGui.TextUnformatted($"Create a new group for {name}.");
|
||||
if (_uiSharedService.IconButton(FontAwesomeIcon.Plus))
|
||||
{
|
||||
HandleAddTag();
|
||||
}
|
||||
ImGui.SameLine();
|
||||
ImGui.InputTextWithHint("##category_name", _uiSharedService.Localize("PairGroups.Popup.NewGroupHint", "New Group"), ref _tagNameToAdd, 40);
|
||||
ImGui.InputTextWithHint("##category_name", "New Group", ref _tagNameToAdd, 40);
|
||||
if (ImGui.IsKeyDown(ImGuiKey.Enter))
|
||||
{
|
||||
HandleAddTag();
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
using Dalamud.Bindings.ImGui;
|
||||
using Dalamud.Bindings.ImGui;
|
||||
using Dalamud.Interface.Utility;
|
||||
using MareSynchronos.PlayerData.Pairs;
|
||||
using MareSynchronos.UI;
|
||||
using MareSynchronos.UI.Handlers;
|
||||
using System.Numerics;
|
||||
|
||||
@@ -16,13 +15,11 @@ public class SelectPairForGroupUi
|
||||
private HashSet<string> _peopleInGroup = new(StringComparer.Ordinal);
|
||||
private bool _show = false;
|
||||
private string _tag = string.Empty;
|
||||
private readonly UiSharedService _uiSharedService;
|
||||
|
||||
public SelectPairForGroupUi(TagHandler tagHandler, UidDisplayHandler uidDisplayHandler, UiSharedService uiSharedService)
|
||||
public SelectPairForGroupUi(TagHandler tagHandler, UidDisplayHandler uidDisplayHandler)
|
||||
{
|
||||
_tagHandler = tagHandler;
|
||||
_uidDisplayHandler = uidDisplayHandler;
|
||||
_uiSharedService = uiSharedService;
|
||||
}
|
||||
|
||||
public void Draw(List<Pair> pairs)
|
||||
@@ -31,7 +28,7 @@ public class SelectPairForGroupUi
|
||||
var minSize = new Vector2(300, workHeight < 400 ? workHeight : 400) * ImGuiHelpers.GlobalScale;
|
||||
var maxSize = new Vector2(300, 1000) * ImGuiHelpers.GlobalScale;
|
||||
|
||||
var popupName = _uiSharedService.Localize("PairGroups.SelectPairs.Title", "Choose Users for Group {0}", _tag);
|
||||
var popupName = $"Choose Users for Group {_tag}";
|
||||
|
||||
if (!_show)
|
||||
{
|
||||
@@ -49,9 +46,9 @@ public class SelectPairForGroupUi
|
||||
ImGui.SetNextWindowSizeConstraints(minSize, maxSize);
|
||||
if (ImGui.BeginPopupModal(popupName, ref _show, ImGuiWindowFlags.Popup | ImGuiWindowFlags.Modal))
|
||||
{
|
||||
ImGui.TextUnformatted(_uiSharedService.Localize("PairGroups.SelectPairs.SelectPrompt", "Select users for group {0}", _tag));
|
||||
ImGui.TextUnformatted($"Select users for group {_tag}");
|
||||
|
||||
ImGui.InputTextWithHint("##filter", _uiSharedService.Localize("PairGroups.SelectPairs.FilterHint", "Filter"), ref _filter, 255, ImGuiInputTextFlags.None);
|
||||
ImGui.InputTextWithHint("##filter", "Filter", ref _filter, 255, ImGuiInputTextFlags.None);
|
||||
foreach (var item in pairs
|
||||
.Where(p => string.IsNullOrEmpty(_filter) || PairName(p).Contains(_filter, StringComparison.OrdinalIgnoreCase))
|
||||
.OrderBy(p => PairName(p), StringComparer.OrdinalIgnoreCase)
|
||||
|
||||
@@ -9,8 +9,7 @@ using MareSynchronos.Services.Mediator;
|
||||
using MareSynchronos.Utils;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System.Numerics;
|
||||
using MareSynchronos.Localization;
|
||||
using System.Globalization;
|
||||
using System;
|
||||
|
||||
namespace MareSynchronos.UI;
|
||||
|
||||
@@ -22,7 +21,7 @@ public class DataAnalysisUi : WindowMediatorSubscriberBase
|
||||
private readonly UiSharedService _uiSharedService;
|
||||
private readonly Dictionary<string, string[]> _texturesToConvert = new(StringComparer.Ordinal);
|
||||
private Dictionary<ObjectKind, Dictionary<string, CharacterAnalyzer.FileDataEntry>>? _cachedAnalysis;
|
||||
private CancellationTokenSource _conversionCancellationTokenSource = new();
|
||||
private CancellationTokenSource? _conversionCancellationTokenSource = new();
|
||||
private string _conversionCurrentFileName = string.Empty;
|
||||
private int _conversionCurrentFileProgress = 0;
|
||||
private Task? _conversionTask;
|
||||
@@ -35,17 +34,11 @@ public class DataAnalysisUi : WindowMediatorSubscriberBase
|
||||
private ObjectKind _selectedObjectTab;
|
||||
private bool _showModal = false;
|
||||
|
||||
private string L(string key, string fallback, params object[] args)
|
||||
{
|
||||
var safeArgs = args ?? Array.Empty<object>();
|
||||
return _uiSharedService.Localize(key, fallback, safeArgs);
|
||||
}
|
||||
|
||||
public DataAnalysisUi(ILogger<DataAnalysisUi> logger, MareMediator mediator,
|
||||
CharacterAnalyzer characterAnalyzer, IpcManager ipcManager,
|
||||
PerformanceCollectorService performanceCollectorService,
|
||||
UiSharedService uiSharedService)
|
||||
: base(logger, mediator, uiSharedService.Localize("DataAnalysis.WindowTitle", "Character Data Analysis"), performanceCollectorService)
|
||||
: base(logger, mediator, "Character Data Analysis", performanceCollectorService)
|
||||
{
|
||||
_characterAnalyzer = characterAnalyzer;
|
||||
_ipcManager = ipcManager;
|
||||
@@ -73,17 +66,29 @@ public class DataAnalysisUi : WindowMediatorSubscriberBase
|
||||
|
||||
protected override void DrawInternal()
|
||||
{
|
||||
var modalTitle = L("DataAnalysis.Bc7.ModalTitle", "BC7 Conversion in Progress");
|
||||
DrawAnalysisContent();
|
||||
}
|
||||
|
||||
public void DrawInline()
|
||||
{
|
||||
using (ImRaii.PushId("CharacterAnalysisInline"))
|
||||
{
|
||||
DrawAnalysisContent();
|
||||
}
|
||||
}
|
||||
|
||||
private void DrawAnalysisContent()
|
||||
{
|
||||
if (_conversionTask != null && !_conversionTask.IsCompleted)
|
||||
{
|
||||
_showModal = true;
|
||||
if (ImGui.BeginPopupModal(modalTitle))
|
||||
if (ImGui.BeginPopupModal("BC7 Conversion in Progress"))
|
||||
{
|
||||
ImGui.TextUnformatted(L("DataAnalysis.Bc7.Status", "BC7 Conversion in progress: {0}/{1}", _conversionCurrentFileProgress, _texturesToConvert.Count));
|
||||
UiSharedService.TextWrapped(L("DataAnalysis.Bc7.CurrentFile", "Current file: {0}", _conversionCurrentFileName));
|
||||
if (_uiSharedService.IconTextButton(FontAwesomeIcon.StopCircle, L("DataAnalysis.Bc7.Cancel", "Cancel conversion")))
|
||||
ImGui.TextUnformatted("BC7 Conversion in progress: " + _conversionCurrentFileProgress + "/" + _texturesToConvert.Count);
|
||||
UiSharedService.TextWrapped("Current file: " + _conversionCurrentFileName);
|
||||
if (_uiSharedService.IconTextButton(FontAwesomeIcon.StopCircle, "Cancel conversion"))
|
||||
{
|
||||
_conversionCancellationTokenSource.Cancel();
|
||||
TryCancel(_conversionCancellationTokenSource);
|
||||
}
|
||||
UiSharedService.SetScaledWindowSize(500);
|
||||
ImGui.EndPopup();
|
||||
@@ -104,7 +109,7 @@ public class DataAnalysisUi : WindowMediatorSubscriberBase
|
||||
|
||||
if (_showModal && !_modalOpen)
|
||||
{
|
||||
ImGui.OpenPopup(modalTitle);
|
||||
ImGui.OpenPopup("BC7 Conversion in Progress");
|
||||
_modalOpen = true;
|
||||
}
|
||||
|
||||
@@ -115,7 +120,7 @@ public class DataAnalysisUi : WindowMediatorSubscriberBase
|
||||
_sortDirty = true;
|
||||
}
|
||||
|
||||
UiSharedService.TextWrapped(L("DataAnalysis.Description", "This window shows you all files and their sizes that are currently in use through your character and associated entities"));
|
||||
UiSharedService.TextWrapped("This window shows you all files and their sizes that are currently in use through your character and associated entities");
|
||||
|
||||
if (_cachedAnalysis == null || _cachedAnalysis.Count == 0) return;
|
||||
|
||||
@@ -123,9 +128,9 @@ public class DataAnalysisUi : WindowMediatorSubscriberBase
|
||||
bool needAnalysis = _cachedAnalysis!.Any(c => c.Value.Any(f => !f.Value.IsComputed));
|
||||
if (isAnalyzing)
|
||||
{
|
||||
UiSharedService.ColorTextWrapped(L("DataAnalysis.Analyzing", "Analyzing {0}/{1}", _characterAnalyzer.CurrentFile, _characterAnalyzer.TotalFiles),
|
||||
ImGuiColors.DalamudYellow);
|
||||
if (_uiSharedService.IconTextButton(FontAwesomeIcon.StopCircle, L("DataAnalysis.Button.CancelAnalysis", "Cancel analysis")))
|
||||
UiSharedService.ColorTextWrapped($"Analyzing {_characterAnalyzer.CurrentFile}/{_characterAnalyzer.TotalFiles}",
|
||||
UiSharedService.AccentColor);
|
||||
if (_uiSharedService.IconTextButton(FontAwesomeIcon.StopCircle, "Cancel analysis"))
|
||||
{
|
||||
_characterAnalyzer.CancelAnalyze();
|
||||
}
|
||||
@@ -134,16 +139,16 @@ public class DataAnalysisUi : WindowMediatorSubscriberBase
|
||||
{
|
||||
if (needAnalysis)
|
||||
{
|
||||
UiSharedService.ColorTextWrapped(L("DataAnalysis.Analyze.MissingNotice", "Some entries in the analysis have file size not determined yet, press the button below to analyze your current data"),
|
||||
ImGuiColors.DalamudYellow);
|
||||
if (_uiSharedService.IconTextButton(FontAwesomeIcon.PlayCircle, L("DataAnalysis.Button.StartMissing", "Start analysis (missing entries)")))
|
||||
UiSharedService.ColorTextWrapped("Some entries in the analysis have file size not determined yet, press the button below to analyze your current data",
|
||||
UiSharedService.AccentColor);
|
||||
if (_uiSharedService.IconTextButton(FontAwesomeIcon.PlayCircle, "Start analysis (missing entries)"))
|
||||
{
|
||||
_ = _characterAnalyzer.ComputeAnalysis(print: false);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (_uiSharedService.IconTextButton(FontAwesomeIcon.PlayCircle, L("DataAnalysis.Button.StartAll", "Start analysis (recalculate all entries)")))
|
||||
if (_uiSharedService.IconTextButton(FontAwesomeIcon.PlayCircle, "Start analysis (recalculate all entries)"))
|
||||
{
|
||||
_ = _characterAnalyzer.ComputeAnalysis(print: false, recalculate: true);
|
||||
}
|
||||
@@ -152,7 +157,7 @@ public class DataAnalysisUi : WindowMediatorSubscriberBase
|
||||
|
||||
ImGui.Separator();
|
||||
|
||||
ImGui.TextUnformatted(L("DataAnalysis.TotalFiles", "Total files:"));
|
||||
ImGui.TextUnformatted("Total files:");
|
||||
ImGui.SameLine();
|
||||
ImGui.TextUnformatted(_cachedAnalysis!.Values.Sum(c => c.Values.Count).ToString());
|
||||
ImGui.SameLine();
|
||||
@@ -162,18 +167,19 @@ public class DataAnalysisUi : WindowMediatorSubscriberBase
|
||||
}
|
||||
if (ImGui.IsItemHovered())
|
||||
{
|
||||
string text = "";
|
||||
var groupedfiles = _cachedAnalysis.Values.SelectMany(f => f.Values).GroupBy(f => f.FileType, StringComparer.Ordinal);
|
||||
var summary = string.Join(Environment.NewLine, groupedfiles.OrderBy(f => f.Key, StringComparer.Ordinal)
|
||||
.Select(f => L("DataAnalysis.Tooltip.FileSummary", "{0}: {1} files, size: {2}, compressed: {3}",
|
||||
f.Key, f.Count(), UiSharedService.ByteToString(f.Sum(v => v.OriginalSize)), UiSharedService.ByteToString(f.Sum(v => v.CompressedSize)))));
|
||||
ImGui.SetTooltip(summary);
|
||||
text = string.Join(Environment.NewLine, groupedfiles.OrderBy(f => f.Key, StringComparer.Ordinal)
|
||||
.Select(f => f.Key + ": " + f.Count() + " files, size: " + UiSharedService.ByteToString(f.Sum(v => v.OriginalSize))
|
||||
+ ", compressed: " + UiSharedService.ByteToString(f.Sum(v => v.CompressedSize))));
|
||||
ImGui.SetTooltip(text);
|
||||
}
|
||||
ImGui.TextUnformatted(L("DataAnalysis.TotalSizeActual", "Total size (actual):"));
|
||||
ImGui.TextUnformatted("Total size (actual):");
|
||||
ImGui.SameLine();
|
||||
ImGui.TextUnformatted(UiSharedService.ByteToString(_cachedAnalysis!.Sum(c => c.Value.Sum(c => c.Value.OriginalSize))));
|
||||
ImGui.TextUnformatted(L("DataAnalysis.TotalSizeDownload", "Total size (download size):"));
|
||||
ImGui.TextUnformatted("Total size (download size):");
|
||||
ImGui.SameLine();
|
||||
using (ImRaii.PushColor(ImGuiCol.Text, ImGuiColors.DalamudYellow, needAnalysis))
|
||||
using (ImRaii.PushColor(ImGuiCol.Text, UiSharedService.AccentColor, needAnalysis))
|
||||
{
|
||||
ImGui.TextUnformatted(UiSharedService.ByteToString(_cachedAnalysis!.Sum(c => c.Value.Sum(c => c.Value.CompressedSize))));
|
||||
if (needAnalysis && !isAnalyzing)
|
||||
@@ -181,13 +187,16 @@ public class DataAnalysisUi : WindowMediatorSubscriberBase
|
||||
ImGui.SameLine();
|
||||
using (ImRaii.PushFont(UiBuilder.IconFont))
|
||||
ImGui.TextUnformatted(FontAwesomeIcon.ExclamationCircle.ToIconString());
|
||||
UiSharedService.AttachToolTip(L("DataAnalysis.Tooltip.CalculateDownloadSize", "Click \"Start analysis\" to calculate download size"));
|
||||
UiSharedService.AttachToolTip("Click \"Start analysis\" to calculate download size");
|
||||
}
|
||||
}
|
||||
ImGui.TextUnformatted(L("DataAnalysis.TotalTriangles", "Total modded model triangles: {0}",
|
||||
UiSharedService.TrisToString(_cachedAnalysis.Sum(c => c.Value.Sum(f => f.Value.Triangles)))));
|
||||
ImGui.TextUnformatted($"Total modded model triangles: {UiSharedService.TrisToString(_cachedAnalysis.Sum(c => c.Value.Sum(f => f.Value.Triangles)))}");
|
||||
ImGui.Separator();
|
||||
|
||||
{
|
||||
using var objectTabColor = ImRaii.PushColor(ImGuiCol.Tab, UiSharedService.AccentColor);
|
||||
using var objectTabHoverColor = ImRaii.PushColor(ImGuiCol.TabHovered, UiSharedService.AccentHoverColor);
|
||||
using var objectTabActiveColor = ImRaii.PushColor(ImGuiCol.TabActive, UiSharedService.AccentActiveColor);
|
||||
using var tabbar = ImRaii.TabBar("objectSelection");
|
||||
foreach (var kvp in _cachedAnalysis)
|
||||
{
|
||||
@@ -199,7 +208,7 @@ public class DataAnalysisUi : WindowMediatorSubscriberBase
|
||||
var groupedfiles = kvp.Value.Select(v => v.Value).GroupBy(f => f.FileType, StringComparer.Ordinal)
|
||||
.OrderBy(k => k.Key, StringComparer.Ordinal).ToList();
|
||||
|
||||
ImGui.TextUnformatted(L("DataAnalysis.FilesFor", "Files for {0}", kvp.Key));
|
||||
ImGui.TextUnformatted("Files for " + kvp.Key);
|
||||
ImGui.SameLine();
|
||||
ImGui.TextUnformatted(kvp.Value.Count.ToString());
|
||||
ImGui.SameLine();
|
||||
@@ -210,17 +219,18 @@ public class DataAnalysisUi : WindowMediatorSubscriberBase
|
||||
}
|
||||
if (ImGui.IsItemHovered())
|
||||
{
|
||||
var summary = string.Join(Environment.NewLine, groupedfiles
|
||||
.Select(f => L("DataAnalysis.Tooltip.FileSummary", "{0}: {1} files, size: {2}, compressed: {3}",
|
||||
f.Key, f.Count(), UiSharedService.ByteToString(f.Sum(v => v.OriginalSize)), UiSharedService.ByteToString(f.Sum(v => v.CompressedSize)))));
|
||||
ImGui.SetTooltip(summary);
|
||||
string text = "";
|
||||
text = string.Join(Environment.NewLine, groupedfiles
|
||||
.Select(f => f.Key + ": " + f.Count() + " files, size: " + UiSharedService.ByteToString(f.Sum(v => v.OriginalSize))
|
||||
+ ", compressed: " + UiSharedService.ByteToString(f.Sum(v => v.CompressedSize))));
|
||||
ImGui.SetTooltip(text);
|
||||
}
|
||||
ImGui.TextUnformatted(L("DataAnalysis.Object.SizeActual", "{0} size (actual):", kvp.Key));
|
||||
ImGui.TextUnformatted($"{kvp.Key} size (actual):");
|
||||
ImGui.SameLine();
|
||||
ImGui.TextUnformatted(UiSharedService.ByteToString(kvp.Value.Sum(c => c.Value.OriginalSize)));
|
||||
ImGui.TextUnformatted(L("DataAnalysis.Object.SizeDownload", "{0} size (download size):", kvp.Key));
|
||||
ImGui.TextUnformatted($"{kvp.Key} size (download size):");
|
||||
ImGui.SameLine();
|
||||
using (ImRaii.PushColor(ImGuiCol.Text, ImGuiColors.DalamudYellow, needAnalysis))
|
||||
using (ImRaii.PushColor(ImGuiCol.Text, UiSharedService.AccentColor, needAnalysis))
|
||||
{
|
||||
ImGui.TextUnformatted(UiSharedService.ByteToString(kvp.Value.Sum(c => c.Value.CompressedSize)));
|
||||
if (needAnalysis && !isAnalyzing)
|
||||
@@ -228,18 +238,17 @@ public class DataAnalysisUi : WindowMediatorSubscriberBase
|
||||
ImGui.SameLine();
|
||||
using (ImRaii.PushFont(UiBuilder.IconFont))
|
||||
ImGui.TextUnformatted(FontAwesomeIcon.ExclamationCircle.ToIconString());
|
||||
UiSharedService.AttachToolTip(L("DataAnalysis.Tooltip.CalculateDownloadSize", "Click \"Start analysis\" to calculate download size"));
|
||||
UiSharedService.AttachToolTip("Click \"Start analysis\" to calculate download size");
|
||||
}
|
||||
}
|
||||
ImGui.TextUnformatted(L("DataAnalysis.Object.Vram", "{0} VRAM usage:", kvp.Key));
|
||||
ImGui.TextUnformatted($"{kvp.Key} VRAM usage:");
|
||||
ImGui.SameLine();
|
||||
var vramUsage = groupedfiles.SingleOrDefault(v => string.Equals(v.Key, "tex", StringComparison.Ordinal));
|
||||
if (vramUsage != null)
|
||||
{
|
||||
ImGui.TextUnformatted(UiSharedService.ByteToString(vramUsage.Sum(f => f.OriginalSize)));
|
||||
}
|
||||
ImGui.TextUnformatted(L("DataAnalysis.Object.Triangles", "{0} modded model triangles: {1}", kvp.Key,
|
||||
UiSharedService.TrisToString(kvp.Value.Sum(f => f.Value.Triangles))));
|
||||
ImGui.TextUnformatted($"{kvp.Key} modded model triangles: {UiSharedService.TrisToString(kvp.Value.Sum(f => f.Value.Triangles))}");
|
||||
|
||||
ImGui.Separator();
|
||||
if (_selectedObjectTab != kvp.Key)
|
||||
@@ -251,15 +260,17 @@ public class DataAnalysisUi : WindowMediatorSubscriberBase
|
||||
_texturesToConvert.Clear();
|
||||
}
|
||||
|
||||
using var fileTabColor = ImRaii.PushColor(ImGuiCol.Tab, UiSharedService.AccentColor);
|
||||
using var fileTabHoverColor = ImRaii.PushColor(ImGuiCol.TabHovered, UiSharedService.AccentHoverColor);
|
||||
using var fileTabActiveColor = ImRaii.PushColor(ImGuiCol.TabActive, UiSharedService.AccentActiveColor);
|
||||
using var fileTabBar = ImRaii.TabBar("fileTabs");
|
||||
|
||||
foreach (IGrouping<string, CharacterAnalyzer.FileDataEntry>? fileGroup in groupedfiles)
|
||||
{
|
||||
string fileGroupText = fileGroup.Key + " [" + fileGroup.Count() + "]";
|
||||
var requiresCompute = fileGroup.Any(k => !k.IsComputed);
|
||||
using var tabcol = ImRaii.PushColor(ImGuiCol.Tab, UiSharedService.Color(ImGuiColors.DalamudYellow), requiresCompute);
|
||||
ImRaii.IEndObject fileTab;
|
||||
using (var textcol = ImRaii.PushColor(ImGuiCol.Text, UiSharedService.Color(new(0, 0, 0, 1)),
|
||||
using (var textcol = ImRaii.PushColor(ImGuiCol.Text, UiSharedService.Color(Vector4.One),
|
||||
requiresCompute && !string.Equals(_selectedFileTypeTab, fileGroup.Key, StringComparison.Ordinal)))
|
||||
{
|
||||
fileTab = ImRaii.TabItem(fileGroupText + "###" + fileGroup.Key);
|
||||
@@ -275,38 +286,36 @@ public class DataAnalysisUi : WindowMediatorSubscriberBase
|
||||
_texturesToConvert.Clear();
|
||||
}
|
||||
|
||||
ImGui.TextUnformatted(L("DataAnalysis.FileGroup.Count", "{0} files", fileGroup.Key));
|
||||
ImGui.TextUnformatted($"{fileGroup.Key} files");
|
||||
ImGui.SameLine();
|
||||
ImGui.TextUnformatted(fileGroup.Count().ToString());
|
||||
|
||||
ImGui.TextUnformatted(L("DataAnalysis.FileGroup.SizeActual", "{0} files size (actual):", fileGroup.Key));
|
||||
ImGui.TextUnformatted($"{fileGroup.Key} files size (actual):");
|
||||
ImGui.SameLine();
|
||||
ImGui.TextUnformatted(UiSharedService.ByteToString(fileGroup.Sum(c => c.OriginalSize)));
|
||||
|
||||
ImGui.TextUnformatted(L("DataAnalysis.FileGroup.SizeDownload", "{0} files size (download size):", fileGroup.Key));
|
||||
ImGui.TextUnformatted($"{fileGroup.Key} files size (download size):");
|
||||
ImGui.SameLine();
|
||||
ImGui.TextUnformatted(UiSharedService.ByteToString(fileGroup.Sum(c => c.CompressedSize)));
|
||||
|
||||
if (string.Equals(_selectedFileTypeTab, "tex", StringComparison.Ordinal))
|
||||
{
|
||||
ImGui.Checkbox(L("DataAnalysis.Bc7.EnableMode", "Enable BC7 Conversion Mode"), ref _enableBc7ConversionMode);
|
||||
ImGui.Checkbox("Enable BC7 Conversion Mode", ref _enableBc7ConversionMode);
|
||||
if (_enableBc7ConversionMode)
|
||||
{
|
||||
UiSharedService.ColorText(L("DataAnalysis.Bc7.WarningTitle", "WARNING BC7 CONVERSION:"), ImGuiColors.DalamudYellow);
|
||||
UiSharedService.ColorText("WARNING BC7 CONVERSION:", UiSharedService.AccentColor);
|
||||
ImGui.SameLine();
|
||||
UiSharedService.ColorText(L("DataAnalysis.Bc7.WarningIrreversible", "Converting textures to BC7 is irreversible!"), ImGuiColors.DalamudRed);
|
||||
UiSharedService.ColorTextWrapped(L("DataAnalysis.Bc7.WarningDetails",
|
||||
"- Converting textures to BC7 will reduce their size (compressed and uncompressed) drastically. It is recommended to be used for large (4k+) textures.\n"
|
||||
+ "- Some textures, especially ones utilizing colorsets, might not be suited for BC7 conversion and might produce visual artifacts.\n"
|
||||
+ "- Before converting textures, make sure to have the original files of the mod you are converting so you can reimport it in case of issues.\n"
|
||||
+ "- Conversion will convert all found texture duplicates (entries with more than 1 file path) automatically.\n"
|
||||
+ "- Converting textures to BC7 is a very expensive operation and, depending on the amount of textures to convert, will take a while to complete."),
|
||||
ImGuiColors.DalamudYellow);
|
||||
if (_texturesToConvert.Count > 0 && _uiSharedService.IconTextButton(FontAwesomeIcon.PlayCircle,
|
||||
L("DataAnalysis.Bc7.StartConversion", "Start conversion of {0} texture(s)", _texturesToConvert.Count)))
|
||||
UiSharedService.ColorText("Converting textures to BC7 is irreversible!", UiSharedService.AccentColor);
|
||||
UiSharedService.ColorTextWrapped("- Converting textures to BC7 will reduce their size (compressed and uncompressed) drastically. It is recommended to be used for large (4k+) textures." +
|
||||
Environment.NewLine + "- Some textures, especially ones utilizing colorsets, might not be suited for BC7 conversion and might produce visual artifacts." +
|
||||
Environment.NewLine + "- Before converting textures, make sure to have the original files of the mod you are converting so you can reimport it in case of issues." +
|
||||
Environment.NewLine + "- Conversion will convert all found texture duplicates (entries with more than 1 file path) automatically." +
|
||||
Environment.NewLine + "- Converting textures to BC7 is a very expensive operation and, depending on the amount of textures to convert, will take a while to complete."
|
||||
, UiSharedService.AccentColor);
|
||||
if (_texturesToConvert.Count > 0 && _uiSharedService.IconTextButton(FontAwesomeIcon.PlayCircle, "Start conversion of " + _texturesToConvert.Count + " texture(s)"))
|
||||
{
|
||||
_conversionCancellationTokenSource = _conversionCancellationTokenSource.CancelRecreate();
|
||||
_conversionTask = _ipcManager.Penumbra.ConvertTextureFiles(_logger, _texturesToConvert, _conversionProgress, _conversionCancellationTokenSource.Token);
|
||||
var conversionCts = EnsureFreshCts(ref _conversionCancellationTokenSource);
|
||||
_conversionTask = _ipcManager.Penumbra.ConvertTextureFiles(_logger, _texturesToConvert, _conversionProgress, conversionCts.Token);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -316,38 +325,41 @@ public class DataAnalysisUi : WindowMediatorSubscriberBase
|
||||
|
||||
fileTab.Dispose();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
ImGui.Separator();
|
||||
|
||||
ImGui.TextUnformatted(L("DataAnalysis.SelectedFile", "Selected file:"));
|
||||
ImGui.TextUnformatted("Selected file:");
|
||||
ImGui.SameLine();
|
||||
UiSharedService.ColorText(_selectedHash, ImGuiColors.DalamudYellow);
|
||||
UiSharedService.ColorText(_selectedHash, UiSharedService.AccentColor);
|
||||
|
||||
if (_cachedAnalysis[_selectedObjectTab].TryGetValue(_selectedHash, out CharacterAnalyzer.FileDataEntry? item))
|
||||
{
|
||||
var filePaths = item.FilePaths;
|
||||
ImGui.TextUnformatted(L("DataAnalysis.LocalFilePath", "Local file path:"));
|
||||
ImGui.TextUnformatted("Local file path:");
|
||||
ImGui.SameLine();
|
||||
UiSharedService.TextWrapped(filePaths[0]);
|
||||
if (filePaths.Count > 1)
|
||||
{
|
||||
ImGui.SameLine();
|
||||
ImGui.TextUnformatted(L("DataAnalysis.MoreCount", "(and {0} more)", filePaths.Count - 1));
|
||||
ImGui.TextUnformatted($"(and {filePaths.Count - 1} more)");
|
||||
ImGui.SameLine();
|
||||
_uiSharedService.IconText(FontAwesomeIcon.InfoCircle);
|
||||
UiSharedService.AttachToolTip(string.Join(Environment.NewLine, filePaths.Skip(1)));
|
||||
}
|
||||
|
||||
var gamepaths = item.GamePaths;
|
||||
ImGui.TextUnformatted(L("DataAnalysis.GamePath", "Used by game path:"));
|
||||
ImGui.TextUnformatted("Used by game path:");
|
||||
ImGui.SameLine();
|
||||
UiSharedService.TextWrapped(gamepaths[0]);
|
||||
if (gamepaths.Count > 1)
|
||||
{
|
||||
ImGui.SameLine();
|
||||
ImGui.TextUnformatted(L("DataAnalysis.MoreCount", "(and {0} more)", gamepaths.Count - 1));
|
||||
ImGui.TextUnformatted($"(and {gamepaths.Count - 1} more)");
|
||||
ImGui.SameLine();
|
||||
_uiSharedService.IconText(FontAwesomeIcon.InfoCircle);
|
||||
UiSharedService.AttachToolTip(string.Join(Environment.NewLine, gamepaths.Skip(1)));
|
||||
@@ -365,10 +377,15 @@ public class DataAnalysisUi : WindowMediatorSubscriberBase
|
||||
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
base.Dispose(disposing);
|
||||
if (disposing)
|
||||
{
|
||||
CancelAndDispose(ref _conversionCancellationTokenSource);
|
||||
_conversionProgress.ProgressChanged -= ConversionProgress_ProgressChanged;
|
||||
}
|
||||
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
private void ConversionProgress_ProgressChanged(object? sender, (string, int) e)
|
||||
{
|
||||
_conversionCurrentFileName = e.Item1;
|
||||
@@ -383,19 +400,19 @@ public class DataAnalysisUi : WindowMediatorSubscriberBase
|
||||
using var table = ImRaii.Table("Analysis", tableColumns, ImGuiTableFlags.Sortable | ImGuiTableFlags.RowBg | ImGuiTableFlags.ScrollY | ImGuiTableFlags.SizingFixedFit,
|
||||
new Vector2(0, 300));
|
||||
if (!table.Success) return;
|
||||
ImGui.TableSetupColumn(L("DataAnalysis.Table.Hash", "Hash"));
|
||||
ImGui.TableSetupColumn(L("DataAnalysis.Table.Filepaths", "Filepaths"), ImGuiTableColumnFlags.PreferSortDescending);
|
||||
ImGui.TableSetupColumn(L("DataAnalysis.Table.Gamepaths", "Gamepaths"), ImGuiTableColumnFlags.PreferSortDescending);
|
||||
ImGui.TableSetupColumn(L("DataAnalysis.Table.FileSize", "File Size"), ImGuiTableColumnFlags.DefaultSort | ImGuiTableColumnFlags.PreferSortDescending);
|
||||
ImGui.TableSetupColumn(L("DataAnalysis.Table.DownloadSize", "Download Size"), ImGuiTableColumnFlags.PreferSortDescending);
|
||||
ImGui.TableSetupColumn("Hash");
|
||||
ImGui.TableSetupColumn("Filepaths", ImGuiTableColumnFlags.PreferSortDescending);
|
||||
ImGui.TableSetupColumn("Gamepaths", ImGuiTableColumnFlags.PreferSortDescending);
|
||||
ImGui.TableSetupColumn("File Size", ImGuiTableColumnFlags.DefaultSort | ImGuiTableColumnFlags.PreferSortDescending);
|
||||
ImGui.TableSetupColumn("Download Size", ImGuiTableColumnFlags.PreferSortDescending);
|
||||
if (string.Equals(fileGroup.Key, "tex", StringComparison.Ordinal))
|
||||
{
|
||||
ImGui.TableSetupColumn(L("DataAnalysis.Table.Format", "Format"));
|
||||
if (_enableBc7ConversionMode) ImGui.TableSetupColumn(L("DataAnalysis.Table.ConvertToBc7", "Convert to BC7"));
|
||||
ImGui.TableSetupColumn("Format");
|
||||
if (_enableBc7ConversionMode) ImGui.TableSetupColumn("Convert to BC7");
|
||||
}
|
||||
if (string.Equals(fileGroup.Key, "mdl", StringComparison.Ordinal))
|
||||
{
|
||||
ImGui.TableSetupColumn(L("DataAnalysis.Table.Triangles", "Triangles"), ImGuiTableColumnFlags.PreferSortDescending);
|
||||
ImGui.TableSetupColumn("Triangles", ImGuiTableColumnFlags.PreferSortDescending);
|
||||
}
|
||||
ImGui.TableSetupScrollFreeze(0, 1);
|
||||
ImGui.TableHeadersRow();
|
||||
@@ -445,8 +462,8 @@ public class DataAnalysisUi : WindowMediatorSubscriberBase
|
||||
ImGui.TableNextColumn();
|
||||
if (string.Equals(_selectedHash, item.Hash, StringComparison.Ordinal))
|
||||
{
|
||||
ImGui.TableSetBgColor(ImGuiTableBgTarget.RowBg1, UiSharedService.Color(ImGuiColors.DalamudYellow));
|
||||
ImGui.TableSetBgColor(ImGuiTableBgTarget.RowBg0, UiSharedService.Color(ImGuiColors.DalamudYellow));
|
||||
ImGui.TableSetBgColor(ImGuiTableBgTarget.RowBg1, UiSharedService.Color(UiSharedService.AccentColor));
|
||||
ImGui.TableSetBgColor(ImGuiTableBgTarget.RowBg0, UiSharedService.Color(UiSharedService.AccentColor));
|
||||
}
|
||||
ImGui.TextUnformatted(item.Hash);
|
||||
if (ImGui.IsItemClicked()) _selectedHash = item.Hash;
|
||||
@@ -460,7 +477,7 @@ public class DataAnalysisUi : WindowMediatorSubscriberBase
|
||||
ImGui.TextUnformatted(UiSharedService.ByteToString(item.OriginalSize));
|
||||
if (ImGui.IsItemClicked()) _selectedHash = item.Hash;
|
||||
ImGui.TableNextColumn();
|
||||
using (ImRaii.PushColor(ImGuiCol.Text, ImGuiColors.DalamudYellow, !item.IsComputed))
|
||||
using (ImRaii.PushColor(ImGuiCol.Text, UiSharedService.AccentColor, !item.IsComputed))
|
||||
ImGui.TextUnformatted(UiSharedService.ByteToString(item.CompressedSize));
|
||||
if (ImGui.IsItemClicked()) _selectedHash = item.Hash;
|
||||
if (string.Equals(fileGroup.Key, "tex", StringComparison.Ordinal))
|
||||
@@ -500,4 +517,31 @@ public class DataAnalysisUi : WindowMediatorSubscriberBase
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static CancellationTokenSource EnsureFreshCts(ref CancellationTokenSource? cts)
|
||||
{
|
||||
CancelAndDispose(ref cts);
|
||||
cts = new CancellationTokenSource();
|
||||
return cts;
|
||||
}
|
||||
|
||||
private static void CancelAndDispose(ref CancellationTokenSource? cts)
|
||||
{
|
||||
if (cts == null) return;
|
||||
TryCancel(cts);
|
||||
cts.Dispose();
|
||||
cts = null;
|
||||
}
|
||||
|
||||
private static void TryCancel(CancellationTokenSource? cts)
|
||||
{
|
||||
if (cts == null) return;
|
||||
try
|
||||
{
|
||||
cts.Cancel();
|
||||
}
|
||||
catch (ObjectDisposedException)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ public class DownloadUi : WindowMediatorSubscriberBase
|
||||
|
||||
public DownloadUi(ILogger<DownloadUi> logger, DalamudUtilService dalamudUtilService, MareConfigService configService,
|
||||
FileUploadManager fileTransferManager, MareMediator mediator, UiSharedService uiShared, PerformanceCollectorService performanceCollectorService)
|
||||
: base(logger, mediator, uiShared.Localize("DownloadUi.WindowTitle", "Umbra Downloads"), performanceCollectorService)
|
||||
: base(logger, mediator, "Umbra Downloads", performanceCollectorService)
|
||||
{
|
||||
_dalamudUtilService = dalamudUtilService;
|
||||
_configService = configService;
|
||||
@@ -69,8 +69,6 @@ public class DownloadUi : WindowMediatorSubscriberBase
|
||||
});
|
||||
}
|
||||
|
||||
private string L(string key, string fallback, params object[] args) => _uiShared.Localize(key, fallback, args);
|
||||
|
||||
protected override void DrawInternal()
|
||||
{
|
||||
if (_configService.Current.ShowTransferWindow)
|
||||
@@ -89,7 +87,7 @@ public class DownloadUi : WindowMediatorSubscriberBase
|
||||
UiSharedService.DrawOutlinedFont($"▲", ImGuiColors.DalamudWhite, new Vector4(0, 0, 0, 255), 1);
|
||||
ImGui.SameLine();
|
||||
var xDistance = ImGui.GetCursorPosX();
|
||||
UiSharedService.DrawOutlinedFont(L("DownloadUi.UploadStatus", "Compressing+Uploading {0}/{1}", doneUploads, totalUploads),
|
||||
UiSharedService.DrawOutlinedFont($"Compressing+Uploading {doneUploads}/{totalUploads}",
|
||||
ImGuiColors.DalamudWhite, new Vector4(0, 0, 0, 255), 1);
|
||||
ImGui.NewLine();
|
||||
ImGui.SameLine(xDistance);
|
||||
@@ -122,7 +120,7 @@ public class DownloadUi : WindowMediatorSubscriberBase
|
||||
ImGui.SameLine();
|
||||
var xDistance = ImGui.GetCursorPosX();
|
||||
UiSharedService.DrawOutlinedFont(
|
||||
L("DownloadUi.DownloadStatus", "{0} [W:{1}/Q:{2}/P:{3}/D:{4}]", item.Key.Name, dlSlot, dlQueue, dlProg, dlDecomp),
|
||||
$"{item.Key.Name} [W:{dlSlot}/Q:{dlQueue}/P:{dlProg}/D:{dlDecomp}]",
|
||||
ImGuiColors.DalamudWhite, new Vector4(0, 0, 0, 255), 1);
|
||||
ImGui.NewLine();
|
||||
ImGui.SameLine(xDistance);
|
||||
@@ -193,7 +191,7 @@ public class DownloadUi : WindowMediatorSubscriberBase
|
||||
try
|
||||
{
|
||||
using var _ = _uiShared.UidFont.Push();
|
||||
var uploadText = L("DownloadUi.UploadingLabel", "Uploading");
|
||||
var uploadText = "Uploading";
|
||||
|
||||
var textSize = ImGui.CalcTextSize(uploadText);
|
||||
|
||||
|
||||
@@ -6,13 +6,12 @@ using Dalamud.Interface;
|
||||
using MareSynchronos.MareConfiguration;
|
||||
using MareSynchronos.MareConfiguration.Configurations;
|
||||
using MareSynchronos.PlayerData.Pairs;
|
||||
using MareSynchronos.Services.AutoDetect;
|
||||
using MareSynchronos.Services.Mediator;
|
||||
using MareSynchronos.WebAPI;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System.Runtime.InteropServices;
|
||||
using MareSynchronos.Localization;
|
||||
using System.Globalization;
|
||||
|
||||
namespace MareSynchronos.UI;
|
||||
|
||||
@@ -43,19 +42,13 @@ public sealed class DtrEntry : IDisposable, IHostedService
|
||||
private readonly ILogger<DtrEntry> _logger;
|
||||
private readonly MareMediator _mareMediator;
|
||||
private readonly PairManager _pairManager;
|
||||
private readonly NearbyPendingService _nearbyPendingService;
|
||||
private Task? _runTask;
|
||||
private string? _text;
|
||||
private string? _tooltip;
|
||||
private Colors _colors;
|
||||
|
||||
private static string L(string key, string fallback, params object[] args)
|
||||
{
|
||||
var safeArgs = args ?? Array.Empty<object>();
|
||||
return LocalizationService.Instance?.GetString(key, fallback, safeArgs)
|
||||
?? string.Format(CultureInfo.CurrentCulture, fallback, safeArgs);
|
||||
}
|
||||
|
||||
public DtrEntry(ILogger<DtrEntry> logger, IDtrBar dtrBar, MareConfigService configService, MareMediator mareMediator, PairManager pairManager, ApiController apiController)
|
||||
public DtrEntry(ILogger<DtrEntry> logger, IDtrBar dtrBar, MareConfigService configService, MareMediator mareMediator, PairManager pairManager, ApiController apiController, NearbyPendingService nearbyPendingService)
|
||||
{
|
||||
_logger = logger;
|
||||
_dtrBar = dtrBar;
|
||||
@@ -64,6 +57,7 @@ public sealed class DtrEntry : IDisposable, IHostedService
|
||||
_mareMediator = mareMediator;
|
||||
_pairManager = pairManager;
|
||||
_apiController = apiController;
|
||||
_nearbyPendingService = nearbyPendingService;
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
@@ -115,7 +109,7 @@ public sealed class DtrEntry : IDisposable, IHostedService
|
||||
private IDtrBarEntry CreateEntry()
|
||||
{
|
||||
_logger.LogTrace("Creating new DtrBar entry");
|
||||
var entry = _dtrBar.Get(L("DtrEntry.EntryName", "Umbra"));
|
||||
var entry = _dtrBar.Get("Umbra");
|
||||
entry.OnClick = _ => _mareMediator.Publish(new UiToggleMessage(typeof(CompactUi)));
|
||||
|
||||
return entry;
|
||||
@@ -156,8 +150,9 @@ public sealed class DtrEntry : IDisposable, IHostedService
|
||||
if (_apiController.IsConnected)
|
||||
{
|
||||
var pairCount = _pairManager.GetVisibleUserCount();
|
||||
|
||||
text = RenderDtrStyle(_configService.Current.DtrStyle, pairCount.ToString());
|
||||
var baseText = RenderDtrStyle(_configService.Current.DtrStyle, pairCount.ToString());
|
||||
var pendingNearby = _nearbyPendingService.Pending.Count;
|
||||
text = pendingNearby > 0 ? $"{baseText} ({pendingNearby})" : baseText;
|
||||
if (pairCount > 0)
|
||||
{
|
||||
IEnumerable<string> visiblePairs;
|
||||
@@ -174,20 +169,28 @@ public sealed class DtrEntry : IDisposable, IHostedService
|
||||
.Select(x => string.Format("{0}", _configService.Current.PreferNoteInDtrTooltip ? x.GetNoteOrName() : x.PlayerName));
|
||||
}
|
||||
|
||||
var header = L("DtrEntry.Tooltip.Connected", "Umbra: Connected");
|
||||
tooltip = header + Environment.NewLine + "----------" + Environment.NewLine + string.Join(Environment.NewLine, visiblePairs);
|
||||
tooltip = $"Umbra: Connected";
|
||||
if (pendingNearby > 0)
|
||||
{
|
||||
tooltip += $"{Environment.NewLine}Invitation en attente : {pendingNearby}";
|
||||
}
|
||||
tooltip += $"{Environment.NewLine}----------{Environment.NewLine}{string.Join(Environment.NewLine, visiblePairs)}";
|
||||
colors = _configService.Current.DtrColorsPairsInRange;
|
||||
}
|
||||
else
|
||||
{
|
||||
tooltip = L("DtrEntry.Tooltip.Connected", "Umbra: Connected");
|
||||
tooltip = "Umbra: Connected";
|
||||
if (pendingNearby > 0)
|
||||
{
|
||||
tooltip += $"{Environment.NewLine}Invitation en attente : {pendingNearby}";
|
||||
}
|
||||
colors = _configService.Current.DtrColorsDefault;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
text = RenderDtrStyle(_configService.Current.DtrStyle, "\uE04C");
|
||||
tooltip = L("DtrEntry.Tooltip.Disconnected", "Umbra: Not Connected");
|
||||
tooltip = "Umbra: Not Connected";
|
||||
colors = _configService.Current.DtrColorsNotConnected;
|
||||
}
|
||||
|
||||
|
||||
@@ -12,6 +12,7 @@ using MareSynchronos.Services.ServerConfiguration;
|
||||
using MareSynchronos.Utils;
|
||||
using MareSynchronos.WebAPI;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System.Numerics;
|
||||
|
||||
namespace MareSynchronos.UI;
|
||||
|
||||
@@ -21,7 +22,6 @@ public class EditProfileUi : WindowMediatorSubscriberBase
|
||||
private readonly FileDialogManager _fileDialogManager;
|
||||
private readonly MareProfileManager _mareProfileManager;
|
||||
private readonly UiSharedService _uiSharedService;
|
||||
private readonly ServerConfigurationManager _serverConfigurationManager;
|
||||
private bool _adjustedForScollBarsLocalProfile = false;
|
||||
private bool _adjustedForScollBarsOnlineProfile = false;
|
||||
private string _descriptionText = string.Empty;
|
||||
@@ -33,9 +33,8 @@ public class EditProfileUi : WindowMediatorSubscriberBase
|
||||
|
||||
public EditProfileUi(ILogger<EditProfileUi> logger, MareMediator mediator,
|
||||
ApiController apiController, UiSharedService uiSharedService, FileDialogManager fileDialogManager,
|
||||
ServerConfigurationManager serverConfigurationManager,
|
||||
MareProfileManager mareProfileManager, PerformanceCollectorService performanceCollectorService)
|
||||
: base(logger, mediator, uiSharedService.Localize("EditProfile.WindowTitle", "Umbra Edit Profile") + "###UmbraSyncEditProfileUI", performanceCollectorService)
|
||||
: base(logger, mediator, "Umbra Edit Profile###UmbraSyncEditProfileUI", performanceCollectorService)
|
||||
{
|
||||
IsOpen = false;
|
||||
this.SizeConstraints = new()
|
||||
@@ -46,7 +45,6 @@ public class EditProfileUi : WindowMediatorSubscriberBase
|
||||
_apiController = apiController;
|
||||
_uiSharedService = uiSharedService;
|
||||
_fileDialogManager = fileDialogManager;
|
||||
_serverConfigurationManager = serverConfigurationManager;
|
||||
_mareProfileManager = mareProfileManager;
|
||||
|
||||
Mediator.Subscribe<GposeStartMessage>(this, (_) => { _wasOpen = IsOpen; IsOpen = false; });
|
||||
@@ -62,17 +60,26 @@ public class EditProfileUi : WindowMediatorSubscriberBase
|
||||
});
|
||||
}
|
||||
|
||||
private string L(string key, string fallback, params object[] args) => _uiSharedService.Localize(key, fallback, args);
|
||||
|
||||
protected override void DrawInternal()
|
||||
{
|
||||
_uiSharedService.BigText(L("EditProfile.CurrentProfile", "Current Profile (as saved on server)"));
|
||||
DrawProfileContent();
|
||||
}
|
||||
|
||||
public void DrawInline()
|
||||
{
|
||||
DrawProfileContent();
|
||||
}
|
||||
|
||||
private void DrawProfileContent()
|
||||
{
|
||||
_uiSharedService.BigText("Current Profile (as saved on server)");
|
||||
ImGuiHelpers.ScaledDummy(new Vector2(0f, ImGui.GetStyle().ItemSpacing.Y / 2));
|
||||
|
||||
var profile = _mareProfileManager.GetMareProfile(new UserData(_apiController.UID));
|
||||
|
||||
if (profile.IsFlagged)
|
||||
{
|
||||
UiSharedService.ColorTextWrapped(profile.Description, ImGuiColors.DalamudRed);
|
||||
UiSharedService.ColorTextWrapped(profile.Description, UiSharedService.AccentColor);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -89,13 +96,12 @@ public class EditProfileUi : WindowMediatorSubscriberBase
|
||||
_descriptionText = _profileDescription;
|
||||
}
|
||||
|
||||
var spacing = ImGui.GetStyle().ItemSpacing.X;
|
||||
if (_pfpTextureWrap != null)
|
||||
{
|
||||
ImGui.Image(_pfpTextureWrap.Handle, ImGuiHelpers.ScaledVector2(_pfpTextureWrap.Width, _pfpTextureWrap.Height));
|
||||
}
|
||||
|
||||
var spacing = ImGui.GetStyle().ItemSpacing.X;
|
||||
ImGuiHelpers.ScaledRelativeSameLine(256, spacing);
|
||||
}
|
||||
using (_uiSharedService.GameFont.Push())
|
||||
{
|
||||
var descriptionTextSize = ImGui.CalcTextSize(profile.Description, hideTextAfterDoubleHash: false, 256f);
|
||||
@@ -127,9 +133,9 @@ public class EditProfileUi : WindowMediatorSubscriberBase
|
||||
ImGui.Separator();
|
||||
_uiSharedService.BigText("Profile Settings");
|
||||
|
||||
if (_uiSharedService.IconTextButton(FontAwesomeIcon.FileUpload, L("EditProfile.Button.UploadPicture", "Upload new profile picture")))
|
||||
if (_uiSharedService.IconTextButton(FontAwesomeIcon.FileUpload, "Upload new profile picture"))
|
||||
{
|
||||
_fileDialogManager.OpenFileDialog(L("EditProfile.Dialog.PictureTitle", "Select new Profile picture"), ".png", (success, file) =>
|
||||
_fileDialogManager.OpenFileDialog("Select new Profile picture", ".png", (success, file) =>
|
||||
{
|
||||
if (!success) return;
|
||||
_ = Task.Run(async () =>
|
||||
@@ -150,29 +156,29 @@ public class EditProfileUi : WindowMediatorSubscriberBase
|
||||
});
|
||||
});
|
||||
}
|
||||
UiSharedService.AttachToolTip(L("EditProfile.Tooltip.UploadPicture", "Select and upload a new profile picture"));
|
||||
UiSharedService.AttachToolTip("Select and upload a new profile picture");
|
||||
ImGui.SameLine();
|
||||
if (_uiSharedService.IconTextButton(FontAwesomeIcon.Trash, L("EditProfile.Button.ClearPicture", "Clear uploaded profile picture")))
|
||||
if (_uiSharedService.IconTextButton(FontAwesomeIcon.Trash, "Clear uploaded profile picture"))
|
||||
{
|
||||
_ = _apiController.UserSetProfile(new UserProfileDto(new UserData(_apiController.UID), Disabled: false, IsNSFW: null, "", Description: null));
|
||||
}
|
||||
UiSharedService.AttachToolTip(L("EditProfile.Tooltip.ClearPicture", "Clear your currently uploaded profile picture"));
|
||||
UiSharedService.AttachToolTip("Clear your currently uploaded profile picture");
|
||||
if (_showFileDialogError)
|
||||
{
|
||||
UiSharedService.ColorTextWrapped(L("EditProfile.Error.PictureTooLarge", "The profile picture must be a PNG file with a maximum height and width of 256px and 250KiB size"), ImGuiColors.DalamudRed);
|
||||
UiSharedService.ColorTextWrapped("The profile picture must be a PNG file with a maximum height and width of 256px and 250KiB size", UiSharedService.AccentColor);
|
||||
}
|
||||
var isNsfw = profile.IsNSFW;
|
||||
if (ImGui.Checkbox(L("EditProfile.Checkbox.Nsfw", "Profile is NSFW"), ref isNsfw))
|
||||
if (ImGui.Checkbox("Profile is NSFW", ref isNsfw))
|
||||
{
|
||||
_ = _apiController.UserSetProfile(new UserProfileDto(new UserData(_apiController.UID), Disabled: false, isNsfw, ProfilePictureBase64: null, Description: null));
|
||||
}
|
||||
_uiSharedService.DrawHelpText(L("EditProfile.Help.Nsfw", "If your profile description or image can be considered NSFW, toggle this to ON"));
|
||||
_uiSharedService.DrawHelpText("If your profile description or image can be considered NSFW, toggle this to ON");
|
||||
var widthTextBox = 400;
|
||||
var posX = ImGui.GetCursorPosX();
|
||||
ImGui.TextUnformatted(L("EditProfile.DescriptionCounter", "Description {0}/1500", _descriptionText.Length));
|
||||
ImGui.TextUnformatted($"Description {_descriptionText.Length}/1500");
|
||||
ImGui.SetCursorPosX(posX);
|
||||
ImGuiHelpers.ScaledRelativeSameLine(widthTextBox, ImGui.GetStyle().ItemSpacing.X);
|
||||
ImGui.TextUnformatted(L("EditProfile.PreviewLabel", "Preview (approximate)"));
|
||||
ImGui.TextUnformatted("Preview (approximate)");
|
||||
using (_uiSharedService.GameFont.Push())
|
||||
ImGui.InputTextMultiline("##description", ref _descriptionText, 1500, ImGuiHelpers.ScaledVector2(widthTextBox, 200));
|
||||
|
||||
@@ -201,17 +207,17 @@ public class EditProfileUi : WindowMediatorSubscriberBase
|
||||
ImGui.EndChildFrame();
|
||||
}
|
||||
|
||||
if (_uiSharedService.IconTextButton(FontAwesomeIcon.Save, L("EditProfile.Button.SaveDescription", "Save Description")))
|
||||
if (_uiSharedService.IconTextButton(FontAwesomeIcon.Save, "Save Description"))
|
||||
{
|
||||
_ = _apiController.UserSetProfile(new UserProfileDto(new UserData(_apiController.UID), Disabled: false, IsNSFW: null, ProfilePictureBase64: null, _descriptionText));
|
||||
}
|
||||
UiSharedService.AttachToolTip(L("EditProfile.Tooltip.SaveDescription", "Sets your profile description text"));
|
||||
UiSharedService.AttachToolTip("Sets your profile description text");
|
||||
ImGui.SameLine();
|
||||
if (_uiSharedService.IconTextButton(FontAwesomeIcon.Trash, L("EditProfile.Button.ClearDescription", "Clear Description")))
|
||||
if (_uiSharedService.IconTextButton(FontAwesomeIcon.Trash, "Clear Description"))
|
||||
{
|
||||
_ = _apiController.UserSetProfile(new UserProfileDto(new UserData(_apiController.UID), Disabled: false, IsNSFW: null, ProfilePictureBase64: null, ""));
|
||||
}
|
||||
UiSharedService.AttachToolTip(L("EditProfile.Tooltip.ClearDescription", "Clears your profile description text"));
|
||||
UiSharedService.AttachToolTip("Clears your profile description text");
|
||||
}
|
||||
|
||||
protected override void Dispose(bool disposing)
|
||||
|
||||
@@ -40,7 +40,7 @@ internal class EventViewerUI : WindowMediatorSubscriberBase
|
||||
public EventViewerUI(ILogger<EventViewerUI> logger, MareMediator mediator,
|
||||
EventAggregator eventAggregator, UiSharedService uiSharedService, MareConfigService configService,
|
||||
PerformanceCollectorService performanceCollectorService)
|
||||
: base(logger, mediator, uiSharedService.Localize("EventViewer.WindowTitle", "Event Viewer"), performanceCollectorService)
|
||||
: base(logger, mediator, "Event Viewer", performanceCollectorService)
|
||||
{
|
||||
_eventAggregator = eventAggregator;
|
||||
_uiSharedService = uiSharedService;
|
||||
@@ -52,8 +52,6 @@ internal class EventViewerUI : WindowMediatorSubscriberBase
|
||||
_filteredEvents = RecreateFilter();
|
||||
}
|
||||
|
||||
private string L(string key, string fallback, params object[] args) => _uiSharedService.Localize(key, fallback, args);
|
||||
|
||||
private Lazy<List<Event>> RecreateFilter()
|
||||
{
|
||||
return new(() =>
|
||||
@@ -83,22 +81,20 @@ internal class EventViewerUI : WindowMediatorSubscriberBase
|
||||
{
|
||||
var newEventsAvailable = _eventAggregator.NewEventsAvailable;
|
||||
|
||||
var unfreezeLabel = L("EventViewer.Button.Unfreeze", "Unfreeze View");
|
||||
var freezeLabel = L("EventViewer.Button.Freeze", "Freeze View");
|
||||
var freezeSize = _uiSharedService.GetIconTextButtonSize(FontAwesomeIcon.PlayCircle, unfreezeLabel);
|
||||
var freezeSize = _uiSharedService.GetIconTextButtonSize(FontAwesomeIcon.PlayCircle, "Unfreeze View");
|
||||
if (_isPaused)
|
||||
{
|
||||
using (ImRaii.PushColor(ImGuiCol.Text, ImGuiColors.DalamudYellow, newEventsAvailable))
|
||||
{
|
||||
if (_uiSharedService.IconTextButton(FontAwesomeIcon.PlayCircle, unfreezeLabel))
|
||||
if (_uiSharedService.IconTextButton(FontAwesomeIcon.PlayCircle, "Unfreeze View"))
|
||||
_isPaused = false;
|
||||
if (newEventsAvailable)
|
||||
UiSharedService.AttachToolTip(L("EventViewer.Tooltip.NewEvents", "New events are available. Click to resume updating."));
|
||||
UiSharedService.AttachToolTip("New events are available. Click to resume updating.");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (_uiSharedService.IconTextButton(FontAwesomeIcon.PauseCircle, freezeLabel))
|
||||
if (_uiSharedService.IconTextButton(FontAwesomeIcon.PauseCircle, "Freeze View"))
|
||||
_isPaused = true;
|
||||
}
|
||||
|
||||
@@ -109,7 +105,7 @@ internal class EventViewerUI : WindowMediatorSubscriberBase
|
||||
|
||||
bool changedFilter = false;
|
||||
ImGui.SetNextItemWidth(200);
|
||||
changedFilter |= ImGui.InputText(L("EventViewer.FilterLabel", "Filter lines"), ref _filterFreeText, 50);
|
||||
changedFilter |= ImGui.InputText("Filter lines", ref _filterFreeText, 50);
|
||||
if (changedFilter) _filteredEvents = RecreateFilter();
|
||||
|
||||
using (ImRaii.Disabled(_filterFreeText.IsNullOrEmpty()))
|
||||
@@ -124,11 +120,10 @@ internal class EventViewerUI : WindowMediatorSubscriberBase
|
||||
|
||||
if (_configService.Current.LogEvents)
|
||||
{
|
||||
var openLogLabel = L("EventViewer.Button.OpenLog", "Open EventLog folder");
|
||||
var buttonSize = _uiSharedService.GetIconTextButtonSize(FontAwesomeIcon.FolderOpen, openLogLabel);
|
||||
var buttonSize = _uiSharedService.GetIconTextButtonSize(FontAwesomeIcon.FolderOpen, "Open EventLog Folder");
|
||||
var dist = ImGui.GetWindowContentRegionMax().X - buttonSize;
|
||||
ImGui.SameLine(dist);
|
||||
if (_uiSharedService.IconTextButton(FontAwesomeIcon.FolderOpen, openLogLabel))
|
||||
if (_uiSharedService.IconTextButton(FontAwesomeIcon.FolderOpen, "Open EventLog folder"))
|
||||
{
|
||||
ProcessStartInfo ps = new()
|
||||
{
|
||||
@@ -157,11 +152,11 @@ internal class EventViewerUI : WindowMediatorSubscriberBase
|
||||
{
|
||||
ImGui.TableSetupScrollFreeze(0, 1);
|
||||
ImGui.TableSetupColumn(string.Empty, ImGuiTableColumnFlags.NoSort);
|
||||
ImGui.TableSetupColumn(L("EventViewer.Column.Time", "Time"), ImGuiTableColumnFlags.None, timeColWidth);
|
||||
ImGui.TableSetupColumn(L("EventViewer.Column.Source", "Source"), ImGuiTableColumnFlags.None, sourceColWidth);
|
||||
ImGui.TableSetupColumn(L("EventViewer.Column.Uid", "UID"), ImGuiTableColumnFlags.None, uidColWidth);
|
||||
ImGui.TableSetupColumn(L("EventViewer.Column.Character", "Character"), ImGuiTableColumnFlags.None, characterColWidth);
|
||||
ImGui.TableSetupColumn(L("EventViewer.Column.Event", "Event"), ImGuiTableColumnFlags.None);
|
||||
ImGui.TableSetupColumn("Time", ImGuiTableColumnFlags.None, timeColWidth);
|
||||
ImGui.TableSetupColumn("Source", ImGuiTableColumnFlags.None, sourceColWidth);
|
||||
ImGui.TableSetupColumn("UID", ImGuiTableColumnFlags.None, uidColWidth);
|
||||
ImGui.TableSetupColumn("Character", ImGuiTableColumnFlags.None, characterColWidth);
|
||||
ImGui.TableSetupColumn("Event", ImGuiTableColumnFlags.None);
|
||||
ImGui.TableHeadersRow();
|
||||
int i = 0;
|
||||
foreach (var ev in _filteredEvents.Value)
|
||||
@@ -180,13 +175,13 @@ internal class EventViewerUI : WindowMediatorSubscriberBase
|
||||
{
|
||||
EventSeverity.Informational => new Vector4(),
|
||||
EventSeverity.Warning => ImGuiColors.DalamudYellow,
|
||||
EventSeverity.Error => ImGuiColors.DalamudRed,
|
||||
EventSeverity.Error => UiSharedService.AccentColor,
|
||||
_ => new Vector4()
|
||||
};
|
||||
|
||||
ImGui.TableNextColumn();
|
||||
_uiSharedService.IconText(icon, iconColor == new Vector4() ? null : iconColor);
|
||||
UiSharedService.AttachToolTip(L($"EventViewer.Severity.{ev.EventSeverity}", ev.EventSeverity.ToString()));
|
||||
UiSharedService.AttachToolTip(ev.EventSeverity.ToString());
|
||||
ImGui.TableNextColumn();
|
||||
ImGui.AlignTextToFramePadding();
|
||||
ImGui.TextUnformatted(ev.EventTime.ToString("T", CultureInfo.CurrentCulture));
|
||||
@@ -205,7 +200,7 @@ internal class EventViewerUI : WindowMediatorSubscriberBase
|
||||
}
|
||||
else
|
||||
{
|
||||
ImGui.TextUnformatted(L("EventViewer.NoValue", "--"));
|
||||
ImGui.TextUnformatted("--");
|
||||
}
|
||||
ImGui.TableNextColumn();
|
||||
ImGui.AlignTextToFramePadding();
|
||||
@@ -219,7 +214,7 @@ internal class EventViewerUI : WindowMediatorSubscriberBase
|
||||
}
|
||||
else
|
||||
{
|
||||
ImGui.TextUnformatted(L("EventViewer.NoValue", "--"));
|
||||
ImGui.TextUnformatted("--");
|
||||
}
|
||||
ImGui.TableNextColumn();
|
||||
ImGui.AlignTextToFramePadding();
|
||||
|
||||
@@ -1,13 +1,11 @@
|
||||
using Dalamud.Bindings.ImGui;
|
||||
using Dalamud.Interface;
|
||||
using Dalamud.Interface.Utility.Raii;
|
||||
using MareSynchronos.Localization;
|
||||
using MareSynchronos.MareConfiguration;
|
||||
using MareSynchronos.PlayerData.Pairs;
|
||||
using MareSynchronos.Services.Mediator;
|
||||
using MareSynchronos.Services.ServerConfiguration;
|
||||
using MareSynchronos.UI.Components;
|
||||
using System.Globalization;
|
||||
|
||||
namespace MareSynchronos.UI.Handlers;
|
||||
|
||||
@@ -24,13 +22,6 @@ public class UidDisplayHandler
|
||||
private bool _popupShown = false;
|
||||
private DateTime? _popupTime;
|
||||
|
||||
private static string L(string key, string fallback, params object[] args)
|
||||
{
|
||||
var safeArgs = args ?? Array.Empty<object>();
|
||||
return LocalizationService.Instance?.GetString(key, fallback, safeArgs)
|
||||
?? string.Format(CultureInfo.CurrentCulture, fallback, safeArgs);
|
||||
}
|
||||
|
||||
public UidDisplayHandler(MareMediator mediator, PairManager pairManager,
|
||||
ServerConfigurationManager serverManager, MareConfigService mareConfigService)
|
||||
{
|
||||
@@ -86,7 +77,21 @@ public class UidDisplayHandler
|
||||
|
||||
if (_popupTime > DateTime.UtcNow || !_mareConfigService.Current.ProfilesShow)
|
||||
{
|
||||
ImGui.SetTooltip(L("UidDisplay.Tooltip", "Left click to switch between UID display and nick\nRight click to change nick for {0}\nMiddle Mouse Button to open their profile in a separate window", pair.UserData.AliasOrUID));
|
||||
// Build tooltip; prepend last-seen when player is offline or not visible
|
||||
string tooltip = "Left click to switch between UID display and nick" + Environment.NewLine
|
||||
+ "Right click to change nick for " + pair.UserData.AliasOrUID + Environment.NewLine
|
||||
+ "Middle Mouse Button to open their profile in a separate window";
|
||||
|
||||
if (!pair.IsOnline || !pair.IsVisible)
|
||||
{
|
||||
var lastSeen = _serverManager.GetNameForUid(pair.UserData.UID);
|
||||
if (!string.IsNullOrEmpty(lastSeen))
|
||||
{
|
||||
tooltip = "Vu sous : " + lastSeen + Environment.NewLine + tooltip;
|
||||
}
|
||||
}
|
||||
|
||||
ImGui.SetTooltip(tooltip);
|
||||
}
|
||||
else if (_popupTime < DateTime.UtcNow && !_popupShown)
|
||||
{
|
||||
@@ -132,7 +137,7 @@ public class UidDisplayHandler
|
||||
ImGui.SetCursorPosY(originalY);
|
||||
|
||||
ImGui.SetNextItemWidth(editBoxWidth.Invoke());
|
||||
if (ImGui.InputTextWithHint("##" + pair.UserData.UID, L("UidDisplay.EditNotes.Hint", "Nick/Notes"), ref _editUserComment, 255, ImGuiInputTextFlags.EnterReturnsTrue))
|
||||
if (ImGui.InputTextWithHint("##" + pair.UserData.UID, "Nick/Notes", ref _editUserComment, 255, ImGuiInputTextFlags.EnterReturnsTrue))
|
||||
{
|
||||
_serverManager.SetNoteForUid(pair.UserData.UID, _editUserComment);
|
||||
_serverManager.SaveNotes();
|
||||
@@ -143,16 +148,21 @@ public class UidDisplayHandler
|
||||
{
|
||||
_editNickEntry = string.Empty;
|
||||
}
|
||||
UiSharedService.AttachToolTip(L("GroupPanel.CommentTooltip", "Hit ENTER to save\nRight click to cancel"));
|
||||
UiSharedService.AttachToolTip("Hit ENTER to save\nRight click to cancel");
|
||||
}
|
||||
}
|
||||
|
||||
public (bool isUid, string text) GetPlayerText(Pair pair)
|
||||
{
|
||||
var textIsUid = true;
|
||||
bool showUidInsteadOfName = ShowUidInsteadOfName(pair);
|
||||
if (showUidInsteadOfName)
|
||||
{
|
||||
return (true, pair.UserData.UID);
|
||||
}
|
||||
|
||||
var textIsUid = true;
|
||||
string? playerText = _serverManager.GetNoteForUid(pair.UserData.UID);
|
||||
if (!showUidInsteadOfName && playerText != null)
|
||||
if (playerText != null)
|
||||
{
|
||||
if (string.IsNullOrEmpty(playerText))
|
||||
{
|
||||
@@ -168,7 +178,7 @@ public class UidDisplayHandler
|
||||
playerText = pair.UserData.AliasOrUID;
|
||||
}
|
||||
|
||||
if (_mareConfigService.Current.ShowCharacterNames && textIsUid && !showUidInsteadOfName)
|
||||
if (_mareConfigService.Current.ShowCharacterNames && textIsUid && pair.IsOnline && pair.IsVisible)
|
||||
{
|
||||
var name = pair.PlayerName;
|
||||
if (name != null)
|
||||
@@ -204,8 +214,11 @@ public class UidDisplayHandler
|
||||
|
||||
private bool ShowUidInsteadOfName(Pair pair)
|
||||
{
|
||||
_showUidForEntry.TryGetValue(pair.UserData.UID, out var showUidInsteadOfName);
|
||||
|
||||
if (_showUidForEntry.TryGetValue(pair.UserData.UID, out var showUidInsteadOfName))
|
||||
{
|
||||
return showUidInsteadOfName;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,7 +5,6 @@ using Dalamud.Interface.Utility.Raii;
|
||||
using Dalamud.Utility;
|
||||
using MareSynchronos.API.Dto.Account;
|
||||
using MareSynchronos.FileCache;
|
||||
using MareSynchronos.Localization;
|
||||
using MareSynchronos.MareConfiguration;
|
||||
using MareSynchronos.MareConfiguration.Models;
|
||||
using MareSynchronos.Services;
|
||||
@@ -37,8 +36,6 @@ public partial class IntroUi : WindowMediatorSubscriberBase
|
||||
private string? _registrationMessage;
|
||||
private RegisterReplyDto? _registrationReply;
|
||||
|
||||
private string L(string key, string fallback, params object[] args) => _uiShared.Localize(key, fallback, args);
|
||||
|
||||
public IntroUi(ILogger<IntroUi> logger, UiSharedService uiShared, MareConfigService configService,
|
||||
CacheMonitor fileCacheManager, ServerConfigurationManager serverConfigurationManager, MareMediator mareMediator,
|
||||
PerformanceCollectorService performanceCollectorService, DalamudUtilService dalamudUtilService, AccountRegistrationService registerService) : base(logger, mareMediator, "Umbra Setup", performanceCollectorService)
|
||||
@@ -72,17 +69,17 @@ public partial class IntroUi : WindowMediatorSubscriberBase
|
||||
return _uiShared.ApiController.ServerState switch
|
||||
{
|
||||
ServerState.Connecting => ImGuiColors.DalamudYellow,
|
||||
ServerState.Reconnecting => ImGuiColors.DalamudRed,
|
||||
ServerState.Reconnecting => UiSharedService.AccentColor,
|
||||
ServerState.Connected => ImGuiColors.HealerGreen,
|
||||
ServerState.Disconnected => ImGuiColors.DalamudYellow,
|
||||
ServerState.Disconnecting => ImGuiColors.DalamudYellow,
|
||||
ServerState.Unauthorized => ImGuiColors.DalamudRed,
|
||||
ServerState.VersionMisMatch => ImGuiColors.DalamudRed,
|
||||
ServerState.Offline => ImGuiColors.DalamudRed,
|
||||
ServerState.Unauthorized => UiSharedService.AccentColor,
|
||||
ServerState.VersionMisMatch => UiSharedService.AccentColor,
|
||||
ServerState.Offline => UiSharedService.AccentColor,
|
||||
ServerState.RateLimited => ImGuiColors.DalamudYellow,
|
||||
ServerState.NoSecretKey => ImGuiColors.DalamudYellow,
|
||||
ServerState.MultiChara => ImGuiColors.DalamudYellow,
|
||||
_ => ImGuiColors.DalamudRed
|
||||
_ => UiSharedService.AccentColor
|
||||
};
|
||||
}
|
||||
|
||||
@@ -90,17 +87,17 @@ public partial class IntroUi : WindowMediatorSubscriberBase
|
||||
{
|
||||
return _uiShared.ApiController.ServerState switch
|
||||
{
|
||||
ServerState.Reconnecting => L("Compact.UidText.Reconnecting", "Reconnecting"),
|
||||
ServerState.Connecting => L("Compact.UidText.Connecting", "Connecting"),
|
||||
ServerState.Disconnected => L("Compact.UidText.Disconnected", "Disconnected"),
|
||||
ServerState.Disconnecting => L("Compact.UidText.Disconnecting", "Disconnecting"),
|
||||
ServerState.Unauthorized => L("Compact.UidText.Unauthorized", "Unauthorized"),
|
||||
ServerState.VersionMisMatch => L("Compact.UidText.VersionMismatch", "Version mismatch"),
|
||||
ServerState.Offline => L("Compact.UidText.Offline", "Unavailable"),
|
||||
ServerState.RateLimited => L("Compact.UidText.RateLimited", "Rate Limited"),
|
||||
ServerState.NoSecretKey => L("Compact.UidText.NoSecretKey", "No Secret Key"),
|
||||
ServerState.MultiChara => L("Compact.UidText.MultiChara", "Duplicate Characters"),
|
||||
ServerState.Connected => L("Intro.ConnectionStatus.Connected", "Connected"),
|
||||
ServerState.Reconnecting => "Reconnecting",
|
||||
ServerState.Connecting => "Connecting",
|
||||
ServerState.Disconnected => "Disconnected",
|
||||
ServerState.Disconnecting => "Disconnecting",
|
||||
ServerState.Unauthorized => "Unauthorized",
|
||||
ServerState.VersionMisMatch => "Version mismatch",
|
||||
ServerState.Offline => "Unavailable",
|
||||
ServerState.RateLimited => "Rate Limited",
|
||||
ServerState.NoSecretKey => "No Secret Key",
|
||||
ServerState.MultiChara => "Duplicate Characters",
|
||||
ServerState.Connected => "Connected",
|
||||
_ => string.Empty
|
||||
};
|
||||
}
|
||||
@@ -111,15 +108,18 @@ public partial class IntroUi : WindowMediatorSubscriberBase
|
||||
|
||||
if (!_configService.Current.AcceptedAgreement && !_readFirstPage)
|
||||
{
|
||||
_uiShared.BigText(L("Intro.Welcome.Title", "Welcome to Umbra"));
|
||||
_uiShared.BigText("Welcome to Umbra");
|
||||
ImGui.Separator();
|
||||
UiSharedService.TextWrapped(L("Intro.Welcome.Paragraph1", "Umbra is a plugin that will replicate your full current character state including all Penumbra mods to other paired users. Note that you will have to have Penumbra as well as Glamourer installed to use this plugin."));
|
||||
UiSharedService.TextWrapped(L("Intro.Welcome.Paragraph2", "We will have to setup a few things first before you can start using this plugin. Click on next to continue."));
|
||||
UiSharedService.TextWrapped("Umbra is a plugin that will replicate your full current character state including all Penumbra mods to other paired users. " +
|
||||
"Note that you will have to have Penumbra as well as Glamourer installed to use this plugin.");
|
||||
UiSharedService.TextWrapped("We will have to setup a few things first before you can start using this plugin. Click on next to continue.");
|
||||
|
||||
UiSharedService.ColorTextWrapped(L("Intro.Welcome.Note", "Note: Any modifications you have applied through anything but Penumbra cannot be shared and your character state on other clients might look broken because of this or others players mods might not apply on your end altogether. If you want to use this plugin you will have to move your mods to Penumbra."), ImGuiColors.DalamudYellow);
|
||||
UiSharedService.ColorTextWrapped("Note: Any modifications you have applied through anything but Penumbra cannot be shared and your character state on other clients " +
|
||||
"might look broken because of this or others players mods might not apply on your end altogether. " +
|
||||
"If you want to use this plugin you will have to move your mods to Penumbra.", ImGuiColors.DalamudYellow);
|
||||
if (!_uiShared.DrawOtherPluginState(intro: true)) return;
|
||||
ImGui.Separator();
|
||||
if (ImGui.Button(L("Intro.Welcome.Next", "Next") + "##toAgreement"))
|
||||
if (ImGui.Button("Next##toAgreement"))
|
||||
{
|
||||
_readFirstPage = true;
|
||||
#if !DEBUG
|
||||
@@ -127,7 +127,7 @@ public partial class IntroUi : WindowMediatorSubscriberBase
|
||||
{
|
||||
for (int i = 10; i > 0; i--)
|
||||
{
|
||||
_timeoutLabel = L("Intro.Agreement.Timeout", "'I agree' button will be available in {0}s", i);
|
||||
_timeoutLabel = $"'I agree' button will be available in {i}s";
|
||||
await Task.Delay(TimeSpan.FromSeconds(1)).ConfigureAwait(false);
|
||||
}
|
||||
});
|
||||
@@ -140,40 +140,52 @@ public partial class IntroUi : WindowMediatorSubscriberBase
|
||||
{
|
||||
using (_uiShared.UidFont.Push())
|
||||
{
|
||||
ImGui.TextUnformatted(L("Intro.Agreement.Title", "Agreement of Usage of Service"));
|
||||
ImGui.TextUnformatted("Conditions d'utilisation");
|
||||
}
|
||||
|
||||
ImGui.Separator();
|
||||
ImGui.SetWindowFontScale(1.5f);
|
||||
string readThis = L("Intro.Agreement.Callout", "READ THIS CAREFULLY");
|
||||
UiSharedService.SetFontScale(1.5f);
|
||||
string readThis = "MERCI DE LIRE ATTENTIVEMENT";
|
||||
Vector2 textSize = ImGui.CalcTextSize(readThis);
|
||||
ImGui.SetCursorPosX(ImGui.GetWindowSize().X / 2 - textSize.X / 2);
|
||||
UiSharedService.ColorText(readThis, ImGuiColors.DalamudRed);
|
||||
ImGui.SetWindowFontScale(1.0f);
|
||||
UiSharedService.ColorText(readThis, UiSharedService.AccentColor);
|
||||
UiSharedService.SetFontScale(1.0f);
|
||||
ImGui.Separator();
|
||||
var agreementParagraphs = new[]
|
||||
{
|
||||
L("Intro.Agreement.Paragraph1", "To use Umbra, you must be over the age of 18, or 21 in some jurisdictions."),
|
||||
L("Intro.Agreement.Paragraph2", "All of the mod files currently active on your character as well as your current character state will be uploaded to the service you registered yourself at automatically. The plugin will exclusively upload the necessary mod files and not the whole mod."),
|
||||
L("Intro.Agreement.Paragraph3", "If you are on a data capped internet connection, higher fees due to data usage depending on the amount of downloaded and uploaded mod files might occur. Mod files will be compressed on up- and download to save on bandwidth usage. Due to varying up- and download speeds, changes in characters might not be visible immediately. Files present on the service that already represent your active mod files will not be uploaded again."),
|
||||
L("Intro.Agreement.Paragraph4", "The mod files you are uploading are confidential and will not be distributed to parties other than the ones who are requesting the exact same mod files. Please think about who you are going to pair since it is unavoidable that they will receive and locally cache the necessary mod files that you have currently in use. Locally cached mod files will have arbitrary file names to discourage attempts at replicating the original mod."),
|
||||
L("Intro.Agreement.Paragraph5", "The plugin creator tried their best to keep you secure. However, there is no guarantee for 100% security. Do not blindly pair your client with everyone."),
|
||||
L("Intro.Agreement.Paragraph6", "Mod files that are saved on the service will remain on the service as long as there are requests for the files from clients. After a period of not being used, the mod files will be automatically deleted."),
|
||||
L("Intro.Agreement.Paragraph7", "Accounts that are inactive for ninety (90) days will be deleted for privacy reasons."),
|
||||
L("Intro.Agreement.Paragraph8", "Umbra is operated from servers located in the European Union. You agree not to upload any content to the service that violates EU law; and more specifically, German law."),
|
||||
L("Intro.Agreement.Paragraph9", "You may delete your account at any time from within the Settings panel of the plugin. Any mods unique to you will then be removed from the server within 14 days."),
|
||||
L("Intro.Agreement.Paragraph10", "This service is provided as-is."),
|
||||
};
|
||||
|
||||
foreach (var paragraph in agreementParagraphs)
|
||||
{
|
||||
UiSharedService.TextWrapped(paragraph);
|
||||
}
|
||||
UiSharedService.TextWrapped("""
|
||||
Pour utiliser les services UmbraSync, vous devez être âgé de plus de 18 ans, où plus de 21 ans dans certaines juridictions.
|
||||
""");
|
||||
UiSharedService.TextWrapped("""
|
||||
Tout les mods actuellement actifs sur votre personnage et ses états associés seront automatiquement téléchargés vers le serveur UmbraSync auquel vous vous êtes inscrit.Il sera téléchargé exclusivement les fichiers nécessaires à la synchronisation et non l'intégralité du mod.
|
||||
""");
|
||||
UiSharedService.TextWrapped("""
|
||||
Si vous disposez d'une connexion Internet limitée, des frais supplémentaires peuvent s'appliquer en fonction du nombre de fichiers envoyés et reçus. Les fichiers seront compressés afin d'économiser la bande passante. En raison des variations de vitesse de débit, les sychronisations peuvent ne pas être visible immédiatement.
|
||||
""");
|
||||
UiSharedService.TextWrapped("""
|
||||
Les fichiers téléchargés sont confidentiels et ne seront pas distribués à des solutions tierces où autres personnes. Uniquement les personnes avec qui vous êtes appairés demandent exactement les mêmes fichiers. Réfléchissez donc bien avec qui vous allez vous appairer.
|
||||
""");
|
||||
UiSharedService.TextWrapped("""
|
||||
Le gentil dev' a fait de son mieux pour assurer votre sécurité. Cependant le risque 0 n'existe pas. Ne vous appairez pas aveuglément avec n'importe qui.
|
||||
""");
|
||||
UiSharedService.TextWrapped("""
|
||||
Après une periode d'inactivité, les mods enregistrés sur le serveur UmbraSync seront automatiquement supprimés.
|
||||
""");
|
||||
UiSharedService.TextWrapped("""
|
||||
Les comptes inactifs pendant 90 jours seront supprimés pour des raisons de stockage et de confidentialité.
|
||||
""");
|
||||
UiSharedService.TextWrapped("""
|
||||
L'infrastructure Umbrasync est hebergé dans l'Union Européenne (Allemagne) et en Suisse. Vous acceptez alors de ne pas télécharger de contenu qui pourrait aller à l'encontre des législations de ces deux pays.
|
||||
""");
|
||||
UiSharedService.TextWrapped("""
|
||||
Vous pouvez supprimer votre compte à tout moment. Votre compte et toutes les données associées seront supprimés dans un délai de 14 jours.
|
||||
""");
|
||||
UiSharedService.TextWrapped("""
|
||||
Ce service est fourni tel quel.
|
||||
""");
|
||||
|
||||
ImGui.Separator();
|
||||
if (_timeoutTask?.IsCompleted ?? true)
|
||||
{
|
||||
if (ImGui.Button(L("Intro.Agreement.Accept", "I agree") + "##toSetup"))
|
||||
if (ImGui.Button("I agree##toSetup"))
|
||||
{
|
||||
_configService.Current.AcceptedAgreement = true;
|
||||
_configService.Save();
|
||||
@@ -190,26 +202,29 @@ public partial class IntroUi : WindowMediatorSubscriberBase
|
||||
|| !Directory.Exists(_configService.Current.CacheFolder)))
|
||||
{
|
||||
using (_uiShared.UidFont.Push())
|
||||
ImGui.TextUnformatted(L("Intro.Storage.Title", "File Storage Setup"));
|
||||
ImGui.TextUnformatted("File Storage Setup");
|
||||
|
||||
ImGui.Separator();
|
||||
|
||||
if (!_uiShared.HasValidPenumbraModPath)
|
||||
{
|
||||
UiSharedService.ColorTextWrapped(L("Intro.Storage.NoPenumbra", "You do not have a valid Penumbra path set. Open Penumbra and set up a valid path for the mod directory."), ImGuiColors.DalamudRed);
|
||||
UiSharedService.ColorTextWrapped("You do not have a valid Penumbra path set. Open Penumbra and set up a valid path for the mod directory.", UiSharedService.AccentColor);
|
||||
}
|
||||
else
|
||||
{
|
||||
UiSharedService.TextWrapped(L("Intro.Storage.Description", "To not unnecessarily download files already present on your computer, Umbra will have to scan your Penumbra mod directory. Additionally, a local storage folder must be set where Umbra will download other character files to. Once the storage folder is set and the scan complete, this page will automatically forward to registration at a service."));
|
||||
UiSharedService.TextWrapped(L("Intro.Storage.ScanNote", "Note: The initial scan, depending on the amount of mods you have, might take a while. Please wait until it is completed."));
|
||||
UiSharedService.ColorTextWrapped(L("Intro.Storage.Warning.FileCache", "Warning: once past this step you should not delete the FileCache.csv of Umbra in the Plugin Configurations folder of Dalamud. Otherwise on the next launch a full re-scan of the file cache database will be initiated."), ImGuiColors.DalamudYellow);
|
||||
UiSharedService.ColorTextWrapped(L("Intro.Storage.Warning.ScanHang", "Warning: if the scan is hanging and does nothing for a long time, chances are high your Penumbra folder is not set up properly."), ImGuiColors.DalamudYellow);
|
||||
UiSharedService.TextWrapped("To not unnecessary download files already present on your computer, Umbra will have to scan your Penumbra mod directory. " +
|
||||
"Additionally, a local storage folder must be set where Umbra will download other character files to. " +
|
||||
"Once the storage folder is set and the scan complete, this page will automatically forward to registration at a service.");
|
||||
UiSharedService.TextWrapped("Note: The initial scan, depending on the amount of mods you have, might take a while. Please wait until it is completed.");
|
||||
UiSharedService.ColorTextWrapped("Warning: once past this step you should not delete the FileCache.csv of Umbra in the Plugin Configurations folder of Dalamud. " +
|
||||
"Otherwise on the next launch a full re-scan of the file cache database will be initiated.", ImGuiColors.DalamudYellow);
|
||||
UiSharedService.ColorTextWrapped("Warning: if the scan is hanging and does nothing for a long time, chances are high your Penumbra folder is not set up properly.", ImGuiColors.DalamudYellow);
|
||||
_uiShared.DrawCacheDirectorySetting();
|
||||
}
|
||||
|
||||
if (!_cacheMonitor.IsScanRunning && !string.IsNullOrEmpty(_configService.Current.CacheFolder) && _uiShared.HasValidPenumbraModPath && Directory.Exists(_configService.Current.CacheFolder))
|
||||
{
|
||||
if (ImGui.Button(L("Intro.Storage.StartScan", "Start Scan") + "##startScan"))
|
||||
if (ImGui.Button("Start Scan##startScan"))
|
||||
{
|
||||
_cacheMonitor.InvokeScan();
|
||||
}
|
||||
@@ -221,21 +236,22 @@ public partial class IntroUi : WindowMediatorSubscriberBase
|
||||
if (!_dalamudUtilService.IsWine)
|
||||
{
|
||||
var useFileCompactor = _configService.Current.UseCompactor;
|
||||
if (ImGui.Checkbox(L("Intro.Storage.UseCompactor", "Use File Compactor"), ref useFileCompactor))
|
||||
if (ImGui.Checkbox("Use File Compactor", ref useFileCompactor))
|
||||
{
|
||||
_configService.Current.UseCompactor = useFileCompactor;
|
||||
_configService.Save();
|
||||
}
|
||||
UiSharedService.ColorTextWrapped(L("Intro.Storage.CompactorDescription", "The File Compactor can save a tremendous amount of space on the hard disk for downloads through Umbra. It will incur a minor CPU penalty on download but can speed up loading of other characters. It is recommended to keep it enabled. You can change this setting later anytime in the Umbra settings."), ImGuiColors.DalamudYellow);
|
||||
UiSharedService.ColorTextWrapped("The File Compactor can save a tremendeous amount of space on the hard disk for downloads through Umbra. It will incur a minor CPU penalty on download but can speed up " +
|
||||
"loading of other characters. It is recommended to keep it enabled. You can change this setting later anytime in the Umbra settings.", ImGuiColors.DalamudYellow);
|
||||
}
|
||||
}
|
||||
else if (!_uiShared.ApiController.IsConnected)
|
||||
{
|
||||
using (_uiShared.UidFont.Push())
|
||||
ImGui.TextUnformatted(L("Intro.Registration.Title", "Service Registration"));
|
||||
ImGui.TextUnformatted("Service Registration");
|
||||
ImGui.Separator();
|
||||
UiSharedService.TextWrapped(L("Intro.Registration.Description", "To be able to use Umbra you will have to register an account."));
|
||||
UiSharedService.TextWrapped(L("Intro.Registration.Support", "Refer to the instructions at the location you obtained this plugin for more information or support."));
|
||||
UiSharedService.TextWrapped("To be able to use Umbra you will have to register an account.");
|
||||
UiSharedService.TextWrapped("Refer to the instructions at the location you obtained this plugin for more information or support.");
|
||||
|
||||
ImGui.Separator();
|
||||
|
||||
@@ -246,8 +262,8 @@ public partial class IntroUi : WindowMediatorSubscriberBase
|
||||
{
|
||||
ImGui.BeginDisabled(_registrationInProgress || _registrationSuccess || _secretKey.Length > 0);
|
||||
ImGui.Separator();
|
||||
ImGui.TextUnformatted(L("Intro.Registration.NewAccountInfo", "If you have not used Umbra before, click below to register a new account."));
|
||||
if (_uiShared.IconTextButton(FontAwesomeIcon.Plus, L("Intro.Registration.RegisterButton", "Register a new Umbra account")))
|
||||
ImGui.TextUnformatted("If you have not used Umbra before, click below to register a new account.");
|
||||
if (_uiShared.IconTextButton(FontAwesomeIcon.Plus, "Register a new Umbra account"))
|
||||
{
|
||||
_registrationInProgress = true;
|
||||
_ = Task.Run(async () => {
|
||||
@@ -257,12 +273,12 @@ public partial class IntroUi : WindowMediatorSubscriberBase
|
||||
if (!reply.Success)
|
||||
{
|
||||
_logger.LogWarning("Registration failed: {err}", reply.ErrorMessage);
|
||||
_registrationMessage = string.IsNullOrEmpty(reply.ErrorMessage)
|
||||
? L("Intro.Registration.UnknownError", "An unknown error occured. Please try again later.")
|
||||
: reply.ErrorMessage;
|
||||
_registrationMessage = reply.ErrorMessage;
|
||||
if (_registrationMessage.IsNullOrEmpty())
|
||||
_registrationMessage = "An unknown error occured. Please try again later.";
|
||||
return;
|
||||
}
|
||||
_registrationMessage = L("Intro.Registration.Success", "New account registered.\nPlease keep a copy of your secret key in case you need to reset your plugins, or to use it on another PC.");
|
||||
_registrationMessage = "New account registered.\nPlease keep a copy of your secret key in case you need to reset your plugins, or to use it on another PC.";
|
||||
_secretKey = reply.SecretKey ?? "";
|
||||
_registrationReply = reply;
|
||||
_registrationSuccess = true;
|
||||
@@ -271,7 +287,7 @@ public partial class IntroUi : WindowMediatorSubscriberBase
|
||||
{
|
||||
_logger.LogWarning(ex, "Registration failed");
|
||||
_registrationSuccess = false;
|
||||
_registrationMessage = L("Intro.Registration.UnknownError", "An unknown error occured. Please try again later.");
|
||||
_registrationMessage = "An unknown error occured. Please try again later.";
|
||||
}
|
||||
finally
|
||||
{
|
||||
@@ -282,7 +298,7 @@ public partial class IntroUi : WindowMediatorSubscriberBase
|
||||
ImGui.EndDisabled(); // _registrationInProgress || _registrationSuccess
|
||||
if (_registrationInProgress)
|
||||
{
|
||||
ImGui.TextUnformatted(L("Intro.Registration.SendingRequest", "Sending request..."));
|
||||
ImGui.TextUnformatted("Sending request...");
|
||||
}
|
||||
else if (!_registrationMessage.IsNullOrEmpty())
|
||||
{
|
||||
@@ -295,40 +311,42 @@ public partial class IntroUi : WindowMediatorSubscriberBase
|
||||
|
||||
ImGui.Separator();
|
||||
|
||||
var secretKeyLabel = _registrationSuccess
|
||||
? L("Intro.Registration.SecretKeyLabelRegistered", "Secret Key")
|
||||
: L("Intro.Registration.SecretKeyLabel", "Enter Secret Key");
|
||||
var text = "Enter Secret Key";
|
||||
|
||||
if (!_registrationSuccess)
|
||||
if (_registrationSuccess)
|
||||
{
|
||||
ImGui.TextUnformatted(L("Intro.Registration.SecretKeyInstructions", "If you already have a registered account, you can enter its secret key below to use it instead."));
|
||||
text = "Secret Key";
|
||||
}
|
||||
else
|
||||
{
|
||||
ImGui.TextUnformatted("If you already have a registered account, you can enter its secret key below to use it instead.");
|
||||
}
|
||||
|
||||
var textSize = ImGui.CalcTextSize(secretKeyLabel);
|
||||
var textSize = ImGui.CalcTextSize(text);
|
||||
ImGui.AlignTextToFramePadding();
|
||||
ImGui.TextUnformatted(secretKeyLabel);
|
||||
ImGui.TextUnformatted(text);
|
||||
ImGui.SameLine();
|
||||
ImGui.SetNextItemWidth(UiSharedService.GetWindowContentRegionWidth() - ImGui.GetWindowContentRegionMin().X - textSize.X);
|
||||
ImGui.InputText("", ref _secretKey, 64);
|
||||
if (_secretKey.Length > 0 && _secretKey.Length != 64)
|
||||
{
|
||||
UiSharedService.ColorTextWrapped(L("Intro.Registration.SecretKeyLength", "Your secret key must be exactly 64 characters long."), ImGuiColors.DalamudRed);
|
||||
UiSharedService.ColorTextWrapped("Your secret key must be exactly 64 characters long.", UiSharedService.AccentColor);
|
||||
}
|
||||
else if (_secretKey.Length == 64 && !HexRegex().IsMatch(_secretKey))
|
||||
{
|
||||
UiSharedService.ColorTextWrapped(L("Intro.Registration.SecretKeyCharacters", "Your secret key can only contain ABCDEF and the numbers 0-9."), ImGuiColors.DalamudRed);
|
||||
UiSharedService.ColorTextWrapped("Your secret key can only contain ABCDEF and the numbers 0-9.", UiSharedService.AccentColor);
|
||||
}
|
||||
else if (_secretKey.Length == 64)
|
||||
{
|
||||
using var saveDisabled = ImRaii.Disabled(_uiShared.ApiController.ServerState == ServerState.Connecting || _uiShared.ApiController.ServerState == ServerState.Reconnecting);
|
||||
if (ImGui.Button(L("Intro.Registration.SaveAndConnect", "Save and Connect")))
|
||||
if (ImGui.Button("Save and Connect"))
|
||||
{
|
||||
string keyName;
|
||||
if (_serverConfigurationManager.CurrentServer == null) _serverConfigurationManager.SelectServer(0);
|
||||
if (_registrationReply != null && _secretKey.Equals(_registrationReply.SecretKey, StringComparison.Ordinal))
|
||||
keyName = _registrationReply.UID + " " + L("Intro.Registration.SavedKeyRegistered", "(registered {0})", DateTime.Now.ToString("yyyy-MM-dd"));
|
||||
keyName = _registrationReply.UID + $" (registered {DateTime.Now:yyyy-MM-dd})";
|
||||
else
|
||||
keyName = L("Intro.Registration.SavedKeySetup", "Secret Key added on Setup ({0})", DateTime.Now.ToString("yyyy-MM-dd"));
|
||||
keyName = $"Secret Key added on Setup ({DateTime.Now:yyyy-MM-dd})";
|
||||
_serverConfigurationManager.CurrentServer!.SecretKeys.Add(_serverConfigurationManager.CurrentServer.SecretKeys.Select(k => k.Key).LastOrDefault() + 1, new SecretKey()
|
||||
{
|
||||
FriendlyName = keyName,
|
||||
|
||||
@@ -22,9 +22,7 @@ public class PermissionWindowUI : WindowMediatorSubscriberBase
|
||||
|
||||
public PermissionWindowUI(ILogger<PermissionWindowUI> logger, Pair pair, MareMediator mediator, UiSharedService uiSharedService,
|
||||
ApiController apiController, PerformanceCollectorService performanceCollectorService)
|
||||
: base(logger, mediator,
|
||||
uiSharedService.Localize("PermissionWindow.Title", "Permissions for {0}", pair.UserData.AliasOrUID) + "###UmbraSyncPermissions" + pair.UserData.UID,
|
||||
performanceCollectorService)
|
||||
: base(logger, mediator, "Permissions for " + pair.UserData.AliasOrUID + "###UmbraSyncPermissions" + pair.UserData.UID, performanceCollectorService)
|
||||
{
|
||||
Pair = pair;
|
||||
_uiSharedService = uiSharedService;
|
||||
@@ -39,8 +37,6 @@ public class PermissionWindowUI : WindowMediatorSubscriberBase
|
||||
IsOpen = true;
|
||||
}
|
||||
|
||||
private string L(string key, string fallback, params object[] args) => _uiSharedService.Localize(key, fallback, args);
|
||||
|
||||
protected override void DrawInternal()
|
||||
{
|
||||
var paused = _ownPermissions.IsPaused();
|
||||
@@ -50,19 +46,18 @@ public class PermissionWindowUI : WindowMediatorSubscriberBase
|
||||
var style = ImGui.GetStyle();
|
||||
var indentSize = ImGui.GetFrameHeight() + style.ItemSpacing.X;
|
||||
|
||||
_uiSharedService.BigText(L("PermissionWindow.Title", "Permissions for {0}", Pair.UserData.AliasOrUID));
|
||||
_uiSharedService.BigText("Permissions for " + Pair.UserData.AliasOrUID);
|
||||
ImGuiHelpers.ScaledDummy(1f);
|
||||
|
||||
if (Pair.UserPair == null)
|
||||
return;
|
||||
|
||||
if (ImGui.Checkbox(L("PermissionWindow.Pause.Label", "Pause Sync"), ref paused))
|
||||
if (ImGui.Checkbox("Pause Sync", ref paused))
|
||||
{
|
||||
_ownPermissions.SetPaused(paused);
|
||||
}
|
||||
_uiSharedService.DrawHelpText(L("PermissionWindow.Pause.HelpMain", "Pausing will completely cease any sync with this user.")
|
||||
+ UiSharedService.TooltipSeparator
|
||||
+ L("PermissionWindow.Pause.HelpNote", "Note: this is bidirectional, either user pausing will cease sync completely."));
|
||||
_uiSharedService.DrawHelpText("Pausing will completely cease any sync with this user." + UiSharedService.TooltipSeparator
|
||||
+ "Note: this is bidirectional, either user pausing will cease sync completely.");
|
||||
var otherPerms = Pair.UserPair.OtherPermissions;
|
||||
|
||||
var otherIsPaused = otherPerms.IsPaused();
|
||||
@@ -75,68 +70,53 @@ public class PermissionWindowUI : WindowMediatorSubscriberBase
|
||||
_uiSharedService.BooleanToColoredIcon(!otherIsPaused, false);
|
||||
ImGui.SameLine();
|
||||
ImGui.AlignTextToFramePadding();
|
||||
var pausedText = otherIsPaused
|
||||
? L("PermissionWindow.OtherPaused.True", "{0} has paused you", Pair.UserData.AliasOrUID)
|
||||
: L("PermissionWindow.OtherPaused.False", "{0} has not paused you", Pair.UserData.AliasOrUID);
|
||||
ImGui.TextUnformatted(pausedText);
|
||||
ImGui.TextUnformatted(Pair.UserData.AliasOrUID + " has " + (!otherIsPaused ? "not " : string.Empty) + "paused you");
|
||||
}
|
||||
|
||||
ImGuiHelpers.ScaledDummy(0.5f);
|
||||
ImGui.Separator();
|
||||
ImGuiHelpers.ScaledDummy(0.5f);
|
||||
|
||||
if (ImGui.Checkbox(L("PermissionWindow.Sounds.Label", "Disable Sounds"), ref disableSounds))
|
||||
if (ImGui.Checkbox("Disable Sounds", ref disableSounds))
|
||||
{
|
||||
_ownPermissions.SetDisableSounds(disableSounds);
|
||||
}
|
||||
_uiSharedService.DrawHelpText(L("PermissionWindow.Sounds.HelpMain", "Disabling sounds will remove all sounds synced with this user on both sides.")
|
||||
+ UiSharedService.TooltipSeparator
|
||||
+ L("PermissionWindow.Sounds.HelpNote", "Note: this is bidirectional, either user disabling sound sync will stop sound sync on both sides."));
|
||||
_uiSharedService.DrawHelpText("Disabling sounds will remove all sounds synced with this user on both sides." + UiSharedService.TooltipSeparator
|
||||
+ "Note: this is bidirectional, either user disabling sound sync will stop sound sync on both sides.");
|
||||
using (ImRaii.PushIndent(indentSize, false))
|
||||
{
|
||||
_uiSharedService.BooleanToColoredIcon(!otherDisableSounds, false);
|
||||
ImGui.SameLine();
|
||||
ImGui.AlignTextToFramePadding();
|
||||
var soundText = otherDisableSounds
|
||||
? L("PermissionWindow.OtherSoundDisabled.True", "{0} has disabled sound sync with you", Pair.UserData.AliasOrUID)
|
||||
: L("PermissionWindow.OtherSoundDisabled.False", "{0} has not disabled sound sync with you", Pair.UserData.AliasOrUID);
|
||||
ImGui.TextUnformatted(soundText);
|
||||
ImGui.TextUnformatted(Pair.UserData.AliasOrUID + " has " + (!otherDisableSounds ? "not " : string.Empty) + "disabled sound sync with you");
|
||||
}
|
||||
|
||||
if (ImGui.Checkbox(L("PermissionWindow.Animations.Label", "Disable Animations"), ref disableAnimations))
|
||||
if (ImGui.Checkbox("Disable Animations", ref disableAnimations))
|
||||
{
|
||||
_ownPermissions.SetDisableAnimations(disableAnimations);
|
||||
}
|
||||
_uiSharedService.DrawHelpText(L("PermissionWindow.Animations.HelpMain", "Disabling sounds will remove all animations synced with this user on both sides.")
|
||||
+ UiSharedService.TooltipSeparator
|
||||
+ L("PermissionWindow.Animations.HelpNote", "Note: this is bidirectional, either user disabling animation sync will stop animation sync on both sides."));
|
||||
_uiSharedService.DrawHelpText("Disabling sounds will remove all animations synced with this user on both sides." + UiSharedService.TooltipSeparator
|
||||
+ "Note: this is bidirectional, either user disabling animation sync will stop animation sync on both sides.");
|
||||
using (ImRaii.PushIndent(indentSize, false))
|
||||
{
|
||||
_uiSharedService.BooleanToColoredIcon(!otherDisableAnimations, false);
|
||||
ImGui.SameLine();
|
||||
ImGui.AlignTextToFramePadding();
|
||||
var animText = otherDisableAnimations
|
||||
? L("PermissionWindow.OtherAnimationDisabled.True", "{0} has disabled animation sync with you", Pair.UserData.AliasOrUID)
|
||||
: L("PermissionWindow.OtherAnimationDisabled.False", "{0} has not disabled animation sync with you", Pair.UserData.AliasOrUID);
|
||||
ImGui.TextUnformatted(animText);
|
||||
ImGui.TextUnformatted(Pair.UserData.AliasOrUID + " has " + (!otherDisableAnimations ? "not " : string.Empty) + "disabled animation sync with you");
|
||||
}
|
||||
|
||||
if (ImGui.Checkbox(L("PermissionWindow.Vfx.Label", "Disable VFX"), ref disableVfx))
|
||||
if (ImGui.Checkbox("Disable VFX", ref disableVfx))
|
||||
{
|
||||
_ownPermissions.SetDisableVFX(disableVfx);
|
||||
}
|
||||
_uiSharedService.DrawHelpText(L("PermissionWindow.Vfx.HelpMain", "Disabling sounds will remove all VFX synced with this user on both sides.")
|
||||
+ UiSharedService.TooltipSeparator
|
||||
+ L("PermissionWindow.Vfx.HelpNote", "Note: this is bidirectional, either user disabling VFX sync will stop VFX sync on both sides."));
|
||||
_uiSharedService.DrawHelpText("Disabling sounds will remove all VFX synced with this user on both sides." + UiSharedService.TooltipSeparator
|
||||
+ "Note: this is bidirectional, either user disabling VFX sync will stop VFX sync on both sides.");
|
||||
using (ImRaii.PushIndent(indentSize, false))
|
||||
{
|
||||
_uiSharedService.BooleanToColoredIcon(!otherDisableVFX, false);
|
||||
ImGui.SameLine();
|
||||
ImGui.AlignTextToFramePadding();
|
||||
var vfxText = otherDisableVFX
|
||||
? L("PermissionWindow.OtherVfxDisabled.True", "{0} has disabled VFX sync with you", Pair.UserData.AliasOrUID)
|
||||
: L("PermissionWindow.OtherVfxDisabled.False", "{0} has not disabled VFX sync with you", Pair.UserData.AliasOrUID);
|
||||
ImGui.TextUnformatted(vfxText);
|
||||
ImGui.TextUnformatted(Pair.UserData.AliasOrUID + " has " + (!otherDisableVFX ? "not " : string.Empty) + "disabled VFX sync with you");
|
||||
}
|
||||
|
||||
ImGuiHelpers.ScaledDummy(0.5f);
|
||||
@@ -146,35 +126,44 @@ public class PermissionWindowUI : WindowMediatorSubscriberBase
|
||||
bool hasChanges = _ownPermissions != Pair.UserPair.OwnPermissions;
|
||||
|
||||
using (ImRaii.Disabled(!hasChanges))
|
||||
if (_uiSharedService.IconTextButton(Dalamud.Interface.FontAwesomeIcon.Save, L("PermissionWindow.Button.Save", "Save")))
|
||||
if (_uiSharedService.IconTextButton(Dalamud.Interface.FontAwesomeIcon.Save, "Save"))
|
||||
{
|
||||
Mediator.Publish(new PairSyncOverrideChanged(Pair.UserData.UID,
|
||||
_ownPermissions.IsDisableSounds(),
|
||||
_ownPermissions.IsDisableAnimations(),
|
||||
_ownPermissions.IsDisableVFX()));
|
||||
_ = _apiController.UserSetPairPermissions(new(Pair.UserData, _ownPermissions));
|
||||
}
|
||||
UiSharedService.AttachToolTip(L("PermissionWindow.Tooltip.Save", "Save and apply all changes"));
|
||||
UiSharedService.AttachToolTip("Save and apply all changes");
|
||||
|
||||
var rightSideButtons = _uiSharedService.GetIconTextButtonSize(Dalamud.Interface.FontAwesomeIcon.Undo, L("PermissionWindow.Button.Revert", "Revert")) +
|
||||
_uiSharedService.GetIconTextButtonSize(Dalamud.Interface.FontAwesomeIcon.ArrowsSpin, L("PermissionWindow.Button.Reset", "Reset to Default"));
|
||||
var rightSideButtons = _uiSharedService.GetIconTextButtonSize(Dalamud.Interface.FontAwesomeIcon.Undo, "Revert") +
|
||||
_uiSharedService.GetIconTextButtonSize(Dalamud.Interface.FontAwesomeIcon.ArrowsSpin, "Reset to Default");
|
||||
var availableWidth = ImGui.GetWindowContentRegionMax().X - ImGui.GetWindowContentRegionMin().X;
|
||||
|
||||
ImGui.SameLine(availableWidth - rightSideButtons);
|
||||
|
||||
using (ImRaii.Disabled(!hasChanges))
|
||||
if (_uiSharedService.IconTextButton(Dalamud.Interface.FontAwesomeIcon.Undo, L("PermissionWindow.Button.Revert", "Revert")))
|
||||
if (_uiSharedService.IconTextButton(Dalamud.Interface.FontAwesomeIcon.Undo, "Revert"))
|
||||
{
|
||||
_ownPermissions = Pair.UserPair.OwnPermissions.DeepClone();
|
||||
}
|
||||
UiSharedService.AttachToolTip(L("PermissionWindow.Tooltip.Revert", "Revert all changes"));
|
||||
UiSharedService.AttachToolTip("Revert all changes");
|
||||
|
||||
ImGui.SameLine();
|
||||
if (_uiSharedService.IconTextButton(Dalamud.Interface.FontAwesomeIcon.ArrowsSpin, L("PermissionWindow.Button.Reset", "Reset to Default")))
|
||||
if (_uiSharedService.IconTextButton(Dalamud.Interface.FontAwesomeIcon.ArrowsSpin, "Reset to Default"))
|
||||
{
|
||||
var defaults = _uiSharedService.ConfigService.Current;
|
||||
_ownPermissions.SetPaused(false);
|
||||
_ownPermissions.SetDisableVFX(false);
|
||||
_ownPermissions.SetDisableSounds(false);
|
||||
_ownPermissions.SetDisableAnimations(false);
|
||||
_ownPermissions.SetDisableSounds(defaults.DefaultDisableSounds);
|
||||
_ownPermissions.SetDisableAnimations(defaults.DefaultDisableAnimations);
|
||||
_ownPermissions.SetDisableVFX(defaults.DefaultDisableVfx);
|
||||
Mediator.Publish(new PairSyncOverrideChanged(Pair.UserData.UID,
|
||||
_ownPermissions.IsDisableSounds(),
|
||||
_ownPermissions.IsDisableAnimations(),
|
||||
_ownPermissions.IsDisableVFX()));
|
||||
_ = _apiController.UserSetPairPermissions(new(Pair.UserData, _ownPermissions));
|
||||
}
|
||||
UiSharedService.AttachToolTip(L("PermissionWindow.Tooltip.Reset", "This will set all permissions to their default setting"));
|
||||
UiSharedService.AttachToolTip("This will set all permissions to their default setting");
|
||||
|
||||
var ySize = ImGui.GetCursorPosY() + style.FramePadding.Y * ImGuiHelpers.GlobalScale + style.FrameBorderSize;
|
||||
ImGui.SetWindowSize(new(400, ySize));
|
||||
|
||||
@@ -16,25 +16,22 @@ namespace MareSynchronos.UI;
|
||||
public class PopoutProfileUi : WindowMediatorSubscriberBase
|
||||
{
|
||||
private readonly MareProfileManager _mareProfileManager;
|
||||
private readonly PairManager _pairManager;
|
||||
private readonly ServerConfigurationManager _serverManager;
|
||||
private readonly UiSharedService _uiSharedService;
|
||||
private Vector2 _lastMainPos = Vector2.Zero;
|
||||
private Vector2 _lastMainSize = Vector2.Zero;
|
||||
private byte[] _lastProfilePicture = [];
|
||||
private byte[] _lastSupporterPicture = [];
|
||||
private Pair? _pair;
|
||||
private IDalamudTextureWrap? _supporterTextureWrap;
|
||||
private IDalamudTextureWrap? _textureWrap;
|
||||
|
||||
public PopoutProfileUi(ILogger<PopoutProfileUi> logger, MareMediator mediator, UiSharedService uiSharedService,
|
||||
ServerConfigurationManager serverManager, MareConfigService mareConfigService,
|
||||
MareProfileManager mareProfileManager, PairManager pairManager, PerformanceCollectorService performanceCollectorService) : base(logger, mediator, "###UmbraSyncPopoutProfileUI", performanceCollectorService)
|
||||
MareProfileManager mareProfileManager, PerformanceCollectorService performanceCollectorService) : base(logger, mediator, "###UmbraSyncPopoutProfileUI", performanceCollectorService)
|
||||
{
|
||||
_uiSharedService = uiSharedService;
|
||||
_serverManager = serverManager;
|
||||
_mareProfileManager = mareProfileManager;
|
||||
_pairManager = pairManager;
|
||||
Flags = ImGuiWindowFlags.NoDecoration;
|
||||
|
||||
Mediator.Subscribe<ProfilePopoutToggle>(this, (msg) =>
|
||||
@@ -42,7 +39,6 @@ public class PopoutProfileUi : WindowMediatorSubscriberBase
|
||||
IsOpen = msg.Pair != null;
|
||||
_pair = msg.Pair;
|
||||
_lastProfilePicture = [];
|
||||
_lastSupporterPicture = [];
|
||||
_textureWrap?.Dispose();
|
||||
_textureWrap = null;
|
||||
_supporterTextureWrap?.Dispose();
|
||||
@@ -113,7 +109,7 @@ public class PopoutProfileUi : WindowMediatorSubscriberBase
|
||||
UiSharedService.ColorText(note, ImGuiColors.DalamudGrey);
|
||||
}
|
||||
string status = _pair.IsVisible ? "Visible" : (_pair.IsOnline ? "Online" : "Offline");
|
||||
UiSharedService.ColorText(status, (_pair.IsVisible || _pair.IsOnline) ? ImGuiColors.HealerGreen : ImGuiColors.DalamudRed);
|
||||
UiSharedService.ColorText(status, (_pair.IsVisible || _pair.IsOnline) ? ImGuiColors.HealerGreen : UiSharedService.AccentColor);
|
||||
if (_pair.IsVisible)
|
||||
{
|
||||
ImGui.SameLine();
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -16,7 +16,6 @@ namespace MareSynchronos.UI;
|
||||
public class StandaloneProfileUi : WindowMediatorSubscriberBase
|
||||
{
|
||||
private readonly MareProfileManager _mareProfileManager;
|
||||
private readonly PairManager _pairManager;
|
||||
private readonly ServerConfigurationManager _serverManager;
|
||||
private readonly UiSharedService _uiSharedService;
|
||||
private bool _adjustedForScrollBars = false;
|
||||
@@ -24,7 +23,7 @@ public class StandaloneProfileUi : WindowMediatorSubscriberBase
|
||||
private IDalamudTextureWrap? _textureWrap;
|
||||
|
||||
public StandaloneProfileUi(ILogger<StandaloneProfileUi> logger, MareMediator mediator, UiSharedService uiBuilder,
|
||||
ServerConfigurationManager serverManager, MareProfileManager mareProfileManager, PairManager pairManager, Pair pair,
|
||||
ServerConfigurationManager serverManager, MareProfileManager mareProfileManager, Pair pair,
|
||||
PerformanceCollectorService performanceCollector)
|
||||
: base(logger, mediator, "Profile of " + pair.UserData.AliasOrUID + "##UmbraSyncStandaloneProfileUI" + pair.UserData.AliasOrUID, performanceCollector)
|
||||
{
|
||||
@@ -32,7 +31,6 @@ public class StandaloneProfileUi : WindowMediatorSubscriberBase
|
||||
_serverManager = serverManager;
|
||||
_mareProfileManager = mareProfileManager;
|
||||
Pair = pair;
|
||||
_pairManager = pairManager;
|
||||
Flags = ImGuiWindowFlags.NoResize | ImGuiWindowFlags.AlwaysAutoResize;
|
||||
|
||||
var spacing = ImGui.GetStyle().ItemSpacing;
|
||||
@@ -111,7 +109,7 @@ public class StandaloneProfileUi : WindowMediatorSubscriberBase
|
||||
UiSharedService.ColorText(note, ImGuiColors.DalamudGrey);
|
||||
}
|
||||
string status = Pair.IsVisible ? "Visible" : (Pair.IsOnline ? "Online" : "Offline");
|
||||
UiSharedService.ColorText(status, (Pair.IsVisible || Pair.IsOnline) ? ImGuiColors.HealerGreen : ImGuiColors.DalamudRed);
|
||||
UiSharedService.ColorText(status, (Pair.IsVisible || Pair.IsOnline) ? ImGuiColors.HealerGreen : UiSharedService.AccentColor);
|
||||
if (Pair.IsVisible)
|
||||
{
|
||||
ImGui.SameLine();
|
||||
|
||||
@@ -3,15 +3,21 @@ using Dalamud.Interface;
|
||||
using Dalamud.Interface.Colors;
|
||||
using Dalamud.Interface.Utility;
|
||||
using Dalamud.Interface.Utility.Raii;
|
||||
using System;
|
||||
using MareSynchronos.API.Data.Enum;
|
||||
using MareSynchronos.API.Data.Extensions;
|
||||
using MareSynchronos.API.Dto.Group;
|
||||
using MareSynchronos.PlayerData.Pairs;
|
||||
using MareSynchronos.Services;
|
||||
using MareSynchronos.Services.AutoDetect;
|
||||
using MareSynchronos.Services.Mediator;
|
||||
using MareSynchronos.Services.Notifications;
|
||||
using MareSynchronos.WebAPI;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System.Globalization;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using MareSynchronos.MareConfiguration.Models;
|
||||
|
||||
namespace MareSynchronos.UI.Components.Popup;
|
||||
|
||||
@@ -23,6 +29,8 @@ public class SyncshellAdminUI : WindowMediatorSubscriberBase
|
||||
private readonly List<string> _oneTimeInvites = [];
|
||||
private readonly PairManager _pairManager;
|
||||
private readonly UiSharedService _uiSharedService;
|
||||
private readonly SyncshellDiscoveryService _syncshellDiscoveryService;
|
||||
private readonly NotificationTracker _notificationTracker;
|
||||
private List<BannedGroupUserDto> _bannedUsers = [];
|
||||
private int _multiInvites;
|
||||
private string _newPassword;
|
||||
@@ -30,20 +38,43 @@ public class SyncshellAdminUI : WindowMediatorSubscriberBase
|
||||
private Task<int>? _pruneTestTask;
|
||||
private Task<int>? _pruneTask;
|
||||
private int _pruneDays = 14;
|
||||
private bool _autoDetectStateInitialized;
|
||||
private bool _autoDetectStateLoading;
|
||||
private bool _autoDetectToggleInFlight;
|
||||
private bool _autoDetectVisible;
|
||||
private bool _autoDetectPasswordDisabled;
|
||||
private string? _autoDetectMessage;
|
||||
|
||||
private bool _autoDetectDesiredVisibility;
|
||||
private int _adDurationHours = 2;
|
||||
private bool _adRecurring = false;
|
||||
private readonly bool[] _adWeekdays = new bool[7];
|
||||
private int _adStartHour = 21;
|
||||
private int _adStartMinute = 0;
|
||||
private int _adEndHour = 23;
|
||||
private int _adEndMinute = 0;
|
||||
private const string AutoDetectTimeZone = "Europe/Paris";
|
||||
|
||||
public SyncshellAdminUI(ILogger<SyncshellAdminUI> logger, MareMediator mediator, ApiController apiController,
|
||||
UiSharedService uiSharedService, PairManager pairManager, GroupFullInfoDto groupFullInfo, PerformanceCollectorService performanceCollectorService)
|
||||
UiSharedService uiSharedService, PairManager pairManager, SyncshellDiscoveryService syncshellDiscoveryService,
|
||||
GroupFullInfoDto groupFullInfo, PerformanceCollectorService performanceCollectorService, NotificationTracker notificationTracker)
|
||||
: base(logger, mediator, "Syncshell Admin Panel (" + groupFullInfo.GroupAliasOrGID + ")", performanceCollectorService)
|
||||
{
|
||||
GroupFullInfo = groupFullInfo;
|
||||
_apiController = apiController;
|
||||
_uiSharedService = uiSharedService;
|
||||
_pairManager = pairManager;
|
||||
_syncshellDiscoveryService = syncshellDiscoveryService;
|
||||
_notificationTracker = notificationTracker;
|
||||
_isOwner = string.Equals(GroupFullInfo.OwnerUID, _apiController.UID, StringComparison.Ordinal);
|
||||
_isModerator = GroupFullInfo.GroupUserInfo.IsModerator();
|
||||
_newPassword = string.Empty;
|
||||
_multiInvites = 30;
|
||||
_pwChangeSuccess = true;
|
||||
_autoDetectVisible = groupFullInfo.AutoDetectVisible;
|
||||
_autoDetectDesiredVisibility = _autoDetectVisible;
|
||||
_autoDetectPasswordDisabled = groupFullInfo.PasswordTemporarilyDisabled;
|
||||
Mediator.Subscribe<SyncshellAutoDetectStateChanged>(this, OnSyncshellAutoDetectStateChanged);
|
||||
IsOpen = true;
|
||||
SizeConstraints = new WindowSizeConstraints()
|
||||
{
|
||||
@@ -59,6 +90,11 @@ public class SyncshellAdminUI : WindowMediatorSubscriberBase
|
||||
if (!_isModerator && !_isOwner) return;
|
||||
|
||||
GroupFullInfo = _pairManager.Groups[GroupFullInfo.Group];
|
||||
if (!_autoDetectToggleInFlight && !_autoDetectStateLoading)
|
||||
{
|
||||
_autoDetectVisible = GroupFullInfo.AutoDetectVisible;
|
||||
_autoDetectPasswordDisabled = GroupFullInfo.PasswordTemporarilyDisabled;
|
||||
}
|
||||
|
||||
using var id = ImRaii.PushId("syncshell_admin_" + GroupFullInfo.GID);
|
||||
|
||||
@@ -68,6 +104,9 @@ public class SyncshellAdminUI : WindowMediatorSubscriberBase
|
||||
ImGui.Separator();
|
||||
var perm = GroupFullInfo.GroupPermissions;
|
||||
|
||||
using var tabColor = ImRaii.PushColor(ImGuiCol.Tab, UiSharedService.AccentColor);
|
||||
using var tabHoverColor = ImRaii.PushColor(ImGuiCol.TabHovered, UiSharedService.AccentHoverColor);
|
||||
using var tabActiveColor = ImRaii.PushColor(ImGuiCol.TabActive, UiSharedService.AccentActiveColor);
|
||||
using var tabbar = ImRaii.TabBar("syncshell_tab_" + GroupFullInfo.GID);
|
||||
|
||||
if (tabbar)
|
||||
@@ -363,6 +402,13 @@ public class SyncshellAdminUI : WindowMediatorSubscriberBase
|
||||
}
|
||||
mgmtTab.Dispose();
|
||||
|
||||
var discoveryTab = ImRaii.TabItem("AutoDetect");
|
||||
if (discoveryTab)
|
||||
{
|
||||
DrawAutoDetectTab();
|
||||
}
|
||||
discoveryTab.Dispose();
|
||||
|
||||
var permissionTab = ImRaii.TabItem("Permissions");
|
||||
if (permissionTab)
|
||||
{
|
||||
@@ -374,7 +420,7 @@ public class SyncshellAdminUI : WindowMediatorSubscriberBase
|
||||
ImGui.TextUnformatted("Sound Sync");
|
||||
_uiSharedService.BooleanToColoredIcon(!isDisableSounds);
|
||||
ImGui.SameLine(230);
|
||||
if (_uiSharedService.IconTextButton(isDisableSounds ? FontAwesomeIcon.VolumeUp : FontAwesomeIcon.VolumeMute,
|
||||
if (_uiSharedService.IconTextButton(isDisableSounds ? FontAwesomeIcon.VolumeMute : FontAwesomeIcon.VolumeUp,
|
||||
isDisableSounds ? "Enable sound sync" : "Disable sound sync"))
|
||||
{
|
||||
perm.SetDisableSounds(!perm.IsDisableSounds());
|
||||
@@ -385,7 +431,7 @@ public class SyncshellAdminUI : WindowMediatorSubscriberBase
|
||||
ImGui.TextUnformatted("Animation Sync");
|
||||
_uiSharedService.BooleanToColoredIcon(!isDisableAnimations);
|
||||
ImGui.SameLine(230);
|
||||
if (_uiSharedService.IconTextButton(isDisableAnimations ? FontAwesomeIcon.Running : FontAwesomeIcon.Stop,
|
||||
if (_uiSharedService.IconTextButton(isDisableAnimations ? FontAwesomeIcon.WindowClose : FontAwesomeIcon.Running,
|
||||
isDisableAnimations ? "Enable animation sync" : "Disable animation sync"))
|
||||
{
|
||||
perm.SetDisableAnimations(!perm.IsDisableAnimations());
|
||||
@@ -396,7 +442,7 @@ public class SyncshellAdminUI : WindowMediatorSubscriberBase
|
||||
ImGui.TextUnformatted("VFX Sync");
|
||||
_uiSharedService.BooleanToColoredIcon(!isDisableVfx);
|
||||
ImGui.SameLine(230);
|
||||
if (_uiSharedService.IconTextButton(isDisableVfx ? FontAwesomeIcon.Sun : FontAwesomeIcon.Circle,
|
||||
if (_uiSharedService.IconTextButton(isDisableVfx ? FontAwesomeIcon.TimesCircle : FontAwesomeIcon.Sun,
|
||||
isDisableVfx ? "Enable VFX sync" : "Disable VFX sync"))
|
||||
{
|
||||
perm.SetDisableVFX(!perm.IsDisableVFX());
|
||||
@@ -448,8 +494,283 @@ public class SyncshellAdminUI : WindowMediatorSubscriberBase
|
||||
}
|
||||
}
|
||||
|
||||
private void DrawAutoDetectTab()
|
||||
{
|
||||
if (!_autoDetectStateInitialized && !_autoDetectStateLoading)
|
||||
{
|
||||
_autoDetectStateInitialized = true;
|
||||
_autoDetectStateLoading = true;
|
||||
_ = EnsureAutoDetectStateAsync();
|
||||
}
|
||||
|
||||
UiSharedService.TextWrapped("Activer l'affichage AutoDetect rend la Syncshell visible dans l'onglet AutoDetect et désactive temporairement le mot de passe.");
|
||||
ImGuiHelpers.ScaledDummy(4);
|
||||
|
||||
if (_autoDetectStateLoading)
|
||||
{
|
||||
ImGui.TextDisabled("Chargement de l'état en cours...");
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(_autoDetectMessage))
|
||||
{
|
||||
UiSharedService.ColorTextWrapped(_autoDetectMessage!, ImGuiColors.DalamudYellow);
|
||||
}
|
||||
|
||||
using (ImRaii.Disabled(_autoDetectToggleInFlight || _autoDetectStateLoading))
|
||||
{
|
||||
if (ImGui.Checkbox("Afficher cette Syncshell dans l'AutoDetect", ref _autoDetectDesiredVisibility))
|
||||
{
|
||||
// Only change local desired state; sending is done via the validate button
|
||||
}
|
||||
}
|
||||
_uiSharedService.DrawHelpText("Quand cette option est activée, le mot de passe devient inactif tant que la visibilité est maintenue.");
|
||||
|
||||
if (_autoDetectDesiredVisibility)
|
||||
{
|
||||
ImGuiHelpers.ScaledDummy(4);
|
||||
ImGui.TextUnformatted("Options d'affichage AutoDetect");
|
||||
ImGui.Separator();
|
||||
|
||||
// Recurring toggle first
|
||||
ImGui.Checkbox("Affichage récurrent", ref _adRecurring);
|
||||
_uiSharedService.DrawHelpText("Si activé, vous pouvez choisir les jours et une plage horaire récurrents. Si désactivé, seule la durée sera prise en compte.");
|
||||
|
||||
// Duration in hours (only when NOT recurring)
|
||||
if (!_adRecurring)
|
||||
{
|
||||
ImGuiHelpers.ScaledDummy(4);
|
||||
int duration = _adDurationHours;
|
||||
ImGui.PushItemWidth(120 * ImGuiHelpers.GlobalScale);
|
||||
if (ImGui.InputInt("Durée (heures)", ref duration))
|
||||
{
|
||||
_adDurationHours = Math.Clamp(duration, 1, 240);
|
||||
}
|
||||
ImGui.PopItemWidth();
|
||||
_uiSharedService.DrawHelpText("Combien de temps la Syncshell doit rester visible, en heures.");
|
||||
}
|
||||
|
||||
ImGuiHelpers.ScaledDummy(4);
|
||||
if (_adRecurring)
|
||||
{
|
||||
ImGuiHelpers.ScaledDummy(4);
|
||||
ImGui.TextUnformatted("Jours de la semaine actifs :");
|
||||
string[] daysFr = new[] { "Lun", "Mar", "Mer", "Jeu", "Ven", "Sam", "Dim" };
|
||||
for (int i = 0; i < 7; i++)
|
||||
{
|
||||
ImGui.SameLine(i == 0 ? 0 : 0);
|
||||
bool v = _adWeekdays[i];
|
||||
if (ImGui.Checkbox($"##adwd{i}", ref v)) _adWeekdays[i] = v;
|
||||
ImGui.SameLine();
|
||||
ImGui.TextUnformatted(daysFr[i]);
|
||||
if (i < 6) ImGui.SameLine();
|
||||
}
|
||||
ImGui.NewLine();
|
||||
_uiSharedService.DrawHelpText("Sélectionnez les jours où l'affichage est autorisé (ex: jeudi et dimanche).");
|
||||
|
||||
ImGuiHelpers.ScaledDummy(4);
|
||||
ImGui.TextUnformatted("Plage horaire (heure locale Europe/Paris) :");
|
||||
ImGui.PushItemWidth(60 * ImGuiHelpers.GlobalScale);
|
||||
ImGui.InputInt("Début heure", ref _adStartHour); ImGui.SameLine();
|
||||
ImGui.InputInt("min", ref _adStartMinute);
|
||||
_adStartHour = Math.Clamp(_adStartHour, 0, 23);
|
||||
_adStartMinute = Math.Clamp(_adStartMinute, 0, 59);
|
||||
ImGui.SameLine();
|
||||
ImGui.TextUnformatted("→"); ImGui.SameLine();
|
||||
ImGui.InputInt("Fin heure", ref _adEndHour); ImGui.SameLine();
|
||||
ImGui.InputInt("min ", ref _adEndMinute);
|
||||
_adEndHour = Math.Clamp(_adEndHour, 0, 23);
|
||||
_adEndMinute = Math.Clamp(_adEndMinute, 0, 59);
|
||||
ImGui.PopItemWidth();
|
||||
_uiSharedService.DrawHelpText("Exemple : de 21h00 à 23h00. Le fuseau utilisé est Europe/Paris (avec changements été/hiver).");
|
||||
}
|
||||
}
|
||||
|
||||
if (_autoDetectPasswordDisabled && _autoDetectVisible)
|
||||
{
|
||||
UiSharedService.ColorTextWrapped("Le mot de passe est actuellement désactivé pendant la visibilité AutoDetect.", ImGuiColors.DalamudYellow);
|
||||
}
|
||||
|
||||
ImGuiHelpers.ScaledDummy(6);
|
||||
using (ImRaii.Disabled(_autoDetectToggleInFlight || _autoDetectStateLoading))
|
||||
{
|
||||
if (ImGui.Button("Valider et envoyer"))
|
||||
{
|
||||
_ = SubmitAutoDetectAsync();
|
||||
}
|
||||
ImGui.SameLine();
|
||||
if (ImGui.Button("Recharger l'état"))
|
||||
{
|
||||
_autoDetectStateLoading = true;
|
||||
_ = EnsureAutoDetectStateAsync(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private async Task EnsureAutoDetectStateAsync(bool force = false)
|
||||
{
|
||||
try
|
||||
{
|
||||
var state = await _syncshellDiscoveryService.GetStateAsync(GroupFullInfo.GID, CancellationToken.None).ConfigureAwait(false);
|
||||
if (state != null)
|
||||
{
|
||||
ApplyAutoDetectState(state.AutoDetectVisible, state.PasswordTemporarilyDisabled, true);
|
||||
_autoDetectMessage = null;
|
||||
}
|
||||
else if (force)
|
||||
{
|
||||
_autoDetectMessage = "Impossible de récupérer l'état AutoDetect.";
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_autoDetectMessage = force ? $"Erreur lors du rafraîchissement : {ex.Message}" : _autoDetectMessage;
|
||||
}
|
||||
finally
|
||||
{
|
||||
_autoDetectStateLoading = false;
|
||||
}
|
||||
}
|
||||
|
||||
private async Task ToggleAutoDetectAsync(bool desiredVisibility)
|
||||
{
|
||||
if (_autoDetectToggleInFlight)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_autoDetectToggleInFlight = true;
|
||||
_autoDetectMessage = null;
|
||||
|
||||
try
|
||||
{
|
||||
var success = await _syncshellDiscoveryService.SetVisibilityAsync(GroupFullInfo.GID, desiredVisibility, CancellationToken.None).ConfigureAwait(false);
|
||||
if (!success)
|
||||
{
|
||||
_autoDetectMessage = "Impossible de mettre à jour la visibilité AutoDetect.";
|
||||
return;
|
||||
}
|
||||
|
||||
await EnsureAutoDetectStateAsync(true).ConfigureAwait(false);
|
||||
_autoDetectMessage = desiredVisibility
|
||||
? "La Syncshell est désormais visible dans AutoDetect."
|
||||
: "La Syncshell n'est plus visible dans AutoDetect.";
|
||||
|
||||
if (desiredVisibility)
|
||||
{
|
||||
PublishSyncshellPublicNotification();
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_autoDetectMessage = $"Erreur lors de la mise à jour AutoDetect : {ex.Message}";
|
||||
}
|
||||
finally
|
||||
{
|
||||
_autoDetectToggleInFlight = false;
|
||||
}
|
||||
}
|
||||
|
||||
private async Task SubmitAutoDetectAsync()
|
||||
{
|
||||
if (_autoDetectToggleInFlight)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_autoDetectToggleInFlight = true;
|
||||
_autoDetectMessage = null;
|
||||
|
||||
try
|
||||
{
|
||||
// Duration always used when visible
|
||||
int? duration = _autoDetectDesiredVisibility ? _adDurationHours : null;
|
||||
|
||||
// Scheduling fields only if recurring is enabled
|
||||
int[]? weekdaysArr = null;
|
||||
TimeSpan? start = null;
|
||||
TimeSpan? end = null;
|
||||
string? tz = null;
|
||||
if (_autoDetectDesiredVisibility && _adRecurring)
|
||||
{
|
||||
List<int> weekdays = new();
|
||||
for (int i = 0; i < 7; i++) if (_adWeekdays[i]) weekdays.Add(i);
|
||||
weekdaysArr = weekdays.Count > 0 ? weekdays.ToArray() : Array.Empty<int>();
|
||||
start = new TimeSpan(_adStartHour, _adStartMinute, 0);
|
||||
end = new TimeSpan(_adEndHour, _adEndMinute, 0);
|
||||
tz = AutoDetectTimeZone;
|
||||
}
|
||||
|
||||
var ok = await _syncshellDiscoveryService.SetVisibilityAsync(
|
||||
GroupFullInfo.GID,
|
||||
_autoDetectDesiredVisibility,
|
||||
duration,
|
||||
weekdaysArr,
|
||||
start,
|
||||
end,
|
||||
tz,
|
||||
CancellationToken.None).ConfigureAwait(false);
|
||||
|
||||
if (!ok)
|
||||
{
|
||||
_autoDetectMessage = "Impossible d'envoyer les paramètres AutoDetect.";
|
||||
return;
|
||||
}
|
||||
|
||||
await EnsureAutoDetectStateAsync(true).ConfigureAwait(false);
|
||||
_autoDetectMessage = _autoDetectDesiredVisibility
|
||||
? "Paramètres AutoDetect envoyés. La Syncshell sera visible selon le planning défini."
|
||||
: "La Syncshell n'est plus visible dans AutoDetect.";
|
||||
|
||||
if (_autoDetectDesiredVisibility)
|
||||
{
|
||||
PublishSyncshellPublicNotification();
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_autoDetectMessage = $"Erreur lors de l'envoi des paramètres AutoDetect : {ex.Message}";
|
||||
}
|
||||
finally
|
||||
{
|
||||
_autoDetectToggleInFlight = false;
|
||||
}
|
||||
}
|
||||
|
||||
private void ApplyAutoDetectState(bool visible, bool passwordDisabled, bool fromServer)
|
||||
{
|
||||
_autoDetectVisible = visible;
|
||||
_autoDetectPasswordDisabled = passwordDisabled;
|
||||
if (fromServer)
|
||||
{
|
||||
GroupFullInfo.AutoDetectVisible = visible;
|
||||
GroupFullInfo.PasswordTemporarilyDisabled = passwordDisabled;
|
||||
}
|
||||
}
|
||||
|
||||
private void OnSyncshellAutoDetectStateChanged(SyncshellAutoDetectStateChanged msg)
|
||||
{
|
||||
if (!string.Equals(msg.Gid, GroupFullInfo.GID, StringComparison.OrdinalIgnoreCase)) return;
|
||||
ApplyAutoDetectState(msg.Visible, msg.PasswordTemporarilyDisabled, true);
|
||||
_autoDetectMessage = null;
|
||||
}
|
||||
|
||||
public override void OnClose()
|
||||
{
|
||||
Mediator.Publish(new RemoveWindowMessage(this));
|
||||
}
|
||||
|
||||
private void PublishSyncshellPublicNotification()
|
||||
{
|
||||
try
|
||||
{
|
||||
var title = $"Syncshell publique: {GroupFullInfo.GroupAliasOrGID}";
|
||||
var message = "La Syncshell est désormais visible via AutoDetect.";
|
||||
Mediator.Publish(new DualNotificationMessage(title, message, NotificationType.Info, TimeSpan.FromSeconds(4)));
|
||||
_notificationTracker.Upsert(NotificationEntry.SyncshellPublic(GroupFullInfo.GID, GroupFullInfo.GroupAliasOrGID));
|
||||
}
|
||||
catch
|
||||
{
|
||||
// swallow any notification errors to not break UI flow
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
540
MareSynchronos/UI/TypingIndicatorOverlay.cs
Normal file
540
MareSynchronos/UI/TypingIndicatorOverlay.cs
Normal file
@@ -0,0 +1,540 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Numerics;
|
||||
using System.Linq;
|
||||
using Dalamud.Bindings.ImGui;
|
||||
using Dalamud.Interface.Utility;
|
||||
using Dalamud.Plugin.Services;
|
||||
using MareSynchronos.API.Data;
|
||||
using MareSynchronos.API.Data.Extensions;
|
||||
using MareSynchronos.API.Data.Enum;
|
||||
using MareSynchronos.MareConfiguration;
|
||||
using MareSynchronos.MareConfiguration.Models;
|
||||
using MareSynchronos.PlayerData.Pairs;
|
||||
using MareSynchronos.Services;
|
||||
using MareSynchronos.Services.Mediator;
|
||||
using MareSynchronos.WebAPI;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Dalamud.Interface.Textures.TextureWraps;
|
||||
using FFXIVClientStructs.Interop;
|
||||
using FFXIVClientStructs.FFXIV.Client.System.Framework;
|
||||
using FFXIVClientStructs.FFXIV.Client.UI;
|
||||
using FFXIVClientStructs.FFXIV.Component.GUI;
|
||||
|
||||
namespace MareSynchronos.UI;
|
||||
|
||||
public sealed class TypingIndicatorOverlay : WindowMediatorSubscriberBase
|
||||
{
|
||||
private const int NameplateIconId = 61397;
|
||||
private static readonly TimeSpan TypingDisplayTime = TimeSpan.FromSeconds(2);
|
||||
private static readonly TimeSpan TypingDisplayDelay = TimeSpan.FromMilliseconds(500);
|
||||
private static readonly TimeSpan TypingDisplayFade = TypingDisplayTime;
|
||||
|
||||
private readonly ILogger<TypingIndicatorOverlay> _typedLogger;
|
||||
private readonly MareConfigService _configService;
|
||||
private readonly IGameGui _gameGui;
|
||||
private readonly ITextureProvider _textureProvider;
|
||||
private readonly IClientState _clientState;
|
||||
private readonly PairManager _pairManager;
|
||||
private readonly IPartyList _partyList;
|
||||
private readonly IObjectTable _objectTable;
|
||||
private readonly DalamudUtilService _dalamudUtil;
|
||||
private readonly TypingIndicatorStateService _typingStateService;
|
||||
private readonly ApiController _apiController;
|
||||
|
||||
public TypingIndicatorOverlay(ILogger<TypingIndicatorOverlay> logger, MareMediator mediator, PerformanceCollectorService performanceCollectorService,
|
||||
MareConfigService configService, IGameGui gameGui, ITextureProvider textureProvider, IClientState clientState,
|
||||
IPartyList partyList, IObjectTable objectTable, DalamudUtilService dalamudUtil, PairManager pairManager,
|
||||
TypingIndicatorStateService typingStateService, ApiController apiController)
|
||||
: base(logger, mediator, nameof(TypingIndicatorOverlay), performanceCollectorService)
|
||||
{
|
||||
_typedLogger = logger;
|
||||
_configService = configService;
|
||||
_gameGui = gameGui;
|
||||
_textureProvider = textureProvider;
|
||||
_clientState = clientState;
|
||||
_partyList = partyList;
|
||||
_objectTable = objectTable;
|
||||
_dalamudUtil = dalamudUtil;
|
||||
_pairManager = pairManager;
|
||||
_typingStateService = typingStateService;
|
||||
_apiController = apiController;
|
||||
|
||||
RespectCloseHotkey = false;
|
||||
IsOpen = true;
|
||||
Flags |= ImGuiWindowFlags.NoDecoration | ImGuiWindowFlags.NoSavedSettings | ImGuiWindowFlags.NoFocusOnAppearing
|
||||
| ImGuiWindowFlags.NoBackground | ImGuiWindowFlags.NoInputs | ImGuiWindowFlags.NoNav;
|
||||
}
|
||||
|
||||
protected override void DrawInternal()
|
||||
{
|
||||
var viewport = ImGui.GetMainViewport();
|
||||
ImGuiHelpers.ForceNextWindowMainViewport();
|
||||
ImGui.SetWindowPos(viewport.Pos);
|
||||
ImGui.SetWindowSize(viewport.Size);
|
||||
|
||||
if (!_clientState.IsLoggedIn)
|
||||
return;
|
||||
|
||||
var typingEnabled = _configService.Current.TypingIndicatorEnabled;
|
||||
if (!typingEnabled)
|
||||
return;
|
||||
|
||||
var showParty = _configService.Current.TypingIndicatorShowOnPartyList;
|
||||
var showNameplates = _configService.Current.TypingIndicatorShowOnNameplates;
|
||||
|
||||
if (!showParty && !showNameplates)
|
||||
return;
|
||||
|
||||
var overlayDrawList = ImGui.GetWindowDrawList();
|
||||
var activeTypers = _typingStateService.GetActiveTypers(TypingDisplayTime);
|
||||
var hasSelf = _typingStateService.TryGetSelfTyping(TypingDisplayTime, out var selfStart, out var selfLast);
|
||||
var now = DateTime.UtcNow;
|
||||
|
||||
if (showParty)
|
||||
{
|
||||
DrawPartyIndicators(overlayDrawList, activeTypers, hasSelf, now, selfStart, selfLast);
|
||||
}
|
||||
|
||||
if (showNameplates)
|
||||
{
|
||||
DrawNameplateIndicators(ImGui.GetWindowDrawList(), activeTypers, hasSelf, now, selfStart, selfLast);
|
||||
}
|
||||
}
|
||||
|
||||
private unsafe void DrawPartyIndicators(ImDrawListPtr drawList, IReadOnlyDictionary<string, (UserData User, DateTime FirstSeen, DateTime LastUpdate, MareSynchronos.API.Data.Enum.TypingScope Scope)> activeTypers,
|
||||
bool selfActive, DateTime now, DateTime selfStart, DateTime selfLast)
|
||||
{
|
||||
var partyAddon = (AtkUnitBase*)_gameGui.GetAddonByName("_PartyList", 1).Address;
|
||||
if (partyAddon == null || !partyAddon->IsVisible)
|
||||
return;
|
||||
|
||||
var showSelf = _configService.Current.TypingIndicatorShowSelf;
|
||||
if (selfActive
|
||||
&& showSelf
|
||||
&& (now - selfStart) >= TypingDisplayDelay
|
||||
&& (now - selfLast) <= TypingDisplayFade)
|
||||
{
|
||||
DrawPartyMemberTyping(drawList, partyAddon, 0);
|
||||
}
|
||||
|
||||
foreach (var (uid, entry) in activeTypers)
|
||||
{
|
||||
if ((now - entry.LastUpdate) > TypingDisplayFade)
|
||||
continue;
|
||||
|
||||
var pair = _pairManager.GetPairByUID(uid);
|
||||
var targetIndex = -1;
|
||||
var playerName = pair?.PlayerName;
|
||||
var objectId = pair?.PlayerCharacterId ?? uint.MaxValue;
|
||||
|
||||
if (objectId != 0 && objectId != uint.MaxValue)
|
||||
{
|
||||
targetIndex = GetPartyIndexForObjectId(objectId);
|
||||
if (targetIndex >= 0 && !string.IsNullOrEmpty(playerName))
|
||||
{
|
||||
var member = _partyList[targetIndex];
|
||||
var memberName = member?.Name?.TextValue;
|
||||
if (!string.IsNullOrEmpty(memberName) && !memberName.Equals(playerName, StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
var nameIndex = GetPartyIndexForName(playerName);
|
||||
targetIndex = nameIndex;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (targetIndex < 0 && !string.IsNullOrEmpty(playerName))
|
||||
{
|
||||
targetIndex = GetPartyIndexForName(playerName);
|
||||
}
|
||||
|
||||
if (targetIndex < 0)
|
||||
continue;
|
||||
|
||||
DrawPartyMemberTyping(drawList, partyAddon, targetIndex);
|
||||
}
|
||||
}
|
||||
|
||||
private unsafe void DrawPartyMemberTyping(ImDrawListPtr drawList, AtkUnitBase* partyList, int memberIndex)
|
||||
{
|
||||
if (memberIndex < 0 || memberIndex > 7) return;
|
||||
|
||||
var nodeIndex = 23 - memberIndex;
|
||||
if (partyList->UldManager.NodeListCount <= nodeIndex) return;
|
||||
|
||||
var memberNode = (AtkComponentNode*)partyList->UldManager.NodeList[nodeIndex];
|
||||
if (memberNode == null || !memberNode->AtkResNode.IsVisible()) return;
|
||||
|
||||
var iconNode = memberNode->Component->UldManager.NodeListCount > 4 ? memberNode->Component->UldManager.NodeList[4] : null;
|
||||
if (iconNode == null) return;
|
||||
|
||||
var align = partyList->UldManager.NodeList[3]->Y;
|
||||
var partyScale = partyList->Scale;
|
||||
|
||||
var iconOffset = new Vector2(-14, 8) * partyScale;
|
||||
var iconSize = new Vector2(iconNode->Width / 2f, iconNode->Height / 2f) * partyScale;
|
||||
|
||||
var iconPos = new Vector2(
|
||||
partyList->X + (memberNode->AtkResNode.X * partyScale) + (iconNode->X * partyScale) + (iconNode->Width * partyScale / 2f),
|
||||
partyList->Y + align + (memberNode->AtkResNode.Y * partyScale) + (iconNode->Y * partyScale) + (iconNode->Height * partyScale / 2f));
|
||||
|
||||
iconPos += iconOffset;
|
||||
|
||||
var texture = _textureProvider.GetFromGame("ui/uld/charamake_dataimport.tex").GetWrapOrEmpty();
|
||||
if (texture == null) return;
|
||||
|
||||
drawList.AddImage(texture.Handle, iconPos, iconPos + iconSize, Vector2.Zero, Vector2.One,
|
||||
ImGui.ColorConvertFloat4ToU32(new Vector4(1f, 1f, 1f, 0.9f)));
|
||||
}
|
||||
|
||||
private unsafe void DrawNameplateIndicators(ImDrawListPtr drawList, IReadOnlyDictionary<string, (UserData User, DateTime FirstSeen, DateTime LastUpdate, MareSynchronos.API.Data.Enum.TypingScope Scope)> activeTypers,
|
||||
bool selfActive, DateTime now, DateTime selfStart, DateTime selfLast)
|
||||
{
|
||||
var iconWrap = _textureProvider.GetFromGameIcon(NameplateIconId).GetWrapOrEmpty();
|
||||
if (iconWrap == null || iconWrap.Handle == IntPtr.Zero)
|
||||
return;
|
||||
|
||||
var showSelf = _configService.Current.TypingIndicatorShowSelf;
|
||||
if (selfActive
|
||||
&& showSelf
|
||||
&& _clientState.LocalPlayer != null
|
||||
&& (now - selfStart) >= TypingDisplayDelay
|
||||
&& (now - selfLast) <= TypingDisplayFade)
|
||||
{
|
||||
var selfId = GetEntityId(_clientState.LocalPlayer.Address);
|
||||
if (selfId != 0 && !TryDrawNameplateBubble(drawList, iconWrap, selfId))
|
||||
{
|
||||
DrawWorldFallbackIcon(drawList, iconWrap, _clientState.LocalPlayer.Position);
|
||||
}
|
||||
}
|
||||
|
||||
foreach (var (uid, entry) in activeTypers)
|
||||
{
|
||||
if ((now - entry.LastUpdate) > TypingDisplayFade)
|
||||
continue;
|
||||
|
||||
if (string.Equals(uid, _apiController.UID, StringComparison.Ordinal))
|
||||
continue;
|
||||
|
||||
var pair = _pairManager.GetPairByUID(uid);
|
||||
var objectId = pair?.PlayerCharacterId ?? 0;
|
||||
var pairName = pair?.PlayerName ?? entry.User.AliasOrUID ?? string.Empty;
|
||||
var pairIdent = pair?.Ident ?? string.Empty;
|
||||
var isPartyMember = IsPartyMember(objectId, pairName);
|
||||
|
||||
// Enforce party-only visibility when the scope is Party/CrossParty
|
||||
if (entry.Scope is TypingScope.Party or TypingScope.CrossParty)
|
||||
{
|
||||
if (!isPartyMember)
|
||||
{
|
||||
_typedLogger.LogTrace("TypingIndicator: suppressed non-party bubble for {uid} due to scope={scope}", uid, entry.Scope);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
var isRelevantMember = IsPlayerRelevant(pair, isPartyMember);
|
||||
|
||||
if (objectId != uint.MaxValue && objectId != 0 && TryDrawNameplateBubble(drawList, iconWrap, objectId))
|
||||
{
|
||||
_typedLogger.LogTrace("TypingIndicator: drew nameplate bubble for {uid} (objectId={objectId}, scope={scope})", uid, objectId, entry.Scope);
|
||||
continue;
|
||||
}
|
||||
|
||||
var hasWorldPosition = TryResolveWorldPosition(pair, entry.User, objectId, out var worldPos);
|
||||
var isNearby = hasWorldPosition && IsWithinRelevantDistance(worldPos);
|
||||
|
||||
if (!isRelevantMember && !isNearby)
|
||||
continue;
|
||||
|
||||
// For Party/CrossParty scope, do not draw fallback world icon for non-party even if nearby
|
||||
if (entry.Scope is TypingScope.Party or TypingScope.CrossParty)
|
||||
{
|
||||
if (!isPartyMember)
|
||||
continue;
|
||||
}
|
||||
|
||||
if (pair == null)
|
||||
{
|
||||
_typedLogger.LogTrace("TypingIndicator: no pair found for {uid}, attempting fallback", uid);
|
||||
}
|
||||
|
||||
_typedLogger.LogTrace("TypingIndicator: fallback draw for {uid} (objectId={objectId}, name={name}, ident={ident}, scope={scope})",
|
||||
uid, objectId, pairName, pairIdent, entry.Scope);
|
||||
|
||||
if (hasWorldPosition)
|
||||
{
|
||||
DrawWorldFallbackIcon(drawList, iconWrap, worldPos);
|
||||
_typedLogger.LogTrace("TypingIndicator: fallback world draw for {uid} at {pos}", uid, worldPos);
|
||||
}
|
||||
else
|
||||
{
|
||||
_typedLogger.LogTrace("TypingIndicator: could not resolve position for {uid}", uid);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private Vector2 GetConfiguredBubbleSize(float scaleX, float scaleY, bool isNameplateVisible, TypingIndicatorBubbleSize? overrideSize = null)
|
||||
{
|
||||
var sizeSetting = overrideSize ?? _configService.Current.TypingIndicatorBubbleSize;
|
||||
var baseSize = sizeSetting switch
|
||||
{
|
||||
TypingIndicatorBubbleSize.Small when isNameplateVisible => 32f,
|
||||
TypingIndicatorBubbleSize.Medium when isNameplateVisible => 44f,
|
||||
TypingIndicatorBubbleSize.Large when isNameplateVisible => 56f,
|
||||
TypingIndicatorBubbleSize.Small => 15f,
|
||||
TypingIndicatorBubbleSize.Medium => 25f,
|
||||
TypingIndicatorBubbleSize.Large => 35f,
|
||||
_ => 35f,
|
||||
};
|
||||
|
||||
return new Vector2(baseSize * scaleX, baseSize * scaleY);
|
||||
}
|
||||
|
||||
private unsafe bool TryDrawNameplateBubble(ImDrawListPtr drawList, IDalamudTextureWrap textureWrap, uint objectId)
|
||||
{
|
||||
if (textureWrap == null || textureWrap.Handle == IntPtr.Zero)
|
||||
return false;
|
||||
|
||||
var framework = Framework.Instance();
|
||||
if (framework == null)
|
||||
return false;
|
||||
|
||||
var ui3D = framework->GetUIModule()->GetUI3DModule();
|
||||
if (ui3D == null)
|
||||
return false;
|
||||
|
||||
var addonNamePlate = (AddonNamePlate*)_gameGui.GetAddonByName("NamePlate", 1).Address;
|
||||
if (addonNamePlate == null)
|
||||
return false;
|
||||
|
||||
AddonNamePlate.NamePlateObject* namePlate = null;
|
||||
float distance = 0f;
|
||||
|
||||
for (var i = 0; i < ui3D->NamePlateObjectInfoCount; i++)
|
||||
{
|
||||
var objectInfo = ui3D->NamePlateObjectInfoPointers[i];
|
||||
if (objectInfo.Value == null || objectInfo.Value->GameObject == null)
|
||||
continue;
|
||||
|
||||
if (objectInfo.Value->GameObject->EntityId != objectId)
|
||||
continue;
|
||||
|
||||
if (objectInfo.Value->GameObject->YalmDistanceFromPlayerX > 35f)
|
||||
return false;
|
||||
|
||||
namePlate = &addonNamePlate->NamePlateObjectArray[objectInfo.Value->NamePlateIndex];
|
||||
distance = objectInfo.Value->GameObject->YalmDistanceFromPlayerX;
|
||||
break;
|
||||
}
|
||||
|
||||
if (namePlate == null || namePlate->RootComponentNode == null)
|
||||
return false;
|
||||
|
||||
var iconNode = namePlate->RootComponentNode->Component->UldManager.NodeList[0];
|
||||
if (iconNode == null)
|
||||
return false;
|
||||
|
||||
var scaleX = namePlate->RootComponentNode->AtkResNode.ScaleX;
|
||||
var scaleY = namePlate->RootComponentNode->AtkResNode.ScaleY;
|
||||
var iconVisible = iconNode->IsVisible();
|
||||
var sizeScaleFactor = 1f;
|
||||
var scaleVector = new Vector2(scaleX, scaleY);
|
||||
var rootPosition = new Vector2(namePlate->RootComponentNode->AtkResNode.X, namePlate->RootComponentNode->AtkResNode.Y);
|
||||
var iconLocalPosition = new Vector2(iconNode->X, iconNode->Y) * scaleVector;
|
||||
var iconDimensions = new Vector2(iconNode->Width, iconNode->Height) * scaleVector;
|
||||
|
||||
if (!iconVisible)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
var iconPos = rootPosition + iconLocalPosition + new Vector2(iconDimensions.X, 0f);
|
||||
|
||||
var iconOffset = new Vector2(distance / 1.5f, distance / 3.5f) * scaleVector;
|
||||
if (iconNode->Height == 24)
|
||||
{
|
||||
iconOffset.Y -= 8f * scaleY;
|
||||
}
|
||||
|
||||
iconPos += iconOffset;
|
||||
|
||||
var iconSize = GetConfiguredBubbleSize(scaleX * sizeScaleFactor, scaleY * sizeScaleFactor, true);
|
||||
|
||||
drawList.AddImage(textureWrap.Handle, iconPos, iconPos + iconSize, Vector2.Zero, Vector2.One,
|
||||
ImGui.ColorConvertFloat4ToU32(new Vector4(1f, 1f, 1f, 0.95f)));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private void DrawWorldFallbackIcon(ImDrawListPtr drawList, IDalamudTextureWrap textureWrap, Vector3 worldPosition)
|
||||
{
|
||||
var offsetPosition = worldPosition + new Vector3(0f, 1.8f, 0f);
|
||||
if (!_gameGui.WorldToScreen(offsetPosition, out var screenPos))
|
||||
return;
|
||||
|
||||
var iconSize = GetConfiguredBubbleSize(ImGuiHelpers.GlobalScale, ImGuiHelpers.GlobalScale, false);
|
||||
var iconPos = screenPos - (iconSize / 2f) - new Vector2(0f, iconSize.Y * 0.6f);
|
||||
drawList.AddImage(textureWrap.Handle, iconPos, iconPos + iconSize, Vector2.Zero, Vector2.One,
|
||||
ImGui.ColorConvertFloat4ToU32(new Vector4(1f, 1f, 1f, 0.95f)));
|
||||
}
|
||||
|
||||
private bool TryGetWorldPosition(uint objectId, out Vector3 position)
|
||||
{
|
||||
position = Vector3.Zero;
|
||||
if (objectId == 0 || objectId == uint.MaxValue)
|
||||
return false;
|
||||
|
||||
foreach (var obj in _objectTable)
|
||||
{
|
||||
if (obj?.EntityId == objectId)
|
||||
{
|
||||
position = obj.Position;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private bool TryResolveWorldPosition(Pair? pair, UserData userData, uint objectId, out Vector3 position)
|
||||
{
|
||||
if (TryGetWorldPosition(objectId, out position))
|
||||
{
|
||||
_typedLogger.LogTrace("TypingIndicator: resolved by objectId {objectId}", objectId);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (pair != null)
|
||||
{
|
||||
var name = pair.PlayerName;
|
||||
if (!string.IsNullOrEmpty(name) && TryGetWorldPositionByName(name!, out position))
|
||||
{
|
||||
_typedLogger.LogTrace("TypingIndicator: resolved by pair name {name}", name);
|
||||
return true;
|
||||
}
|
||||
|
||||
var ident = pair.Ident;
|
||||
if (!string.IsNullOrEmpty(ident))
|
||||
{
|
||||
var cached = _dalamudUtil.FindPlayerByNameHash(ident);
|
||||
if (!string.IsNullOrEmpty(cached.Name) && TryGetWorldPositionByName(cached.Name, out position))
|
||||
{
|
||||
_typedLogger.LogTrace("TypingIndicator: resolved by cached name {name}", cached.Name);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (cached.Address != IntPtr.Zero)
|
||||
{
|
||||
var objRef = _objectTable.CreateObjectReference(cached.Address);
|
||||
if (objRef != null)
|
||||
{
|
||||
position = objRef.Position;
|
||||
_typedLogger.LogTrace("TypingIndicator: resolved by cached address {addr}", cached.Address);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var alias = userData.AliasOrUID;
|
||||
if (!string.IsNullOrEmpty(alias) && TryGetWorldPositionByName(alias, out position))
|
||||
{
|
||||
_typedLogger.LogTrace("TypingIndicator: resolved by user alias {alias}", alias);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private bool TryGetWorldPositionByName(string name, out Vector3 position)
|
||||
{
|
||||
position = Vector3.Zero;
|
||||
foreach (var obj in _objectTable)
|
||||
{
|
||||
if (obj != null && obj.Name.TextValue.Equals(name, StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
position = obj.Position;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private int GetPartyIndexForObjectId(uint objectId)
|
||||
{
|
||||
for (var i = 0; i < _partyList.Count; ++i)
|
||||
{
|
||||
var member = _partyList[i];
|
||||
if (member == null) continue;
|
||||
|
||||
var gameObject = member.GameObject;
|
||||
if (gameObject != null && GetEntityId(gameObject.Address) == objectId)
|
||||
return i;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
private int GetPartyIndexForName(string name)
|
||||
{
|
||||
for (var i = 0; i < _partyList.Count; ++i)
|
||||
{
|
||||
var member = _partyList[i];
|
||||
if (member?.Name == null) continue;
|
||||
|
||||
if (member.Name.TextValue.Equals(name, StringComparison.OrdinalIgnoreCase))
|
||||
return i;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
private bool IsPartyMember(uint objectId, string? playerName)
|
||||
{
|
||||
if (objectId != 0 && objectId != uint.MaxValue && GetPartyIndexForObjectId(objectId) >= 0)
|
||||
return true;
|
||||
|
||||
if (!string.IsNullOrEmpty(playerName) && GetPartyIndexForName(playerName) >= 0)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private bool IsPlayerRelevant(Pair? pair, bool isPartyMember)
|
||||
{
|
||||
if (isPartyMember)
|
||||
return true;
|
||||
|
||||
if (pair?.UserPair != null)
|
||||
{
|
||||
var userPair = pair.UserPair;
|
||||
if (userPair.OtherPermissions.IsPaired() || userPair.OwnPermissions.IsPaired())
|
||||
return true;
|
||||
}
|
||||
|
||||
if (pair?.GroupPair != null && pair.GroupPair.Any(g =>
|
||||
!g.Value.GroupUserPermissions.IsPaused() &&
|
||||
!g.Key.GroupUserPermissions.IsPaused()))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private bool IsWithinRelevantDistance(Vector3 position)
|
||||
{
|
||||
if (_clientState.LocalPlayer == null)
|
||||
return false;
|
||||
|
||||
var distance = Vector3.Distance(_clientState.LocalPlayer.Position, position);
|
||||
return distance <= 40f;
|
||||
}
|
||||
|
||||
private static unsafe uint GetEntityId(nint address)
|
||||
{
|
||||
if (address == nint.Zero) return 0;
|
||||
return ((FFXIVClientStructs.FFXIV.Client.Game.Object.GameObject*)address)->EntityId;
|
||||
}
|
||||
}
|
||||
@@ -12,7 +12,6 @@ using Dalamud.Plugin.Services;
|
||||
using Dalamud.Utility;
|
||||
using MareSynchronos.FileCache;
|
||||
using MareSynchronos.Interop.Ipc;
|
||||
using MareSynchronos.Localization;
|
||||
using MareSynchronos.MareConfiguration;
|
||||
using MareSynchronos.MareConfiguration.Models;
|
||||
using MareSynchronos.PlayerData.Pairs;
|
||||
@@ -21,7 +20,8 @@ using MareSynchronos.Services.Mediator;
|
||||
using MareSynchronos.Services.ServerConfiguration;
|
||||
using MareSynchronos.WebAPI;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System.Globalization;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Numerics;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
@@ -38,7 +38,11 @@ public partial class UiSharedService : DisposableMediatorSubscriberBase
|
||||
ImGuiWindowFlags.NoScrollbar |
|
||||
ImGuiWindowFlags.NoScrollWithMouse;
|
||||
|
||||
public const float ContentFontScale = 0.92f;
|
||||
|
||||
public static Vector4 AccentColor { get; set; } = ImGuiColors.DalamudViolet;
|
||||
public static Vector4 AccentHoverColor { get; set; } = new Vector4(0x3A / 255f, 0x15 / 255f, 0x50 / 255f, 1f);
|
||||
public static Vector4 AccentActiveColor { get; set; } = AccentHoverColor;
|
||||
|
||||
public readonly FileDialogManager FileDialogManager;
|
||||
|
||||
@@ -55,11 +59,12 @@ public partial class UiSharedService : DisposableMediatorSubscriberBase
|
||||
private readonly DalamudUtilService _dalamudUtil;
|
||||
private readonly IpcManager _ipcManager;
|
||||
private readonly IDalamudPluginInterface _pluginInterface;
|
||||
private readonly LocalizationService _localizationService;
|
||||
private readonly ITextureProvider _textureProvider;
|
||||
private readonly Dictionary<string, object> _selectedComboItems = new(StringComparer.Ordinal);
|
||||
private readonly ServerConfigurationManager _serverConfigurationManager;
|
||||
private bool _cacheDirectoryHasOtherFilesThanCache = false;
|
||||
private static readonly Stack<float> _fontScaleStack = new();
|
||||
private static float _currentWindowFontScale = 1f;
|
||||
|
||||
private bool _cacheDirectoryIsValidPath = true;
|
||||
|
||||
@@ -87,7 +92,7 @@ public partial class UiSharedService : DisposableMediatorSubscriberBase
|
||||
public UiSharedService(ILogger<UiSharedService> logger, IpcManager ipcManager, ApiController apiController,
|
||||
CacheMonitor cacheMonitor, FileDialogManager fileDialogManager,
|
||||
MareConfigService configService, DalamudUtilService dalamudUtil, IDalamudPluginInterface pluginInterface,
|
||||
LocalizationService localizationService, ITextureProvider textureProvider,
|
||||
ITextureProvider textureProvider,
|
||||
ServerConfigurationManager serverManager, MareMediator mediator) : base(logger, mediator)
|
||||
{
|
||||
_ipcManager = ipcManager;
|
||||
@@ -97,7 +102,6 @@ public partial class UiSharedService : DisposableMediatorSubscriberBase
|
||||
_configService = configService;
|
||||
_dalamudUtil = dalamudUtil;
|
||||
_pluginInterface = pluginInterface;
|
||||
_localizationService = localizationService;
|
||||
_textureProvider = textureProvider;
|
||||
_serverConfigurationManager = serverManager;
|
||||
|
||||
@@ -119,8 +123,12 @@ public partial class UiSharedService : DisposableMediatorSubscriberBase
|
||||
{
|
||||
e.OnPreBuild(tk => tk.AddDalamudAssetFont(Dalamud.DalamudAsset.NotoSansJpMedium, new()
|
||||
{
|
||||
SizePx = 35,
|
||||
GlyphRanges = [0x20, 0x7E, 0]
|
||||
SizePx = 27,
|
||||
GlyphRanges = [
|
||||
0x0020, 0x007E,
|
||||
0x00A0, 0x017F,
|
||||
0
|
||||
]
|
||||
}));
|
||||
});
|
||||
GameFont = _pluginInterface.UiBuilder.FontAtlas.NewGameFontHandle(new(GameFontFamilyAndSize.Axis12));
|
||||
@@ -128,10 +136,6 @@ public partial class UiSharedService : DisposableMediatorSubscriberBase
|
||||
}
|
||||
|
||||
public ApiController ApiController => _apiController;
|
||||
public LocalizationService Localization => _localizationService;
|
||||
|
||||
public string Localize(string key, string fallback, params object[] args) => _localizationService.GetString(key, fallback, args);
|
||||
public string Localize(string fallback, params object[] args) => _localizationService.GetString(fallback, args);
|
||||
|
||||
public bool EditTrackerPosition { get; set; }
|
||||
|
||||
@@ -144,6 +148,7 @@ public partial class UiSharedService : DisposableMediatorSubscriberBase
|
||||
public string PlayerName => _dalamudUtil.GetPlayerName();
|
||||
|
||||
public IFontHandle UidFont { get; init; }
|
||||
public MareConfigService ConfigService => _configService;
|
||||
public Dictionary<ushort, string> WorldData => _dalamudUtil.WorldData.Value;
|
||||
|
||||
public uint WorldId => _dalamudUtil.GetHomeWorldId();
|
||||
@@ -221,7 +226,38 @@ public partial class UiSharedService : DisposableMediatorSubscriberBase
|
||||
|
||||
public static bool CtrlPressed() => (GetKeyState(0xA2) & 0x8000) != 0 || (GetKeyState(0xA3) & 0x8000) != 0;
|
||||
|
||||
public static void DrawGrouped(Action imguiDrawAction, float rounding = 5f, float? expectedWidth = null)
|
||||
public static IDisposable PushFontScale(float scale)
|
||||
{
|
||||
var previous = _currentWindowFontScale;
|
||||
_fontScaleStack.Push(previous);
|
||||
if (Math.Abs(previous - scale) > float.Epsilon)
|
||||
{
|
||||
SetFontScale(scale);
|
||||
}
|
||||
|
||||
return new FontScaleScope();
|
||||
}
|
||||
|
||||
private sealed class FontScaleScope : IDisposable
|
||||
{
|
||||
public void Dispose()
|
||||
{
|
||||
if (_fontScaleStack.Count == 0) return;
|
||||
var previous = _fontScaleStack.Pop();
|
||||
if (Math.Abs(previous - _currentWindowFontScale) > float.Epsilon)
|
||||
{
|
||||
SetFontScale(previous);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void SetFontScale(float scale)
|
||||
{
|
||||
ImGui.SetWindowFontScale(scale);
|
||||
_currentWindowFontScale = scale;
|
||||
}
|
||||
|
||||
public static void DrawGrouped(Action imguiDrawAction, float rounding = 5f, float? expectedWidth = null, bool drawBorder = true)
|
||||
{
|
||||
var cursorPos = ImGui.GetCursorPos();
|
||||
using (ImRaii.Group())
|
||||
@@ -235,11 +271,129 @@ public partial class UiSharedService : DisposableMediatorSubscriberBase
|
||||
imguiDrawAction.Invoke();
|
||||
}
|
||||
|
||||
if (drawBorder)
|
||||
{
|
||||
ImGui.GetWindowDrawList().AddRect(
|
||||
ImGui.GetItemRectMin() - ImGui.GetStyle().ItemInnerSpacing,
|
||||
ImGui.GetItemRectMax() + ImGui.GetStyle().ItemInnerSpacing,
|
||||
Color(ImGuiColors.DalamudGrey2), rounding);
|
||||
}
|
||||
}
|
||||
|
||||
public static void DrawCard(string id, Action draw, Vector2? padding = null, Vector4? background = null,
|
||||
Vector4? border = null, float? rounding = null, bool stretchWidth = false)
|
||||
{
|
||||
var style = ImGui.GetStyle();
|
||||
var padBase = style.FramePadding;
|
||||
var pad = padding ?? new Vector2(
|
||||
padBase.X + 4f * ImGuiHelpers.GlobalScale,
|
||||
padBase.Y + 3f * ImGuiHelpers.GlobalScale);
|
||||
var cardBg = background ?? new Vector4(0.08f, 0.08f, 0.10f, 0.94f);
|
||||
var cardBorder = border ?? new Vector4(0f, 0f, 0f, 0.85f);
|
||||
float cardRounding = rounding ?? Math.Max(style.FrameRounding, 8f * ImGuiHelpers.GlobalScale);
|
||||
float borderThickness = Math.Max(1f, Math.Max(style.FrameBorderSize, 1f) * ImGuiHelpers.GlobalScale);
|
||||
float borderInset = borderThickness;
|
||||
|
||||
var originalCursor = ImGui.GetCursorPos();
|
||||
if (stretchWidth)
|
||||
{
|
||||
ImGui.SetCursorPosX(ImGui.GetWindowContentRegionMin().X);
|
||||
}
|
||||
|
||||
var startCursor = ImGui.GetCursorPos();
|
||||
var drawList = ImGui.GetWindowDrawList();
|
||||
drawList.ChannelsSplit(2);
|
||||
drawList.ChannelsSetCurrent(1);
|
||||
|
||||
ImGui.PushID(id);
|
||||
ImGui.SetCursorPos(new Vector2(startCursor.X + pad.X, startCursor.Y + pad.Y));
|
||||
ImGui.BeginGroup();
|
||||
draw();
|
||||
ImGui.EndGroup();
|
||||
ImGui.PopID();
|
||||
|
||||
var contentMin = ImGui.GetItemRectMin();
|
||||
var contentMax = ImGui.GetItemRectMax();
|
||||
var cardMin = contentMin - pad;
|
||||
var cardMax = contentMax + pad;
|
||||
var outerMin = cardMin;
|
||||
var outerMax = cardMax;
|
||||
|
||||
if (stretchWidth)
|
||||
{
|
||||
var windowPos = ImGui.GetWindowPos();
|
||||
var regionMin = ImGui.GetWindowContentRegionMin();
|
||||
var regionMax = ImGui.GetWindowContentRegionMax();
|
||||
var scrollX = ImGui.GetScrollX();
|
||||
cardMin.X = windowPos.X + regionMin.X + scrollX;
|
||||
cardMax.X = windowPos.X + regionMax.X + scrollX;
|
||||
outerMin.X = cardMin.X;
|
||||
outerMax.X = cardMax.X;
|
||||
startCursor.X = ImGui.GetWindowContentRegionMin().X;
|
||||
}
|
||||
|
||||
var drawMin = new Vector2(cardMin.X + borderInset, cardMin.Y + borderInset);
|
||||
var drawMax = new Vector2(cardMax.X - borderInset, cardMax.Y - borderInset);
|
||||
var clipMin = drawList.GetClipRectMin();
|
||||
var clipMax = drawList.GetClipRectMax();
|
||||
var clipInset = new Vector2(borderThickness * 0.5f + 0.5f, borderThickness * 0.5f + 0.5f);
|
||||
drawMin = Vector2.Max(drawMin, clipMin + clipInset);
|
||||
drawMax = Vector2.Min(drawMax, clipMax - clipInset);
|
||||
if (drawMax.X <= drawMin.X)
|
||||
{
|
||||
drawMax.X = drawMin.X + borderThickness;
|
||||
}
|
||||
if (drawMax.Y <= drawMin.Y)
|
||||
{
|
||||
drawMax.Y = drawMin.Y + borderThickness;
|
||||
}
|
||||
|
||||
drawList.ChannelsSetCurrent(0);
|
||||
drawList.AddRectFilled(drawMin, drawMax, ImGui.ColorConvertFloat4ToU32(cardBg), cardRounding);
|
||||
if (cardBorder.W > 0f && borderThickness > 0f)
|
||||
{
|
||||
drawList.AddRect(drawMin, drawMax, ImGui.ColorConvertFloat4ToU32(cardBorder), cardRounding, ImDrawFlags.None, borderThickness);
|
||||
}
|
||||
drawList.ChannelsMerge();
|
||||
|
||||
ImGui.SetCursorPos(startCursor);
|
||||
var dummyWidth = outerMax.X - outerMin.X;
|
||||
var dummyHeight = outerMax.Y - outerMin.Y;
|
||||
ImGui.Dummy(new Vector2(dummyWidth, dummyHeight));
|
||||
ImGui.SetCursorPos(new Vector2(startCursor.X, startCursor.Y + dummyHeight));
|
||||
|
||||
if (!stretchWidth)
|
||||
{
|
||||
ImGui.SetCursorPosX(originalCursor.X);
|
||||
}
|
||||
else
|
||||
{
|
||||
ImGui.SetCursorPosX(startCursor.X);
|
||||
}
|
||||
}
|
||||
|
||||
public static bool DrawArrowToggle(ref bool state, string id)
|
||||
{
|
||||
var framePadding = ImGui.GetStyle().FramePadding;
|
||||
ImGui.PushStyleVar(ImGuiStyleVar.FramePadding, new Vector2(framePadding.X, framePadding.Y * 0.85f));
|
||||
ImGui.PushStyleColor(ImGuiCol.Button, Vector4.Zero);
|
||||
ImGui.PushStyleColor(ImGuiCol.ButtonHovered, new Vector4(1f, 1f, 1f, 0.08f));
|
||||
ImGui.PushStyleColor(ImGuiCol.ButtonActive, new Vector4(1f, 1f, 1f, 0.16f));
|
||||
bool clicked = ImGui.ArrowButton(id, state ? ImGuiDir.Down : ImGuiDir.Right);
|
||||
ImGui.PopStyleColor(3);
|
||||
ImGui.PopStyleVar();
|
||||
if (clicked)
|
||||
{
|
||||
state = !state;
|
||||
}
|
||||
return state;
|
||||
}
|
||||
|
||||
public static float GetCardContentPaddingX()
|
||||
{
|
||||
var style = ImGui.GetStyle();
|
||||
return style.FramePadding.X + 4f * ImGuiHelpers.GlobalScale;
|
||||
}
|
||||
|
||||
public static void DrawGroupedCenteredColorText(string text, Vector4 color, float? maxWidth = null)
|
||||
{
|
||||
@@ -318,7 +472,7 @@ public partial class UiSharedService : DisposableMediatorSubscriberBase
|
||||
}
|
||||
}
|
||||
|
||||
public static Vector4 GetBoolColor(bool input) => input ? AccentColor : ImGuiColors.DalamudRed;
|
||||
public static Vector4 GetBoolColor(bool input) => input ? AccentColor : UiSharedService.AccentColor;
|
||||
|
||||
public float GetIconTextButtonSize(FontAwesomeIcon icon, string text)
|
||||
{
|
||||
@@ -376,6 +530,8 @@ public partial class UiSharedService : DisposableMediatorSubscriberBase
|
||||
Vector2 cursorScreenPos = ImGui.GetCursorScreenPos();
|
||||
float x = vector.X + ImGui.GetStyle().FramePadding.X * 2f;
|
||||
float frameHeight = height ?? ImGui.GetFrameHeight();
|
||||
using var hoverColor = ImRaii.PushColor(ImGuiCol.ButtonHovered, AccentHoverColor);
|
||||
using var activeColor = ImRaii.PushColor(ImGuiCol.ButtonActive, AccentActiveColor);
|
||||
bool result = ImGui.Button(string.Empty, new Vector2(x, frameHeight));
|
||||
Vector2 pos = new Vector2(cursorScreenPos.X + ImGui.GetStyle().FramePadding.X,
|
||||
cursorScreenPos.Y + (height ?? ImGui.GetFrameHeight()) / 2f - (vector.Y / 2f));
|
||||
@@ -386,13 +542,113 @@ public partial class UiSharedService : DisposableMediatorSubscriberBase
|
||||
return result;
|
||||
}
|
||||
|
||||
private bool IconTextButtonInternal(FontAwesomeIcon icon, string text, Vector4? defaultColor = null, float? width = null)
|
||||
public bool IconButtonCentered(FontAwesomeIcon icon, float? height = null, float xOffset = 0f, float yOffset = 0f, bool square = false)
|
||||
{
|
||||
int num = 0;
|
||||
string text = icon.ToIconString();
|
||||
|
||||
ImGui.PushID($"centered-{text}");
|
||||
Vector2 glyphSize;
|
||||
using (IconFont.Push())
|
||||
glyphSize = ImGui.CalcTextSize(text);
|
||||
ImDrawListPtr drawList = ImGui.GetWindowDrawList();
|
||||
Vector2 cursorScreenPos = ImGui.GetCursorScreenPos();
|
||||
float frameHeight = height ?? ImGui.GetFrameHeight();
|
||||
float buttonWidth = square ? frameHeight : glyphSize.X + ImGui.GetStyle().FramePadding.X * 2f;
|
||||
using var hoverColor = ImRaii.PushColor(ImGuiCol.ButtonHovered, AccentHoverColor);
|
||||
using var activeColor = ImRaii.PushColor(ImGuiCol.ButtonActive, AccentActiveColor);
|
||||
bool clicked = ImGui.Button(string.Empty, new Vector2(buttonWidth, frameHeight));
|
||||
Vector2 pos = new Vector2(
|
||||
cursorScreenPos.X + (buttonWidth - glyphSize.X) / 2f + xOffset,
|
||||
cursorScreenPos.Y + frameHeight / 2f - glyphSize.Y / 2f + yOffset);
|
||||
using (IconFont.Push())
|
||||
drawList.AddText(pos, ImGui.GetColorU32(ImGuiCol.Text), text);
|
||||
ImGui.PopID();
|
||||
|
||||
return clicked;
|
||||
}
|
||||
public bool IconPauseButtonCentered(float? height = null)
|
||||
{
|
||||
ImGui.PushID("centered-pause-custom");
|
||||
Vector2 glyphSize;
|
||||
using (IconFont.Push())
|
||||
glyphSize = ImGui.CalcTextSize(FontAwesomeIcon.Pause.ToIconString());
|
||||
float frameHeight = height ?? ImGui.GetFrameHeight();
|
||||
float buttonWidth = glyphSize.X + ImGui.GetStyle().FramePadding.X * 2f;
|
||||
|
||||
using var hoverColor = ImRaii.PushColor(ImGuiCol.ButtonHovered, AccentHoverColor);
|
||||
using var activeColor = ImRaii.PushColor(ImGuiCol.ButtonActive, AccentActiveColor);
|
||||
|
||||
var drawList = ImGui.GetWindowDrawList();
|
||||
var buttonTopLeft = ImGui.GetCursorScreenPos();
|
||||
bool clicked = ImGui.Button(string.Empty, new Vector2(buttonWidth, frameHeight));
|
||||
|
||||
var textColor = ImGui.GetColorU32(ImGuiCol.Text);
|
||||
|
||||
float h = frameHeight * 0.55f; // bar height
|
||||
float w = MathF.Max(1f, frameHeight * 0.16f); // bar width
|
||||
float gap = MathF.Max(1f, w * 0.9f); // gap between bars
|
||||
float total = 2f * w + gap;
|
||||
|
||||
float startX = buttonTopLeft.X + (buttonWidth - total) / 2f;
|
||||
float startY = buttonTopLeft.Y + (frameHeight - h) / 2f;
|
||||
float rounding = w * 0.35f;
|
||||
|
||||
drawList.AddRectFilled(new Vector2(startX, startY), new Vector2(startX + w, startY + h), textColor, rounding);
|
||||
float rightX = startX + w + gap;
|
||||
drawList.AddRectFilled(new Vector2(rightX, startY), new Vector2(rightX + w, startY + h), textColor, rounding);
|
||||
|
||||
ImGui.PopID();
|
||||
return clicked;
|
||||
}
|
||||
|
||||
public bool IconPlusButtonCentered(float? height = null)
|
||||
{
|
||||
ImGui.PushID("centered-plus-custom");
|
||||
Vector2 glyphSize;
|
||||
using (IconFont.Push())
|
||||
glyphSize = ImGui.CalcTextSize(FontAwesomeIcon.Plus.ToIconString());
|
||||
float frameHeight = height ?? ImGui.GetFrameHeight();
|
||||
float buttonWidth = glyphSize.X + ImGui.GetStyle().FramePadding.X * 2f;
|
||||
|
||||
using var hoverColor = ImRaii.PushColor(ImGuiCol.ButtonHovered, AccentHoverColor);
|
||||
using var activeColor = ImRaii.PushColor(ImGuiCol.ButtonActive, AccentActiveColor);
|
||||
|
||||
var drawList = ImGui.GetWindowDrawList();
|
||||
var buttonTopLeft = ImGui.GetCursorScreenPos();
|
||||
bool clicked = ImGui.Button(string.Empty, new Vector2(buttonWidth, frameHeight));
|
||||
|
||||
var color = ImGui.GetColorU32(ImGuiCol.Text);
|
||||
|
||||
float armThickness = MathF.Max(1f, frameHeight * 0.14f);
|
||||
float crossSize = frameHeight * 0.55f; // total length of vertical/horizontal arms
|
||||
float startX = buttonTopLeft.X + (buttonWidth - crossSize) / 2f;
|
||||
float startY = buttonTopLeft.Y + (frameHeight - crossSize) / 2f;
|
||||
float endX = startX + crossSize;
|
||||
float endY = startY + crossSize;
|
||||
float r = armThickness * 0.35f;
|
||||
|
||||
float hY1 = startY + (crossSize - armThickness) / 2f;
|
||||
drawList.AddRectFilled(new Vector2(startX, hY1), new Vector2(endX, hY1 + armThickness), color, r);
|
||||
float vX1 = startX + (crossSize - armThickness) / 2f;
|
||||
drawList.AddRectFilled(new Vector2(vX1, startY), new Vector2(vX1 + armThickness, endY), color, r);
|
||||
|
||||
ImGui.PopID();
|
||||
return clicked;
|
||||
}
|
||||
|
||||
private bool IconTextButtonInternal(FontAwesomeIcon icon, string text, Vector4? defaultColor = null, float? width = null, bool useAccentHover = true)
|
||||
{
|
||||
int colorsPushed = 0;
|
||||
if (defaultColor.HasValue)
|
||||
{
|
||||
ImGui.PushStyleColor(ImGuiCol.Button, defaultColor.Value);
|
||||
num++;
|
||||
colorsPushed++;
|
||||
}
|
||||
if (useAccentHover)
|
||||
{
|
||||
ImGui.PushStyleColor(ImGuiCol.ButtonHovered, AccentHoverColor);
|
||||
ImGui.PushStyleColor(ImGuiCol.ButtonActive, AccentActiveColor);
|
||||
colorsPushed += 2;
|
||||
}
|
||||
|
||||
ImGui.PushID(text);
|
||||
@@ -412,9 +668,9 @@ public partial class UiSharedService : DisposableMediatorSubscriberBase
|
||||
Vector2 pos2 = new Vector2(pos.X + vector.X + num2, cursorScreenPos.Y + ImGui.GetStyle().FramePadding.Y);
|
||||
windowDrawList.AddText(pos2, ImGui.GetColorU32(ImGuiCol.Text), text);
|
||||
ImGui.PopID();
|
||||
if (num > 0)
|
||||
if (colorsPushed > 0)
|
||||
{
|
||||
ImGui.PopStyleColor(num);
|
||||
ImGui.PopStyleColor(colorsPushed);
|
||||
}
|
||||
|
||||
return result;
|
||||
@@ -424,7 +680,8 @@ public partial class UiSharedService : DisposableMediatorSubscriberBase
|
||||
{
|
||||
return IconTextButtonInternal(icon, text,
|
||||
isInPopup ? ColorHelpers.RgbaUintToVector4(ImGui.GetColorU32(ImGuiCol.PopupBg)) : null,
|
||||
width <= 0 ? null : width);
|
||||
width <= 0 ? null : width,
|
||||
!isInPopup);
|
||||
}
|
||||
|
||||
public static bool IsDirectoryWritable(string dirPath, bool throwIfFails = false)
|
||||
@@ -526,7 +783,7 @@ public partial class UiSharedService : DisposableMediatorSubscriberBase
|
||||
public void BooleanToColoredIcon(bool value, bool inline = true)
|
||||
{
|
||||
using var colorgreen = ImRaii.PushColor(ImGuiCol.Text, AccentColor, value);
|
||||
using var colorred = ImRaii.PushColor(ImGuiCol.Text, ImGuiColors.DalamudRed, !value);
|
||||
using var colorred = ImRaii.PushColor(ImGuiCol.Text, UiSharedService.AccentColor, !value);
|
||||
|
||||
if (inline) ImGui.SameLine();
|
||||
|
||||
@@ -600,24 +857,24 @@ public partial class UiSharedService : DisposableMediatorSubscriberBase
|
||||
|
||||
if (_isPenumbraDirectory)
|
||||
{
|
||||
ColorTextWrapped("Do not point the storage path directly to the Penumbra directory. If necessary, make a subfolder in it.", ImGuiColors.DalamudRed);
|
||||
ColorTextWrapped("Do not point the storage path directly to the Penumbra directory. If necessary, make a subfolder in it.", UiSharedService.AccentColor);
|
||||
}
|
||||
else if (_isOneDrive)
|
||||
{
|
||||
ColorTextWrapped("Do not point the storage path to a folder in OneDrive. Do not use OneDrive folders for any Mod related functionality.", ImGuiColors.DalamudRed);
|
||||
ColorTextWrapped("Do not point the storage path to a folder in OneDrive. Do not use OneDrive folders for any Mod related functionality.", UiSharedService.AccentColor);
|
||||
}
|
||||
else if (!_isDirectoryWritable)
|
||||
{
|
||||
ColorTextWrapped("The folder you selected does not exist or cannot be written to. Please provide a valid path.", ImGuiColors.DalamudRed);
|
||||
ColorTextWrapped("The folder you selected does not exist or cannot be written to. Please provide a valid path.", UiSharedService.AccentColor);
|
||||
}
|
||||
else if (_cacheDirectoryHasOtherFilesThanCache)
|
||||
{
|
||||
ColorTextWrapped("Your selected directory has files or directories inside that are not Umbra related. Use an empty directory or a previous storage directory only.", ImGuiColors.DalamudRed);
|
||||
ColorTextWrapped("Your selected directory has files or directories inside that are not Umbra related. Use an empty directory or a previous storage directory only.", UiSharedService.AccentColor);
|
||||
}
|
||||
else if (!_cacheDirectoryIsValidPath)
|
||||
{
|
||||
ColorTextWrapped("Your selected directory contains illegal characters unreadable by FFXIV. " +
|
||||
"Restrict yourself to latin letters (A-Z), underscores (_), dashes (-) and arabic numbers (0-9).", ImGuiColors.DalamudRed);
|
||||
"Restrict yourself to latin letters (A-Z), underscores (_), dashes (-) and arabic numbers (0-9).", UiSharedService.AccentColor);
|
||||
}
|
||||
|
||||
float maxCacheSize = (float)_configService.Current.MaxLocalCacheInGiB;
|
||||
@@ -769,19 +1026,15 @@ public partial class UiSharedService : DisposableMediatorSubscriberBase
|
||||
var check = FontAwesomeIcon.Check;
|
||||
var cross = FontAwesomeIcon.SquareXmark;
|
||||
|
||||
var availableTemplate = Localize("Settings.Plugins.Tooltip.Available", "{0} is available and up to date.");
|
||||
var unavailableTemplate = Localize("Settings.Plugins.Tooltip.Unavailable", "{0} is unavailable or not up to date.");
|
||||
string FormatTooltip(bool exists, string pluginName) => string.Format(CultureInfo.CurrentCulture, exists ? availableTemplate : unavailableTemplate, pluginName);
|
||||
|
||||
if (intro)
|
||||
{
|
||||
ImGui.SetWindowFontScale(0.8f);
|
||||
BigText(Localize("Settings.Plugins.MandatoryHeading", "Mandatory Plugins"));
|
||||
ImGui.SetWindowFontScale(1.0f);
|
||||
SetFontScale(0.8f);
|
||||
BigText("Mandatory Plugins");
|
||||
SetFontScale(1.0f);
|
||||
}
|
||||
else
|
||||
{
|
||||
ImGui.TextUnformatted(Localize("Settings.Plugins.MandatoryLabel", "Mandatory Plugins:"));
|
||||
ImGui.TextUnformatted("Mandatory Plugins:");
|
||||
ImGui.SameLine();
|
||||
}
|
||||
|
||||
@@ -789,23 +1042,23 @@ public partial class UiSharedService : DisposableMediatorSubscriberBase
|
||||
ImGui.SameLine();
|
||||
IconText(_penumbraExists ? check : cross, GetBoolColor(_penumbraExists));
|
||||
ImGui.SameLine();
|
||||
AttachToolTip(FormatTooltip(_penumbraExists, "Penumbra"));
|
||||
AttachToolTip($"Penumbra is " + (_penumbraExists ? "available and up to date." : "unavailable or not up to date."));
|
||||
|
||||
ImGui.TextUnformatted("Glamourer");
|
||||
ImGui.SameLine();
|
||||
IconText(_glamourerExists ? check : cross, GetBoolColor(_glamourerExists));
|
||||
AttachToolTip(FormatTooltip(_glamourerExists, "Glamourer"));
|
||||
AttachToolTip($"Glamourer is " + (_glamourerExists ? "available and up to date." : "unavailable or not up to date."));
|
||||
|
||||
if (intro)
|
||||
{
|
||||
ImGui.SetWindowFontScale(0.8f);
|
||||
BigText(Localize("Settings.Plugins.OptionalHeading", "Optional Addons"));
|
||||
ImGui.SetWindowFontScale(1.0f);
|
||||
UiSharedService.TextWrapped(Localize("Settings.Plugins.OptionalDescription", "These addons are not required for basic operation, but without them you may not see others as intended."));
|
||||
SetFontScale(0.8f);
|
||||
BigText("Optional Addons");
|
||||
SetFontScale(1.0f);
|
||||
UiSharedService.TextWrapped("These addons are not required for basic operation, but without them you may not see others as intended.");
|
||||
}
|
||||
else
|
||||
{
|
||||
ImGui.TextUnformatted(Localize("Settings.Plugins.OptionalLabel", "Optional Addons:"));
|
||||
ImGui.TextUnformatted("Optional Addons:");
|
||||
ImGui.SameLine();
|
||||
}
|
||||
|
||||
@@ -815,7 +1068,7 @@ public partial class UiSharedService : DisposableMediatorSubscriberBase
|
||||
ImGui.SameLine();
|
||||
IconText(_heelsExists ? check : cross, GetBoolColor(_heelsExists));
|
||||
ImGui.SameLine();
|
||||
AttachToolTip(FormatTooltip(_heelsExists, "SimpleHeels"));
|
||||
AttachToolTip($"SimpleHeels is " + (_heelsExists ? "available and up to date." : "unavailable or not up to date."));
|
||||
ImGui.Spacing();
|
||||
|
||||
ImGui.SameLine();
|
||||
@@ -823,7 +1076,7 @@ public partial class UiSharedService : DisposableMediatorSubscriberBase
|
||||
ImGui.SameLine();
|
||||
IconText(_customizePlusExists ? check : cross, GetBoolColor(_customizePlusExists));
|
||||
ImGui.SameLine();
|
||||
AttachToolTip(FormatTooltip(_customizePlusExists, "Customize+"));
|
||||
AttachToolTip($"Customize+ is " + (_customizePlusExists ? "available and up to date." : "unavailable or not up to date."));
|
||||
ImGui.Spacing();
|
||||
|
||||
ImGui.SameLine();
|
||||
@@ -831,7 +1084,7 @@ public partial class UiSharedService : DisposableMediatorSubscriberBase
|
||||
ImGui.SameLine();
|
||||
IconText(_honorificExists ? check : cross, GetBoolColor(_honorificExists));
|
||||
ImGui.SameLine();
|
||||
AttachToolTip(FormatTooltip(_honorificExists, "Honorific"));
|
||||
AttachToolTip($"Honorific is " + (_honorificExists ? "available and up to date." : "unavailable or not up to date."));
|
||||
ImGui.Spacing();
|
||||
|
||||
ImGui.SameLine();
|
||||
@@ -839,7 +1092,7 @@ public partial class UiSharedService : DisposableMediatorSubscriberBase
|
||||
ImGui.SameLine();
|
||||
IconText(_petNamesExists ? check : cross, GetBoolColor(_petNamesExists));
|
||||
ImGui.SameLine();
|
||||
AttachToolTip(FormatTooltip(_petNamesExists, "PetNicknames"));
|
||||
AttachToolTip($"PetNicknames is " + (_petNamesExists ? "available and up to date." : "unavailable or not up to date."));
|
||||
ImGui.Spacing();
|
||||
|
||||
ImGui.SetCursorPosX(alignPos);
|
||||
@@ -847,7 +1100,7 @@ public partial class UiSharedService : DisposableMediatorSubscriberBase
|
||||
ImGui.SameLine();
|
||||
IconText(_moodlesExists ? check : cross, GetBoolColor(_moodlesExists));
|
||||
ImGui.SameLine();
|
||||
AttachToolTip(FormatTooltip(_moodlesExists, "Moodles"));
|
||||
AttachToolTip($"Moodles is " + (_moodlesExists ? "available and up to date." : "unavailable or not up to date."));
|
||||
ImGui.Spacing();
|
||||
|
||||
ImGui.SameLine();
|
||||
@@ -855,12 +1108,12 @@ public partial class UiSharedService : DisposableMediatorSubscriberBase
|
||||
ImGui.SameLine();
|
||||
IconText(_brioExists ? check : cross, GetBoolColor(_brioExists));
|
||||
ImGui.SameLine();
|
||||
AttachToolTip(FormatTooltip(_brioExists, "Brio"));
|
||||
AttachToolTip($"Brio is " + (_moodlesExists ? "available and up to date." : "unavailable or not up to date."));
|
||||
ImGui.Spacing();
|
||||
|
||||
if (!_penumbraExists || !_glamourerExists)
|
||||
{
|
||||
ImGui.TextColored(ImGuiColors.DalamudRed, Localize("Settings.Plugins.WarningMandatoryMissing", "You need to install both Penumbra and Glamourer and keep them up to date to use Umbra."));
|
||||
ImGui.TextColored(UiSharedService.AccentColor, "You need to install both Penumbra and Glamourer and keep them up to date to use Umbra.");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
namespace MareSynchronos.Utils;
|
||||
|
||||
public class PngHdr
|
||||
public static class PngHdr
|
||||
{
|
||||
private static readonly byte[] _magicSignature = [137, 80, 78, 71, 13, 10, 26, 10];
|
||||
private static readonly byte[] _IHDR = [(byte)'I', (byte)'H', (byte)'D', (byte)'R'];
|
||||
|
||||
@@ -4,7 +4,6 @@ using MareSynchronos.Services;
|
||||
using MareSynchronos.Services.ServerConfiguration;
|
||||
using MareSynchronos.Utils;
|
||||
using MareSynchronos.WebAPI.SignalR;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System.Net.Http.Headers;
|
||||
using System.Net.Http.Json;
|
||||
using System.Reflection;
|
||||
@@ -15,17 +14,15 @@ namespace MareSynchronos.WebAPI;
|
||||
public sealed class AccountRegistrationService : IDisposable
|
||||
{
|
||||
private readonly HttpClient _httpClient;
|
||||
private readonly ILogger<AccountRegistrationService> _logger;
|
||||
private readonly ServerConfigurationManager _serverManager;
|
||||
|
||||
private string GenerateSecretKey()
|
||||
private static string GenerateSecretKey()
|
||||
{
|
||||
return Convert.ToHexString(SHA256.HashData(RandomNumberGenerator.GetBytes(64)));
|
||||
}
|
||||
|
||||
public AccountRegistrationService(ILogger<AccountRegistrationService> logger, ServerConfigurationManager serverManager)
|
||||
public AccountRegistrationService(ServerConfigurationManager serverManager)
|
||||
{
|
||||
_logger = logger;
|
||||
_serverManager = serverManager;
|
||||
_httpClient = new(
|
||||
new HttpClientHandler
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using System.Net.Http.Headers;
|
||||
using System.Text;
|
||||
using System.Text.Json;
|
||||
using System.Text.Json.Serialization;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using MareSynchronos.WebAPI.SignalR;
|
||||
using MareSynchronos.Services.AutoDetect;
|
||||
@@ -65,15 +66,21 @@ public class DiscoveryApiClient
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<bool> SendRequestAsync(string endpoint, string token, string? displayName, CancellationToken ct)
|
||||
public async Task<bool> SendRequestAsync(string endpoint, string? token, string? targetUid, string? displayName, CancellationToken ct)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (string.IsNullOrEmpty(token) && string.IsNullOrEmpty(targetUid))
|
||||
{
|
||||
_logger.LogWarning("Discovery request aborted: no token or targetUid provided");
|
||||
return false;
|
||||
}
|
||||
|
||||
var jwt = await _tokenProvider.GetOrUpdateToken(ct).ConfigureAwait(false);
|
||||
if (string.IsNullOrEmpty(jwt)) return false;
|
||||
using var req = new HttpRequestMessage(HttpMethod.Post, endpoint);
|
||||
req.Headers.Authorization = new AuthenticationHeaderValue("Bearer", jwt);
|
||||
var body = JsonSerializer.Serialize(new { token, displayName });
|
||||
var body = JsonSerializer.Serialize(new RequestPayload(token, targetUid, displayName));
|
||||
req.Content = new StringContent(body, Encoding.UTF8, "application/json");
|
||||
var resp = await _httpClient.SendAsync(req, ct).ConfigureAwait(false);
|
||||
if (resp.StatusCode == System.Net.HttpStatusCode.Unauthorized)
|
||||
@@ -82,7 +89,7 @@ public class DiscoveryApiClient
|
||||
if (string.IsNullOrEmpty(jwt2)) return false;
|
||||
using var req2 = new HttpRequestMessage(HttpMethod.Post, endpoint);
|
||||
req2.Headers.Authorization = new AuthenticationHeaderValue("Bearer", jwt2);
|
||||
var body2 = JsonSerializer.Serialize(new { token, displayName });
|
||||
var body2 = JsonSerializer.Serialize(new RequestPayload(token, targetUid, displayName));
|
||||
req2.Content = new StringContent(body2, Encoding.UTF8, "application/json");
|
||||
resp = await _httpClient.SendAsync(req2, ct).ConfigureAwait(false);
|
||||
}
|
||||
@@ -102,6 +109,14 @@ public class DiscoveryApiClient
|
||||
}
|
||||
}
|
||||
|
||||
private sealed record RequestPayload(
|
||||
[property: JsonPropertyName("token"), JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
||||
string? Token,
|
||||
[property: JsonPropertyName("targetUid"), JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
||||
string? TargetUid,
|
||||
[property: JsonPropertyName("displayName"), JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
||||
string? DisplayName);
|
||||
|
||||
public async Task<bool> PublishAsync(string endpoint, IEnumerable<string> hashes, string? displayName, CancellationToken ct, bool allowRequests = true)
|
||||
{
|
||||
try
|
||||
|
||||
@@ -4,6 +4,7 @@ using MareSynchronos.API.Data;
|
||||
using MareSynchronos.API.Dto.Files;
|
||||
using MareSynchronos.API.Routes;
|
||||
using MareSynchronos.FileCache;
|
||||
using MareSynchronos.MareConfiguration;
|
||||
using MareSynchronos.PlayerData.Handlers;
|
||||
using MareSynchronos.Services.Mediator;
|
||||
using MareSynchronos.Utils;
|
||||
@@ -20,17 +21,22 @@ public partial class FileDownloadManager : DisposableMediatorSubscriberBase
|
||||
private readonly Dictionary<string, FileDownloadStatus> _downloadStatus;
|
||||
private readonly FileCompactor _fileCompactor;
|
||||
private readonly FileCacheManager _fileDbManager;
|
||||
private readonly MareConfigService _mareConfigService;
|
||||
private readonly FileTransferOrchestrator _orchestrator;
|
||||
private readonly List<ThrottledStream> _activeDownloadStreams;
|
||||
private readonly object _queueLock = new();
|
||||
private SemaphoreSlim? _downloadQueueSemaphore;
|
||||
private int _downloadQueueCapacity = -1;
|
||||
|
||||
public FileDownloadManager(ILogger<FileDownloadManager> logger, MareMediator mediator,
|
||||
FileTransferOrchestrator orchestrator,
|
||||
FileCacheManager fileCacheManager, FileCompactor fileCompactor) : base(logger, mediator)
|
||||
FileCacheManager fileCacheManager, FileCompactor fileCompactor, MareConfigService mareConfigService) : base(logger, mediator)
|
||||
{
|
||||
_downloadStatus = new Dictionary<string, FileDownloadStatus>(StringComparer.Ordinal);
|
||||
_orchestrator = orchestrator;
|
||||
_fileDbManager = fileCacheManager;
|
||||
_fileCompactor = fileCompactor;
|
||||
_mareConfigService = mareConfigService;
|
||||
_activeDownloadStreams = [];
|
||||
|
||||
Mediator.Subscribe<DownloadLimitChangedMessage>(this, (msg) =>
|
||||
@@ -59,6 +65,14 @@ public partial class FileDownloadManager : DisposableMediatorSubscriberBase
|
||||
|
||||
public async Task DownloadFiles(GameObjectHandler gameObject, List<FileReplacementData> fileReplacementDto, CancellationToken ct)
|
||||
{
|
||||
SemaphoreSlim? queueSemaphore = null;
|
||||
if (_mareConfigService.Current.EnableDownloadQueue)
|
||||
{
|
||||
queueSemaphore = GetQueueSemaphore();
|
||||
Logger.LogTrace("Queueing download for {name}. Currently queued: {queued}", gameObject.Name, queueSemaphore.CurrentCount);
|
||||
await queueSemaphore.WaitAsync(ct).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
Mediator.Publish(new HaltScanMessage(nameof(DownloadFiles)));
|
||||
try
|
||||
{
|
||||
@@ -70,6 +84,11 @@ public partial class FileDownloadManager : DisposableMediatorSubscriberBase
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (queueSemaphore != null)
|
||||
{
|
||||
queueSemaphore.Release();
|
||||
}
|
||||
|
||||
Mediator.Publish(new DownloadFinishedMessage(gameObject));
|
||||
Mediator.Publish(new ResumeScanMessage(nameof(DownloadFiles)));
|
||||
}
|
||||
@@ -132,6 +151,22 @@ public partial class FileDownloadManager : DisposableMediatorSubscriberBase
|
||||
return (string.Join("", hashName), long.Parse(string.Join("", fileLength)));
|
||||
}
|
||||
|
||||
private SemaphoreSlim GetQueueSemaphore()
|
||||
{
|
||||
var desiredCapacity = Math.Clamp(_mareConfigService.Current.ParallelDownloads, 1, 10);
|
||||
|
||||
lock (_queueLock)
|
||||
{
|
||||
if (_downloadQueueSemaphore == null || _downloadQueueCapacity != desiredCapacity)
|
||||
{
|
||||
_downloadQueueSemaphore = new SemaphoreSlim(desiredCapacity, desiredCapacity);
|
||||
_downloadQueueCapacity = desiredCapacity;
|
||||
}
|
||||
|
||||
return _downloadQueueSemaphore;
|
||||
}
|
||||
}
|
||||
|
||||
private async Task DownloadAndMungeFileHttpClient(string downloadGroup, Guid requestId, List<DownloadFileTransfer> fileTransfer, string tempPath, IProgress<long> progress, CancellationToken ct)
|
||||
{
|
||||
Logger.LogDebug("GUID {requestId} on server {uri} for files {files}", requestId, fileTransfer[0].DownloadUri, string.Join(", ", fileTransfer.Select(c => c.Hash).ToList()));
|
||||
|
||||
@@ -17,19 +17,16 @@ namespace MareSynchronos.WebAPI.Files;
|
||||
public sealed class FileUploadManager : DisposableMediatorSubscriberBase
|
||||
{
|
||||
private readonly FileCacheManager _fileDbManager;
|
||||
private readonly MareConfigService _mareConfigService;
|
||||
private readonly FileTransferOrchestrator _orchestrator;
|
||||
private readonly ServerConfigurationManager _serverManager;
|
||||
private readonly Dictionary<string, DateTime> _verifiedUploadedHashes = new(StringComparer.Ordinal);
|
||||
private CancellationTokenSource? _uploadCancellationTokenSource = new();
|
||||
|
||||
public FileUploadManager(ILogger<FileUploadManager> logger, MareMediator mediator,
|
||||
MareConfigService mareConfigService,
|
||||
FileTransferOrchestrator orchestrator,
|
||||
FileCacheManager fileDbManager,
|
||||
ServerConfigurationManager serverManager) : base(logger, mediator)
|
||||
{
|
||||
_mareConfigService = mareConfigService;
|
||||
_orchestrator = orchestrator;
|
||||
_fileDbManager = fileDbManager;
|
||||
_serverManager = serverManager;
|
||||
|
||||
@@ -19,6 +19,6 @@ public class DownloadFileTransfer : FileTransfer
|
||||
get => Dto.Size;
|
||||
}
|
||||
|
||||
public long TotalRaw => 0; // XXX
|
||||
public long TotalRaw => Dto.Size;
|
||||
private DownloadFileDto Dto => (DownloadFileDto)TransferDto;
|
||||
}
|
||||
@@ -97,6 +97,27 @@ public partial class ApiController
|
||||
await _mareHub!.InvokeAsync(nameof(UserSetProfile), userDescription).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
public async Task UserSetTypingState(bool isTyping)
|
||||
{
|
||||
CheckConnection();
|
||||
await _mareHub!.SendAsync(nameof(UserSetTypingState), isTyping).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
public async Task UserSetTypingState(bool isTyping, MareSynchronos.API.Data.Enum.TypingScope scope)
|
||||
{
|
||||
CheckConnection();
|
||||
try
|
||||
{
|
||||
await _mareHub!.SendAsync(nameof(UserSetTypingState), isTyping, scope).ConfigureAwait(false);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
// fallback for older servers without scope support
|
||||
Logger.LogDebug(ex, "UserSetTypingState(scope) not supported on server, falling back to legacy call");
|
||||
await _mareHub!.SendAsync(nameof(UserSetTypingState), isTyping).ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
|
||||
private async Task PushCharacterDataInternal(CharacterData character, List<UserData> visibleCharacters)
|
||||
{
|
||||
Logger.LogInformation("Pushing character data for {hash} to {charas}", character.DataHash.Value, string.Join(", ", visibleCharacters.Select(c => c.AliasOrUID)));
|
||||
|
||||
@@ -138,6 +138,13 @@ public partial class ApiController
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
public Task Client_UserTypingState(TypingStateDto dto)
|
||||
{
|
||||
Logger.LogTrace("Client_UserTypingState: {uid} typing={typing}", dto.User.UID, dto.IsTyping);
|
||||
Mediator.Publish(new UserTypingStateMessage(dto));
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
public Task Client_UserReceiveCharacterData(OnlineUserCharaDataDto dataDto)
|
||||
{
|
||||
Logger.LogTrace("Client_UserReceiveCharacterData: {user}", dataDto.User);
|
||||
@@ -224,7 +231,7 @@ public partial class ApiController
|
||||
|
||||
public Task Client_GposeLobbyPushWorldData(UserData userData, WorldData worldData)
|
||||
{
|
||||
//Logger.LogDebug("Client_GposeLobbyPushWorldData: {dto}", userData);
|
||||
Logger.LogDebug("Client_GposeLobbyPushWorldData: {dto}", userData);
|
||||
ExecuteSafely(() => Mediator.Publish(new GPoseLobbyReceiveWorldData(userData, worldData)));
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
@@ -313,6 +320,12 @@ public partial class ApiController
|
||||
_mareHub!.On(nameof(Client_UserChatMsg), act);
|
||||
}
|
||||
|
||||
public void OnUserTypingState(Action<TypingStateDto> act)
|
||||
{
|
||||
if (_initialized) return;
|
||||
_mareHub!.On(nameof(Client_UserTypingState), act);
|
||||
}
|
||||
|
||||
public void OnUserReceiveCharacterData(Action<OnlineUserCharaDataDto> act)
|
||||
{
|
||||
if (_initialized) return;
|
||||
|
||||
@@ -0,0 +1,94 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using MareSynchronos.API.Dto.McdfShare;
|
||||
using Microsoft.AspNetCore.SignalR.Client;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace MareSynchronos.WebAPI;
|
||||
|
||||
public sealed partial class ApiController
|
||||
{
|
||||
public async Task<List<McdfShareEntryDto>> McdfShareGetOwn()
|
||||
{
|
||||
if (!IsConnected) return [];
|
||||
try
|
||||
{
|
||||
return await _mareHub!.InvokeAsync<List<McdfShareEntryDto>>(nameof(McdfShareGetOwn)).ConfigureAwait(false);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logger.LogWarning(ex, "Error during {method}", nameof(McdfShareGetOwn));
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<List<McdfShareEntryDto>> McdfShareGetShared()
|
||||
{
|
||||
if (!IsConnected) return [];
|
||||
try
|
||||
{
|
||||
return await _mareHub!.InvokeAsync<List<McdfShareEntryDto>>(nameof(McdfShareGetShared)).ConfigureAwait(false);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logger.LogWarning(ex, "Error during {method}", nameof(McdfShareGetShared));
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
public async Task McdfShareUpload(McdfShareUploadRequestDto requestDto)
|
||||
{
|
||||
if (!IsConnected) return;
|
||||
try
|
||||
{
|
||||
await _mareHub!.InvokeAsync(nameof(McdfShareUpload), requestDto).ConfigureAwait(false);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logger.LogWarning(ex, "Error during {method}", nameof(McdfShareUpload));
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<McdfSharePayloadDto?> McdfShareDownload(Guid shareId)
|
||||
{
|
||||
if (!IsConnected) return null;
|
||||
try
|
||||
{
|
||||
return await _mareHub!.InvokeAsync<McdfSharePayloadDto?>(nameof(McdfShareDownload), shareId).ConfigureAwait(false);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logger.LogWarning(ex, "Error during {method}", nameof(McdfShareDownload));
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<bool> McdfShareDelete(Guid shareId)
|
||||
{
|
||||
if (!IsConnected) return false;
|
||||
try
|
||||
{
|
||||
return await _mareHub!.InvokeAsync<bool>(nameof(McdfShareDelete), shareId).ConfigureAwait(false);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logger.LogWarning(ex, "Error during {method}", nameof(McdfShareDelete));
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<McdfShareEntryDto?> McdfShareUpdate(McdfShareUpdateRequestDto requestDto)
|
||||
{
|
||||
if (!IsConnected) return null;
|
||||
try
|
||||
{
|
||||
return await _mareHub!.InvokeAsync<McdfShareEntryDto?>(nameof(McdfShareUpdate), requestDto).ConfigureAwait(false);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logger.LogWarning(ex, "Error during {method}", nameof(McdfShareUpdate));
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
using System.Collections.Generic;
|
||||
using MareSynchronos.API.Dto.Group;
|
||||
using Microsoft.AspNetCore.SignalR.Client;
|
||||
|
||||
namespace MareSynchronos.WebAPI;
|
||||
|
||||
public partial class ApiController
|
||||
{
|
||||
public async Task<List<SyncshellDiscoveryEntryDto>> SyncshellDiscoveryList()
|
||||
{
|
||||
CheckConnection();
|
||||
return await _mareHub!.InvokeAsync<List<SyncshellDiscoveryEntryDto>>(nameof(SyncshellDiscoveryList)).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
public async Task<SyncshellDiscoveryStateDto?> SyncshellDiscoveryGetState(GroupDto group)
|
||||
{
|
||||
CheckConnection();
|
||||
return await _mareHub!.InvokeAsync<SyncshellDiscoveryStateDto?>(nameof(SyncshellDiscoveryGetState), group).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
public async Task<bool> SyncshellDiscoverySetVisibility(SyncshellDiscoveryVisibilityRequestDto request)
|
||||
{
|
||||
CheckConnection();
|
||||
return await _mareHub!.InvokeAsync<bool>(nameof(SyncshellDiscoverySetVisibility), request).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
public async Task<bool> SyncshellDiscoveryJoin(GroupDto group)
|
||||
{
|
||||
CheckConnection();
|
||||
return await _mareHub!.InvokeAsync<bool>(nameof(SyncshellDiscoveryJoin), group).ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user