From 858055b8c46a4ad8b4b033d32b753ded48325a30 Mon Sep 17 00:00:00 2001 From: Pfauenauge90 <44173739+Pfauenauge90@users.noreply.github.com> Date: Mon, 15 Apr 2019 22:51:32 +0200 Subject: [PATCH] Error Window Former-commit-id: e58ba8be94bb6f6b39c713f44dec20089c20b348 --- voxygen/src/menu/main/mod.rs | 15 +++++++++------ voxygen/src/menu/main/ui.rs | 19 +++++++++++++++---- 2 files changed, 24 insertions(+), 10 deletions(-) diff --git a/voxygen/src/menu/main/mod.rs b/voxygen/src/menu/main/mod.rs index 7f12830ac5..983a2d41b5 100644 --- a/voxygen/src/menu/main/mod.rs +++ b/voxygen/src/menu/main/mod.rs @@ -60,7 +60,7 @@ impl PlayState for MainMenuState { global_state.window.renderer_mut().clear(BG_COLOR); // Poll client creation - match client_init.as_ref().and_then(|init| init.poll()) { + match client_init.as_ref().and_then(|init| init.poll()) { Some(Ok(client)) => { self.main_menu_ui.connected(); return PlayStateResult::Push(Box::new(CharSelectionState::new( @@ -70,11 +70,14 @@ impl PlayState for MainMenuState { } Some(Err(err)) => { client_init = None; - self.main_menu_ui.login_error(match err { - InitError::BadAddress(_) | InitError::NoAddress => "No such host is known", - InitError::ConnectionFailed(_) => "Could not connect to address", - }.to_string()); - }, + self.main_menu_ui.login_error( + match err { + InitError::BadAddress(_) | InitError::NoAddress => "Server not found", + InitError::ConnectionFailed(_) => "Connection failed", + } + .to_string(), + ); + } None => {} } diff --git a/voxygen/src/menu/main/ui.rs b/voxygen/src/menu/main/ui.rs index c5e7f83504..ae8d053654 100644 --- a/voxygen/src/menu/main/ui.rs +++ b/voxygen/src/menu/main/ui.rs @@ -36,6 +36,8 @@ widget_ids! { servers_button, settings_button, quit_button, + // Error + error_frame, } } @@ -52,6 +54,8 @@ struct Imgs { button: ImgId, button_hover: ImgId, button_press: ImgId, + + error_frame: ImgId, } impl Imgs { fn new(ui: &mut Ui, renderer: &mut Renderer) -> Imgs { @@ -82,6 +86,9 @@ impl Imgs { button: load("element/buttons/button.png"), button_hover: load("element/buttons/button_hover.png"), button_press: load("element/buttons/button_press.png"), + + //Error + error_frame: load("element/frames/skin_eyes.png"), } } } @@ -203,20 +210,24 @@ impl MainMenuUi { // Login error if let Some(msg) = &self.login_error { let text = Text::new(&msg) - .rgba(0.5, 0.0, 0.0, 1.0) + .rgba(1.0, 1.0, 1.0, 1.0) .font_size(30) .font_id(self.font_opensans); let x = match text.get_x_dimension(ui_widgets) { Dimension::Absolute(x) => x + 10.0, _ => 0.0, }; - Rectangle::fill([x, 40.0]) - .rgba(0.2, 0.3, 0.3, 0.7) + Rectangle::fill([x, 60.0]) + .rgba(0.1, 0.1, 0.1, 1.0) .parent(ui_widgets.window) - .up_from(self.ids.username_bg, 35.0) + .mid_bottom_with_margin_on(self.ids.username_bg, 0.0) .set(self.ids.login_error_bg, ui_widgets); text.middle_of(self.ids.login_error_bg) .set(self.ids.login_error, ui_widgets); + Image::new(self.imgs.error_frame) + .h(60.0) + .middle_of(self.ids.login_error) + .set(self.ids.error_frame, ui_widgets); } // Server address Image::new(self.imgs.input_bg)