Make the import popup closeable by clicking outside if it is finished.

This commit is contained in:
Ottermandias 2024-07-12 17:54:47 +02:00
parent 22af545e8d
commit 94a05afbe0
2 changed files with 18 additions and 16 deletions

View file

@ -25,20 +25,22 @@ public partial class TexToolsImporter
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 partial class TexToolsImporter
}
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 @@ public partial class TexToolsImporter
ImGuiUtil.HoverTooltip(ex.ToString());
}
}
return false;
}
public bool DrawCancelButton(Vector2 size)

View file

@ -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 sealed class ImportPopup : Window, IUiService
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)