imgui now only shows when settings.gameplay.toggle_debug is true

This commit is contained in:
Ben Wallis 2020-07-26 13:59:39 +01:00
parent 6231ee5a54
commit 2cd6ee9ca8
3 changed files with 23 additions and 18 deletions

View File

@ -1437,6 +1437,7 @@ impl Hud {
.font_size(self.fonts.cyri.scale(14))
.set(self.ids.debug_info, ui_widgets);
}
} else {
// Help Window
if let Some(help_key) = global_state.settings.controls.get_binding(GameInput::Help) {

View File

@ -143,7 +143,10 @@ fn handle_main_events_cleared(
global_state.window.renderer_mut().clear();
last.render(global_state.window.renderer_mut(), &global_state.settings);
global_state.window.imgui_render();
if global_state.settings.gameplay.toggle_debug {
global_state.window.imgui_render();
}
global_state.window.renderer_mut().flush();
global_state

View File

@ -185,23 +185,6 @@ impl PlayState for SessionState {
self.voxygen_i18n = load_expect::<VoxygenLocalization>(&i18n_asset_key(
&global_state.settings.language.selected_language,
));
global_state.window.imgui_run_ui = Box::new(|ui| {
Window::new(im_str!("Veloren ImgUi Test"))
.size([300.0, 100.0], Condition::FirstUseEver)
.build( ui, || {
ui.text(im_str!("Hello world!"));
ui.text(im_str!("こんにちは世界!"));
ui.text(im_str!("This...is...imgui-rs!"));
ui.separator();
let mouse_pos = ui.io().mouse_pos;
ui.text(format!(
"Mouse Position: ({:.1},{:.1})",
mouse_pos[0], mouse_pos[1]
));
});
});
// TODO: can this be a method on the session or are there borrowcheck issues?
let client_state = self.client.borrow().get_client_state();
@ -726,6 +709,24 @@ impl PlayState for SessionState {
hud_events.push(HudEvent::ChangeLanguage(self.voxygen_i18n.metadata.clone()));
}
if global_state.settings.gameplay.toggle_debug {
global_state.window.imgui_run_ui = Box::new(|ui| {
Window::new(im_str!("Veloren ImgUi Test"))
.size([300.0, 100.0], Condition::FirstUseEver)
.build(ui, || {
ui.text(im_str!("Hello world!"));
ui.text(im_str!("こんにちは世界!"));
ui.text(im_str!("This...is...imgui-rs!"));
ui.separator();
let mouse_pos = ui.io().mouse_pos;
ui.text(format!(
"Mouse Position: ({:.1},{:.1})",
mouse_pos[0], mouse_pos[1]
));
});
});
}
// Maintain the UI.
for event in hud_events {
match event {