Initialize migration. (#88)

Co-authored-by: defnotken <itsdefnotken@gmail.com>
Co-authored-by: cake <admin@cakeandbanana.nl>
Reviewed-on: #88
Reviewed-by: cake <cake@noreply.git.lightless-sync.org>
Co-authored-by: defnotken <defnotken@noreply.git.lightless-sync.org>
Co-committed-by: defnotken <defnotken@noreply.git.lightless-sync.org>
This commit was merged in pull request #88.
This commit is contained in:
2025-11-29 18:02:39 +01:00
committed by cake
parent 9e12725f89
commit 740b58afc4
63 changed files with 1720 additions and 1005 deletions

View File

@@ -612,7 +612,7 @@ public class SettingsUi : WindowMediatorSubscriberBase
}
}
private bool DrawStyleResetButton(string key, bool hasOverride, string? tooltipOverride = null)
private static bool DrawStyleResetButton(string key, bool hasOverride, string? tooltipOverride = null)
{
using var id = ImRaii.PushId($"reset-{key}");
using var disabled = ImRaii.Disabled(!hasOverride);
@@ -736,7 +736,7 @@ public class SettingsUi : WindowMediatorSubscriberBase
_uiShared.DrawHelpText("Controls how many uploads can run at once.");
_uiShared.ColoredSeparator(UIColors.Get("LightlessPurple"), 2f);
UiSharedService.ColoredSeparator(UIColors.Get("LightlessPurple"), 2f);
if (ImGui.Checkbox("Enable Pair Download Limiter", ref limitPairApplications))
{
@@ -783,7 +783,7 @@ public class SettingsUi : WindowMediatorSubscriberBase
ImGui.TextColored(ImGuiColors.DalamudGrey, "Pair apply limiter is disabled.");
}
_uiShared.ColoredSeparator(UIColors.Get("LightlessPurple"), 2f);
UiSharedService.ColoredSeparator(UIColors.Get("LightlessPurple"), 2f);
if (ImGui.Checkbox("Use Alternative Upload Method", ref useAlternativeUpload))
{
@@ -899,13 +899,10 @@ public class SettingsUi : WindowMediatorSubscriberBase
using var tree = ImRaii.TreeNode("Speed Test to Servers");
if (tree)
{
if (_downloadServersTask == null || ((_downloadServersTask?.IsCompleted ?? false) &&
(!_downloadServersTask?.IsCompletedSuccessfully ?? false)))
if ((_downloadServersTask == null || ((_downloadServersTask?.IsCompleted ?? false) &&
(!_downloadServersTask?.IsCompletedSuccessfully ?? false))) && _uiShared.IconTextButton(FontAwesomeIcon.GroupArrowsRotate, "Update Download Server List"))
{
if (_uiShared.IconTextButton(FontAwesomeIcon.GroupArrowsRotate, "Update Download Server List"))
{
_downloadServersTask = GetDownloadServerList();
}
_downloadServersTask = GetDownloadServerList();
}
if (_downloadServersTask != null && _downloadServersTask.IsCompleted &&
@@ -1136,9 +1133,9 @@ public class SettingsUi : WindowMediatorSubscriberBase
.DeserializeAsync<List<string>>(await result.Content.ReadAsStreamAsync().ConfigureAwait(false))
.ConfigureAwait(false);
}
catch (Exception ex)
catch (Exception)
{
_logger.LogWarning(ex, "Failed to get download server list");
_logger.LogWarning("Failed to get download server list");
throw;
}
}
@@ -1219,7 +1216,7 @@ public class SettingsUi : WindowMediatorSubscriberBase
UiSharedService.TooltipSeparator
+ "Keeping LOD enabled can lead to more crashes. Use at your own risk.");
_uiShared.ColoredSeparator(UIColors.Get("LightlessYellow"), 2f);
UiSharedService.ColoredSeparator(UIColors.Get("LightlessYellow"), 2f);
}
private void DrawFileStorageSettings()
@@ -1421,7 +1418,7 @@ public class SettingsUi : WindowMediatorSubscriberBase
}
}
_uiShared.ColoredSeparator(UIColors.Get("LightlessYellow"), 1.5f);
UiSharedService.ColoredSeparator(UIColors.Get("LightlessYellow"), 1.5f);
ImGui.TreePop();
}
@@ -1453,7 +1450,7 @@ public class SettingsUi : WindowMediatorSubscriberBase
}
catch (IOException ex)
{
_logger.LogWarning(ex, $"Could not delete file {file} because it is in use.");
_logger.LogWarning(ex, "Could not delete file {file} because it is in use.", file);
}
}
@@ -1487,7 +1484,7 @@ public class SettingsUi : WindowMediatorSubscriberBase
ImGui.EndDisabled();
ImGui.Unindent();
_uiShared.ColoredSeparator(UIColors.Get("DimRed"), 1.5f);
UiSharedService.ColoredSeparator(UIColors.Get("DimRed"), 1.5f);
ImGui.TreePop();
}
}
@@ -1500,8 +1497,6 @@ public class SettingsUi : WindowMediatorSubscriberBase
}
_lastTab = "General";
//UiSharedService.FontText("Experimental", _uiShared.UidFont);
//ImGui.Separator();
_uiShared.UnderlinedBigText("General Settings", UIColors.Get("LightlessBlue"));
ImGui.Dummy(new Vector2(10));
@@ -1539,7 +1534,7 @@ public class SettingsUi : WindowMediatorSubscriberBase
ImGuiColors.DalamudRed);
}
_uiShared.ColoredSeparator(UIColors.Get("LightlessPurple"), 1.5f);
UiSharedService.ColoredSeparator(UIColors.Get("LightlessPurple"), 1.5f);
ImGui.TreePop();
}
@@ -1567,7 +1562,7 @@ public class SettingsUi : WindowMediatorSubscriberBase
_uiShared.DrawHelpText(
"This will automatically populate user notes using the first encountered player name if the note was not set prior");
_uiShared.ColoredSeparator(UIColors.Get("LightlessPurple"), 1.5f);
UiSharedService.ColoredSeparator(UIColors.Get("LightlessPurple"), 1.5f);
ImGui.TreePop();
}
@@ -1635,7 +1630,7 @@ public class SettingsUi : WindowMediatorSubscriberBase
}
_uiShared.ColoredSeparator(UIColors.Get("LightlessPurple"), 1.5f);
UiSharedService.ColoredSeparator(UIColors.Get("LightlessPurple"), 1.5f);
ImGui.TreePop();
}
@@ -1675,7 +1670,7 @@ public class SettingsUi : WindowMediatorSubscriberBase
}
_uiShared.DrawHelpText("When enabled, Lightfinder will automatically turn on after reconnecting to the Lightless server.");
_uiShared.ColoredSeparator(UIColors.Get("LightlessPurpleDefault"), 1.5f);
UiSharedService.ColoredSeparator(UIColors.Get("LightlessPurpleDefault"), 1.5f);
ImGui.TextUnformatted("Lightfinder Nameplate Colors");
if (ImGui.BeginTable("##LightfinderColorTable", 3, ImGuiTableFlags.Borders | ImGuiTableFlags.RowBg | ImGuiTableFlags.SizingFixedFit))
@@ -1731,7 +1726,7 @@ public class SettingsUi : WindowMediatorSubscriberBase
ImGui.Spacing();
_uiShared.ColoredSeparator(UIColors.Get("LightlessPurpleDefault"), 1.5f);
UiSharedService.ColoredSeparator(UIColors.Get("LightlessPurpleDefault"), 1.5f);
ImGui.TextUnformatted("Lightfinder Info Bar");
if (ImGui.Checkbox("Show Lightfinder status in Server info bar", ref showLightfinderInDtr))
@@ -1827,7 +1822,7 @@ public class SettingsUi : WindowMediatorSubscriberBase
}
ImGui.EndDisabled();
_uiShared.ColoredSeparator(UIColors.Get("LightlessPurpleDefault"), 1.5f);
UiSharedService.ColoredSeparator(UIColors.Get("LightlessPurpleDefault"), 1.5f);
ImGui.TextUnformatted("Alignment");
ImGui.BeginDisabled(autoAlign);
@@ -1952,7 +1947,7 @@ public class SettingsUi : WindowMediatorSubscriberBase
}
_uiShared.ColoredSeparator(UIColors.Get("LightlessPurpleDefault"), 1.5f);
UiSharedService.ColoredSeparator(UIColors.Get("LightlessPurpleDefault"), 1.5f);
ImGui.TextUnformatted("Visibility");
var showOwn = _configService.Current.LightfinderLabelShowOwn;
@@ -1990,7 +1985,7 @@ public class SettingsUi : WindowMediatorSubscriberBase
}
_uiShared.DrawHelpText("Toggles Lightfinder label when no nameplate(s) is visible.");
_uiShared.ColoredSeparator(UIColors.Get("LightlessPurpleDefault"), 1.5f);
UiSharedService.ColoredSeparator(UIColors.Get("LightlessPurpleDefault"), 1.5f);
ImGui.TextUnformatted("Label");
var useIcon = _configService.Current.LightfinderLabelUseIcon;
@@ -2096,7 +2091,7 @@ public class SettingsUi : WindowMediatorSubscriberBase
_lightfinderIconPresetIndex = -1;
}
_uiShared.ColoredSeparator(UIColors.Get("LightlessPurple"), 1.5f);
UiSharedService.ColoredSeparator(UIColors.Get("LightlessPurple"), 1.5f);
ImGui.TreePop();
}
@@ -2184,7 +2179,7 @@ public class SettingsUi : WindowMediatorSubscriberBase
ImGui.Spacing();
_uiShared.ColoredSeparator(UIColors.Get("LightlessPurpleDefault"), 1.5f);
UiSharedService.ColoredSeparator(UIColors.Get("LightlessPurpleDefault"), 1.5f);
ImGui.TextUnformatted("Server Info Bar Colors");
@@ -2236,7 +2231,7 @@ public class SettingsUi : WindowMediatorSubscriberBase
ImGui.Spacing();
_uiShared.ColoredSeparator(UIColors.Get("LightlessPurpleDefault"), 1.5f);
UiSharedService.ColoredSeparator(UIColors.Get("LightlessPurpleDefault"), 1.5f);
ImGui.TextUnformatted("Nameplate Colors");
@@ -2281,7 +2276,7 @@ public class SettingsUi : WindowMediatorSubscriberBase
ImGui.Spacing();
_uiShared.ColoredSeparator(UIColors.Get("LightlessPurpleDefault"), 1.5f);
UiSharedService.ColoredSeparator(UIColors.Get("LightlessPurpleDefault"), 1.5f);
ImGui.TextUnformatted("UI Theme");
@@ -2303,7 +2298,7 @@ public class SettingsUi : WindowMediatorSubscriberBase
DrawThemeOverridesSection();
_uiShared.ColoredSeparator(UIColors.Get("LightlessPurple"), 1.5f);
UiSharedService.ColoredSeparator(UIColors.Get("LightlessPurple"), 1.5f);
ImGui.TreePop();
}
@@ -2401,7 +2396,7 @@ public class SettingsUi : WindowMediatorSubscriberBase
_configService.Save();
}
_uiShared.ColoredSeparator(UIColors.Get("LightlessPurple"), 1.5f);
UiSharedService.ColoredSeparator(UIColors.Get("LightlessPurple"), 1.5f);
ImGui.TreePop();
}
@@ -2444,7 +2439,7 @@ public class SettingsUi : WindowMediatorSubscriberBase
_uiShared.DrawHelpText("Will show profiles that have the NSFW tag enabled");
_uiShared.ColoredSeparator(UIColors.Get("LightlessPurple"), 1.5f);
UiSharedService.ColoredSeparator(UIColors.Get("LightlessPurple"), 1.5f);
ImGui.TreePop();
}
ImGui.Separator();
@@ -2542,7 +2537,7 @@ public class SettingsUi : WindowMediatorSubscriberBase
+ "Default: 165 thousand");
}
_uiShared.ColoredSeparator(UIColors.Get("LightlessPurple"), 1.5f);
UiSharedService.ColoredSeparator(UIColors.Get("LightlessPurple"), 1.5f);
ImGui.TreePop();
}
@@ -2646,7 +2641,7 @@ public class SettingsUi : WindowMediatorSubscriberBase
+ "Default: 250 thousand");
}
_uiShared.ColoredSeparator(UIColors.Get("LightlessPurple"), 1.5f);
UiSharedService.ColoredSeparator(UIColors.Get("LightlessPurple"), 1.5f);
ImGui.TreePop();
}
@@ -2726,7 +2721,7 @@ public class SettingsUi : WindowMediatorSubscriberBase
ImGui.Dummy(new Vector2(5));
_uiShared.ColoredSeparator(UIColors.Get("DimRed"), 3f);
UiSharedService.ColoredSeparator(UIColors.Get("DimRed"), 3f);
var onlyUncompressed = textureConfig.OnlyDownscaleUncompressedTextures;
if (ImGui.Checkbox("Only downscale uncompressed textures", ref onlyUncompressed))
{
@@ -2734,7 +2729,7 @@ public class SettingsUi : WindowMediatorSubscriberBase
_playerPerformanceConfigService.Save();
}
_uiShared.DrawHelpText("If disabled, compressed textures will be targeted for downscaling too.");
_uiShared.ColoredSeparator(UIColors.Get("DimRed"), 3f);
UiSharedService.ColoredSeparator(UIColors.Get("DimRed"), 3f);
ImGui.Dummy(new Vector2(5));
@@ -2742,7 +2737,7 @@ public class SettingsUi : WindowMediatorSubscriberBase
ImGui.Dummy(new Vector2(5));
_uiShared.ColoredSeparator(UIColors.Get("LightlessYellow"), 1.5f);
UiSharedService.ColoredSeparator(UIColors.Get("LightlessYellow"), 1.5f);
ImGui.TreePop();
}
@@ -2890,7 +2885,7 @@ public class SettingsUi : WindowMediatorSubscriberBase
ImGui.EndPopup();
}
_uiShared.ColoredSeparator(UIColors.Get("DimRed"), 1.5f);
UiSharedService.ColoredSeparator(UIColors.Get("DimRed"), 1.5f);
ImGui.TreePop();
}
@@ -3468,15 +3463,13 @@ public class SettingsUi : WindowMediatorSubscriberBase
private int _lastSelectedServerIndex = -1;
private Task<(bool Success, bool PartialSuccess, string Result)>? _secretKeysConversionTask = null;
private CancellationTokenSource _secretKeysConversionCts = new CancellationTokenSource();
private CancellationTokenSource _secretKeysConversionCts = new();
private async Task<(bool Success, bool partialSuccess, string Result)> ConvertSecretKeysToUIDs(
ServerStorage serverStorage, CancellationToken token)
{
List<Authentication> failedConversions = serverStorage.Authentications
.Where(u => u.SecretKeyIdx == -1 && string.IsNullOrEmpty(u.UID)).ToList();
List<Authentication> conversionsToAttempt = serverStorage.Authentications
.Where(u => u.SecretKeyIdx != -1 && string.IsNullOrEmpty(u.UID)).ToList();
List<Authentication> failedConversions = [.. serverStorage.Authentications.Where(u => u.SecretKeyIdx == -1 && string.IsNullOrEmpty(u.UID))];
List<Authentication> conversionsToAttempt = [.. serverStorage.Authentications.Where(u => u.SecretKeyIdx != -1 && string.IsNullOrEmpty(u.UID))];
List<Authentication> successfulConversions = [];
Dictionary<string, List<Authentication>> secretKeyMapping = new(StringComparer.Ordinal);
foreach (var authEntry in conversionsToAttempt)
@@ -3546,6 +3539,7 @@ public class SettingsUi : WindowMediatorSubscriberBase
sb.Append(string.Join(", ", failedConversions.Select(k => k.CharacterName)));
}
_secretKeysConversionCts.Dispose();
return (true, failedConversions.Count != 0, sb.ToString());
}
@@ -3914,7 +3908,7 @@ public class SettingsUi : WindowMediatorSubscriberBase
ImGui.Unindent();
}
_uiShared.ColoredSeparator(UIColors.Get("LightlessPurple"), 1.5f);
UiSharedService.ColoredSeparator(UIColors.Get("LightlessPurple"), 1.5f);
ImGui.TreePop();
}
@@ -3956,7 +3950,7 @@ public class SettingsUi : WindowMediatorSubscriberBase
_uiShared.DrawHelpText("Click anywhere on a notification to dismiss it. Notifications with action buttons (like pair requests) are excluded.");
_uiShared.ColoredSeparator(UIColors.Get("LightlessPurple"), 1.5f);
UiSharedService.ColoredSeparator(UIColors.Get("LightlessPurple"), 1.5f);
ImGui.TreePop();
}
@@ -4119,7 +4113,7 @@ public class SettingsUi : WindowMediatorSubscriberBase
ImGui.SetTooltip("Right click to reset to default (3).");
_uiShared.DrawHelpText("Width of the colored accent bar on the left side.");
_uiShared.ColoredSeparator(UIColors.Get("LightlessPurple"), 1.5f);
UiSharedService.ColoredSeparator(UIColors.Get("LightlessPurple"), 1.5f);
ImGui.TreePop();
}
}
@@ -4214,7 +4208,7 @@ public class SettingsUi : WindowMediatorSubscriberBase
if (ImGui.IsItemHovered())
ImGui.SetTooltip("Right click to reset to default (20).");
_uiShared.ColoredSeparator(UIColors.Get("LightlessPurple"), 1.5f);
UiSharedService.ColoredSeparator(UIColors.Get("LightlessPurple"), 1.5f);
ImGui.TreePop();
}
@@ -4229,7 +4223,7 @@ public class SettingsUi : WindowMediatorSubscriberBase
_uiShared.DrawHelpText(
"Configure which sounds play for each notification type. Use the play button to preview sounds.");
_uiShared.ColoredSeparator(UIColors.Get("LightlessPurple"), 1.5f);
UiSharedService.ColoredSeparator(UIColors.Get("LightlessPurple"), 1.5f);
ImGui.TreePop();
}
@@ -4277,7 +4271,7 @@ public class SettingsUi : WindowMediatorSubscriberBase
"Only show online notifications for pairs where you have set an individual note.");
ImGui.Unindent();
_uiShared.ColoredSeparator(UIColors.Get("LightlessGreen"), 1.5f);
UiSharedService.ColoredSeparator(UIColors.Get("LightlessGreen"), 1.5f);
ImGui.TreePop();
}
@@ -4293,7 +4287,7 @@ public class SettingsUi : WindowMediatorSubscriberBase
_uiShared.DrawHelpText(
"When you receive a pair request, show Accept/Decline buttons in the notification.");
_uiShared.ColoredSeparator(UIColors.Get("LightlessPurple"), 1.5f);
UiSharedService.ColoredSeparator(UIColors.Get("LightlessPurple"), 1.5f);
ImGui.TreePop();
}
@@ -4309,7 +4303,7 @@ public class SettingsUi : WindowMediatorSubscriberBase
_uiShared.DrawHelpText(
"When a player exceeds performance thresholds or is auto-paused, show Pause/Unpause buttons in the notification.");
_uiShared.ColoredSeparator(UIColors.Get("LightlessOrange"), 1.5f);
UiSharedService.ColoredSeparator(UIColors.Get("LightlessOrange"), 1.5f);
ImGui.TreePop();
}
@@ -4324,7 +4318,7 @@ public class SettingsUi : WindowMediatorSubscriberBase
_uiShared.DrawHelpText("Disable warning notifications for missing optional plugins.");
_uiShared.ColoredSeparator(UIColors.Get("LightlessYellow"), 1.5f);
UiSharedService.ColoredSeparator(UIColors.Get("LightlessYellow"), 1.5f);
ImGui.TreePop();
}
@@ -4334,32 +4328,32 @@ public class SettingsUi : WindowMediatorSubscriberBase
}
}
private NotificationLocation[] GetLightlessNotificationLocations()
private static NotificationLocation[] GetLightlessNotificationLocations()
{
return new[]
{
return
[
NotificationLocation.LightlessUi, NotificationLocation.Chat, NotificationLocation.ChatAndLightlessUi, NotificationLocation.Nowhere
};
];
}
private NotificationLocation[] GetDownloadNotificationLocations()
private static NotificationLocation[] GetDownloadNotificationLocations()
{
return new[]
{
return
[
NotificationLocation.LightlessUi, NotificationLocation.TextOverlay, NotificationLocation.Nowhere
};
];
}
private NotificationLocation[] GetClassicNotificationLocations()
private static NotificationLocation[] GetClassicNotificationLocations()
{
return new[]
{
return
[
NotificationLocation.Toast, NotificationLocation.Chat, NotificationLocation.Both,
NotificationLocation.Nowhere
};
];
}
private string GetNotificationLocationLabel(NotificationLocation location)
private static string GetNotificationLocationLabel(NotificationLocation location)
{
return location switch
{
@@ -4374,7 +4368,7 @@ public class SettingsUi : WindowMediatorSubscriberBase
};
}
private string GetNotificationCornerLabel(NotificationCorner corner)
private static string GetNotificationCornerLabel(NotificationCorner corner)
{
return corner switch
{