feat: show errors in main menu when client fails

Instead of `[ERROR] Failed to tick the scene: Network(Bincode(Io(Custom { kind: UnexpectedEof, error: "failed to fill whole buffer" })))`
This commit is contained in:
timokoesters
2019-10-18 13:24:18 +02:00
parent 3b24af76ab
commit 21f126acd4
5 changed files with 23 additions and 9 deletions

View File

@ -75,11 +75,11 @@ impl PlayState for MainMenuState {
}
Some(Err(err)) => {
client_init = None;
self.main_menu_ui.login_error(
global_state.error_message = Some(
match err {
InitError::BadAddress(_) | InitError::NoAddress => "Server not found",
InitError::InvalidAuth => "Invalid credentials",
InitError::ServerIsFull => "Server is Full!",
InitError::ServerIsFull => "Server is full",
InitError::ConnectionFailed(_) => "Connection failed",
InitError::ClientCrashed => "Client crashed",
}
@ -129,8 +129,8 @@ impl PlayState for MainMenuState {
false,
)));
} else {
self.main_menu_ui
.login_error("Invalid username or password".to_string());
global_state.error_message =
Some("Invalid username or password".to_string());
}
}
MainMenuEvent::CancelLoginAttempt => {
@ -152,6 +152,10 @@ impl PlayState for MainMenuState {
}
}
if let Some(error) = global_state.error_message.take() {
self.main_menu_ui.show_error(error);
}
// Draw the UI to the screen.
self.main_menu_ui.render(global_state.window.renderer_mut());