improve error handling and add metadata

This commit is contained in:
Chance 2025-04-03 01:00:24 -04:00
parent 13893e96a9
commit 43fd5966b7
17 changed files with 1162 additions and 787 deletions

View file

@ -2,6 +2,8 @@ use std::ops::Deref;
use std::sync::Arc;
use ctx::{Renderer, Vertex};
use winit::dpi::LogicalSize;
use winit::dpi::Size;
use std::env;
use std::fs;
use std::path::PathBuf;
@ -84,7 +86,7 @@ f 6/11/6 5/10/6 1/1/6 2/13/6
impl App<'_> {
fn create_main_window(&mut self, event_loop: &ActiveEventLoop) {
let win_attr = Window::default_attributes().with_title("Zenyx");
let win_attr = Window::default_attributes().with_title("Zenyx").with_min_inner_size(Size::Logical(LogicalSize::new(100.0, 100.0)));
match event_loop.create_window(win_attr) {
Ok(window) => {
let window = Arc::new(window);
@ -119,10 +121,10 @@ impl App<'_> {
);
info!("Main window created: {:?}", window_id);
}
Err(e) => error!("Failed to create WGPU context: {:?}", e),
Err(e) => error!("Failed to create WGPU context: {:#}", e),
}
}
Err(e) => error!("Failed to create main window: {:?}", e),
Err(e) => error!("Failed to create main window: {:#}", e),
}
}
@ -140,9 +142,9 @@ impl App<'_> {
window_id: WindowId,
key_event: KeyEvent,
) {
if !key_event.state.is_pressed() {
if !key_event.state.is_pressed() || key_event.repeat {
return;
}
}
match key_event.physical_key {
winit::keyboard::PhysicalKey::Code(code) => match code {
winit::keyboard::KeyCode::Space => {
@ -186,10 +188,19 @@ impl App<'_> {
let title = format!("Zenyx - New Window {}", self.windows.len());
// TODO: Verify that this is safe instead of matching on it
let win_attr = unsafe {
let base = Window::default_attributes().with_title(title);
let base = Window::default_attributes().with_title(title).with_min_inner_size(Size::Logical(LogicalSize::new(100.0, 100.0)));
match main_ctx.window_handle() {
Ok(handle) => base.with_parent_window(Some(handle.as_raw())),
Err(_) => base,
Ok(handle) => {
if !cfg!(target_os = "windows") {
base.with_parent_window(Some(handle.as_raw()))
} else {
base
}
},
Err(e) => {
error!("{e}");
base
},
}
};
match event_loop.create_window(win_attr) {
@ -350,6 +361,6 @@ pub fn init_renderer(event_loop: EventLoop<()>) {
event_loop.set_control_flow(ControlFlow::Wait);
let mut app = App::default();
if let Err(e) = event_loop.run_app(&mut app) {
error!("Failed to run application: {:?}", e);
error!("Failed to run application: {}", e);
}
}