From 7f6ba8e492c7f5f786f037b4c790dde1216d0142 Mon Sep 17 00:00:00 2001 From: Avi Weinstock Date: Sun, 17 Jul 2022 14:55:22 -0400 Subject: [PATCH] Closing a subwindow (such as inventory or the list of online players) only regrabs the cursor if no other subwindow requires it. Fixes #1116. --- CHANGELOG.md | 1 + voxygen/src/hud/mod.rs | 23 +++++++++++++---------- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 62514d0036..67f0721df3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -84,6 +84,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - All sounds now stop upon quitting to main menu - Combat music now loops and ends properly - Modular weapons now have a selling price +- Closing a subwindow now only regrabs the cursor if no other subwindow requires it. ## [0.12.0] - 2022-02-19 diff --git a/voxygen/src/hud/mod.rs b/voxygen/src/hud/mod.rs index 1be92c2001..7f020361bb 100644 --- a/voxygen/src/hud/mod.rs +++ b/voxygen/src/hud/mod.rs @@ -726,7 +726,7 @@ impl Show { if !self.esc_menu { self.bag = open; self.map = false; - self.want_grab = !open; + self.want_grab = !self.any_window_requires_cursor(); self.crafting_fields.salvage = false; if !open { @@ -740,7 +740,7 @@ impl Show { self.bag = open; self.trade = open; self.map = false; - self.want_grab = !open; + self.want_grab = !self.any_window_requires_cursor(); } } @@ -752,7 +752,7 @@ impl Show { self.crafting_fields.salvage = false; self.social = false; self.diary = false; - self.want_grab = !open; + self.want_grab = !self.any_window_requires_cursor(); } } @@ -764,7 +764,7 @@ impl Show { } self.social = open; self.diary = false; - self.want_grab = !open; + self.want_grab = !self.any_window_requires_cursor(); } } @@ -779,7 +779,7 @@ impl Show { self.crafting_fields.recipe_inputs = HashMap::new(); self.bag = open; self.map = false; - self.want_grab = !open; + self.want_grab = !self.any_window_requires_cursor(); } } @@ -806,7 +806,7 @@ impl Show { self.map = false; self.diary_fields = diary::DiaryShow::default(); self.diary = open; - self.want_grab = !open; + self.want_grab = !self.any_window_requires_cursor(); } } @@ -822,7 +822,7 @@ impl Show { self.crafting = false; self.crafting_fields.salvage = false; self.diary = false; - self.want_grab = !open; + self.want_grab = !self.any_window_requires_cursor(); } } @@ -860,8 +860,8 @@ impl Show { // TODO: Add self updating key-bindings element //fn toggle_help(&mut self) { self.help = !self.help } - fn toggle_windows(&mut self, global_state: &mut GlobalState) { - if self.bag + fn any_window_requires_cursor(&self) -> bool { + self.bag || self.trade || self.esc_menu || self.map @@ -871,7 +871,10 @@ impl Show { || self.help || self.intro || !matches!(self.open_windows, Windows::None) - { + } + + fn toggle_windows(&mut self, global_state: &mut GlobalState) { + if self.any_window_requires_cursor() { self.bag = false; self.trade = false; self.esc_menu = false;