UI Update & Fix Nearby

This commit is contained in:
2025-11-01 01:09:06 +01:00
parent 84586cac3d
commit 513845b811
12 changed files with 188 additions and 72 deletions

View File

@@ -8,6 +8,7 @@ public class PlayerPerformanceConfig : IMareConfiguration
public bool AutoPausePlayersExceedingThresholds { get; set; } = true; public bool AutoPausePlayersExceedingThresholds { get; set; } = true;
public bool NotifyAutoPauseDirectPairs { get; set; } = true; public bool NotifyAutoPauseDirectPairs { get; set; } = true;
public bool NotifyAutoPauseGroupPairs { get; set; } = true; public bool NotifyAutoPauseGroupPairs { get; set; } = true;
public bool ShowSelfAnalysisWarnings { get; set; } = true;
public int VRAMSizeAutoPauseThresholdMiB { get; set; } = 500; public int VRAMSizeAutoPauseThresholdMiB { get; set; } = 500;
public int TrisAutoPauseThresholdThousands { get; set; } = 400; public int TrisAutoPauseThresholdThousands { get; set; } = 400;
public bool IgnoreDirectPairs { get; set; } = true; public bool IgnoreDirectPairs { get; set; } = true;

View File

@@ -3,7 +3,7 @@
<PropertyGroup> <PropertyGroup>
<AssemblyName>UmbraSync</AssemblyName> <AssemblyName>UmbraSync</AssemblyName>
<RootNamespace>UmbraSync</RootNamespace> <RootNamespace>UmbraSync</RootNamespace>
<Version>0.1.9.6</Version> <Version>0.1.9.9</Version>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>

View File

@@ -8,6 +8,7 @@ using MareSynchronos.WebAPI.AutoDetect;
using Dalamud.Plugin.Services; using Dalamud.Plugin.Services;
using System.Numerics; using System.Numerics;
using System.Linq; using System.Linq;
using System.Collections.Generic;
using MareSynchronos.Utils; using MareSynchronos.Utils;
namespace MareSynchronos.Services.AutoDetect; namespace MareSynchronos.Services.AutoDetect;
@@ -35,6 +36,8 @@ public class NearbyDiscoveryService : IHostedService, IMediatorSubscriber
private bool _lastAutoDetectState; private bool _lastAutoDetectState;
private DateTime _lastHeartbeat = DateTime.MinValue; private DateTime _lastHeartbeat = DateTime.MinValue;
private static readonly TimeSpan HeartbeatInterval = TimeSpan.FromSeconds(75); private static readonly TimeSpan HeartbeatInterval = TimeSpan.FromSeconds(75);
private readonly object _entriesLock = new();
private List<NearbyEntry> _lastEntries = [];
public NearbyDiscoveryService(ILogger<NearbyDiscoveryService> logger, MareMediator mediator, public NearbyDiscoveryService(ILogger<NearbyDiscoveryService> logger, MareMediator mediator,
MareConfigService config, DiscoveryConfigProvider configProvider, DalamudUtilService dalamudUtilService, MareConfigService config, DiscoveryConfigProvider configProvider, DalamudUtilService dalamudUtilService,
@@ -134,6 +137,22 @@ public class NearbyDiscoveryService : IHostedService, IMediatorSubscriber
return Task.CompletedTask; 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) private static void CancelAndDispose(ref CancellationTokenSource? cts)
{ {
if (cts == null) return; if (cts == null) return;
@@ -443,6 +462,7 @@ public class NearbyDiscoveryService : IHostedService, IMediatorSubscriber
_logger.LogDebug("Nearby: well-known not available or disabled; running in local-only mode"); _logger.LogDebug("Nearby: well-known not available or disabled; running in local-only mode");
} }
} }
UpdateSnapshot(entries);
_mediator.Publish(new DiscoveryListUpdated(entries)); _mediator.Publish(new DiscoveryListUpdated(entries));
var delayMs = Math.Max(1000, _configProvider.MinQueryIntervalMs); var delayMs = Math.Max(1000, _configProvider.MinQueryIntervalMs);

