delete toml/intermediate palettes

This commit is contained in:
Max Bradbury 2021-05-16 22:49:12 +01:00
parent e35a453f76
commit d66da61f70
3 changed files with 2 additions and 56 deletions

View File

@ -11,7 +11,6 @@ mod room;
pub use colour::Colour; pub use colour::Colour;
pub use palette::Palette; pub use palette::Palette;
pub use palette::IntermediatePalette;
use crate::config::Config; use crate::config::Config;
#[derive(Eq, Hash, PartialEq)] #[derive(Eq, Hash, PartialEq)]

View File

@ -67,18 +67,7 @@
// } // }
pub(crate) mod palette { pub(crate) mod palette {
use crate::{Palette, Colour, IntermediatePalette}; use crate::{Palette, Colour};
pub(crate) fn intermediate() -> IntermediatePalette {
IntermediatePalette {
colours: vec![
vec![0,0,0,0],
vec![0,81,104,255],
vec![118,159,155,255],
vec![155,155,155,255],
]
}
}
pub(crate) fn default() -> Palette { pub(crate) fn default() -> Palette {
Palette { Palette {

View File

@ -2,7 +2,7 @@ use std::fs::read_to_string;
use std::path::PathBuf; use std::path::PathBuf;
use serde_derive::{Serialize, Deserialize}; use serde_derive::{Serialize, Deserialize};
use crate::colour::Colour; use crate::colour::Colour;
use image::{GenericImageView, Rgba, DynamicImage, Rgb, GenericImage}; use image::{GenericImageView, Rgba, DynamicImage, GenericImage};
use image::io::Reader as ImageReader; use image::io::Reader as ImageReader;
/// todo enumerate original format /// todo enumerate original format
@ -13,23 +13,6 @@ pub struct Palette {
} }
impl Palette { impl Palette {
pub fn from(name: &str, toml: &str) -> Self {
let intermediate: IntermediatePalette = toml::from_str(toml).unwrap();
println!("palette name: {}", name);
for colour in &intermediate.colours {
println!("palette colour: {}{}{}", colour[0], colour[1], colour[2]);
}
Palette {
name: name.to_string(),
colours: intermediate.colours.iter().map(|vec| {
Colour::from(vec.clone())
}).collect(),
}
}
/// todo result /// todo result
pub fn from_file(path: PathBuf) -> Self { pub fn from_file(path: PathBuf) -> Self {
match path.extension().unwrap().to_str().unwrap() { match path.extension().unwrap().to_str().unwrap() {
@ -38,10 +21,6 @@ impl Palette {
"pal" => Self::from_jasc(path), "pal" => Self::from_jasc(path),
"png" => Self::from_png(path), "png" => Self::from_png(path),
"txt" => Self::from_txt(path), "txt" => Self::from_txt(path),
"toml" => Self::from(
path.file_stem().as_ref().unwrap().to_str().unwrap(),
&read_to_string(&path).unwrap()
),
_ => panic!("Bad palette") _ => panic!("Bad palette")
} }
} }
@ -191,27 +170,6 @@ impl Palette {
} }
} }
/// for toml purposes
#[derive(Serialize, Deserialize)]
pub struct IntermediatePalette {
pub colours: Vec<Vec<u8>>,
}
/// for toml purposes
#[derive(Serialize, Deserialize)]
struct IntermediatePalettes {
/// singular so each palette section is named "palette" instead of "palettes" in toml
palette: Vec<IntermediatePalette>,
}
// impl IntermediatePalettes {
// pub fn from_dir() -> Self {
// Self {
// palette: vec![]
// }
// }
// }
#[cfg(test)] #[cfg(test)]
mod test { mod test {
use std::path::PathBuf; use std::path::PathBuf;