Initialize debug with proper Program name
This commit is contained in:
parent
f618382a0d
commit
a106f7f837
2 changed files with 24 additions and 0 deletions
|
|
@ -110,6 +110,10 @@ pub trait Program: Sized {
|
|||
type Flags = (P, I);
|
||||
type Executor = P::Executor;
|
||||
|
||||
fn name() -> &'static str {
|
||||
std::any::type_name::<P::State>()
|
||||
}
|
||||
|
||||
fn new(
|
||||
(program, initialize): Self::Flags,
|
||||
) -> (Self, Task<Self::Message>) {
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ pub use state::State;
|
|||
|
||||
use crate::conversion;
|
||||
use crate::core;
|
||||
use crate::core::keyboard;
|
||||
use crate::core::mouse;
|
||||
use crate::core::renderer;
|
||||
use crate::core::theme;
|
||||
|
|
@ -69,6 +70,9 @@ where
|
|||
/// The data needed to initialize your [`Program`].
|
||||
type Flags;
|
||||
|
||||
/// Returns the unique name of the [`Program`].
|
||||
fn name() -> &'static str;
|
||||
|
||||
/// Initializes the [`Program`] with the flags provided to
|
||||
/// [`run`] as part of the [`Settings`].
|
||||
///
|
||||
|
|
@ -154,6 +158,8 @@ where
|
|||
{
|
||||
use winit::event_loop::EventLoop;
|
||||
|
||||
debug::init(P::name());
|
||||
|
||||
let boot_span = debug::boot();
|
||||
|
||||
let event_loop = EventLoop::with_user_event()
|
||||
|
|
@ -973,6 +979,20 @@ async fn run_instance<P, C>(
|
|||
window.state.scale_factor(),
|
||||
window.state.modifiers(),
|
||||
) {
|
||||
if matches!(
|
||||
event,
|
||||
core::Event::Keyboard(
|
||||
keyboard::Event::KeyPressed {
|
||||
modified_key: keyboard::Key::Named(
|
||||
keyboard::key::Named::F12
|
||||
),
|
||||
..
|
||||
}
|
||||
)
|
||||
) {
|
||||
debug::toggle_comet();
|
||||
}
|
||||
|
||||
events.push((id, event));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue