Skip to content

Commit

Permalink
fix: cache copy of external mods
Browse files Browse the repository at this point in the history
  • Loading branch information
anna-is-cute committed Aug 17, 2023
1 parent be72554 commit 514be96
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
8 changes: 5 additions & 3 deletions Ui/ExternalImportWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ public bool Draw() {
return false;
}

var external = this.Plugin.State.ExternalNoBlock;

ImGui.PushTextWrapPos();
using var pop = new OnDispose(ImGui.PopTextWrapPos);

Expand All @@ -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);
}
}
Expand All @@ -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)) {
Expand All @@ -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<Task>();
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;
Expand Down
6 changes: 4 additions & 2 deletions Ui/Tabs/Manager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -149,8 +149,10 @@ private void DrawPackageList(Dictionary<Guid, IGetNewestVersionInfo_Variant> 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));
}

Expand Down

0 comments on commit 514be96

Please sign in to comment.