From a8792744e12583a0997189e4f636f953e93ed814 Mon Sep 17 00:00:00 2001 From: Max Bradbury Date: Sun, 16 May 2021 17:04:46 +0100 Subject: [PATCH] comment out some currently-unused stuff --- src/image.rs | 74 +++++++++++++-------------- src/mock.rs | 134 ++++++++++++++++++++++++------------------------- src/palette.rs | 14 +++--- src/room.rs | 58 ++++++++++----------- 4 files changed, 140 insertions(+), 140 deletions(-) diff --git a/src/image.rs b/src/image.rs index 7533e07..a696627 100644 --- a/src/image.rs +++ b/src/image.rs @@ -7,16 +7,16 @@ pub struct Image { pub pixels: Vec, } -impl Image { - fn from(intermediate: IntermediateImage) -> Image { - Image { - name: intermediate.name.to_owned(), - pixels: intermediate.pixels.split_whitespace().collect::().chars().map( - |char|char as u8 - ).collect() - } - } -} +// impl Image { +// fn from(intermediate: IntermediateImage) -> Image { +// Image { +// name: intermediate.name.to_owned(), +// pixels: intermediate.pixels.split_whitespace().collect::().chars().map( +// |char|char as u8 +// ).collect() +// } +// } +// } /// for toml purposes #[derive(Debug, Serialize, Deserialize)] @@ -25,13 +25,13 @@ pub(crate) struct IntermediateImages { image: Vec, } -impl IntermediateImages { - fn to_images(&self) -> Vec { - self.image.iter().map(|intermediate| - Image::from(intermediate.clone()) - ).collect() - } -} +// impl IntermediateImages { +// fn to_images(&self) -> Vec { +// self.image.iter().map(|intermediate| +// Image::from(intermediate.clone()) +// ).collect() +// } +// } #[derive(Clone, Debug, Serialize, Deserialize)] pub(crate) struct IntermediateImage { @@ -39,26 +39,26 @@ pub(crate) struct IntermediateImage { pixels: String, } -impl IntermediateImage { - // todo refactor - fn from(image: Image) -> IntermediateImage { - let mut string = "\n".to_string(); - - let sqrt = (image.pixels.len() as f64).sqrt() as usize; - for line in image.pixels.chunks(sqrt) { - for pixel in line { - string.push_str(&format!("{}", *pixel)); - } - string.push('\n'); - } - - IntermediateImage { - name: image.name.to_owned(), - /// todo wtf? I guess this crate doesn't handle multiline strings correctly - pixels: format!("\"\"{}\"\"", string), - } - } -} +// impl IntermediateImage { +// // todo refactor +// fn from(image: Image) -> IntermediateImage { +// let mut string = "\n".to_string(); +// +// let sqrt = (image.pixels.len() as f64).sqrt() as usize; +// for line in image.pixels.chunks(sqrt) { +// for pixel in line { +// string.push_str(&format!("{}", *pixel)); +// } +// string.push('\n'); +// } +// +// IntermediateImage { +// name: image.name.to_owned(), +// /// todo wtf? I guess this crate doesn't handle multiline strings correctly +// pixels: format!("\"\"{}\"\"", string), +// } +// } +// } #[cfg(test)] mod test { diff --git a/src/mock.rs b/src/mock.rs index 710746f..1cd4d47 100644 --- a/src/mock.rs +++ b/src/mock.rs @@ -1,70 +1,70 @@ -pub(crate) mod image { - use crate::image::Image; - - pub fn bg() -> Image { - Image { - name: "bg".to_string(), - pixels: vec![ - 0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0, - ] - } - } - - pub fn block() -> Image { - Image { - name: "block".to_string(), - pixels: vec![ - 1,1,1,1,1,1,1,1, - 1,0,0,0,0,0,0,1, - 1,0,0,0,0,0,0,1, - 1,0,0,1,1,0,0,1, - 1,0,0,1,1,0,0,1, - 1,0,0,0,0,0,0,1, - 1,0,0,0,0,0,0,1, - 1,1,1,1,1,1,1,1, - ] - } - } - - pub fn avatar() -> Image { - Image { - name: "avatar".to_string(), - pixels: vec![ - 0,0,0,2,2,0,0,0, - 0,0,0,2,2,0,0,0, - 0,0,0,2,2,0,0,0, - 0,0,2,2,2,2,0,0, - 0,2,2,2,2,2,2,0, - 2,0,2,2,2,2,0,2, - 0,0,2,0,0,2,0,0, - 0,0,2,0,0,2,0,0, - ] - } - } - - pub fn cat() -> Image { - Image { - name: "cat".to_string(), - pixels: vec![ - 0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0, - 0,2,0,2,0,0,0,2, - 0,2,2,2,0,0,0,2, - 0,2,2,2,0,0,2,0, - 0,2,2,2,2,2,0,0, - 0,0,2,2,2,2,0,0, - 0,0,2,0,0,2,0,0, - ] - } - } -} +// pub(crate) mod image { +// use crate::image::Image; +// +// pub fn bg() -> Image { +// Image { +// name: "bg".to_string(), +// pixels: vec![ +// 0,0,0,0,0,0,0,0, +// 0,0,0,0,0,0,0,0, +// 0,0,0,0,0,0,0,0, +// 0,0,0,0,0,0,0,0, +// 0,0,0,0,0,0,0,0, +// 0,0,0,0,0,0,0,0, +// 0,0,0,0,0,0,0,0, +// 0,0,0,0,0,0,0,0, +// ] +// } +// } +// +// pub fn block() -> Image { +// Image { +// name: "block".to_string(), +// pixels: vec![ +// 1,1,1,1,1,1,1,1, +// 1,0,0,0,0,0,0,1, +// 1,0,0,0,0,0,0,1, +// 1,0,0,1,1,0,0,1, +// 1,0,0,1,1,0,0,1, +// 1,0,0,0,0,0,0,1, +// 1,0,0,0,0,0,0,1, +// 1,1,1,1,1,1,1,1, +// ] +// } +// } +// +// pub fn avatar() -> Image { +// Image { +// name: "avatar".to_string(), +// pixels: vec![ +// 0,0,0,2,2,0,0,0, +// 0,0,0,2,2,0,0,0, +// 0,0,0,2,2,0,0,0, +// 0,0,2,2,2,2,0,0, +// 0,2,2,2,2,2,2,0, +// 2,0,2,2,2,2,0,2, +// 0,0,2,0,0,2,0,0, +// 0,0,2,0,0,2,0,0, +// ] +// } +// } +// +// pub fn cat() -> Image { +// Image { +// name: "cat".to_string(), +// pixels: vec![ +// 0,0,0,0,0,0,0,0, +// 0,0,0,0,0,0,0,0, +// 0,2,0,2,0,0,0,2, +// 0,2,2,2,0,0,0,2, +// 0,2,2,2,0,0,2,0, +// 0,2,2,2,2,2,0,0, +// 0,0,2,2,2,2,0,0, +// 0,0,2,0,0,2,0,0, +// ] +// } +// } +// } pub(crate) mod palette { use crate::{Palette, Colour, IntermediatePalette}; diff --git a/src/palette.rs b/src/palette.rs index 2cf3488..3bc974f 100644 --- a/src/palette.rs +++ b/src/palette.rs @@ -104,13 +104,13 @@ struct IntermediatePalettes { palette: Vec, } -impl IntermediatePalettes { - pub fn from_dir() -> Self { - Self { - palette: vec![] - } - } -} +// impl IntermediatePalettes { +// pub fn from_dir() -> Self { +// Self { +// palette: vec![] +// } +// } +// } #[cfg(test)] mod test { diff --git a/src/room.rs b/src/room.rs index 27a8ee2..d93db5b 100644 --- a/src/room.rs +++ b/src/room.rs @@ -1,17 +1,17 @@ -use std::collections::HashMap; +// use std::collections::HashMap; use serde_derive::{Serialize, Deserialize}; -use crate::Position; +// use crate::Position; -pub struct Room { - pub name: String, - pub width: u8, - pub height: u8, - /// thing names and their positions - pub background: HashMap, - pub foreground: HashMap, -} +// pub struct Room { +// pub name: String, +// pub width: u8, +// pub height: u8, +// /// thing names and their positions +// pub background: HashMap, +// pub foreground: HashMap, +// } /// todo &str? #[derive(Serialize, Deserialize)] @@ -21,22 +21,22 @@ struct IntermediateRoom { foreground: Vec, } -impl IntermediateRoom { - fn from(room: Room) -> IntermediateRoom { - fn hashmap_to_vec(hash: HashMap, width: u8, height: u8) -> Vec { - let mut thing_ids = Vec::new(); - - while thing_ids.len() < (width * height) as usize { - thing_ids.push(String::new()); - } - - thing_ids - } - - IntermediateRoom { - name: "".to_string(), - background: vec![], - foreground: vec![] - } - } -} +// impl IntermediateRoom { +// fn from(_room: Room) -> IntermediateRoom { +// fn hashmap_to_vec(_hash: HashMap, width: u8, height: u8) -> Vec { +// let mut thing_ids = Vec::new(); +// +// while thing_ids.len() < (width * height) as usize { +// thing_ids.push(String::new()); +// } +// +// thing_ids +// } +// +// IntermediateRoom { +// name: "".to_string(), +// background: vec![], +// foreground: vec![] +// } +// } +// }