diff --git a/Cargo.lock b/Cargo.lock index 5f37f87..99bf27f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -644,8 +644,7 @@ dependencies = [ [[package]] name = "egui-sfml" version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f56d752addd1955819d547ae5d60c6520039e014f28fd72115c93e2602142c21" +source = "git+https://github.com/crumblingstatue/egui-sfml.git#80c8100a7bab657d27cf5ed80f4cfc8555ed4b80" dependencies = [ "egui", "glu-sys", @@ -2067,15 +2066,15 @@ dependencies = [ [[package]] name = "sfml" -version = "0.23.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "12aaf39186c88af472facf8c5ac113cf19cbe2587f1295aff9ac469cf95a89b9" +version = "0.24.0-alpha.1" +source = "git+https://github.com/jeremyletang/rust-sfml.git#8380032676dfdb18538c26ca365f905507792c08" dependencies = [ "bitflags 2.6.0", "cc", "cmake", "link-cplusplus", "num-traits", + "pkg-config", "widestring", ] diff --git a/Cargo.toml b/Cargo.toml index d95b02b..061e474 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -26,7 +26,7 @@ either = "1.10.0" tree_magic_mini = { version = "3.1.4", features = ["tree_magic_db"] } bytemuck = "1.15.0" slotmap = { version = "1.0.7", features = ["serde"] } -egui-sfml = { version = "0.6.0", optional = true } +egui-sfml = { git = "https://github.com/crumblingstatue/egui-sfml.git", optional = true } num-traits = "0.2.18" serde-big-array = "0.5.1" egui = { version = "0.29", features = ["serde"] } diff --git a/src/gui.rs b/src/gui.rs index 5337e08..9cf53a2 100644 --- a/src/gui.rs +++ b/src/gui.rs @@ -84,7 +84,7 @@ impl Gui { } } -#[must_use = "Returns false if application should quit"] +/// The bool indicates whether the application should continue running pub fn do_egui( sf_egui: &mut SfEgui, gui: &mut crate::gui::Gui, @@ -94,8 +94,8 @@ pub fn do_egui( rwin: &mut RenderWindow, font_size: u16, line_spacing: u16, -) -> anyhow::Result { - sf_egui.run(rwin, |_rwin, ctx| { +) -> anyhow::Result<(egui_sfml::DrawInput, bool)> { + let di = sf_egui.run(rwin, |_rwin, ctx| { let mut open = IMMEDIATE.enabled() || PERSISTENT.enabled(); let was_open = open; Window::new("Debug").open(&mut open).show(ctx, windows::debug_window::ui); @@ -178,7 +178,7 @@ pub fn do_egui( line_spacing, ); })?; - Ok(true) + Ok((di, true)) } pub fn set_font_sizes_ctx(ctx: &egui::Context, style: &Style) { diff --git a/src/main.rs b/src/main.rs index 4c59c74..db13f10 100644 --- a/src/main.rs +++ b/src/main.rs @@ -319,37 +319,43 @@ fn do_fatal_error_report(title: &str, mut desc: &str, backtrace: &Backtrace) { } } rw.clear(Color::BLACK); - let _ = sf_egui.run(&mut rw, |rw, ctx| { - egui::CentralPanel::default().show(ctx, |ui| { - ui.heading(title); - ui.separator(); - egui::ScrollArea::vertical().auto_shrink(false).max_height(500.).show(ui, |ui| { - ui.add( - egui::TextEdit::multiline(&mut desc) - .code_editor() - .desired_width(f32::INFINITY), + #[expect(clippy::unwrap_used)] + let di = sf_egui + .run(&mut rw, |rw, ctx| { + egui::CentralPanel::default().show(ctx, |ui| { + ui.heading(title); + ui.separator(); + egui::ScrollArea::vertical().auto_shrink(false).max_height(500.).show( + ui, + |ui| { + ui.add( + egui::TextEdit::multiline(&mut desc) + .code_editor() + .desired_width(f32::INFINITY), + ); + if !bt_string.is_empty() { + ui.heading("Backtrace"); + ui.add( + egui::TextEdit::multiline(&mut bt_string.as_str()) + .code_editor() + .desired_width(f32::INFINITY), + ); + } + }, ); - if !bt_string.is_empty() { - ui.heading("Backtrace"); - ui.add( - egui::TextEdit::multiline(&mut bt_string.as_str()) - .code_editor() - .desired_width(f32::INFINITY), - ); - } - }); - ui.separator(); - ui.horizontal(|ui| { - if ui.button("Copy to clipboard").clicked() { - ui.output_mut(|out| out.copied_text = desc.to_owned()); - } - if ui.button("Close").clicked() { - rw.close(); - } + ui.separator(); + ui.horizontal(|ui| { + if ui.button("Copy to clipboard").clicked() { + ui.output_mut(|out| out.copied_text = desc.to_owned()); + } + if ui.button("Close").clicked() { + rw.close(); + } + }); }); - }); - }); - sf_egui.draw(&mut rw, None); + }) + .unwrap(); + sf_egui.draw(di, &mut rw, None); rw.display(); } } @@ -376,7 +382,8 @@ fn do_frame( update(app, sf_egui.context().wants_keyboard_input()); app.update(gui, window, lua, font_size, line_spacing); let mp: ViewportVec = try_conv_mp_zero(window.mouse_position()); - if !gui::do_egui(sf_egui, gui, app, mp, lua, window, font_size, line_spacing)? { + let (di, cont) = gui::do_egui(sf_egui, gui, app, mp, lua, window, font_size, line_spacing)?; + if !cont { return Ok(false); } // Here we flush GUI command queue every frame @@ -400,7 +407,7 @@ fn do_frame( window.draw_text(&txt, &RenderStates::DEFAULT); } } - sf_egui.draw(window, None); + sf_egui.draw(di, window, None); window.display(); // Should only be true on the frame right after reloading app.just_reloaded = false; @@ -642,12 +649,12 @@ fn handle_events( clippy::cast_precision_loss, reason = "Window sizes larger than i16::MAX aren't supported." )] - window.set_view(&View::from_rect(Rect::new( - 0., - 0., - width as f32, - height as f32, - ))); + match View::from_rect(Rect::new(0., 0., width as f32, height as f32)) { + Ok(view) => window.set_view(&view), + Err(e) => { + gamedebug_core::per!("Failed to create view: {e}"); + } + } } _ => {} } diff --git a/src/view/draw.rs b/src/view/draw.rs index ce853cf..aea6984 100644 --- a/src/view/draw.rs +++ b/src/view/draw.rs @@ -448,7 +448,7 @@ impl View { } }, ); - rs.set_texture(Some(font.texture(hex.font_size.into()))); + rs.texture = Some(font.texture(hex.font_size.into())); } ViewKind::Dec(dec) => { draw_view( @@ -510,7 +510,7 @@ impl View { } }, ); - rs.set_texture(Some(font.texture(dec.font_size.into()))); + rs.texture = Some(font.texture(dec.font_size.into())); } ViewKind::Text(text) => { draw_view( @@ -574,7 +574,7 @@ impl View { } }, ); - rs.set_texture(Some(font.texture(text.font_size.into()))); + rs.texture = Some(font.texture(text.font_size.into())); } ViewKind::Block => { draw_view(