From d52bc7b646a0274c231e1d6182a5073246ab7b33 Mon Sep 17 00:00:00 2001 From: Filipe Rodrigues Date: Sun, 26 Apr 2020 09:32:44 +0100 Subject: [PATCH 01/12] Initial Commit --- .gitignore | 3 + Cargo.lock | 539 +++++++++++++++++++++++++++++++++++++++++++++++++++ Cargo.toml | 35 ++++ src/cli.rs | 72 +++++++ src/main.rs | 127 ++++++++++++ src/panic.rs | 31 +++ 6 files changed, 807 insertions(+) create mode 100644 .gitignore create mode 100644 Cargo.lock create mode 100644 Cargo.toml create mode 100644 src/cli.rs create mode 100644 src/main.rs create mode 100644 src/panic.rs diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..96d8802 --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +/target +.vscode +resources/ \ No newline at end of file diff --git a/Cargo.lock b/Cargo.lock new file mode 100644 index 0000000..83dc176 --- /dev/null +++ b/Cargo.lock @@ -0,0 +1,539 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +[[package]] +name = "ansi_term" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ee49baf6cb617b853aa8d93bf420db2383fab46d314482ca2803b40d5fde979b" +dependencies = [ + "winapi", +] + +[[package]] +name = "arrayref" +version = "0.3.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a4c527152e37cf757a3f78aae5a06fbeefdb07ccc535c980a3208ee3060dd544" + +[[package]] +name = "arrayvec" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cff77d8686867eceff3105329d4698d96c2391c176d5d03adc90c7389162b5b8" + +[[package]] +name = "ascii" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbf56136a5198c7b01a49e3afcbef6cf84597273d298f54432926024107b0109" +dependencies = [ + "serde", +] + +[[package]] +name = "atty" +version = "0.2.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8" +dependencies = [ + "hermit-abi", + "libc", + "winapi", +] + +[[package]] +name = "autocfg" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8aac770f1885fd7e387acedd76065302551364496e46b3dd00860b2f8359b9d" + +[[package]] +name = "base64" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b41b7ea54a0c9d92199de89e20e58d49f02f8e699814ef3fdf266f6f748d15c7" + +[[package]] +name = "bitflags" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693" + +[[package]] +name = "blake2b_simd" +version = "0.5.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d8fb2d74254a3a0b5cac33ac9f8ed0e44aa50378d9dbb2e5d83bd21ed1dc2c8a" +dependencies = [ + "arrayref", + "arrayvec", + "constant_time_eq", +] + +[[package]] +name = "byteorder" +version = "1.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "08c48aae112d48ed9f069b33538ea9e3e90aa263cfa3d1c24309612b1f7472de" + +[[package]] +name = "cfg-if" +version = "0.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822" + +[[package]] +name = "chrono" +version = "0.4.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "80094f509cf8b5ae86a4966a39b3ff66cd7e2a3e594accec3743ff3fabeab5b2" +dependencies = [ + "num-integer", + "num-traits", + "time", +] + +[[package]] +name = "clap" +version = "2.33.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5067f5bb2d80ef5d68b4c87db81601f0b75bca627bc2ef76b141d7b846a3c6d9" +dependencies = [ + "ansi_term", + "atty", + "bitflags", + "strsim", + "textwrap", + "unicode-width", + "vec_map", +] + +[[package]] +name = "constant_time_eq" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "245097e9a4535ee1e3e3931fcfcd55a796a44c643e8596ff6566d68f09b87bbc" + +[[package]] +name = "crossbeam-utils" +version = "0.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c3c7c73a2d1e9fc0886a08b93e98eb643461230d5f1925e4036204d5f2e261a8" +dependencies = [ + "autocfg", + "cfg-if", + "lazy_static", +] + +[[package]] +name = "dcb" +version = "0.1.0" +dependencies = [ + "arrayref", + "ascii", + "byteorder", + "derive_more", + "err-impl", + "log", + "serde", +] + +[[package]] +name = "dcb-extract" +version = "0.1.0" +dependencies = [ + "clap", + "dcb", + "derive_more", + "err-backtrace", + "err-ext", + "err-panic", + "log", + "serde_yaml", + "simplelog", + "string-err", +] + +[[package]] +name = "derive_more" +version = "0.99.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2323f3f47db9a0e77ce7a300605d8d2098597fc451ed1a97bb1f6411bb550a7" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "dirs" +version = "2.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "13aea89a5c93364a98e9b37b2fa237effbb694d5cfe01c5b70941f7eb087d5e3" +dependencies = [ + "cfg-if", + "dirs-sys", +] + +[[package]] +name = "dirs-sys" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "afa0b23de8fd801745c471deffa6e12d248f962c9fd4b4c33787b055599bde7b" +dependencies = [ + "cfg-if", + "libc", + "redox_users", + "winapi", +] + +[[package]] +name = "dtoa" +version = "0.4.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4358a9e11b9a09cf52383b451b49a169e8d797b68aa02301ff586d70d9661ea3" + +[[package]] +name = "err-backtrace" +version = "0.1.0" + +[[package]] +name = "err-ext" +version = "0.1.0" + +[[package]] +name = "err-impl" +version = "0.1.0" +dependencies = [ + "proc-macro-error", + "proc-macro2", + "quote", + "syn", + "synstructure", +] + +[[package]] +name = "err-panic" +version = "0.1.0" +dependencies = [ + "string-err", +] + +[[package]] +name = "getrandom" +version = "0.1.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7abc8dd8451921606d809ba32e95b6111925cd2906060d2dcc29c070220503eb" +dependencies = [ + "cfg-if", + "libc", + "wasi", +] + +[[package]] +name = "hermit-abi" +version = "0.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "725cf19794cf90aa94e65050cb4191ff5d8fa87a498383774c47b332e3af952e" +dependencies = [ + "libc", +] + +[[package]] +name = "lazy_static" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" + +[[package]] +name = "libc" +version = "0.2.68" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dea0c0405123bba743ee3f91f49b1c7cfb684eef0da0a50110f758ccf24cdff0" + +[[package]] +name = "linked-hash-map" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ae91b68aebc4ddb91978b11a1b02ddd8602a05ec19002801c5666000e05e0f83" + +[[package]] +name = "log" +version = "0.4.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "14b6052be84e6b71ab17edffc2eeabf5c2c3ae1fdb464aae35ac50c67a44e1f7" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "num-integer" +version = "0.1.42" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f6ea62e9d81a77cd3ee9a2a5b9b609447857f3d358704331e4ef39eb247fcba" +dependencies = [ + "autocfg", + "num-traits", +] + +[[package]] +name = "num-traits" +version = "0.2.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c62be47e61d1842b9170f0fdeec8eba98e60e90e5446449a0545e5152acd7096" +dependencies = [ + "autocfg", +] + +[[package]] +name = "proc-macro-error" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "98e9e4b82e0ef281812565ea4751049f1bdcdfccda7d3f459f2e138a40c08678" +dependencies = [ + "proc-macro-error-attr", + "proc-macro2", + "quote", + "syn", + "version_check", +] + +[[package]] +name = "proc-macro-error-attr" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4f5444ead4e9935abd7f27dc51f7e852a0569ac888096d5ec2499470794e2e53" +dependencies = [ + "proc-macro2", + "quote", + "syn", + "syn-mid", + "version_check", +] + +[[package]] +name = "proc-macro2" +version = "1.0.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "df246d292ff63439fea9bc8c0a270bed0e390d5ebd4db4ba15aba81111b5abe3" +dependencies = [ + "unicode-xid", +] + +[[package]] +name = "quote" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2bdc6c187c65bca4260c9011c9e3132efe4909da44726bad24cf7572ae338d7f" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "redox_syscall" +version = "0.1.56" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2439c63f3f6139d1b57529d16bc3b8bb855230c8efcc5d3a896c8bea7c3b1e84" + +[[package]] +name = "redox_users" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09b23093265f8d200fa7b4c2c76297f47e681c655f6f1285a8780d6a022f7431" +dependencies = [ + "getrandom", + "redox_syscall", + "rust-argon2", +] + +[[package]] +name = "rust-argon2" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2bc8af4bda8e1ff4932523b94d3dd20ee30a87232323eda55903ffd71d2fb017" +dependencies = [ + "base64", + "blake2b_simd", + "constant_time_eq", + "crossbeam-utils", +] + +[[package]] +name = "serde" +version = "1.0.106" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "36df6ac6412072f67cf767ebbde4133a5b2e88e76dc6187fa7104cd16f783399" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_derive" +version = "1.0.106" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9e549e3abf4fb8621bd1609f11dfc9f5e50320802273b12f3811a67e6716ea6c" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "serde_yaml" +version = "0.8.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "691b17f19fc1ec9d94ec0b5864859290dff279dbd7b03f017afda54eb36c3c35" +dependencies = [ + "dtoa", + "linked-hash-map", + "serde", + "yaml-rust", +] + +[[package]] +name = "simplelog" +version = "0.7.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bcacac97349a890d437921dfb23cbec52ab5b4752551cb637df2721371acd467" +dependencies = [ + "chrono", + "log", + "term", +] + +[[package]] +name = "string-err" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5eb6c5ccd2a653178945caa695062379fa26812f1e63584111ac8fff988358d1" + +[[package]] +name = "strsim" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a" + +[[package]] +name = "syn" +version = "1.0.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0df0eb663f387145cab623dea85b09c2c5b4b0aef44e945d928e682fce71bb03" +dependencies = [ + "proc-macro2", + "quote", + "unicode-xid", +] + +[[package]] +name = "syn-mid" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7be3539f6c128a931cf19dcee741c1af532c7fd387baa739c03dd2e96479338a" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "synstructure" +version = "0.12.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "67656ea1dc1b41b1451851562ea232ec2e5a80242139f7e679ceccfb5d61f545" +dependencies = [ + "proc-macro2", + "quote", + "syn", + "unicode-xid", +] + +[[package]] +name = "term" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c0863a3345e70f61d613eab32ee046ccd1bcc5f9105fe402c61fcd0c13eeb8b5" +dependencies = [ + "dirs", + "winapi", +] + +[[package]] +name = "textwrap" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d326610f408c7a4eb6f51c37c330e496b08506c9457c9d34287ecc38809fb060" +dependencies = [ + "unicode-width", +] + +[[package]] +name = "time" +version = "0.1.42" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "db8dcfca086c1143c9270ac42a2bbd8a7ee477b78ac8e45b19abfb0cbede4b6f" +dependencies = [ + "libc", + "redox_syscall", + "winapi", +] + +[[package]] +name = "unicode-width" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "caaa9d531767d1ff2150b9332433f32a24622147e5ebb1f26409d5da67afd479" + +[[package]] +name = "unicode-xid" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "826e7639553986605ec5979c7dd957c7895e93eabed50ab2ffa7f6128a75097c" + +[[package]] +name = "vec_map" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "05c78687fb1a80548ae3250346c3db86a80a7cdd77bda190189f2d0a0987c81a" + +[[package]] +name = "version_check" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "078775d0255232fb988e6fccf26ddc9d1ac274299aaedcedce21c6f72cc533ce" + +[[package]] +name = "wasi" +version = "0.9.0+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519" + +[[package]] +name = "winapi" +version = "0.3.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8093091eeb260906a183e6ae1abdba2ef5ef2257a21801128899c3fc699229c6" +dependencies = [ + "winapi-i686-pc-windows-gnu", + "winapi-x86_64-pc-windows-gnu", +] + +[[package]] +name = "winapi-i686-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" + +[[package]] +name = "winapi-x86_64-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" + +[[package]] +name = "yaml-rust" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "65923dd1784f44da1d2c3dbbc5e822045628c590ba72123e1c73d3c230c4434d" +dependencies = [ + "linked-hash-map", +] diff --git a/Cargo.toml b/Cargo.toml new file mode 100644 index 0000000..da7ffa3 --- /dev/null +++ b/Cargo.toml @@ -0,0 +1,35 @@ +[package] +name = "dcb-extract" +version = "0.1.0" +authors = ["Filipe Rodrigues "] +edition = "2018" + +[dependencies] + +# Dcb +dcb = { path = "../dcb" } + +# Cmd +clap = "2.33" + +# Logging +log = "0.4" +simplelog = "0.7" + +# Error handling +string-err = "0.1" +err-backtrace = { path = "../err-backtrace" } +err-panic = { path = "../err-panic", features = ["string-err-ext"] } +err-ext = { path = "../err-ext" } +derive_more = "0.99" + + +# Serde +serde_yaml = "0.8" + +# Build dependencies in release mode +[profile.dev.package."*"] +opt-level = 2 +[profile.dev.package.dcb] # Except dcb +opt-level = 0 + diff --git a/src/cli.rs b/src/cli.rs new file mode 100644 index 0000000..24b38b4 --- /dev/null +++ b/src/cli.rs @@ -0,0 +1,72 @@ +//! Cli manager for the extractor + +// Filesystem +use std::path::{Path, PathBuf}; + +// Clap +use clap::{Arg as ClapArg, App as ClapApp}; + +// Errors +use err_panic::ErrorExtPanic; + + +/// All of the data received form the command line +/// +/// # Public fields +/// All fields are public as this type has no invariants. +pub struct CliData +{ + /// The input filename + pub input_filename: PathBuf, + + /// The output directory + pub output_dir: PathBuf, +} + +impl CliData +{ + /// Constructs all of the cli data given and returns it + pub fn new() -> Self + { + // Get all matches from cli + let matches = ClapApp::new("Dcb Extractor") + .version("0.0") + .author("Filipe [...] <[...]@gmail.com>") + .about("Extracts all data from a Digimon Digital Card Battle `.bin` game file") + .arg( ClapArg::with_name("INPUT") + .help("Sets the input game file to use") + .required(true) + .index(1) + ) + .arg( ClapArg::with_name("OUTPUT") + .help("Sets the output directory to use") + .short("o") + .long("output") + .takes_value(true) + .required(false) + ) + .get_matches(); + + // Get the input filename + // Note: required + let input_filename = matches.value_of("INPUT") + .map(Path::new) + .map(Path::to_path_buf) + .panic_msg("Unable to get required argument `INPUT`"); + + // Try to get the output + let output_dir = match matches.value_of("OUTPUT") { + Some(output) => PathBuf::from(output), + None => input_filename + .parent() + .unwrap_or_else(|| Path::new(".")) + .to_path_buf() + }; + + // Return the cli data + Self { + input_filename, + output_dir, + } + } +} diff --git a/src/main.rs b/src/main.rs new file mode 100644 index 0000000..b972b6c --- /dev/null +++ b/src/main.rs @@ -0,0 +1,127 @@ +//! Data extractor +//! +//! # Details +//! Extracts data from the game file to several other files, that can be +//! edited and then used by `Patcher` to modify the game file. +//! +//! # Syntax +//! The executable may be called as `./dcb-extractor {-o }` +//! +//! Use the command `./dcb-extractor --help` for more information. +//! +//! # Data extracted +//! Currently only the following is extracted: +//! - Card table +//! - Deck table (partial) + +// Features +#![feature( + box_syntax, + backtrace, + panic_info_message, +)] + +// Lints +#![warn( + clippy::restriction, + clippy::pedantic, + clippy::nursery, +)] +#![allow( + clippy::implicit_return, // We prefer implicit returns where possible + clippy::module_name_repetitions, // This happens often due to separating things into modules finely + clippy::wildcard_enum_match_arm, // We only use wildcards when we truly only care about some variants + clippy::result_expect_used, + clippy::option_expect_used, // We use expect when there is no alternative. + clippy::used_underscore_binding, // Useful for macros and such +)] + +// Modules +mod cli; +mod panic; + +// Exports +use cli::CliData; + +// Dcb +use dcb::{ + GameFile, + game::{ + card::Table as CardTable + }, + //game::deck::Table as DeckTable, +}; + +// Errors +use err_ext::ErrorExt; +use err_panic::ErrorExtPanic; +use err_backtrace::ErrBacktraceExt; + +fn main() { + // Initialize the logger and set the panic handler + init_logger(); + std::panic::set_hook(box panic::log_handler); + + // Get all data from cli + let CliData{ input_filename, output_dir } = CliData::new(); + + let cur_working_dir = std::env::current_dir().expect("No cwd"); + log::info!("cwd: {}", cur_working_dir.display()); + + // Open the game file + let input_file = std::fs::File::open(&input_filename) + .panic_err_msg("Unable to open input file"); + let mut game_file = GameFile::from_reader(input_file) + .panic_err_msg("Unable to parse input file as dcb"); + + // Get the cards table + let cards_table = CardTable::deserialize(&mut game_file) + .panic_err_msg("Unable to create cards table"); + let cards_table_yaml = serde_yaml::to_string(&cards_table) + .panic_err_msg("Unable to serialize cards table"); + log::info!("Extracted {} cards", cards_table.card_count()); + + /* + // Get the decks table + let decks_table = DeckTable::new(&mut game_file) + .panic_err_msg("Unable to create decks table"); + let decks_table_yaml = serde_yaml::to_string(&decks_table) + .panic_err_msg("Unable to serialize decks table"); + log::info!("Extracted {} decks", "[Unknown]"); + */ + + // And output everything to the files + let cards_table_output_filename = output_dir.join("cards.yaml"); + std::fs::write(&cards_table_output_filename, cards_table_yaml) + .map_err(|err| log::warn!("Unable to write output file {}:\n{}", cards_table_output_filename.display(), err.err_backtrace() )) + .ignore(); + /* + let decks_table_output_filename = output_dir.join("decks.yaml"); + std::fs::write(output_dir.join("decks.yaml"), decks_table_yaml) + .map_err(|err| log::warn!("Unable to write output file {}:\n{}", decks_table_output_filename.display(), err.err_backtrace() )) + .ignore(); + */ +} + +/// Initializes the global logger +fn init_logger() { + use simplelog::{CombinedLogger, SharedLogger, TermLogger, WriteLogger, Config, TerminalMode}; + use log::LevelFilter::{Info, Trace}; + use std::convert::identity; + /// The type of logger required to pass to `CombinedLogger::init` + type BoxedLogger = Box; + + // All loggers to try and initialize + let loggers: Vec< Option > = vec![ + TermLogger ::new(Info, Config::default(), TerminalMode::Mixed) + .map(|logger| BoxedLogger::from(logger)), + std::fs::File::create("latest.log").ok() + .map(|file| WriteLogger::new(Trace, Config::default(), file)) + .map(|logger| BoxedLogger::from(logger)) + ]; + + // Filter all logger that actually work and initialize them + CombinedLogger::init( + loggers.into_iter().filter_map(identity).collect() + ).ignore_with_err(|_| log::warn!("Logger was already initialized at the start of the program")); +} diff --git a/src/panic.rs b/src/panic.rs new file mode 100644 index 0000000..595c8ef --- /dev/null +++ b/src/panic.rs @@ -0,0 +1,31 @@ +//! Panic handlers for this application + +// Std +use std::{ + error::Error, + backtrace::{Backtrace, BacktraceStatus}, +}; +// Error backtrace +use err_backtrace::ErrBacktraceExt; + +/// Panic handler based on logging to the current initialization +pub fn log_handler(info: &std::panic::PanicInfo) { + // Log that this thread has panicked + log::error!("Thread \"{}\" panicked", std::thread::current().name().unwrap_or("[Unknown]")); + + // Log any message that came with the panic + log::info!("Panic message: {}", info.message().unwrap_or( &format_args!("None") )); + + // Print an error backtrace if we found any + if let Some(err) = info.payload().downcast_ref::< Box >() { + log::info!("Error backtrace:\n{}", err.err_backtrace()); + } + + // And print a backtrace of where this panic occured. + let backtrace = Backtrace::force_capture(); + if backtrace.status() == BacktraceStatus::Captured { + log::info!("Backtrace:\n{}", backtrace); + } else { + log::info!("Unable to get backtrace: {}", backtrace); + } +} From 3e10f0668afdf5f8462d560c2a8038672d8d1e40 Mon Sep 17 00:00:00 2001 From: Filipe Rodrigues Date: Fri, 1 May 2020 07:02:23 +0100 Subject: [PATCH 02/12] Removed extraction of the Deck table. --- src/main.rs | 24 +++--------------------- 1 file changed, 3 insertions(+), 21 deletions(-) diff --git a/src/main.rs b/src/main.rs index b972b6c..3253d36 100644 --- a/src/main.rs +++ b/src/main.rs @@ -46,14 +46,11 @@ use cli::CliData; // Dcb use dcb::{ GameFile, - game::{ - card::Table as CardTable - }, - //game::deck::Table as DeckTable, + game::card::Table as CardTable, }; // Errors -use err_ext::ErrorExt; +use err_ext::ResultExt; use err_panic::ErrorExtPanic; use err_backtrace::ErrBacktraceExt; @@ -63,7 +60,7 @@ fn main() { std::panic::set_hook(box panic::log_handler); // Get all data from cli - let CliData{ input_filename, output_dir } = CliData::new(); + let CliData { input_filename, output_dir } = CliData::new(); let cur_working_dir = std::env::current_dir().expect("No cwd"); log::info!("cwd: {}", cur_working_dir.display()); @@ -81,26 +78,11 @@ fn main() { .panic_err_msg("Unable to serialize cards table"); log::info!("Extracted {} cards", cards_table.card_count()); - /* - // Get the decks table - let decks_table = DeckTable::new(&mut game_file) - .panic_err_msg("Unable to create decks table"); - let decks_table_yaml = serde_yaml::to_string(&decks_table) - .panic_err_msg("Unable to serialize decks table"); - log::info!("Extracted {} decks", "[Unknown]"); - */ - // And output everything to the files let cards_table_output_filename = output_dir.join("cards.yaml"); std::fs::write(&cards_table_output_filename, cards_table_yaml) .map_err(|err| log::warn!("Unable to write output file {}:\n{}", cards_table_output_filename.display(), err.err_backtrace() )) .ignore(); - /* - let decks_table_output_filename = output_dir.join("decks.yaml"); - std::fs::write(output_dir.join("decks.yaml"), decks_table_yaml) - .map_err(|err| log::warn!("Unable to write output file {}:\n{}", decks_table_output_filename.display(), err.err_backtrace() )) - .ignore(); - */ } /// Initializes the global logger From 8910ef9d544a1a45a130a9547455abf5fa338f78 Mon Sep 17 00:00:00 2001 From: Filipe Rodrigues Date: Fri, 1 May 2020 07:05:28 +0100 Subject: [PATCH 03/12] Removed getting current working directory. --- src/main.rs | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/main.rs b/src/main.rs index 3253d36..6a4e664 100644 --- a/src/main.rs +++ b/src/main.rs @@ -62,9 +62,6 @@ fn main() { // Get all data from cli let CliData { input_filename, output_dir } = CliData::new(); - let cur_working_dir = std::env::current_dir().expect("No cwd"); - log::info!("cwd: {}", cur_working_dir.display()); - // Open the game file let input_file = std::fs::File::open(&input_filename) .panic_err_msg("Unable to open input file"); @@ -73,9 +70,10 @@ fn main() { // Get the cards table let cards_table = CardTable::deserialize(&mut game_file) - .panic_err_msg("Unable to create cards table"); + .panic_err_msg("Unable to deserialize cards table from game file"); let cards_table_yaml = serde_yaml::to_string(&cards_table) - .panic_err_msg("Unable to serialize cards table"); + .panic_err_msg("Unable to serialize cards table to yaml"); + log::info!("Extracted {} cards", cards_table.card_count()); // And output everything to the files From 64ca282e2f7c1945a878f40647145b184aedbf65 Mon Sep 17 00:00:00 2001 From: Filipe Rodrigues Date: Fri, 1 May 2020 08:26:57 +0100 Subject: [PATCH 04/12] Renamed project to allow multiple tools. --- Cargo.lock | 2 +- Cargo.toml | 14 ++++++++++---- src/{ => extractor}/cli.rs | 0 src/{ => extractor}/main.rs | 0 src/{ => extractor}/panic.rs | 0 5 files changed, 11 insertions(+), 5 deletions(-) rename src/{ => extractor}/cli.rs (100%) rename src/{ => extractor}/main.rs (100%) rename src/{ => extractor}/panic.rs (100%) diff --git a/Cargo.lock b/Cargo.lock index 83dc176..388d5d3 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -139,7 +139,7 @@ dependencies = [ ] [[package]] -name = "dcb-extract" +name = "dcb-tools" version = "0.1.0" dependencies = [ "clap", diff --git a/Cargo.toml b/Cargo.toml index da7ffa3..027aab7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,11 +1,18 @@ [package] -name = "dcb-extract" +name = "dcb-tools" version = "0.1.0" authors = ["Filipe Rodrigues "] edition = "2018" -[dependencies] +[[bin]] +name = "extractor" +path = "src/extractor/main.rs" +[[bin]] +name = "patcher" +path = "src/patcher/main.rs" + +[dependencies] # Dcb dcb = { path = "../dcb" } @@ -23,13 +30,12 @@ err-panic = { path = "../err-panic", features = ["string-err-ext"] } err-ext = { path = "../err-ext" } derive_more = "0.99" - # Serde serde_yaml = "0.8" # Build dependencies in release mode [profile.dev.package."*"] opt-level = 2 -[profile.dev.package.dcb] # Except dcb +[profile.dev.package.dcb] # Except dcb for debugging opt-level = 0 diff --git a/src/cli.rs b/src/extractor/cli.rs similarity index 100% rename from src/cli.rs rename to src/extractor/cli.rs diff --git a/src/main.rs b/src/extractor/main.rs similarity index 100% rename from src/main.rs rename to src/extractor/main.rs diff --git a/src/panic.rs b/src/extractor/panic.rs similarity index 100% rename from src/panic.rs rename to src/extractor/panic.rs From e3eebb254960f64df4f8cb22d52d0fbf51e21c63 Mon Sep 17 00:00:00 2001 From: Filipe Rodrigues Date: Fri, 1 May 2020 11:29:22 +0100 Subject: [PATCH 05/12] Added a patcher for the game. --- src/extractor/main.rs | 5 +- src/patcher/cli.rs | 69 ++++++++++++++++++++++++++++ src/patcher/main.rs | 103 ++++++++++++++++++++++++++++++++++++++++++ src/patcher/panic.rs | 31 +++++++++++++ 4 files changed, 205 insertions(+), 3 deletions(-) create mode 100644 src/patcher/cli.rs create mode 100644 src/patcher/main.rs create mode 100644 src/patcher/panic.rs diff --git a/src/extractor/main.rs b/src/extractor/main.rs index 6a4e664..dbb2f70 100644 --- a/src/extractor/main.rs +++ b/src/extractor/main.rs @@ -5,14 +5,13 @@ //! edited and then used by `Patcher` to modify the game file. //! //! # Syntax -//! The executable may be called as `./dcb-extractor {-o }` +//! The executable may be called as `./extractor {-o }` //! -//! Use the command `./dcb-extractor --help` for more information. +//! Use the command `./extractor --help` for more information. //! //! # Data extracted //! Currently only the following is extracted: //! - Card table -//! - Deck table (partial) // Features #![feature( diff --git a/src/patcher/cli.rs b/src/patcher/cli.rs new file mode 100644 index 0000000..85e4899 --- /dev/null +++ b/src/patcher/cli.rs @@ -0,0 +1,69 @@ +//! Cli manager for the extractor + +// Filesystem +use std::path::{Path, PathBuf}; + +// Clap +use clap::{Arg as ClapArg, App as ClapApp}; + +// Errors +use err_panic::ErrorExtPanic; + + +/// Data from the command line +#[derive(PartialEq, Clone, Debug)] +pub struct CliData +{ + /// The game file + pub game_file_path: PathBuf, + + /// The input directory + pub input_dir: PathBuf, +} + +impl CliData +{ + /// Constructs all of the cli data given and returns it + pub fn new() -> Self + { + // Get all matches from cli + let matches = ClapApp::new("Dcb Patcher") + .version("0.0") + .author("Filipe [...] <[...]@gmail.com>") + .about("Patches data to a Digimon Digital Card Battle `.bin` game file") + .arg( ClapArg::with_name("GAME_FILE") + .help("Sets the game file to use") + .required(true) + .index(1) + ) + .arg( ClapArg::with_name("INPUT") + .help("Sets the output directory to use") + .short("i") + .long("input") + .index(2) + .takes_value(true) + .required(true) + ) + .get_matches(); + + // Get the ouput filename + // Note: required + let game_file_path = matches.value_of("GAME_FILE") + .map(Path::new) + .map(Path::to_path_buf) + .panic_msg("Unable to get required argument `GAME_FILE`"); + + // Get the input dir + // Note: required + let input_dir = matches.value_of("INPUT") + .map(Path::new) + .map(Path::to_path_buf) + .panic_msg("Unable to get required argument `INPUT`"); + + // Return the cli data + Self { + game_file_path, + input_dir, + } + } +} diff --git a/src/patcher/main.rs b/src/patcher/main.rs new file mode 100644 index 0000000..7ae66b3 --- /dev/null +++ b/src/patcher/main.rs @@ -0,0 +1,103 @@ +//! Data patches +//! +//! # Details +//! Patches data to the game file from several other files. +//! +//! # Syntax +//! The executable may be called as `./patcher ` +//! +//! Use the command `./patcher --help` for more information. +//! +//! # Data patched +//! Currently only the following is patched: +//! - Card table + +// Features +#![feature( + box_syntax, + backtrace, + panic_info_message, +)] + +// Lints +#![warn( + clippy::restriction, + clippy::pedantic, + clippy::nursery, +)] +#![allow( + clippy::implicit_return, // We prefer implicit returns where possible + clippy::module_name_repetitions, // This happens often due to separating things into modules finely + clippy::wildcard_enum_match_arm, // We only use wildcards when we truly only care about some variants + clippy::result_expect_used, + clippy::option_expect_used, // We use expect when there is no alternative. + clippy::used_underscore_binding, // Useful for macros and such +)] + +// Modules +mod cli; +mod panic; + +// Exports +use cli::CliData; + +// Dcb +use dcb::{ + GameFile, + game::card::Table as CardTable, +}; + +// Errors +use err_ext::ResultExt; +use err_panic::ErrorExtPanic; + +fn main() { + // Initialize the logger and set the panic handler + init_logger(); + std::panic::set_hook(box panic::log_handler); + + // Get all data from cli + let CliData { game_file_path, input_dir } = CliData::new(); + + // Load the card table + let cards_table_file = std::fs::File::open( input_dir.join("cards.yaml") ) + .panic_err_msg("Unable to open `cards.yaml`"); + let cards_table: CardTable = serde_yaml::from_reader( cards_table_file ) + .panic_err_msg("Unable to parse `cards.yaml`"); + + // Open the game file + let game_file = std::fs::OpenOptions::new() + .write(true) + .truncate(false) + .open( game_file_path ) + .panic_err_msg("Unable to open game file"); + let mut game_file = GameFile::from_reader( game_file ) + .panic_err_msg("Unable to initialize game file"); + + // And write the cards table + cards_table.serialize(&mut game_file) + .panic_err_msg("Unable to serialize cards table"); +} + +/// Initializes the global logger +fn init_logger() { + use simplelog::{CombinedLogger, SharedLogger, TermLogger, WriteLogger, Config, TerminalMode}; + use log::LevelFilter::{Info, Trace}; + use std::convert::identity; + /// The type of logger required to pass to `CombinedLogger::init` + type BoxedLogger = Box; + + // All loggers to try and initialize + let loggers: Vec< Option > = vec![ + TermLogger ::new(Info, Config::default(), TerminalMode::Mixed) + .map(|logger| BoxedLogger::from(logger)), + std::fs::File::create("latest.log").ok() + .map(|file| WriteLogger::new(Trace, Config::default(), file)) + .map(|logger| BoxedLogger::from(logger)) + ]; + + // Filter all logger that actually work and initialize them + CombinedLogger::init( + loggers.into_iter().filter_map(identity).collect() + ).ignore_with_err(|_| log::warn!("Logger was already initialized at the start of the program")); +} diff --git a/src/patcher/panic.rs b/src/patcher/panic.rs new file mode 100644 index 0000000..595c8ef --- /dev/null +++ b/src/patcher/panic.rs @@ -0,0 +1,31 @@ +//! Panic handlers for this application + +// Std +use std::{ + error::Error, + backtrace::{Backtrace, BacktraceStatus}, +}; +// Error backtrace +use err_backtrace::ErrBacktraceExt; + +/// Panic handler based on logging to the current initialization +pub fn log_handler(info: &std::panic::PanicInfo) { + // Log that this thread has panicked + log::error!("Thread \"{}\" panicked", std::thread::current().name().unwrap_or("[Unknown]")); + + // Log any message that came with the panic + log::info!("Panic message: {}", info.message().unwrap_or( &format_args!("None") )); + + // Print an error backtrace if we found any + if let Some(err) = info.payload().downcast_ref::< Box >() { + log::info!("Error backtrace:\n{}", err.err_backtrace()); + } + + // And print a backtrace of where this panic occured. + let backtrace = Backtrace::force_capture(); + if backtrace.status() == BacktraceStatus::Captured { + log::info!("Backtrace:\n{}", backtrace); + } else { + log::info!("Unable to get backtrace: {}", backtrace); + } +} From b98c2ef50ec96d581aaef31d4360740575dbba22 Mon Sep 17 00:00:00 2001 From: Filipe Rodrigues Date: Fri, 1 May 2020 11:32:23 +0100 Subject: [PATCH 06/12] Started using a formatter. --- rustfmt.toml | 18 ++++++++++ src/extractor/cli.rs | 67 +++++++++++++++------------------- src/extractor/main.rs | 81 ++++++++++++++++++------------------------ src/extractor/panic.rs | 12 +++---- src/patcher/cli.rs | 52 ++++++++++++--------------- src/patcher/main.rs | 69 ++++++++++++++--------------------- src/patcher/panic.rs | 12 +++---- 7 files changed, 142 insertions(+), 169 deletions(-) create mode 100644 rustfmt.toml diff --git a/rustfmt.toml b/rustfmt.toml new file mode 100644 index 0000000..844da63 --- /dev/null +++ b/rustfmt.toml @@ -0,0 +1,18 @@ +# We're fine with unstable features +unstable_features = true + + + +binop_separator = "Back" +hard_tabs = true +condense_wildcard_suffixes = true +match_block_trailing_comma = true +newline_style = "Unix" +reorder_impl_items = true +overflow_delimited_expr = true +use_field_init_shorthand = true +enum_discrim_align_threshold = 100 +fn_args_layout = "Compressed" +merge_derives = false +merge_imports = true +max_width = 150 diff --git a/src/extractor/cli.rs b/src/extractor/cli.rs index 24b38b4..9f3fe38 100644 --- a/src/extractor/cli.rs +++ b/src/extractor/cli.rs @@ -4,69 +4,60 @@ use std::path::{Path, PathBuf}; // Clap -use clap::{Arg as ClapArg, App as ClapApp}; +use clap::{App as ClapApp, Arg as ClapArg}; // Errors use err_panic::ErrorExtPanic; +/// Data from the command line +#[derive(PartialEq, Clone, Debug)] +pub struct CliData { + /// The game file + pub game_file_path: PathBuf, -/// All of the data received form the command line -/// -/// # Public fields -/// All fields are public as this type has no invariants. -pub struct CliData -{ - /// The input filename - pub input_filename: PathBuf, - - /// The output directory + /// The ouput directory pub output_dir: PathBuf, } -impl CliData -{ +impl CliData { /// Constructs all of the cli data given and returns it - pub fn new() -> Self - { + pub fn new() -> Self { // Get all matches from cli let matches = ClapApp::new("Dcb Extractor") .version("0.0") .author("Filipe [...] <[...]@gmail.com>") .about("Extracts all data from a Digimon Digital Card Battle `.bin` game file") - .arg( ClapArg::with_name("INPUT") - .help("Sets the input game file to use") - .required(true) - .index(1) + .arg( + ClapArg::with_name("GAME_FILE") + .help("Sets the input game file to use") + .required(true) + .index(1), ) - .arg( ClapArg::with_name("OUTPUT") - .help("Sets the output directory to use") - .short("o") - .long("output") - .takes_value(true) - .required(false) + .arg( + ClapArg::with_name("OUTPUT") + .help("Sets the output directory to use") + .short("o") + .long("output") + .takes_value(true) + .required(false), ) .get_matches(); - + // Get the input filename // Note: required - let input_filename = matches.value_of("INPUT") + let game_file_path = matches + .value_of("GAME_FILE") .map(Path::new) .map(Path::to_path_buf) - .panic_msg("Unable to get required argument `INPUT`"); - + .panic_msg("Unable to get required argument `GAME_FILE`"); + // Try to get the output let output_dir = match matches.value_of("OUTPUT") { Some(output) => PathBuf::from(output), - None => input_filename - .parent() - .unwrap_or_else(|| Path::new(".")) - .to_path_buf() + None => game_file_path.parent().unwrap_or_else(|| Path::new(".")).to_path_buf(), }; - + // Return the cli data - Self { - input_filename, - output_dir, - } + Self { game_file_path, output_dir } } } diff --git a/src/extractor/main.rs b/src/extractor/main.rs index dbb2f70..6e5f0c3 100644 --- a/src/extractor/main.rs +++ b/src/extractor/main.rs @@ -1,31 +1,22 @@ //! Data extractor -//! +//! //! # Details //! Extracts data from the game file to several other files, that can be //! edited and then used by `Patcher` to modify the game file. -//! +//! //! # Syntax //! The executable may be called as `./extractor {-o }` -//! +//! //! Use the command `./extractor --help` for more information. -//! +//! //! # Data extracted //! Currently only the following is extracted: //! - Card table // Features -#![feature( - box_syntax, - backtrace, - panic_info_message, -)] - +#![feature(box_syntax, backtrace, panic_info_message)] // Lints -#![warn( - clippy::restriction, - clippy::pedantic, - clippy::nursery, -)] +#![warn(clippy::restriction, clippy::pedantic, clippy::nursery)] #![allow( clippy::implicit_return, // We prefer implicit returns where possible clippy::module_name_repetitions, // This happens often due to separating things into modules finely @@ -43,64 +34,62 @@ mod panic; use cli::CliData; // Dcb -use dcb::{ - GameFile, - game::card::Table as CardTable, -}; +use dcb::{game::card::Table as CardTable, GameFile}; // Errors +use err_backtrace::ErrBacktraceExt; use err_ext::ResultExt; use err_panic::ErrorExtPanic; -use err_backtrace::ErrBacktraceExt; fn main() { // Initialize the logger and set the panic handler init_logger(); std::panic::set_hook(box panic::log_handler); - + // Get all data from cli - let CliData { input_filename, output_dir } = CliData::new(); - + let CliData { game_file_path, output_dir } = CliData::new(); + // Open the game file - let input_file = std::fs::File::open(&input_filename) - .panic_err_msg("Unable to open input file"); - let mut game_file = GameFile::from_reader(input_file) - .panic_err_msg("Unable to parse input file as dcb"); - + let input_file = std::fs::File::open(&game_file_path).panic_err_msg("Unable to open input file"); + let mut game_file = GameFile::from_reader(input_file).panic_err_msg("Unable to parse input file as dcb"); + // Get the cards table - let cards_table = CardTable::deserialize(&mut game_file) - .panic_err_msg("Unable to deserialize cards table from game file"); - let cards_table_yaml = serde_yaml::to_string(&cards_table) - .panic_err_msg("Unable to serialize cards table to yaml"); - + let cards_table = CardTable::deserialize(&mut game_file).panic_err_msg("Unable to deserialize cards table from game file"); + let cards_table_yaml = serde_yaml::to_string(&cards_table).panic_err_msg("Unable to serialize cards table to yaml"); + log::info!("Extracted {} cards", cards_table.card_count()); - + // And output everything to the files let cards_table_output_filename = output_dir.join("cards.yaml"); std::fs::write(&cards_table_output_filename, cards_table_yaml) - .map_err(|err| log::warn!("Unable to write output file {}:\n{}", cards_table_output_filename.display(), err.err_backtrace() )) + .map_err(|err| { + log::warn!( + "Unable to write output file {}:\n{}", + cards_table_output_filename.display(), + err.err_backtrace() + ) + }) .ignore(); } /// Initializes the global logger fn init_logger() { - use simplelog::{CombinedLogger, SharedLogger, TermLogger, WriteLogger, Config, TerminalMode}; use log::LevelFilter::{Info, Trace}; + use simplelog::{CombinedLogger, Config, SharedLogger, TermLogger, TerminalMode, WriteLogger}; use std::convert::identity; /// The type of logger required to pass to `CombinedLogger::init` type BoxedLogger = Box; - + // All loggers to try and initialize - let loggers: Vec< Option > = vec![ - TermLogger ::new(Info, Config::default(), TerminalMode::Mixed) - .map(|logger| BoxedLogger::from(logger)), - std::fs::File::create("latest.log").ok() + let loggers: Vec> = vec![ + TermLogger::new(Info, Config::default(), TerminalMode::Mixed).map(|logger| BoxedLogger::from(logger)), + std::fs::File::create("latest.log") + .ok() .map(|file| WriteLogger::new(Trace, Config::default(), file)) - .map(|logger| BoxedLogger::from(logger)) + .map(|logger| BoxedLogger::from(logger)), ]; - + // Filter all logger that actually work and initialize them - CombinedLogger::init( - loggers.into_iter().filter_map(identity).collect() - ).ignore_with_err(|_| log::warn!("Logger was already initialized at the start of the program")); + CombinedLogger::init(loggers.into_iter().filter_map(identity).collect()) + .ignore_with_err(|_| log::warn!("Logger was already initialized at the start of the program")); } diff --git a/src/extractor/panic.rs b/src/extractor/panic.rs index 595c8ef..10657ef 100644 --- a/src/extractor/panic.rs +++ b/src/extractor/panic.rs @@ -2,8 +2,8 @@ // Std use std::{ - error::Error, backtrace::{Backtrace, BacktraceStatus}, + error::Error, }; // Error backtrace use err_backtrace::ErrBacktraceExt; @@ -12,15 +12,15 @@ use err_backtrace::ErrBacktraceExt; pub fn log_handler(info: &std::panic::PanicInfo) { // Log that this thread has panicked log::error!("Thread \"{}\" panicked", std::thread::current().name().unwrap_or("[Unknown]")); - + // Log any message that came with the panic - log::info!("Panic message: {}", info.message().unwrap_or( &format_args!("None") )); - + log::info!("Panic message: {}", info.message().unwrap_or(&format_args!("None"))); + // Print an error backtrace if we found any - if let Some(err) = info.payload().downcast_ref::< Box >() { + if let Some(err) = info.payload().downcast_ref::>() { log::info!("Error backtrace:\n{}", err.err_backtrace()); } - + // And print a backtrace of where this panic occured. let backtrace = Backtrace::force_capture(); if backtrace.status() == BacktraceStatus::Captured { diff --git a/src/patcher/cli.rs b/src/patcher/cli.rs index 85e4899..630dddc 100644 --- a/src/patcher/cli.rs +++ b/src/patcher/cli.rs @@ -4,66 +4,58 @@ use std::path::{Path, PathBuf}; // Clap -use clap::{Arg as ClapArg, App as ClapApp}; +use clap::{App as ClapApp, Arg as ClapArg}; // Errors use err_panic::ErrorExtPanic; - /// Data from the command line #[derive(PartialEq, Clone, Debug)] -pub struct CliData -{ +pub struct CliData { /// The game file pub game_file_path: PathBuf, - + /// The input directory pub input_dir: PathBuf, } -impl CliData -{ +impl CliData { /// Constructs all of the cli data given and returns it - pub fn new() -> Self - { + pub fn new() -> Self { // Get all matches from cli let matches = ClapApp::new("Dcb Patcher") .version("0.0") .author("Filipe [...] <[...]@gmail.com>") .about("Patches data to a Digimon Digital Card Battle `.bin` game file") - .arg( ClapArg::with_name("GAME_FILE") - .help("Sets the game file to use") - .required(true) - .index(1) - ) - .arg( ClapArg::with_name("INPUT") - .help("Sets the output directory to use") - .short("i") - .long("input") - .index(2) - .takes_value(true) - .required(true) + .arg(ClapArg::with_name("GAME_FILE").help("Sets the game file to use").required(true).index(1)) + .arg( + ClapArg::with_name("INPUT") + .help("Sets the output directory to use") + .short("i") + .long("input") + .index(2) + .takes_value(true) + .required(true), ) .get_matches(); - + // Get the ouput filename // Note: required - let game_file_path = matches.value_of("GAME_FILE") + let game_file_path = matches + .value_of("GAME_FILE") .map(Path::new) .map(Path::to_path_buf) .panic_msg("Unable to get required argument `GAME_FILE`"); - + // Get the input dir // Note: required - let input_dir = matches.value_of("INPUT") + let input_dir = matches + .value_of("INPUT") .map(Path::new) .map(Path::to_path_buf) .panic_msg("Unable to get required argument `INPUT`"); - + // Return the cli data - Self { - game_file_path, - input_dir, - } + Self { game_file_path, input_dir } } } diff --git a/src/patcher/main.rs b/src/patcher/main.rs index 7ae66b3..f247867 100644 --- a/src/patcher/main.rs +++ b/src/patcher/main.rs @@ -1,30 +1,21 @@ //! Data patches -//! +//! //! # Details //! Patches data to the game file from several other files. -//! +//! //! # Syntax //! The executable may be called as `./patcher ` -//! +//! //! Use the command `./patcher --help` for more information. -//! +//! //! # Data patched //! Currently only the following is patched: //! - Card table // Features -#![feature( - box_syntax, - backtrace, - panic_info_message, -)] - +#![feature(box_syntax, backtrace, panic_info_message)] // Lints -#![warn( - clippy::restriction, - clippy::pedantic, - clippy::nursery, -)] +#![warn(clippy::restriction, clippy::pedantic, clippy::nursery)] #![allow( clippy::implicit_return, // We prefer implicit returns where possible clippy::module_name_repetitions, // This happens often due to separating things into modules finely @@ -42,10 +33,7 @@ mod panic; use cli::CliData; // Dcb -use dcb::{ - GameFile, - game::card::Table as CardTable, -}; +use dcb::{game::card::Table as CardTable, GameFile}; // Errors use err_ext::ResultExt; @@ -55,49 +43,44 @@ fn main() { // Initialize the logger and set the panic handler init_logger(); std::panic::set_hook(box panic::log_handler); - + // Get all data from cli let CliData { game_file_path, input_dir } = CliData::new(); - + // Load the card table - let cards_table_file = std::fs::File::open( input_dir.join("cards.yaml") ) - .panic_err_msg("Unable to open `cards.yaml`"); - let cards_table: CardTable = serde_yaml::from_reader( cards_table_file ) - .panic_err_msg("Unable to parse `cards.yaml`"); - + let cards_table_file = std::fs::File::open(input_dir.join("cards.yaml")).panic_err_msg("Unable to open `cards.yaml`"); + let cards_table: CardTable = serde_yaml::from_reader(cards_table_file).panic_err_msg("Unable to parse `cards.yaml`"); + // Open the game file let game_file = std::fs::OpenOptions::new() .write(true) .truncate(false) - .open( game_file_path ) + .open(game_file_path) .panic_err_msg("Unable to open game file"); - let mut game_file = GameFile::from_reader( game_file ) - .panic_err_msg("Unable to initialize game file"); - + let mut game_file = GameFile::from_reader(game_file).panic_err_msg("Unable to initialize game file"); + // And write the cards table - cards_table.serialize(&mut game_file) - .panic_err_msg("Unable to serialize cards table"); + cards_table.serialize(&mut game_file).panic_err_msg("Unable to serialize cards table"); } /// Initializes the global logger fn init_logger() { - use simplelog::{CombinedLogger, SharedLogger, TermLogger, WriteLogger, Config, TerminalMode}; use log::LevelFilter::{Info, Trace}; + use simplelog::{CombinedLogger, Config, SharedLogger, TermLogger, TerminalMode, WriteLogger}; use std::convert::identity; /// The type of logger required to pass to `CombinedLogger::init` type BoxedLogger = Box; - + // All loggers to try and initialize - let loggers: Vec< Option > = vec![ - TermLogger ::new(Info, Config::default(), TerminalMode::Mixed) - .map(|logger| BoxedLogger::from(logger)), - std::fs::File::create("latest.log").ok() + let loggers: Vec> = vec![ + TermLogger::new(Info, Config::default(), TerminalMode::Mixed).map(|logger| BoxedLogger::from(logger)), + std::fs::File::create("latest.log") + .ok() .map(|file| WriteLogger::new(Trace, Config::default(), file)) - .map(|logger| BoxedLogger::from(logger)) + .map(|logger| BoxedLogger::from(logger)), ]; - + // Filter all logger that actually work and initialize them - CombinedLogger::init( - loggers.into_iter().filter_map(identity).collect() - ).ignore_with_err(|_| log::warn!("Logger was already initialized at the start of the program")); + CombinedLogger::init(loggers.into_iter().filter_map(identity).collect()) + .ignore_with_err(|_| log::warn!("Logger was already initialized at the start of the program")); } diff --git a/src/patcher/panic.rs b/src/patcher/panic.rs index 595c8ef..10657ef 100644 --- a/src/patcher/panic.rs +++ b/src/patcher/panic.rs @@ -2,8 +2,8 @@ // Std use std::{ - error::Error, backtrace::{Backtrace, BacktraceStatus}, + error::Error, }; // Error backtrace use err_backtrace::ErrBacktraceExt; @@ -12,15 +12,15 @@ use err_backtrace::ErrBacktraceExt; pub fn log_handler(info: &std::panic::PanicInfo) { // Log that this thread has panicked log::error!("Thread \"{}\" panicked", std::thread::current().name().unwrap_or("[Unknown]")); - + // Log any message that came with the panic - log::info!("Panic message: {}", info.message().unwrap_or( &format_args!("None") )); - + log::info!("Panic message: {}", info.message().unwrap_or(&format_args!("None"))); + // Print an error backtrace if we found any - if let Some(err) = info.payload().downcast_ref::< Box >() { + if let Some(err) = info.payload().downcast_ref::>() { log::info!("Error backtrace:\n{}", err.err_backtrace()); } - + // And print a backtrace of where this panic occured. let backtrace = Backtrace::force_capture(); if backtrace.status() == BacktraceStatus::Captured { From 406f38b65e0de7da2e49a067fcd6ceceaf57c1d5 Mon Sep 17 00:00:00 2001 From: Filipe Rodrigues Date: Fri, 1 May 2020 19:29:06 +0100 Subject: [PATCH 07/12] Changed `patcher` to use the parent of the game file by default if no directory is given. --- src/extractor/main.rs | 23 ++++++++++------------- src/patcher/cli.rs | 13 +++++-------- src/patcher/main.rs | 12 ++++++++++-- 3 files changed, 25 insertions(+), 23 deletions(-) diff --git a/src/extractor/main.rs b/src/extractor/main.rs index 6e5f0c3..e998570 100644 --- a/src/extractor/main.rs +++ b/src/extractor/main.rs @@ -34,10 +34,12 @@ mod panic; use cli::CliData; // Dcb -use dcb::{game::card::Table as CardTable, GameFile}; +use dcb::{ + game::{card::Table as CardTable, deck::Table as DeckTable}, + GameFile, +}; // Errors -use err_backtrace::ErrBacktraceExt; use err_ext::ResultExt; use err_panic::ErrorExtPanic; @@ -56,20 +58,15 @@ fn main() { // Get the cards table let cards_table = CardTable::deserialize(&mut game_file).panic_err_msg("Unable to deserialize cards table from game file"); let cards_table_yaml = serde_yaml::to_string(&cards_table).panic_err_msg("Unable to serialize cards table to yaml"); - log::info!("Extracted {} cards", cards_table.card_count()); + // Get the decks table + let decks_table = DeckTable::deserialize(&mut game_file).panic_err_msg("Unable to deserialize decks table from game file"); + let decks_table_yaml = serde_yaml::to_string(&decks_table).panic_err_msg("Unable to serialize decks table to yaml"); + // And output everything to the files - let cards_table_output_filename = output_dir.join("cards.yaml"); - std::fs::write(&cards_table_output_filename, cards_table_yaml) - .map_err(|err| { - log::warn!( - "Unable to write output file {}:\n{}", - cards_table_output_filename.display(), - err.err_backtrace() - ) - }) - .ignore(); + std::fs::write(&output_dir.join("cards.yaml"), cards_table_yaml).panic_err_msg("Unable to write cards table to file"); + std::fs::write(&output_dir.join("decks.yaml"), decks_table_yaml).panic_err_msg("Unable to write decks table to file"); } /// Initializes the global logger diff --git a/src/patcher/cli.rs b/src/patcher/cli.rs index 630dddc..30bf7fb 100644 --- a/src/patcher/cli.rs +++ b/src/patcher/cli.rs @@ -30,12 +30,11 @@ impl CliData { .arg(ClapArg::with_name("GAME_FILE").help("Sets the game file to use").required(true).index(1)) .arg( ClapArg::with_name("INPUT") - .help("Sets the output directory to use") + .help("Sets the input directory to use") .short("i") .long("input") - .index(2) .takes_value(true) - .required(true), + .required(false), ) .get_matches(); @@ -47,13 +46,11 @@ impl CliData { .map(Path::to_path_buf) .panic_msg("Unable to get required argument `GAME_FILE`"); - // Get the input dir - // Note: required + // Get the input dir as either an input, the game file directory or the current directory let input_dir = matches .value_of("INPUT") - .map(Path::new) - .map(Path::to_path_buf) - .panic_msg("Unable to get required argument `INPUT`"); + .map_or_else(|| game_file_path.parent().unwrap_or_else(|| Path::new(".")), Path::new) + .to_path_buf(); // Return the cli data Self { game_file_path, input_dir } diff --git a/src/patcher/main.rs b/src/patcher/main.rs index f247867..4429111 100644 --- a/src/patcher/main.rs +++ b/src/patcher/main.rs @@ -33,7 +33,10 @@ mod panic; use cli::CliData; // Dcb -use dcb::{game::card::Table as CardTable, GameFile}; +use dcb::{ + game::{card::Table as CardTable, deck::Table as DeckTable}, + GameFile, +}; // Errors use err_ext::ResultExt; @@ -51,6 +54,10 @@ fn main() { let cards_table_file = std::fs::File::open(input_dir.join("cards.yaml")).panic_err_msg("Unable to open `cards.yaml`"); let cards_table: CardTable = serde_yaml::from_reader(cards_table_file).panic_err_msg("Unable to parse `cards.yaml`"); + // Load the decks table + let decks_table_file = std::fs::File::open(input_dir.join("decks.yaml")).panic_err_msg("Unable to open `decks.yaml`"); + let decks_table: DeckTable = serde_yaml::from_reader(decks_table_file).panic_err_msg("Unable to parse `decks.yaml`"); + // Open the game file let game_file = std::fs::OpenOptions::new() .write(true) @@ -59,8 +66,9 @@ fn main() { .panic_err_msg("Unable to open game file"); let mut game_file = GameFile::from_reader(game_file).panic_err_msg("Unable to initialize game file"); - // And write the cards table + // And write everything cards_table.serialize(&mut game_file).panic_err_msg("Unable to serialize cards table"); + decks_table.serialize(&mut game_file).panic_err_msg("Unable to serialize decks table"); } /// Initializes the global logger From 0895aac99b2ea6b0bbaca1da6f5f34d145102699 Mon Sep 17 00:00:00 2001 From: Filipe Rodrigues Date: Sun, 3 May 2020 10:55:54 +0100 Subject: [PATCH 08/12] Moved `panic.rs` to be shared among all binaries. Moved `init_logger` to `logger.rs`. Added a `card-editor` binary based on imgui (Abandoned). --- Cargo.lock | 886 ++++++++++++++++++++++++++++++++++- Cargo.toml | 22 + src/card-editor/cli.rs | 41 ++ src/card-editor/main.rs | 282 +++++++++++ src/extractor/main.rs | 28 +- src/logger.rs | 27 ++ src/{extractor => }/panic.rs | 0 src/patcher/main.rs | 28 +- src/patcher/panic.rs | 31 -- 9 files changed, 1245 insertions(+), 100 deletions(-) create mode 100644 src/card-editor/cli.rs create mode 100644 src/card-editor/main.rs create mode 100644 src/logger.rs rename src/{extractor => }/panic.rs (100%) delete mode 100644 src/patcher/panic.rs diff --git a/Cargo.lock b/Cargo.lock index 388d5d3..2c58cb7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1,5 +1,25 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. +[[package]] +name = "andrew" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b7f09f89872c2b6b29e319377b1fbe91c6f5947df19a25596e121cf19a7b35e" +dependencies = [ + "bitflags", + "line_drawing", + "rusttype 0.7.9", + "walkdir", + "xdg", + "xml-rs", +] + +[[package]] +name = "android_glue" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "000444226fcff248f2bc4c7625be32c63caccfecc2723a2b9f78a7487a49c407" + [[package]] name = "ansi_term" version = "0.11.0" @@ -9,6 +29,15 @@ dependencies = [ "winapi", ] +[[package]] +name = "approx" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f0e60b75072ecd4168020818c0107f2857bb6c4e64252d8d3983f6263b40a5c3" +dependencies = [ + "num-traits", +] + [[package]] name = "arrayref" version = "0.3.6" @@ -47,6 +76,28 @@ version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f8aac770f1885fd7e387acedd76065302551364496e46b3dd00860b2f8359b9d" +[[package]] +name = "backtrace" +version = "0.3.46" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b1e692897359247cc6bb902933361652380af0f1b7651ae5c5013407f30e109e" +dependencies = [ + "backtrace-sys", + "cfg-if", + "libc", + "rustc-demangle", +] + +[[package]] +name = "backtrace-sys" +version = "0.1.37" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "18fbebbe1c9d1f383a9cc7e8ccdb471b91c8d024ee9c2ca5b5346121fe8b4399" +dependencies = [ + "cc", + "libc", +] + [[package]] name = "base64" version = "0.11.0" @@ -70,18 +121,40 @@ dependencies = [ "constant_time_eq", ] +[[package]] +name = "block" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0d8c1fef690941d3e7788d328517591fecc684c084084702d6ff1641e993699a" + [[package]] name = "byteorder" version = "1.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "08c48aae112d48ed9f069b33538ea9e3e90aa263cfa3d1c24309612b1f7472de" +[[package]] +name = "cc" +version = "1.0.52" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c3d87b23d6a92cd03af510a5ade527033f6aa6fa92161e2d5863a907d4c5e31d" + [[package]] name = "cfg-if" version = "0.1.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822" +[[package]] +name = "cgl" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "55e7ec0b74fe5897894cbc207092c577e87c52f8a59e8ca8d97ef37551f60a49" +dependencies = [ + "gleam", + "libc", +] + [[package]] name = "chrono" version = "0.4.11" @@ -102,18 +175,70 @@ dependencies = [ "ansi_term", "atty", "bitflags", - "strsim", + "strsim 0.8.0", "textwrap", "unicode-width", "vec_map", ] +[[package]] +name = "cloudabi" +version = "0.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ddfc5b9aa5d4507acaf872de71051dfd0e309860e88966e1051e462a077aac4f" +dependencies = [ + "bitflags", +] + +[[package]] +name = "cocoa" +version = "0.18.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1706996401131526e36b3b49f0c4d912639ce110996f3ca144d78946727bce54" +dependencies = [ + "bitflags", + "block", + "core-foundation", + "core-graphics", + "foreign-types", + "libc", + "objc", +] + [[package]] name = "constant_time_eq" version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "245097e9a4535ee1e3e3931fcfcd55a796a44c643e8596ff6566d68f09b87bbc" +[[package]] +name = "core-foundation" +version = "0.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "25b9e03f145fd4f2bf705e07b900cd41fc636598fe5dc452fd0db1441c3f496d" +dependencies = [ + "core-foundation-sys", + "libc", +] + +[[package]] +name = "core-foundation-sys" +version = "0.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e7ca8a5221364ef15ce201e8ed2f609fc312682a8f4e0e3d4aa5879764e0fa3b" + +[[package]] +name = "core-graphics" +version = "0.17.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "56790968ab1c8a1202a102e6de05fc6e1ec87da99e4e93e9a7d13efbfc1e95a9" +dependencies = [ + "bitflags", + "core-foundation", + "foreign-types", + "libc", +] + [[package]] name = "crossbeam-utils" version = "0.7.2" @@ -142,16 +267,27 @@ dependencies = [ name = "dcb-tools" version = "0.1.0" dependencies = [ + "ascii", "clap", "dcb", "derive_more", "err-backtrace", "err-ext", "err-panic", + "float-ord", + "gfx", + "gfx_device_gl", + "gfx_window_glutin", + "glutin", + "imgui", + "imgui-gfx-renderer", + "imgui-winit-support", + "itertools", "log", "serde_yaml", "simplelog", "string-err", + "strsim 0.10.0", ] [[package]] @@ -160,8 +296,8 @@ version = "0.99.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e2323f3f47db9a0e77ce7a300605d8d2098597fc451ed1a97bb1f6411bb550a7" dependencies = [ - "proc-macro2", - "quote", + "proc-macro2 1.0.10", + "quote 1.0.3", "syn", ] @@ -187,12 +323,42 @@ dependencies = [ "winapi", ] +[[package]] +name = "dlib" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77e51249a9d823a4cb79e3eca6dcd756153e8ed0157b6c04775d04bf1b13b76a" +dependencies = [ + "libloading", +] + +[[package]] +name = "downcast-rs" +version = "1.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "52ba6eb47c2131e784a38b726eb54c1e1484904f013e576a25354d0124161af6" + +[[package]] +name = "draw_state" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "33cf9537e2d06891448799b96d5a8c8083e0e90522a7fdabe6ebf4f41d79d651" +dependencies = [ + "bitflags", +] + [[package]] name = "dtoa" version = "0.4.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4358a9e11b9a09cf52383b451b49a169e8d797b68aa02301ff586d70d9661ea3" +[[package]] +name = "either" +version = "1.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bb1f6b1ce1c140482ea30ddd3335fc0024ac7ee112895426e0a629a6c20adfe3" + [[package]] name = "err-backtrace" version = "0.1.0" @@ -206,8 +372,8 @@ name = "err-impl" version = "0.1.0" dependencies = [ "proc-macro-error", - "proc-macro2", - "quote", + "proc-macro2 1.0.10", + "quote 1.0.3", "syn", "synstructure", ] @@ -219,6 +385,27 @@ dependencies = [ "string-err", ] +[[package]] +name = "float-ord" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7bad48618fdb549078c333a7a8528acb57af271d0433bdecd523eb620628364e" + +[[package]] +name = "foreign-types" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f6f339eb8adc052cd2ca78910fda869aefa38d22d5cb648e6485e4d3fc06f3b1" +dependencies = [ + "foreign-types-shared", +] + +[[package]] +name = "foreign-types-shared" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b" + [[package]] name = "getrandom" version = "0.1.14" @@ -230,6 +417,161 @@ dependencies = [ "wasi", ] +[[package]] +name = "gfx" +version = "0.18.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "01de46f9508a5c259aef105f0bff760ceddca832ea9c87ce03d1923e22ee155b" +dependencies = [ + "draw_state", + "gfx_core", + "log", +] + +[[package]] +name = "gfx_core" +version = "0.9.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "75fbddaef2e12b4995900539d7209d947b988a3d87ee8737484d049b526e5441" +dependencies = [ + "bitflags", + "draw_state", + "log", +] + +[[package]] +name = "gfx_device_gl" +version = "0.16.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "109c385fa380c18888633aa27d1e16cbae518469702a2f69dcb5f52d5378bebc" +dependencies = [ + "gfx_core", + "gfx_gl", + "log", +] + +[[package]] +name = "gfx_gl" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f2d38164670920cfb7491bc0cf6f49f0554bd1c44cdbedc6c78d2bf91691ff5e" +dependencies = [ + "gl_generator 0.14.0", +] + +[[package]] +name = "gfx_window_glutin" +version = "0.31.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "310ff66f08b5a55854b18fea2f48bdbb75c94458207ba574c9723be78e97a646" +dependencies = [ + "gfx_core", + "gfx_device_gl", + "glutin", +] + +[[package]] +name = "gl_generator" +version = "0.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ca98bbde17256e02d17336a6bdb5a50f7d0ccacee502e191d3e3d0ec2f96f84a" +dependencies = [ + "khronos_api", + "log", + "xml-rs", +] + +[[package]] +name = "gl_generator" +version = "0.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1a95dfc23a2b4a9a2f5ab41d194f8bfda3cabec42af4e39f08c339eb2a0c124d" +dependencies = [ + "khronos_api", + "log", + "xml-rs", +] + +[[package]] +name = "gleam" +version = "0.6.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cae10d7c99d0e77b4766e850a60898a17c1abaf01075531f1066f03dc7dc5fc5" +dependencies = [ + "gl_generator 0.13.1", +] + +[[package]] +name = "glutin" +version = "0.21.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5371b35b309dace06be1b81b5f6adb1c9de578b7dbe1e74bf7e4ef762cf6febd" +dependencies = [ + "android_glue", + "cgl", + "cocoa", + "core-foundation", + "core-graphics", + "glutin_egl_sys", + "glutin_emscripten_sys", + "glutin_gles2_sys", + "glutin_glx_sys", + "glutin_wgl_sys", + "lazy_static", + "libloading", + "objc", + "osmesa-sys", + "parking_lot 0.9.0", + "wayland-client", + "winapi", + "winit", +] + +[[package]] +name = "glutin_egl_sys" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "772edef3b28b8ad41e4ea202748e65eefe8e5ffd1f4535f1219793dbb20b3d4c" +dependencies = [ + "gl_generator 0.13.1", + "winapi", +] + +[[package]] +name = "glutin_emscripten_sys" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "80de4146df76e8a6c32b03007bc764ff3249dcaeb4f675d68a06caf1bac363f1" + +[[package]] +name = "glutin_gles2_sys" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "07e853d96bebcb8e53e445225c3009758c6f5960d44f2543245f6f07b567dae0" +dependencies = [ + "gl_generator 0.13.1", + "objc", +] + +[[package]] +name = "glutin_glx_sys" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "08c243de74d6cf5ea100c788826d2fb9319de315485dd4b310811a663b3809c3" +dependencies = [ + "gl_generator 0.13.1", + "x11-dl", +] + +[[package]] +name = "glutin_wgl_sys" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a93dba7ee3a0feeac0f437141ff25e71ce2066bcf1a706acab1559ffff94eb6a" +dependencies = [ + "gl_generator 0.13.1", +] + [[package]] name = "hermit-abi" version = "0.1.10" @@ -239,6 +581,64 @@ dependencies = [ "libc", ] +[[package]] +name = "imgui" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a2d28cee2982d4dab4dd954c23be339ab1f98be4ff5a13ecd8fbfb47cdfa23a" +dependencies = [ + "bitflags", + "gfx", + "imgui-sys", + "lazy_static", + "parking_lot 0.10.2", +] + +[[package]] +name = "imgui-gfx-renderer" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "506eae7244a06bc18273634d1c30e070bdf592f5e7fb1f6871d062ad17a4b2ec" +dependencies = [ + "gfx", + "imgui", + "winapi", +] + +[[package]] +name = "imgui-sys" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "21a8693e0f66ecd2ec10e2f0ed4dc4519071495f350e6d8ddaf3e70351229257" +dependencies = [ + "cc", +] + +[[package]] +name = "imgui-winit-support" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5685c7d17aee9555377f9c4f7b6fac96899a7015f6b41950c613a3df034aff08" +dependencies = [ + "imgui", + "winit", +] + +[[package]] +name = "itertools" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "284f18f85651fe11e8a991b2adb42cb078325c996ed026d994719efcfca1d54b" +dependencies = [ + "either", +] + +[[package]] +name = "khronos_api" +version = "3.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2db585e1d738fc771bf08a151420d3ed193d9d895a36df7f6f8a9456b911ddc" + [[package]] name = "lazy_static" version = "1.4.0" @@ -251,12 +651,40 @@ version = "0.2.68" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dea0c0405123bba743ee3f91f49b1c7cfb684eef0da0a50110f758ccf24cdff0" +[[package]] +name = "libloading" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f2b111a074963af1d37a139918ac6d49ad1d0d5e47f72fd55388619691a7d753" +dependencies = [ + "cc", + "winapi", +] + +[[package]] +name = "line_drawing" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5cc7ad3d82c845bdb5dde34ffdcc7a5fb4d2996e1e1ee0f19c33bc80e15196b9" +dependencies = [ + "num-traits", +] + [[package]] name = "linked-hash-map" version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ae91b68aebc4ddb91978b11a1b02ddd8602a05ec19002801c5666000e05e0f83" +[[package]] +name = "lock_api" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c4da24a77a3d8a6d4862d95f72e6fdb9c09a643ecdb402d754004a557f2bec75" +dependencies = [ + "scopeguard", +] + [[package]] name = "log" version = "0.4.8" @@ -266,6 +694,44 @@ dependencies = [ "cfg-if", ] +[[package]] +name = "malloc_buf" +version = "0.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "62bb907fe88d54d8d9ce32a3cceab4218ed2f6b7d35617cafe9adf84e43919cb" +dependencies = [ + "libc", +] + +[[package]] +name = "maybe-uninit" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "60302e4db3a61da70c0cb7991976248362f30319e88850c487b9b95bbf059e00" + +[[package]] +name = "memmap" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6585fd95e7bb50d6cc31e20d4cf9afb4e2ba16c5846fc76793f11218da9c475b" +dependencies = [ + "libc", + "winapi", +] + +[[package]] +name = "nix" +version = "0.14.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c722bee1037d430d0f8e687bbdbf222f27cc6e4e68d5caf630857bb2b6dbdce" +dependencies = [ + "bitflags", + "cc", + "cfg-if", + "libc", + "void", +] + [[package]] name = "num-integer" version = "0.1.42" @@ -285,6 +751,95 @@ dependencies = [ "autocfg", ] +[[package]] +name = "objc" +version = "0.2.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "915b1b472bc21c53464d6c8461c9d3af805ba1ef837e1cac254428f4a77177b1" +dependencies = [ + "malloc_buf", +] + +[[package]] +name = "ordered-float" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "18869315e81473c951eb56ad5558bbc56978562d3ecfb87abb7a1e944cea4518" +dependencies = [ + "num-traits", +] + +[[package]] +name = "osmesa-sys" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "88cfece6e95d2e717e0872a7f53a8684712ad13822a7979bc760b9c77ec0013b" +dependencies = [ + "shared_library", +] + +[[package]] +name = "parking_lot" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f842b1982eb6c2fe34036a4fbfb06dd185a3f5c8edfaacdf7d1ea10b07de6252" +dependencies = [ + "lock_api", + "parking_lot_core 0.6.2", + "rustc_version", +] + +[[package]] +name = "parking_lot" +version = "0.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3a704eb390aafdc107b0e392f56a82b668e3a71366993b5340f5833fd62505e" +dependencies = [ + "lock_api", + "parking_lot_core 0.7.2", +] + +[[package]] +name = "parking_lot_core" +version = "0.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b876b1b9e7ac6e1a74a6da34d25c42e17e8862aa409cbbbdcfc8d86c6f3bc62b" +dependencies = [ + "cfg-if", + "cloudabi", + "libc", + "redox_syscall", + "rustc_version", + "smallvec 0.6.13", + "winapi", +] + +[[package]] +name = "parking_lot_core" +version = "0.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d58c7c768d4ba344e3e8d72518ac13e259d7c7ade24167003b8488e10b6740a3" +dependencies = [ + "cfg-if", + "cloudabi", + "libc", + "redox_syscall", + "smallvec 1.4.0", + "winapi", +] + +[[package]] +name = "percent-encoding" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d4fd5641d01c8f18a23da7b6fe29298ff4b55afcccdf78973b24cf3175fee32e" + +[[package]] +name = "pkg-config" +version = "0.3.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "05da548ad6865900e60eaba7f589cc0783590a92e940c26953ff81ddbab2d677" + [[package]] name = "proc-macro-error" version = "1.0.2" @@ -292,8 +847,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "98e9e4b82e0ef281812565ea4751049f1bdcdfccda7d3f459f2e138a40c08678" dependencies = [ "proc-macro-error-attr", - "proc-macro2", - "quote", + "proc-macro2 1.0.10", + "quote 1.0.3", "syn", "version_check", ] @@ -304,20 +859,38 @@ version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4f5444ead4e9935abd7f27dc51f7e852a0569ac888096d5ec2499470794e2e53" dependencies = [ - "proc-macro2", - "quote", + "proc-macro2 1.0.10", + "quote 1.0.3", "syn", "syn-mid", "version_check", ] +[[package]] +name = "proc-macro2" +version = "0.4.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf3d2011ab5c909338f7887f4fc896d35932e29146c12c8d01da6b22a80ba759" +dependencies = [ + "unicode-xid 0.1.0", +] + [[package]] name = "proc-macro2" version = "1.0.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "df246d292ff63439fea9bc8c0a270bed0e390d5ebd4db4ba15aba81111b5abe3" dependencies = [ - "unicode-xid", + "unicode-xid 0.2.0", +] + +[[package]] +name = "quote" +version = "0.6.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ce23b6b870e8f94f81fb0a363d65d86675884b34a09043c81e5562f11c1f8e1" +dependencies = [ + "proc-macro2 0.4.30", ] [[package]] @@ -326,7 +899,16 @@ version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2bdc6c187c65bca4260c9011c9e3132efe4909da44726bad24cf7572ae338d7f" dependencies = [ - "proc-macro2", + "proc-macro2 1.0.10", +] + +[[package]] +name = "raw-window-handle" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0a441a7a6c80ad6473bd4b74ec1c9a4c951794285bf941c2126f607c72e48211" +dependencies = [ + "libc", ] [[package]] @@ -358,6 +940,71 @@ dependencies = [ "crossbeam-utils", ] +[[package]] +name = "rustc-demangle" +version = "0.1.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4c691c0e608126e00913e33f0ccf3727d5fc84573623b8d65b2df340b5201783" + +[[package]] +name = "rustc_version" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a" +dependencies = [ + "semver", +] + +[[package]] +name = "rusttype" +version = "0.7.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "310942406a39981bed7e12b09182a221a29e0990f3e7e0c971f131922ed135d5" +dependencies = [ + "rusttype 0.8.3", +] + +[[package]] +name = "rusttype" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9f61411055101f7b60ecf1041d87fb74205fb20b0c7a723f07ef39174cf6b4c0" +dependencies = [ + "approx", + "ordered-float", + "stb_truetype", +] + +[[package]] +name = "same-file" +version = "1.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "93fc1dc3aaa9bfed95e02e6eadabb4baf7e3078b0bd1b4d7b6b0b68378900502" +dependencies = [ + "winapi-util", +] + +[[package]] +name = "scopeguard" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" + +[[package]] +name = "semver" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" +dependencies = [ + "semver-parser", +] + +[[package]] +name = "semver-parser" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" + [[package]] name = "serde" version = "1.0.106" @@ -373,8 +1020,8 @@ version = "1.0.106" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9e549e3abf4fb8621bd1609f11dfc9f5e50320802273b12f3811a67e6716ea6c" dependencies = [ - "proc-macro2", - "quote", + "proc-macro2 1.0.10", + "quote 1.0.3", "syn", ] @@ -390,6 +1037,16 @@ dependencies = [ "yaml-rust", ] +[[package]] +name = "shared_library" +version = "0.1.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a9e7e0f2bfae24d8a5b5a66c5b257a83c7412304311512a0c054cd5e619da11" +dependencies = [ + "lazy_static", + "libc", +] + [[package]] name = "simplelog" version = "0.7.5" @@ -401,6 +1058,47 @@ dependencies = [ "term", ] +[[package]] +name = "smallvec" +version = "0.6.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f7b0758c52e15a8b5e3691eae6cc559f08eee9406e548a4477ba4e67770a82b6" +dependencies = [ + "maybe-uninit", +] + +[[package]] +name = "smallvec" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c7cb5678e1615754284ec264d9bb5b4c27d2018577fd90ac0ceb578591ed5ee4" + +[[package]] +name = "smithay-client-toolkit" +version = "0.4.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2ccb8c57049b2a34d2cc2b203fa785020ba0129d31920ef0d317430adaf748fa" +dependencies = [ + "andrew", + "bitflags", + "dlib", + "lazy_static", + "memmap", + "nix", + "wayland-client", + "wayland-commons", + "wayland-protocols", +] + +[[package]] +name = "stb_truetype" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f77b6b07e862c66a9f3e62a07588fee67cd90a9135a2b942409f195507b4fb51" +dependencies = [ + "byteorder", +] + [[package]] name = "string-err" version = "0.1.1" @@ -413,15 +1111,21 @@ version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a" +[[package]] +name = "strsim" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" + [[package]] name = "syn" version = "1.0.17" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0df0eb663f387145cab623dea85b09c2c5b4b0aef44e945d928e682fce71bb03" dependencies = [ - "proc-macro2", - "quote", - "unicode-xid", + "proc-macro2 1.0.10", + "quote 1.0.3", + "unicode-xid 0.2.0", ] [[package]] @@ -430,8 +1134,8 @@ version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7be3539f6c128a931cf19dcee741c1af532c7fd387baa739c03dd2e96479338a" dependencies = [ - "proc-macro2", - "quote", + "proc-macro2 1.0.10", + "quote 1.0.3", "syn", ] @@ -441,10 +1145,10 @@ version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "67656ea1dc1b41b1451851562ea232ec2e5a80242139f7e679ceccfb5d61f545" dependencies = [ - "proc-macro2", - "quote", + "proc-macro2 1.0.10", + "quote 1.0.3", "syn", - "unicode-xid", + "unicode-xid 0.2.0", ] [[package]] @@ -483,6 +1187,12 @@ version = "0.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "caaa9d531767d1ff2150b9332433f32a24622147e5ebb1f26409d5da67afd479" +[[package]] +name = "unicode-xid" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fc72304796d0818e357ead4e000d19c9c174ab23dc11093ac919054d20a6a7fc" + [[package]] name = "unicode-xid" version = "0.2.0" @@ -501,12 +1211,88 @@ version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "078775d0255232fb988e6fccf26ddc9d1ac274299aaedcedce21c6f72cc533ce" +[[package]] +name = "void" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6a02e4885ed3bc0f2de90ea6dd45ebcbb66dacffe03547fadbb0eeae2770887d" + +[[package]] +name = "walkdir" +version = "2.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "777182bc735b6424e1a57516d35ed72cb8019d85c8c9bf536dccb3445c1a2f7d" +dependencies = [ + "same-file", + "winapi", + "winapi-util", +] + [[package]] name = "wasi" version = "0.9.0+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519" +[[package]] +name = "wayland-client" +version = "0.21.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "49963e5f9eeaf637bfcd1b9f0701c99fd5cd05225eb51035550d4272806f2713" +dependencies = [ + "bitflags", + "downcast-rs", + "libc", + "nix", + "wayland-commons", + "wayland-scanner", + "wayland-sys", +] + +[[package]] +name = "wayland-commons" +version = "0.21.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "40c08896768b667e1df195d88a62a53a2d1351a1ed96188be79c196b35bb32ec" +dependencies = [ + "nix", + "wayland-sys", +] + +[[package]] +name = "wayland-protocols" +version = "0.21.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4afde2ea2a428eee6d7d2c8584fdbe8b82eee8b6c353e129a434cd6e07f42145" +dependencies = [ + "bitflags", + "wayland-client", + "wayland-commons", + "wayland-scanner", + "wayland-sys", +] + +[[package]] +name = "wayland-scanner" +version = "0.21.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bf3828c568714507315ee425a9529edc4a4aa9901409e373e9e0027e7622b79e" +dependencies = [ + "proc-macro2 0.4.30", + "quote 0.6.13", + "xml-rs", +] + +[[package]] +name = "wayland-sys" +version = "0.21.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "520ab0fd578017a0ee2206623ba9ef4afe5e8f23ca7b42f6acfba2f4e66b1628" +dependencies = [ + "dlib", + "lazy_static", +] + [[package]] name = "winapi" version = "0.3.8" @@ -523,12 +1309,70 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" +[[package]] +name = "winapi-util" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178" +dependencies = [ + "winapi", +] + [[package]] name = "winapi-x86_64-pc-windows-gnu" version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" +[[package]] +name = "winit" +version = "0.19.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e96eb4bb472fa43e718e8fa4aef82f86cd9deac9483a1e1529230babdb394a8" +dependencies = [ + "android_glue", + "backtrace", + "bitflags", + "cocoa", + "core-foundation", + "core-graphics", + "lazy_static", + "libc", + "log", + "objc", + "parking_lot 0.9.0", + "percent-encoding", + "raw-window-handle", + "smithay-client-toolkit", + "wayland-client", + "winapi", + "x11-dl", +] + +[[package]] +name = "x11-dl" +version = "2.18.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2bf981e3a5b3301209754218f962052d4d9ee97e478f4d26d4a6eced34c1fef8" +dependencies = [ + "lazy_static", + "libc", + "maybe-uninit", + "pkg-config", +] + +[[package]] +name = "xdg" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d089681aa106a86fade1b0128fb5daf07d5867a509ab036d99988dec80429a57" + +[[package]] +name = "xml-rs" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b07db065a5cf61a7e4ba64f29e67db906fb1787316516c4e6e5ff0fea1efcd8a" + [[package]] name = "yaml-rust" version = "0.4.3" diff --git a/Cargo.toml b/Cargo.toml index 027aab7..f5dc41e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -12,10 +12,22 @@ path = "src/extractor/main.rs" name = "patcher" path = "src/patcher/main.rs" +[[bin]] +name = "card-editor" +path = "src/card-editor/main.rs" + [dependencies] # Dcb dcb = { path = "../dcb" } +# Text +ascii = "1.0" +strsim = "0.10" + +# Helpers +float-ord = "0.2" +itertools = "0.9" + # Cmd clap = "2.33" @@ -33,6 +45,16 @@ derive_more = "0.99" # Serde serde_yaml = "0.8" +# Window / Ui +gfx = "0.18" +gfx_device_gl = "0.16" +gfx_window_glutin = "0.31" +glutin = "0.21" +#image = "0.23" +imgui = "0.3" +imgui-gfx-renderer = "0.3" +imgui-winit-support = { version = "0.3", default-features = false, features = ["winit-19"] } + # Build dependencies in release mode [profile.dev.package."*"] opt-level = 2 diff --git a/src/card-editor/cli.rs b/src/card-editor/cli.rs new file mode 100644 index 0000000..cebe9e7 --- /dev/null +++ b/src/card-editor/cli.rs @@ -0,0 +1,41 @@ +//! Cli manager for the extractor + +// Filesystem +use std::path::{Path, PathBuf}; + +// Clap +use clap::{App as ClapApp, Arg as ClapArg}; + +/// Data from the command line +#[derive(PartialEq, Clone, Debug)] +pub struct CliData { + /// The data directory + pub data_dir: PathBuf, +} + +impl CliData { + /// Constructs all of the cli data given and returns it + pub fn new() -> Self { + // Get all matches from cli + let matches = ClapApp::new("Dcb Card Editor") + .version("0.0") + .author("Filipe [...] <[...]@gmail.com>") + .about("Edits card data from Digimon Digital Card Battle extracted files") + .arg( + ClapArg::with_name("INPUT") + .help("Sets the Data directory to use") + .short("i") + .long("input") + .index(1) + .takes_value(true) + .required(true), + ) + .get_matches(); + + // Get the data dir as either an input or the current directory + let data_dir = matches.value_of("INPUT").map_or_else(|| Path::new("."), Path::new).to_path_buf(); + + // Return the cli data + Self { data_dir } + } +} diff --git a/src/card-editor/main.rs b/src/card-editor/main.rs new file mode 100644 index 0000000..302c531 --- /dev/null +++ b/src/card-editor/main.rs @@ -0,0 +1,282 @@ +//! Data patches +//! +//! # Details +//! Patches data to the game file from several other files. +//! +//! # Syntax +//! The executable may be called as `./patcher ` +//! +//! Use the command `./patcher --help` for more information. +//! +//! # Data patched +//! Currently only the following is patched: +//! - Card table + +// Features +#![feature(box_syntax, backtrace, panic_info_message, bool_to_option)] +// Lints +#![warn(clippy::restriction, clippy::pedantic, clippy::nursery)] +#![allow( + clippy::implicit_return, // We prefer implicit returns where possible + clippy::module_name_repetitions, // This happens often due to separating things into modules finely + clippy::wildcard_enum_match_arm, // We only use wildcards when we truly only care about some variants + clippy::result_expect_used, + clippy::option_expect_used, // We use expect when there is no alternative. + clippy::used_underscore_binding, // Useful for macros and such + clippy::integer_arithmetic, + clippy::float_arithmetic, // We need to use numbers my guy + clippy::as_conversions, + clippy::cast_sign_loss, + clippy::cast_possible_wrap, + clippy::cast_possible_truncation, // Needed for converting between stuff + clippy::items_after_statements, +)] + +// Modules +mod cli; +#[path = "../logger.rs"] +mod logger; +#[path = "../panic.rs"] +mod panic; + +// Gfx / GLutin +use gfx::Device; +use glutin::{Event, WindowEvent}; + +// Imgui +use imgui::{Context, FontConfig, FontGlyphRanges, FontSource, ImString}; +use imgui_gfx_renderer::{Renderer, Shaders}; +use imgui_winit_support::{HiDpiMode, WinitPlatform}; + +// Errors +use err_backtrace::ErrBacktraceExt; +use err_ext::ResultExt; +use err_panic::ErrorExtPanic; + +// Itertools +use itertools::Itertools; + +// Dcb +use dcb::game::{card::Table as CardTable, deck::Table as DeckTable}; + +#[allow(clippy::too_many_lines)] // TODO: Fix +fn main() { + // Initialize the logger and set the panic handler + logger::init(); + std::panic::set_hook(box panic::log_handler); + + // Get all data from cli + let cli::CliData { data_dir } = cli::CliData::new(); + + // Load all data files + let cards_table_file = std::fs::File::open(data_dir.join("cards.yaml")).panic_err_msg("Unable to open `cards.yaml`"); + let decks_table_file = std::fs::File::open(data_dir.join("decks.yaml")).panic_err_msg("Unable to open `decks.yaml`"); + + // Parse everything from yaml + let mut cards_table: CardTable = serde_yaml::from_reader(cards_table_file).panic_err_msg("Unable to parse `cards.yaml`"); + let decks_table: DeckTable = serde_yaml::from_reader(decks_table_file).panic_err_msg("Unable to parse `decks.yaml`"); + + // Create a new window + let mut events_loop = glutin::EventsLoop::new(); + let builder = glutin::WindowBuilder::new() + .with_title("Dcb Card Editor") + .with_dimensions(glutin::dpi::LogicalSize::new(1024.0, 768.0)); + let context = glutin::ContextBuilder::new().with_vsync(true); + let (windowed_context, mut device, mut factory, mut main_color, mut main_depth) = + gfx_window_glutin::init::(builder, context, &events_loop) + .panic_err_msg("Failed to initialize graphics"); + let mut encoder: gfx::Encoder<_, _> = factory.create_command_buffer().into(); + let shaders = { + let version = device.get_info().shading_language; + if version.is_embedded { + if version.major >= 3 { + Shaders::GlSlEs300 + } else { + Shaders::GlSlEs100 + } + } else if version.major >= 4 { + Shaders::GlSl400 + } else if version.major >= 3 { + if version.minor >= 2 { + Shaders::GlSl150 + } else { + Shaders::GlSl130 + } + } else { + Shaders::GlSl110 + } + }; + + // Create a new context for `imgui` + let mut imgui_context = Context::create(); + let mut platform = WinitPlatform::init(&mut imgui_context); + + // Add our font to imgui + let hidpi_factor = platform.hidpi_factor(); + let font_size = (13.0 * hidpi_factor) as f32; + imgui_context.fonts().add_font(&[ + FontSource::DefaultFontData { + config: Some(FontConfig { + size_pixels: font_size, + ..FontConfig::default() + }), + }, + FontSource::TtfData { + data: include_bytes!("../../resources/OpenSans-Regular.ttf"), + size_pixels: font_size, + config: Some(FontConfig { + rasterizer_multiply: 1.75, + glyph_ranges: FontGlyphRanges::japanese(), + ..FontConfig::default() + }), + }, + ]); + imgui_context.io_mut().font_global_scale = (1.0 / hidpi_factor) as f32; + + // Fix `sRGB` on style colors + let style = imgui_context.style_mut(); + #[allow(clippy::indexing_slicing)] // False positive, this is a `[f32; 4]` + for color in style.colors.iter_mut() { + color[0] = color[0].powf(2.2); + color[1] = color[1].powf(2.2); + color[2] = color[2].powf(2.2); + color[3] = 1.0 - (1.0 - color[3]).powf(2.2); + } + + // Attach the window to the platform + let mut renderer = Renderer::init(&mut imgui_context, &mut factory, shaders).panic_err_msg("Unable to initialize renderer"); + platform.attach_window(imgui_context.io_mut(), windowed_context.window(), HiDpiMode::Rounded); + + let mut last_frame = std::time::Instant::now(); + let mut run = true; + + // Get all digimon names as `ImString`s + let mut digimon_names: Vec<_> = cards_table.digimons.iter().map(|digimon| ImString::new(digimon.name.clone())).collect(); + let mut digimon_filter_idx = 0; + let mut digimon_filter_search = ImString::new(""); + + while run { + // Check for events + events_loop.poll_events(|event| { + platform.handle_event(imgui_context.io_mut(), windowed_context.window(), &event); + + if let Event::WindowEvent { event, .. } = event { + match event { + WindowEvent::Resized(_) => { + gfx_window_glutin::update_views(&windowed_context, &mut main_color, &mut main_depth); + }, + WindowEvent::CloseRequested => run = false, + _ => (), + } + } + }); + + // Prepare and execute ui frame + let io = imgui_context.io_mut(); + platform + .prepare_frame(io, windowed_context.window()) + .ignore_with_err(|err| log::warn!("Unable to prepare frame: {}", err)); + last_frame = io.update_delta_time(last_frame); + let ui = imgui_context.frame(); + { + ui.text("Digimon: "); + + ui.input_text(imgui::im_str!("Digimon Filter"), &mut digimon_filter_search) + .resize_buffer(true) + .build(); + + let digimon_filters: Vec<_> = digimon_names + .iter() + .enumerate() + .map(|(idx, string)| { + ( + float_ord::FloatOrd(1.0 - strsim::jaro(string.to_str(), digimon_filter_search.to_str())), + string, + idx, + ) + }) + .sorted() + .collect(); + + let digimon_filter_names: Vec<_> = digimon_filters + .iter() + .filter_map(|(value, string, _)| (digimon_filter_search.is_empty() || value.0 < 0.5).then_some(string)) + .collect(); + + ui.list_box( + imgui::im_str!("Digimon List"), + &mut digimon_filter_idx, + digimon_filter_names.as_slice(), + 4, + ); + + ui.separator(); + + /* + if let Some((_, _, idx)) = digimon_filters.get(digimon_filter_idx as usize) { + let idx = *idx; + std::mem::drop(digimon_filters); + if let Some(digimon_name_buffer) = digimon_names.get_mut(idx) { + if ui.input_text(imgui::im_str!("Name"), digimon_name_buffer).resize_buffer(true).build() { + if let Some(digimon) = cards_table.digimons.get_mut(idx) { + match ascii::AsciiString::from_ascii(digimon_name_buffer.to_string()) { + Ok(name) => { + digimon.name = name; + }, + Err(err) => { + ui.text(format!("Unable to set digimon name:\n{}", err.err_backtrace())); + }, + } + } + } + } + } + */ + + //if let Some(digimon_name) = digimon_names.iter_mut().enumerate().find(|(_, name)| name == ) + + /* + if let Some((idx, digimon)) = cards_table.digimons.iter_mut().enumerate().find(|(_, digimon)| { + digimon_filter_names + .get(digimon_filter_idx as usize) + .map_or(false, |&name| name.to_str() == digimon.name) + }) { + let mut name_buffer = ImString::new(digimon.name.clone()); + if ui.input_text(imgui::im_str!("Name"), &mut name_buffer).resize_buffer(true).build() { + match ascii::AsciiString::from_ascii(name_buffer.to_string()) { + Ok(name) => { + digimon.name = name; + if let Some(name) = digimon_names.get_mut(idx) { + *name = name_buffer.clone(); + } + }, + Err(err) => { + ui.text(format!("Unable to set digimon name:\n{}", err.err_backtrace())); + }, + } + } + } + */ + } + + // Clear, render everything and flush it out + encoder.clear(&main_color, [0.2, 0.2, 0.2, 1.0]); + platform.prepare_render(&ui, windowed_context.window()); + renderer + .render(&mut factory, &mut encoder, &mut main_color, ui.render()) + .ignore_with_err(|err| log::warn!("Unable to render: {}", err.err_backtrace())); + encoder.flush(&mut device); + windowed_context + .swap_buffers() + .ignore_with_err(|err| log::warn!("Unable to swap buffers: {}", err.err_backtrace())); + device.cleanup(); + } + + // Convert everything back to yaml + let cards_table_yaml = serde_yaml::to_string(&cards_table).panic_err_msg("Unable to serialize cards table to yaml"); + let decks_table_yaml = serde_yaml::to_string(&decks_table).panic_err_msg("Unable to serialize decks table to yaml"); + + // Ouput all data to devices + std::fs::write(&data_dir.join("cards.yaml"), cards_table_yaml).panic_err_msg("Unable to write cards table to file"); + std::fs::write(&data_dir.join("decks.yaml"), decks_table_yaml).panic_err_msg("Unable to write decks table to file"); +} diff --git a/src/extractor/main.rs b/src/extractor/main.rs index e998570..cbb5f7a 100644 --- a/src/extractor/main.rs +++ b/src/extractor/main.rs @@ -28,6 +28,9 @@ // Modules mod cli; +#[path = "../logger.rs"] +mod logger; +#[path = "../panic.rs"] mod panic; // Exports @@ -40,12 +43,11 @@ use dcb::{ }; // Errors -use err_ext::ResultExt; use err_panic::ErrorExtPanic; fn main() { // Initialize the logger and set the panic handler - init_logger(); + logger::init(); std::panic::set_hook(box panic::log_handler); // Get all data from cli @@ -68,25 +70,3 @@ fn main() { std::fs::write(&output_dir.join("cards.yaml"), cards_table_yaml).panic_err_msg("Unable to write cards table to file"); std::fs::write(&output_dir.join("decks.yaml"), decks_table_yaml).panic_err_msg("Unable to write decks table to file"); } - -/// Initializes the global logger -fn init_logger() { - use log::LevelFilter::{Info, Trace}; - use simplelog::{CombinedLogger, Config, SharedLogger, TermLogger, TerminalMode, WriteLogger}; - use std::convert::identity; - /// The type of logger required to pass to `CombinedLogger::init` - type BoxedLogger = Box; - - // All loggers to try and initialize - let loggers: Vec> = vec![ - TermLogger::new(Info, Config::default(), TerminalMode::Mixed).map(|logger| BoxedLogger::from(logger)), - std::fs::File::create("latest.log") - .ok() - .map(|file| WriteLogger::new(Trace, Config::default(), file)) - .map(|logger| BoxedLogger::from(logger)), - ]; - - // Filter all logger that actually work and initialize them - CombinedLogger::init(loggers.into_iter().filter_map(identity).collect()) - .ignore_with_err(|_| log::warn!("Logger was already initialized at the start of the program")); -} diff --git a/src/logger.rs b/src/logger.rs new file mode 100644 index 0000000..be7bff5 --- /dev/null +++ b/src/logger.rs @@ -0,0 +1,27 @@ +//! Logger initialization + +// Log +use log::LevelFilter; +use simplelog::{CombinedLogger, Config, SharedLogger, TermLogger, TerminalMode, WriteLogger}; + +// Error +use err_ext::ResultExt; + +/// The type of logger required to pass to `CombinedLogger::init` +type BoxedLogger = Box; + +/// Initializes the global logger +pub fn init() { + // All loggers to try and initialize + let loggers: Vec> = vec![ + TermLogger::new(LevelFilter::Warn, Config::default(), TerminalMode::Mixed).map(|logger| BoxedLogger::from(logger)), + std::fs::File::create("latest.log") + .ok() + .map(|file| WriteLogger::new(LevelFilter::Trace, Config::default(), file)) + .map(|logger| BoxedLogger::from(logger)), + ]; + + // Filter all logger that actually work and initialize them + CombinedLogger::init(loggers.into_iter().filter_map(std::convert::identity).collect()) + .ignore_with_err(|_| log::warn!("Logger was already initialized at the start of the program")); +} diff --git a/src/extractor/panic.rs b/src/panic.rs similarity index 100% rename from src/extractor/panic.rs rename to src/panic.rs diff --git a/src/patcher/main.rs b/src/patcher/main.rs index 4429111..09db450 100644 --- a/src/patcher/main.rs +++ b/src/patcher/main.rs @@ -27,6 +27,9 @@ // Modules mod cli; +#[path = "../logger.rs"] +mod logger; +#[path = "../panic.rs"] mod panic; // Exports @@ -39,12 +42,11 @@ use dcb::{ }; // Errors -use err_ext::ResultExt; use err_panic::ErrorExtPanic; fn main() { // Initialize the logger and set the panic handler - init_logger(); + logger::init(); std::panic::set_hook(box panic::log_handler); // Get all data from cli @@ -70,25 +72,3 @@ fn main() { cards_table.serialize(&mut game_file).panic_err_msg("Unable to serialize cards table"); decks_table.serialize(&mut game_file).panic_err_msg("Unable to serialize decks table"); } - -/// Initializes the global logger -fn init_logger() { - use log::LevelFilter::{Info, Trace}; - use simplelog::{CombinedLogger, Config, SharedLogger, TermLogger, TerminalMode, WriteLogger}; - use std::convert::identity; - /// The type of logger required to pass to `CombinedLogger::init` - type BoxedLogger = Box; - - // All loggers to try and initialize - let loggers: Vec> = vec![ - TermLogger::new(Info, Config::default(), TerminalMode::Mixed).map(|logger| BoxedLogger::from(logger)), - std::fs::File::create("latest.log") - .ok() - .map(|file| WriteLogger::new(Trace, Config::default(), file)) - .map(|logger| BoxedLogger::from(logger)), - ]; - - // Filter all logger that actually work and initialize them - CombinedLogger::init(loggers.into_iter().filter_map(identity).collect()) - .ignore_with_err(|_| log::warn!("Logger was already initialized at the start of the program")); -} diff --git a/src/patcher/panic.rs b/src/patcher/panic.rs deleted file mode 100644 index 10657ef..0000000 --- a/src/patcher/panic.rs +++ /dev/null @@ -1,31 +0,0 @@ -//! Panic handlers for this application - -// Std -use std::{ - backtrace::{Backtrace, BacktraceStatus}, - error::Error, -}; -// Error backtrace -use err_backtrace::ErrBacktraceExt; - -/// Panic handler based on logging to the current initialization -pub fn log_handler(info: &std::panic::PanicInfo) { - // Log that this thread has panicked - log::error!("Thread \"{}\" panicked", std::thread::current().name().unwrap_or("[Unknown]")); - - // Log any message that came with the panic - log::info!("Panic message: {}", info.message().unwrap_or(&format_args!("None"))); - - // Print an error backtrace if we found any - if let Some(err) = info.payload().downcast_ref::>() { - log::info!("Error backtrace:\n{}", err.err_backtrace()); - } - - // And print a backtrace of where this panic occured. - let backtrace = Backtrace::force_capture(); - if backtrace.status() == BacktraceStatus::Captured { - log::info!("Backtrace:\n{}", backtrace); - } else { - log::info!("Unable to get backtrace: {}", backtrace); - } -} From 5ad5eb37f127fc091fb34d01f3dca2b3c4af1b5f Mon Sep 17 00:00:00 2001 From: Filipe Rodrigues Date: Wed, 13 May 2020 15:02:46 +0100 Subject: [PATCH 09/12] Removed `card-editor`. Changed `err-impl` to a git dependency. --- Cargo.lock | 897 ++++------------------------------------ Cargo.toml | 22 +- src/card-editor/cli.rs | 41 -- src/card-editor/main.rs | 282 ------------- 4 files changed, 76 insertions(+), 1166 deletions(-) delete mode 100644 src/card-editor/cli.rs delete mode 100644 src/card-editor/main.rs diff --git a/Cargo.lock b/Cargo.lock index 2c58cb7..4fff96b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1,25 +1,5 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. -[[package]] -name = "andrew" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b7f09f89872c2b6b29e319377b1fbe91c6f5947df19a25596e121cf19a7b35e" -dependencies = [ - "bitflags", - "line_drawing", - "rusttype 0.7.9", - "walkdir", - "xdg", - "xml-rs", -] - -[[package]] -name = "android_glue" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "000444226fcff248f2bc4c7625be32c63caccfecc2723a2b9f78a7487a49c407" - [[package]] name = "ansi_term" version = "0.11.0" @@ -29,15 +9,6 @@ dependencies = [ "winapi", ] -[[package]] -name = "approx" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f0e60b75072ecd4168020818c0107f2857bb6c4e64252d8d3983f6263b40a5c3" -dependencies = [ - "num-traits", -] - [[package]] name = "arrayref" version = "0.3.6" @@ -76,28 +47,6 @@ version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f8aac770f1885fd7e387acedd76065302551364496e46b3dd00860b2f8359b9d" -[[package]] -name = "backtrace" -version = "0.3.46" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b1e692897359247cc6bb902933361652380af0f1b7651ae5c5013407f30e109e" -dependencies = [ - "backtrace-sys", - "cfg-if", - "libc", - "rustc-demangle", -] - -[[package]] -name = "backtrace-sys" -version = "0.1.37" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "18fbebbe1c9d1f383a9cc7e8ccdb471b91c8d024ee9c2ca5b5346121fe8b4399" -dependencies = [ - "cc", - "libc", -] - [[package]] name = "base64" version = "0.11.0" @@ -121,40 +70,18 @@ dependencies = [ "constant_time_eq", ] -[[package]] -name = "block" -version = "0.1.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0d8c1fef690941d3e7788d328517591fecc684c084084702d6ff1641e993699a" - [[package]] name = "byteorder" version = "1.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "08c48aae112d48ed9f069b33538ea9e3e90aa263cfa3d1c24309612b1f7472de" -[[package]] -name = "cc" -version = "1.0.52" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3d87b23d6a92cd03af510a5ade527033f6aa6fa92161e2d5863a907d4c5e31d" - [[package]] name = "cfg-if" version = "0.1.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822" -[[package]] -name = "cgl" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "55e7ec0b74fe5897894cbc207092c577e87c52f8a59e8ca8d97ef37551f60a49" -dependencies = [ - "gleam", - "libc", -] - [[package]] name = "chrono" version = "0.4.11" @@ -175,70 +102,18 @@ dependencies = [ "ansi_term", "atty", "bitflags", - "strsim 0.8.0", + "strsim", "textwrap", "unicode-width", "vec_map", ] -[[package]] -name = "cloudabi" -version = "0.0.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ddfc5b9aa5d4507acaf872de71051dfd0e309860e88966e1051e462a077aac4f" -dependencies = [ - "bitflags", -] - -[[package]] -name = "cocoa" -version = "0.18.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1706996401131526e36b3b49f0c4d912639ce110996f3ca144d78946727bce54" -dependencies = [ - "bitflags", - "block", - "core-foundation", - "core-graphics", - "foreign-types", - "libc", - "objc", -] - [[package]] name = "constant_time_eq" version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "245097e9a4535ee1e3e3931fcfcd55a796a44c643e8596ff6566d68f09b87bbc" -[[package]] -name = "core-foundation" -version = "0.6.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "25b9e03f145fd4f2bf705e07b900cd41fc636598fe5dc452fd0db1441c3f496d" -dependencies = [ - "core-foundation-sys", - "libc", -] - -[[package]] -name = "core-foundation-sys" -version = "0.6.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e7ca8a5221364ef15ce201e8ed2f609fc312682a8f4e0e3d4aa5879764e0fa3b" - -[[package]] -name = "core-graphics" -version = "0.17.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "56790968ab1c8a1202a102e6de05fc6e1ec87da99e4e93e9a7d13efbfc1e95a9" -dependencies = [ - "bitflags", - "core-foundation", - "foreign-types", - "libc", -] - [[package]] name = "crossbeam-utils" version = "0.7.2" @@ -273,21 +148,17 @@ dependencies = [ "derive_more", "err-backtrace", "err-ext", + "err-impl", "err-panic", "float-ord", - "gfx", - "gfx_device_gl", - "gfx_window_glutin", - "glutin", - "imgui", - "imgui-gfx-renderer", - "imgui-winit-support", "itertools", "log", + "rand", + "serde", "serde_yaml", "simplelog", + "smart-default", "string-err", - "strsim 0.10.0", ] [[package]] @@ -296,8 +167,8 @@ version = "0.99.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e2323f3f47db9a0e77ce7a300605d8d2098597fc451ed1a97bb1f6411bb550a7" dependencies = [ - "proc-macro2 1.0.10", - "quote 1.0.3", + "proc-macro2", + "quote", "syn", ] @@ -323,30 +194,6 @@ dependencies = [ "winapi", ] -[[package]] -name = "dlib" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77e51249a9d823a4cb79e3eca6dcd756153e8ed0157b6c04775d04bf1b13b76a" -dependencies = [ - "libloading", -] - -[[package]] -name = "downcast-rs" -version = "1.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "52ba6eb47c2131e784a38b726eb54c1e1484904f013e576a25354d0124161af6" - -[[package]] -name = "draw_state" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "33cf9537e2d06891448799b96d5a8c8083e0e90522a7fdabe6ebf4f41d79d651" -dependencies = [ - "bitflags", -] - [[package]] name = "dtoa" version = "0.4.5" @@ -370,10 +217,11 @@ version = "0.1.0" [[package]] name = "err-impl" version = "0.1.0" +source = "git+https://github.com/Zenithsiz/err-impl#188a95b85272fc087794c7f7f0972e146a1d350e" dependencies = [ "proc-macro-error", - "proc-macro2 1.0.10", - "quote 1.0.3", + "proc-macro2", + "quote", "syn", "synstructure", ] @@ -391,21 +239,6 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7bad48618fdb549078c333a7a8528acb57af271d0433bdecd523eb620628364e" -[[package]] -name = "foreign-types" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f6f339eb8adc052cd2ca78910fda869aefa38d22d5cb648e6485e4d3fc06f3b1" -dependencies = [ - "foreign-types-shared", -] - -[[package]] -name = "foreign-types-shared" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b" - [[package]] name = "getrandom" version = "0.1.14" @@ -417,161 +250,6 @@ dependencies = [ "wasi", ] -[[package]] -name = "gfx" -version = "0.18.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "01de46f9508a5c259aef105f0bff760ceddca832ea9c87ce03d1923e22ee155b" -dependencies = [ - "draw_state", - "gfx_core", - "log", -] - -[[package]] -name = "gfx_core" -version = "0.9.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "75fbddaef2e12b4995900539d7209d947b988a3d87ee8737484d049b526e5441" -dependencies = [ - "bitflags", - "draw_state", - "log", -] - -[[package]] -name = "gfx_device_gl" -version = "0.16.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "109c385fa380c18888633aa27d1e16cbae518469702a2f69dcb5f52d5378bebc" -dependencies = [ - "gfx_core", - "gfx_gl", - "log", -] - -[[package]] -name = "gfx_gl" -version = "0.6.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f2d38164670920cfb7491bc0cf6f49f0554bd1c44cdbedc6c78d2bf91691ff5e" -dependencies = [ - "gl_generator 0.14.0", -] - -[[package]] -name = "gfx_window_glutin" -version = "0.31.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "310ff66f08b5a55854b18fea2f48bdbb75c94458207ba574c9723be78e97a646" -dependencies = [ - "gfx_core", - "gfx_device_gl", - "glutin", -] - -[[package]] -name = "gl_generator" -version = "0.13.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca98bbde17256e02d17336a6bdb5a50f7d0ccacee502e191d3e3d0ec2f96f84a" -dependencies = [ - "khronos_api", - "log", - "xml-rs", -] - -[[package]] -name = "gl_generator" -version = "0.14.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a95dfc23a2b4a9a2f5ab41d194f8bfda3cabec42af4e39f08c339eb2a0c124d" -dependencies = [ - "khronos_api", - "log", - "xml-rs", -] - -[[package]] -name = "gleam" -version = "0.6.19" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cae10d7c99d0e77b4766e850a60898a17c1abaf01075531f1066f03dc7dc5fc5" -dependencies = [ - "gl_generator 0.13.1", -] - -[[package]] -name = "glutin" -version = "0.21.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5371b35b309dace06be1b81b5f6adb1c9de578b7dbe1e74bf7e4ef762cf6febd" -dependencies = [ - "android_glue", - "cgl", - "cocoa", - "core-foundation", - "core-graphics", - "glutin_egl_sys", - "glutin_emscripten_sys", - "glutin_gles2_sys", - "glutin_glx_sys", - "glutin_wgl_sys", - "lazy_static", - "libloading", - "objc", - "osmesa-sys", - "parking_lot 0.9.0", - "wayland-client", - "winapi", - "winit", -] - -[[package]] -name = "glutin_egl_sys" -version = "0.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "772edef3b28b8ad41e4ea202748e65eefe8e5ffd1f4535f1219793dbb20b3d4c" -dependencies = [ - "gl_generator 0.13.1", - "winapi", -] - -[[package]] -name = "glutin_emscripten_sys" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "80de4146df76e8a6c32b03007bc764ff3249dcaeb4f675d68a06caf1bac363f1" - -[[package]] -name = "glutin_gles2_sys" -version = "0.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "07e853d96bebcb8e53e445225c3009758c6f5960d44f2543245f6f07b567dae0" -dependencies = [ - "gl_generator 0.13.1", - "objc", -] - -[[package]] -name = "glutin_glx_sys" -version = "0.1.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "08c243de74d6cf5ea100c788826d2fb9319de315485dd4b310811a663b3809c3" -dependencies = [ - "gl_generator 0.13.1", - "x11-dl", -] - -[[package]] -name = "glutin_wgl_sys" -version = "0.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a93dba7ee3a0feeac0f437141ff25e71ce2066bcf1a706acab1559ffff94eb6a" -dependencies = [ - "gl_generator 0.13.1", -] - [[package]] name = "hermit-abi" version = "0.1.10" @@ -581,49 +259,6 @@ dependencies = [ "libc", ] -[[package]] -name = "imgui" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a2d28cee2982d4dab4dd954c23be339ab1f98be4ff5a13ecd8fbfb47cdfa23a" -dependencies = [ - "bitflags", - "gfx", - "imgui-sys", - "lazy_static", - "parking_lot 0.10.2", -] - -[[package]] -name = "imgui-gfx-renderer" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "506eae7244a06bc18273634d1c30e070bdf592f5e7fb1f6871d062ad17a4b2ec" -dependencies = [ - "gfx", - "imgui", - "winapi", -] - -[[package]] -name = "imgui-sys" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "21a8693e0f66ecd2ec10e2f0ed4dc4519071495f350e6d8ddaf3e70351229257" -dependencies = [ - "cc", -] - -[[package]] -name = "imgui-winit-support" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5685c7d17aee9555377f9c4f7b6fac96899a7015f6b41950c613a3df034aff08" -dependencies = [ - "imgui", - "winit", -] - [[package]] name = "itertools" version = "0.9.0" @@ -633,12 +268,6 @@ dependencies = [ "either", ] -[[package]] -name = "khronos_api" -version = "3.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2db585e1d738fc771bf08a151420d3ed193d9d895a36df7f6f8a9456b911ddc" - [[package]] name = "lazy_static" version = "1.4.0" @@ -651,40 +280,12 @@ version = "0.2.68" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dea0c0405123bba743ee3f91f49b1c7cfb684eef0da0a50110f758ccf24cdff0" -[[package]] -name = "libloading" -version = "0.5.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f2b111a074963af1d37a139918ac6d49ad1d0d5e47f72fd55388619691a7d753" -dependencies = [ - "cc", - "winapi", -] - -[[package]] -name = "line_drawing" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5cc7ad3d82c845bdb5dde34ffdcc7a5fb4d2996e1e1ee0f19c33bc80e15196b9" -dependencies = [ - "num-traits", -] - [[package]] name = "linked-hash-map" version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ae91b68aebc4ddb91978b11a1b02ddd8602a05ec19002801c5666000e05e0f83" -[[package]] -name = "lock_api" -version = "0.3.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c4da24a77a3d8a6d4862d95f72e6fdb9c09a643ecdb402d754004a557f2bec75" -dependencies = [ - "scopeguard", -] - [[package]] name = "log" version = "0.4.8" @@ -694,44 +295,6 @@ dependencies = [ "cfg-if", ] -[[package]] -name = "malloc_buf" -version = "0.0.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62bb907fe88d54d8d9ce32a3cceab4218ed2f6b7d35617cafe9adf84e43919cb" -dependencies = [ - "libc", -] - -[[package]] -name = "maybe-uninit" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "60302e4db3a61da70c0cb7991976248362f30319e88850c487b9b95bbf059e00" - -[[package]] -name = "memmap" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6585fd95e7bb50d6cc31e20d4cf9afb4e2ba16c5846fc76793f11218da9c475b" -dependencies = [ - "libc", - "winapi", -] - -[[package]] -name = "nix" -version = "0.14.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c722bee1037d430d0f8e687bbdbf222f27cc6e4e68d5caf630857bb2b6dbdce" -dependencies = [ - "bitflags", - "cc", - "cfg-if", - "libc", - "void", -] - [[package]] name = "num-integer" version = "0.1.42" @@ -752,93 +315,10 @@ dependencies = [ ] [[package]] -name = "objc" -version = "0.2.7" +name = "ppv-lite86" +version = "0.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "915b1b472bc21c53464d6c8461c9d3af805ba1ef837e1cac254428f4a77177b1" -dependencies = [ - "malloc_buf", -] - -[[package]] -name = "ordered-float" -version = "1.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "18869315e81473c951eb56ad5558bbc56978562d3ecfb87abb7a1e944cea4518" -dependencies = [ - "num-traits", -] - -[[package]] -name = "osmesa-sys" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "88cfece6e95d2e717e0872a7f53a8684712ad13822a7979bc760b9c77ec0013b" -dependencies = [ - "shared_library", -] - -[[package]] -name = "parking_lot" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f842b1982eb6c2fe34036a4fbfb06dd185a3f5c8edfaacdf7d1ea10b07de6252" -dependencies = [ - "lock_api", - "parking_lot_core 0.6.2", - "rustc_version", -] - -[[package]] -name = "parking_lot" -version = "0.10.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d3a704eb390aafdc107b0e392f56a82b668e3a71366993b5340f5833fd62505e" -dependencies = [ - "lock_api", - "parking_lot_core 0.7.2", -] - -[[package]] -name = "parking_lot_core" -version = "0.6.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b876b1b9e7ac6e1a74a6da34d25c42e17e8862aa409cbbbdcfc8d86c6f3bc62b" -dependencies = [ - "cfg-if", - "cloudabi", - "libc", - "redox_syscall", - "rustc_version", - "smallvec 0.6.13", - "winapi", -] - -[[package]] -name = "parking_lot_core" -version = "0.7.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d58c7c768d4ba344e3e8d72518ac13e259d7c7ade24167003b8488e10b6740a3" -dependencies = [ - "cfg-if", - "cloudabi", - "libc", - "redox_syscall", - "smallvec 1.4.0", - "winapi", -] - -[[package]] -name = "percent-encoding" -version = "2.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d4fd5641d01c8f18a23da7b6fe29298ff4b55afcccdf78973b24cf3175fee32e" - -[[package]] -name = "pkg-config" -version = "0.3.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05da548ad6865900e60eaba7f589cc0783590a92e940c26953ff81ddbab2d677" +checksum = "74490b50b9fbe561ac330df47c08f3f33073d2d00c150f719147d7c54522fa1b" [[package]] name = "proc-macro-error" @@ -847,8 +327,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "98e9e4b82e0ef281812565ea4751049f1bdcdfccda7d3f459f2e138a40c08678" dependencies = [ "proc-macro-error-attr", - "proc-macro2 1.0.10", - "quote 1.0.3", + "proc-macro2", + "quote", "syn", "version_check", ] @@ -859,38 +339,20 @@ version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4f5444ead4e9935abd7f27dc51f7e852a0569ac888096d5ec2499470794e2e53" dependencies = [ - "proc-macro2 1.0.10", - "quote 1.0.3", + "proc-macro2", + "quote", "syn", "syn-mid", "version_check", ] -[[package]] -name = "proc-macro2" -version = "0.4.30" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf3d2011ab5c909338f7887f4fc896d35932e29146c12c8d01da6b22a80ba759" -dependencies = [ - "unicode-xid 0.1.0", -] - [[package]] name = "proc-macro2" version = "1.0.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "df246d292ff63439fea9bc8c0a270bed0e390d5ebd4db4ba15aba81111b5abe3" dependencies = [ - "unicode-xid 0.2.0", -] - -[[package]] -name = "quote" -version = "0.6.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ce23b6b870e8f94f81fb0a363d65d86675884b34a09043c81e5562f11c1f8e1" -dependencies = [ - "proc-macro2 0.4.30", + "unicode-xid", ] [[package]] @@ -899,16 +361,48 @@ version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2bdc6c187c65bca4260c9011c9e3132efe4909da44726bad24cf7572ae338d7f" dependencies = [ - "proc-macro2 1.0.10", + "proc-macro2", ] [[package]] -name = "raw-window-handle" -version = "0.3.3" +name = "rand" +version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0a441a7a6c80ad6473bd4b74ec1c9a4c951794285bf941c2126f607c72e48211" +checksum = "6a6b1679d49b24bbfe0c803429aa1874472f50d9b363131f0e89fc356b544d03" dependencies = [ + "getrandom", "libc", + "rand_chacha", + "rand_core", + "rand_hc", +] + +[[package]] +name = "rand_chacha" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f4c8ed856279c9737206bf725bf36935d8666ead7aa69b52be55af369d193402" +dependencies = [ + "ppv-lite86", + "rand_core", +] + +[[package]] +name = "rand_core" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "90bde5296fc891b0cef12a6d03ddccc162ce7b2aff54160af9338f8d40df6d19" +dependencies = [ + "getrandom", +] + +[[package]] +name = "rand_hc" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ca3129af7b92a17112d59ad498c6f81eaf463253766b90396d39ea7a39d6613c" +dependencies = [ + "rand_core", ] [[package]] @@ -940,71 +434,6 @@ dependencies = [ "crossbeam-utils", ] -[[package]] -name = "rustc-demangle" -version = "0.1.16" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c691c0e608126e00913e33f0ccf3727d5fc84573623b8d65b2df340b5201783" - -[[package]] -name = "rustc_version" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a" -dependencies = [ - "semver", -] - -[[package]] -name = "rusttype" -version = "0.7.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "310942406a39981bed7e12b09182a221a29e0990f3e7e0c971f131922ed135d5" -dependencies = [ - "rusttype 0.8.3", -] - -[[package]] -name = "rusttype" -version = "0.8.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9f61411055101f7b60ecf1041d87fb74205fb20b0c7a723f07ef39174cf6b4c0" -dependencies = [ - "approx", - "ordered-float", - "stb_truetype", -] - -[[package]] -name = "same-file" -version = "1.0.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "93fc1dc3aaa9bfed95e02e6eadabb4baf7e3078b0bd1b4d7b6b0b68378900502" -dependencies = [ - "winapi-util", -] - -[[package]] -name = "scopeguard" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" - -[[package]] -name = "semver" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" -dependencies = [ - "semver-parser", -] - -[[package]] -name = "semver-parser" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" - [[package]] name = "serde" version = "1.0.106" @@ -1020,8 +449,8 @@ version = "1.0.106" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9e549e3abf4fb8621bd1609f11dfc9f5e50320802273b12f3811a67e6716ea6c" dependencies = [ - "proc-macro2 1.0.10", - "quote 1.0.3", + "proc-macro2", + "quote", "syn", ] @@ -1037,16 +466,6 @@ dependencies = [ "yaml-rust", ] -[[package]] -name = "shared_library" -version = "0.1.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a9e7e0f2bfae24d8a5b5a66c5b257a83c7412304311512a0c054cd5e619da11" -dependencies = [ - "lazy_static", - "libc", -] - [[package]] name = "simplelog" version = "0.7.5" @@ -1059,44 +478,14 @@ dependencies = [ ] [[package]] -name = "smallvec" -version = "0.6.13" +name = "smart-default" +version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f7b0758c52e15a8b5e3691eae6cc559f08eee9406e548a4477ba4e67770a82b6" +checksum = "133659a15339456eeeb07572eb02a91c91e9815e9cbc89566944d2c8d3efdbf6" dependencies = [ - "maybe-uninit", -] - -[[package]] -name = "smallvec" -version = "1.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c7cb5678e1615754284ec264d9bb5b4c27d2018577fd90ac0ceb578591ed5ee4" - -[[package]] -name = "smithay-client-toolkit" -version = "0.4.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2ccb8c57049b2a34d2cc2b203fa785020ba0129d31920ef0d317430adaf748fa" -dependencies = [ - "andrew", - "bitflags", - "dlib", - "lazy_static", - "memmap", - "nix", - "wayland-client", - "wayland-commons", - "wayland-protocols", -] - -[[package]] -name = "stb_truetype" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f77b6b07e862c66a9f3e62a07588fee67cd90a9135a2b942409f195507b4fb51" -dependencies = [ - "byteorder", + "proc-macro2", + "quote", + "syn", ] [[package]] @@ -1111,21 +500,15 @@ version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a" -[[package]] -name = "strsim" -version = "0.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" - [[package]] name = "syn" version = "1.0.17" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0df0eb663f387145cab623dea85b09c2c5b4b0aef44e945d928e682fce71bb03" dependencies = [ - "proc-macro2 1.0.10", - "quote 1.0.3", - "unicode-xid 0.2.0", + "proc-macro2", + "quote", + "unicode-xid", ] [[package]] @@ -1134,8 +517,8 @@ version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7be3539f6c128a931cf19dcee741c1af532c7fd387baa739c03dd2e96479338a" dependencies = [ - "proc-macro2 1.0.10", - "quote 1.0.3", + "proc-macro2", + "quote", "syn", ] @@ -1145,10 +528,10 @@ version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "67656ea1dc1b41b1451851562ea232ec2e5a80242139f7e679ceccfb5d61f545" dependencies = [ - "proc-macro2 1.0.10", - "quote 1.0.3", + "proc-macro2", + "quote", "syn", - "unicode-xid 0.2.0", + "unicode-xid", ] [[package]] @@ -1187,12 +570,6 @@ version = "0.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "caaa9d531767d1ff2150b9332433f32a24622147e5ebb1f26409d5da67afd479" -[[package]] -name = "unicode-xid" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fc72304796d0818e357ead4e000d19c9c174ab23dc11093ac919054d20a6a7fc" - [[package]] name = "unicode-xid" version = "0.2.0" @@ -1211,88 +588,12 @@ version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "078775d0255232fb988e6fccf26ddc9d1ac274299aaedcedce21c6f72cc533ce" -[[package]] -name = "void" -version = "1.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6a02e4885ed3bc0f2de90ea6dd45ebcbb66dacffe03547fadbb0eeae2770887d" - -[[package]] -name = "walkdir" -version = "2.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "777182bc735b6424e1a57516d35ed72cb8019d85c8c9bf536dccb3445c1a2f7d" -dependencies = [ - "same-file", - "winapi", - "winapi-util", -] - [[package]] name = "wasi" version = "0.9.0+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519" -[[package]] -name = "wayland-client" -version = "0.21.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49963e5f9eeaf637bfcd1b9f0701c99fd5cd05225eb51035550d4272806f2713" -dependencies = [ - "bitflags", - "downcast-rs", - "libc", - "nix", - "wayland-commons", - "wayland-scanner", - "wayland-sys", -] - -[[package]] -name = "wayland-commons" -version = "0.21.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "40c08896768b667e1df195d88a62a53a2d1351a1ed96188be79c196b35bb32ec" -dependencies = [ - "nix", - "wayland-sys", -] - -[[package]] -name = "wayland-protocols" -version = "0.21.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4afde2ea2a428eee6d7d2c8584fdbe8b82eee8b6c353e129a434cd6e07f42145" -dependencies = [ - "bitflags", - "wayland-client", - "wayland-commons", - "wayland-scanner", - "wayland-sys", -] - -[[package]] -name = "wayland-scanner" -version = "0.21.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bf3828c568714507315ee425a9529edc4a4aa9901409e373e9e0027e7622b79e" -dependencies = [ - "proc-macro2 0.4.30", - "quote 0.6.13", - "xml-rs", -] - -[[package]] -name = "wayland-sys" -version = "0.21.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "520ab0fd578017a0ee2206623ba9ef4afe5e8f23ca7b42f6acfba2f4e66b1628" -dependencies = [ - "dlib", - "lazy_static", -] - [[package]] name = "winapi" version = "0.3.8" @@ -1309,70 +610,12 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" -[[package]] -name = "winapi-util" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178" -dependencies = [ - "winapi", -] - [[package]] name = "winapi-x86_64-pc-windows-gnu" version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" -[[package]] -name = "winit" -version = "0.19.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e96eb4bb472fa43e718e8fa4aef82f86cd9deac9483a1e1529230babdb394a8" -dependencies = [ - "android_glue", - "backtrace", - "bitflags", - "cocoa", - "core-foundation", - "core-graphics", - "lazy_static", - "libc", - "log", - "objc", - "parking_lot 0.9.0", - "percent-encoding", - "raw-window-handle", - "smithay-client-toolkit", - "wayland-client", - "winapi", - "x11-dl", -] - -[[package]] -name = "x11-dl" -version = "2.18.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2bf981e3a5b3301209754218f962052d4d9ee97e478f4d26d4a6eced34c1fef8" -dependencies = [ - "lazy_static", - "libc", - "maybe-uninit", - "pkg-config", -] - -[[package]] -name = "xdg" -version = "2.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d089681aa106a86fade1b0128fb5daf07d5867a509ab036d99988dec80429a57" - -[[package]] -name = "xml-rs" -version = "0.8.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b07db065a5cf61a7e4ba64f29e67db906fb1787316516c4e6e5ff0fea1efcd8a" - [[package]] name = "yaml-rust" version = "0.4.3" diff --git a/Cargo.toml b/Cargo.toml index f5dc41e..93c3753 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -12,21 +12,17 @@ path = "src/extractor/main.rs" name = "patcher" path = "src/patcher/main.rs" -[[bin]] -name = "card-editor" -path = "src/card-editor/main.rs" - [dependencies] # Dcb dcb = { path = "../dcb" } # Text ascii = "1.0" -strsim = "0.10" # Helpers float-ord = "0.2" itertools = "0.9" +rand = "0.7" # Cmd clap = "2.33" @@ -40,24 +36,18 @@ string-err = "0.1" err-backtrace = { path = "../err-backtrace" } err-panic = { path = "../err-panic", features = ["string-err-ext"] } err-ext = { path = "../err-ext" } +err-impl = { git = "https://github.com/Zenithsiz/err-impl" } + +# Derives derive_more = "0.99" +smart-default = "0.6" # Serde +serde = "1.0" serde_yaml = "0.8" -# Window / Ui -gfx = "0.18" -gfx_device_gl = "0.16" -gfx_window_glutin = "0.31" -glutin = "0.21" -#image = "0.23" -imgui = "0.3" -imgui-gfx-renderer = "0.3" -imgui-winit-support = { version = "0.3", default-features = false, features = ["winit-19"] } - # Build dependencies in release mode [profile.dev.package."*"] opt-level = 2 [profile.dev.package.dcb] # Except dcb for debugging opt-level = 0 - diff --git a/src/card-editor/cli.rs b/src/card-editor/cli.rs deleted file mode 100644 index cebe9e7..0000000 --- a/src/card-editor/cli.rs +++ /dev/null @@ -1,41 +0,0 @@ -//! Cli manager for the extractor - -// Filesystem -use std::path::{Path, PathBuf}; - -// Clap -use clap::{App as ClapApp, Arg as ClapArg}; - -/// Data from the command line -#[derive(PartialEq, Clone, Debug)] -pub struct CliData { - /// The data directory - pub data_dir: PathBuf, -} - -impl CliData { - /// Constructs all of the cli data given and returns it - pub fn new() -> Self { - // Get all matches from cli - let matches = ClapApp::new("Dcb Card Editor") - .version("0.0") - .author("Filipe [...] <[...]@gmail.com>") - .about("Edits card data from Digimon Digital Card Battle extracted files") - .arg( - ClapArg::with_name("INPUT") - .help("Sets the Data directory to use") - .short("i") - .long("input") - .index(1) - .takes_value(true) - .required(true), - ) - .get_matches(); - - // Get the data dir as either an input or the current directory - let data_dir = matches.value_of("INPUT").map_or_else(|| Path::new("."), Path::new).to_path_buf(); - - // Return the cli data - Self { data_dir } - } -} diff --git a/src/card-editor/main.rs b/src/card-editor/main.rs deleted file mode 100644 index 302c531..0000000 --- a/src/card-editor/main.rs +++ /dev/null @@ -1,282 +0,0 @@ -//! Data patches -//! -//! # Details -//! Patches data to the game file from several other files. -//! -//! # Syntax -//! The executable may be called as `./patcher ` -//! -//! Use the command `./patcher --help` for more information. -//! -//! # Data patched -//! Currently only the following is patched: -//! - Card table - -// Features -#![feature(box_syntax, backtrace, panic_info_message, bool_to_option)] -// Lints -#![warn(clippy::restriction, clippy::pedantic, clippy::nursery)] -#![allow( - clippy::implicit_return, // We prefer implicit returns where possible - clippy::module_name_repetitions, // This happens often due to separating things into modules finely - clippy::wildcard_enum_match_arm, // We only use wildcards when we truly only care about some variants - clippy::result_expect_used, - clippy::option_expect_used, // We use expect when there is no alternative. - clippy::used_underscore_binding, // Useful for macros and such - clippy::integer_arithmetic, - clippy::float_arithmetic, // We need to use numbers my guy - clippy::as_conversions, - clippy::cast_sign_loss, - clippy::cast_possible_wrap, - clippy::cast_possible_truncation, // Needed for converting between stuff - clippy::items_after_statements, -)] - -// Modules -mod cli; -#[path = "../logger.rs"] -mod logger; -#[path = "../panic.rs"] -mod panic; - -// Gfx / GLutin -use gfx::Device; -use glutin::{Event, WindowEvent}; - -// Imgui -use imgui::{Context, FontConfig, FontGlyphRanges, FontSource, ImString}; -use imgui_gfx_renderer::{Renderer, Shaders}; -use imgui_winit_support::{HiDpiMode, WinitPlatform}; - -// Errors -use err_backtrace::ErrBacktraceExt; -use err_ext::ResultExt; -use err_panic::ErrorExtPanic; - -// Itertools -use itertools::Itertools; - -// Dcb -use dcb::game::{card::Table as CardTable, deck::Table as DeckTable}; - -#[allow(clippy::too_many_lines)] // TODO: Fix -fn main() { - // Initialize the logger and set the panic handler - logger::init(); - std::panic::set_hook(box panic::log_handler); - - // Get all data from cli - let cli::CliData { data_dir } = cli::CliData::new(); - - // Load all data files - let cards_table_file = std::fs::File::open(data_dir.join("cards.yaml")).panic_err_msg("Unable to open `cards.yaml`"); - let decks_table_file = std::fs::File::open(data_dir.join("decks.yaml")).panic_err_msg("Unable to open `decks.yaml`"); - - // Parse everything from yaml - let mut cards_table: CardTable = serde_yaml::from_reader(cards_table_file).panic_err_msg("Unable to parse `cards.yaml`"); - let decks_table: DeckTable = serde_yaml::from_reader(decks_table_file).panic_err_msg("Unable to parse `decks.yaml`"); - - // Create a new window - let mut events_loop = glutin::EventsLoop::new(); - let builder = glutin::WindowBuilder::new() - .with_title("Dcb Card Editor") - .with_dimensions(glutin::dpi::LogicalSize::new(1024.0, 768.0)); - let context = glutin::ContextBuilder::new().with_vsync(true); - let (windowed_context, mut device, mut factory, mut main_color, mut main_depth) = - gfx_window_glutin::init::(builder, context, &events_loop) - .panic_err_msg("Failed to initialize graphics"); - let mut encoder: gfx::Encoder<_, _> = factory.create_command_buffer().into(); - let shaders = { - let version = device.get_info().shading_language; - if version.is_embedded { - if version.major >= 3 { - Shaders::GlSlEs300 - } else { - Shaders::GlSlEs100 - } - } else if version.major >= 4 { - Shaders::GlSl400 - } else if version.major >= 3 { - if version.minor >= 2 { - Shaders::GlSl150 - } else { - Shaders::GlSl130 - } - } else { - Shaders::GlSl110 - } - }; - - // Create a new context for `imgui` - let mut imgui_context = Context::create(); - let mut platform = WinitPlatform::init(&mut imgui_context); - - // Add our font to imgui - let hidpi_factor = platform.hidpi_factor(); - let font_size = (13.0 * hidpi_factor) as f32; - imgui_context.fonts().add_font(&[ - FontSource::DefaultFontData { - config: Some(FontConfig { - size_pixels: font_size, - ..FontConfig::default() - }), - }, - FontSource::TtfData { - data: include_bytes!("../../resources/OpenSans-Regular.ttf"), - size_pixels: font_size, - config: Some(FontConfig { - rasterizer_multiply: 1.75, - glyph_ranges: FontGlyphRanges::japanese(), - ..FontConfig::default() - }), - }, - ]); - imgui_context.io_mut().font_global_scale = (1.0 / hidpi_factor) as f32; - - // Fix `sRGB` on style colors - let style = imgui_context.style_mut(); - #[allow(clippy::indexing_slicing)] // False positive, this is a `[f32; 4]` - for color in style.colors.iter_mut() { - color[0] = color[0].powf(2.2); - color[1] = color[1].powf(2.2); - color[2] = color[2].powf(2.2); - color[3] = 1.0 - (1.0 - color[3]).powf(2.2); - } - - // Attach the window to the platform - let mut renderer = Renderer::init(&mut imgui_context, &mut factory, shaders).panic_err_msg("Unable to initialize renderer"); - platform.attach_window(imgui_context.io_mut(), windowed_context.window(), HiDpiMode::Rounded); - - let mut last_frame = std::time::Instant::now(); - let mut run = true; - - // Get all digimon names as `ImString`s - let mut digimon_names: Vec<_> = cards_table.digimons.iter().map(|digimon| ImString::new(digimon.name.clone())).collect(); - let mut digimon_filter_idx = 0; - let mut digimon_filter_search = ImString::new(""); - - while run { - // Check for events - events_loop.poll_events(|event| { - platform.handle_event(imgui_context.io_mut(), windowed_context.window(), &event); - - if let Event::WindowEvent { event, .. } = event { - match event { - WindowEvent::Resized(_) => { - gfx_window_glutin::update_views(&windowed_context, &mut main_color, &mut main_depth); - }, - WindowEvent::CloseRequested => run = false, - _ => (), - } - } - }); - - // Prepare and execute ui frame - let io = imgui_context.io_mut(); - platform - .prepare_frame(io, windowed_context.window()) - .ignore_with_err(|err| log::warn!("Unable to prepare frame: {}", err)); - last_frame = io.update_delta_time(last_frame); - let ui = imgui_context.frame(); - { - ui.text("Digimon: "); - - ui.input_text(imgui::im_str!("Digimon Filter"), &mut digimon_filter_search) - .resize_buffer(true) - .build(); - - let digimon_filters: Vec<_> = digimon_names - .iter() - .enumerate() - .map(|(idx, string)| { - ( - float_ord::FloatOrd(1.0 - strsim::jaro(string.to_str(), digimon_filter_search.to_str())), - string, - idx, - ) - }) - .sorted() - .collect(); - - let digimon_filter_names: Vec<_> = digimon_filters - .iter() - .filter_map(|(value, string, _)| (digimon_filter_search.is_empty() || value.0 < 0.5).then_some(string)) - .collect(); - - ui.list_box( - imgui::im_str!("Digimon List"), - &mut digimon_filter_idx, - digimon_filter_names.as_slice(), - 4, - ); - - ui.separator(); - - /* - if let Some((_, _, idx)) = digimon_filters.get(digimon_filter_idx as usize) { - let idx = *idx; - std::mem::drop(digimon_filters); - if let Some(digimon_name_buffer) = digimon_names.get_mut(idx) { - if ui.input_text(imgui::im_str!("Name"), digimon_name_buffer).resize_buffer(true).build() { - if let Some(digimon) = cards_table.digimons.get_mut(idx) { - match ascii::AsciiString::from_ascii(digimon_name_buffer.to_string()) { - Ok(name) => { - digimon.name = name; - }, - Err(err) => { - ui.text(format!("Unable to set digimon name:\n{}", err.err_backtrace())); - }, - } - } - } - } - } - */ - - //if let Some(digimon_name) = digimon_names.iter_mut().enumerate().find(|(_, name)| name == ) - - /* - if let Some((idx, digimon)) = cards_table.digimons.iter_mut().enumerate().find(|(_, digimon)| { - digimon_filter_names - .get(digimon_filter_idx as usize) - .map_or(false, |&name| name.to_str() == digimon.name) - }) { - let mut name_buffer = ImString::new(digimon.name.clone()); - if ui.input_text(imgui::im_str!("Name"), &mut name_buffer).resize_buffer(true).build() { - match ascii::AsciiString::from_ascii(name_buffer.to_string()) { - Ok(name) => { - digimon.name = name; - if let Some(name) = digimon_names.get_mut(idx) { - *name = name_buffer.clone(); - } - }, - Err(err) => { - ui.text(format!("Unable to set digimon name:\n{}", err.err_backtrace())); - }, - } - } - } - */ - } - - // Clear, render everything and flush it out - encoder.clear(&main_color, [0.2, 0.2, 0.2, 1.0]); - platform.prepare_render(&ui, windowed_context.window()); - renderer - .render(&mut factory, &mut encoder, &mut main_color, ui.render()) - .ignore_with_err(|err| log::warn!("Unable to render: {}", err.err_backtrace())); - encoder.flush(&mut device); - windowed_context - .swap_buffers() - .ignore_with_err(|err| log::warn!("Unable to swap buffers: {}", err.err_backtrace())); - device.cleanup(); - } - - // Convert everything back to yaml - let cards_table_yaml = serde_yaml::to_string(&cards_table).panic_err_msg("Unable to serialize cards table to yaml"); - let decks_table_yaml = serde_yaml::to_string(&decks_table).panic_err_msg("Unable to serialize decks table to yaml"); - - // Ouput all data to devices - std::fs::write(&data_dir.join("cards.yaml"), cards_table_yaml).panic_err_msg("Unable to write cards table to file"); - std::fs::write(&data_dir.join("decks.yaml"), decks_table_yaml).panic_err_msg("Unable to write decks table to file"); -} From 52e89ab1a23d741923680ba53654d5db5f44cbeb Mon Sep 17 00:00:00 2001 From: Filipe Rodrigues Date: Wed, 13 May 2020 15:04:22 +0100 Subject: [PATCH 10/12] Now ignoring `Cargo.lock`. --- .gitignore | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 96d8802..ff0d847 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,3 @@ /target -.vscode -resources/ \ No newline at end of file +/.vscode +Cargo.lock From c26a34144c165c7f1e402d2cd1b8c826f987836d Mon Sep 17 00:00:00 2001 From: Filipe Rodrigues Date: Sat, 30 May 2020 14:35:02 +0100 Subject: [PATCH 11/12] Updated `rustfmt.toml`, but noticed a bug where `cargo fmt` cannot use the `#[path = "..."] mod ...` syntax, so currently no formatting is done. --- rustfmt.toml | 39 +++++++++++++++++++++++++++++++++++++++ src/extractor/main.rs | 1 + 2 files changed, 40 insertions(+) diff --git a/rustfmt.toml b/rustfmt.toml index 844da63..f0c05cf 100644 --- a/rustfmt.toml +++ b/rustfmt.toml @@ -16,3 +16,42 @@ fn_args_layout = "Compressed" merge_derives = false merge_imports = true max_width = 150 +use_small_heuristics = "Default" +indent_style = "Block" +wrap_comments = false +format_code_in_doc_comments = false +comment_width = 150 +normalize_comments = false +normalize_doc_attributes = false +license_template_path = "" +format_strings = true +format_macro_matchers = true +format_macro_bodies = true +empty_item_single_line = true +struct_lit_single_line = true +fn_single_line = false +where_single_line = false +imports_indent = "Block" +imports_layout = "Mixed" +reorder_imports = true +reorder_modules = true +type_punctuation_density = "Wide" +space_before_colon = false +space_after_colon = true +spaces_around_ranges = false +remove_nested_parens = true +combine_control_expr = true +struct_field_align_threshold = 20 +match_arm_blocks = true +force_multiline_blocks = false +brace_style = "SameLineWhere" +control_brace_style = "AlwaysSameLine" +trailing_semicolon = true +trailing_comma = "Vertical" +blank_lines_lower_bound = 0 +blank_lines_upper_bound = 2 +inline_attribute_width = 0 +use_try_shorthand = true +force_explicit_abi = true +error_on_line_overflow = true +error_on_unformatted = true diff --git a/src/extractor/main.rs b/src/extractor/main.rs index cbb5f7a..95c5da1 100644 --- a/src/extractor/main.rs +++ b/src/extractor/main.rs @@ -27,6 +27,7 @@ )] // Modules +// TODO: `cargo fmt` cannot use this syntax, possibly change it once possible mod cli; #[path = "../logger.rs"] mod logger; From 5a8f2cc1f5c4a686dc4ee69fe3d5548caa5895a4 Mon Sep 17 00:00:00 2001 From: Filipe Rodrigues Date: Wed, 21 Oct 2020 00:54:06 +0100 Subject: [PATCH 12/12] Moved project into sub-folder 'dcb-tools' in preparation for merge with main repo --- .gitignore | 3 - Cargo.lock | 626 ----------------------- Cargo.toml => dcb-tools/Cargo.toml | 0 rustfmt.toml => dcb-tools/rustfmt.toml | 0 {src => dcb-tools/src}/extractor/cli.rs | 0 {src => dcb-tools/src}/extractor/main.rs | 0 {src => dcb-tools/src}/logger.rs | 0 {src => dcb-tools/src}/panic.rs | 0 {src => dcb-tools/src}/patcher/cli.rs | 0 {src => dcb-tools/src}/patcher/main.rs | 0 10 files changed, 629 deletions(-) delete mode 100644 .gitignore delete mode 100644 Cargo.lock rename Cargo.toml => dcb-tools/Cargo.toml (100%) rename rustfmt.toml => dcb-tools/rustfmt.toml (100%) rename {src => dcb-tools/src}/extractor/cli.rs (100%) rename {src => dcb-tools/src}/extractor/main.rs (100%) rename {src => dcb-tools/src}/logger.rs (100%) rename {src => dcb-tools/src}/panic.rs (100%) rename {src => dcb-tools/src}/patcher/cli.rs (100%) rename {src => dcb-tools/src}/patcher/main.rs (100%) diff --git a/.gitignore b/.gitignore deleted file mode 100644 index ff0d847..0000000 --- a/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -/target -/.vscode -Cargo.lock diff --git a/Cargo.lock b/Cargo.lock deleted file mode 100644 index 4fff96b..0000000 --- a/Cargo.lock +++ /dev/null @@ -1,626 +0,0 @@ -# This file is automatically @generated by Cargo. -# It is not intended for manual editing. -[[package]] -name = "ansi_term" -version = "0.11.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ee49baf6cb617b853aa8d93bf420db2383fab46d314482ca2803b40d5fde979b" -dependencies = [ - "winapi", -] - -[[package]] -name = "arrayref" -version = "0.3.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4c527152e37cf757a3f78aae5a06fbeefdb07ccc535c980a3208ee3060dd544" - -[[package]] -name = "arrayvec" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cff77d8686867eceff3105329d4698d96c2391c176d5d03adc90c7389162b5b8" - -[[package]] -name = "ascii" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bbf56136a5198c7b01a49e3afcbef6cf84597273d298f54432926024107b0109" -dependencies = [ - "serde", -] - -[[package]] -name = "atty" -version = "0.2.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8" -dependencies = [ - "hermit-abi", - "libc", - "winapi", -] - -[[package]] -name = "autocfg" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f8aac770f1885fd7e387acedd76065302551364496e46b3dd00860b2f8359b9d" - -[[package]] -name = "base64" -version = "0.11.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b41b7ea54a0c9d92199de89e20e58d49f02f8e699814ef3fdf266f6f748d15c7" - -[[package]] -name = "bitflags" -version = "1.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693" - -[[package]] -name = "blake2b_simd" -version = "0.5.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d8fb2d74254a3a0b5cac33ac9f8ed0e44aa50378d9dbb2e5d83bd21ed1dc2c8a" -dependencies = [ - "arrayref", - "arrayvec", - "constant_time_eq", -] - -[[package]] -name = "byteorder" -version = "1.3.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "08c48aae112d48ed9f069b33538ea9e3e90aa263cfa3d1c24309612b1f7472de" - -[[package]] -name = "cfg-if" -version = "0.1.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822" - -[[package]] -name = "chrono" -version = "0.4.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "80094f509cf8b5ae86a4966a39b3ff66cd7e2a3e594accec3743ff3fabeab5b2" -dependencies = [ - "num-integer", - "num-traits", - "time", -] - -[[package]] -name = "clap" -version = "2.33.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5067f5bb2d80ef5d68b4c87db81601f0b75bca627bc2ef76b141d7b846a3c6d9" -dependencies = [ - "ansi_term", - "atty", - "bitflags", - "strsim", - "textwrap", - "unicode-width", - "vec_map", -] - -[[package]] -name = "constant_time_eq" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "245097e9a4535ee1e3e3931fcfcd55a796a44c643e8596ff6566d68f09b87bbc" - -[[package]] -name = "crossbeam-utils" -version = "0.7.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3c7c73a2d1e9fc0886a08b93e98eb643461230d5f1925e4036204d5f2e261a8" -dependencies = [ - "autocfg", - "cfg-if", - "lazy_static", -] - -[[package]] -name = "dcb" -version = "0.1.0" -dependencies = [ - "arrayref", - "ascii", - "byteorder", - "derive_more", - "err-impl", - "log", - "serde", -] - -[[package]] -name = "dcb-tools" -version = "0.1.0" -dependencies = [ - "ascii", - "clap", - "dcb", - "derive_more", - "err-backtrace", - "err-ext", - "err-impl", - "err-panic", - "float-ord", - "itertools", - "log", - "rand", - "serde", - "serde_yaml", - "simplelog", - "smart-default", - "string-err", -] - -[[package]] -name = "derive_more" -version = "0.99.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2323f3f47db9a0e77ce7a300605d8d2098597fc451ed1a97bb1f6411bb550a7" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "dirs" -version = "2.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "13aea89a5c93364a98e9b37b2fa237effbb694d5cfe01c5b70941f7eb087d5e3" -dependencies = [ - "cfg-if", - "dirs-sys", -] - -[[package]] -name = "dirs-sys" -version = "0.3.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "afa0b23de8fd801745c471deffa6e12d248f962c9fd4b4c33787b055599bde7b" -dependencies = [ - "cfg-if", - "libc", - "redox_users", - "winapi", -] - -[[package]] -name = "dtoa" -version = "0.4.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4358a9e11b9a09cf52383b451b49a169e8d797b68aa02301ff586d70d9661ea3" - -[[package]] -name = "either" -version = "1.5.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bb1f6b1ce1c140482ea30ddd3335fc0024ac7ee112895426e0a629a6c20adfe3" - -[[package]] -name = "err-backtrace" -version = "0.1.0" - -[[package]] -name = "err-ext" -version = "0.1.0" - -[[package]] -name = "err-impl" -version = "0.1.0" -source = "git+https://github.com/Zenithsiz/err-impl#188a95b85272fc087794c7f7f0972e146a1d350e" -dependencies = [ - "proc-macro-error", - "proc-macro2", - "quote", - "syn", - "synstructure", -] - -[[package]] -name = "err-panic" -version = "0.1.0" -dependencies = [ - "string-err", -] - -[[package]] -name = "float-ord" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7bad48618fdb549078c333a7a8528acb57af271d0433bdecd523eb620628364e" - -[[package]] -name = "getrandom" -version = "0.1.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7abc8dd8451921606d809ba32e95b6111925cd2906060d2dcc29c070220503eb" -dependencies = [ - "cfg-if", - "libc", - "wasi", -] - -[[package]] -name = "hermit-abi" -version = "0.1.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "725cf19794cf90aa94e65050cb4191ff5d8fa87a498383774c47b332e3af952e" -dependencies = [ - "libc", -] - -[[package]] -name = "itertools" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "284f18f85651fe11e8a991b2adb42cb078325c996ed026d994719efcfca1d54b" -dependencies = [ - "either", -] - -[[package]] -name = "lazy_static" -version = "1.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" - -[[package]] -name = "libc" -version = "0.2.68" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dea0c0405123bba743ee3f91f49b1c7cfb684eef0da0a50110f758ccf24cdff0" - -[[package]] -name = "linked-hash-map" -version = "0.5.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae91b68aebc4ddb91978b11a1b02ddd8602a05ec19002801c5666000e05e0f83" - -[[package]] -name = "log" -version = "0.4.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "14b6052be84e6b71ab17edffc2eeabf5c2c3ae1fdb464aae35ac50c67a44e1f7" -dependencies = [ - "cfg-if", -] - -[[package]] -name = "num-integer" -version = "0.1.42" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f6ea62e9d81a77cd3ee9a2a5b9b609447857f3d358704331e4ef39eb247fcba" -dependencies = [ - "autocfg", - "num-traits", -] - -[[package]] -name = "num-traits" -version = "0.2.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c62be47e61d1842b9170f0fdeec8eba98e60e90e5446449a0545e5152acd7096" -dependencies = [ - "autocfg", -] - -[[package]] -name = "ppv-lite86" -version = "0.2.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "74490b50b9fbe561ac330df47c08f3f33073d2d00c150f719147d7c54522fa1b" - -[[package]] -name = "proc-macro-error" -version = "1.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "98e9e4b82e0ef281812565ea4751049f1bdcdfccda7d3f459f2e138a40c08678" -dependencies = [ - "proc-macro-error-attr", - "proc-macro2", - "quote", - "syn", - "version_check", -] - -[[package]] -name = "proc-macro-error-attr" -version = "1.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4f5444ead4e9935abd7f27dc51f7e852a0569ac888096d5ec2499470794e2e53" -dependencies = [ - "proc-macro2", - "quote", - "syn", - "syn-mid", - "version_check", -] - -[[package]] -name = "proc-macro2" -version = "1.0.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "df246d292ff63439fea9bc8c0a270bed0e390d5ebd4db4ba15aba81111b5abe3" -dependencies = [ - "unicode-xid", -] - -[[package]] -name = "quote" -version = "1.0.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2bdc6c187c65bca4260c9011c9e3132efe4909da44726bad24cf7572ae338d7f" -dependencies = [ - "proc-macro2", -] - -[[package]] -name = "rand" -version = "0.7.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6a6b1679d49b24bbfe0c803429aa1874472f50d9b363131f0e89fc356b544d03" -dependencies = [ - "getrandom", - "libc", - "rand_chacha", - "rand_core", - "rand_hc", -] - -[[package]] -name = "rand_chacha" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f4c8ed856279c9737206bf725bf36935d8666ead7aa69b52be55af369d193402" -dependencies = [ - "ppv-lite86", - "rand_core", -] - -[[package]] -name = "rand_core" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "90bde5296fc891b0cef12a6d03ddccc162ce7b2aff54160af9338f8d40df6d19" -dependencies = [ - "getrandom", -] - -[[package]] -name = "rand_hc" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca3129af7b92a17112d59ad498c6f81eaf463253766b90396d39ea7a39d6613c" -dependencies = [ - "rand_core", -] - -[[package]] -name = "redox_syscall" -version = "0.1.56" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2439c63f3f6139d1b57529d16bc3b8bb855230c8efcc5d3a896c8bea7c3b1e84" - -[[package]] -name = "redox_users" -version = "0.3.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "09b23093265f8d200fa7b4c2c76297f47e681c655f6f1285a8780d6a022f7431" -dependencies = [ - "getrandom", - "redox_syscall", - "rust-argon2", -] - -[[package]] -name = "rust-argon2" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2bc8af4bda8e1ff4932523b94d3dd20ee30a87232323eda55903ffd71d2fb017" -dependencies = [ - "base64", - "blake2b_simd", - "constant_time_eq", - "crossbeam-utils", -] - -[[package]] -name = "serde" -version = "1.0.106" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "36df6ac6412072f67cf767ebbde4133a5b2e88e76dc6187fa7104cd16f783399" -dependencies = [ - "serde_derive", -] - -[[package]] -name = "serde_derive" -version = "1.0.106" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e549e3abf4fb8621bd1609f11dfc9f5e50320802273b12f3811a67e6716ea6c" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "serde_yaml" -version = "0.8.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "691b17f19fc1ec9d94ec0b5864859290dff279dbd7b03f017afda54eb36c3c35" -dependencies = [ - "dtoa", - "linked-hash-map", - "serde", - "yaml-rust", -] - -[[package]] -name = "simplelog" -version = "0.7.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bcacac97349a890d437921dfb23cbec52ab5b4752551cb637df2721371acd467" -dependencies = [ - "chrono", - "log", - "term", -] - -[[package]] -name = "smart-default" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "133659a15339456eeeb07572eb02a91c91e9815e9cbc89566944d2c8d3efdbf6" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "string-err" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5eb6c5ccd2a653178945caa695062379fa26812f1e63584111ac8fff988358d1" - -[[package]] -name = "strsim" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a" - -[[package]] -name = "syn" -version = "1.0.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0df0eb663f387145cab623dea85b09c2c5b4b0aef44e945d928e682fce71bb03" -dependencies = [ - "proc-macro2", - "quote", - "unicode-xid", -] - -[[package]] -name = "syn-mid" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7be3539f6c128a931cf19dcee741c1af532c7fd387baa739c03dd2e96479338a" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "synstructure" -version = "0.12.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "67656ea1dc1b41b1451851562ea232ec2e5a80242139f7e679ceccfb5d61f545" -dependencies = [ - "proc-macro2", - "quote", - "syn", - "unicode-xid", -] - -[[package]] -name = "term" -version = "0.6.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c0863a3345e70f61d613eab32ee046ccd1bcc5f9105fe402c61fcd0c13eeb8b5" -dependencies = [ - "dirs", - "winapi", -] - -[[package]] -name = "textwrap" -version = "0.11.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d326610f408c7a4eb6f51c37c330e496b08506c9457c9d34287ecc38809fb060" -dependencies = [ - "unicode-width", -] - -[[package]] -name = "time" -version = "0.1.42" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "db8dcfca086c1143c9270ac42a2bbd8a7ee477b78ac8e45b19abfb0cbede4b6f" -dependencies = [ - "libc", - "redox_syscall", - "winapi", -] - -[[package]] -name = "unicode-width" -version = "0.1.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "caaa9d531767d1ff2150b9332433f32a24622147e5ebb1f26409d5da67afd479" - -[[package]] -name = "unicode-xid" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "826e7639553986605ec5979c7dd957c7895e93eabed50ab2ffa7f6128a75097c" - -[[package]] -name = "vec_map" -version = "0.8.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05c78687fb1a80548ae3250346c3db86a80a7cdd77bda190189f2d0a0987c81a" - -[[package]] -name = "version_check" -version = "0.9.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "078775d0255232fb988e6fccf26ddc9d1ac274299aaedcedce21c6f72cc533ce" - -[[package]] -name = "wasi" -version = "0.9.0+wasi-snapshot-preview1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519" - -[[package]] -name = "winapi" -version = "0.3.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8093091eeb260906a183e6ae1abdba2ef5ef2257a21801128899c3fc699229c6" -dependencies = [ - "winapi-i686-pc-windows-gnu", - "winapi-x86_64-pc-windows-gnu", -] - -[[package]] -name = "winapi-i686-pc-windows-gnu" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" - -[[package]] -name = "winapi-x86_64-pc-windows-gnu" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" - -[[package]] -name = "yaml-rust" -version = "0.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "65923dd1784f44da1d2c3dbbc5e822045628c590ba72123e1c73d3c230c4434d" -dependencies = [ - "linked-hash-map", -] diff --git a/Cargo.toml b/dcb-tools/Cargo.toml similarity index 100% rename from Cargo.toml rename to dcb-tools/Cargo.toml diff --git a/rustfmt.toml b/dcb-tools/rustfmt.toml similarity index 100% rename from rustfmt.toml rename to dcb-tools/rustfmt.toml diff --git a/src/extractor/cli.rs b/dcb-tools/src/extractor/cli.rs similarity index 100% rename from src/extractor/cli.rs rename to dcb-tools/src/extractor/cli.rs diff --git a/src/extractor/main.rs b/dcb-tools/src/extractor/main.rs similarity index 100% rename from src/extractor/main.rs rename to dcb-tools/src/extractor/main.rs diff --git a/src/logger.rs b/dcb-tools/src/logger.rs similarity index 100% rename from src/logger.rs rename to dcb-tools/src/logger.rs diff --git a/src/panic.rs b/dcb-tools/src/panic.rs similarity index 100% rename from src/panic.rs rename to dcb-tools/src/panic.rs diff --git a/src/patcher/cli.rs b/dcb-tools/src/patcher/cli.rs similarity index 100% rename from src/patcher/cli.rs rename to dcb-tools/src/patcher/cli.rs diff --git a/src/patcher/main.rs b/dcb-tools/src/patcher/main.rs similarity index 100% rename from src/patcher/main.rs rename to dcb-tools/src/patcher/main.rs