diff --git a/Glamourer/Gui/Tabs/DesignTab/ModAssociationsTab.cs b/Glamourer/Gui/Tabs/DesignTab/ModAssociationsTab.cs index ae2a76c..0618d14 100644 --- a/Glamourer/Gui/Tabs/DesignTab/ModAssociationsTab.cs +++ b/Glamourer/Gui/Tabs/DesignTab/ModAssociationsTab.cs @@ -115,7 +115,7 @@ public class ModAssociationsTab if (ImGui.IsItemHovered()) { - var (_, newSettings) = _penumbra.GetMods().FirstOrDefault(m => m.Mod == mod); + var newSettings = _penumbra.GetModSettings(mod); if (ImGui.IsItemClicked()) updatedMod = (mod, newSettings); diff --git a/Glamourer/Interop/Penumbra/PenumbraService.cs b/Glamourer/Interop/Penumbra/PenumbraService.cs index c7297aa..c6617e7 100644 --- a/Glamourer/Interop/Penumbra/PenumbraService.cs +++ b/Glamourer/Interop/Penumbra/PenumbraService.cs @@ -110,17 +110,38 @@ public unsafe class PenumbraService : IDisposable remove => _modSettingChanged.Event -= value; } + public ModSettings GetModSettings(in Mod mod) + { + if (!Available) + return ModSettings.Empty; + + try + { + var collection = _currentCollection.Invoke(ApiCollectionType.Current); + var (ec, tuple) = _getCurrentSettings.Invoke(collection, mod.DirectoryName, string.Empty, false); + if (ec is not PenumbraApiEc.Success) + return ModSettings.Empty; + + return tuple.HasValue ? new ModSettings(tuple.Value.Item3, tuple.Value.Item2, tuple.Value.Item1) : ModSettings.Empty; + } + catch (Exception ex) + { + Glamourer.Log.Error($"Error fetching mod settings for {mod.DirectoryName} from Penumbra:\n{ex}"); + return ModSettings.Empty; + } + } + public IReadOnlyList<(Mod Mod, ModSettings Settings)> GetMods() { if (!Available) - return Array.Empty<(Mod Mod, ModSettings Settings)>(); + return []; try { var allMods = _getMods.Invoke(); var collection = _currentCollection.Invoke(ApiCollectionType.Current); return allMods - .Select(m => (m.Item1, m.Item2, _getCurrentSettings.Invoke(collection, m.Item1, m.Item2, true))) + .Select(m => (m.Item1, m.Item2, _getCurrentSettings.Invoke(collection, m.Item1, m.Item2, false))) .Where(t => t.Item3.Item1 is PenumbraApiEc.Success) .Select(t => (new Mod(t.Item2, t.Item1), !t.Item3.Item2.HasValue @@ -135,7 +156,7 @@ public unsafe class PenumbraService : IDisposable catch (Exception ex) { Glamourer.Log.Error($"Error fetching mods from Penumbra:\n{ex}"); - return Array.Empty<(Mod Mod, ModSettings Settings)>(); + return []; } }