From 05f454c3f0c072df66f69350bdf5c76b22708fa6 Mon Sep 17 00:00:00 2001 From: LLLL Colonq Date: Mon, 11 May 2026 18:05:45 -0400 Subject: Clean up warnings --- crates/teleia/src/font.rs | 2 +- crates/teleia/src/lib.rs | 2 ++ crates/teleia/src/renderer.rs | 5 ++--- crates/teleia/src/script.rs | 1 + crates/teleia/src/state.rs | 37 +++++++++++++++++++++++-------------- 5 files changed, 29 insertions(+), 18 deletions(-) diff --git a/crates/teleia/src/font.rs b/crates/teleia/src/font.rs index 2e90571..0f18cd7 100644 --- a/crates/teleia/src/font.rs +++ b/crates/teleia/src/font.rs @@ -75,7 +75,7 @@ impl Bitmap { } pub fn render_text_parameterized(&self, - ctx: &context::Context, st: &state::State, + ctx: &context::Context, _st: &state::State, text: &str, params: BitmapParams, ) { diff --git a/crates/teleia/src/lib.rs b/crates/teleia/src/lib.rs index 32e2e9c..0d9a53f 100644 --- a/crates/teleia/src/lib.rs +++ b/crates/teleia/src/lib.rs @@ -141,6 +141,7 @@ where } game.initialize(ctx, st)?; + st.initialize_audio(ctx, game)?; 'running: loop { if ctx.window.borrow().should_close() { game.finalize(ctx, st)?; @@ -244,6 +245,7 @@ where } let _ = game.initialize(ctx, st); + let _ = st.initialize_audio(ctx, game); let res = std::rc::Rc::new(std::cell::RefCell::new(Ok(()))); let result = res.clone(); event_loop.set_control_flow(winit::event_loop::ControlFlow::Wait); diff --git a/crates/teleia/src/renderer.rs b/crates/teleia/src/renderer.rs index 5242eac..49a7913 100644 --- a/crates/teleia/src/renderer.rs +++ b/crates/teleia/src/renderer.rs @@ -295,7 +295,7 @@ impl Renderer { self.texture = BoundTexture::None; self.bind_uber_2d(ctx, st, UberFlags::TEXTURE_COLOR | UberFlags::VERTEX_COLOR | UberFlags::FLIP_TEXTURE); let dims = glam::Vec2::new(st.font_default.char_width as f32, st.font_default.char_height as f32); - let fpos = (pos + glam::Vec2::new(-dims.x / 2.0, st.font_default.char_height as f32 / 2.0)); + let fpos = pos + glam::Vec2::new(-dims.x / 2.0, st.font_default.char_height as f32 / 2.0); self.set_position_2d(ctx, st, fpos, dims); st.font_default.render_text_helper(ctx, st, s, &[col]); } @@ -309,9 +309,8 @@ impl Renderer { self.texture = BoundTexture::None; self.bind_uber_2d(ctx, st, UberFlags::TEXTURE_COLOR | UberFlags::VERTEX_COLOR | UberFlags::FLIP_TEXTURE); let width = s.len() as f32 * st.font_default.char_width as f32; - let height = st.font_default.char_height as f32; let dims = glam::Vec2::new(st.font_default.char_width as f32, st.font_default.char_height as f32); - let fpos = (pos + glam::Vec2::new(-dims.x / 2.0 - (width / 2.0).round(), st.font_default.char_height as f32 / 2.0)); + let fpos = pos + glam::Vec2::new(-dims.x / 2.0 - (width / 2.0).round(), st.font_default.char_height as f32 / 2.0); self.set_position_2d(ctx, st, fpos, dims); st.font_default.render_text(ctx, st, s); } diff --git a/crates/teleia/src/script.rs b/crates/teleia/src/script.rs index 6995dba..0631e31 100644 --- a/crates/teleia/src/script.rs +++ b/crates/teleia/src/script.rs @@ -58,6 +58,7 @@ struct PitParser { cur: PitParserTokenInfo, next: PitParserTokenInfo, } +#[allow(dead_code)] unsafe extern "C" { pub fn pit_runtime_test(out: *mut u8, out_len: i64, buf: *mut u8, len: i64) -> c_int; fn pit_runtime_new(buf: *mut MaybeUninit, len: i64) -> *mut PitRuntime; diff --git a/crates/teleia/src/state.rs b/crates/teleia/src/state.rs index 9ac617e..354bd1c 100644 --- a/crates/teleia/src/state.rs +++ b/crates/teleia/src/state.rs @@ -22,10 +22,10 @@ pub trait Game { ) -> HashMap { HashMap::new() } - fn finish_title(&mut self, ctx: &context::Context, st: &mut State) -> utils::Erm<()> { Ok(()) } fn keybindings_were_reset(&mut self, ctx: &context::Context, st: &mut State) -> utils::Erm<()> { Ok(()) } fn mouse_move(&mut self, ctx: &context::Context, st: &mut State, x: i32, y: i32) -> utils::Erm<()> { Ok(()) } fn mouse_press(&mut self, ctx: &context::Context, st: &mut State) -> utils::Erm<()> { Ok(()) } + fn mouse_released(&mut self, ctx: &context::Context, st: &mut State) -> utils::Erm<()> { Ok(()) } fn update(&mut self, ctx: &context::Context, st: &mut State) -> utils::Erm<()> { Ok(()) } fn render(&mut self, ctx: &context::Context, st: &mut State) -> utils::Erm<()> { Ok(()) } } @@ -447,6 +447,20 @@ impl State { ); } + pub fn initialize_audio( + &mut self, + ctx: &context::Context, + game: &mut G + ) -> utils::Erm<()> where G: Game + { + if self.audio.is_none() { + self.audio = Some(audio::Assets::new(|actx| { + game.initialize_audio(ctx, &self, actx) + })); + } + Ok(()) + } + pub fn mouse_moved( &mut self, ctx: &context::Context, @@ -474,22 +488,17 @@ impl State { ctx: &context::Context, game: &mut G ) -> utils::Erm<()> where G: Game { - log::info!("click"); - if self.audio.is_none() { - self.audio = Some(audio::Assets::new(|actx| { - game.initialize_audio(ctx, &self, actx) - })); - game.finish_title(ctx, self)?; - } + self.initialize_audio(ctx, game)?; game.mouse_press(ctx, self)?; Ok(()) } pub fn mouse_released( &mut self, - _ctx: &context::Context, - _game: &mut G + ctx: &context::Context, + game: &mut G ) -> utils::Erm<()> where G: Game { + game.mouse_released(ctx, self)?; Ok(()) } @@ -584,10 +593,10 @@ impl State { if err != glow::NO_ERROR { log::warn!("opengl error: {}", err); } - let log = unsafe { ctx.gl.get_debug_message_log(5) }; - for m in log { - log::warn!("opengl debug message: {:?}", m); - } + // let log = unsafe { ctx.gl.get_debug_message_log(5) }; + // for m in log { + // log::warn!("opengl debug message: {:?}", m); + // } } Ok(()) } -- cgit v1.2.3