Skip to content

Commit 0aca30d

Browse files
committed
add SyncEnabledChanged and SyncedEntryBase.SyncEnabled
1 parent f219e99 commit 0aca30d

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

CSync/CSync/Lib/ConfigSyncBehaviour.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,11 @@ public override void OnNetworkSpawn()
6969
if (!ReferenceEquals(syncedEntryBase.BoxedEntry, args.ChangedSetting)) return;
7070
_deltas[currentIndex] = syncedEntryBase.ToDelta();
7171
};
72+
73+
syncedEntryBase.SyncEnabledChanged += (_, args) =>
74+
{
75+
_deltas[currentIndex] = syncedEntryBase.ToDelta();
76+
};
7277
}
7378

7479
InitialSyncCompletedHandler?.Invoke(this, EventArgs.Empty);

CSync/CSync/Lib/SyncedEntryBase.cs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,17 @@ public abstract class SyncedEntryBase
99
public abstract ConfigEntryBase BoxedEntry { get; protected init; }
1010

1111
public abstract object? BoxedValueOverride { get; set; }
12-
public virtual bool SyncEnabled { get; set; }
12+
13+
private bool _syncEnabled;
14+
public bool SyncEnabled {
15+
get => _syncEnabled;
16+
set {
17+
if (value == _syncEnabled) return;
18+
_syncEnabled = value;
19+
SyncEnabledChanged?.Invoke(this, EventArgs.Empty);
20+
}
21+
}
22+
1323
public virtual bool ValueOverridden { get; internal set; } = false;
1424

1525
internal SyncedEntryBase(ConfigEntryBase configEntry)
@@ -18,6 +28,8 @@ internal SyncedEntryBase(ConfigEntryBase configEntry)
1828
BoxedValueOverride = configEntry.DefaultValue;
1929
}
2030

31+
internal event EventHandler? SyncEnabledChanged;
32+
2133
public void SetSerializedValueOverride(string value)
2234
{
2335
BoxedValueOverride = TomlTypeConverter.ConvertToValue(value, BoxedEntry.SettingType);

0 commit comments

Comments
 (0)