View File

@@ -4,6 +4,7 @@ using Lumina.Data.Files;
using MareSynchronos.API.Data; using MareSynchronos.API.Data;
using MareSynchronos.API.Data.Enum; using MareSynchronos.API.Data.Enum;
using MareSynchronos.FileCache; using MareSynchronos.FileCache;
using MareSynchronos.MareConfiguration;
using MareSynchronos.MareConfiguration.Models; using MareSynchronos.MareConfiguration.Models;
using MareSynchronos.Services.Mediator; using MareSynchronos.Services.Mediator;
using MareSynchronos.UI; using MareSynchronos.UI;
@@ -29,8 +30,9 @@ public sealed class CharacterAnalyzer : DisposableMediatorSubscriberBase
private const long NotificationTriangleThreshold = 150_000; private const long NotificationTriangleThreshold = 150_000;
private bool _sizeWarningShown; private bool _sizeWarningShown;
private bool _triangleWarningShown; 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) : base(logger, mediator)
{ {
Mediator.Subscribe<CharacterDataCreatedMessage>(this, (msg) => Mediator.Subscribe<CharacterDataCreatedMessage>(this, (msg) =>
@@ -41,6 +43,7 @@ public sealed class CharacterAnalyzer : DisposableMediatorSubscriberBase
}); });
_fileCacheManager = fileCacheManager; _fileCacheManager = fileCacheManager;
_xivDataAnalyzer = modelAnalyzer; _xivDataAnalyzer = modelAnalyzer;
_playerPerformanceConfigService = playerPerformanceConfigService;
} }
public int CurrentFile { get; internal set; } public int CurrentFile { get; internal set; }
@@ -313,6 +316,12 @@ public sealed class CharacterAnalyzer : DisposableMediatorSubscriberBase
return; return;
} }
if (!_playerPerformanceConfigService.Current.ShowSelfAnalysisWarnings)
{
ResetThresholdFlagsIfNeeded(summary);
return;
}
bool sizeExceeded = summary.TotalCompressedSize >= NotificationSizeThreshold; bool sizeExceeded = summary.TotalCompressedSize >= NotificationSizeThreshold;
bool trianglesExceeded = summary.TotalTriangles >= NotificationTriangleThreshold; bool trianglesExceeded = summary.TotalTriangles >= NotificationTriangleThreshold;
List<string> exceededReasons = new(); List<string> exceededReasons = new();

View File

@@ -24,14 +24,16 @@ public class AutoDetectUi : WindowMediatorSubscriberBase
private readonly MareConfigService _configService; private readonly MareConfigService _configService;
private readonly DalamudUtilService _dalamud; private readonly DalamudUtilService _dalamud;
private readonly AutoDetectRequestService _requestService; private readonly AutoDetectRequestService _requestService;
private readonly NearbyDiscoveryService _discoveryService;
private readonly NearbyPendingService _pendingService; private readonly NearbyPendingService _pendingService;
private readonly PairManager _pairManager; private readonly PairManager _pairManager;
private List<Services.Mediator.NearbyEntry> _entries = new(); private List<Services.Mediator.NearbyEntry> _entries;
private readonly HashSet<string> _acceptInFlight = new(StringComparer.Ordinal); private readonly HashSet<string> _acceptInFlight = new(StringComparer.Ordinal);
public AutoDetectUi(ILogger<AutoDetectUi> logger, MareMediator mediator, public AutoDetectUi(ILogger<AutoDetectUi> logger, MareMediator mediator,
MareConfigService configService, DalamudUtilService dalamudUtilService, MareConfigService configService, DalamudUtilService dalamudUtilService,
AutoDetectRequestService requestService, NearbyPendingService pendingService, PairManager pairManager, AutoDetectRequestService requestService, NearbyPendingService pendingService, PairManager pairManager,
NearbyDiscoveryService discoveryService,
PerformanceCollectorService performanceCollectorService) PerformanceCollectorService performanceCollectorService)
: base(logger, mediator, "AutoDetect", performanceCollectorService) : base(logger, mediator, "AutoDetect", performanceCollectorService)
{ {
@@ -40,6 +42,9 @@ public class AutoDetectUi : WindowMediatorSubscriberBase
_requestService = requestService; _requestService = requestService;
_pendingService = pendingService; _pendingService = pendingService;
_pairManager = pairManager; _pairManager = pairManager;
_discoveryService = discoveryService;
Mediator.Subscribe<Services.Mediator.DiscoveryListUpdated>(this, OnDiscoveryUpdated);
_entries = _discoveryService.SnapshotEntries();
Flags |= ImGuiWindowFlags.NoScrollbar; Flags |= ImGuiWindowFlags.NoScrollbar;
SizeConstraints = new WindowSizeConstraints() SizeConstraints = new WindowSizeConstraints()
@@ -214,61 +219,102 @@ public class AutoDetectUi : WindowMediatorSubscriberBase
ImGuiHelpers.ScaledDummy(6); ImGuiHelpers.ScaledDummy(6);
// Table header var sourceEntries = _entries.Count > 0 ? _entries : _discoveryService.SnapshotEntries();
if (ImGui.BeginTable("autodetect-nearby", 5, ImGuiTableFlags.SizingStretchProp)) var orderedEntries = sourceEntries
{ .OrderBy(e => float.IsNaN(e.Distance) ? float.MaxValue : e.Distance)
ImGui.TableSetupColumn("Name"); .ToList();
ImGui.TableSetupColumn("World");
ImGui.TableSetupColumn("Distance");
ImGui.TableSetupColumn("Status");
ImGui.TableSetupColumn("Action");
ImGui.TableHeadersRow();
var data = _entries.Count > 0 ? _entries.Where(e => e.IsMatch).ToList() : new List<Services.Mediator.NearbyEntry>(); if (orderedEntries.Count == 0)
foreach (var e in data) {
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();
for (int i = 0; i < orderedEntries.Count; i++)
{
var entry = orderedEntries[i];
bool isMatch = entry.IsMatch;
bool alreadyPaired = IsAlreadyPairedByUidOrAlias(entry);
bool overDistance = !float.IsNaN(entry.Distance) && entry.Distance > maxDist;
bool canRequest = isMatch && 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
? "Déjà appairé"
: overDistance
? $"Hors portée (> {maxDist} m)"
: !isMatch
? "Umbra non activé"
: !entry.AcceptPairRequests
? "Invitations refusées"
: string.IsNullOrEmpty(entry.Token)
? "Indisponible"
: "Disponible";
ImGui.TableNextColumn();
ImGui.TextUnformatted(displayName);
ImGui.TableNextColumn();
ImGui.TextUnformatted(worldName);
ImGui.TableNextColumn();
ImGui.TextUnformatted(distanceText);
ImGui.TableNextColumn();
ImGui.TextUnformatted(status);
ImGui.TableNextColumn();
using (ImRaii.PushId(i))
{ {
ImGui.TableNextColumn(); if (canRequest && !overDistance)
ImGui.TextUnformatted(e.Name);
ImGui.TableNextColumn();
ImGui.TextUnformatted(e.WorldId == 0 ? "-" : (_dalamud.WorldData.Value.TryGetValue(e.WorldId, out var w) ? w : e.WorldId.ToString()));
ImGui.TableNextColumn();
ImGui.TextUnformatted(float.IsNaN(e.Distance) ? "-" : $"{e.Distance:0.0} m");
ImGui.TableNextColumn();
bool alreadyPaired = IsAlreadyPairedByUidOrAlias(e);
string status = alreadyPaired ? "Paired" : (string.IsNullOrEmpty(e.Token) ? "Requests disabled" : "On Umbra");
ImGui.TextUnformatted(status);
ImGui.TableNextColumn();
using (ImRaii.Disabled(alreadyPaired || string.IsNullOrEmpty(e.Token)))
{ {
if (alreadyPaired) if (ImGui.Button("Envoyer invitation"))
{ {
ImGui.Button($"Already sync##{e.Name}"); _ = _requestService.SendRequestAsync(entry.Token!, entry.Uid, entry.DisplayName);
} }
else if (string.IsNullOrEmpty(e.Token)) UiSharedService.AttachToolTip("Envoie une demande d'appairage via AutoDetect.");
}
else
{
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)."
: !isMatch
? "Ce joueur n'utilise pas UmbraSync ou ne s'est pas rendu détectable."
: !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))
{ {
ImGui.Button($"Requests disabled##{e.Name}"); UiSharedService.AttachToolTip(reason);
}
else if (ImGui.Button($"Send request##{e.Name}"))
{
_ = _requestService.SendRequestAsync(e.Token!, e.Uid, e.DisplayName);
} }
} }
} }
ImGui.EndTable();
} }
}
public override void OnOpen() ImGui.EndTable();
{
base.OnOpen();
Mediator.Subscribe<Services.Mediator.DiscoveryListUpdated>(this, OnDiscoveryUpdated);
}
public override void OnClose()
{
Mediator.Unsubscribe<Services.Mediator.DiscoveryListUpdated>(this);
base.OnClose();
} }
private void OnDiscoveryUpdated(Services.Mediator.DiscoveryListUpdated msg) private void OnDiscoveryUpdated(Services.Mediator.DiscoveryListUpdated msg)

