fix & remove some unused uses, cursor toggle tweak

Former-commit-id: b398b11606d983b7f80364a5689804e3491c218f
This commit is contained in:
Imbris 2019-05-11 10:59:48 -04:00
parent f4947e3637
commit 75bfbf4cef
4 changed files with 20 additions and 18 deletions

View File

@ -475,6 +475,13 @@ impl Hud {
self.show.toggle_ui(); self.show.toggle_ui();
true true
} }
WinEvent::KeyDown(Key::ToggleCursor) => {
self.force_ungrab = !self.force_ungrab;
if self.force_ungrab {
global_state.window.grab_cursor(false);
}
true
}
_ if !self.show.ui => false, _ if !self.show.ui => false,
WinEvent::Zoom(_) => !cursor_grabbed && !self.ui.no_widget_capturing_mouse(), WinEvent::Zoom(_) => !cursor_grabbed && !self.ui.no_widget_capturing_mouse(),
WinEvent::KeyDown(Key::Enter) => { WinEvent::KeyDown(Key::Enter) => {
@ -527,13 +534,6 @@ impl Hud {
self.show.toggle_help(); self.show.toggle_help();
true true
} }
Key::ToggleCursor => {
self.force_ungrab = !self.force_ungrab;
if self.force_ungrab {
global_state.window.grab_cursor(false);
}
true
}
_ => false, _ => false,
}, },
WinEvent::KeyDown(key) | WinEvent::KeyUp(key) => match key { WinEvent::KeyDown(key) | WinEvent::KeyUp(key) => match key {

View File

@ -1,17 +1,18 @@
use crate::{ use crate::{
render::Renderer, render::Renderer,
ui::{self, BlankGraphic, Graphic, ImageGraphic, ScaleMode, Ui, VoxelGraphic}, ui::{
self,
img_ids::{ImageGraphic, VoxelGraphic},
ScaleMode, Ui,
},
window::Window, window::Window,
}; };
use common::{ use common::comp::character::{
assets, Belt, Character, Chest, Foot, Gender, Hand, Head, Pants, Race, Weapon,
comp::character::{Belt, Character, Chest, Foot, Gender, Hand, Head, Pants, Race, Weapon},
}; };
use conrod_core::{ use conrod_core::{
color, color,
color::TRANSPARENT, color::TRANSPARENT,
image::Id as ImgId,
text::font::Id as FontId,
widget::{text_box::Event as TextBoxEvent, Button, Image, Rectangle, Text, TextBox}, widget::{text_box::Event as TextBoxEvent, Button, Image, Rectangle, Text, TextBox},
widget_ids, Borderable, Color, Colorable, Labelable, Positionable, Sizeable, Widget, widget_ids, Borderable, Color, Colorable, Labelable, Positionable, Sizeable, Widget,
}; };

View File

@ -1,15 +1,16 @@
use crate::{ use crate::{
render::Renderer, render::Renderer,
ui::{self, BlankGraphic, Graphic, ImageGraphic, ScaleMode, Ui, VoxelGraphic}, ui::{
self,
img_ids::{ImageGraphic, VoxelGraphic},
ScaleMode, Ui,
},
GlobalState, DEFAULT_PUBLIC_SERVER, GlobalState, DEFAULT_PUBLIC_SERVER,
}; };
use common::assets;
use conrod_core::{ use conrod_core::{
color, color,
color::TRANSPARENT, color::TRANSPARENT,
image::Id as ImgId,
position::Relative, position::Relative,
text::font::Id as FontId,
widget::{text_box::Event as TextBoxEvent, Button, Image, List, Rectangle, Text, TextBox}, widget::{text_box::Event as TextBoxEvent, Button, Image, List, Rectangle, Text, TextBox},
widget_ids, Borderable, Color, Colorable, Labelable, Positionable, Sizeable, Widget, widget_ids, Borderable, Color, Colorable, Labelable, Positionable, Sizeable, Widget,
}; };

View File

@ -87,7 +87,7 @@ macro_rules! image_ids {
pub fn load(ui: &mut crate::ui::Ui) -> Result<Self, common::assets::Error> { pub fn load(ui: &mut crate::ui::Ui) -> Result<Self, common::assets::Error> {
use crate::ui::img_ids::GraphicCreator; use crate::ui::img_ids::GraphicCreator;
Ok(Self { Ok(Self {
$($( $name: ui.add_graphic(<$T>::new_graphic($specifier)?), )*)* $($( $name: ui.add_graphic(<$T as GraphicCreator>::new_graphic($specifier)?), )*)*
}) })
} }
} }