Debug info for menus
This commit is contained in:
parent
8d26ea38c8
commit
4d6974d70f
@ -29,6 +29,7 @@ pub enum MenuStateSignal {
|
|||||||
pub struct MainMenu {
|
pub struct MainMenu {
|
||||||
pub has_updated_discord_rpc: bool,
|
pub has_updated_discord_rpc: bool,
|
||||||
volume_percentage: f32,
|
volume_percentage: f32,
|
||||||
|
show_debug_info: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl MainMenu {
|
impl MainMenu {
|
||||||
@ -42,6 +43,7 @@ impl MainMenu {
|
|||||||
Self {
|
Self {
|
||||||
has_updated_discord_rpc: false,
|
has_updated_discord_rpc: false,
|
||||||
volume_percentage: game_settings.volume.unwrap_or(0.5),
|
volume_percentage: game_settings.volume.unwrap_or(0.5),
|
||||||
|
show_debug_info: false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -78,9 +80,21 @@ impl MainMenu {
|
|||||||
let mouse_x = draw.get_mouse_x();
|
let mouse_x = draw.get_mouse_x();
|
||||||
let mouse_y = draw.get_mouse_y();
|
let mouse_y = draw.get_mouse_y();
|
||||||
|
|
||||||
//TODO Errase later
|
// Optionally display debug info
|
||||||
draw.draw_text(&mouse_x.to_string(), 20, 5, 20, Color::BLACK);
|
if draw.is_key_pressed(KeyboardKey::KEY_F3) {
|
||||||
draw.draw_text(&mouse_y.to_string(), 70, 5, 20, Color::BLACK);
|
self.show_debug_info = !self.show_debug_info;
|
||||||
|
}
|
||||||
|
if self.show_debug_info {
|
||||||
|
// Draw FPS and mouse location
|
||||||
|
draw.draw_fps(10, 10);
|
||||||
|
draw.draw_text(
|
||||||
|
format!("Mouse position: ({}, {})", mouse_x, mouse_y).as_str(),
|
||||||
|
10,
|
||||||
|
30,
|
||||||
|
20,
|
||||||
|
Color::GREEN,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
//Screen Size
|
//Screen Size
|
||||||
let window_height = draw.get_screen_height();
|
let window_height = draw.get_screen_height();
|
||||||
|
@ -17,7 +17,9 @@ use crate::{
|
|||||||
use super::main_menu::MenuStateSignal;
|
use super::main_menu::MenuStateSignal;
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct PauseMenu {}
|
pub struct PauseMenu {
|
||||||
|
show_debug_info: bool,
|
||||||
|
}
|
||||||
|
|
||||||
impl PauseMenu {
|
impl PauseMenu {
|
||||||
/// Construct a new `PauseMenu`
|
/// Construct a new `PauseMenu`
|
||||||
@ -27,7 +29,9 @@ impl PauseMenu {
|
|||||||
constants: &ProjectConstants,
|
constants: &ProjectConstants,
|
||||||
game_settings: &mut PersistentGameSettings,
|
game_settings: &mut PersistentGameSettings,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
Self {}
|
Self {
|
||||||
|
show_debug_info: false,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn render_pause_menu_frame(
|
pub async fn render_pause_menu_frame(
|
||||||
@ -45,6 +49,26 @@ impl PauseMenu {
|
|||||||
// Clear the screen
|
// Clear the screen
|
||||||
draw.clear_background(Color::WHITE);
|
draw.clear_background(Color::WHITE);
|
||||||
|
|
||||||
|
//Obtain mouse position
|
||||||
|
let mouse_x = draw.get_mouse_x();
|
||||||
|
let mouse_y = draw.get_mouse_y();
|
||||||
|
|
||||||
|
// Optionally display debug info
|
||||||
|
if draw.is_key_pressed(KeyboardKey::KEY_F3) {
|
||||||
|
self.show_debug_info = !self.show_debug_info;
|
||||||
|
}
|
||||||
|
if self.show_debug_info {
|
||||||
|
// Draw FPS and mouse location
|
||||||
|
draw.draw_fps(10, 10);
|
||||||
|
draw.draw_text(
|
||||||
|
format!("Mouse position: ({}, {})", mouse_x, mouse_y).as_str(),
|
||||||
|
10,
|
||||||
|
30,
|
||||||
|
20,
|
||||||
|
Color::GREEN,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
// Title
|
// Title
|
||||||
draw.draw_text("Paused", 100, 90, 60, Color::BLACK);
|
draw.draw_text("Paused", 100, 90, 60, Color::BLACK);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user