Use current temporary settings for mod associations if they exist.

This commit is contained in:
Ottermandias 2025-01-14 14:51:36 +01:00
parent c83ddf054a
commit 60a1ee728a
4 changed files with 28 additions and 8 deletions

View file

@ -118,7 +118,7 @@ public class EquipmentDrawer
public void DrawWeapons(EquipDrawData mainhand, EquipDrawData offhand, bool allWeapons) public void DrawWeapons(EquipDrawData mainhand, EquipDrawData offhand, bool allWeapons)
{ {
if (mainhand.CurrentItem.PrimaryId.Id == 0) if (mainhand.CurrentItem.PrimaryId.Id == 0 && !allWeapons)
return; return;
if (_config.HideApplyCheckmarks) if (_config.HideApplyCheckmarks)

View file

@ -149,12 +149,14 @@ public class ModAssociationsTab(PenumbraService penumbra, DesignFileSystemSelect
ImUtf8.IconButton(FontAwesomeIcon.RedoAlt, "Update the settings of this mod association."u8); ImUtf8.IconButton(FontAwesomeIcon.RedoAlt, "Update the settings of this mod association."u8);
if (ImGui.IsItemHovered()) if (ImGui.IsItemHovered())
{ {
var newSettings = penumbra.GetModSettings(mod); var newSettings = penumbra.GetModSettings(mod, out var source);
if (ImGui.IsItemClicked()) if (ImGui.IsItemClicked())
updatedMod = (mod, newSettings); updatedMod = (mod, newSettings);
using var style = ImRaii.PushStyle(ImGuiStyleVar.PopupBorderSize, 2 * ImGuiHelpers.GlobalScale); using var style = ImRaii.PushStyle(ImGuiStyleVar.PopupBorderSize, 2 * ImGuiHelpers.GlobalScale);
using var tt = ImUtf8.Tooltip(); using var tt = ImUtf8.Tooltip();
if (source.Length > 0)
ImUtf8.Text($"Using temporary settings made by {source}.");
ImGui.Separator(); ImGui.Separator();
var namesDifferent = mod.Name != mod.DirectoryName; var namesDifferent = mod.Name != mod.DirectoryName;
ImGui.Dummy(new Vector2(300 * ImGuiHelpers.GlobalScale, 0)); ImGui.Dummy(new Vector2(300 * ImGuiHelpers.GlobalScale, 0));
@ -162,6 +164,7 @@ public class ModAssociationsTab(PenumbraService penumbra, DesignFileSystemSelect
{ {
if (namesDifferent) if (namesDifferent)
ImUtf8.Text("Directory Name"u8); ImUtf8.Text("Directory Name"u8);
ImUtf8.Text("Force Inherit"u8);
ImUtf8.Text("Enabled"u8); ImUtf8.Text("Enabled"u8);
ImUtf8.Text("Priority"u8); ImUtf8.Text("Priority"u8);
ModCombo.DrawSettingsLeft(newSettings); ModCombo.DrawSettingsLeft(newSettings);
@ -173,6 +176,7 @@ public class ModAssociationsTab(PenumbraService penumbra, DesignFileSystemSelect
if (namesDifferent) if (namesDifferent)
ImUtf8.Text(mod.DirectoryName); ImUtf8.Text(mod.DirectoryName);
ImUtf8.Text(newSettings.ForceInherit.ToString());
ImUtf8.Text(newSettings.Enabled.ToString()); ImUtf8.Text(newSettings.Enabled.ToString());
ImUtf8.Text(newSettings.Priority.ToString()); ImUtf8.Text(newSettings.Priority.ToString());
ModCombo.DrawSettingsRight(newSettings); ModCombo.DrawSettingsRight(newSettings);

View file

@ -33,9 +33,10 @@ public readonly record struct ModSettings(Dictionary<string, List<string>> Setti
public class PenumbraService : IDisposable public class PenumbraService : IDisposable
{ {
public const int RequiredPenumbraBreakingVersion = 5; public const int RequiredPenumbraBreakingVersion = 5;
public const int RequiredPenumbraFeatureVersion = 3; public const int RequiredPenumbraFeatureVersion = 3;
public const int RequiredPenumbraFeatureVersionTemp = 4; public const int RequiredPenumbraFeatureVersionTemp = 4;
public const int RequiredPenumbraFeatureVersionTemp2 = 5;
private const int Key = -1610; 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.RemoveTemporaryModSettingsPlayer? _removeTemporaryModSettingsPlayer;
private global::Penumbra.Api.IpcSubscribers.RemoveAllTemporaryModSettings? _removeAllTemporaryModSettings; private global::Penumbra.Api.IpcSubscribers.RemoveAllTemporaryModSettings? _removeAllTemporaryModSettings;
private global::Penumbra.Api.IpcSubscribers.RemoveAllTemporaryModSettingsPlayer? _removeAllTemporaryModSettingsPlayer; private global::Penumbra.Api.IpcSubscribers.RemoveAllTemporaryModSettingsPlayer? _removeAllTemporaryModSettingsPlayer;
private global::Penumbra.Api.IpcSubscribers.QueryTemporaryModSettings? _queryTemporaryModSettings;
private global::Penumbra.Api.IpcSubscribers.OpenMainWindow? _openModPage; private global::Penumbra.Api.IpcSubscribers.OpenMainWindow? _openModPage;
private readonly IDisposable _initializedEvent; private readonly IDisposable _initializedEvent;
@ -128,19 +130,30 @@ public class PenumbraService : IDisposable
public Dictionary<Guid, string> GetCollections() public Dictionary<Guid, string> GetCollections()
=> Available ? _collections!.Invoke() : []; => Available ? _collections!.Invoke() : [];
public ModSettings GetModSettings(in Mod mod) public ModSettings GetModSettings(in Mod mod, out string source)
{ {
source = string.Empty;
if (!Available) if (!Available)
return ModSettings.Empty; return ModSettings.Empty;
try try
{ {
var collection = _currentCollection!.Invoke(ApiCollectionType.Current); 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); var (ec, tuple) = _getCurrentSettings!.Invoke(collection!.Value.Id, mod.DirectoryName);
if (ec is not PenumbraApiEc.Success) if (ec is not PenumbraApiEc.Success)
return ModSettings.Empty; 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) catch (Exception ex)
{ {
@ -441,6 +454,8 @@ public class PenumbraService : IDisposable
_removeAllTemporaryModSettings = new global::Penumbra.Api.IpcSubscribers.RemoveAllTemporaryModSettings(_pluginInterface); _removeAllTemporaryModSettings = new global::Penumbra.Api.IpcSubscribers.RemoveAllTemporaryModSettings(_pluginInterface);
_removeAllTemporaryModSettingsPlayer = _removeAllTemporaryModSettingsPlayer =
new global::Penumbra.Api.IpcSubscribers.RemoveAllTemporaryModSettingsPlayer(_pluginInterface); new global::Penumbra.Api.IpcSubscribers.RemoveAllTemporaryModSettingsPlayer(_pluginInterface);
if (CurrentMinor >= RequiredPenumbraFeatureVersionTemp2)
_queryTemporaryModSettings = new global::Penumbra.Api.IpcSubscribers.QueryTemporaryModSettings(_pluginInterface);
} }
Available = true; Available = true;
@ -485,6 +500,7 @@ public class PenumbraService : IDisposable
_removeTemporaryModSettingsPlayer = null; _removeTemporaryModSettingsPlayer = null;
_removeAllTemporaryModSettings = null; _removeAllTemporaryModSettings = null;
_removeAllTemporaryModSettingsPlayer = null; _removeAllTemporaryModSettingsPlayer = null;
_queryTemporaryModSettings = null;
Available = false; Available = false;
Glamourer.Log.Debug("Glamourer detached from Penumbra."); Glamourer.Log.Debug("Glamourer detached from Penumbra.");
} }

@ -1 +1 @@
Subproject commit f60de67d24afe6e175f17d03cd234f493ea91265 Subproject commit b4e716f86d94cd4d98d8f58e580ed5f619ea87ae