diff --git a/Penumbra/Import/TexToolsImporter.Gui.cs b/Penumbra/Import/TexToolsImporter.Gui.cs index 309f107a..a069204c 100644 --- a/Penumbra/Import/TexToolsImporter.Gui.cs +++ b/Penumbra/Import/TexToolsImporter.Gui.cs @@ -25,20 +25,22 @@ public bool DrawProgressInfo(Vector2 size) if (_modPackCount == 0) { ImGuiUtil.Center("Nothing to extract."); - return false; + return true; } if (_modPackCount == _currentModPackIdx) - return DrawEndState(); + { + DrawEndState(); + return true; + } ImGui.NewLine(); var percentage = (float)_currentModPackIdx / _modPackCount; ImGui.ProgressBar(percentage, size, $"Mod {_currentModPackIdx + 1} / {_modPackCount}"); ImGui.NewLine(); - if (State == ImporterState.DeduplicatingFiles) - ImGui.TextUnformatted($"Deduplicating {_currentModName}..."); - else - ImGui.TextUnformatted($"Extracting {_currentModName}..."); + ImGui.TextUnformatted(State == ImporterState.DeduplicatingFiles + ? $"Deduplicating {_currentModName}..." + : $"Extracting {_currentModName}..."); if (_currentNumOptions > 1) { @@ -63,18 +65,15 @@ public bool DrawProgressInfo(Vector2 size) } - private bool DrawEndState() + private void DrawEndState() { var success = ExtractedMods.Count(t => t.Error == null); - if (ImGui.IsKeyPressed(ImGuiKey.Escape)) - return true; - ImGui.TextUnformatted($"Successfully extracted {success} / {ExtractedMods.Count} files."); ImGui.NewLine(); using var table = ImRaii.Table("##files", 2); if (!table) - return false; + return; foreach (var (file, dir, ex) in ExtractedMods) { @@ -93,8 +92,6 @@ private bool DrawEndState() ImGuiUtil.HoverTooltip(ex.ToString()); } } - - return false; } public bool DrawCancelButton(Vector2 size) diff --git a/Penumbra/UI/ImportPopup.cs b/Penumbra/UI/ImportPopup.cs index fb2028b5..28767edc 100644 --- a/Penumbra/UI/ImportPopup.cs +++ b/Penumbra/UI/ImportPopup.cs @@ -1,4 +1,6 @@ +using Dalamud.Game.ClientState.Keys; using Dalamud.Interface.Windowing; +using Dalamud.Plugin.Services; using ImGuiNET; using OtterGui.Raii; using OtterGui.Services; @@ -68,13 +70,16 @@ public override void Draw() ImGui.SetNextWindowSize(size); using var popup = ImRaii.Popup(importPopup, ImGuiWindowFlags.Modal); PopupWasDrawn = true; + var terminate = false; using (var child = ImRaii.Child("##import", new Vector2(-1, size.Y - ImGui.GetFrameHeight() * 2))) { - if (child) - import.DrawProgressInfo(new Vector2(-1, ImGui.GetFrameHeight())); + if (child.Success && import.DrawProgressInfo(new Vector2(-1, ImGui.GetFrameHeight()))) + if (!ImGui.IsMouseHoveringRect(ImGui.GetWindowPos(), ImGui.GetWindowPos() + ImGui.GetWindowSize()) + && ImGui.IsMouseClicked(ImGuiMouseButton.Left)) + terminate = true; } - var terminate = import.State == ImporterState.Done + terminate |= import.State == ImporterState.Done ? ImGui.Button("Close", -Vector2.UnitX) : import.DrawCancelButton(-Vector2.UnitX); if (terminate)