From 08dff26c383a3f05fd9a89662bae6ba5693819b3 Mon Sep 17 00:00:00 2001 From: Anna Date: Mon, 2 Sep 2024 21:16:55 -0400 Subject: [PATCH] feat: add delete button and close when solved --- Ui/Dialogs/MultipleModDirectoriesDialog.cs | 41 +++++++++++++++++----- 1 file changed, 32 insertions(+), 9 deletions(-) diff --git a/Ui/Dialogs/MultipleModDirectoriesDialog.cs b/Ui/Dialogs/MultipleModDirectoriesDialog.cs index 9b137f2..6d620c8 100644 --- a/Ui/Dialogs/MultipleModDirectoriesDialog.cs +++ b/Ui/Dialogs/MultipleModDirectoriesDialog.cs @@ -58,26 +58,49 @@ protected override DrawStatus InnerDraw() { ImGui.Spacing(); + var numExisting = 0; + foreach (var (path, version) in this.DirectoryVersions) { ImGui.Bullet(); var exists = this.PathStatus.GetValueOrDefault(path, false); + if (exists) { + numExisting += 1; + } + using (ImGuiHelper.DisabledUnless(exists)) { ImGui.SameLine(); - ImGui.TextUnformatted($"v{version} -"); - ImGui.SameLine(); - if (ImGui.SmallButton($"Open##{path}")) { - Process.Start(new ProcessStartInfo(path) { - UseShellExecute = true, - }); + ImGui.BeginGroup(); + using (new OnDispose(ImGui.EndGroup)) { + ImGui.TextUnformatted($"v{version}"); + + ImGui.SameLine(); + if (ImGui.SmallButton($"Open##{path}")) { + Process.Start(new ProcessStartInfo(path) { + UseShellExecute = true, + }); + } + + ImGui.SameLine(); + + var shift = ImGui.GetIO().KeyShift; + using (ImGuiHelper.DisabledUnless(shift)) { + if (ImGui.SmallButton("Permanently delete")) { + Directory.Delete(path, true); + this.UpdateStatuses(); + } + } + + if (!shift) { + ImGuiHelper.Tooltip("Hold Shift to enable this button.", ImGuiHoveredFlags.AllowWhenDisabled); + } } - ImGui.SameLine(); - ImGui.TextUnformatted($" - {path}"); + ImGuiHelper.Tooltip(path); } } - return DrawStatus.Continue; + return numExisting <= 1 ? DrawStatus.Finished : DrawStatus.Continue; } }