Fill in username & server fields in ui reimplementation, stop saving password in the settings file

This commit is contained in:
Imbris 2020-06-03 01:48:33 -04:00
parent 73982637b2
commit 01eb061a83
3 changed files with 18 additions and 28 deletions

View File

@ -33,7 +33,6 @@ impl Screen {
fonts: &Fonts,
imgs: &Imgs,
bg_img: image::Handle,
start: &std::time::Instant,
connection_state: &ConnectionState,
version: &str,
time: f32,

View File

@ -93,7 +93,7 @@ pub enum Event {
StartSingleplayer,
Quit,
Settings,
//DisclaimerClosed,
//DisclaimerClosed, TODO: remove all traces?
AuthServerTrust(String, bool),
}
@ -115,7 +115,7 @@ pub struct LoginInfo {
}
enum Info {
Disclaimer,
//Disclaimer,
Intro,
}
@ -151,7 +151,6 @@ enum Screen {
},
}
// TODO: use i18n font scale thing
struct IcedState {
fonts: IcedFonts,
imgs: IcedImgs,
@ -184,7 +183,7 @@ enum Message {
TrustPromptAdd,
TrustPromptCancel,
CloseError,
CloseDisclaimer,
//CloseDisclaimer,
}
impl IcedState {
@ -201,11 +200,11 @@ impl IcedState {
common::util::GIT_VERSION.to_string()
);
let info = if settings.show_disclaimer {
Info::Disclaimer
} else {
Info::Intro
};
let info = Info::Intro; // if settings.show_disclaimer {
//Info::Disclaimer
//} else {
//Info::Intro
//};
Self {
fonts,
@ -215,9 +214,9 @@ impl IcedState {
version,
login_info: LoginInfo {
username: String::new(),
username: settings.networking.username.clone(),
password: String::new(),
server: String::new(),
server: settings.networking.default_server.clone(),
},
show_servers: false,
@ -248,13 +247,11 @@ impl IcedState {
),
Screen::Connecting {
screen,
start,
connection_state,
} => screen.view(
&self.fonts,
&self.imgs,
self.bg_img,
&start,
&connection_state,
&self.version,
self.time,
@ -271,7 +268,6 @@ impl IcedState {
Message::Singleplayer => {
self.screen = Screen::Connecting {
screen: connecting::Screen::new(),
start: std::time::Instant::now(),
connection_state: ConnectionState::InProgress {
status: [self.i18n.get("main.creating_world"), "..."].concat(),
},
@ -282,7 +278,6 @@ impl IcedState {
Message::Multiplayer => {
self.screen = Screen::Connecting {
screen: connecting::Screen::new(),
start: std::time::Instant::now(),
connection_state: ConnectionState::InProgress {
status: [self.i18n.get("main.connecting"), "..."].concat(),
},
@ -332,9 +327,9 @@ impl IcedState {
*error = None;
}
},
Message::CloseDisclaimer => {
events.push(Event::DisclaimerClosed);
},
//Message::CloseDisclaimer => {
// events.push(Event::DisclaimerClosed);
//},
}
}
@ -535,11 +530,7 @@ impl<'a> MainMenuUi {
imgs,
username: networking.username.clone(),
password: "".to_owned(),
server_address: networking
.servers
.get(networking.default_server)
.cloned()
.unwrap_or_default(),
server_address: networking.default_server.clone(),
popup: None,
connecting: None,
show_servers: false,
@ -992,7 +983,7 @@ impl<'a> MainMenuUi {
.was_clicked()
{
self.server_address = net_settings.servers[item.i].clone();
net_settings.default_server = item.i;
net_settings.default_server = self.server_address.clone();
}
}

View File

@ -558,16 +558,16 @@ impl Default for GameplaySettings {
pub struct NetworkingSettings {
pub username: String,
pub servers: Vec<String>,
pub default_server: usize,
pub default_server: String,
pub trusted_auth_servers: HashSet<String>,
}
impl Default for NetworkingSettings {
fn default() -> Self {
Self {
username: "Username".to_string(),
username: "".to_string(),
servers: vec!["server.veloren.net".to_string()],
default_server: 0,
default_server: "server.veloren.net".to_string(),
trusted_auth_servers: ["https://auth.veloren.net"]
.iter()
.map(|s| s.to_string())