diff --git a/agb-image-converter/src/config.rs b/agb-image-converter/src/config.rs index 5e0ce482..bccb252d 100644 --- a/agb-image-converter/src/config.rs +++ b/agb-image-converter/src/config.rs @@ -2,7 +2,7 @@ use serde::Deserialize; use std::collections::HashMap; use std::fs; -use crate::{Colour, TileSize}; +use crate::{Colour, Colours, TileSize}; pub(crate) fn parse(filename: &str) -> Box { let config_toml = @@ -23,6 +23,7 @@ pub(crate) fn parse(filename: &str) -> Box { pub(crate) trait Config { fn crate_prefix(&self) -> String; fn images(&self) -> HashMap; + fn colours(&self) -> Colours; } pub(crate) trait Image { @@ -35,6 +36,7 @@ pub(crate) trait Image { pub struct ConfigV1 { version: String, crate_prefix: Option, + colours: Option, image: HashMap, } @@ -52,6 +54,14 @@ impl Config for ConfigV1 { .map(|(filename, image)| (filename.clone(), image as &dyn Image)) .collect() } + + fn colours(&self) -> Colours { + match self.colours { + None | Some(16) => Colours::Colours16, + Some(256) => Colours::Colours256, + _ => panic!("colours must either not be set or 16 or 256"), + } + } } #[derive(Deserialize)] diff --git a/agb-image-converter/src/lib.rs b/agb-image-converter/src/lib.rs index 2f41c577..ddbe8638 100644 --- a/agb-image-converter/src/lib.rs +++ b/agb-image-converter/src/lib.rs @@ -30,6 +30,11 @@ pub(crate) enum TileSize { Tile32, } +pub(crate) enum Colours { + Colours16, + Colours256, +} + impl TileSize { fn to_size(self) -> usize { match self {