Current State.

This commit is contained in:
Ottermandias 2024-12-27 17:51:17 +01:00
parent 98a89bb2b4
commit 282189ef6d
9 changed files with 115 additions and 56 deletions

View file

@ -36,17 +36,11 @@ public class ModSelection : EventWrapper<Mod?, Mod?, ModSelection.Priority>
_communicator.ModSettingChanged.Subscribe(OnSettingChange, ModSettingChanged.Priority.ModSelection);
}
public ModSettings Settings { get; private set; } = ModSettings.Empty;
public ModCollection Collection { get; private set; } = ModCollection.Empty;
public Mod? Mod { get; private set; }
public ModSettings? OwnSettings { get; private set; }
public bool IsTemporary
=> OwnSettings != Settings;
public TemporaryModSettings? AsTemporarySettings
=> Settings as TemporaryModSettings;
public ModSettings Settings { get; private set; } = ModSettings.Empty;
public ModCollection Collection { get; private set; } = ModCollection.Empty;
public Mod? Mod { get; private set; }
public ModSettings? OwnSettings { get; private set; }
public TemporaryModSettings? TemporarySettings { get; private set; }
public void SelectMod(Mod? mod)
{
@ -98,6 +92,7 @@ public class ModSelection : EventWrapper<Mod?, Mod?, ModSelection.Priority>
{
(var settings, Collection) = _collections.Current.GetActualSettings(Mod.Index);
OwnSettings = _collections.Current.GetOwnSettings(Mod.Index);
TemporarySettings = _collections.Current.GetTempSettings(Mod.Index);
Settings = settings ?? ModSettings.Empty;
}
}

View file

@ -12,6 +12,7 @@ namespace Penumbra.Mods.Settings;
public class ModSettings
{
public static readonly ModSettings Empty = new();
public SettingList Settings { get; internal init; } = [];
public ModPriority Priority { get; set; }
public bool Enabled { get; set; }

View file

@ -5,4 +5,21 @@ public sealed class TemporaryModSettings : ModSettings
public string Source = string.Empty;
public int Lock = 0;
public bool ForceInherit;
// Create default settings for a given mod.
public static TemporaryModSettings DefaultSettings(Mod mod, string source, int key = 0)
=> new()
{
Enabled = false,
Source = source,
Lock = key,
Priority = ModPriority.Default,
Settings = SettingList.Default(mod),
};
}
public static class ModSettingsExtensions
{
public static bool IsTemporary(this ModSettings? settings)
=> settings is TemporaryModSettings;
}