mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Fix difficult grabbing after closing via button
Former-commit-id: 2649d9e210d375f19d2970f15614be23d5173c67
This commit is contained in:
parent
3daec2cb17
commit
9edcabc679
@ -140,15 +140,20 @@ pub struct Show {
|
||||
want_grab: bool,
|
||||
}
|
||||
impl Show {
|
||||
fn toggle_bag(&mut self) {
|
||||
self.bag = !self.bag;
|
||||
self.want_grab = !self.bag;
|
||||
fn bag(&mut self, open: bool) {
|
||||
self.bag = open;
|
||||
self.want_grab = !open;
|
||||
}
|
||||
|
||||
fn toggle_map(&mut self) {
|
||||
self.map = !self.map;
|
||||
fn toggle_bag(&mut self) {
|
||||
self.bag(!self.bag);
|
||||
}
|
||||
fn map(&mut self, open: bool) {
|
||||
self.map = open;
|
||||
self.bag = false;
|
||||
self.want_grab = !self.map;
|
||||
self.want_grab = !open;
|
||||
}
|
||||
fn toggle_map(&mut self) {
|
||||
self.map(!self.map)
|
||||
}
|
||||
|
||||
fn toggle_mini_map(&mut self) {
|
||||
@ -179,13 +184,20 @@ impl Show {
|
||||
}
|
||||
}
|
||||
|
||||
fn toggle_settings(&mut self) {
|
||||
self.open_windows = match self.open_windows {
|
||||
Windows::Settings => Windows::None,
|
||||
_ => Windows::Settings,
|
||||
fn settings(&mut self, open: bool) {
|
||||
self.open_windows = if open {
|
||||
Windows::Settings
|
||||
} else {
|
||||
Windows::None
|
||||
};
|
||||
self.bag = false;
|
||||
self.want_grab = self.open_windows != Windows::Settings;
|
||||
self.want_grab = !open;
|
||||
}
|
||||
fn toggle_settings(&mut self) {
|
||||
match self.open_windows {
|
||||
Windows::Settings => self.settings(false),
|
||||
_ => self.settings(true),
|
||||
};
|
||||
}
|
||||
|
||||
fn toggle_help(&mut self) {
|
||||
@ -453,7 +465,10 @@ impl Hud {
|
||||
match Bag::new(self.inventory_space, &self.imgs, &self.fonts)
|
||||
.set(self.ids.bag, ui_widgets)
|
||||
{
|
||||
Some(bag::Event::Close) => self.show.bag = false,
|
||||
Some(bag::Event::Close) => {
|
||||
self.show.bag(false);
|
||||
self.force_ungrab = true;
|
||||
}
|
||||
None => {}
|
||||
}
|
||||
}
|
||||
@ -499,7 +514,10 @@ impl Hud {
|
||||
self.show.inventory_test_button = !self.show.inventory_test_button
|
||||
}
|
||||
settings_window::Event::ToggleDebug => self.show.debug = !self.show.debug,
|
||||
settings_window::Event::Close => self.show.open_windows = Windows::None,
|
||||
settings_window::Event::Close => {
|
||||
self.show.settings(false);
|
||||
self.force_ungrab = true;
|
||||
}
|
||||
settings_window::Event::AdjustViewDistance(view_distance) => {
|
||||
events.push(Event::AdjustViewDistance(view_distance));
|
||||
}
|
||||
@ -547,7 +565,10 @@ impl Hud {
|
||||
// Map
|
||||
if self.show.map {
|
||||
match Map::new(&self.imgs, &self.fonts).set(self.ids.map, ui_widgets) {
|
||||
Some(map::Event::Close) => self.show.map = false,
|
||||
Some(map::Event::Close) => {
|
||||
self.show.map(false);
|
||||
self.force_ungrab = true;
|
||||
}
|
||||
None => {}
|
||||
}
|
||||
}
|
||||
@ -559,7 +580,11 @@ impl Hud {
|
||||
self.show.esc_menu = false;
|
||||
self.show.open_windows = Windows::Settings;
|
||||
}
|
||||
Some(esc_menu::Event::Close) => self.show.esc_menu = false,
|
||||
Some(esc_menu::Event::Close) => {
|
||||
self.show.esc_menu = false;
|
||||
self.show.want_grab = false;
|
||||
self.force_ungrab = true;
|
||||
}
|
||||
Some(esc_menu::Event::Logout) => events.push(Event::Logout),
|
||||
Some(esc_menu::Event::Quit) => events.push(Event::Quit),
|
||||
None => {}
|
||||
|
Loading…
Reference in New Issue
Block a user