Made char select handle client events

This commit is contained in:
Joshua Barretto 2020-07-06 17:11:19 +01:00
parent bdab3972c2
commit ddaa0a9246
2 changed files with 38 additions and 17 deletions

View File

@ -154,16 +154,37 @@ impl PlayState for CharSelectionState {
let localized_strings = assets::load_expect::<VoxygenLocalization>(&i18n_asset_key(
&global_state.settings.language.selected_language,
));
if let Err(e) = self.client.borrow_mut().tick(
match self.client.borrow_mut().tick(
comp::ControllerInputs::default(),
clock.get_last_delta(),
|_| {},
) {
global_state.info_message =
Some(localized_strings.get("common.connection_lost").to_owned());
error!(?e, "[char_selection] Failed to tick the scene");
return PlayStateResult::Pop;
Ok(events) => {
for event in events {
match event {
client::Event::SetViewDistance(vd) => {
global_state.settings.graphics.view_distance = vd;
global_state.settings.save_to_file_warn();
},
client::Event::Disconnect => {
global_state.info_message = Some(
localized_strings
.get("main.login.server_shut_down")
.to_owned(),
);
return PlayStateResult::Pop;
},
_ => {},
}
}
},
Err(err) => {
global_state.info_message =
Some(localized_strings.get("common.connection_lost").to_owned());
error!(?err, "[char_selection] Failed to tick the client");
return PlayStateResult::Pop;
},
}
self.client.borrow_mut().cleanup();