comment out some currently-unused stuff
This commit is contained in:
parent
4fb8ddf7ea
commit
a8792744e1
74
src/image.rs
74
src/image.rs
|
@ -7,16 +7,16 @@ pub struct Image {
|
|||
pub pixels: Vec<u8>,
|
||||
}
|
||||
|
||||
impl Image {
|
||||
fn from(intermediate: IntermediateImage) -> Image {
|
||||
Image {
|
||||
name: intermediate.name.to_owned(),
|
||||
pixels: intermediate.pixels.split_whitespace().collect::<String>().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::<String>().chars().map(
|
||||
// |char|char as u8
|
||||
// ).collect()
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
/// for toml purposes
|
||||
#[derive(Debug, Serialize, Deserialize)]
|
||||
|
@ -25,13 +25,13 @@ pub(crate) struct IntermediateImages {
|
|||
image: Vec<IntermediateImage>,
|
||||
}
|
||||
|
||||
impl IntermediateImages {
|
||||
fn to_images(&self) -> Vec<Image> {
|
||||
self.image.iter().map(|intermediate|
|
||||
Image::from(intermediate.clone())
|
||||
).collect()
|
||||
}
|
||||
}
|
||||
// impl IntermediateImages {
|
||||
// fn to_images(&self) -> Vec<Image> {
|
||||
// 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 {
|
||||
|
|
134
src/mock.rs
134
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};
|
||||
|
|
|
@ -104,13 +104,13 @@ struct IntermediatePalettes {
|
|||
palette: Vec<IntermediatePalette>,
|
||||
}
|
||||
|
||||
impl IntermediatePalettes {
|
||||
pub fn from_dir() -> Self {
|
||||
Self {
|
||||
palette: vec![]
|
||||
}
|
||||
}
|
||||
}
|
||||
// impl IntermediatePalettes {
|
||||
// pub fn from_dir() -> Self {
|
||||
// Self {
|
||||
// palette: vec![]
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
|
|
58
src/room.rs
58
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<Position, String>,
|
||||
pub foreground: HashMap<Position, String>,
|
||||
}
|
||||
// pub struct Room {
|
||||
// pub name: String,
|
||||
// pub width: u8,
|
||||
// pub height: u8,
|
||||
// /// thing names and their positions
|
||||
// pub background: HashMap<Position, String>,
|
||||
// pub foreground: HashMap<Position, String>,
|
||||
// }
|
||||
|
||||
/// todo &str?
|
||||
#[derive(Serialize, Deserialize)]
|
||||
|
@ -21,22 +21,22 @@ struct IntermediateRoom {
|
|||
foreground: Vec<String>,
|
||||
}
|
||||
|
||||
impl IntermediateRoom {
|
||||
fn from(room: Room) -> IntermediateRoom {
|
||||
fn hashmap_to_vec(hash: HashMap<Position, String>, width: u8, height: u8) -> Vec<String> {
|
||||
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<Position, String>, width: u8, height: u8) -> Vec<String> {
|
||||
// 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![]
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
|
Loading…
Reference in New Issue