- Fixed up the settings menu.

- Made SettingEntry throw an error if "Value" attribute is not found in XML.
- Fixed saved values for settings sometimes not reloading after disabling and re-enabling a package.
This commit is contained in:
MapleWheels
2026-04-17 08:54:33 -04:00
parent 8896377f9c
commit 8f33e0af43
8 changed files with 212 additions and 51 deletions
@@ -33,6 +33,11 @@ public partial class SettingEntry<T> : SettingBase, ISettingBase<T>, INetworkSyn
ThrowHelper.ThrowArgumentException($"{nameof(ISettingBase<T>)}: The type of {nameof(T)} is not an allowed type.");
}
ValueChangePredicate = valueChangePredicate;
if (ConfigInfo.Element.Attribute("Value") is null)
{
ThrowHelper.ThrowArgumentException($"The Setting {InternalName} in package {OwnerPackage.Name} does not have a 'Value' attribute!");
}
try
{
@@ -147,10 +152,8 @@ public partial class SettingEntry<T> : SettingBase, ISettingBase<T>, INetworkSyn
}
public override Type GetValueType() => typeof(T);
public override string GetStringValue() => Value?.ToString() ?? string.Empty;
public override string GetDefaultStringValue() => DefaultValue.ToString();
public override string GetDefaultStringValue() => DefaultValue?.ToString() ?? string.Empty;
public override bool TrySetSerializedValue(OneOf<string, XElement> value)
{
@@ -181,7 +184,6 @@ public partial class SettingEntry<T> : SettingBase, ISettingBase<T>, INetworkSyn
return default(T);
}
});
return !isFailed && TrySetValue(typeConvertedValue);
}