- Weird LuaCs Settings Menu bug present: package is loaded on startup but is then unloaded if the settingsmenu is opened and the package is not in the enabled list.

This commit is contained in:
Maplewheels
2026-02-28 22:10:29 -05:00
parent 28b355911d
commit 09bc2d0891
9 changed files with 52 additions and 191 deletions
@@ -29,6 +29,7 @@ public interface ISettingBase : IDataInfo, IEquatable<ISettingBase>, IDisposable
#if CLIENT
IConfigDisplayInfo GetDisplayInfo();
#endif
bool IsDisposed { get; }
Type GetValueType();
string GetStringValue();
string GetDefaultStringValue();
@@ -30,12 +30,14 @@ public abstract class SettingBase : ISettingBase
}
private int _isDisposed = 0;
protected virtual bool IsDisposed
public virtual bool IsDisposed
{
get => ModUtils.Threading.GetBool(ref _isDisposed);
private set => ModUtils.Threading.SetBool(ref _isDisposed, value);
}
protected abstract void OnDispose();
public virtual void Dispose()
{
if (!ModUtils.Threading.CheckIfClearAndSetBool(ref _isDisposed))
@@ -43,8 +45,8 @@ public abstract class SettingBase : ISettingBase
return;
}
OnDispose();
ConfigInfo = null;
OnValueChanged = null;
GC.SuppressFinalize(this);
}
@@ -55,6 +57,6 @@ public abstract class SettingBase : ISettingBase
public abstract string GetDefaultStringValue();
public abstract bool TrySetValue(OneOf<string, XElement> value);
public event Action<ISettingBase> OnValueChanged;
public abstract event Action<ISettingBase> OnValueChanged;
public abstract OneOf<string, XElement> GetSerializableValue();
}
@@ -65,7 +65,7 @@ public class SettingEntry<T> : SettingBase, ISettingBase<T>, INetworkSyncVar whe
{
return false;
}
OnValueChanged?.Invoke(this);
#if CLIENT
if (GameMain.IsMultiplayer && SyncType is NetSync.ClientOneWay or NetSync.TwoWay)
{
@@ -96,6 +96,11 @@ public class SettingEntry<T> : SettingBase, ISettingBase<T>, INetworkSyncVar whe
return true;
}
protected override void OnDispose()
{
ValueChangePredicate = null;
}
public override Type GetValueType() => typeof(T);
public override string GetStringValue() => Value.ToString();
@@ -135,6 +140,8 @@ public class SettingEntry<T> : SettingBase, ISettingBase<T>, INetworkSyncVar whe
return !isFailed && TrySetValue(typeConvertedValue);
}
public override event Action<ISettingBase> OnValueChanged;
public override OneOf<string, XElement> GetSerializableValue() => Value.ToString();
// -- Networking