Make the DTR colors configurable (#77)

* Make the DTR colors configurable

* Allow using (most of) the full RGB space (thanks @Caraxi)
This commit is contained in:
N. Lo
2024-08-27 09:25:36 +02:00
committed by Loporrit
parent fec13209d8
commit 24593becc9
3 changed files with 99 additions and 16 deletions

View File

@@ -980,6 +980,9 @@ public class SettingsUi : WindowMediatorSubscriberBase
var showUidInDtrTooltip = _configService.Current.ShowUidInDtrTooltip;
var preferNoteInDtrTooltip = _configService.Current.PreferNoteInDtrTooltip;
var useColorsInDtr = _configService.Current.UseColorsInDtr;
var dtrColorsDefault = _configService.Current.DtrColorsDefault;
var dtrColorsNotConnected = _configService.Current.DtrColorsNotConnected;
var dtrColorsPairsInRange = _configService.Current.DtrColorsPairsInRange;
if (ImGui.Checkbox("Enable Game Right Click Menu Entries", ref enableRightClickMenu))
{
@@ -1023,6 +1026,30 @@ public class SettingsUi : WindowMediatorSubscriberBase
_configService.Current.UseColorsInDtr = useColorsInDtr;
_configService.Save();
}
using (ImRaii.Disabled(!useColorsInDtr))
{
using var indent2 = ImRaii.PushIndent();
if (InputDtrColors("Default", ref dtrColorsDefault))
{
_configService.Current.DtrColorsDefault = dtrColorsDefault;
_configService.Save();
}
ImGui.SameLine();
if (InputDtrColors("Not Connected", ref dtrColorsNotConnected))
{
_configService.Current.DtrColorsNotConnected = dtrColorsNotConnected;
_configService.Save();
}
ImGui.SameLine();
if (InputDtrColors("Pairs in Range", ref dtrColorsPairsInRange))
{
_configService.Current.DtrColorsPairsInRange = dtrColorsPairsInRange;
_configService.Save();
}
}
}
if (ImGui.Checkbox("Show separate Visible group", ref showVisibleSeparate))
@@ -1157,6 +1184,37 @@ public class SettingsUi : WindowMediatorSubscriberBase
}
}
private static bool InputDtrColors(string label, ref DtrEntry.Colors colors)
{
using var id = ImRaii.PushId(label);
var innerSpacing = ImGui.GetStyle().ItemInnerSpacing.X;
var foregroundColor = ConvertColor(colors.Foreground);
var glowColor = ConvertColor(colors.Glow);
var ret = ImGui.ColorEdit3("###foreground", ref foregroundColor, ImGuiColorEditFlags.NoInputs | ImGuiColorEditFlags.NoLabel | ImGuiColorEditFlags.Uint8);
if (ImGui.IsItemHovered())
ImGui.SetTooltip("Foreground Color - Set to pure black (#000000) to use the default color");
ImGui.SameLine(0.0f, innerSpacing);
ret |= ImGui.ColorEdit3("###glow", ref glowColor, ImGuiColorEditFlags.NoInputs | ImGuiColorEditFlags.NoLabel | ImGuiColorEditFlags.Uint8);
if (ImGui.IsItemHovered())
ImGui.SetTooltip("Glow Color - Set to pure black (#000000) to use the default color");
ImGui.SameLine(0.0f, innerSpacing);
ImGui.TextUnformatted(label);
if (ret)
colors = new(ConvertBackColor(foregroundColor), ConvertBackColor(glowColor));
return ret;
static Vector3 ConvertColor(uint color)
=> unchecked(new((byte)color / 255.0f, (byte)(color >> 8) / 255.0f, (byte)(color >> 16) / 255.0f));
static uint ConvertBackColor(Vector3 color)
=> byte.CreateSaturating(color.X * 255.0f) | ((uint)byte.CreateSaturating(color.Y * 255.0f) << 8) | ((uint)byte.CreateSaturating(color.Z * 255.0f) << 16);
}
private void DrawServerConfiguration()
{
_lastTab = "Service Settings";