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