View File

@@ -76,7 +76,7 @@ public class CompactUi : WindowMediatorSubscriberBase
private CompactUiSection _activeSection = CompactUiSection.VisiblePairs; private CompactUiSection _activeSection = CompactUiSection.VisiblePairs;
private const float SidebarWidth = 42f; private const float SidebarWidth = 42f;
private const float SidebarIconSize = 22f; private const float SidebarIconSize = 22f;
private const float ContentFontScale = 0.92f; private const float ContentFontScale = UiSharedService.ContentFontScale;
private static readonly Vector4 SidebarButtonColor = new(0.08f, 0.08f, 0.10f, 0.92f); private static readonly Vector4 SidebarButtonColor = new(0.08f, 0.08f, 0.10f, 0.92f);
private static readonly Vector4 SidebarButtonHoverColor = new(0.12f, 0.12f, 0.16f, 0.95f); private static readonly Vector4 SidebarButtonHoverColor = new(0.12f, 0.12f, 0.16f, 0.95f);
private static readonly Vector4 SidebarButtonActiveColor = new(0.16f, 0.16f, 0.22f, 0.95f); private static readonly Vector4 SidebarButtonActiveColor = new(0.16f, 0.16f, 0.22f, 0.95f);
@@ -186,7 +186,7 @@ public class CompactUi : WindowMediatorSubscriberBase
ImGui.SetCursorPosY(ImGui.GetCursorPosY() - ImGui.GetStyle().WindowPadding.Y - 1f * ImGuiHelpers.GlobalScale + ImGui.GetStyle().ItemSpacing.Y); ImGui.SetCursorPosY(ImGui.GetCursorPosY() - ImGui.GetStyle().WindowPadding.Y - 1f * ImGuiHelpers.GlobalScale + ImGui.GetStyle().ItemSpacing.Y);
var sidebarWidth = ImGuiHelpers.ScaledVector2(SidebarWidth, 0).X; var sidebarWidth = ImGuiHelpers.ScaledVector2(SidebarWidth, 0).X;
ImGui.SetWindowFontScale(ContentFontScale); using var fontScale = UiSharedService.PushFontScale(ContentFontScale);
ImGui.PushStyleVar(ImGuiStyleVar.FramePadding, ImGui.GetStyle().FramePadding * ContentFontScale); ImGui.PushStyleVar(ImGuiStyleVar.FramePadding, ImGui.GetStyle().FramePadding * ContentFontScale);
ImGui.BeginChild("compact-sidebar", new Vector2(sidebarWidth, 0), false, ImGuiWindowFlags.NoScrollbar); ImGui.BeginChild("compact-sidebar", new Vector2(sidebarWidth, 0), false, ImGuiWindowFlags.NoScrollbar);
@@ -232,7 +232,6 @@ public class CompactUi : WindowMediatorSubscriberBase
} }
ImGui.PopStyleVar(); ImGui.PopStyleVar();
ImGui.SetWindowFontScale(1f);
} }
public override void OnClose() public override void OnClose()
@@ -735,7 +734,6 @@ if (showNearby && pendingInvites > 0)
} }
else else
{ {
var visibleUsers = visibleUsersSource.Select(c => new DrawUserPair("Visible" + c.UserData.UID, c, _uidDisplayHandler, _apiController, Mediator, _selectGroupForPairUi, _uiSharedService, _charaDataManager, _serverManager)).ToList();
var onlineUsers = nonVisibleUsers.Where(u => u.UserPair!.OtherPermissions.IsPaired() && (u.IsOnline || u.UserPair!.OwnPermissions.IsPaused())) var onlineUsers = nonVisibleUsers.Where(u => u.UserPair!.OtherPermissions.IsPaired() && (u.IsOnline || u.UserPair!.OwnPermissions.IsPaused()))
.Select(c => new DrawUserPair("Online" + c.UserData.UID, c, _uidDisplayHandler, _apiController, Mediator, _selectGroupForPairUi, _uiSharedService, _charaDataManager, _serverManager)) .Select(c => new DrawUserPair("Online" + c.UserData.UID, c, _uidDisplayHandler, _apiController, Mediator, _selectGroupForPairUi, _uiSharedService, _charaDataManager, _serverManager))
.ToList(); .ToList();
@@ -750,7 +748,7 @@ if (showNearby && pendingInvites > 0)
drawVisibleExtras = () => DrawNearbyCard(entriesForExtras); drawVisibleExtras = () => DrawNearbyCard(entriesForExtras);
} }
_pairGroupsUi.Draw(visibleUsers, onlineUsers, offlineUsers, drawVisibleExtras); _pairGroupsUi.Draw(Array.Empty<DrawUserPair>().ToList(), onlineUsers, offlineUsers, drawVisibleExtras);
} }
ImGui.EndChild(); ImGui.EndChild();
@@ -1289,7 +1287,7 @@ if (showNearby && pendingInvites > 0)
} }
var originalPos = ImGui.GetCursorPos(); var originalPos = ImGui.GetCursorPos();
ImGui.SetWindowFontScale(1.5f); UiSharedService.SetFontScale(1.5f);
Vector2 buttonSize = Vector2.Zero; Vector2 buttonSize = Vector2.Zero;
float spacingX = ImGui.GetStyle().ItemSpacing.X; float spacingX = ImGui.GetStyle().ItemSpacing.X;
@@ -1307,7 +1305,7 @@ if (showNearby && pendingInvites > 0)
} }
ImGui.SetCursorPos(originalPos); ImGui.SetCursorPos(originalPos);
ImGui.SetWindowFontScale(1f); UiSharedService.SetFontScale(1f);
float referenceHeight = buttonSize.Y > 0f ? buttonSize.Y : ImGui.GetFrameHeight(); float referenceHeight = buttonSize.Y > 0f ? buttonSize.Y : ImGui.GetFrameHeight();
ImGui.SetCursorPosY(originalPos.Y + referenceHeight / 2f - uidTextSize.Y / 2f - spacingX / 2f); ImGui.SetCursorPosY(originalPos.Y + referenceHeight / 2f - uidTextSize.Y / 2f - spacingX / 2f);

