Files
StarterNG/StarterNG/Application/AppState.cs
maj00r 2cfb4e4fec Tell the tapes the simulator runs only while the starter watches it
The tapes looked for any process named as the chosen exe, every two seconds
off the UI thread. Under Wine the process is eu07.exe and never matched, so a
run never showed as running and the tape window did not follow the driven
vehicle, while a simulator started some other way was taken for the last
launch. The starter's own watch of the process it started now says it.
2026-11-03 21:51:53 +01:00

63 lines
1.4 KiB
C#

using System;
using StarterNG.Domain.Sceneries;
using StarterNG.Classes;
namespace StarterNG.Application;
public sealed class AppState
{
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();
}
}
public string? StartingVehicleName
{
get => _startingVehicleName;
set
{
if (_startingVehicleName == value) return;
_startingVehicleName = value;
Changed?.Invoke();
}
}
private volatile bool _simulatorRunning;
/// <summary>
/// The simulator the starter watches is still running: the one it started, not
/// any of the same name. Read off the UI thread too.
/// </summary>
public bool SimulatorRunning
{
get => _simulatorRunning;
set => _simulatorRunning = value;
}
public void NotifyChanged() => Changed?.Invoke();
}