rework lightfinder for new api

This commit is contained in:
azyges
2025-10-09 07:33:49 +09:00
parent 86107acf12
commit f01229a97f
11 changed files with 531 additions and 164 deletions

View File

@@ -181,12 +181,13 @@ public class SettingsUi : WindowMediatorSubscriberBase
var foregroundColor = ConvertColor(colors.Foreground);
var glowColor = ConvertColor(colors.Glow);
var ret = ImGui.ColorEdit3("###foreground", ref foregroundColor, ImGuiColorEditFlags.NoInputs | ImGuiColorEditFlags.NoLabel | ImGuiColorEditFlags.Uint8);
const ImGuiColorEditFlags colorFlags = ImGuiColorEditFlags.NoInputs | ImGuiColorEditFlags.NoLabel;
var ret = ImGui.ColorEdit3("###foreground", ref foregroundColor, colorFlags);
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);
ret |= ImGui.ColorEdit3("###glow", ref glowColor, colorFlags);
if (ImGui.IsItemHovered())
ImGui.SetTooltip("Glow Color - Set to pure black (#000000) to use the default color");
@@ -199,10 +200,26 @@ public class SettingsUi : WindowMediatorSubscriberBase
return ret;
static Vector3 ConvertColor(uint color)
=> unchecked(new((byte)color / 255.0f, (byte)(color >> 8) / 255.0f, (byte)(color >> 16) / 255.0f));
{
var r = (color & 0xFF) / 255.0f;
var g = ((color >> 8) & 0xFF) / 255.0f;
var b = ((color >> 16) & 0xFF) / 255.0f;
return new(r, g, b);
}
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);
{
static byte ToByte(float channel)
{
var scaled = MathF.Round(Math.Clamp(channel, 0f, 1f) * 255.0f);
return (byte)Math.Clamp((int)scaled, 0, 255);
}
var r = ToByte(color.X);
var g = ToByte(color.Y);
var b = ToByte(color.Z);
return (uint)(r | (g << 8) | (b << 16));
}
}
private void DrawBlockedTransfers()
@@ -1066,10 +1083,66 @@ public class SettingsUi : WindowMediatorSubscriberBase
if (_uiShared.MediumTreeNode("Lightfinder", UIColors.Get("LightlessPurple")))
{
bool autoEnable = _configService.Current.LightfinderAutoEnableOnConnect;
var autoAlign = _configService.Current.LightfinderAutoAlign;
var offsetX = (int)_configService.Current.LightfinderLabelOffsetX;
var offsetY = (int)_configService.Current.LightfinderLabelOffsetY;
var labelScale = _configService.Current.LightfinderLabelScale;
bool showLightfinderInDtr = _configService.Current.ShowLightfinderInDtr;
var dtrLightfinderEnabled = _configService.Current.DtrColorsLightfinderEnabled;
var dtrLightfinderDisabled = _configService.Current.DtrColorsLightfinderDisabled;
var dtrLightfinderCooldown = _configService.Current.DtrColorsLightfinderCooldown;
var dtrLightfinderUnavailable = _configService.Current.DtrColorsLightfinderUnavailable;
ImGui.TextUnformatted("Connection");
if (ImGui.Checkbox("Auto-enable Lightfinder on server connection", ref autoEnable))
{
_configService.Current.LightfinderAutoEnableOnConnect = autoEnable;
_configService.Save();
}
_uiShared.DrawHelpText("When enabled, Lightfinder will automatically turn on after reconnecting to the Lightless server.");
_uiShared.ColoredSeparator(UIColors.Get("LightlessPurpleDefault"), 1.5f);
ImGui.TextUnformatted("Lightfinder Info Bar");
if (ImGui.Checkbox("Show Lightfinder status in Server info bar", ref showLightfinderInDtr))
{
_configService.Current.ShowLightfinderInDtr = showLightfinderInDtr;
_configService.Save();
}
_uiShared.DrawHelpText("Adds a Lightfinder status to the Server info bar. Left click toggles Lightfinder when visible.");
bool useLightfinderColors = _configService.Current.UseLightfinderColorsInDtr;
if (ImGui.Checkbox("Color-code the Lightfinder info bar according to status", ref useLightfinderColors))
{
_configService.Current.UseLightfinderColorsInDtr = useLightfinderColors;
_configService.Save();
}
ImGui.BeginDisabled(!showLightfinderInDtr || !useLightfinderColors);
if (InputDtrColors("Enables", ref dtrLightfinderEnabled))
{
_configService.Current.DtrColorsLightfinderEnabled = dtrLightfinderEnabled;
_configService.Save();
}
if (InputDtrColors("Disabled", ref dtrLightfinderDisabled))
{
_configService.Current.DtrColorsLightfinderDisabled = dtrLightfinderDisabled;
_configService.Save();
}
if (InputDtrColors("Cooldown", ref dtrLightfinderCooldown))
{
_configService.Current.DtrColorsLightfinderCooldown = dtrLightfinderCooldown;
_configService.Save();
}
if (InputDtrColors("Unavailable", ref dtrLightfinderUnavailable))
{
_configService.Current.DtrColorsLightfinderUnavailable = dtrLightfinderUnavailable;
_configService.Save();
}
ImGui.EndDisabled();
_uiShared.ColoredSeparator(UIColors.Get("LightlessPurpleDefault"), 1.5f);
ImGui.TextUnformatted("Alignment");
ImGui.BeginDisabled(autoAlign);