From 514be96b83e2c1a7d2437f57944c59f9c5301bc6 Mon Sep 17 00:00:00 2001 From: Anna Clemens Date: Thu, 17 Aug 2023 14:25:30 -0400 Subject: [PATCH] fix: cache copy of external mods --- Ui/ExternalImportWindow.cs | 8 +++++--- Ui/Tabs/Manager.cs | 6 ++++-- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/Ui/ExternalImportWindow.cs b/Ui/ExternalImportWindow.cs index 51a158f..c66d578 100644 --- a/Ui/ExternalImportWindow.cs +++ b/Ui/ExternalImportWindow.cs @@ -30,6 +30,8 @@ public bool Draw() { return false; } + var external = this.Plugin.State.ExternalNoBlock; + ImGui.PushTextWrapPos(); using var pop = new OnDispose(ImGui.PopTextWrapPos); @@ -38,7 +40,7 @@ public bool Draw() { using var disabled = ImGuiHelper.WithDisabled(this._processing); if (ImGui.Button("Select all")) { - foreach (var id in this.Plugin.State.ExternalNoBlock.Keys) { + foreach (var id in external.Keys) { this.Selected.Add(id); } } @@ -49,7 +51,7 @@ public bool Draw() { this.Selected.Clear(); } - foreach (var (id, mod) in this.Plugin.State.ExternalNoBlock) { + foreach (var (id, mod) in external) { var check = this.Selected.Contains(id); var plural = mod.Variants.Count == 1 ? "variant" : "variants"; if (ImGui.Checkbox($"{mod.Name} ({mod.Variants.Count} {plural})", ref check)) { @@ -68,7 +70,7 @@ public bool Draw() { if (ImGui.Button($"{label}###import") && this.Plugin.Penumbra.GetModDirectory() is { } penumbra && !string.IsNullOrWhiteSpace(penumbra)) { var tasks = new List(); foreach (var id in this.Selected) { - var info = this.Plugin.State.ExternalNoBlock[id]; + var info = external[id]; var directory = Path.GetDirectoryName(info.CoverImagePath); if (string.IsNullOrWhiteSpace(directory)) { continue; diff --git a/Ui/Tabs/Manager.cs b/Ui/Tabs/Manager.cs index 6100760..30935dc 100644 --- a/Ui/Tabs/Manager.cs +++ b/Ui/Tabs/Manager.cs @@ -149,8 +149,10 @@ private void DrawPackageList(Dictionary all ImGui.Separator(); - if (this.Plugin.State.ExternalNoBlock.Count > 0) { - if (ImGui.Button("Import new mods...")) { + var external = this.Plugin.State.ExternalNoBlock.Count; + if (external > 0) { + var plural = external == 1 ? "mod" : "mods"; + if (ImGui.Button($"Import {external:N0} new {plural}...")) { this.Ui.AddIfNotPresent(new ExternalImportWindow(this.Plugin)); }