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.

This commit is contained in:
Imbris 2020-06-06 00:37:29 -04:00
parent a9541f1506
commit a94bc4b725
3 changed files with 20 additions and 18 deletions

View File

@ -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<ClientInit>,
) {
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() {

View File

@ -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,

View File

@ -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) {