Skip to content

Commit

Permalink
feat: add delete button and close when solved
Browse files Browse the repository at this point in the history
  • Loading branch information
anna-is-cute committed Sep 3, 2024
1 parent 6e4c3f3 commit 08dff26
Showing 1 changed file with 32 additions and 9 deletions.
41 changes: 32 additions & 9 deletions Ui/Dialogs/MultipleModDirectoriesDialog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}

0 comments on commit 08dff26

Please sign in to comment.