From a94bc4b72544130a5f07196b6b0ab9171b769ea9 Mon Sep 17 00:00:00 2001 From: Imbris Date: Sat, 6 Jun 2020 00:37:29 -0400 Subject: [PATCH] Make cancel button in connecting screen visble again, don't save username & server for singleplayer login, make iced version go back to login screen properly. --- voxygen/src/menu/main/mod.rs | 18 +++++++++--------- voxygen/src/menu/main/ui/connecting.rs | 12 ++++++------ voxygen/src/menu/main/ui/mod.rs | 8 +++++--- 3 files changed, 20 insertions(+), 18 deletions(-) diff --git a/voxygen/src/menu/main/mod.rs b/voxygen/src/menu/main/mod.rs index 87d06381e0..f9d81b3244 100644 --- a/voxygen/src/menu/main/mod.rs +++ b/voxygen/src/menu/main/mod.rs @@ -226,6 +226,15 @@ impl PlayState for MainMenuState { password, server_address, } => { + let mut net_settings = &mut global_state.settings.networking; + net_settings.username = username.clone(); + if !net_settings.servers.contains(&server_address) { + net_settings.servers.push(server_address.clone()); + } + if let Err(err) = global_state.settings.save_to_file() { + warn!("Failed to save settings: {:?}", err); + } + attempt_login( &mut global_state.settings, &mut global_state.info_message, @@ -298,15 +307,6 @@ fn attempt_login( server_port: u16, client_init: &mut Option, ) { - let mut net_settings = &mut settings.networking; - net_settings.username = username.clone(); - if !net_settings.servers.contains(&server_address) { - net_settings.servers.push(server_address.clone()); - } - if let Err(e) = settings.save_to_file() { - warn!(?e, "Failed to save settings"); - } - if comp::Player::alias_is_valid(&username) { // Don't try to connect if there is already a connection in progress. if client_init.is_none() { diff --git a/voxygen/src/menu/main/ui/connecting.rs b/voxygen/src/menu/main/ui/connecting.rs index b75080f3e8..36647f7d9c 100644 --- a/voxygen/src/menu/main/ui/connecting.rs +++ b/voxygen/src/menu/main/ui/connecting.rs @@ -38,15 +38,15 @@ impl Screen { let status = Text::new(status) .size(fonts.alkhemi.scale(80)) .font(fonts.alkhemi.id) - .color(Color::from_rgba(1.0, 1.0, 1.0, fade_msg)) - .vertical_alignment(VerticalAlignment::Bottom) - .width(Length::Fill) - .height(Length::Fill); + .color(Color::from_rgba(1.0, 1.0, 1.0, fade_msg)); - let status = Row::with_children(vec![ + let status = Container::new(Row::with_children(vec![ Space::new(Length::Units(80), Length::Shrink).into(), status.into(), - ]); + ])) + .width(Length::Fill) + .height(Length::Fill) + .align_y(Align::End); let cancel = neat_button( &mut self.cancel_button, diff --git a/voxygen/src/menu/main/ui/mod.rs b/voxygen/src/menu/main/ui/mod.rs index b218f0a89b..b9dd5171d1 100644 --- a/voxygen/src/menu/main/ui/mod.rs +++ b/voxygen/src/menu/main/ui/mod.rs @@ -367,7 +367,7 @@ impl IcedState { } }, Message::CancelConnect => { - self.cancel_connection(); + self.exit_connect_screen(); events.push(Event::CancelLoginAttempt); }, msg @ Message::TrustPromptAdd | msg @ Message::TrustPromptCancel => { @@ -410,7 +410,8 @@ impl IcedState { } } - fn cancel_connection(&mut self) { + // Connection successful of failed + fn exit_connect_screen(&mut self) { if matches!(&self.screen, Screen::Connecting {..}) { self.screen = Screen::Login { screen: login::Screen::new(), @@ -1244,13 +1245,14 @@ impl<'a> MainMenuUi { self.popup = None; self.connecting = None; self.connect = false; + self.ice_state.exit_connect_screen(); } pub fn cancel_connection(&mut self) { self.popup = None; self.connecting = None; self.connect = false; - self.ice_state.cancel_connection(); + self.ice_state.exit_connect_screen(); } pub fn handle_event(&mut self, event: ui::Event) {