From 9714b8a3ca97fd091692cee20f2438c37a082805 Mon Sep 17 00:00:00 2001 From: Corwin Date: Tue, 15 Feb 2022 21:28:21 +0000 Subject: [PATCH] types required for aseprite import --- agb-image-converter/Cargo.toml | 3 +- agb-image-converter/src/aseprite.rs | 56 +++++++++++++++++++++++++++++ agb-image-converter/src/lib.rs | 1 + 3 files changed, 59 insertions(+), 1 deletion(-) create mode 100644 agb-image-converter/src/aseprite.rs diff --git a/agb-image-converter/Cargo.toml b/agb-image-converter/Cargo.toml index f26d4630..52fdf639 100644 --- a/agb-image-converter/Cargo.toml +++ b/agb-image-converter/Cargo.toml @@ -15,4 +15,5 @@ toml = "0.5.8" serde = { version = "1.0", features = ["derive"] } syn = "1.0.86" proc-macro2 = "1.0.36" -quote = "1.0.15" \ No newline at end of file +quote = "1.0.15" +serde_json = "1.0" \ No newline at end of file diff --git a/agb-image-converter/src/aseprite.rs b/agb-image-converter/src/aseprite.rs new file mode 100644 index 00000000..5efa51e6 --- /dev/null +++ b/agb-image-converter/src/aseprite.rs @@ -0,0 +1,56 @@ +use serde::Deserialize; + +#[derive(Deserialize)] +pub struct Aseprite { + pub frames: Vec, + pub meta: Meta, +} + +#[derive(Deserialize)] +pub struct Meta { + pub app: String, + pub version: String, + pub image: String, + pub format: String, + pub size: Size, + pub scale: String, + #[serde(rename = "frameTags")] + pub frame_tags: Vec, +} + +#[derive(Deserialize)] +pub struct Size { + pub w: u32, + pub h: u32, +} + +#[derive(Deserialize, Clone, Copy)] +#[serde(rename_all = "lowercase")] +pub enum Direction { + Forward, + Backward, + Pingpong, +} + +#[derive(Deserialize)] + +pub struct FrameTag { + pub name: String, + pub from: u32, + pub to: u32, + pub direction: Direction, +} + +#[derive(Deserialize)] +pub struct Frame { + pub frame: Frame2, + pub trimmed: bool, +} + +#[derive(Deserialize)] +pub struct Frame2 { + pub x: u32, + pub y: u32, + pub w: u32, + pub h: u32, +} diff --git a/agb-image-converter/src/lib.rs b/agb-image-converter/src/lib.rs index 7d6df7e8..bedcf034 100644 --- a/agb-image-converter/src/lib.rs +++ b/agb-image-converter/src/lib.rs @@ -5,6 +5,7 @@ use std::path::Path; use quote::{format_ident, quote}; +mod aseprite; mod colour; mod config; mod image_loader;