From 60a1ee728ad67750f219fccb5c58fc73c40aa8d5 Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Tue, 14 Jan 2025 14:51:36 +0100 Subject: [PATCH] Use current temporary settings for mod associations if they exist. --- Glamourer/Gui/Equipment/EquipmentDrawer.cs | 2 +- .../Gui/Tabs/DesignTab/ModAssociationsTab.cs | 6 ++++- Glamourer/Interop/Penumbra/PenumbraService.cs | 26 +++++++++++++++---- Penumbra.Api | 2 +- 4 files changed, 28 insertions(+), 8 deletions(-) diff --git a/Glamourer/Gui/Equipment/EquipmentDrawer.cs b/Glamourer/Gui/Equipment/EquipmentDrawer.cs index 601d3ae..c8a4b11 100644 --- a/Glamourer/Gui/Equipment/EquipmentDrawer.cs +++ b/Glamourer/Gui/Equipment/EquipmentDrawer.cs @@ -118,7 +118,7 @@ public class EquipmentDrawer public void DrawWeapons(EquipDrawData mainhand, EquipDrawData offhand, bool allWeapons) { - if (mainhand.CurrentItem.PrimaryId.Id == 0) + if (mainhand.CurrentItem.PrimaryId.Id == 0 && !allWeapons) return; if (_config.HideApplyCheckmarks) diff --git a/Glamourer/Gui/Tabs/DesignTab/ModAssociationsTab.cs b/Glamourer/Gui/Tabs/DesignTab/ModAssociationsTab.cs index b02ece6..5eda7cc 100644 --- a/Glamourer/Gui/Tabs/DesignTab/ModAssociationsTab.cs +++ b/Glamourer/Gui/Tabs/DesignTab/ModAssociationsTab.cs @@ -149,12 +149,14 @@ public class ModAssociationsTab(PenumbraService penumbra, DesignFileSystemSelect ImUtf8.IconButton(FontAwesomeIcon.RedoAlt, "Update the settings of this mod association."u8); if (ImGui.IsItemHovered()) { - var newSettings = penumbra.GetModSettings(mod); + var newSettings = penumbra.GetModSettings(mod, out var source); if (ImGui.IsItemClicked()) updatedMod = (mod, newSettings); using var style = ImRaii.PushStyle(ImGuiStyleVar.PopupBorderSize, 2 * ImGuiHelpers.GlobalScale); using var tt = ImUtf8.Tooltip(); + if (source.Length > 0) + ImUtf8.Text($"Using temporary settings made by {source}."); ImGui.Separator(); var namesDifferent = mod.Name != mod.DirectoryName; ImGui.Dummy(new Vector2(300 * ImGuiHelpers.GlobalScale, 0)); @@ -162,6 +164,7 @@ public class ModAssociationsTab(PenumbraService penumbra, DesignFileSystemSelect { if (namesDifferent) ImUtf8.Text("Directory Name"u8); + ImUtf8.Text("Force Inherit"u8); ImUtf8.Text("Enabled"u8); ImUtf8.Text("Priority"u8); ModCombo.DrawSettingsLeft(newSettings); @@ -173,6 +176,7 @@ public class ModAssociationsTab(PenumbraService penumbra, DesignFileSystemSelect if (namesDifferent) ImUtf8.Text(mod.DirectoryName); + ImUtf8.Text(newSettings.ForceInherit.ToString()); ImUtf8.Text(newSettings.Enabled.ToString()); ImUtf8.Text(newSettings.Priority.ToString()); ModCombo.DrawSettingsRight(newSettings); diff --git a/Glamourer/Interop/Penumbra/PenumbraService.cs b/Glamourer/Interop/Penumbra/PenumbraService.cs index 868ce11..13be628 100644 --- a/Glamourer/Interop/Penumbra/PenumbraService.cs +++ b/Glamourer/Interop/Penumbra/PenumbraService.cs @@ -33,9 +33,10 @@ public readonly record struct ModSettings(Dictionary> Setti public class PenumbraService : IDisposable { - public const int RequiredPenumbraBreakingVersion = 5; - public const int RequiredPenumbraFeatureVersion = 3; - public const int RequiredPenumbraFeatureVersionTemp = 4; + public const int RequiredPenumbraBreakingVersion = 5; + public const int RequiredPenumbraFeatureVersion = 3; + public const int RequiredPenumbraFeatureVersionTemp = 4; + public const int RequiredPenumbraFeatureVersionTemp2 = 5; private const int Key = -1610; @@ -67,6 +68,7 @@ public class PenumbraService : IDisposable private global::Penumbra.Api.IpcSubscribers.RemoveTemporaryModSettingsPlayer? _removeTemporaryModSettingsPlayer; private global::Penumbra.Api.IpcSubscribers.RemoveAllTemporaryModSettings? _removeAllTemporaryModSettings; private global::Penumbra.Api.IpcSubscribers.RemoveAllTemporaryModSettingsPlayer? _removeAllTemporaryModSettingsPlayer; + private global::Penumbra.Api.IpcSubscribers.QueryTemporaryModSettings? _queryTemporaryModSettings; private global::Penumbra.Api.IpcSubscribers.OpenMainWindow? _openModPage; private readonly IDisposable _initializedEvent; @@ -128,19 +130,30 @@ public class PenumbraService : IDisposable public Dictionary GetCollections() => Available ? _collections!.Invoke() : []; - public ModSettings GetModSettings(in Mod mod) + public ModSettings GetModSettings(in Mod mod, out string source) { + source = string.Empty; if (!Available) return ModSettings.Empty; try { var collection = _currentCollection!.Invoke(ApiCollectionType.Current); + if (_queryTemporaryModSettings != null) + { + var tempEc = _queryTemporaryModSettings.Invoke(collection!.Value.Id, mod.DirectoryName, out var tempTuple, out source); + if (tempEc is PenumbraApiEc.Success && tempTuple != null) + return new ModSettings(tempTuple.Value.Settings, tempTuple.Value.Priority, tempTuple.Value.Enabled, + tempTuple.Value.ForceInherit, false); + } + var (ec, tuple) = _getCurrentSettings!.Invoke(collection!.Value.Id, mod.DirectoryName); if (ec is not PenumbraApiEc.Success) return ModSettings.Empty; - return tuple.HasValue ? new ModSettings(tuple.Value.Item3, tuple.Value.Item2, tuple.Value.Item1, false, false) : ModSettings.Empty; + return tuple.HasValue + ? new ModSettings(tuple.Value.Item3, tuple.Value.Item2, tuple.Value.Item1, false, false) + : ModSettings.Empty; } catch (Exception ex) { @@ -441,6 +454,8 @@ public class PenumbraService : IDisposable _removeAllTemporaryModSettings = new global::Penumbra.Api.IpcSubscribers.RemoveAllTemporaryModSettings(_pluginInterface); _removeAllTemporaryModSettingsPlayer = new global::Penumbra.Api.IpcSubscribers.RemoveAllTemporaryModSettingsPlayer(_pluginInterface); + if (CurrentMinor >= RequiredPenumbraFeatureVersionTemp2) + _queryTemporaryModSettings = new global::Penumbra.Api.IpcSubscribers.QueryTemporaryModSettings(_pluginInterface); } Available = true; @@ -485,6 +500,7 @@ public class PenumbraService : IDisposable _removeTemporaryModSettingsPlayer = null; _removeAllTemporaryModSettings = null; _removeAllTemporaryModSettingsPlayer = null; + _queryTemporaryModSettings = null; Available = false; Glamourer.Log.Debug("Glamourer detached from Penumbra."); } diff --git a/Penumbra.Api b/Penumbra.Api index f60de67..b4e716f 160000 --- a/Penumbra.Api +++ b/Penumbra.Api @@ -1 +1 @@ -Subproject commit f60de67d24afe6e175f17d03cd234f493ea91265 +Subproject commit b4e716f86d94cd4d98d8f58e580ed5f619ea87ae