Updated the CharacterSummaryViewModel to expose an additional property _canLaunch (with an Observable generated instance) which is set to either true or false (defaults to true) depending on the state of _tarkovClientService.RunningStateChanged.
An event handler is attached to listen for RunningStateChanged events, if the state is either Starting or Running _canLaunch is set to false, the other states (NotRunning and StoppedUnexpectedly) set this to true.
The CharacterSummaryView.axaml's command button (Login or Play) has the property IsEnabled bound to this new property - in doing this all buttons are enabled or disabled when EFT is started/stopped. This property is changed on the UI thread with the use of Dispatcher.UIThread.Invoke().
The upshot of this change is that the UI now behaves as such:
Not logged in, Tarkov not running, all buttons enabled:
Login dialog disables the login button for the selected profile (as expected for a button with a bound command):
Successful login, Tarkov now running (or starting up), all buttons are disabled:
Exited from Tarkov, all buttons are enabled.
Saved profiles work in much the same way - but without the login dialog of course.
Saved profile (remember me ticked during login), Tarkov not running all buttons available.
Saved profile (remember me ticked during login), Tarkov running all buttons disabled.
Saved profile (remember me ticked during login), Tarkov exited all buttons available again.
[!NOTE]
Have added comments in the CharacterSummaryViewModel constructor regarding future implementation of IActivatableViewModel from Avalonia.ReactiveUI - however it would require changes to the code behind the axaml. It may be worth looking into this as part of a larger refactor at a later date.
Updated the CharacterSummaryViewModel to expose an additional property _canLaunch (with an Observable generated instance) which is set to either true or false (defaults to true) depending on the state of _tarkovClientService.RunningStateChanged.
An event handler is attached to listen for RunningStateChanged events, if the state is either Starting or Running _canLaunch is set to false, the other states (NotRunning and StoppedUnexpectedly) set this to true.
The CharacterSummaryView.axaml's command button (Login or Play) has the property IsEnabled bound to this new property - in doing this all buttons are enabled or disabled when EFT is started/stopped. This property is changed on the UI thread with the use of Dispatcher.UIThread.Invoke().
The upshot of this change is that the UI now behaves as such:
Not logged in, Tarkov not running, all buttons enabled:
Login dialog disables the login button for the selected profile (as expected for a button with a bound command):
Successful login, Tarkov now running (or starting up), all buttons are disabled:
Exited from Tarkov, all buttons are enabled.
Saved profiles work in much the same way - but without the login dialog of course.
Saved profile (remember me ticked during login), Tarkov not running all buttons available.
Saved profile (remember me ticked during login), Tarkov running all buttons disabled.
Saved profile (remember me ticked during login), Tarkov exited all buttons available again.