diff --git a/EndlessClient/Controllers/LoginController.cs b/EndlessClient/Controllers/LoginController.cs index 4431105d..de1974a4 100644 --- a/EndlessClient/Controllers/LoginController.cs +++ b/EndlessClient/Controllers/LoginController.cs @@ -101,7 +101,9 @@ public async Task LoginToAccount(ILoginParameters loginParameters) var reply = loginToServerOperation.Result; if (reply == LoginReply.Ok) - _gameStateActions.ChangeToState(GameStates.LoggedIn); + { + await DispatcherGameComponent.Invoke(() => _gameStateActions.ChangeToState(GameStates.LoggedIn)); + } else { _errorDisplayAction.ShowLoginError(reply); @@ -227,12 +229,15 @@ public async Task LoginToCharacter(Character character) _clientWindowSizeRepository.Resizable = true; } - _gameStateActions.ChangeToState(GameStates.PlayingTheGame); - _chatTextBoxActions.FocusChatTextBox(); - _statusLabelSetter.SetStatusLabel(EOResourceID.STATUS_LABEL_TYPE_WARNING, - EOResourceID.LOADING_GAME_HINT_FIRST); - _firstTimePlayerActions.WarnFirstTimePlayers(); - _mapChangedActions.ActiveCharacterEnterMapForLogin(); + await DispatcherGameComponent.Invoke(() => + { + _gameStateActions.ChangeToState(GameStates.PlayingTheGame); + _chatTextBoxActions.FocusChatTextBox(); + _statusLabelSetter.SetStatusLabel(EOResourceID.STATUS_LABEL_TYPE_WARNING, + EOResourceID.LOADING_GAME_HINT_FIRST); + _firstTimePlayerActions.WarnFirstTimePlayers(); + _mapChangedActions.ActiveCharacterEnterMapForLogin(); + }); } private void SetInitialStateAndShowError(NoDataSentException ex) diff --git a/EndlessClient/Controllers/MainButtonController.cs b/EndlessClient/Controllers/MainButtonController.cs index fc95380a..5f50375b 100644 --- a/EndlessClient/Controllers/MainButtonController.cs +++ b/EndlessClient/Controllers/MainButtonController.cs @@ -1,6 +1,7 @@ using AutomaticTypeMapper; using EndlessClient.Dialogs.Actions; using EndlessClient.GameExecution; +using EndlessClient.Rendering; using EOLib.Domain; using EOLib.Domain.Protocol; using EOLib.Net.Communication; @@ -66,8 +67,11 @@ public async Task ClickCreateAccount() if (result) { - _gameStateActions.ChangeToState(GameStates.CreateAccount); - _accountDialogDisplayActions.ShowInitialCreateWarningDialog(); + await DispatcherGameComponent.Invoke(() => + { + _gameStateActions.ChangeToState(GameStates.CreateAccount); + _accountDialogDisplayActions.ShowInitialCreateWarningDialog(); + }); } } @@ -76,7 +80,9 @@ public async Task ClickLogin() var result = await StartNetworkConnection().ConfigureAwait(false); if (result) - _gameStateActions.ChangeToState(GameStates.Login); + { + await DispatcherGameComponent.Invoke(() => _gameStateActions.ChangeToState(GameStates.Login)); + } } public void ClickViewCredits()