From 652b2e99d25239fe2fc0f6d0939531808d92cf8a Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Fri, 15 Sep 2023 01:06:53 +0200 Subject: [PATCH] Add key checks to restoring from backup or deleting backups. --- Penumbra/UI/ModsTab/ModPanelEditTab.cs | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/Penumbra/UI/ModsTab/ModPanelEditTab.cs b/Penumbra/UI/ModsTab/ModPanelEditTab.cs index 0e239b7f..bd5a62c4 100644 --- a/Penumbra/UI/ModsTab/ModPanelEditTab.cs +++ b/Penumbra/UI/ModsTab/ModPanelEditTab.cs @@ -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(); @@ -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; @@ -49,6 +50,7 @@ public ModPanelEditTab(ModManager modManager, ModFileSystemSelector selector, Mo _editor = editor; _filenames = filenames; _modExportManager = modExportManager; + _config = config; } public ReadOnlySpan Label @@ -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}\"."); + } } /// Anything about editing the regular meta information about the mod.