fix: image.show(), private ahfail_get_resource, saturating_sub in display

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Asger Geel Weirsøe
2026-05-06 09:35:02 +02:00
parent 3dc0733cd0
commit f05e93b75e
2 changed files with 4 additions and 6 deletions

View File

@@ -5,7 +5,7 @@ use glib::Cast;
const SPRITE_SCALE: f64 = 0.6; const SPRITE_SCALE: f64 = 0.6;
extern "C" { extern "C" {
pub fn ahfail_get_resource() -> *mut gio::ffi::GResource; fn ahfail_get_resource() -> *mut gio::ffi::GResource;
} }
/// Registers GResources and loads all sprite frames into a looping PixbufSimpleAnim. /// Registers GResources and loads all sprite frames into a looping PixbufSimpleAnim.

View File

@@ -15,11 +15,8 @@ pub fn place_sprite(
let sprite_w = animation.width(); let sprite_w = animation.width();
let sprite_h = animation.height(); let sprite_h = animation.height();
let safe_w = screen_w - SPRITE_MARGIN; let max_x = screen_w.saturating_sub(SPRITE_MARGIN).saturating_sub(sprite_w).max(0);
let safe_h = screen_h - SPRITE_MARGIN; let max_y = screen_h.saturating_sub(SPRITE_MARGIN).saturating_sub(sprite_h).max(0);
let max_x = (safe_w - sprite_w).max(0);
let max_y = (safe_h - sprite_h).max(0);
let mut rng = rand::thread_rng(); let mut rng = rand::thread_rng();
let mut x = rng.gen_range(0..=max_x); let mut x = rng.gen_range(0..=max_x);
@@ -38,6 +35,7 @@ pub fn place_sprite(
} }
let image = gtk::Image::from_animation(animation); let image = gtk::Image::from_animation(animation);
image.show();
fixed.put(&image, x, y); fixed.put(&image, x, y);
image image
} }