View File

@@ -201,7 +201,7 @@ public class DrawGroupPair : DrawPairBase
var individualVFXDisabled = (_pair.UserPair?.OwnPermissions.IsDisableVFX() ?? false) || (_pair.UserPair?.OtherPermissions.IsDisableVFX() ?? false); var individualVFXDisabled = (_pair.UserPair?.OwnPermissions.IsDisableVFX() ?? false) || (_pair.UserPair?.OtherPermissions.IsDisableVFX() ?? false);
bool showShared = _charaDataManager.SharedWithYouData.TryGetValue(_pair.UserData, out var sharedData); bool showShared = _charaDataManager.SharedWithYouData.TryGetValue(_pair.UserData, out var sharedData);
bool showInfo = (individualAnimDisabled || individualSoundsDisabled || animDisabled || soundsDisabled); bool showInfo = (individualAnimDisabled || individualSoundsDisabled || individualVFXDisabled || animDisabled || soundsDisabled || vfxDisabled);
bool showPlus = _pair.UserPair == null && _pair.IsOnline; bool showPlus = _pair.UserPair == null && _pair.IsOnline;
bool showBars = (userIsOwner || (userIsModerator && !entryIsMod && !entryIsOwner)) || !_pair.IsPaused; bool showBars = (userIsOwner || (userIsModerator && !entryIsMod && !entryIsOwner)) || !_pair.IsPaused;
bool showPause = true; bool showPause = true;
@@ -267,7 +267,7 @@ public class DrawGroupPair : DrawPairBase
if (showInfo && infoIconWidth > 0f) if (showInfo && infoIconWidth > 0f)
{ {
ImGui.SetCursorPosY(textPosY); ImGui.SetCursorPosY(textPosY);
if (individualAnimDisabled || individualSoundsDisabled) if (individualAnimDisabled || individualSoundsDisabled || individualVFXDisabled)
{ {
ImGui.PushStyleColor(ImGuiCol.Text, ImGuiColors.DalamudYellow); ImGui.PushStyleColor(ImGuiCol.Text, ImGuiColors.DalamudYellow);
_uiSharedService.IconText(permIcon); _uiSharedService.IconText(permIcon);

View File

@@ -91,6 +91,7 @@ internal sealed class GroupPanel
public void DrawSyncshells() public void DrawSyncshells()
{ {
using var fontScale = UiSharedService.PushFontScale(UiSharedService.ContentFontScale);
using (ImRaii.PushId("addsyncshell")) DrawAddSyncshell(); using (ImRaii.PushId("addsyncshell")) DrawAddSyncshell();
using (ImRaii.PushId("syncshelllist")) DrawSyncshellList(); using (ImRaii.PushId("syncshelllist")) DrawSyncshellList();
_mainUi.TransferPartHeight = ImGui.GetCursorPosY(); _mainUi.TransferPartHeight = ImGui.GetCursorPosY();
@@ -613,7 +614,7 @@ internal sealed class GroupPanel
ImGui.Separator(); ImGui.Separator();
} }
ImGui.Unindent(20); ImGui.Unindent(20);
}, background: new Vector4(0.15f, 0.15f, 0.20f, 0.94f), border: new Vector4(0f, 0f, 0f, 0.78f), stretchWidth: true); }, stretchWidth: true);
ImGuiHelpers.ScaledDummy(4f); ImGuiHelpers.ScaledDummy(4f);
} }

