diff --git a/Cargo.lock b/Cargo.lock index 7c388a9..feff04e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4,9 +4,9 @@ version = 3 [[package]] name = "adler" -version = "0.2.3" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ee2a4ec343196209d6594e19543ae87a39f96d5534d7174822a3ad825dd6ed7e" +checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" [[package]] name = "adler32" @@ -26,17 +26,29 @@ version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cdb031dd78e28731d87d56cc8ffef4a8f36ca26c38fe2de700543e627f8a464a" +[[package]] +name = "bit_field" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dcb6dd1c2376d2e096796e234a70e17e94cc2d5d54ff8ce42b28cef1d0d359a4" + [[package]] name = "bitflags" version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693" +[[package]] +name = "bumpalo" +version = "3.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0d261e256854913907f67ed06efbc3338dfe6179796deefc1ff763fc1aee5535" + [[package]] name = "bytemuck" -version = "1.5.0" +version = "1.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a4bad0c5981acc24bc09e532f35160f952e35422603f0563cd7a73c2c2e65a0" +checksum = "c041d3eab048880cb0b86b256447da3f18859a163c3b8d8893f4e6368abe6393" [[package]] name = "byteorder" @@ -83,9 +95,9 @@ dependencies = [ [[package]] name = "crossbeam-deque" -version = "0.8.0" +version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94af6efb46fef72616855b036a624cf27ba656ffc9be1b9a3c931cfc7749a9a9" +checksum = "715e8152b692bba2d374b53d4875445368fdf21a94751410af607a5ac677d1fc" dependencies = [ "cfg-if", "crossbeam-epoch", @@ -211,30 +223,26 @@ dependencies = [ ] [[package]] -name = "deflate" -version = "0.8.6" +name = "crunchy" +version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "73770f8e1fe7d64df17ca66ad28994a0a623ea497fa69486e14984e715c5d174" -dependencies = [ - "adler32", - "byteorder", -] +checksum = "7a81dae078cea95a014a339291cec439d2f232ebe854a9d672b796c6afafa9b7" [[package]] name = "deflate" -version = "0.9.1" +version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f95bf05dffba6e6cce8dfbb30def788154949ccd9aed761b472119c21e01c70" +checksum = "c86f7e25f518f4b81808a2cf1c50996a61f5c2eb394b2393bd87f2a4780a432f" dependencies = [ "adler32", ] [[package]] name = "dmi" -version = "0.1.1" -source = "git+https://github.com/spacestation13/dmi#f301d39b475cb2915e21dfa06b66409cd101a70a" +version = "0.2.1" +source = "git+https://github.com/spacestation13/dmi?tag=v0.2.1#02ac0082789b324bbb2402565f0869755c46aded" dependencies = [ - "deflate 0.9.1", + "deflate", "image", "inflate", "thiserror", @@ -255,6 +263,70 @@ version = "1.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e78d4f1cc4ae33bbfc157ed5d5a5ef3bc29227303d595861deb238fcec4e9457" +[[package]] +name = "exr" +version = "1.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e8af5ef47e2ed89d23d0ecbc1b681b30390069de70260937877514377fc24feb" +dependencies = [ + "bit_field", + "flume", + "half", + "lebe", + "miniz_oxide", + "smallvec", + "threadpool", + "zune-inflate", +] + +[[package]] +name = "flate2" +version = "1.0.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a8a2db397cb1c8772f31494cb8917e48cd1e64f0fa7efac59fbd741a0a8ce841" +dependencies = [ + "crc32fast", + "miniz_oxide", +] + +[[package]] +name = "flume" +version = "0.10.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1657b4441c3403d9f7b3409e47575237dac27b1b5726df654a6ecbf92f0f7577" +dependencies = [ + "futures-core", + "futures-sink", + "nanorand", + "pin-project", + "spin", +] + +[[package]] +name = "futures-core" +version = "0.3.26" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec90ff4d0fe1f57d600049061dc6bb68ed03c7d2fbd697274c41805dcb3f8608" + +[[package]] +name = "futures-sink" +version = "0.3.26" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f310820bb3e8cfd46c80db4d7fb8353e15dfff853a127158425f31e0be6c8364" + +[[package]] +name = "getrandom" +version = "0.2.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c05aeb6a22b8f62540c194aac980f2115af067bfe15a0734d7277a768d396b31" +dependencies = [ + "cfg-if", + "js-sys", + "libc", + "wasi", + "wasm-bindgen", +] + [[package]] name = "gif" version = "0.11.1" @@ -265,6 +337,15 @@ dependencies = [ "weezl", ] +[[package]] +name = "half" +version = "2.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "02b4af3693f1b705df946e9fe5631932443781d0aabb423b62fcd4d73f6d2fd0" +dependencies = [ + "crunchy", +] + [[package]] name = "hermit-abi" version = "0.1.18" @@ -276,7 +357,7 @@ dependencies = [ [[package]] name = "icon-cutter" -version = "0.1.5" +version = "0.1.6" dependencies = [ "anyhow", "dmi", @@ -287,16 +368,16 @@ dependencies = [ [[package]] name = "image" -version = "0.23.13" +version = "0.24.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "293f07a1875fa7e9c5897b51aa68b2d8ed8271b87e1a44cb64b9c3d98aabbc0d" +checksum = "69b7ea949b537b0fd0af141fff8c77690f2ce96f4f41f042ccb6c69c6c965945" dependencies = [ "bytemuck", "byteorder", "color_quant", + "exr", "gif", "jpeg-decoder", - "num-iter", "num-rational", "num-traits", "png", @@ -315,24 +396,39 @@ dependencies = [ [[package]] name = "jpeg-decoder" -version = "0.1.22" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "229d53d58899083193af11e15917b5640cd40b29ff475a1fe4ef725deb02d0f2" +checksum = "bc0000e42512c92e31c2252315bda326620a4e034105e900c98ec492fa077b3e" dependencies = [ "rayon", ] +[[package]] +name = "js-sys" +version = "0.3.61" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "445dde2150c55e483f3d8416706b97ec8e8237c307e5b7b4b8dd15e6af2a0730" +dependencies = [ + "wasm-bindgen", +] + [[package]] name = "lazy_static" version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" +[[package]] +name = "lebe" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "03087c2bad5e1034e8cace5926dec053fb3790248370865f5117a7d0213354c8" + [[package]] name = "libc" -version = "0.2.85" +version = "0.2.139" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ccac4b00700875e6a07c6cde370d44d32fa01c5a65cdd2fca6858c479d28bb3" +checksum = "201de327520df007757c1f0adce6e827fe8562fbc28bfd9c15571c66ca1f5f79" [[package]] name = "linked-hash-map" @@ -340,6 +436,24 @@ version = "0.5.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7fb9b38af92608140b86b693604b9ffcc5824240a484d1ecd4795bacb2fe88f3" +[[package]] +name = "lock_api" +version = "0.4.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "88943dd7ef4a2e5a4bfa2753aaab3013e34ce2533d1996fb18ef591e315e2b3b" +dependencies = [ + "scopeguard", +] + +[[package]] +name = "log" +version = "0.4.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "abb12e687cfb44aa40f41fc3978ef76448f9b6038cad6aef4259d3c095a2382e" +dependencies = [ + "cfg-if", +] + [[package]] name = "memoffset" version = "0.6.1" @@ -351,21 +465,20 @@ dependencies = [ [[package]] name = "miniz_oxide" -version = "0.3.7" +version = "0.6.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "791daaae1ed6889560f8c4359194f56648355540573244a5448a83ba1ecc7435" +checksum = "b275950c28b37e794e8c55d88aeb5e139d0ce23fdbbeda68f8d7174abdf9e8fa" dependencies = [ - "adler32", + "adler", ] [[package]] -name = "miniz_oxide" -version = "0.4.3" +name = "nanorand" +version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0f2d26ec3309788e423cfbf68ad1800f061638098d76a83681af979dc4eda19d" +checksum = "6a51313c5820b0b02bd422f4b44776fbf47961755c74ce64afc73bfad10226c3" dependencies = [ - "adler", - "autocfg", + "getrandom", ] [[package]] @@ -378,22 +491,11 @@ dependencies = [ "num-traits", ] -[[package]] -name = "num-iter" -version = "0.1.42" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b2021c8337a54d21aca0d59a92577a029af9431cb59b909b03252b9c164fad59" -dependencies = [ - "autocfg", - "num-integer", - "num-traits", -] - [[package]] name = "num-rational" -version = "0.3.2" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "12ac428b1cb17fce6f731001d307d351ec70a6d202fc2e60f7d4c5e42d8f4f07" +checksum = "0638a1c9d0a3c0914158145bc76cff373a75a627e6ecbfb71cbe6f453a5a19b0" dependencies = [ "autocfg", "num-integer", @@ -419,25 +521,51 @@ dependencies = [ "libc", ] +[[package]] +name = "once_cell" +version = "1.17.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6f61fba1741ea2b3d6a1e3178721804bb716a68a6aeba1149b5d52e3d464ea66" + +[[package]] +name = "pin-project" +version = "1.0.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ad29a609b6bcd67fee905812e544992d216af9d755757c05ed2d0e15a74c6ecc" +dependencies = [ + "pin-project-internal", +] + +[[package]] +name = "pin-project-internal" +version = "1.0.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "069bdb1e05adc7a8990dce9cc75370895fbe4e3d58b9b73bf1aee56359344a55" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "png" -version = "0.16.8" +version = "0.17.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3c3287920cb847dee3de33d301c463fba14dda99db24214ddf93f83d3021f4c6" +checksum = "5d708eaf860a19b19ce538740d2b4bdeeb8337fa53f7738455e706623ad5c638" dependencies = [ "bitflags", "crc32fast", - "deflate 0.8.6", - "miniz_oxide 0.3.7", + "flate2", + "miniz_oxide", ] [[package]] name = "proc-macro2" -version = "1.0.24" +version = "1.0.51" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e0704ee1a7e00d7bb417d0770ea303c1bccbabf0ef1667dae92b5967f5f8a71" +checksum = "5d727cae5b39d21da60fa540906919ad737832fe0b1c165da3a34d6548c849d6" dependencies = [ - "unicode-xid", + "unicode-ident", ] [[package]] @@ -451,26 +579,23 @@ dependencies = [ [[package]] name = "rayon" -version = "1.5.0" +version = "1.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8b0d8e0819fadc20c74ea8373106ead0600e3a67ef1fe8da56e39b9ae7275674" +checksum = "6db3a213adf02b3bcfd2d3846bb41cb22857d131789e01df434fb7e7bc0759b7" dependencies = [ - "autocfg", - "crossbeam-deque", "either", "rayon-core", ] [[package]] name = "rayon-core" -version = "1.9.0" +version = "1.10.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ab346ac5921dc62ffa9f89b7a773907511cdfa5490c572ae9be1be33e8afa4a" +checksum = "356a0625f1954f730c0201cdab48611198dc6ce21f4acff55089b5a78e6e835b" dependencies = [ "crossbeam-channel", "crossbeam-deque", "crossbeam-utils", - "lazy_static", "num_cpus", ] @@ -486,15 +611,36 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" +[[package]] +name = "simd-adler32" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "14a5df39617d7c8558154693a1bb8157a4aab8179209540cc0b10e5dc24e0b18" + +[[package]] +name = "smallvec" +version = "1.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a507befe795404456341dfab10cef66ead4c041f62b8b11bbb92bffe5d0953e0" + +[[package]] +name = "spin" +version = "0.9.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7dccf47db1b41fa1573ed27ccf5e08e3ca771cb994f776668c5ebda893b248fc" +dependencies = [ + "lock_api", +] + [[package]] name = "syn" -version = "1.0.60" +version = "1.0.107" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c700597eca8a5a762beb35753ef6b94df201c81cca676604f547495a0d7f0081" +checksum = "1f4064b5b16e03ae50984a5a8ed5d4f8803e6bc1fd170a3cda91a1be4b18e3f5" dependencies = [ "proc-macro2", "quote", - "unicode-xid", + "unicode-ident", ] [[package]] @@ -526,22 +672,91 @@ dependencies = [ "syn", ] +[[package]] +name = "threadpool" +version = "1.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d050e60b33d41c19108b32cea32164033a9013fe3b46cbd4457559bfbf77afaa" +dependencies = [ + "num_cpus", +] + [[package]] name = "tiff" -version = "0.6.1" +version = "0.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a53f4706d65497df0c4349241deddf35f84cee19c87ed86ea8ca590f4464437" +checksum = "7449334f9ff2baf290d55d73983a7d6fa15e01198faef72af07e2a8db851e471" dependencies = [ + "flate2", "jpeg-decoder", - "miniz_oxide 0.4.3", "weezl", ] [[package]] -name = "unicode-xid" -version = "0.2.1" +name = "unicode-ident" +version = "1.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "84a22b9f218b40614adcb3f4ff08b703773ad44fa9423e4e0d346d5db86e4ebc" + +[[package]] +name = "wasi" +version = "0.11.0+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" + +[[package]] +name = "wasm-bindgen" +version = "0.2.84" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "31f8dcbc21f30d9b8f2ea926ecb58f6b91192c17e9d33594b3df58b2007ca53b" +dependencies = [ + "cfg-if", + "wasm-bindgen-macro", +] + +[[package]] +name = "wasm-bindgen-backend" +version = "0.2.84" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "95ce90fd5bcc06af55a641a86428ee4229e44e07033963a2290a8e241607ccb9" +dependencies = [ + "bumpalo", + "log", + "once_cell", + "proc-macro2", + "quote", + "syn", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-macro" +version = "0.2.84" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4c21f77c0bedc37fd5dc21f897894a5ca01e7bb159884559461862ae90c0b4c5" +dependencies = [ + "quote", + "wasm-bindgen-macro-support", +] + +[[package]] +name = "wasm-bindgen-macro-support" +version = "0.2.84" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2aff81306fcac3c7515ad4e177f521b5c9a15f2b08f4e32d823066102f35a5f6" +dependencies = [ + "proc-macro2", + "quote", + "syn", + "wasm-bindgen-backend", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-shared" +version = "0.2.84" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f7fe0bb3479651439c9112f72b6c505038574c9fbb575ed1bf3b797fa39dd564" +checksum = "0046fef7e28c3804e5e38bfa31ea2a0f73905319b677e57ebe37e49358989b5d" [[package]] name = "weezl" @@ -579,3 +794,12 @@ checksum = "56c1936c4cc7a1c9ab21a1ebb602eb942ba868cbd44a99cb7cdc5892335e1c85" dependencies = [ "linked-hash-map", ] + +[[package]] +name = "zune-inflate" +version = "0.2.42" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c473377c11c4a3ac6a2758f944cd336678e9c977aa0abf54f6450cf77e902d6d" +dependencies = [ + "simd-adler32", +] diff --git a/Cargo.toml b/Cargo.toml index 0e03ff4..d0e7d1e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "icon-cutter" -version = "0.1.5" +version = "0.1.6" authors = ["L "] edition = "2018" license = "AGPL" @@ -9,8 +9,8 @@ homepage = "https://github.com/tgstation/icon-cutter" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -dmi = { git = "https://github.com/spacestation13/dmi", version = "0.1" } +dmi = { git = "https://github.com/spacestation13/dmi", tag = "v0.2.1" } anyhow = "1.0" -image = "0.23" +image = "0.24" yaml-rust = "0.4" dont_disappear = "3.0" diff --git a/src/config.rs b/src/config.rs index c9d2808..90d7617 100644 --- a/src/config.rs +++ b/src/config.rs @@ -142,8 +142,8 @@ impl PrefHolder { imageops::replace( &mut corners_image, frame_img, - (index * self.icon_size_x) + self.west_start, - self.north_start, + ((index * self.icon_size_x) + self.west_start).into(), + self.north_start.into(), ); let frame_img = &corners .get_mut(&glob::NE_INDEX) @@ -153,8 +153,8 @@ impl PrefHolder { imageops::replace( &mut corners_image, frame_img, - (index * self.icon_size_x) + self.east_start, - self.north_start, + ((index * self.icon_size_x) + self.east_start).into(), + self.north_start.into(), ); let frame_img = &corners .get_mut(&glob::SE_INDEX) @@ -164,8 +164,8 @@ impl PrefHolder { imageops::replace( &mut corners_image, frame_img, - (index * self.icon_size_x) + self.east_start, - self.south_start, + ((index * self.icon_size_x) + self.east_start).into(), + self.south_start.into(), ); let frame_img = &corners .get_mut(&glob::SW_INDEX) @@ -175,8 +175,8 @@ impl PrefHolder { imageops::replace( &mut corners_image, frame_img, - (index * self.icon_size_x) + self.west_start, - self.south_start, + ((index * self.icon_size_x) + self.west_start).into(), + self.south_start.into(), ); index += 1; } @@ -463,12 +463,11 @@ pub fn read_some_string_config(source: &yaml_rust::yaml::Yaml, index: &str) -> O } pub fn load_configs(caller_path: String) -> Result { - let config_path; let last_slash = caller_path.rfind(|c| c == '/' || c == '\\'); - if last_slash != None { - config_path = caller_path[..last_slash.unwrap()].to_string(); + let config_path: String = if let Some(last_idx) = last_slash { + caller_path[..last_idx].to_string() } else { - config_path = ".".to_string(); + ".".to_string() }; let path = Path::new(&config_path).join("config.yaml"); let mut file = File::open(path)?; @@ -740,9 +739,8 @@ pub fn load_configs(caller_path: String) -> Result { None => 1, }; - let delay; - if frames_per_state == 1 { - delay = None; + let delay = if frames_per_state == 1 { + None } else { let mut delay_vec = vec![]; if doc["delay"].is_badvalue() { @@ -750,9 +748,8 @@ pub fn load_configs(caller_path: String) -> Result { delay_vec.push(1_f32) // List is empty, let's fill it with an arbitrary value. } } else { - let yaml_delay; - match doc["delay"].as_vec() { - Some(thing) => yaml_delay = thing, + let yaml_delay = match doc["delay"].as_vec() { + Some(thing) => thing, None => bail!("Delay config improperly set. Please look at the example files for the proper format. Contents: {:?}", doc["delay"]) }; for delay_value in yaml_delay.iter() { @@ -780,26 +777,23 @@ pub fn load_configs(caller_path: String) -> Result { } } }; - delay = Some(delay_vec); + Some(delay_vec) }; - let produce_corners; - if doc["produce_corners"].is_badvalue() { - produce_corners = false; + let produce_corners: bool = if doc["produce_corners"].is_badvalue() { + false } else { - produce_corners = doc["produce_corners"].as_bool().unwrap_or(false) + doc["produce_corners"].as_bool().unwrap_or(false) }; - let produce_dirs; - if doc["produce_dirs"].is_badvalue() { - produce_dirs = false; + let produce_dirs: bool = if doc["produce_dirs"].is_badvalue() { + false } else { - produce_dirs = doc["produce_dirs"].as_bool().unwrap_or(false) + doc["produce_dirs"].as_bool().unwrap_or(false) }; - let prefabs; - if doc["prefabs"].is_badvalue() { - prefabs = None; + let prefabs = if doc["prefabs"].is_badvalue() { + None } else { let mut prefab_map: HashMap = HashMap::new(); let yaml_prefabs = match doc["prefabs"].as_hash() { @@ -821,12 +815,11 @@ pub fn load_configs(caller_path: String) -> Result { }; prefab_map.insert(signature, position); } - prefabs = Some(prefab_map); - } + Some(prefab_map) + }; - let prefab_overlays; - if doc["prefab_overlays"].is_badvalue() { - prefab_overlays = None; + let prefab_overlays = if doc["prefab_overlays"].is_badvalue() { + None } else { let mut overlays_map: HashMap> = HashMap::new(); let yaml_prefab_overlays = match doc["prefab_overlays"].as_hash() { @@ -866,7 +859,7 @@ pub fn load_configs(caller_path: String) -> Result { }; overlays_map.insert(signature, overlay_vec); } - prefab_overlays = Some(overlays_map); + Some(overlays_map) }; let dmi_version = match read_some_string_config(doc, "dmi_version") { @@ -874,7 +867,8 @@ pub fn load_configs(caller_path: String) -> Result { None => "4.0".to_string(), }; - let is_diagonal = se_flat != None && nw_flat != None && ne_flat != None && sw_flat != None; + let is_diagonal = + se_flat.is_some() && nw_flat.is_some() && ne_flat.is_some() && sw_flat.is_some(); Ok(PrefHolder { file_to_open, diff --git a/src/helpers.rs b/src/helpers.rs index 4ff104f..9f54c00 100644 --- a/src/helpers.rs +++ b/src/helpers.rs @@ -167,7 +167,7 @@ pub fn dir_offset_signature(icon_signature: u8, byond_dir: u8) -> Result String { - let dot_offset = text.find('.').unwrap_or_else(|| text.len()); + let dot_offset = text.find('.').unwrap_or(text.len()); text.drain(dot_offset..); //.collect(); text } diff --git a/src/main.rs b/src/main.rs index abd2cba..904dc76 100644 --- a/src/main.rs +++ b/src/main.rs @@ -20,9 +20,8 @@ fn main() { let self_path = args.remove(0); - let prefs; - match config::load_configs(self_path) { - Ok(thing) => prefs = thing, + let prefs = match config::load_configs(self_path) { + Ok(thing) => thing, Err(_e) => { println!("Failed to load configs.\nSolution: add a properly-filled config.yaml file to the folder executing the program. Check the namesake folder for examples."); dont_disappear::any_key_to_continue::default(); @@ -43,7 +42,7 @@ fn main() { for (icons_built, image_path_string) in args.iter().enumerate() { let path = Path::new(&image_path_string); - let mut file = match File::open(&path) { + let mut file = match File::open(path) { Ok(f) => f, Err(e) => { println!("Wrong file path: {:#?}", e); @@ -63,7 +62,7 @@ fn main() { let dot_offset = image_path_string .find('.') - .unwrap_or_else(|| image_path_string.len()); + .unwrap_or(image_path_string.len()); formatted_file_name = formatted_file_name.drain(..dot_offset).collect(); //Here we remove everything after the dot. Whether .dmi or .png is the same for us. let building_return = build_icons(cursor, formatted_file_name, &prefs, icons_built); @@ -84,7 +83,7 @@ fn build_icons( prefs: &config::PrefHolder, icons_built: usize, ) -> Result { - let (corners, mounted_prefabs) = prefs.build_corners_and_prefabs(input, &*file_string_path)?; + let (corners, mounted_prefabs) = prefs.build_corners_and_prefabs(input, &file_string_path)?; let possible_icon_states = prepare_icon_states(prefs.is_diagonal); @@ -94,11 +93,11 @@ fn build_icons( "prepare_icon_states() produced {} results", number_of_icon_states ); - let icon_directions; - if prefs.produce_dirs { - icon_directions = glob::BYOND_CARDINALS.to_vec(); + + let icon_directions = if prefs.produce_dirs { + glob::BYOND_CARDINALS.to_vec() } else { - icon_directions = vec![glob::BYOND_SOUTH]; + vec![glob::BYOND_SOUTH] }; let output_name = match &prefs.output_name { @@ -150,8 +149,8 @@ fn build_icons( imageops::replace( &mut image_frame, &mounted_prefabs[icon_signature][frame as usize], - prefs.output_west_start, - prefs.output_north_start, + prefs.output_west_start.into(), + prefs.output_north_start.into(), ); icon_state_images.push(image_frame); } @@ -172,8 +171,8 @@ fn build_icons( imageops::overlay( &mut image_frame, corner_img, - prefs.output_west_start, - prefs.output_north_start, + prefs.output_west_start.into(), + prefs.output_north_start.into(), ); let corner_img = &corners .get(&glob::NE_INDEX) @@ -186,8 +185,8 @@ fn build_icons( imageops::overlay( &mut image_frame, corner_img, - prefs.output_east_start, - prefs.output_north_start, + prefs.output_east_start.into(), + prefs.output_north_start.into(), ); let corner_img = &corners .get(&glob::SE_INDEX) @@ -200,8 +199,8 @@ fn build_icons( imageops::overlay( &mut image_frame, corner_img, - prefs.output_east_start, - prefs.output_south_start, + prefs.output_east_start.into(), + prefs.output_south_start.into(), ); let corner_img = &corners .get(&glob::SW_INDEX) @@ -214,8 +213,8 @@ fn build_icons( imageops::overlay( &mut image_frame, corner_img, - prefs.output_west_start, - prefs.output_south_start, + prefs.output_west_start.into(), + prefs.output_south_start.into(), ); icon_state_images.push(image_frame); } @@ -255,7 +254,7 @@ fn build_icons( }; let output_name = format!("{}.dmi", output_name); let dmi_path = Path::new(&output_name); - let mut file = File::create(&dmi_path)?; + let mut file = File::create(dmi_path)?; new_icon.save(&mut file)?; println!(