mirror of
https://github.com/xivdev/Penumbra.git
synced 2025-12-12 18:27:24 +01:00
Fix issue with empty and temporary settings.
This commit is contained in:
parent
52927ff06b
commit
3078c467d0
4 changed files with 23 additions and 9 deletions
|
|
@ -11,11 +11,18 @@ namespace Penumbra.Mods.Settings;
|
|||
/// <summary> Contains the settings for a given mod. </summary>
|
||||
public class ModSettings
|
||||
{
|
||||
public static readonly ModSettings Empty = new();
|
||||
public static readonly ModSettings Empty = new(true);
|
||||
|
||||
public SettingList Settings { get; internal init; } = [];
|
||||
public ModPriority Priority { get; set; }
|
||||
public bool Enabled { get; set; }
|
||||
public bool IsEmpty { get; protected init; }
|
||||
|
||||
public ModSettings()
|
||||
{ }
|
||||
|
||||
protected ModSettings(bool empty)
|
||||
=> IsEmpty = empty;
|
||||
|
||||
// Create an independent copy of the current settings.
|
||||
public ModSettings DeepCopy()
|
||||
|
|
|
|||
|
|
@ -2,9 +2,11 @@ namespace Penumbra.Mods.Settings;
|
|||
|
||||
public sealed class TemporaryModSettings : ModSettings
|
||||
{
|
||||
public new static readonly TemporaryModSettings Empty = new(true);
|
||||
|
||||
public const string OwnSource = "yourself";
|
||||
public string Source = string.Empty;
|
||||
public int Lock = 0;
|
||||
public int Lock;
|
||||
public bool ForceInherit;
|
||||
|
||||
// Create default settings for a given mod.
|
||||
|
|
@ -21,12 +23,16 @@ public sealed class TemporaryModSettings : ModSettings
|
|||
public TemporaryModSettings()
|
||||
{ }
|
||||
|
||||
private TemporaryModSettings(bool empty)
|
||||
: base(empty)
|
||||
{ }
|
||||
|
||||
public TemporaryModSettings(Mod mod, ModSettings? clone, string source = OwnSource, int key = 0)
|
||||
{
|
||||
Source = source;
|
||||
Lock = key;
|
||||
ForceInherit = clone == null;
|
||||
if (clone != null && clone != Empty)
|
||||
if (clone is { IsEmpty: false })
|
||||
{
|
||||
Enabled = clone.Enabled;
|
||||
Priority = clone.Priority;
|
||||
|
|
@ -34,6 +40,7 @@ public sealed class TemporaryModSettings : ModSettings
|
|||
}
|
||||
else
|
||||
{
|
||||
IsEmpty = true;
|
||||
Enabled = false;
|
||||
Priority = ModPriority.Default;
|
||||
Settings = SettingList.Default(mod);
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@ public sealed class ModGroupDrawer(Configuration config, CollectionManager colle
|
|||
case GroupDrawBehaviour.SingleSelection:
|
||||
ImGuiUtil.Dummy(UiHelpers.DefaultSpace, useDummy);
|
||||
useDummy = false;
|
||||
DrawSingleGroupCombo(group, idx, settings == ModSettings.Empty ? group.DefaultSettings : settings.Settings[idx]);
|
||||
DrawSingleGroupCombo(group, idx, settings.IsEmpty ? group.DefaultSettings : settings.Settings[idx]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
@ -59,7 +59,7 @@ public sealed class ModGroupDrawer(Configuration config, CollectionManager colle
|
|||
{
|
||||
ImGuiUtil.Dummy(UiHelpers.DefaultSpace, useDummy);
|
||||
useDummy = false;
|
||||
var option = settings == ModSettings.Empty ? group.DefaultSettings : settings.Settings[idx];
|
||||
var option = settings.IsEmpty ? group.DefaultSettings : settings.Settings[idx];
|
||||
if (group.Behaviour is GroupDrawBehaviour.MultiSelection)
|
||||
DrawMultiGroup(group, idx, option);
|
||||
else
|
||||
|
|
|
|||
|
|
@ -183,7 +183,7 @@ public class ModPanelSettingsTab(
|
|||
/// </summary>
|
||||
private void DrawRemoveSettings()
|
||||
{
|
||||
var drawInherited = !_inherited && selection.Settings != ModSettings.Empty;
|
||||
var drawInherited = !_inherited && !selection.Settings.IsEmpty;
|
||||
var scroll = ImGui.GetScrollMaxY() > 0 ? ImGui.GetStyle().ScrollbarSize + ImGui.GetStyle().ItemInnerSpacing.X : 0;
|
||||
var buttonSize = ImUtf8.CalcTextSize("Turn Permanent_"u8).X;
|
||||
var offset = drawInherited
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue