Skip to content

Commit

Permalink
Add key checks to restoring from backup or deleting backups.
Browse files Browse the repository at this point in the history
  • Loading branch information
Ottermandias committed Sep 14, 2023
1 parent c5ef7bf commit 652b2e9
Showing 1 changed file with 17 additions and 5 deletions.
22 changes: 17 additions & 5 deletions Penumbra/UI/ModsTab/ModPanelEditTab.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ public class ModPanelEditTab : ITab
private readonly ModFileSystemSelector _selector;
private readonly ModEditWindow _editWindow;
private readonly ModEditor _editor;
private readonly Configuration _config;

private readonly TagButtons _modTags = new();

Expand All @@ -39,7 +40,7 @@ public class ModPanelEditTab : ITab
private Mod _mod = null!;

public ModPanelEditTab(ModManager modManager, ModFileSystemSelector selector, ModFileSystem fileSystem, ChatService chat,
ModEditWindow editWindow, ModEditor editor, FilenameService filenames, ModExportManager modExportManager)
ModEditWindow editWindow, ModEditor editor, FilenameService filenames, ModExportManager modExportManager, Configuration config)
{
_modManager = modManager;
_selector = selector;
Expand All @@ -49,6 +50,7 @@ public ModPanelEditTab(ModManager modManager, ModFileSystemSelector selector, Mo
_editor = editor;
_filenames = filenames;
_modExportManager = modExportManager;
_config = config;
}

public ReadOnlySpan<byte> Label
Expand Down Expand Up @@ -162,17 +164,27 @@ private void BackupButtons(Vector2 buttonSize)

ImGui.SameLine();
tt = backup.Exists
? $"Delete existing mod export \"{backup.Name}\"."
? $"Delete existing mod export \"{backup.Name}\" (hold {_config.DeleteModModifier} while clicking)."
: $"Exported mod \"{backup.Name}\" does not exist.";
if (ImGuiUtil.DrawDisabledButton("Delete Export", buttonSize, tt, !backup.Exists))
if (ImGuiUtil.DrawDisabledButton("Delete Export", buttonSize, tt, !backup.Exists || !_config.DeleteModModifier.IsActive()))
backup.Delete();

tt = backup.Exists
? $"Restore mod from exported file \"{backup.Name}\"."
? $"Restore mod from exported file \"{backup.Name}\" (hold {_config.DeleteModModifier} while clicking)."
: $"Exported mod \"{backup.Name}\" does not exist.";
ImGui.SameLine();
if (ImGuiUtil.DrawDisabledButton("Restore From Export", buttonSize, tt, !backup.Exists))
if (ImGuiUtil.DrawDisabledButton("Restore From Export", buttonSize, tt, !backup.Exists || !_config.DeleteModModifier.IsActive()))
backup.Restore(_modManager);
if (backup.Exists)
{
ImGui.SameLine();
using (var font = ImRaii.PushFont(UiBuilder.IconFont))
{
ImGui.TextUnformatted(FontAwesomeIcon.CheckCircle.ToIconString());
}

ImGuiUtil.HoverTooltip($"Export exists in \"{backup.Name}\".");
}
}

/// <summary> Anything about editing the regular meta information about the mod. </summary>
Expand Down

0 comments on commit 652b2e9

Please sign in to comment.