diff --git a/MareSynchronos/MareConfiguration/Configurations/MareConfig.cs b/MareSynchronos/MareConfiguration/Configurations/MareConfig.cs index 7d66175..a755304 100644 --- a/MareSynchronos/MareConfiguration/Configurations/MareConfig.cs +++ b/MareSynchronos/MareConfiguration/Configurations/MareConfig.cs @@ -13,6 +13,7 @@ public class MareConfig : IMareConfiguration public int DtrStyle { get; set; } = 0; public bool ShowUidInDtrTooltip { get; set; } = true; public bool PreferNoteInDtrTooltip { get; set; } = false; + public bool UseColorsInDtr { get; set; } = true; public bool EnableRightClickMenus { get; set; } = true; public NotificationLocation ErrorNotification { get; set; } = NotificationLocation.Both; public string ExportFolder { get; set; } = string.Empty; diff --git a/MareSynchronos/UI/DtrEntry.cs b/MareSynchronos/UI/DtrEntry.cs index 2bd66cb..026a5c2 100644 --- a/MareSynchronos/UI/DtrEntry.cs +++ b/MareSynchronos/UI/DtrEntry.cs @@ -1,4 +1,5 @@ using Dalamud.Game.Gui.Dtr; +using Dalamud.Game.Text.SeStringHandling; using Dalamud.Plugin.Services; using MareSynchronos.MareConfiguration; using MareSynchronos.MareConfiguration.Configurations; @@ -38,6 +39,8 @@ public sealed class DtrEntry : IDisposable, IHostedService private readonly PairManager _pairManager; private Task? _runTask; private string? _text; + private string? _tooltip; + private StatusColorId _color; public DtrEntry(ILogger logger, IDtrBar dtrBar, ConfigurationServiceBase configService, MareMediator mareMediator, PairManager pairManager, ApiController apiController) { @@ -90,6 +93,8 @@ public sealed class DtrEntry : IDisposable, IHostedService if (!_entry.IsValueCreated) return; _logger.LogInformation("Clearing entry"); _text = null; + _tooltip = null; + _color = default; _entry.Value.Shown = false; } @@ -134,6 +139,7 @@ public sealed class DtrEntry : IDisposable, IHostedService string text; string tooltip; + StatusColorId color; if (_apiController.IsConnected) { var pairCount = _pairManager.GetVisibleUserCount(); @@ -156,22 +162,30 @@ public sealed class DtrEntry : IDisposable, IHostedService } tooltip = $"Loporrit: Connected{Environment.NewLine}----------{Environment.NewLine}{string.Join(Environment.NewLine, visiblePairs)}"; + color = StatusColorId.PairsInRange; } else { tooltip = "Loporrit: Connected"; + color = default; } } else { text = RenderDtrStyle(_configService.Current.DtrStyle, "\uE04C"); tooltip = "Loporrit: Not Connected"; + color = StatusColorId.NotConnected; } - if (!string.Equals(text, _text, StringComparison.Ordinal)) + if (!_configService.Current.UseColorsInDtr) + color = default; + + if (!string.Equals(text, _text, StringComparison.Ordinal) || !string.Equals(tooltip, _tooltip, StringComparison.Ordinal) || color != _color) { _text = text; - _entry.Value.Text = text; + _tooltip = tooltip; + _color = color; + _entry.Value.Text = color != default ? BuildColoredSeString(text, color) : text; _entry.Value.Tooltip = tooltip; } } @@ -193,4 +207,14 @@ public sealed class DtrEntry : IDisposable, IHostedService _ => $"\uE044 {text}" }; } + + private static SeString BuildColoredSeString(string text, StatusColorId color) + => new SeStringBuilder().AddUiGlow(text, (ushort)color).Build(); + + private enum StatusColorId : ushort + { + None = default, + NotConnected = 518, + PairsInRange = 526, + } } diff --git a/MareSynchronos/UI/SettingsUi.cs b/MareSynchronos/UI/SettingsUi.cs index df94cc1..fc68b9c 100644 --- a/MareSynchronos/UI/SettingsUi.cs +++ b/MareSynchronos/UI/SettingsUi.cs @@ -979,6 +979,7 @@ public class SettingsUi : WindowMediatorSubscriberBase var enableDtrEntry = _configService.Current.EnableDtrEntry; var showUidInDtrTooltip = _configService.Current.ShowUidInDtrTooltip; var preferNoteInDtrTooltip = _configService.Current.PreferNoteInDtrTooltip; + var useColorsInDtr = _configService.Current.UseColorsInDtr; if (ImGui.Checkbox("Enable Game Right Click Menu Entries", ref enableRightClickMenu)) { @@ -1016,6 +1017,12 @@ public class SettingsUi : WindowMediatorSubscriberBase _configService.Current.DtrStyle = i; _configService.Save(); }, _configService.Current.DtrStyle); + + if (ImGui.Checkbox("Color-code the Server Info Bar entry according to status", ref useColorsInDtr)) + { + _configService.Current.UseColorsInDtr = useColorsInDtr; + _configService.Save(); + } } if (ImGui.Checkbox("Show separate Visible group", ref showVisibleSeparate))