diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..352a626 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,5 @@ +{ + "rust-analyzer.linkedProjects": [ + "./Cargo.toml" + ] +} \ No newline at end of file diff --git a/Cargo.lock b/Cargo.lock index 2701ca5..3441f97 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -11,12 +11,6 @@ dependencies = [ "winapi", ] -[[package]] -name = "anyhow" -version = "1.0.81" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0952808a6c2afd1aa8947271f3a60f1a6763c7b912d210184c5149b5cf147247" - [[package]] name = "atty" version = "0.2.14" @@ -114,12 +108,6 @@ dependencies = [ "wasi", ] -[[package]] -name = "glob" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b" - [[package]] name = "hermit-abi" version = "0.1.19" @@ -129,30 +117,6 @@ dependencies = [ "libc", ] -[[package]] -name = "include_dir" -version = "0.6.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "24b56e147e6187d61e9d0f039f10e070d0c0a887e24fe0bb9ca3f29bfde62cab" -dependencies = [ - "glob", - "include_dir_impl", - "proc-macro-hack", -] - -[[package]] -name = "include_dir_impl" -version = "0.6.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0a0c890c85da4bab7bce4204c707396bbd3c6c8a681716a51c8814cfc2b682df" -dependencies = [ - "anyhow", - "proc-macro-hack", - "proc-macro2", - "quote", - "syn 1.0.109", -] - [[package]] name = "itoa" version = "1.0.10" @@ -176,11 +140,9 @@ name = "pokerust" version = "0.1.0" dependencies = [ "clap", - "include_dir", "once_cell", "rand", "rust-embed", - "serde", "serde_json", ] @@ -190,12 +152,6 @@ version = "0.2.17" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" -[[package]] -name = "proc-macro-hack" -version = "0.5.20+deprecated" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc375e1527247fe1a97d8b7156678dfe7c1af2fc075c9a4db3690ecd2a148068" - [[package]] name = "proc-macro2" version = "1.0.79" @@ -264,7 +220,7 @@ dependencies = [ "proc-macro2", "quote", "rust-embed-utils", - "syn 2.0.55", + "syn", "walkdir", ] @@ -310,7 +266,7 @@ checksum = "7eb0b34b42edc17f6b7cac84a52a1c5f0e1bb2227e997ca9011ea3dd34e8610b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.55", + "syn", ] [[package]] @@ -341,17 +297,6 @@ version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a" -[[package]] -name = "syn" -version = "1.0.109" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" -dependencies = [ - "proc-macro2", - "quote", - "unicode-ident", -] - [[package]] name = "syn" version = "2.0.55" diff --git a/Cargo.toml b/Cargo.toml index 7efcde5..97b5ff7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -3,14 +3,10 @@ name = "pokerust" version = "0.1.0" edition = "2021" -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - [dependencies] +clap = "2.0.0" rand = "0.8" -serde = { version = "1.0", features = ["derive"] } serde_json = "1.0" once_cell = "1.8.0" -clap = { version = "2" } -include_dir = "0.6.0" rust-embed = "8.3.0" diff --git a/README.md b/README.md index 9ff8847..defdd85 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,9 @@ # PokeRust +*For educational purposes* A simple colorscript written in Rust. -Inspired by [phoneybadger's pokemon-coloscripts](https://gitlab.com/phoneybadger/pokemon-colorscripts) - -*For educational purposes* +Inspired by [phoneybadger's pokemon-coloscripts](https://gitlab.com/phoneybadger/pokemon-colorscripts). ## Performance @@ -16,3 +15,9 @@ This is the Python implementation: This is the Rust implementation: ![rust implementation](img/screenshot_250324_132205.png) + +## Credits + +- [phoneybadger](https://gitlab.com/phoneybadger) for the original colorscripts and inspiration. +- [talwat](https://github.com/talwat/pokeget-rs) for Rust code reference. (fast af implementation at ~1ms) +- [msikma](https://github.com/msikma/pokesprite/) for the colorscripts' sprites. diff --git a/build/arch/PKGBUILD b/build/arch/PKGBUILD index 1202c3a..2f9eb7e 100644 --- a/build/arch/PKGBUILD +++ b/build/arch/PKGBUILD @@ -1,7 +1,7 @@ pkgname=pokerust-git pkgdesc="Pokemon Colorscripts written in Rust" _gitname=pokerust -pkgver=r8.c1e2b64 +pkgver=r21.28c9d43 pkgrel=1 arch=('x86_64') url="https://github.com/Vomitblood/$_gitname" @@ -21,10 +21,14 @@ pkgver() { build() { cd "$srcdir/$_gitname" + # build main program cargo build --release + # build mini program + cargo build --release --bin minimon } package() { cd "$srcdir/$_gitname" install -Dm755 target/release/$_gitname "$pkgdir/usr/bin/$_gitname" + install -Dm755 target/release/minimon "$pkgdir/usr/bin/minimon" } diff --git a/src/bin/minimon.rs b/src/bin/minimon.rs new file mode 100644 index 0000000..995d9a2 --- /dev/null +++ b/src/bin/minimon.rs @@ -0,0 +1,19 @@ +use rand::prelude::SliceRandom; +use rust_embed::RustEmbed; +use std::str; + +#[derive(RustEmbed)] +#[folder = "colorscripts/small/regular/"] +struct ColorScriptsDir; + +fn main() { + let files: Vec<_> = ColorScriptsDir::iter().collect(); + let mut rng = rand::thread_rng(); + + if let Some(random_file) = files.choose(&mut rng) { + println!("Random Pokémon Sprite: {}", random_file); + if let Some(file_data) = ColorScriptsDir::get(random_file) { + println!("{}", std::str::from_utf8(file_data.data.as_ref()).unwrap()); + } + } +} diff --git a/src/main.rs b/src/main.rs index ffbf6cf..d41b6d4 100644 --- a/src/main.rs +++ b/src/main.rs @@ -3,7 +3,7 @@ use rand::Rng; // set global constants #[derive(rust_embed::RustEmbed)] #[folder = "colorscripts/"] -pub struct ColorScriptsDir; +struct ColorScriptsDir; const POKEMON_JSON: &str = std::include_str!("../pokemon.json");