From 6d6bab0a08e1a8c44bda46e0250a754bef5f074a Mon Sep 17 00:00:00 2001 From: timokoesters Date: Sun, 19 May 2019 20:22:45 +0200 Subject: [PATCH] Make use of states in char-selection Former-commit-id: f74d4811bebb0e60093a96d70feeedaae8bc6c04 --- client/src/lib.rs | 1 + common/src/comp/stats.rs | 2 +- common/src/sys/action.rs | 2 +- voxygen/src/menu/char_selection/mod.rs | 8 ++++++-- 4 files changed, 9 insertions(+), 4 deletions(-) diff --git a/client/src/lib.rs b/client/src/lib.rs index 448c1e308f..511d32079e 100644 --- a/client/src/lib.rs +++ b/client/src/lib.rs @@ -102,6 +102,7 @@ impl Client { pub fn register(&mut self, player: comp::Player) { self.postbox.send_message(ClientMsg::Register { player }); + self.pending_state_request = true; } pub fn request_character(&mut self, name: String, body: comp::Body) { diff --git a/common/src/comp/stats.rs b/common/src/comp/stats.rs index 9c47b9a439..3b165f1337 100644 --- a/common/src/comp/stats.rs +++ b/common/src/comp/stats.rs @@ -1,5 +1,5 @@ -use specs::{Component, FlaggedStorage, NullStorage, VecStorage}; use crate::state::Time; +use specs::{Component, FlaggedStorage, NullStorage, VecStorage}; #[derive(Clone, Debug, Serialize, Deserialize)] pub struct Health { diff --git a/common/src/sys/action.rs b/common/src/sys/action.rs index 2178c1f8fc..4817b54206 100644 --- a/common/src/sys/action.rs +++ b/common/src/sys/action.rs @@ -5,7 +5,7 @@ use vek::*; // Crate use crate::{ comp::{phys::Pos, Action, Actions, Control, Stats}, - state::{Time, DeltaTime}, + state::{DeltaTime, Time}, }; // Basic ECS AI agent system diff --git a/voxygen/src/menu/char_selection/mod.rs b/voxygen/src/menu/char_selection/mod.rs index e54a7035d1..2e1f5a3635 100644 --- a/voxygen/src/menu/char_selection/mod.rs +++ b/voxygen/src/menu/char_selection/mod.rs @@ -8,7 +8,7 @@ use crate::{ Direction, GlobalState, PlayState, PlayStateResult, }; use client::{self, Client}; -use common::{clock::Clock, comp, msg::ClientMsg}; +use common::{clock::Clock, comp, msg::ClientMsg, msg::ClientState}; use scene::Scene; use std::{cell::RefCell, rc::Rc, time::Duration}; use ui::CharSelectionUi; @@ -46,7 +46,9 @@ impl PlayState for CharSelectionState { // Set up an fps clock. let mut clock = Clock::new(); - loop { + while self.client.borrow().is_request_pending() + || self.client.borrow().get_client_state() == Some(ClientState::Registered) + { // Handle window events. for event in global_state.window.fetch_events() { match event { @@ -122,6 +124,8 @@ impl PlayState for CharSelectionState { // Wait for the next tick. clock.tick(Duration::from_millis(1000 / FPS)); } + + PlayStateResult::Pop } fn name(&self) -> &'static str {