From abf5a7e1367cd78a108fc0e69dbef9764ccf00cc Mon Sep 17 00:00:00 2001 From: juliancoffee Date: Fri, 6 Aug 2021 21:57:34 +0300 Subject: [PATCH 1/3] Add option to toggle egui debug --- voxygen/src/run.rs | 4 +++- voxygen/src/settings/interface.rs | 2 ++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/voxygen/src/run.rs b/voxygen/src/run.rs index ed21b503da..e704baf0bc 100644 --- a/voxygen/src/run.rs +++ b/voxygen/src/run.rs @@ -196,7 +196,9 @@ fn handle_main_events_cleared( last.render(&mut drawer, &global_state.settings); #[cfg(feature = "egui-ui")] - if last.egui_enabled() && global_state.settings.interface.toggle_debug { + if last.egui_enabled() + && global_state.settings.interface.toggle_debug + && global_state.settings.interface.toggle_egui_debug { drawer.draw_egui(&mut global_state.egui_state.platform, scale_factor); } }; diff --git a/voxygen/src/settings/interface.rs b/voxygen/src/settings/interface.rs index 7f20f8b5bc..673caa753a 100644 --- a/voxygen/src/settings/interface.rs +++ b/voxygen/src/settings/interface.rs @@ -10,6 +10,7 @@ use vek::*; #[serde(default)] pub struct InterfaceSettings { pub toggle_debug: bool, + pub toggle_egui_debug: bool, pub toggle_hitboxes: bool, pub toggle_chat: bool, pub sct: bool, @@ -46,6 +47,7 @@ impl Default for InterfaceSettings { fn default() -> Self { Self { toggle_debug: false, + toggle_egui_debug: false, toggle_hitboxes: false, toggle_chat: true, sct: true, From 16c72b866763ce6cde01a220e4e84e76060c375b Mon Sep 17 00:00:00 2001 From: juliancoffee Date: Fri, 6 Aug 2021 22:22:05 +0300 Subject: [PATCH 2/3] Add hotkey to toggle Egui Debug --- assets/voxygen/i18n/en/gameinput.ron | 1 + voxygen/src/controller.rs | 4 ++++ voxygen/src/game_input.rs | 3 +++ voxygen/src/hud/mod.rs | 6 ++++++ voxygen/src/settings/control.rs | 2 ++ voxygen/src/settings/gamepad.rs | 4 ++++ 6 files changed, 20 insertions(+) diff --git a/assets/voxygen/i18n/en/gameinput.ron b/assets/voxygen/i18n/en/gameinput.ron index ab2605acb3..316b489ace 100644 --- a/assets/voxygen/i18n/en/gameinput.ron +++ b/assets/voxygen/i18n/en/gameinput.ron @@ -21,6 +21,7 @@ "gameinput.help": "Toggle Help Window", "gameinput.toggleinterface": "Toggle Interface", "gameinput.toggledebug": "Toggle FPS and Debug Info", + "gameinput.toggle_egui_debug": "Toggle EGUI Debug Info", "gameinput.togglechat": "Toggle Chat", "gameinput.screenshot": "Take Screenshot", "gameinput.toggleingameui": "Toggle Nametags", diff --git a/voxygen/src/controller.rs b/voxygen/src/controller.rs index b9eec9aa82..b64860e9e0 100644 --- a/voxygen/src/controller.rs +++ b/voxygen/src/controller.rs @@ -150,6 +150,10 @@ impl From<&crate::settings::GamepadSettings> for ControllerSettings { map.entry(settings.game_buttons.toggle_debug) .or_default() .push(GameInput::ToggleDebug); + #[cfg(feature = "egui-ui")] + map.entry(settings.game_buttons.toggle_debug) + .or_default() + .push(GameInput::ToggleEguiDebug); map.entry(settings.game_buttons.toggle_chat) .or_default() .push(GameInput::ToggleChat); diff --git a/voxygen/src/game_input.rs b/voxygen/src/game_input.rs index db75015f1b..6756330cd7 100644 --- a/voxygen/src/game_input.rs +++ b/voxygen/src/game_input.rs @@ -106,6 +106,9 @@ pub enum GameInput { Help, #[strum(serialize = "gameinput.toggledebug")] ToggleDebug, + #[cfg(feature = "egui-ui")] + #[strum(serialize = "gameinput.toggle_egui_debug")] + ToggleEguiDebug, #[strum(serialize = "gameinput.togglechat")] ToggleChat, #[strum(serialize = "gameinput.fullscreen")] diff --git a/voxygen/src/hud/mod.rs b/voxygen/src/hud/mod.rs index 92fa442b93..342c94023c 100644 --- a/voxygen/src/hud/mod.rs +++ b/voxygen/src/hud/mod.rs @@ -3656,6 +3656,12 @@ impl Hud { self.show.debug = global_state.settings.interface.toggle_debug; true }, + #[cfg(feature = "egui-ui")] + GameInput::ToggleEguiDebug if state => { + global_state.settings.interface.toggle_egui_debug = + !global_state.settings.interface.toggle_egui_debug; + true + }, GameInput::ToggleChat if state => { global_state.settings.interface.toggle_chat = !global_state.settings.interface.toggle_chat; diff --git a/voxygen/src/settings/control.rs b/voxygen/src/settings/control.rs index 213a82f1f3..faa53ba8f1 100644 --- a/voxygen/src/settings/control.rs +++ b/voxygen/src/settings/control.rs @@ -144,6 +144,8 @@ impl ControlSettings { GameInput::Help => KeyMouse::Key(VirtualKeyCode::F1), GameInput::ToggleInterface => KeyMouse::Key(VirtualKeyCode::F2), GameInput::ToggleDebug => KeyMouse::Key(VirtualKeyCode::F3), + #[cfg(feature = "egui-ui")] + GameInput::ToggleEguiDebug => KeyMouse::Key(VirtualKeyCode::F7), GameInput::ToggleChat => KeyMouse::Key(VirtualKeyCode::F5), GameInput::Fullscreen => KeyMouse::Key(VirtualKeyCode::F11), GameInput::Screenshot => KeyMouse::Key(VirtualKeyCode::F4), diff --git a/voxygen/src/settings/gamepad.rs b/voxygen/src/settings/gamepad.rs index 1fe8b25739..4cc7d0e78d 100644 --- a/voxygen/src/settings/gamepad.rs +++ b/voxygen/src/settings/gamepad.rs @@ -77,6 +77,8 @@ pub mod con_settings { pub help: Button, pub toggle_interface: Button, pub toggle_debug: Button, + #[cfg(feature = "egui-ui")] + pub toggle_egui_debug: Button, pub toggle_chat: Button, pub fullscreen: Button, pub screenshot: Button, @@ -168,6 +170,8 @@ pub mod con_settings { help: Button::Simple(GilButton::Unknown), toggle_interface: Button::Simple(GilButton::Unknown), toggle_debug: Button::Simple(GilButton::Unknown), + #[cfg(feature = "egui-ui")] + toggle_egui_debug: Button::Simple(GilButton::Unknown), toggle_chat: Button::Simple(GilButton::Unknown), fullscreen: Button::Simple(GilButton::Unknown), screenshot: Button::Simple(GilButton::Unknown), From 3411ccc7ee620e432e5bb431a01f0cfb5acffec5 Mon Sep 17 00:00:00 2001 From: juliancoffee Date: Fri, 6 Aug 2021 22:53:51 +0300 Subject: [PATCH 3/3] Shift egui debug window right --- voxygen/egui/src/lib.rs | 4 +++- voxygen/src/run.rs | 3 ++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/voxygen/egui/src/lib.rs b/voxygen/egui/src/lib.rs index d851f714c3..c92f120c68 100644 --- a/voxygen/egui/src/lib.rs +++ b/voxygen/egui/src/lib.rs @@ -14,7 +14,7 @@ use core::mem; use egui::{ plot::{Plot, Value}, widgets::plot::Curve, - CollapsingHeader, Color32, Grid, Label, ScrollArea, Slider, Ui, Window, + CollapsingHeader, Color32, Grid, Label, Pos2, ScrollArea, Slider, Ui, Window, }; fn two_col_row(ui: &mut Ui, label: impl Into