Skip to content

Commit

Permalink
Make the import popup closeable by clicking outside if it is finished.
Browse files Browse the repository at this point in the history
  • Loading branch information
Ottermandias committed Jul 12, 2024
1 parent 22af545 commit 94a05af
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 16 deletions.
23 changes: 10 additions & 13 deletions Penumbra/Import/TexToolsImporter.Gui.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand All @@ -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)
{
Expand All @@ -93,8 +92,6 @@ private bool DrawEndState()
ImGuiUtil.HoverTooltip(ex.ToString());
}
}

return false;
}

public bool DrawCancelButton(Vector2 size)
Expand Down
11 changes: 8 additions & 3 deletions Penumbra/UI/ImportPopup.cs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 94a05af

Please sign in to comment.