View File

@@ -198,10 +198,7 @@ public class PairGroupsUi
private void DrawUserPairs(List<string> tagsWithPairsInThem, List<DrawUserPair> allUsers, IEnumerable<DrawUserPair> visibleUsers, IEnumerable<DrawUserPair> onlineUsers, IEnumerable<DrawUserPair> offlineUsers, Action? drawVisibleExtras) private void DrawUserPairs(List<string> tagsWithPairsInThem, List<DrawUserPair> allUsers, IEnumerable<DrawUserPair> visibleUsers, IEnumerable<DrawUserPair> onlineUsers, IEnumerable<DrawUserPair> offlineUsers, Action? drawVisibleExtras)
{ {
if (_mareConfig.Current.ShowVisibleUsersSeparately) // Visible section intentionally omitted for Individual Pairs view.
{
using (ImRaii.PushId("$group-VisibleCustomTag")) DrawCategory(TagHandler.CustomVisibleTag, visibleUsers, allUsers, drawExtraContent: drawVisibleExtras);
}
foreach (var tag in tagsWithPairsInThem) foreach (var tag in tagsWithPairsInThem)
{ {
if (_mareConfig.Current.ShowOfflineUsersSeparately) if (_mareConfig.Current.ShowOfflineUsersSeparately)

View File

@@ -144,12 +144,12 @@ public partial class IntroUi : WindowMediatorSubscriberBase
} }
ImGui.Separator(); ImGui.Separator();
ImGui.SetWindowFontScale(1.5f); UiSharedService.SetFontScale(1.5f);
string readThis = "MERCI DE LIRE ATTENTIVEMENT"; string readThis = "MERCI DE LIRE ATTENTIVEMENT";
Vector2 textSize = ImGui.CalcTextSize(readThis); Vector2 textSize = ImGui.CalcTextSize(readThis);
ImGui.SetCursorPosX(ImGui.GetWindowSize().X / 2 - textSize.X / 2); ImGui.SetCursorPosX(ImGui.GetWindowSize().X / 2 - textSize.X / 2);
UiSharedService.ColorText(readThis, UiSharedService.AccentColor); UiSharedService.ColorText(readThis, UiSharedService.AccentColor);
ImGui.SetWindowFontScale(1.0f); UiSharedService.SetFontScale(1.0f);
ImGui.Separator(); ImGui.Separator();
UiSharedService.TextWrapped(""" UiSharedService.TextWrapped("""
Pour utiliser les services UmbraSync, vous devez être â de plus de 18 ans, plus de 21 ans dans certaines juridictions. Pour utiliser les services UmbraSync, vous devez être â de plus de 18 ans, plus de 21 ans dans certaines juridictions.

View File

@@ -534,9 +534,9 @@ public class SettingsUi : WindowMediatorSubscriberBase
}, globalChatTypeIdx); }, globalChatTypeIdx);
_uiShared.DrawHelpText("FFXIV chat channel to output chat messages on."); _uiShared.DrawHelpText("FFXIV chat channel to output chat messages on.");
ImGui.SetWindowFontScale(0.6f); UiSharedService.SetFontScale(0.6f);
_uiShared.BigText("\"Chat 2\" Plugin Integration"); _uiShared.BigText("\"Chat 2\" Plugin Integration");
ImGui.SetWindowFontScale(1.0f); UiSharedService.SetFontScale(1.0f);
var extraChatTags = _configService.Current.ExtraChatTags; var extraChatTags = _configService.Current.ExtraChatTags;
if (ImGui.Checkbox("Tag messages as ExtraChat", ref extraChatTags)) if (ImGui.Checkbox("Tag messages as ExtraChat", ref extraChatTags))
@@ -577,9 +577,9 @@ public class SettingsUi : WindowMediatorSubscriberBase
if (shellEnabled) if (shellEnabled)
shellName = $"[{shellNumber}] {shellName}"; shellName = $"[{shellNumber}] {shellName}";
ImGui.SetWindowFontScale(0.6f); UiSharedService.SetFontScale(0.6f);
_uiShared.BigText(shellName); _uiShared.BigText(shellName);
ImGui.SetWindowFontScale(1.0f); UiSharedService.SetFontScale(1.0f);
using var pushIndent = ImRaii.PushIndent(); using var pushIndent = ImRaii.PushIndent();
@@ -1333,6 +1333,14 @@ public class SettingsUi : WindowMediatorSubscriberBase
_uiShared.BigText("Global Configuration"); _uiShared.BigText("Global Configuration");
bool showSelfAnalysisWarnings = _playerPerformanceConfigService.Current.ShowSelfAnalysisWarnings;
if (ImGui.Checkbox("Display self-analysis warnings", ref showSelfAnalysisWarnings))
{
_playerPerformanceConfigService.Current.ShowSelfAnalysisWarnings = showSelfAnalysisWarnings;
_playerPerformanceConfigService.Save();
}
_uiShared.DrawHelpText("Disable to suppress UmbraSync chat warnings when your character exceeds the self-analysis thresholds.");
bool alwaysShrinkTextures = _playerPerformanceConfigService.Current.TextureShrinkMode == TextureShrinkMode.Always; bool alwaysShrinkTextures = _playerPerformanceConfigService.Current.TextureShrinkMode == TextureShrinkMode.Always;
bool deleteOriginalTextures = _playerPerformanceConfigService.Current.TextureShrinkDeleteOriginal; bool deleteOriginalTextures = _playerPerformanceConfigService.Current.TextureShrinkDeleteOriginal;

