From b461ad845d97fe546370ea90bdafc3e07eb6b692 Mon Sep 17 00:00:00 2001 From: Eauldane Date: Sun, 30 Nov 2025 20:11:39 +0000 Subject: [PATCH] Fix window closing if there's an invalid repo URL added. --- .../Internal/Windows/Settings/SettingsWindow.cs | 10 +++++++--- .../Settings/Widgets/ThirdRepoSettingsEntry.cs | 17 ++++++++++++++--- 2 files changed, 21 insertions(+), 6 deletions(-) diff --git a/Dalamud/Interface/Internal/Windows/Settings/SettingsWindow.cs b/Dalamud/Interface/Internal/Windows/Settings/SettingsWindow.cs index 581ef3746..cf9b520ef 100644 --- a/Dalamud/Interface/Internal/Windows/Settings/SettingsWindow.cs +++ b/Dalamud/Interface/Internal/Windows/Settings/SettingsWindow.cs @@ -175,17 +175,21 @@ internal sealed class SettingsWindow : Window { if (buttonChild) { - using var disabled = ImRaii.Disabled(this.tabs.Any(x => x.Entries.Any(y => !y.IsValid))); - using (ImRaii.PushStyle(ImGuiStyleVar.FrameRounding, 100f)) { using var font = ImRaii.PushFont(InterfaceManager.IconFont); + var hasInvalidEntries = this.tabs.Any(x => x.Entries.Any(y => !y.IsValid)); + + using var disabled = ImRaii.Disabled(hasInvalidEntries); + if (ImGui.Button(FontAwesomeIcon.Save.ToIconString(), new Vector2(40))) { this.Save(); - if (!ImGui.IsKeyDown(ImGuiKey.ModShift)) + hasInvalidEntries = this.tabs.Any(x => x.Entries.Any(y => !y.IsValid)); + + if (!hasInvalidEntries && !ImGui.IsKeyDown(ImGuiKey.ModShift)) this.IsOpen = false; } } diff --git a/Dalamud/Interface/Internal/Windows/Settings/Widgets/ThirdRepoSettingsEntry.cs b/Dalamud/Interface/Internal/Windows/Settings/Widgets/ThirdRepoSettingsEntry.cs index b0cc61eb0..d0a750c31 100644 --- a/Dalamud/Interface/Internal/Windows/Settings/Widgets/ThirdRepoSettingsEntry.cs +++ b/Dalamud/Interface/Internal/Windows/Settings/Widgets/ThirdRepoSettingsEntry.cs @@ -42,6 +42,7 @@ internal class ThirdRepoSettingsEntry : SettingsEntry this.thirdRepoList = [.. Service.Get().ThirdRepoList.Select(x => x.Clone())]; this.thirdRepoListChanged = false; + this.IsValid = true; } public override void Save() @@ -50,9 +51,12 @@ internal class ThirdRepoSettingsEntry : SettingsEntry var addedPendingRepo = this.TryAddTempRepo(); if (!addedPendingRepo && hasPendingRepo) { + this.IsValid = false; return; } + this.IsValid = true; + Service.Get().ThirdRepoList = [.. this.thirdRepoList.Select(x => x.Clone())]; @@ -179,6 +183,8 @@ internal class ThirdRepoSettingsEntry : SettingsEntry var url = thirdRepoSetting.Url; if (ImGui.InputText($"##thirdRepoInput", ref url, 65535, ImGuiInputTextFlags.EnterReturnsTrue)) { + this.IsValid = true; + var contains = this.thirdRepoList.Select(repo => repo.Url).Contains(url); if (thirdRepoSetting.Url == url) { @@ -196,8 +202,8 @@ internal class ThirdRepoSettingsEntry : SettingsEntry } else { + this.thirdRepoListChanged = thirdRepoSetting.Url != url; thirdRepoSetting.Url = url; - this.thirdRepoListChanged = url != thirdRepoSetting.Url; } } @@ -236,8 +242,10 @@ internal class ThirdRepoSettingsEntry : SettingsEntry ImGui.Text(repoNumber.ToString()); ImGui.NextColumn(); ImGui.SetNextItemWidth(-1); - ImGui.InputText("##thirdRepoUrlInput"u8, ref this.thirdRepoTempUrl, 300); - ImGui.NextColumn(); + if (ImGui.InputText("##thirdRepoUrlInput"u8, ref this.thirdRepoTempUrl, 300)) + { + this.IsValid = true; + } ImGui.NextColumn(); // Enabled button ImGui.NextColumn(); if (!string.IsNullOrEmpty(this.thirdRepoTempUrl) && ImGuiComponents.IconButton(FontAwesomeIcon.Plus)) @@ -267,6 +275,7 @@ internal class ThirdRepoSettingsEntry : SettingsEntry { this.thirdRepoAddError = Loc.Localize("DalamudThirdRepoExists", "Repo already exists."); Task.Delay(5000).ContinueWith(t => this.thirdRepoAddError = string.Empty); + this.IsValid = false; return false; } @@ -274,6 +283,7 @@ internal class ThirdRepoSettingsEntry : SettingsEntry { this.thirdRepoAddError = Loc.Localize("DalamudThirdRepoNotUrl", "The entered address is not a valid URL.\nDid you mean to enter it as a DevPlugin in the fields above instead?"); Task.Delay(5000).ContinueWith(t => this.thirdRepoAddError = string.Empty); + this.IsValid = false; return false; } @@ -284,6 +294,7 @@ internal class ThirdRepoSettingsEntry : SettingsEntry }); this.thirdRepoListChanged = true; this.thirdRepoTempUrl = string.Empty; + this.IsValid = true; return true; }