add info options for server bar, direct settings button in lightfinder window and fix color swaps

This commit is contained in:
azyges
2025-10-11 00:48:19 +09:00
parent f01229a97f
commit 9b04976aa6
9 changed files with 238 additions and 18 deletions

View File

@@ -73,6 +73,8 @@ public class SettingsUi : WindowMediatorSubscriberBase
private string _lightfinderIconInput = string.Empty;
private bool _lightfinderIconInputInitialized = false;
private int _lightfinderIconPresetIndex = -1;
private bool _selectGeneralTabOnNextDraw = false;
private bool _openLightfinderSectionOnNextDraw = false;
private static readonly (string Label, SeIconChar Icon)[] LightfinderIconPresets = new[]
{
("Link Marker", SeIconChar.LinkMarker),
@@ -136,6 +138,12 @@ public class SettingsUi : WindowMediatorSubscriberBase
};
Mediator.Subscribe<OpenSettingsUiMessage>(this, (_) => Toggle());
Mediator.Subscribe<OpenLightfinderSettingsMessage>(this, (_) =>
{
IsOpen = true;
_selectGeneralTabOnNextDraw = true;
_openLightfinderSectionOnNextDraw = true;
});
Mediator.Subscribe<SwitchToIntroUiMessage>(this, (_) => IsOpen = false);
Mediator.Subscribe<CutsceneStartMessage>(this, (_) => UiSharedService_GposeStart());
Mediator.Subscribe<CutsceneEndMessage>(this, (_) => UiSharedService_GposeEnd());
@@ -222,6 +230,17 @@ public class SettingsUi : WindowMediatorSubscriberBase
}
}
private static DtrEntry.Colors SwapColorChannels(DtrEntry.Colors colors)
=> new(SwapColorChannels(colors.Foreground), SwapColorChannels(colors.Glow));
private static uint SwapColorChannels(uint color)
{
if (color == 0)
return 0;
return ((color & 0xFFu) << 16) | (color & 0xFF00u) | ((color >> 16) & 0xFFu);
}
private void DrawBlockedTransfers()
{
_lastTab = "BlockedTransfers";
@@ -1081,18 +1100,31 @@ public class SettingsUi : WindowMediatorSubscriberBase
ImGui.Separator();
var forceOpenLightfinder = _openLightfinderSectionOnNextDraw;
if (_openLightfinderSectionOnNextDraw)
{
ImGui.SetNextItemOpen(true, ImGuiCond.Always);
}
if (_uiShared.MediumTreeNode("Lightfinder", UIColors.Get("LightlessPurple")))
{
if (forceOpenLightfinder)
{
ImGui.SetScrollHereY();
}
_openLightfinderSectionOnNextDraw = false;
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;
var dtrLightfinderEnabled = SwapColorChannels(_configService.Current.DtrColorsLightfinderEnabled);
var dtrLightfinderDisabled = SwapColorChannels(_configService.Current.DtrColorsLightfinderDisabled);
var dtrLightfinderCooldown = SwapColorChannels(_configService.Current.DtrColorsLightfinderCooldown);
var dtrLightfinderUnavailable = SwapColorChannels(_configService.Current.DtrColorsLightfinderUnavailable);
ImGui.TextUnformatted("Connection");
if (ImGui.Checkbox("Auto-enable Lightfinder on server connection", ref autoEnable))
@@ -1112,6 +1144,40 @@ public class SettingsUi : WindowMediatorSubscriberBase
}
_uiShared.DrawHelpText("Adds a Lightfinder status to the Server info bar. Left click toggles Lightfinder when visible.");
var lightfinderDisplayMode = _configService.Current.LightfinderDtrDisplayMode;
var lightfinderDisplayLabel = lightfinderDisplayMode switch
{
LightfinderDtrDisplayMode.PendingPairRequests => "Pending pair requests",
_ => "Nearby Lightfinder users",
};
ImGui.BeginDisabled(!showLightfinderInDtr);
if (ImGui.BeginCombo("Info display", lightfinderDisplayLabel))
{
foreach (var option in Enum.GetValues<LightfinderDtrDisplayMode>())
{
var optionLabel = option switch
{
LightfinderDtrDisplayMode.PendingPairRequests => "Pending pair requests",
_ => "Nearby Lightfinder users",
};
var selected = option == lightfinderDisplayMode;
if (ImGui.Selectable(optionLabel, selected))
{
_configService.Current.LightfinderDtrDisplayMode = option;
_configService.Save();
}
if (selected)
ImGui.SetItemDefaultFocus();
}
ImGui.EndCombo();
}
ImGui.EndDisabled();
_uiShared.DrawHelpText("Choose what the Lightfinder info bar displays while Lightfinder is active.");
bool useLightfinderColors = _configService.Current.UseLightfinderColorsInDtr;
if (ImGui.Checkbox("Color-code the Lightfinder info bar according to status", ref useLightfinderColors))
{
@@ -1120,24 +1186,24 @@ public class SettingsUi : WindowMediatorSubscriberBase
}
ImGui.BeginDisabled(!showLightfinderInDtr || !useLightfinderColors);
if (InputDtrColors("Enables", ref dtrLightfinderEnabled))
if (InputDtrColors("Enabled", ref dtrLightfinderEnabled))
{
_configService.Current.DtrColorsLightfinderEnabled = dtrLightfinderEnabled;
_configService.Current.DtrColorsLightfinderEnabled = SwapColorChannels(dtrLightfinderEnabled);
_configService.Save();
}
if (InputDtrColors("Disabled", ref dtrLightfinderDisabled))
{
_configService.Current.DtrColorsLightfinderDisabled = dtrLightfinderDisabled;
_configService.Current.DtrColorsLightfinderDisabled = SwapColorChannels(dtrLightfinderDisabled);
_configService.Save();
}
if (InputDtrColors("Cooldown", ref dtrLightfinderCooldown))
{
_configService.Current.DtrColorsLightfinderCooldown = dtrLightfinderCooldown;
_configService.Current.DtrColorsLightfinderCooldown = SwapColorChannels(dtrLightfinderCooldown);
_configService.Save();
}
if (InputDtrColors("Unavailable", ref dtrLightfinderUnavailable))
{
_configService.Current.DtrColorsLightfinderUnavailable = dtrLightfinderUnavailable;
_configService.Current.DtrColorsLightfinderUnavailable = SwapColorChannels(dtrLightfinderUnavailable);
_configService.Save();
}
ImGui.EndDisabled();
@@ -2696,8 +2762,15 @@ public class SettingsUi : WindowMediatorSubscriberBase
ImGui.Separator();
if (ImGui.BeginTabBar("mainTabBar"))
{
if (ImGui.BeginTabItem("General"))
var generalTabFlags = ImGuiTabItemFlags.None;
if (_selectGeneralTabOnNextDraw)
{
generalTabFlags |= ImGuiTabItemFlags.SetSelected;
}
if (ImGui.BeginTabItem("General", generalTabFlags))
{
_selectGeneralTabOnNextDraw = false;
DrawGeneral();
ImGui.EndTabItem();
}