Move global maintains above rendering

Also moves the call to the AudioFrontend constructor to take place in the
GlobalState constructor


Former-commit-id: 0be9df5a7355b6a7d1ce758894568d67df7db11a
This commit is contained in:
Louis Pearson 2019-05-18 14:10:02 -06:00
parent 22286c24e6
commit 6b0fc57ce3
4 changed files with 11 additions and 12 deletions

View File

@ -97,8 +97,6 @@ fn main() {
])
.unwrap();
let audio = AudioFrontend::new();
// Set up panic handler to relay swish panic messages to the user
let settings_clone = settings.clone();
let default_hook = panic::take_hook();
@ -164,7 +162,7 @@ fn main() {
let mut global_state = GlobalState {
settings,
window,
audio,
audio: AudioFrontend::new(),
};
// Set up the initial play state.

View File

@ -90,6 +90,9 @@ impl PlayState for CharSelectionState {
}
}
// Mantain global state
global_state.maintain();
// Maintain the scene.
self.scene
.maintain(global_state.window.renderer_mut(), &self.client.borrow());
@ -119,9 +122,6 @@ impl PlayState for CharSelectionState {
.swap_buffers()
.expect("Failed to swap window buffers");
// Mantain global state
global_state.maintain();
// Wait for the next tick.
clock.tick(Duration::from_millis(1000 / FPS));
}

View File

@ -86,6 +86,9 @@ impl PlayState for MainMenuState {
None => {}
}
// Maintain global_state
global_state.maintain();
// Maintain the UI.
for event in self.main_menu_ui.maintain(global_state) {
match event {
@ -124,9 +127,6 @@ impl PlayState for MainMenuState {
.swap_buffers()
.expect("Failed to swap window buffers!");
// Maintain global_state
global_state.maintain();
// Wait for the next tick
clock.tick(Duration::from_millis(1000 / FPS));
}

View File

@ -167,11 +167,15 @@ impl PlayState for SessionState {
self.tick(clock.get_last_delta())
.expect("Failed to tick the scene!");
// Maintain global state
global_state.maintain();
// Maintain the scene.
self.scene.maintain(
global_state.window.renderer_mut(),
&mut self.client.borrow_mut(),
);
// Maintain the UI.
for event in self
.hud
@ -198,9 +202,6 @@ impl PlayState for SessionState {
.swap_buffers()
.expect("Failed to swap window buffers!");
// Maintain global state
global_state.maintain();
// Wait for the next tick.
clock.tick(Duration::from_millis(1000 / FPS));