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:
@@ -5,7 +5,7 @@ use glib::Cast;
|
||||
const SPRITE_SCALE: f64 = 0.6;
|
||||
|
||||
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.
|
||||
|
||||
@@ -15,11 +15,8 @@ pub fn place_sprite(
|
||||
let sprite_w = animation.width();
|
||||
let sprite_h = animation.height();
|
||||
|
||||
let safe_w = screen_w - SPRITE_MARGIN;
|
||||
let safe_h = screen_h - SPRITE_MARGIN;
|
||||
|
||||
let max_x = (safe_w - sprite_w).max(0);
|
||||
let max_y = (safe_h - sprite_h).max(0);
|
||||
let max_x = screen_w.saturating_sub(SPRITE_MARGIN).saturating_sub(sprite_w).max(0);
|
||||
let max_y = screen_h.saturating_sub(SPRITE_MARGIN).saturating_sub(sprite_h).max(0);
|
||||
|
||||
let mut rng = rand::thread_rng();
|
||||
let mut x = rng.gen_range(0..=max_x);
|
||||
@@ -38,6 +35,7 @@ pub fn place_sprite(
|
||||
}
|
||||
|
||||
let image = gtk::Image::from_animation(animation);
|
||||
image.show();
|
||||
fixed.put(&image, x, y);
|
||||
image
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user