diff --git a/LightlessSync/LightlessConfiguration/Configurations/LightlessConfig.cs b/LightlessSync/LightlessConfiguration/Configurations/LightlessConfig.cs index 660cddf..cfe5277 100644 --- a/LightlessSync/LightlessConfiguration/Configurations/LightlessConfig.cs +++ b/LightlessSync/LightlessConfiguration/Configurations/LightlessConfig.cs @@ -1,4 +1,4 @@ -using LightlessSync.LightlessConfiguration.Models; +using LightlessSync.LightlessConfiguration.Models; using LightlessSync.UI; using Microsoft.Extensions.Logging; @@ -15,6 +15,7 @@ public class LightlessConfig : ILightlessConfiguration public bool PreferNoteInDtrTooltip { get; set; } = false; public bool IsNameplateColorsEnabled { get; set; } = false; public DtrEntry.Colors NameplateColors { get; set; } = new(Foreground: 0xE69138u, Glow: 0xFFBA47u); + public Dictionary CustomUIColors { get; set; } = new(StringComparer.OrdinalIgnoreCase); public bool UseColorsInDtr { get; set; } = true; public DtrEntry.Colors DtrColorsDefault { get; set; } = default; public DtrEntry.Colors DtrColorsNotConnected { get; set; } = new(Glow: 0x0428FFu); diff --git a/LightlessSync/LightlessPlugin.cs b/LightlessSync/LightlessPlugin.cs index 85582a0..66d2c2b 100644 --- a/LightlessSync/LightlessPlugin.cs +++ b/LightlessSync/LightlessPlugin.cs @@ -1,10 +1,11 @@ -using LightlessSync.FileCache; +using LightlessSync.FileCache; using LightlessSync.LightlessConfiguration; using LightlessSync.PlayerData.Pairs; using LightlessSync.PlayerData.Services; using LightlessSync.Services; using LightlessSync.Services.Mediator; using LightlessSync.Services.ServerConfiguration; +using LightlessSync.UI; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Logging; @@ -98,6 +99,7 @@ public class LightlessPlugin : MediatorSubscriberBase, IHostedService Mediator.Subscribe(this, (_) => DalamudUtilOnLogIn()); Mediator.Subscribe(this, (_) => DalamudUtilOnLogOut()); + UIColors.Initialize(_lightlessConfigService); Mediator.StartQueueProcessing(); return Task.CompletedTask; diff --git a/LightlessSync/UI/UIColors.cs b/LightlessSync/UI/UIColors.cs index 5f08846..1d56167 100644 --- a/LightlessSync/UI/UIColors.cs +++ b/LightlessSync/UI/UIColors.cs @@ -1,5 +1,6 @@ -using System.Globalization; +using System.Globalization; using System.Numerics; +using LightlessSync.LightlessConfiguration; namespace LightlessSync.UI { @@ -14,12 +15,17 @@ namespace LightlessSync.UI { "DimRed", "#d44444" }, }; - private static readonly Dictionary CustomColors = new(StringComparer.OrdinalIgnoreCase); + private static LightlessConfigService? _configService; + + public static void Initialize(LightlessConfigService configService) + { + _configService = configService; + } public static Vector4 Get(string name) { - if (CustomColors.TryGetValue(name, out var customColor)) - return customColor; + if (_configService?.Current.CustomUIColors.TryGetValue(name, out var customColorHex) == true) + return HexToRgba(customColorHex); if (!DefaultHexColors.TryGetValue(name, out var hex)) throw new ArgumentException($"Color '{name}' not found in UIColors."); @@ -32,17 +38,29 @@ namespace LightlessSync.UI if (!DefaultHexColors.ContainsKey(name)) throw new ArgumentException($"Color '{name}' not found in UIColors."); - CustomColors[name] = color; + if (_configService != null) + { + _configService.Current.CustomUIColors[name] = RgbaToHex(color); + _configService.Save(); + } } public static void Reset(string name) { - CustomColors.Remove(name); + if (_configService != null) + { + _configService.Current.CustomUIColors.Remove(name); + _configService.Save(); + } } public static void ResetAll() { - CustomColors.Clear(); + if (_configService != null) + { + _configService.Current.CustomUIColors.Clear(); + _configService.Save(); + } } public static Vector4 GetDefault(string name) @@ -55,7 +73,7 @@ namespace LightlessSync.UI public static bool IsCustom(string name) { - return CustomColors.ContainsKey(name); + return _configService?.Current.CustomUIColors.ContainsKey(name) == true; } public static IEnumerable GetColorNames() diff --git a/PenumbraAPI b/PenumbraAPI index dd14131..953dd22 160000 --- a/PenumbraAPI +++ b/PenumbraAPI @@ -1 +1 @@ -Subproject commit dd14131793e5ae47cc8e9232f46469216017b5aa +Subproject commit 953dd227afda6b3943b0b88cc965d8aee8a879b5