mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Switch states instead of popping
This commit is contained in:
parent
fb4aba9bb7
commit
a391f2e0f2
@ -77,8 +77,6 @@ pub struct Client {
|
|||||||
loaded_distance: f32,
|
loaded_distance: f32,
|
||||||
|
|
||||||
pending_chunks: HashMap<Vec2<i32>, Instant>,
|
pending_chunks: HashMap<Vec2<i32>, Instant>,
|
||||||
|
|
||||||
disconnected: bool,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Client {
|
impl Client {
|
||||||
@ -165,8 +163,6 @@ impl Client {
|
|||||||
loaded_distance: 0.0,
|
loaded_distance: 0.0,
|
||||||
|
|
||||||
pending_chunks: HashMap::new(),
|
pending_chunks: HashMap::new(),
|
||||||
|
|
||||||
disconnected: false,
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -703,7 +699,6 @@ impl Client {
|
|||||||
);
|
);
|
||||||
},
|
},
|
||||||
ServerMsg::Disconnect => {
|
ServerMsg::Disconnect => {
|
||||||
self.disconnected = true;
|
|
||||||
frontend_events.push(Event::Disconnect);
|
frontend_events.push(Event::Disconnect);
|
||||||
self.postbox.send_message(ClientMsg::Terminate);
|
self.postbox.send_message(ClientMsg::Terminate);
|
||||||
},
|
},
|
||||||
@ -718,9 +713,6 @@ impl Client {
|
|||||||
Ok(frontend_events)
|
Ok(frontend_events)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get's whether or not the client just disconnected
|
|
||||||
pub fn disconnected(&self) -> bool { self.disconnected }
|
|
||||||
|
|
||||||
/// Get the player's entity.
|
/// Get the player's entity.
|
||||||
pub fn entity(&self) -> EcsEntity { self.entity }
|
pub fn entity(&self) -> EcsEntity { self.entity }
|
||||||
|
|
||||||
|
@ -39,11 +39,6 @@ impl PlayState for CharSelectionState {
|
|||||||
// Set up an fps clock.
|
// Set up an fps clock.
|
||||||
let mut clock = Clock::start();
|
let mut clock = Clock::start();
|
||||||
|
|
||||||
// Check if we just disconnected, if so go to main menu
|
|
||||||
if self.client.borrow().disconnected() {
|
|
||||||
return PlayStateResult::Pop;
|
|
||||||
}
|
|
||||||
|
|
||||||
let mut current_client_state = self.client.borrow().get_client_state();
|
let mut current_client_state = self.client.borrow().get_client_state();
|
||||||
while let ClientState::Pending | ClientState::Registered = current_client_state {
|
while let ClientState::Pending | ClientState::Registered = current_client_state {
|
||||||
// Handle window events
|
// Handle window events
|
||||||
@ -83,7 +78,7 @@ impl PlayState for CharSelectionState {
|
|||||||
char_data.body,
|
char_data.body,
|
||||||
char_data.tool,
|
char_data.tool,
|
||||||
);
|
);
|
||||||
return PlayStateResult::Push(Box::new(SessionState::new(
|
return PlayStateResult::Switch(Box::new(SessionState::new(
|
||||||
global_state,
|
global_state,
|
||||||
self.client.clone(),
|
self.client.clone(),
|
||||||
)));
|
)));
|
||||||
|
@ -3,6 +3,7 @@ use crate::{
|
|||||||
hud::{DebugInfo, Event as HudEvent, Hud},
|
hud::{DebugInfo, Event as HudEvent, Hud},
|
||||||
i18n::{i18n_asset_key, VoxygenLocalization},
|
i18n::{i18n_asset_key, VoxygenLocalization},
|
||||||
key_state::KeyState,
|
key_state::KeyState,
|
||||||
|
menu::char_selection::CharSelectionState,
|
||||||
render::Renderer,
|
render::Renderer,
|
||||||
scene::{camera, Scene, SceneData},
|
scene::{camera, Scene, SceneData},
|
||||||
window::{Event, GameInput},
|
window::{Event, GameInput},
|
||||||
@ -680,6 +681,13 @@ impl PlayState for SessionState {
|
|||||||
current_client_state = self.client.borrow().get_client_state();
|
current_client_state = self.client.borrow().get_client_state();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if let ClientState::Registered = current_client_state {
|
||||||
|
return PlayStateResult::Switch(Box::new(CharSelectionState::new(
|
||||||
|
global_state,
|
||||||
|
self.client.clone(),
|
||||||
|
)));
|
||||||
|
}
|
||||||
|
|
||||||
PlayStateResult::Pop
|
PlayStateResult::Pop
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user