mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Error Window
Former-commit-id: e58ba8be94bb6f6b39c713f44dec20089c20b348
This commit is contained in:
parent
f32852054d
commit
858055b8c4
@ -60,7 +60,7 @@ impl PlayState for MainMenuState {
|
|||||||
global_state.window.renderer_mut().clear(BG_COLOR);
|
global_state.window.renderer_mut().clear(BG_COLOR);
|
||||||
|
|
||||||
// Poll client creation
|
// 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)) => {
|
Some(Ok(client)) => {
|
||||||
self.main_menu_ui.connected();
|
self.main_menu_ui.connected();
|
||||||
return PlayStateResult::Push(Box::new(CharSelectionState::new(
|
return PlayStateResult::Push(Box::new(CharSelectionState::new(
|
||||||
@ -70,11 +70,14 @@ impl PlayState for MainMenuState {
|
|||||||
}
|
}
|
||||||
Some(Err(err)) => {
|
Some(Err(err)) => {
|
||||||
client_init = None;
|
client_init = None;
|
||||||
self.main_menu_ui.login_error(match err {
|
self.main_menu_ui.login_error(
|
||||||
InitError::BadAddress(_) | InitError::NoAddress => "No such host is known",
|
match err {
|
||||||
InitError::ConnectionFailed(_) => "Could not connect to address",
|
InitError::BadAddress(_) | InitError::NoAddress => "Server not found",
|
||||||
}.to_string());
|
InitError::ConnectionFailed(_) => "Connection failed",
|
||||||
},
|
}
|
||||||
|
.to_string(),
|
||||||
|
);
|
||||||
|
}
|
||||||
None => {}
|
None => {}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -36,6 +36,8 @@ widget_ids! {
|
|||||||
servers_button,
|
servers_button,
|
||||||
settings_button,
|
settings_button,
|
||||||
quit_button,
|
quit_button,
|
||||||
|
// Error
|
||||||
|
error_frame,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -52,6 +54,8 @@ struct Imgs {
|
|||||||
button: ImgId,
|
button: ImgId,
|
||||||
button_hover: ImgId,
|
button_hover: ImgId,
|
||||||
button_press: ImgId,
|
button_press: ImgId,
|
||||||
|
|
||||||
|
error_frame: ImgId,
|
||||||
}
|
}
|
||||||
impl Imgs {
|
impl Imgs {
|
||||||
fn new(ui: &mut Ui, renderer: &mut Renderer) -> Imgs {
|
fn new(ui: &mut Ui, renderer: &mut Renderer) -> Imgs {
|
||||||
@ -82,6 +86,9 @@ impl Imgs {
|
|||||||
button: load("element/buttons/button.png"),
|
button: load("element/buttons/button.png"),
|
||||||
button_hover: load("element/buttons/button_hover.png"),
|
button_hover: load("element/buttons/button_hover.png"),
|
||||||
button_press: load("element/buttons/button_press.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
|
// Login error
|
||||||
if let Some(msg) = &self.login_error {
|
if let Some(msg) = &self.login_error {
|
||||||
let text = Text::new(&msg)
|
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_size(30)
|
||||||
.font_id(self.font_opensans);
|
.font_id(self.font_opensans);
|
||||||
let x = match text.get_x_dimension(ui_widgets) {
|
let x = match text.get_x_dimension(ui_widgets) {
|
||||||
Dimension::Absolute(x) => x + 10.0,
|
Dimension::Absolute(x) => x + 10.0,
|
||||||
_ => 0.0,
|
_ => 0.0,
|
||||||
};
|
};
|
||||||
Rectangle::fill([x, 40.0])
|
Rectangle::fill([x, 60.0])
|
||||||
.rgba(0.2, 0.3, 0.3, 0.7)
|
.rgba(0.1, 0.1, 0.1, 1.0)
|
||||||
.parent(ui_widgets.window)
|
.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);
|
.set(self.ids.login_error_bg, ui_widgets);
|
||||||
text.middle_of(self.ids.login_error_bg)
|
text.middle_of(self.ids.login_error_bg)
|
||||||
.set(self.ids.login_error, ui_widgets);
|
.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
|
// Server address
|
||||||
Image::new(self.imgs.input_bg)
|
Image::new(self.imgs.input_bg)
|
||||||
|
Loading…
Reference in New Issue
Block a user