mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Tweak pausing code to reduce duplication
This commit is contained in:
parent
2f5c8fa3f3
commit
0275cc9523
@ -465,18 +465,15 @@ impl Show {
|
||||
self.want_grab = true;
|
||||
|
||||
// Unpause the game if we are on singleplayer
|
||||
#[cfg(feature = "singleplayer")]
|
||||
global_state.unpause();
|
||||
} else {
|
||||
self.esc_menu = true;
|
||||
self.want_grab = false;
|
||||
|
||||
// Pause the game if we are on singleplayer
|
||||
#[cfg(feature = "singleplayer")]
|
||||
{
|
||||
// Pause the game if we are on singleplayer
|
||||
if let Some(singleplayer) = global_state.singleplayer.as_ref() {
|
||||
singleplayer.pause(true);
|
||||
}
|
||||
}
|
||||
global_state.pause();
|
||||
}
|
||||
}
|
||||
|
||||
@ -1721,13 +1718,9 @@ impl Hud {
|
||||
settings_window::Event::ToggleDebug => self.show.debug = !self.show.debug,
|
||||
settings_window::Event::ChangeTab(tab) => self.show.open_setting_tab(tab),
|
||||
settings_window::Event::Close => {
|
||||
// Unpause the game if we are on singleplayer so that we can logout
|
||||
#[cfg(feature = "singleplayer")]
|
||||
{
|
||||
// Unpause the game if we are on singleplayer so that we can logout
|
||||
if let Some(singleplayer) = global_state.singleplayer.as_ref() {
|
||||
singleplayer.pause(false);
|
||||
};
|
||||
}
|
||||
global_state.unpause();
|
||||
|
||||
self.show.settings(false)
|
||||
},
|
||||
@ -1912,10 +1905,12 @@ impl Hud {
|
||||
self.force_ungrab = false;
|
||||
|
||||
// Unpause the game if we are on singleplayer
|
||||
#[cfg(feature = "singleplayer")]
|
||||
global_state.unpause();
|
||||
},
|
||||
Some(esc_menu::Event::Logout) => {
|
||||
// Unpause the game if we are on singleplayer so that we can logout
|
||||
#[cfg(feature = "singleplayer")]
|
||||
global_state.unpause();
|
||||
|
||||
events.push(Event::Logout);
|
||||
@ -1923,6 +1918,7 @@ impl Hud {
|
||||
Some(esc_menu::Event::Quit) => events.push(Event::Quit),
|
||||
Some(esc_menu::Event::CharacterSelection) => {
|
||||
// Unpause the game if we are on singleplayer so that we can logout
|
||||
#[cfg(feature = "singleplayer")]
|
||||
global_state.unpause();
|
||||
|
||||
events.push(Event::CharacterSelection)
|
||||
|
@ -73,12 +73,11 @@ impl GlobalState {
|
||||
#[cfg(not(feature = "singleplayer"))]
|
||||
pub fn paused(&self) -> bool { false }
|
||||
|
||||
pub fn unpause(&self) {
|
||||
#[cfg(feature = "singleplayer")]
|
||||
{
|
||||
self.singleplayer.as_ref().map(|s| s.pause(false));
|
||||
}
|
||||
}
|
||||
#[cfg(feature = "singleplayer")]
|
||||
pub fn unpause(&self) { self.singleplayer.as_ref().map(|s| s.pause(false)); }
|
||||
|
||||
#[cfg(feature = "singleplayer")]
|
||||
pub fn pause(&self) { self.singleplayer.as_ref().map(|s| s.pause(true)); }
|
||||
}
|
||||
|
||||
// TODO: appears to be currently unused by playstates
|
||||
|
Loading…
Reference in New Issue
Block a user