comment out some currently-unused stuff

This commit is contained in:
Max Bradbury 2021-05-16 17:04:46 +01:00
parent 4fb8ddf7ea
commit a8792744e1
4 changed files with 140 additions and 140 deletions

View File

@ -7,16 +7,16 @@ pub struct Image {
pub pixels: Vec<u8>, pub pixels: Vec<u8>,
} }
impl Image { // impl Image {
fn from(intermediate: IntermediateImage) -> Image { // fn from(intermediate: IntermediateImage) -> Image {
Image { // Image {
name: intermediate.name.to_owned(), // name: intermediate.name.to_owned(),
pixels: intermediate.pixels.split_whitespace().collect::<String>().chars().map( // pixels: intermediate.pixels.split_whitespace().collect::<String>().chars().map(
|char|char as u8 // |char|char as u8
).collect() // ).collect()
} // }
} // }
} // }
/// for toml purposes /// for toml purposes
#[derive(Debug, Serialize, Deserialize)] #[derive(Debug, Serialize, Deserialize)]
@ -25,13 +25,13 @@ pub(crate) struct IntermediateImages {
image: Vec<IntermediateImage>, image: Vec<IntermediateImage>,
} }
impl IntermediateImages { // impl IntermediateImages {
fn to_images(&self) -> Vec<Image> { // fn to_images(&self) -> Vec<Image> {
self.image.iter().map(|intermediate| // self.image.iter().map(|intermediate|
Image::from(intermediate.clone()) // Image::from(intermediate.clone())
).collect() // ).collect()
} // }
} // }
#[derive(Clone, Debug, Serialize, Deserialize)] #[derive(Clone, Debug, Serialize, Deserialize)]
pub(crate) struct IntermediateImage { pub(crate) struct IntermediateImage {
@ -39,26 +39,26 @@ pub(crate) struct IntermediateImage {
pixels: String, pixels: String,
} }
impl IntermediateImage { // impl IntermediateImage {
// todo refactor // // todo refactor
fn from(image: Image) -> IntermediateImage { // fn from(image: Image) -> IntermediateImage {
let mut string = "\n".to_string(); // let mut string = "\n".to_string();
//
let sqrt = (image.pixels.len() as f64).sqrt() as usize; // let sqrt = (image.pixels.len() as f64).sqrt() as usize;
for line in image.pixels.chunks(sqrt) { // for line in image.pixels.chunks(sqrt) {
for pixel in line { // for pixel in line {
string.push_str(&format!("{}", *pixel)); // string.push_str(&format!("{}", *pixel));
} // }
string.push('\n'); // string.push('\n');
} // }
//
IntermediateImage { // IntermediateImage {
name: image.name.to_owned(), // name: image.name.to_owned(),
/// todo wtf? I guess this crate doesn't handle multiline strings correctly // /// todo wtf? I guess this crate doesn't handle multiline strings correctly
pixels: format!("\"\"{}\"\"", string), // pixels: format!("\"\"{}\"\"", string),
} // }
} // }
} // }
#[cfg(test)] #[cfg(test)]
mod test { mod test {

View File

@ -1,70 +1,70 @@
pub(crate) mod image { // pub(crate) mod image {
use crate::image::Image; // use crate::image::Image;
//
pub fn bg() -> Image { // pub fn bg() -> Image {
Image { // Image {
name: "bg".to_string(), // name: "bg".to_string(),
pixels: vec![ // 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,
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 { // pub fn block() -> Image {
Image { // Image {
name: "block".to_string(), // name: "block".to_string(),
pixels: vec![ // pixels: vec![
1,1,1,1,1,1,1,1, // 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,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,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,0,0,0,0,0,0,1, // 1,0,0,0,0,0,0,1,
1,1,1,1,1,1,1,1, // 1,1,1,1,1,1,1,1,
] // ]
} // }
} // }
//
pub fn avatar() -> Image { // pub fn avatar() -> Image {
Image { // Image {
name: "avatar".to_string(), // name: "avatar".to_string(),
pixels: vec![ // 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,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,0,2,2,2,2,0,0,
0,2,2,2,2,2,2,0, // 0,2,2,2,2,2,2,0,
2,0,2,2,2,2,0,2, // 2,0,2,2,2,2,0,2,
0,0,2,0,0,2,0,0, // 0,0,2,0,0,2,0,0,
0,0,2,0,0,2,0,0, // 0,0,2,0,0,2,0,0,
] // ]
} // }
} // }
//
pub fn cat() -> Image { // pub fn cat() -> Image {
Image { // Image {
name: "cat".to_string(), // name: "cat".to_string(),
pixels: vec![ // 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,2,0,2,0,0,0,2, // 0,2,0,2,0,0,0,2,
0,2,2,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,0,0,2,0,
0,2,2,2,2,2,0,0, // 0,2,2,2,2,2,0,0,
0,0,2,2,2,2,0,0, // 0,0,2,2,2,2,0,0,
0,0,2,0,0,2,0,0, // 0,0,2,0,0,2,0,0,
] // ]
} // }
} // }
} // }
pub(crate) mod palette { pub(crate) mod palette {
use crate::{Palette, Colour, IntermediatePalette}; use crate::{Palette, Colour, IntermediatePalette};

View File

@ -104,13 +104,13 @@ struct IntermediatePalettes {
palette: Vec<IntermediatePalette>, palette: Vec<IntermediatePalette>,
} }
impl IntermediatePalettes { // impl IntermediatePalettes {
pub fn from_dir() -> Self { // pub fn from_dir() -> Self {
Self { // Self {
palette: vec![] // palette: vec![]
} // }
} // }
} // }
#[cfg(test)] #[cfg(test)]
mod test { mod test {

View File

@ -1,17 +1,17 @@
use std::collections::HashMap; // use std::collections::HashMap;
use serde_derive::{Serialize, Deserialize}; use serde_derive::{Serialize, Deserialize};
use crate::Position; // use crate::Position;
pub struct Room { // pub struct Room {
pub name: String, // pub name: String,
pub width: u8, // pub width: u8,
pub height: u8, // pub height: u8,
/// thing names and their positions // /// thing names and their positions
pub background: HashMap<Position, String>, // pub background: HashMap<Position, String>,
pub foreground: HashMap<Position, String>, // pub foreground: HashMap<Position, String>,
} // }
/// todo &str? /// todo &str?
#[derive(Serialize, Deserialize)] #[derive(Serialize, Deserialize)]
@ -21,22 +21,22 @@ struct IntermediateRoom {
foreground: Vec<String>, foreground: Vec<String>,
} }
impl IntermediateRoom { // impl IntermediateRoom {
fn from(room: Room) -> IntermediateRoom { // fn from(_room: Room) -> IntermediateRoom {
fn hashmap_to_vec(hash: HashMap<Position, String>, width: u8, height: u8) -> Vec<String> { // fn hashmap_to_vec(_hash: HashMap<Position, String>, width: u8, height: u8) -> Vec<String> {
let mut thing_ids = Vec::new(); // let mut thing_ids = Vec::new();
//
while thing_ids.len() < (width * height) as usize { // while thing_ids.len() < (width * height) as usize {
thing_ids.push(String::new()); // thing_ids.push(String::new());
} // }
//
thing_ids // thing_ids
} // }
//
IntermediateRoom { // IntermediateRoom {
name: "".to_string(), // name: "".to_string(),
background: vec![], // background: vec![],
foreground: vec![] // foreground: vec![]
} // }
} // }
} // }