fixes #712 - where pressing N to leave Settings doesn't unpause a single player game world

This commit is contained in:
Ryan Baker 2020-08-18 13:42:40 -04:00
parent bc7f0731fc
commit 3cdf7006e5
2 changed files with 16 additions and 5 deletions

View File

@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Added ### Added
### Changed ### Changed
- Fixed a bug where leaving the Settings menu by pressing "N" in single player kept the game paused
### Removed ### Removed

View File

@ -457,10 +457,20 @@ impl Show {
} }
} }
fn toggle_settings(&mut self) { fn toggle_settings(&mut self, global_state: &GlobalState) {
match self.open_windows { match self.open_windows {
Windows::Settings => self.settings(false), Windows::Settings => {
_ => self.settings(true), #[cfg(feature = "singleplayer")]
global_state.unpause();
self.settings(false);
},
_ => {
#[cfg(feature = "singleplayer")]
global_state.pause();
self.settings(true)
},
}; };
} }
@ -1615,7 +1625,7 @@ impl Hud {
.set(self.ids.buttons, ui_widgets) .set(self.ids.buttons, ui_widgets)
{ {
Some(buttons::Event::ToggleBag) => self.show.toggle_bag(), Some(buttons::Event::ToggleBag) => self.show.toggle_bag(),
Some(buttons::Event::ToggleSettings) => self.show.toggle_settings(), Some(buttons::Event::ToggleSettings) => self.show.toggle_settings(global_state),
Some(buttons::Event::ToggleSocial) => self.show.toggle_social(), Some(buttons::Event::ToggleSocial) => self.show.toggle_social(),
Some(buttons::Event::ToggleSpell) => self.show.toggle_spell(), Some(buttons::Event::ToggleSpell) => self.show.toggle_spell(),
Some(buttons::Event::ToggleMap) => self.show.toggle_map(), Some(buttons::Event::ToggleMap) => self.show.toggle_map(),
@ -2294,7 +2304,7 @@ impl Hud {
true true
}, },
GameInput::Settings if state => { GameInput::Settings if state => {
self.show.toggle_settings(); self.show.toggle_settings(global_state);
true true
}, },
GameInput::Help if state => { GameInput::Help if state => {