Allow importing aseprite backgrounds directly

This commit is contained in:
GBA bot 2023-04-13 22:31:45 +01:00 committed by Gwilym Inzani
parent 498236d064
commit 753f59e0e0
9 changed files with 17 additions and 7 deletions

View file

@ -1,6 +1,6 @@
use std::path; use std::{ffi::OsStr, path};
use image::GenericImageView; use image::{DynamicImage, GenericImageView};
use crate::colour::Colour; use crate::colour::Colour;
@ -12,7 +12,17 @@ pub(crate) struct Image {
impl Image { impl Image {
pub fn load_from_file(image_path: &path::Path) -> Self { pub fn load_from_file(image_path: &path::Path) -> Self {
let img = image::open(image_path).expect("Expected image to exist"); let img = if image_path
.extension()
.is_some_and(|extension| extension == OsStr::new("aseprite"))
{
let ase =
asefile::AsepriteFile::read_file(image_path).expect("failed to read aseprite file");
DynamicImage::ImageRgba8(ase.frame(0).image())
} else {
image::open(image_path).expect("Expected image to exist")
};
Self::load_from_dyn_image(img) Self::load_from_dyn_image(img)
} }

Binary file not shown.

Before

Width:  |  Height:  |  Size: 591 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 550 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.2 KiB

View file

@ -6,9 +6,9 @@ use agb::{
use crate::sfx::Sfx; use crate::sfx::Sfx;
include_background_gfx!(backgrounds, "121105", include_background_gfx!(backgrounds, "121105",
stars => "gfx/stars.png", stars => "gfx/stars.aseprite",
title => "gfx/title-screen.png", title => "gfx/title-screen.aseprite",
help => "gfx/help-text.png", help => "gfx/help-text.aseprite",
descriptions1 => "gfx/descriptions1.png", descriptions1 => "gfx/descriptions1.png",
descriptions2 => "gfx/descriptions2.png", descriptions2 => "gfx/descriptions2.png",
); );

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.5 KiB

View file

@ -57,7 +57,7 @@ const SWORDLESS_JUMP: &Tag = TAG_MAP.get("jump swordless");
const SWORDLESS_ATTACK: &Tag = KNIFE_ATTACK; const SWORDLESS_ATTACK: &Tag = KNIFE_ATTACK;
const SWORDLESS_JUMP_ATTACK: &Tag = KNIFE_JUMP_ATTACK; const SWORDLESS_JUMP_ATTACK: &Tag = KNIFE_JUMP_ATTACK;
agb::include_background_gfx!(background, "53269a", background => "gfx/background.png"); agb::include_background_gfx!(background, "53269a", background => "gfx/background.aseprite");
type Number = FixedNum<8>; type Number = FixedNum<8>;