From f9f7b7e667fc700462bdc4a0b794efb7adcf18e1 Mon Sep 17 00:00:00 2001
From: David Higueros <111460331+TheDavSmasher@users.noreply.github.com>
Date: Fri, 19 Jun 2026 23:30:58 -0600
Subject: [PATCH] Expanded setters to set the inner options values as well
---
.../OptionTypes/ModdedOptionList.cs | 36 ++++++++++++++-----
1 file changed, 28 insertions(+), 8 deletions(-)
diff --git a/MiraAPI/GameOptions/OptionTypes/ModdedOptionList.cs b/MiraAPI/GameOptions/OptionTypes/ModdedOptionList.cs
index cc7bdfd..a32a727 100644
--- a/MiraAPI/GameOptions/OptionTypes/ModdedOptionList.cs
+++ b/MiraAPI/GameOptions/OptionTypes/ModdedOptionList.cs
@@ -13,23 +13,21 @@ namespace MiraAPI.GameOptions.OptionTypes;
/// The type of options.
public class ModdedOptionList : IModdedOptionList, IReadOnlyList where T : IModdedOption
{
- private IMiraPlugin? _parentMod;
-
///
public int Count { get; }
///
public IMiraPlugin? ParentMod
{
- get => _parentMod;
+ get;
set
{
- if (_parentMod != null || value == null) return;
- _parentMod = value;
+ if (field != null || value == null) return;
+ field = value;
foreach (var option in Options)
{
- option.ParentMod = _parentMod!;
+ option.ParentMod = value;
}
}
}
@@ -40,10 +38,32 @@ public class ModdedOptionList : IModdedOptionList, IReadOnlyList where T :
public IReadOnlyList Options { get; }
///
- public Func Visible { get; set; }
+ public Func Visible
+ {
+ get;
+ set
+ {
+ field = value;
+ foreach (var (option, idx) in Options.Select((o, i) => (o, i)))
+ {
+ option.Visible = () => value(idx);
+ }
+ }
+ }
///
- public bool IncludeInPreset { get; set; }
+ public bool IncludeInPreset
+ {
+ get;
+ set
+ {
+ field = value;
+ foreach (var option in Options)
+ {
+ option.IncludeInPreset = value;
+ }
+ }
+ }
///
/// Initializes a new instance of the class.