View File

@@ -21,6 +21,7 @@ using MareSynchronos.Services.ServerConfiguration;
using MareSynchronos.WebAPI; using MareSynchronos.WebAPI;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
using System; using System;
using System.Collections.Generic;
using System.Numerics; using System.Numerics;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using System.Text; using System.Text;
@@ -37,6 +38,8 @@ public partial class UiSharedService : DisposableMediatorSubscriberBase
ImGuiWindowFlags.NoScrollbar | ImGuiWindowFlags.NoScrollbar |
ImGuiWindowFlags.NoScrollWithMouse; ImGuiWindowFlags.NoScrollWithMouse;
public const float ContentFontScale = 0.92f;
public static Vector4 AccentColor { get; set; } = ImGuiColors.DalamudViolet; 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 AccentHoverColor { get; set; } = new Vector4(0x3A / 255f, 0x15 / 255f, 0x50 / 255f, 1f);
public static Vector4 AccentActiveColor { get; set; } = AccentHoverColor; public static Vector4 AccentActiveColor { get; set; } = AccentHoverColor;
@@ -60,6 +63,8 @@ public partial class UiSharedService : DisposableMediatorSubscriberBase
private readonly Dictionary<string, object> _selectedComboItems = new(StringComparer.Ordinal); private readonly Dictionary<string, object> _selectedComboItems = new(StringComparer.Ordinal);
private readonly ServerConfigurationManager _serverConfigurationManager; private readonly ServerConfigurationManager _serverConfigurationManager;
private bool _cacheDirectoryHasOtherFilesThanCache = false; private bool _cacheDirectoryHasOtherFilesThanCache = false;
private static readonly Stack<float> _fontScaleStack = new();
private static float _currentWindowFontScale = 1f;
private bool _cacheDirectoryIsValidPath = true; private bool _cacheDirectoryIsValidPath = true;
@@ -217,6 +222,37 @@ public partial class UiSharedService : DisposableMediatorSubscriberBase
public static bool CtrlPressed() => (GetKeyState(0xA2) & 0x8000) != 0 || (GetKeyState(0xA3) & 0x8000) != 0; public static bool CtrlPressed() => (GetKeyState(0xA2) & 0x8000) != 0 || (GetKeyState(0xA3) & 0x8000) != 0;
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) public static void DrawGrouped(Action imguiDrawAction, float rounding = 5f, float? expectedWidth = null, bool drawBorder = true)
{ {
var cursorPos = ImGui.GetCursorPos(); var cursorPos = ImGui.GetCursorPos();
@@ -894,9 +930,9 @@ public partial class UiSharedService : DisposableMediatorSubscriberBase
if (intro) if (intro)
{ {
ImGui.SetWindowFontScale(0.8f); SetFontScale(0.8f);
BigText("Mandatory Plugins"); BigText("Mandatory Plugins");
ImGui.SetWindowFontScale(1.0f); SetFontScale(1.0f);
} }
else else
{ {
@@ -917,9 +953,9 @@ public partial class UiSharedService : DisposableMediatorSubscriberBase
if (intro) if (intro)
{ {
ImGui.SetWindowFontScale(0.8f); SetFontScale(0.8f);
BigText("Optional Addons"); BigText("Optional Addons");
ImGui.SetWindowFontScale(1.0f); SetFontScale(1.0f);
UiSharedService.TextWrapped("These addons are not required for basic operation, but without them you may not see others as intended."); UiSharedService.TextWrapped("These addons are not required for basic operation, but without them you may not see others as intended.");
} }
else else