gdritter repos palladio / 26c5dae
make it work again? Getty Ritter 3 years ago
6 changed file(s) with 43 addition(s) and 27 deletion(s). Collapse all Expand all
22 name = "palladio"
33 version = "0.1.0"
44 authors = ["Getty Ritter <palladio@infinitenegativeutility.com>"]
5 edition = "2018"
6
7 [lib]
8
9 [[bin]]
10 name = "palladio"
11 path = "src/main.rs"
12
13 [[bin]]
14 name = "run-palladio"
15 path = "src/run.rs"
516
617 [dependencies]
718 gtk = { version = "0.2", features = ["v3_22"] }
11 extern crate clap;
22
3 use constants;
3 use crate::constants;
44
55 pub struct Cfg {
66 pub file_path: Option<String>,
1 extern crate cairo;
2 extern crate gdk;
3 extern crate gtk;
4 extern crate rand;
5 extern crate failure;
6 extern crate image;
7 extern crate zip;
8 extern crate serde;
9 #[macro_use] extern crate serde_derive;
10 extern crate serde_json;
1 use palladio::{cfg, model, view};
112
12 pub mod cfg;
13 pub mod constants;
14 pub mod grammar;
15 pub mod model;
16 pub mod strings;
17 pub mod view;
3 // pub mod cfg;
4 // pub mod constants;
5 // pub mod grammar;
6 // pub mod model;
7 // pub mod strings;
8 // pub mod view;
189
1910 fn main() {
2011 let cfg = cfg::palladio_args();
11 use failure::Error;
22 use image;
33 use serde_json;
4 use std::io::{Read, Write, Seek};
4 use std::io::{Read, Seek, Write};
55 use zip::{ZipArchive, ZipWriter};
6
7 use crate::constants;
68
79 /// This value represents both the current document in-memory as well
810 /// as the entirety of the values that we will want to both save and
1012 pub struct Document {
1113 pub tilesheet: image::DynamicImage,
1214 pub metadata: Metadata,
13 pub rules: (),
15 pub rules: Vec<RuleSpec>,
16 }
17
18 #[derive(Debug, PartialEq, Eq, Serialize, Deserialize)]
19 pub struct RuleSpec {
20 pub rule_name: String,
21 pub lhs: Vec<((u16, u16), (u16, u16))>,
22 pub rhs: Vec<((u16, u16), (u16, u16))>,
1423 }
1524
1625 /// This should be renamed probably, but it's the configuration-level
4150 let file = archive.by_name("rules.json")?;
4251 serde_json::from_reader(file)?
4352 };
44 Ok(Document{ tilesheet, metadata, rules })
53 Ok(Document {
54 tilesheet,
55 metadata,
56 rules,
57 })
4558 }
4659
4760 /// Attempt to write a `Document` from anything which implements
5265
5366 let mut zip = ZipWriter::new(w);
5467 zip.start_file("tilesheet.png", FileOptions::default())?;
55 self.tilesheet.write_to(&mut zip, image::ImageOutputFormat::PNG)?;
68 self.tilesheet
69 .write_to(&mut zip, image::ImageOutputFormat::PNG)?;
5670
5771 zip.start_file("metadata.json", FileOptions::default())?;
5872 serde_json::to_writer(&mut zip, &self.metadata)?;
6478 writeln!(
6579 &mut zip,
6680 "Created by {} v{}",
67 ::constants::PROGRAM_NAME,
68 ::constants::PROGRAM_VERSION,
81 constants::PROGRAM_NAME,
82 constants::PROGRAM_VERSION,
6983 )?;
7084
7185 zip.finish()?;
8296 tile_height: 16,
8397 config_loop_forever: false,
8498 },
85 rules: (),
99 rules: Vec::new(),
86100 }
87101 }
88102 }
11 pub mod document;
22 pub use self::document::*;
33 use failure::Error;
4 use cfg;
4 use crate::cfg;
55
66 pub struct State {
77 pub document: Document,
1717 };
1818 use std::process;
1919
20 use constants;
21 use strings;
20 use crate::constants;
21 use crate::strings;
2222 use self::canvas::GridCanvas;
2323 use self::picker::Picker;
2424