diff --git a/StarterNG/Classes/AppState.cs b/StarterNG/Classes/AppState.cs index fbbdf0a..624fc14 100644 --- a/StarterNG/Classes/AppState.cs +++ b/StarterNG/Classes/AppState.cs @@ -1,4 +1,6 @@ -namespace StarterNG.Classes; +using System; + +namespace StarterNG.Classes; /// /// Shared selection state across views: the scenery and trainset currently in @@ -10,6 +12,50 @@ public sealed class AppState { public static AppState Instance { get; } = new(); - public Scenery? CurrentScenery { get; set; } - public Trainset? CurrentTrainset { get; set; } + public event Action? Changed; + + private Scenery? _currentScenery; + private Trainset? _currentTrainset; + private string? _startingVehicleName; + + public Scenery? CurrentScenery + { + get => _currentScenery; + set + { + if (ReferenceEquals(_currentScenery, value)) return; + _currentScenery = value; + Changed?.Invoke(); + } + } + + public Trainset? CurrentTrainset + { + get => _currentTrainset; + set + { + if (ReferenceEquals(_currentTrainset, value)) return; + _currentTrainset = value; + Changed?.Invoke(); + } + } + + /// + /// Node name of the vehicle the player starts in (-v), like Pascal + /// SelVehicle. Updated when a consist car is clicked in the depot or a + /// trainset is picked in Scenarios. + /// + public string? StartingVehicleName + { + get => _startingVehicleName; + set + { + if (_startingVehicleName == value) return; + _startingVehicleName = value; + Changed?.Invoke(); + } + } + + /// Notify listeners after in-place edits that affect Start enablement. + public void NotifyChanged() => Changed?.Invoke(); } diff --git a/StarterNG/MainWindow.axaml b/StarterNG/MainWindow.axaml index 8cbddeb..80decfc 100644 --- a/StarterNG/MainWindow.axaml +++ b/StarterNG/MainWindow.axaml @@ -70,9 +70,9 @@ Tag="settings" IsCheckedChanged="Nav_OnCheckedChanged" Content="{Binding [NavSettings], Source={x:Static starterNg:App.Loc}}" /> -