Color-code the DTR entry (#76)
This commit is contained in:
@@ -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<DtrEntry> logger, IDtrBar dtrBar, ConfigurationServiceBase<MareConfig> 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,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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))
|
||||
|
||||
Reference in New Issue
Block a user