diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml new file mode 100644 index 0000000..dffc2d7 --- /dev/null +++ b/.github/workflows/check.yml @@ -0,0 +1,21 @@ +name: Check + +on: + workflow_dispatch: + +jobs: + check-windows: + name: Cargo check + runs-on: windows-latest + + steps: + - uses: actions/checkout@v4 + + - name: Install Rust + uses: dtolnay/rust-toolchain@stable + + - name: Cargo check + run: cargo check --release + + - name: Cargo test + run: cargo test --release \ No newline at end of file diff --git a/.github/workflows/master.yml b/.github/workflows/master.yml new file mode 100644 index 0000000..6dc17d5 --- /dev/null +++ b/.github/workflows/master.yml @@ -0,0 +1,73 @@ +name: Build & Release PR > Master + +on: + # Run checks on pull requests to main + pull_request: + branches: + - master + + # Create release draft when code is merged into main + push: + branches: + - master + +permissions: + contents: write + +jobs: + check: + if: github.event_name == 'pull_request' + name: Cargo Check & Test (PR) + runs-on: windows-latest + + steps: + - uses: actions/checkout@v4 + - uses: dtolnay/rust-toolchain@stable + + - name: Cargo check + run: cargo check --release + + - name: Cargo test + run: cargo test --release + + release: + if: github.event_name == 'push' && github.ref == 'refs/heads/main' + name: Build and Draft Release (Windows) + runs-on: windows-latest + needs: [] # can't "need" PR jobs, different event type + + steps: + - uses: actions/checkout@v4 + - uses: dtolnay/rust-toolchain@stable + + - name: Build release binary + run: cargo build --release --target x86_64-pc-windows-msvc + + - name: Prepare artifact folder + run: | + mkdir dist + mkdir dist\GammaEditor + mkdir dist\GammaEditor\logs + copy target\x86_64-pc-windows-msvc\release\gammaeditor.exe dist\GammaEditor\gammaeditor.exe + + - name: Extract latest changelog section + id: changelog + shell: bash + run: | + CONTENT=$(awk ' + /^## \[/ { if (NR>1) exit } NR>1 { print } + ' CHANGELOG.md) + + echo "changelog<> $GITHUB_OUTPUT + echo "$CONTENT" >> $GITHUB_OUTPUT + echo "EOF" >> $GITHUB_OUTPUT + + - name: Create GitHub Release (draft) + uses: softprops/action-gh-release@v2 + with: + draft: true + tag_name: "v${{ github.run_number }}" + name: "GammaEditor v${{ github.run_number }}" + body: ${{ steps.changelog.outputs.changelog }} + files: | + dist/GammaEditor/gammaeditor.exe diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..d6d0554 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,60 @@ +name: Release + +on: + workflow_dispatch: + +permissions: + contents: write + +jobs: + release-windows: + name: Build and Draft Release (Windows) + runs-on: windows-latest + + steps: + - uses: actions/checkout@v4 + + - name: Install Rust + uses: dtolnay/rust-toolchain@stable + + - name: Build release binary + run: cargo build --release --target x86_64-pc-windows-msvc + + - name: Prepare artifact folder + run: | + mkdir dist + mkdir dist\GammaEditor + mkdir dist\GammaEditor\logs + copy target\x86_64-pc-windows-msvc\release\gammaeditor.exe dist\GammaEditor\gammaeditor.exe + + - name: Create ZIP archive + run: | + $zipName = "GammaEditor-${{ github.ref_name }}.zip" + Compress-Archive -Path "dist\GammaEditor" -DestinationPath "dist\$zipName" + Write-Host "Created archive: dist\$zipName" + + - name: Extract changelog for this version + id: changelog + shell: bash + run: | + TAG_NAME="${GITHUB_REF#refs/tags/}" + echo "Tag: $TAG_NAME" + CONTENT=$(awk -v tag="## [${TAG_NAME#v}]" ' + $0 == tag {flag=1; next} + /^## \[/ && flag {exit} + flag {print} + ' CHANGELOG.md) + + echo "changelog<> $GITHUB_OUTPUT + echo "$CONTENT" >> $GITHUB_OUTPUT + echo "EOF" >> $GITHUB_OUTPUT + + - name: Create GitHub Release (draft) + uses: softprops/action-gh-release@v2 + with: + draft: true + tag_name: ${{ github.ref_name }} + name: "GammaEditor ${{ github.ref_name }}" + body: ${{ steps.changelog.outputs.changelog }} + files: | + dist/GammaEditor-${{ github.ref_name }}.zip diff --git a/.gitignore b/.gitignore index 4804dba..8370dee 100644 --- a/.gitignore +++ b/.gitignore @@ -136,5 +136,4 @@ dist # Generated by Cargo # will have compiled files and executables -/target/ -/images/ \ No newline at end of file +/target/ \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..3d1ad5c --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,10 @@ +# Changelog + +## [0.2.0] +- Added nickname editor +- Added icon in singlescreen +- Added shiny toggle +- Images are now loaded from cache on startup (rather than loaded at runtime) +- Stopped terminal from popping up on start. +- Added App icon +- Added App icon and version in titlebar \ No newline at end of file diff --git a/Cargo.lock b/Cargo.lock index 4efc382..401a175 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -136,6 +136,15 @@ dependencies = [ "memchr", ] +[[package]] +name = "aligned-vec" +version = "0.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc890384c8602f339876ded803c97ad529f3842aba97f6392b3dba0dd171769b" +dependencies = [ + "equator", +] + [[package]] name = "android-activity" version = "0.6.0" @@ -190,6 +199,18 @@ version = "1.0.13" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5192cca8006f1fd4f7237516f40fa183bb07f8fbdfedaa0036de5ea9b0b45e78" +[[package]] +name = "anyhow" +version = "1.0.100" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a23eb6b1614318a8071c9b2521f36b424b2c83db5eb3a0fead4a6c0809af6e61" + +[[package]] +name = "arbitrary" +version = "1.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c3d036a3c4ab069c7b410a2ce876bd74808d2d0888a82667669f8e783a898bf1" + [[package]] name = "arboard" version = "3.6.1" @@ -210,6 +231,17 @@ dependencies = [ "x11rb", ] +[[package]] +name = "arg_enum_proc_macro" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ae92a5119aa49cdbcf6b9f893fe4e1d98b04ccbf82ee0584ad948a44a734dea" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "arrayref" version = "0.3.9" @@ -474,6 +506,29 @@ version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ace50bade8e6234aa140d9a2f552bbee1db4d353f69b8217bc503490fc1a9f26" +[[package]] +name = "av1-grain" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4f3efb2ca85bc610acfa917b5aaa36f3fcbebed5b3182d7f877b02531c4b80c8" +dependencies = [ + "anyhow", + "arrayvec", + "log", + "nom", + "num-rational", + "v_frame", +] + +[[package]] +name = "avif-serialize" +version = "0.8.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "47c8fbc0f831f4519fe8b810b6a7a91410ec83031b8233f730a0480029f6a23f" +dependencies = [ + "arrayvec", +] + [[package]] name = "base64" version = "0.22.1" @@ -495,6 +550,12 @@ version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5e764a1d40d510daf35e07be9eb06e75770908c27d411ee6c92109c9840eaaf7" +[[package]] +name = "bit_field" +version = "0.10.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e4b40c7323adcfc0a41c4b88143ed58346ff65a288fc144329c5c45e05d70c6" + [[package]] name = "bitflags" version = "1.3.2" @@ -507,12 +568,27 @@ version = "2.9.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2261d10cca569e4643e526d8dc2e62e433cc8aba21ab764233731f8d369bf394" +[[package]] +name = "bitstream-io" +version = "2.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6099cdc01846bc367c4e7dd630dc5966dccf36b652fae7a74e17b640411a91b2" + [[package]] name = "block" version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0d8c1fef690941d3e7788d328517591fecc684c084084702d6ff1641e993699a" +[[package]] +name = "block-buffer" +version = "0.10.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3078c7629b62d3f0439517fa394996acacc5cbc91c5a20d8c658e77abd503a71" +dependencies = [ + "generic-array", +] + [[package]] name = "block2" version = "0.5.1" @@ -544,6 +620,12 @@ dependencies = [ "piper", ] +[[package]] +name = "built" +version = "0.7.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "56ed6191a7e78c36abdb16ab65341eefd73d64d303fffccdbb00d51e4205967b" + [[package]] name = "bumpalo" version = "3.17.0" @@ -637,6 +719,16 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6d43a04d8753f35258c91f8ec639f792891f748a1edbd759cf1dcea3382ad83c" +[[package]] +name = "cfg-expr" +version = "0.15.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d067ad48b8650848b989a59a86c6c36a995d02d2bf778d45c3c5d57bc2718f02" +dependencies = [ + "smallvec", + "target-lexicon", +] + [[package]] name = "cfg-if" version = "1.0.0" @@ -842,6 +934,15 @@ dependencies = [ "libc", ] +[[package]] +name = "cpufeatures" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "59ed5838eebb26a2bb2e58f6d5b5316989ae9d08bab10e0e6d103e656d1b0280" +dependencies = [ + "libc", +] + [[package]] name = "crc32fast" version = "1.4.2" @@ -862,7 +963,7 @@ dependencies = [ "ciborium", "clap", "criterion-plot", - "itertools", + "itertools 0.13.0", "num-traits", "oorandom", "plotters", @@ -881,7 +982,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9b1bcc0dc7dfae599d84ad0b1a55f80cde8af3725da8313b528da95ef783e338" dependencies = [ "cast", - "itertools", + "itertools 0.13.0", ] [[package]] @@ -915,6 +1016,16 @@ version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "460fbee9c2c2f33933d720630a6a0bac33ba7053db5344fac858d4b8952d77d5" +[[package]] +name = "crypto-common" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3" +dependencies = [ + "generic-array", + "typenum", +] + [[package]] name = "cursor-icon" version = "1.2.0" @@ -972,6 +1083,16 @@ dependencies = [ "serde", ] +[[package]] +name = "digest" +version = "0.10.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" +dependencies = [ + "block-buffer", + "crypto-common", +] + [[package]] name = "dispatch" version = "0.2.0" @@ -1282,6 +1403,26 @@ version = "0.33.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "66054d943c66715c6003a27a3dc152d87cadf714ef2597ccd79f550413009b97" +[[package]] +name = "equator" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4711b213838dfee0117e3be6ac926007d7f433d7bbe33595975d4190cb07e6fc" +dependencies = [ + "equator-macro", +] + +[[package]] +name = "equator-macro" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "44f23cf4b44bfce11a86ace86f8a73ffdec849c9fd00a386a53d278bd9e81fb3" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "equivalent" version = "1.0.2" @@ -1334,6 +1475,21 @@ dependencies = [ "pin-project-lite", ] +[[package]] +name = "exr" +version = "1.73.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f83197f59927b46c04a183a619b7c29df34e63e63c7869320862268c0ef687e0" +dependencies = [ + "bit_field", + "half", + "lebe", + "miniz_oxide", + "rayon-core", + "smallvec", + "zune-inflate", +] + [[package]] name = "fastrand" version = "2.3.0" @@ -1508,7 +1664,7 @@ dependencies = [ [[package]] name = "gammaeditor" -version = "0.1.0" +version = "0.2.0" dependencies = [ "chrono", "criterion", @@ -1516,11 +1672,24 @@ dependencies = [ "egui", "egui_extras", "gvas", + "image", "indexmap 2.11.3", "ordered-float", "rfd", + "rust-embed", "serde", "serde_json", + "winresource", +] + +[[package]] +name = "generic-array" +version = "0.14.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4bb6743198531e02858aeaea5398fcc883e71851fcbcb5a2f773e2fb6cb1edf2" +dependencies = [ + "typenum", + "version_check", ] [[package]] @@ -1760,6 +1929,12 @@ dependencies = [ "foldhash 0.2.0", ] +[[package]] +name = "heck" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" + [[package]] name = "hermit-abi" version = "0.5.2" @@ -1924,12 +2099,19 @@ dependencies = [ "bytemuck", "byteorder-lite", "color_quant", + "exr", "gif", "image-webp", "moxcms", "num-traits", "png 0.18.0", + "qoi", + "ravif", + "rayon", + "rgb", "tiff", + "zune-core", + "zune-jpeg", ] [[package]] @@ -1948,6 +2130,12 @@ version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "edcd27d72f2f071c64249075f42e205ff93c9a4c5f6c6da53e79ed9f9832c285" +[[package]] +name = "imgref" +version = "1.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e7c5cedc30da3a610cac6b4ba17597bdf7152cf974e8aab3afb3d54455e371c8" + [[package]] name = "indexmap" version = "1.9.3" @@ -1971,6 +2159,26 @@ dependencies = [ "serde_core", ] +[[package]] +name = "interpolate_name" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c34819042dc3d3971c46c2190835914dfbe0c3c13f61449b2997f4e9722dfa60" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "itertools" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba291022dbbd398a455acf126c1e341954079855bc60dfdda641363bd6922569" +dependencies = [ + "either", +] + [[package]] name = "itertools" version = "0.13.0" @@ -2056,12 +2264,28 @@ dependencies = [ "smallvec", ] +[[package]] +name = "lebe" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a79a3332a6609480d7d0c9eab957bca6b455b91bb84e66d19f5ff66294b85b8" + [[package]] name = "libc" version = "0.2.172" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d750af042f7ef4f724306de029d18836c26c1765a54a6a3f094cbd23a7267ffa" +[[package]] +name = "libfuzzer-sys" +version = "0.4.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5037190e1f70cbeef565bd267599242926f724d3b8a9f510fd7e0b540cfa4404" +dependencies = [ + "arbitrary", + "cc", +] + [[package]] name = "libloading" version = "0.8.9" @@ -2128,6 +2352,15 @@ version = "0.4.28" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "34080505efa8e45a4b816c349525ebe327ceaa8559756f0356cba97ef3bf7432" +[[package]] +name = "loop9" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fae87c125b03c1d2c0150c90365d7d6bcc53fb73a9acaef207d2d065860f062" +dependencies = [ + "imgref", +] + [[package]] name = "malloc_buf" version = "0.0.6" @@ -2137,6 +2370,16 @@ dependencies = [ "libc", ] +[[package]] +name = "maybe-rayon" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ea1f30cedd69f0a2954655f7188c6a834246d2bcf1e315e2ac40c4b24dc9519" +dependencies = [ + "cfg-if", + "rayon", +] + [[package]] name = "memchr" version = "2.7.4" @@ -2194,6 +2437,12 @@ dependencies = [ "unicase", ] +[[package]] +name = "minimal-lexical" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" + [[package]] name = "miniz_oxide" version = "0.8.8" @@ -2270,6 +2519,12 @@ dependencies = [ "jni-sys", ] +[[package]] +name = "new_debug_unreachable" +version = "1.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "650eef8c711430f1a879fdd01d4745a7deea475becfb90269c06775983bbf086" + [[package]] name = "nix" version = "0.30.1" @@ -2289,12 +2544,69 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2bf50223579dc7cdcfb3bfcacf7069ff68243f8c363f62ffa99cf000a6b9c451" +[[package]] +name = "nom" +version = "7.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d273983c5a657a70a3e8f2a01329822f3b8c8172b73826411a55751e404a0a4a" +dependencies = [ + "memchr", + "minimal-lexical", +] + +[[package]] +name = "noop_proc_macro" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0676bb32a98c1a483ce53e500a81ad9c3d5b3f7c920c28c24e9cb0980d0b5bc8" + +[[package]] +name = "num-bigint" +version = "0.4.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a5e44f723f1133c9deac646763579fdb3ac745e418f2a7af9cd0c431da1f20b9" +dependencies = [ + "num-integer", + "num-traits", +] + [[package]] name = "num-conv" version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "51d515d32fb182ee37cda2ccdcb92950d6a3c2893aa280e540671c2cd0f3b1d9" +[[package]] +name = "num-derive" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed3955f1a9c7c0c15e092f9c887db08b1fc683305fdf6eb6684f22555355e202" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "num-integer" +version = "0.1.46" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7969661fd2958a5cb096e56c8e1ad0444ac2bbcd0061bd28660485a44879858f" +dependencies = [ + "num-traits", +] + +[[package]] +name = "num-rational" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f83d14da390562dca69fc84082e73e548e1ad308d24accdedd2720017cb37824" +dependencies = [ + "num-bigint", + "num-integer", + "num-traits", +] + [[package]] name = "num-traits" version = "0.2.19" @@ -2940,6 +3252,19 @@ name = "profiling" version = "1.0.17" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3eb8486b569e12e2c32ad3e204dbaba5e4b5b216e9367044f25f1dba42341773" +dependencies = [ + "profiling-procmacros", +] + +[[package]] +name = "profiling-procmacros" +version = "1.0.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "52717f9a02b6965224f95ca2a81e2e0c5c43baacd28ca057577988930b6c3d5b" +dependencies = [ + "quote", + "syn", +] [[package]] name = "pxfm" @@ -2950,6 +3275,15 @@ dependencies = [ "num-traits", ] +[[package]] +name = "qoi" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f6d64c71eb498fe9eae14ce4ec935c555749aef511cca85b5568910d6e48001" +dependencies = [ + "bytemuck", +] + [[package]] name = "quick-error" version = "2.0.1" @@ -2996,6 +3330,8 @@ version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" dependencies = [ + "libc", + "rand_chacha 0.3.1", "rand_core 0.6.4", "serde", ] @@ -3006,10 +3342,20 @@ version = "0.9.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6db2770f06117d490610c7488547d543617b21bfa07796d7a12f6f1bd53850d1" dependencies = [ - "rand_chacha", + "rand_chacha 0.9.0", "rand_core 0.9.3", ] +[[package]] +name = "rand_chacha" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" +dependencies = [ + "ppv-lite86", + "rand_core 0.6.4", +] + [[package]] name = "rand_chacha" version = "0.9.0" @@ -3026,6 +3372,7 @@ version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" dependencies = [ + "getrandom 0.2.16", "serde", ] @@ -3044,6 +3391,56 @@ version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c3d6831663a5098ea164f89cff59c6284e95f4e3c76ce9848d4529f5ccca9bde" +[[package]] +name = "rav1e" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cd87ce80a7665b1cce111f8a16c1f3929f6547ce91ade6addf4ec86a8dda5ce9" +dependencies = [ + "arbitrary", + "arg_enum_proc_macro", + "arrayvec", + "av1-grain", + "bitstream-io", + "built", + "cfg-if", + "interpolate_name", + "itertools 0.12.1", + "libc", + "libfuzzer-sys", + "log", + "maybe-rayon", + "new_debug_unreachable", + "noop_proc_macro", + "num-derive", + "num-traits", + "once_cell", + "paste", + "profiling", + "rand 0.8.5", + "rand_chacha 0.3.1", + "simd_helpers", + "system-deps", + "thiserror 1.0.69", + "v_frame", + "wasm-bindgen", +] + +[[package]] +name = "ravif" +version = "0.11.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5825c26fddd16ab9f515930d49028a630efec172e903483c94796cfe31893e6b" +dependencies = [ + "avif-serialize", + "imgref", + "loop9", + "quick-error", + "rav1e", + "rayon", + "rgb", +] + [[package]] name = "raw-window-handle" version = "0.6.2" @@ -3190,6 +3587,40 @@ version = "0.20.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6c20b6793b5c2fa6553b250154b78d6d0db37e72700ae35fad9387a46f487c97" +[[package]] +name = "rust-embed" +version = "8.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "947d7f3fad52b283d261c4c99a084937e2fe492248cb9a68a8435a861b8798ca" +dependencies = [ + "rust-embed-impl", + "rust-embed-utils", + "walkdir", +] + +[[package]] +name = "rust-embed-impl" +version = "8.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5fa2c8c9e8711e10f9c4fd2d64317ef13feaab820a4c51541f1a8c8e2e851ab2" +dependencies = [ + "proc-macro2", + "quote", + "rust-embed-utils", + "syn", + "walkdir", +] + +[[package]] +name = "rust-embed-utils" +version = "8.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "60b161f275cb337fe0a44d924a5f4df0ed69c2c39519858f931ce61c779d3475" +dependencies = [ + "sha2", + "walkdir", +] + [[package]] name = "rustc-hash" version = "1.1.0" @@ -3362,6 +3793,24 @@ dependencies = [ "syn", ] +[[package]] +name = "serde_spanned" +version = "0.6.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bf41e0cfaf7226dca15e8197172c295a782857fcb97fad1808a166870dee75a3" +dependencies = [ + "serde", +] + +[[package]] +name = "serde_spanned" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e24345aa0fe688594e73770a5f6d1b216508b4f93484c0026d521acd30134392" +dependencies = [ + "serde_core", +] + [[package]] name = "serde_with" version = "3.12.0" @@ -3392,6 +3841,17 @@ dependencies = [ "syn", ] +[[package]] +name = "sha2" +version = "0.10.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a7507d819769d01a365ab707794a4084392c824f54a7a6a7862f8c3d0892b283" +dependencies = [ + "cfg-if", + "cpufeatures", + "digest", +] + [[package]] name = "shlex" version = "1.3.0" @@ -3413,6 +3873,15 @@ version = "0.3.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d66dc143e6b11c1eddc06d5c423cfc97062865baf299914ab64caa38182078fe" +[[package]] +name = "simd_helpers" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "95890f873bec569a0362c235787f3aca6e1e887302ba4840839bcc6459c42da6" +dependencies = [ + "quote", +] + [[package]] name = "simplecss" version = "0.2.2" @@ -3568,6 +4037,25 @@ dependencies = [ "syn", ] +[[package]] +name = "system-deps" +version = "6.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a3e535eb8dded36d55ec13eddacd30dec501792ff23a0b1682c38601b8cf2349" +dependencies = [ + "cfg-expr", + "heck", + "pkg-config", + "toml 0.8.22", + "version-compare", +] + +[[package]] +name = "target-lexicon" +version = "0.12.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "61c41af27dd6d1e27b1b16b489db798443478cef1f06a660c96db617ba5de3b1" + [[package]] name = "tempfile" version = "3.23.0" @@ -3721,11 +4209,50 @@ dependencies = [ "serde_json", ] +[[package]] +name = "toml" +version = "0.8.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "05ae329d1f08c4d17a59bed7ff5b5a769d062e64a62d34a3261b219e62cd5aae" +dependencies = [ + "serde", + "serde_spanned 0.6.9", + "toml_datetime 0.6.9", + "toml_edit", +] + +[[package]] +name = "toml" +version = "0.9.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ae2a4cf385da23d1d53bc15cdfa5c2109e93d8d362393c801e87da2f72f0e201" +dependencies = [ + "indexmap 2.11.3", + "serde_core", + "serde_spanned 1.0.3", + "toml_datetime 0.7.3", + "toml_parser", + "toml_writer", + "winnow", +] + [[package]] name = "toml_datetime" version = "0.6.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3da5db5a963e24bc68be8b17b6fa82814bb22ee8660f192bb182771d498f09a3" +dependencies = [ + "serde", +] + +[[package]] +name = "toml_datetime" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f2cdb639ebbc97961c51720f858597f7f24c4fc295327923af55b74c3c724533" +dependencies = [ + "serde_core", +] [[package]] name = "toml_edit" @@ -3734,10 +4261,27 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "310068873db2c5b3e7659d2cc35d21855dbafa50d1ce336397c666e3cb08137e" dependencies = [ "indexmap 2.11.3", - "toml_datetime", + "serde", + "serde_spanned 0.6.9", + "toml_datetime 0.6.9", + "winnow", +] + +[[package]] +name = "toml_parser" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b551886f449aa90d4fe2bdaa9f4a2577ad2dde302c61ecf262d80b116db95c10" +dependencies = [ "winnow", ] +[[package]] +name = "toml_writer" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "df8b2b54733674ad286d16267dcfc7a71ed5c776e4ac7aa3c3e2561f7c637bf2" + [[package]] name = "tracing" version = "0.1.41" @@ -3784,6 +4328,12 @@ dependencies = [ "rustc-hash 2.1.1", ] +[[package]] +name = "typenum" +version = "1.19.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "562d481066bde0658276a35467c4af00bdc6ee726305698a55b86e61d7ad82bb" + [[package]] name = "uds_windows" version = "1.1.0" @@ -3887,6 +4437,23 @@ version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b6c140620e7ffbb22c2dee59cafe6084a59b5ffc27a8859a5f0d494b5d52b6be" +[[package]] +name = "v_frame" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "666b7727c8875d6ab5db9533418d7c764233ac9c0cff1d469aec8fa127597be2" +dependencies = [ + "aligned-vec", + "num-traits", + "wasm-bindgen", +] + +[[package]] +name = "version-compare" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "852e951cb7832cb45cb1169900d19760cfa39b82bc0ea9c0e5a14ae88411c98b" + [[package]] name = "version_check" version = "0.9.5" @@ -4822,6 +5389,16 @@ dependencies = [ "memchr", ] +[[package]] +name = "winresource" +version = "0.1.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f1ef04dd590e94ff7431a8eda99d5ca659e688d60e930bd0a330062acea4608f" +dependencies = [ + "toml 0.9.6", + "version_check", +] + [[package]] name = "wit-bindgen" version = "0.46.0" @@ -5110,6 +5687,15 @@ version = "0.4.12" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3f423a2c17029964870cfaabb1f13dfab7d092a62a29a89264f4d36990ca414a" +[[package]] +name = "zune-inflate" +version = "0.2.54" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "73ab332fe2f6680068f3582b16a24f90ad7096d5d39b974d1c0aff0125116f02" +dependencies = [ + "simd-adler32", +] + [[package]] name = "zune-jpeg" version = "0.4.21" diff --git a/Cargo.toml b/Cargo.toml index 20e057b..fa924b5 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "gammaeditor" -version = "0.1.0" +version = "0.2.0" description = "A PkHex esque app for Gamma Engine games" authors = ["CalRL"] edition = "2021" @@ -16,11 +16,16 @@ eframe = "0.33.0" egui = { version = "0.33.0" } egui_extras = { version = "0.33.0", features = ["all_loaders"]} rfd = { version = "0.15.4" } +rust-embed="8.9.0" +image = { version = "0.25.8" } [dev-dependencies] ordered-float = { version = "4.6.0"} criterion = "0.7.0" +[build-dependencies] +winresource = "0.1.27" + [[bench]] name = "gvas_read" harness = false diff --git a/benches/gvas_read.rs b/benches/gvas_read.rs index 59deda1..0546f60 100644 --- a/benches/gvas_read.rs +++ b/benches/gvas_read.rs @@ -1,15 +1,15 @@ use criterion::{criterion_group, criterion_main, Criterion}; -use std::hint::black_box; +use gammaeditor::save::pokemon::pokemon_info::PokemonInfo; +use gammaeditor::{try_gvas_read, try_gvas_write}; +use gvas::game_version::GameVersion; +use gvas::GvasFile; use std::arch::x86_64::_rdtsc; use std::fs::File; +use std::hint::black_box; use std::io::Cursor; use std::path::PathBuf; use std::sync::{Arc, OnceLock, RwLock}; use std::time::Duration; -use gvas::game_version::GameVersion; -use gvas::GvasFile; -use gammaeditor::save::pokemon::pokemon_info::PokemonInfo; -use gammaeditor::{try_gvas_read, try_gvas_write}; fn bench_gvas_read(c: &mut Criterion) { let path = PathBuf::from("benches/resource/Slot1.sav"); @@ -19,7 +19,7 @@ fn bench_gvas_read(c: &mut Criterion) { group.measurement_time(Duration::from_secs(5)); group.bench_function("read (time)", |b| { - b.iter(|| { + b.iter(|| { let mut cursor = Cursor::new(black_box(&bytes)); let gvas = GvasFile::read(&mut cursor, GameVersion::Default).unwrap(); black_box(gvas); @@ -46,18 +46,16 @@ fn bench_gvas_read(c: &mut Criterion) { }); }); - let mut gvas: GvasFile = GvasFile::read(&mut Cursor::new(&bytes), GameVersion::Default).unwrap(); + let mut gvas: GvasFile = + GvasFile::read(&mut Cursor::new(&bytes), GameVersion::Default).unwrap(); group.bench_function("get a deep struct (time)", |b| { - b.iter(|| { - let g = black_box(&gvas); + b.iter(|| { + let g = black_box(&gvas); - let res = PokemonInfo::new_party(g) - .unwrap() - .get_stats(2) - .unwrap(); + let res = PokemonInfo::new_party(g).unwrap().get_stats(2).unwrap(); - black_box(res); - }) + black_box(res); + }) }); group.bench_function("get a deep struct (cycles)", |b| { @@ -69,10 +67,7 @@ fn bench_gvas_read(c: &mut Criterion) { let g = black_box(&gvas); - let res = PokemonInfo::new_party(g) - .unwrap() - .get_stats(2) - .unwrap(); + let res = PokemonInfo::new_party(g).unwrap().get_stats(2).unwrap(); let end = _rdtsc(); total_cycles += end - start; @@ -87,8 +82,9 @@ fn bench_gvas_read(c: &mut Criterion) { }); }); - let gvas: GvasFile = GvasFile::read(&mut Cursor::new(&bytes), GameVersion::Default).unwrap(); - pub static FAKE_STATIC: OnceLock>> = OnceLock::>>::new(); + let gvas: GvasFile = GvasFile::read(&mut Cursor::new(&bytes), GameVersion::Default).unwrap(); + pub static FAKE_STATIC: OnceLock>> = + OnceLock::>>::new(); FAKE_STATIC.set(Arc::new(RwLock::new(gvas))); group.bench_function("try gvas read (time)", |b| { b.iter(|| { diff --git a/build.rs b/build.rs new file mode 100644 index 0000000..d78ed72 --- /dev/null +++ b/build.rs @@ -0,0 +1,9 @@ +fn main() { + #[cfg(windows)] + { + let _ = winresource::WindowsResource::new() + .set_icon("images/pokeball.ico") + .compile() + .expect("Failed to add Windows icon"); + } +} \ No newline at end of file diff --git a/capabilities/default.json b/capabilities/default.json deleted file mode 100644 index 4cdbf49..0000000 --- a/capabilities/default.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "$schema": "../gen/schemas/desktop-schema.json", - "identifier": "default", - "description": "Capability for the main window", - "windows": ["main"], - "permissions": [ - "core:default", - "opener:default" - ] -} diff --git a/images/non_shiny.png b/images/non_shiny.png new file mode 100644 index 0000000..b9ac6bc Binary files /dev/null and b/images/non_shiny.png differ diff --git a/images/normal/Abra.png b/images/normal/Abra.png new file mode 100644 index 0000000..0e1183c Binary files /dev/null and b/images/normal/Abra.png differ diff --git a/images/normal/Absol.png b/images/normal/Absol.png new file mode 100644 index 0000000..ae7f136 Binary files /dev/null and b/images/normal/Absol.png differ diff --git a/images/normal/Aggron.png b/images/normal/Aggron.png new file mode 100644 index 0000000..bf54c0f Binary files /dev/null and b/images/normal/Aggron.png differ diff --git a/images/normal/Alakazam.png b/images/normal/Alakazam.png new file mode 100644 index 0000000..14a8abe Binary files /dev/null and b/images/normal/Alakazam.png differ diff --git a/images/normal/Altaria.png b/images/normal/Altaria.png new file mode 100644 index 0000000..8adc144 Binary files /dev/null and b/images/normal/Altaria.png differ diff --git a/images/normal/Anorith.png b/images/normal/Anorith.png new file mode 100644 index 0000000..a2c0373 Binary files /dev/null and b/images/normal/Anorith.png differ diff --git a/images/normal/Armaldo.png b/images/normal/Armaldo.png new file mode 100644 index 0000000..485948e Binary files /dev/null and b/images/normal/Armaldo.png differ diff --git a/images/normal/Aron.png b/images/normal/Aron.png new file mode 100644 index 0000000..0d4af44 Binary files /dev/null and b/images/normal/Aron.png differ diff --git a/images/normal/Azumarill.png b/images/normal/Azumarill.png new file mode 100644 index 0000000..913eb68 Binary files /dev/null and b/images/normal/Azumarill.png differ diff --git a/images/normal/Azurill.png b/images/normal/Azurill.png new file mode 100644 index 0000000..645d2c8 Binary files /dev/null and b/images/normal/Azurill.png differ diff --git a/images/normal/Bagon.png b/images/normal/Bagon.png new file mode 100644 index 0000000..4c6c287 Binary files /dev/null and b/images/normal/Bagon.png differ diff --git a/images/normal/Baltoy.png b/images/normal/Baltoy.png new file mode 100644 index 0000000..3bfb216 Binary files /dev/null and b/images/normal/Baltoy.png differ diff --git a/images/normal/Banette.png b/images/normal/Banette.png new file mode 100644 index 0000000..128ce4e Binary files /dev/null and b/images/normal/Banette.png differ diff --git a/images/normal/Barboach.png b/images/normal/Barboach.png new file mode 100644 index 0000000..35b77c3 Binary files /dev/null and b/images/normal/Barboach.png differ diff --git a/images/normal/Beautifly.png b/images/normal/Beautifly.png new file mode 100644 index 0000000..43288f5 Binary files /dev/null and b/images/normal/Beautifly.png differ diff --git a/images/normal/Beldum.png b/images/normal/Beldum.png new file mode 100644 index 0000000..9898945 Binary files /dev/null and b/images/normal/Beldum.png differ diff --git a/images/normal/Bellossom.png b/images/normal/Bellossom.png new file mode 100644 index 0000000..1535aae Binary files /dev/null and b/images/normal/Bellossom.png differ diff --git a/images/normal/Blaziken.png b/images/normal/Blaziken.png new file mode 100644 index 0000000..6711d28 Binary files /dev/null and b/images/normal/Blaziken.png differ diff --git a/images/normal/Breloom.png b/images/normal/Breloom.png new file mode 100644 index 0000000..5a30a0a Binary files /dev/null and b/images/normal/Breloom.png differ diff --git a/images/normal/Cacnea.png b/images/normal/Cacnea.png new file mode 100644 index 0000000..6ef068b Binary files /dev/null and b/images/normal/Cacnea.png differ diff --git a/images/normal/Cacturne.png b/images/normal/Cacturne.png new file mode 100644 index 0000000..97e77c1 Binary files /dev/null and b/images/normal/Cacturne.png differ diff --git a/images/normal/Camerupt.png b/images/normal/Camerupt.png new file mode 100644 index 0000000..be6e7d6 Binary files /dev/null and b/images/normal/Camerupt.png differ diff --git a/images/normal/Carvanha.png b/images/normal/Carvanha.png new file mode 100644 index 0000000..5c4e84c Binary files /dev/null and b/images/normal/Carvanha.png differ diff --git a/images/normal/Cascoon.png b/images/normal/Cascoon.png new file mode 100644 index 0000000..f03396f Binary files /dev/null and b/images/normal/Cascoon.png differ diff --git a/images/normal/Castform.png b/images/normal/Castform.png new file mode 100644 index 0000000..000c783 Binary files /dev/null and b/images/normal/Castform.png differ diff --git a/images/normal/Chimecho.png b/images/normal/Chimecho.png new file mode 100644 index 0000000..fb048a0 Binary files /dev/null and b/images/normal/Chimecho.png differ diff --git a/images/normal/Chinchou.png b/images/normal/Chinchou.png new file mode 100644 index 0000000..c036c87 Binary files /dev/null and b/images/normal/Chinchou.png differ diff --git a/images/normal/Clamperl.png b/images/normal/Clamperl.png new file mode 100644 index 0000000..9b33021 Binary files /dev/null and b/images/normal/Clamperl.png differ diff --git a/images/normal/Claydol.png b/images/normal/Claydol.png new file mode 100644 index 0000000..a88c4db Binary files /dev/null and b/images/normal/Claydol.png differ diff --git a/images/normal/Combusken.png b/images/normal/Combusken.png new file mode 100644 index 0000000..3841ca9 Binary files /dev/null and b/images/normal/Combusken.png differ diff --git a/images/normal/Corphish.png b/images/normal/Corphish.png new file mode 100644 index 0000000..0820aee Binary files /dev/null and b/images/normal/Corphish.png differ diff --git a/images/normal/Corsola.png b/images/normal/Corsola.png new file mode 100644 index 0000000..c681fe6 Binary files /dev/null and b/images/normal/Corsola.png differ diff --git a/images/normal/Cradily.png b/images/normal/Cradily.png new file mode 100644 index 0000000..7b2ff11 Binary files /dev/null and b/images/normal/Cradily.png differ diff --git a/images/normal/Crawdaunt.png b/images/normal/Crawdaunt.png new file mode 100644 index 0000000..ee72378 Binary files /dev/null and b/images/normal/Crawdaunt.png differ diff --git a/images/normal/Crobat.png b/images/normal/Crobat.png new file mode 100644 index 0000000..536314c Binary files /dev/null and b/images/normal/Crobat.png differ diff --git a/images/normal/Delcatty.png b/images/normal/Delcatty.png new file mode 100644 index 0000000..653fa27 Binary files /dev/null and b/images/normal/Delcatty.png differ diff --git a/images/normal/Deoxys.png b/images/normal/Deoxys.png new file mode 100644 index 0000000..a2977e4 Binary files /dev/null and b/images/normal/Deoxys.png differ diff --git a/images/normal/Dodrio.png b/images/normal/Dodrio.png new file mode 100644 index 0000000..3a70788 Binary files /dev/null and b/images/normal/Dodrio.png differ diff --git a/images/normal/Doduo.png b/images/normal/Doduo.png new file mode 100644 index 0000000..99e8438 Binary files /dev/null and b/images/normal/Doduo.png differ diff --git a/images/normal/Donphan.png b/images/normal/Donphan.png new file mode 100644 index 0000000..e4610b4 Binary files /dev/null and b/images/normal/Donphan.png differ diff --git a/images/normal/Dragonite.png b/images/normal/Dragonite.png new file mode 100644 index 0000000..9cb0893 Binary files /dev/null and b/images/normal/Dragonite.png differ diff --git a/images/normal/Dusclops.png b/images/normal/Dusclops.png new file mode 100644 index 0000000..aa2e4b5 Binary files /dev/null and b/images/normal/Dusclops.png differ diff --git a/images/normal/Duskull.png b/images/normal/Duskull.png new file mode 100644 index 0000000..235f067 Binary files /dev/null and b/images/normal/Duskull.png differ diff --git a/images/normal/Dustox.png b/images/normal/Dustox.png new file mode 100644 index 0000000..4964052 Binary files /dev/null and b/images/normal/Dustox.png differ diff --git a/images/normal/Electrike.png b/images/normal/Electrike.png new file mode 100644 index 0000000..6564354 Binary files /dev/null and b/images/normal/Electrike.png differ diff --git a/images/normal/Electrode.png b/images/normal/Electrode.png new file mode 100644 index 0000000..82fe723 Binary files /dev/null and b/images/normal/Electrode.png differ diff --git a/images/normal/Exploud.png b/images/normal/Exploud.png new file mode 100644 index 0000000..cfc02df Binary files /dev/null and b/images/normal/Exploud.png differ diff --git a/images/normal/Feebas.png b/images/normal/Feebas.png new file mode 100644 index 0000000..da62001 Binary files /dev/null and b/images/normal/Feebas.png differ diff --git a/images/normal/Flygon.png b/images/normal/Flygon.png new file mode 100644 index 0000000..ff07a1e Binary files /dev/null and b/images/normal/Flygon.png differ diff --git a/images/normal/Gardevoir.png b/images/normal/Gardevoir.png new file mode 100644 index 0000000..9106c40 Binary files /dev/null and b/images/normal/Gardevoir.png differ diff --git a/images/normal/Geodude.png b/images/normal/Geodude.png new file mode 100644 index 0000000..62438ce Binary files /dev/null and b/images/normal/Geodude.png differ diff --git a/images/normal/Girafarig.png b/images/normal/Girafarig.png new file mode 100644 index 0000000..7e5a79f Binary files /dev/null and b/images/normal/Girafarig.png differ diff --git a/images/normal/Glalie.png b/images/normal/Glalie.png new file mode 100644 index 0000000..fbce92b Binary files /dev/null and b/images/normal/Glalie.png differ diff --git a/images/normal/Gloom.png b/images/normal/Gloom.png new file mode 100644 index 0000000..b29bc7d Binary files /dev/null and b/images/normal/Gloom.png differ diff --git a/images/normal/Golbat.png b/images/normal/Golbat.png new file mode 100644 index 0000000..3bacc20 Binary files /dev/null and b/images/normal/Golbat.png differ diff --git a/images/normal/Goldeen.png b/images/normal/Goldeen.png new file mode 100644 index 0000000..06c54a1 Binary files /dev/null and b/images/normal/Goldeen.png differ diff --git a/images/normal/Golduck.png b/images/normal/Golduck.png new file mode 100644 index 0000000..0bc17fa Binary files /dev/null and b/images/normal/Golduck.png differ diff --git a/images/normal/Golem.png b/images/normal/Golem.png new file mode 100644 index 0000000..a18dc61 Binary files /dev/null and b/images/normal/Golem.png differ diff --git a/images/normal/Gorebyss.png b/images/normal/Gorebyss.png new file mode 100644 index 0000000..3587418 Binary files /dev/null and b/images/normal/Gorebyss.png differ diff --git a/images/normal/Graveler.png b/images/normal/Graveler.png new file mode 100644 index 0000000..24a803e Binary files /dev/null and b/images/normal/Graveler.png differ diff --git a/images/normal/Grimer.png b/images/normal/Grimer.png new file mode 100644 index 0000000..fc043cf Binary files /dev/null and b/images/normal/Grimer.png differ diff --git a/images/normal/Groudon.png b/images/normal/Groudon.png new file mode 100644 index 0000000..f62784f Binary files /dev/null and b/images/normal/Groudon.png differ diff --git a/images/normal/Grovyle.png b/images/normal/Grovyle.png new file mode 100644 index 0000000..bca15c2 Binary files /dev/null and b/images/normal/Grovyle.png differ diff --git a/images/normal/Grumpig.png b/images/normal/Grumpig.png new file mode 100644 index 0000000..8114163 Binary files /dev/null and b/images/normal/Grumpig.png differ diff --git a/images/normal/Gulpin.png b/images/normal/Gulpin.png new file mode 100644 index 0000000..a3dd393 Binary files /dev/null and b/images/normal/Gulpin.png differ diff --git a/images/normal/Gyarados.png b/images/normal/Gyarados.png new file mode 100644 index 0000000..312e4e9 Binary files /dev/null and b/images/normal/Gyarados.png differ diff --git a/images/normal/Hariyama.png b/images/normal/Hariyama.png new file mode 100644 index 0000000..1727696 Binary files /dev/null and b/images/normal/Hariyama.png differ diff --git a/images/normal/Heracross.png b/images/normal/Heracross.png new file mode 100644 index 0000000..8d95863 Binary files /dev/null and b/images/normal/Heracross.png differ diff --git a/images/normal/Horsea.png b/images/normal/Horsea.png new file mode 100644 index 0000000..5e38314 Binary files /dev/null and b/images/normal/Horsea.png differ diff --git a/images/normal/Huntail.png b/images/normal/Huntail.png new file mode 100644 index 0000000..407a13b Binary files /dev/null and b/images/normal/Huntail.png differ diff --git a/images/normal/Igglybuff.png b/images/normal/Igglybuff.png new file mode 100644 index 0000000..54f1c17 Binary files /dev/null and b/images/normal/Igglybuff.png differ diff --git a/images/normal/Illumise.png b/images/normal/Illumise.png new file mode 100644 index 0000000..b244549 Binary files /dev/null and b/images/normal/Illumise.png differ diff --git a/images/normal/Jigglypuff.png b/images/normal/Jigglypuff.png new file mode 100644 index 0000000..676c518 Binary files /dev/null and b/images/normal/Jigglypuff.png differ diff --git a/images/normal/Jirachi.png b/images/normal/Jirachi.png new file mode 100644 index 0000000..e66d8ef Binary files /dev/null and b/images/normal/Jirachi.png differ diff --git a/images/normal/Kadabra.png b/images/normal/Kadabra.png new file mode 100644 index 0000000..f87af70 Binary files /dev/null and b/images/normal/Kadabra.png differ diff --git a/images/normal/Kecleon.png b/images/normal/Kecleon.png new file mode 100644 index 0000000..e32e852 Binary files /dev/null and b/images/normal/Kecleon.png differ diff --git a/images/normal/Kingdra.png b/images/normal/Kingdra.png new file mode 100644 index 0000000..c305992 Binary files /dev/null and b/images/normal/Kingdra.png differ diff --git a/images/normal/Kirlia.png b/images/normal/Kirlia.png new file mode 100644 index 0000000..ad6282e Binary files /dev/null and b/images/normal/Kirlia.png differ diff --git a/images/normal/Koffing.png b/images/normal/Koffing.png new file mode 100644 index 0000000..3aac728 Binary files /dev/null and b/images/normal/Koffing.png differ diff --git a/images/normal/Kyogre.png b/images/normal/Kyogre.png new file mode 100644 index 0000000..f7c9e0b Binary files /dev/null and b/images/normal/Kyogre.png differ diff --git a/images/normal/Lairon.png b/images/normal/Lairon.png new file mode 100644 index 0000000..51037a3 Binary files /dev/null and b/images/normal/Lairon.png differ diff --git a/images/normal/Lanturn.png b/images/normal/Lanturn.png new file mode 100644 index 0000000..8bab4be Binary files /dev/null and b/images/normal/Lanturn.png differ diff --git a/images/normal/Latias.png b/images/normal/Latias.png new file mode 100644 index 0000000..1809f12 Binary files /dev/null and b/images/normal/Latias.png differ diff --git a/images/normal/Latios.png b/images/normal/Latios.png new file mode 100644 index 0000000..4526c56 Binary files /dev/null and b/images/normal/Latios.png differ diff --git a/images/normal/Lileep.png b/images/normal/Lileep.png new file mode 100644 index 0000000..3b0ab1d Binary files /dev/null and b/images/normal/Lileep.png differ diff --git a/images/normal/Linoone.png b/images/normal/Linoone.png new file mode 100644 index 0000000..29f5028 Binary files /dev/null and b/images/normal/Linoone.png differ diff --git a/images/normal/Lombre.png b/images/normal/Lombre.png new file mode 100644 index 0000000..5dbf23a Binary files /dev/null and b/images/normal/Lombre.png differ diff --git a/images/normal/Lotad.png b/images/normal/Lotad.png new file mode 100644 index 0000000..71a8337 Binary files /dev/null and b/images/normal/Lotad.png differ diff --git a/images/normal/Loudred.png b/images/normal/Loudred.png new file mode 100644 index 0000000..c2c22fa Binary files /dev/null and b/images/normal/Loudred.png differ diff --git a/images/normal/Ludicolo.png b/images/normal/Ludicolo.png new file mode 100644 index 0000000..296faf6 Binary files /dev/null and b/images/normal/Ludicolo.png differ diff --git a/images/normal/Lunatone.png b/images/normal/Lunatone.png new file mode 100644 index 0000000..051b630 Binary files /dev/null and b/images/normal/Lunatone.png differ diff --git a/images/normal/Luvdisc.png b/images/normal/Luvdisc.png new file mode 100644 index 0000000..591fe52 Binary files /dev/null and b/images/normal/Luvdisc.png differ diff --git a/images/normal/Machamp.png b/images/normal/Machamp.png new file mode 100644 index 0000000..5870280 Binary files /dev/null and b/images/normal/Machamp.png differ diff --git a/images/normal/Machoke.png b/images/normal/Machoke.png new file mode 100644 index 0000000..ce1e5e7 Binary files /dev/null and b/images/normal/Machoke.png differ diff --git a/images/normal/Machop.png b/images/normal/Machop.png new file mode 100644 index 0000000..cb3b3da Binary files /dev/null and b/images/normal/Machop.png differ diff --git a/images/normal/Magcargo.png b/images/normal/Magcargo.png new file mode 100644 index 0000000..ba847eb Binary files /dev/null and b/images/normal/Magcargo.png differ diff --git a/images/normal/Magikarp.png b/images/normal/Magikarp.png new file mode 100644 index 0000000..7890411 Binary files /dev/null and b/images/normal/Magikarp.png differ diff --git a/images/normal/Magnemite.png b/images/normal/Magnemite.png new file mode 100644 index 0000000..69a3fb8 Binary files /dev/null and b/images/normal/Magnemite.png differ diff --git a/images/normal/Magneton.png b/images/normal/Magneton.png new file mode 100644 index 0000000..e707aa6 Binary files /dev/null and b/images/normal/Magneton.png differ diff --git a/images/normal/Makuhita.png b/images/normal/Makuhita.png new file mode 100644 index 0000000..fdb3a7d Binary files /dev/null and b/images/normal/Makuhita.png differ diff --git a/images/normal/Manectric.png b/images/normal/Manectric.png new file mode 100644 index 0000000..05b1c40 Binary files /dev/null and b/images/normal/Manectric.png differ diff --git a/images/normal/Marill.png b/images/normal/Marill.png new file mode 100644 index 0000000..f56950c Binary files /dev/null and b/images/normal/Marill.png differ diff --git a/images/normal/Marshtomp.png b/images/normal/Marshtomp.png new file mode 100644 index 0000000..bc59db9 Binary files /dev/null and b/images/normal/Marshtomp.png differ diff --git a/images/normal/Masquerain.png b/images/normal/Masquerain.png new file mode 100644 index 0000000..6a146ab Binary files /dev/null and b/images/normal/Masquerain.png differ diff --git a/images/normal/Mawile.png b/images/normal/Mawile.png new file mode 100644 index 0000000..207259d Binary files /dev/null and b/images/normal/Mawile.png differ diff --git a/images/normal/Medicham.png b/images/normal/Medicham.png new file mode 100644 index 0000000..10ee778 Binary files /dev/null and b/images/normal/Medicham.png differ diff --git a/images/normal/Meditite.png b/images/normal/Meditite.png new file mode 100644 index 0000000..34d7b4d Binary files /dev/null and b/images/normal/Meditite.png differ diff --git a/images/normal/Metagross.png b/images/normal/Metagross.png new file mode 100644 index 0000000..d6a9873 Binary files /dev/null and b/images/normal/Metagross.png differ diff --git a/images/normal/Metang.png b/images/normal/Metang.png new file mode 100644 index 0000000..d7e1ccf Binary files /dev/null and b/images/normal/Metang.png differ diff --git a/images/normal/Mightyena.png b/images/normal/Mightyena.png new file mode 100644 index 0000000..8fe7b8c Binary files /dev/null and b/images/normal/Mightyena.png differ diff --git a/images/normal/Milotic.png b/images/normal/Milotic.png new file mode 100644 index 0000000..0408d46 Binary files /dev/null and b/images/normal/Milotic.png differ diff --git a/images/normal/Minun.png b/images/normal/Minun.png new file mode 100644 index 0000000..f8935e2 Binary files /dev/null and b/images/normal/Minun.png differ diff --git a/images/normal/Mudkip.png b/images/normal/Mudkip.png new file mode 100644 index 0000000..546fb09 Binary files /dev/null and b/images/normal/Mudkip.png differ diff --git a/images/normal/Muk.png b/images/normal/Muk.png new file mode 100644 index 0000000..2d55d22 Binary files /dev/null and b/images/normal/Muk.png differ diff --git a/images/normal/Natu.png b/images/normal/Natu.png new file mode 100644 index 0000000..ca5960e Binary files /dev/null and b/images/normal/Natu.png differ diff --git a/images/normal/Nincada.png b/images/normal/Nincada.png new file mode 100644 index 0000000..48f0e2f Binary files /dev/null and b/images/normal/Nincada.png differ diff --git a/images/normal/Ninetales.png b/images/normal/Ninetales.png new file mode 100644 index 0000000..355ac2d Binary files /dev/null and b/images/normal/Ninetales.png differ diff --git a/images/normal/Ninjask.png b/images/normal/Ninjask.png new file mode 100644 index 0000000..8788b40 Binary files /dev/null and b/images/normal/Ninjask.png differ diff --git a/images/normal/Nosepass.png b/images/normal/Nosepass.png new file mode 100644 index 0000000..f1c20ec Binary files /dev/null and b/images/normal/Nosepass.png differ diff --git a/images/normal/Numel.png b/images/normal/Numel.png new file mode 100644 index 0000000..4a6342b Binary files /dev/null and b/images/normal/Numel.png differ diff --git a/images/normal/Nuzleaf.png b/images/normal/Nuzleaf.png new file mode 100644 index 0000000..d8ce276 Binary files /dev/null and b/images/normal/Nuzleaf.png differ diff --git a/images/normal/Oddish.png b/images/normal/Oddish.png new file mode 100644 index 0000000..d3ff06f Binary files /dev/null and b/images/normal/Oddish.png differ diff --git a/images/normal/Pelipper.png b/images/normal/Pelipper.png new file mode 100644 index 0000000..c083efd Binary files /dev/null and b/images/normal/Pelipper.png differ diff --git a/images/normal/Phanpy.png b/images/normal/Phanpy.png new file mode 100644 index 0000000..b218d2f Binary files /dev/null and b/images/normal/Phanpy.png differ diff --git a/images/normal/Pichu.png b/images/normal/Pichu.png new file mode 100644 index 0000000..6021600 Binary files /dev/null and b/images/normal/Pichu.png differ diff --git a/images/normal/Pikachu.png b/images/normal/Pikachu.png new file mode 100644 index 0000000..1aa2006 Binary files /dev/null and b/images/normal/Pikachu.png differ diff --git a/images/normal/Pinsir.png b/images/normal/Pinsir.png new file mode 100644 index 0000000..34225b6 Binary files /dev/null and b/images/normal/Pinsir.png differ diff --git a/images/normal/Plusle.png b/images/normal/Plusle.png new file mode 100644 index 0000000..fcc8ee9 Binary files /dev/null and b/images/normal/Plusle.png differ diff --git a/images/normal/Poochyena.png b/images/normal/Poochyena.png new file mode 100644 index 0000000..c544e2f Binary files /dev/null and b/images/normal/Poochyena.png differ diff --git a/images/normal/Psyduck.png b/images/normal/Psyduck.png new file mode 100644 index 0000000..2155f6a Binary files /dev/null and b/images/normal/Psyduck.png differ diff --git a/images/normal/Raichu.png b/images/normal/Raichu.png new file mode 100644 index 0000000..e3fc20f Binary files /dev/null and b/images/normal/Raichu.png differ diff --git a/images/normal/Ralts.png b/images/normal/Ralts.png new file mode 100644 index 0000000..c5b029c Binary files /dev/null and b/images/normal/Ralts.png differ diff --git a/images/normal/Rayquaza.png b/images/normal/Rayquaza.png new file mode 100644 index 0000000..4524b41 Binary files /dev/null and b/images/normal/Rayquaza.png differ diff --git a/images/normal/Regice.png b/images/normal/Regice.png new file mode 100644 index 0000000..2cd93f0 Binary files /dev/null and b/images/normal/Regice.png differ diff --git a/images/normal/Regirock.png b/images/normal/Regirock.png new file mode 100644 index 0000000..dcdc4d7 Binary files /dev/null and b/images/normal/Regirock.png differ diff --git a/images/normal/Registeel.png b/images/normal/Registeel.png new file mode 100644 index 0000000..04e34e8 Binary files /dev/null and b/images/normal/Registeel.png differ diff --git a/images/normal/Relicanth.png b/images/normal/Relicanth.png new file mode 100644 index 0000000..64d4de8 Binary files /dev/null and b/images/normal/Relicanth.png differ diff --git a/images/normal/Rhydon.png b/images/normal/Rhydon.png new file mode 100644 index 0000000..e58e916 Binary files /dev/null and b/images/normal/Rhydon.png differ diff --git a/images/normal/Rhyhorn.png b/images/normal/Rhyhorn.png new file mode 100644 index 0000000..49ede85 Binary files /dev/null and b/images/normal/Rhyhorn.png differ diff --git a/images/normal/Roselia.png b/images/normal/Roselia.png new file mode 100644 index 0000000..a805907 Binary files /dev/null and b/images/normal/Roselia.png differ diff --git a/images/normal/Sableye.png b/images/normal/Sableye.png new file mode 100644 index 0000000..f72a1ce Binary files /dev/null and b/images/normal/Sableye.png differ diff --git a/images/normal/Salamence.png b/images/normal/Salamence.png new file mode 100644 index 0000000..93684ae Binary files /dev/null and b/images/normal/Salamence.png differ diff --git a/images/normal/Sandshrew.png b/images/normal/Sandshrew.png new file mode 100644 index 0000000..9435fff Binary files /dev/null and b/images/normal/Sandshrew.png differ diff --git a/images/normal/Sandslash.png b/images/normal/Sandslash.png new file mode 100644 index 0000000..ded9d1f Binary files /dev/null and b/images/normal/Sandslash.png differ diff --git a/images/normal/Sceptile.png b/images/normal/Sceptile.png new file mode 100644 index 0000000..f205fc4 Binary files /dev/null and b/images/normal/Sceptile.png differ diff --git a/images/normal/Seadra.png b/images/normal/Seadra.png new file mode 100644 index 0000000..c1b6ba0 Binary files /dev/null and b/images/normal/Seadra.png differ diff --git a/images/normal/Seaking.png b/images/normal/Seaking.png new file mode 100644 index 0000000..6d7ad44 Binary files /dev/null and b/images/normal/Seaking.png differ diff --git a/images/normal/Sealeo.png b/images/normal/Sealeo.png new file mode 100644 index 0000000..49fc2e1 Binary files /dev/null and b/images/normal/Sealeo.png differ diff --git a/images/normal/Seedot.png b/images/normal/Seedot.png new file mode 100644 index 0000000..fba4c7f Binary files /dev/null and b/images/normal/Seedot.png differ diff --git a/images/normal/Seviper.png b/images/normal/Seviper.png new file mode 100644 index 0000000..6eccc85 Binary files /dev/null and b/images/normal/Seviper.png differ diff --git a/images/normal/Sharpedo.png b/images/normal/Sharpedo.png new file mode 100644 index 0000000..c76fe84 Binary files /dev/null and b/images/normal/Sharpedo.png differ diff --git a/images/normal/Shedinja.png b/images/normal/Shedinja.png new file mode 100644 index 0000000..1f32405 Binary files /dev/null and b/images/normal/Shedinja.png differ diff --git a/images/normal/Shelgon.png b/images/normal/Shelgon.png new file mode 100644 index 0000000..6f0f039 Binary files /dev/null and b/images/normal/Shelgon.png differ diff --git a/images/normal/Shiftry.png b/images/normal/Shiftry.png new file mode 100644 index 0000000..e7335a4 Binary files /dev/null and b/images/normal/Shiftry.png differ diff --git a/images/normal/Shroomish.png b/images/normal/Shroomish.png new file mode 100644 index 0000000..9792f03 Binary files /dev/null and b/images/normal/Shroomish.png differ diff --git a/images/normal/Shuppet.png b/images/normal/Shuppet.png new file mode 100644 index 0000000..c0fbfd0 Binary files /dev/null and b/images/normal/Shuppet.png differ diff --git a/images/normal/Silcoon.png b/images/normal/Silcoon.png new file mode 100644 index 0000000..a3ad7f5 Binary files /dev/null and b/images/normal/Silcoon.png differ diff --git a/images/normal/Skarmory.png b/images/normal/Skarmory.png new file mode 100644 index 0000000..c8a2fb3 Binary files /dev/null and b/images/normal/Skarmory.png differ diff --git a/images/normal/Skitty.png b/images/normal/Skitty.png new file mode 100644 index 0000000..1c6275c Binary files /dev/null and b/images/normal/Skitty.png differ diff --git a/images/normal/Slaking.png b/images/normal/Slaking.png new file mode 100644 index 0000000..d8a189c Binary files /dev/null and b/images/normal/Slaking.png differ diff --git a/images/normal/Slakoth.png b/images/normal/Slakoth.png new file mode 100644 index 0000000..351ce50 Binary files /dev/null and b/images/normal/Slakoth.png differ diff --git a/images/normal/Slugma.png b/images/normal/Slugma.png new file mode 100644 index 0000000..4fc9a9e Binary files /dev/null and b/images/normal/Slugma.png differ diff --git a/images/normal/Snorunt.png b/images/normal/Snorunt.png new file mode 100644 index 0000000..37f809e Binary files /dev/null and b/images/normal/Snorunt.png differ diff --git a/images/normal/Solrock.png b/images/normal/Solrock.png new file mode 100644 index 0000000..07a340b Binary files /dev/null and b/images/normal/Solrock.png differ diff --git a/images/normal/Spheal.png b/images/normal/Spheal.png new file mode 100644 index 0000000..a3125cd Binary files /dev/null and b/images/normal/Spheal.png differ diff --git a/images/normal/Spinda.png b/images/normal/Spinda.png new file mode 100644 index 0000000..b8d3519 Binary files /dev/null and b/images/normal/Spinda.png differ diff --git a/images/normal/Spoink.png b/images/normal/Spoink.png new file mode 100644 index 0000000..1343067 Binary files /dev/null and b/images/normal/Spoink.png differ diff --git a/images/normal/Starmie.png b/images/normal/Starmie.png new file mode 100644 index 0000000..7906722 Binary files /dev/null and b/images/normal/Starmie.png differ diff --git a/images/normal/Staryu.png b/images/normal/Staryu.png new file mode 100644 index 0000000..dc62b6d Binary files /dev/null and b/images/normal/Staryu.png differ diff --git a/images/normal/Surskit.png b/images/normal/Surskit.png new file mode 100644 index 0000000..96fd625 Binary files /dev/null and b/images/normal/Surskit.png differ diff --git a/images/normal/Swablu.png b/images/normal/Swablu.png new file mode 100644 index 0000000..2e32a6f Binary files /dev/null and b/images/normal/Swablu.png differ diff --git a/images/normal/Swalot.png b/images/normal/Swalot.png new file mode 100644 index 0000000..bb5169d Binary files /dev/null and b/images/normal/Swalot.png differ diff --git a/images/normal/Swampert.png b/images/normal/Swampert.png new file mode 100644 index 0000000..bd3de62 Binary files /dev/null and b/images/normal/Swampert.png differ diff --git a/images/normal/Swellow.png b/images/normal/Swellow.png new file mode 100644 index 0000000..d6095bc Binary files /dev/null and b/images/normal/Swellow.png differ diff --git a/images/normal/Taillow.png b/images/normal/Taillow.png new file mode 100644 index 0000000..9546560 Binary files /dev/null and b/images/normal/Taillow.png differ diff --git a/images/normal/Tentacool.png b/images/normal/Tentacool.png new file mode 100644 index 0000000..78ac32b Binary files /dev/null and b/images/normal/Tentacool.png differ diff --git a/images/normal/Tentacruel.png b/images/normal/Tentacruel.png new file mode 100644 index 0000000..0d47198 Binary files /dev/null and b/images/normal/Tentacruel.png differ diff --git a/images/normal/Torchic.png b/images/normal/Torchic.png new file mode 100644 index 0000000..4fbf39d Binary files /dev/null and b/images/normal/Torchic.png differ diff --git a/images/normal/Torkoal.png b/images/normal/Torkoal.png new file mode 100644 index 0000000..b39bd8b Binary files /dev/null and b/images/normal/Torkoal.png differ diff --git a/images/normal/Trapinch.png b/images/normal/Trapinch.png new file mode 100644 index 0000000..cabe707 Binary files /dev/null and b/images/normal/Trapinch.png differ diff --git a/images/normal/Treecko.png b/images/normal/Treecko.png new file mode 100644 index 0000000..4a98ac1 Binary files /dev/null and b/images/normal/Treecko.png differ diff --git a/images/normal/Tropius.png b/images/normal/Tropius.png new file mode 100644 index 0000000..d562304 Binary files /dev/null and b/images/normal/Tropius.png differ diff --git a/images/normal/Vibrava.png b/images/normal/Vibrava.png new file mode 100644 index 0000000..37c75eb Binary files /dev/null and b/images/normal/Vibrava.png differ diff --git a/images/normal/Vigoroth.png b/images/normal/Vigoroth.png new file mode 100644 index 0000000..80d8118 Binary files /dev/null and b/images/normal/Vigoroth.png differ diff --git a/images/normal/Vileplume.png b/images/normal/Vileplume.png new file mode 100644 index 0000000..6fff64e Binary files /dev/null and b/images/normal/Vileplume.png differ diff --git a/images/normal/Volbeat.png b/images/normal/Volbeat.png new file mode 100644 index 0000000..62d88a6 Binary files /dev/null and b/images/normal/Volbeat.png differ diff --git a/images/normal/Voltorb.png b/images/normal/Voltorb.png new file mode 100644 index 0000000..439dfc0 Binary files /dev/null and b/images/normal/Voltorb.png differ diff --git a/images/normal/Vulpix.png b/images/normal/Vulpix.png new file mode 100644 index 0000000..e260025 Binary files /dev/null and b/images/normal/Vulpix.png differ diff --git a/images/normal/Wailmer.png b/images/normal/Wailmer.png new file mode 100644 index 0000000..facf0b8 Binary files /dev/null and b/images/normal/Wailmer.png differ diff --git a/images/normal/Wailord.png b/images/normal/Wailord.png new file mode 100644 index 0000000..db3308e Binary files /dev/null and b/images/normal/Wailord.png differ diff --git a/images/normal/Walrein.png b/images/normal/Walrein.png new file mode 100644 index 0000000..72ed1a5 Binary files /dev/null and b/images/normal/Walrein.png differ diff --git a/images/normal/Weezing.png b/images/normal/Weezing.png new file mode 100644 index 0000000..c0b2e92 Binary files /dev/null and b/images/normal/Weezing.png differ diff --git a/images/normal/Whiscash.png b/images/normal/Whiscash.png new file mode 100644 index 0000000..f1d0a19 Binary files /dev/null and b/images/normal/Whiscash.png differ diff --git a/images/normal/Whismur.png b/images/normal/Whismur.png new file mode 100644 index 0000000..c19d20d Binary files /dev/null and b/images/normal/Whismur.png differ diff --git a/images/normal/Wigglytuff.png b/images/normal/Wigglytuff.png new file mode 100644 index 0000000..71319a4 Binary files /dev/null and b/images/normal/Wigglytuff.png differ diff --git a/images/normal/Wingull.png b/images/normal/Wingull.png new file mode 100644 index 0000000..11aa855 Binary files /dev/null and b/images/normal/Wingull.png differ diff --git a/images/normal/Wobbuffet.png b/images/normal/Wobbuffet.png new file mode 100644 index 0000000..44cd376 Binary files /dev/null and b/images/normal/Wobbuffet.png differ diff --git a/images/normal/Wurmple.png b/images/normal/Wurmple.png new file mode 100644 index 0000000..8613b80 Binary files /dev/null and b/images/normal/Wurmple.png differ diff --git a/images/normal/Wynaut.png b/images/normal/Wynaut.png new file mode 100644 index 0000000..1de25b8 Binary files /dev/null and b/images/normal/Wynaut.png differ diff --git a/images/normal/Xatu.png b/images/normal/Xatu.png new file mode 100644 index 0000000..a490e45 Binary files /dev/null and b/images/normal/Xatu.png differ diff --git a/images/normal/Zangoose.png b/images/normal/Zangoose.png new file mode 100644 index 0000000..bc28f4d Binary files /dev/null and b/images/normal/Zangoose.png differ diff --git a/images/normal/Zigzagoon.png b/images/normal/Zigzagoon.png new file mode 100644 index 0000000..39c210b Binary files /dev/null and b/images/normal/Zigzagoon.png differ diff --git a/images/normal/Zubat.png b/images/normal/Zubat.png new file mode 100644 index 0000000..0221663 Binary files /dev/null and b/images/normal/Zubat.png differ diff --git a/images/pokeball.ico b/images/pokeball.ico new file mode 100644 index 0000000..acf7e85 Binary files /dev/null and b/images/pokeball.ico differ diff --git a/images/pokeball.png b/images/pokeball.png new file mode 100644 index 0000000..1409f30 Binary files /dev/null and b/images/pokeball.png differ diff --git a/images/shiny.png b/images/shiny.png new file mode 100644 index 0000000..9c18ce8 Binary files /dev/null and b/images/shiny.png differ diff --git a/images/shiny/Abra.png b/images/shiny/Abra.png new file mode 100644 index 0000000..192877e Binary files /dev/null and b/images/shiny/Abra.png differ diff --git a/images/shiny/Absol.png b/images/shiny/Absol.png new file mode 100644 index 0000000..b4e812a Binary files /dev/null and b/images/shiny/Absol.png differ diff --git a/images/shiny/Aggron.png b/images/shiny/Aggron.png new file mode 100644 index 0000000..58ff14f Binary files /dev/null and b/images/shiny/Aggron.png differ diff --git a/images/shiny/Alakazam.png b/images/shiny/Alakazam.png new file mode 100644 index 0000000..eb4cf18 Binary files /dev/null and b/images/shiny/Alakazam.png differ diff --git a/images/shiny/Altaria.png b/images/shiny/Altaria.png new file mode 100644 index 0000000..0c66566 Binary files /dev/null and b/images/shiny/Altaria.png differ diff --git a/images/shiny/Anorith.png b/images/shiny/Anorith.png new file mode 100644 index 0000000..10f94be Binary files /dev/null and b/images/shiny/Anorith.png differ diff --git a/images/shiny/Armaldo.png b/images/shiny/Armaldo.png new file mode 100644 index 0000000..e4ba5ae Binary files /dev/null and b/images/shiny/Armaldo.png differ diff --git a/images/shiny/Aron.png b/images/shiny/Aron.png new file mode 100644 index 0000000..6b4b06b Binary files /dev/null and b/images/shiny/Aron.png differ diff --git a/images/shiny/Azumarill.png b/images/shiny/Azumarill.png new file mode 100644 index 0000000..0deab07 Binary files /dev/null and b/images/shiny/Azumarill.png differ diff --git a/images/shiny/Azurill.png b/images/shiny/Azurill.png new file mode 100644 index 0000000..2c6ee27 Binary files /dev/null and b/images/shiny/Azurill.png differ diff --git a/images/shiny/Bagon.png b/images/shiny/Bagon.png new file mode 100644 index 0000000..b9d015a Binary files /dev/null and b/images/shiny/Bagon.png differ diff --git a/images/shiny/Baltoy.png b/images/shiny/Baltoy.png new file mode 100644 index 0000000..569e37a Binary files /dev/null and b/images/shiny/Baltoy.png differ diff --git a/images/shiny/Banette.png b/images/shiny/Banette.png new file mode 100644 index 0000000..c1b661e Binary files /dev/null and b/images/shiny/Banette.png differ diff --git a/images/shiny/Barboach.png b/images/shiny/Barboach.png new file mode 100644 index 0000000..1a221bb Binary files /dev/null and b/images/shiny/Barboach.png differ diff --git a/images/shiny/Beautifly.png b/images/shiny/Beautifly.png new file mode 100644 index 0000000..4f44cb6 Binary files /dev/null and b/images/shiny/Beautifly.png differ diff --git a/images/shiny/Beldum.png b/images/shiny/Beldum.png new file mode 100644 index 0000000..09c7745 Binary files /dev/null and b/images/shiny/Beldum.png differ diff --git a/images/shiny/Bellossom.png b/images/shiny/Bellossom.png new file mode 100644 index 0000000..013df11 Binary files /dev/null and b/images/shiny/Bellossom.png differ diff --git a/images/shiny/Blaziken.png b/images/shiny/Blaziken.png new file mode 100644 index 0000000..9f23d05 Binary files /dev/null and b/images/shiny/Blaziken.png differ diff --git a/images/shiny/Breloom.png b/images/shiny/Breloom.png new file mode 100644 index 0000000..bfb1c52 Binary files /dev/null and b/images/shiny/Breloom.png differ diff --git a/images/shiny/Cacnea.png b/images/shiny/Cacnea.png new file mode 100644 index 0000000..3826740 Binary files /dev/null and b/images/shiny/Cacnea.png differ diff --git a/images/shiny/Cacturne.png b/images/shiny/Cacturne.png new file mode 100644 index 0000000..b920328 Binary files /dev/null and b/images/shiny/Cacturne.png differ diff --git a/images/shiny/Camerupt.png b/images/shiny/Camerupt.png new file mode 100644 index 0000000..ef697bd Binary files /dev/null and b/images/shiny/Camerupt.png differ diff --git a/images/shiny/Carvanha.png b/images/shiny/Carvanha.png new file mode 100644 index 0000000..7659536 Binary files /dev/null and b/images/shiny/Carvanha.png differ diff --git a/images/shiny/Cascoon.png b/images/shiny/Cascoon.png new file mode 100644 index 0000000..c8c15ce Binary files /dev/null and b/images/shiny/Cascoon.png differ diff --git a/images/shiny/Castform.png b/images/shiny/Castform.png new file mode 100644 index 0000000..6dc45aa Binary files /dev/null and b/images/shiny/Castform.png differ diff --git a/images/shiny/Chimecho.png b/images/shiny/Chimecho.png new file mode 100644 index 0000000..f54a559 Binary files /dev/null and b/images/shiny/Chimecho.png differ diff --git a/images/shiny/Chinchou.png b/images/shiny/Chinchou.png new file mode 100644 index 0000000..b1820bd Binary files /dev/null and b/images/shiny/Chinchou.png differ diff --git a/images/shiny/Clamperl.png b/images/shiny/Clamperl.png new file mode 100644 index 0000000..4e26cb8 Binary files /dev/null and b/images/shiny/Clamperl.png differ diff --git a/images/shiny/Claydol.png b/images/shiny/Claydol.png new file mode 100644 index 0000000..753ebb8 Binary files /dev/null and b/images/shiny/Claydol.png differ diff --git a/images/shiny/Combusken.png b/images/shiny/Combusken.png new file mode 100644 index 0000000..f370cea Binary files /dev/null and b/images/shiny/Combusken.png differ diff --git a/images/shiny/Corphish.png b/images/shiny/Corphish.png new file mode 100644 index 0000000..21bd0f8 Binary files /dev/null and b/images/shiny/Corphish.png differ diff --git a/images/shiny/Corsola.png b/images/shiny/Corsola.png new file mode 100644 index 0000000..ac103d9 Binary files /dev/null and b/images/shiny/Corsola.png differ diff --git a/images/shiny/Cradily.png b/images/shiny/Cradily.png new file mode 100644 index 0000000..06dd027 Binary files /dev/null and b/images/shiny/Cradily.png differ diff --git a/images/shiny/Crawdaunt.png b/images/shiny/Crawdaunt.png new file mode 100644 index 0000000..b0c84b8 Binary files /dev/null and b/images/shiny/Crawdaunt.png differ diff --git a/images/shiny/Crobat.png b/images/shiny/Crobat.png new file mode 100644 index 0000000..06798cc Binary files /dev/null and b/images/shiny/Crobat.png differ diff --git a/images/shiny/Delcatty.png b/images/shiny/Delcatty.png new file mode 100644 index 0000000..f17e0fa Binary files /dev/null and b/images/shiny/Delcatty.png differ diff --git a/images/shiny/Deoxys.png b/images/shiny/Deoxys.png new file mode 100644 index 0000000..061cf40 Binary files /dev/null and b/images/shiny/Deoxys.png differ diff --git a/images/shiny/Dodrio.png b/images/shiny/Dodrio.png new file mode 100644 index 0000000..0f0f5ad Binary files /dev/null and b/images/shiny/Dodrio.png differ diff --git a/images/shiny/Doduo.png b/images/shiny/Doduo.png new file mode 100644 index 0000000..3251f2c Binary files /dev/null and b/images/shiny/Doduo.png differ diff --git a/images/shiny/Donphan.png b/images/shiny/Donphan.png new file mode 100644 index 0000000..97861f1 Binary files /dev/null and b/images/shiny/Donphan.png differ diff --git a/images/shiny/Dragonite.png b/images/shiny/Dragonite.png new file mode 100644 index 0000000..bb17576 Binary files /dev/null and b/images/shiny/Dragonite.png differ diff --git a/images/shiny/Dusclops.png b/images/shiny/Dusclops.png new file mode 100644 index 0000000..58be9e9 Binary files /dev/null and b/images/shiny/Dusclops.png differ diff --git a/images/shiny/Duskull.png b/images/shiny/Duskull.png new file mode 100644 index 0000000..d312c75 Binary files /dev/null and b/images/shiny/Duskull.png differ diff --git a/images/shiny/Dustox.png b/images/shiny/Dustox.png new file mode 100644 index 0000000..ee63a6f Binary files /dev/null and b/images/shiny/Dustox.png differ diff --git a/images/shiny/Electrike.png b/images/shiny/Electrike.png new file mode 100644 index 0000000..df983f2 Binary files /dev/null and b/images/shiny/Electrike.png differ diff --git a/images/shiny/Electrode.png b/images/shiny/Electrode.png new file mode 100644 index 0000000..d2ecb88 Binary files /dev/null and b/images/shiny/Electrode.png differ diff --git a/images/shiny/Exploud.png b/images/shiny/Exploud.png new file mode 100644 index 0000000..69dead8 Binary files /dev/null and b/images/shiny/Exploud.png differ diff --git a/images/shiny/Feebas.png b/images/shiny/Feebas.png new file mode 100644 index 0000000..d81041b Binary files /dev/null and b/images/shiny/Feebas.png differ diff --git a/images/shiny/Flygon.png b/images/shiny/Flygon.png new file mode 100644 index 0000000..4f7aed7 Binary files /dev/null and b/images/shiny/Flygon.png differ diff --git a/images/shiny/Gardevoir.png b/images/shiny/Gardevoir.png new file mode 100644 index 0000000..2c025df Binary files /dev/null and b/images/shiny/Gardevoir.png differ diff --git a/images/shiny/Geodude.png b/images/shiny/Geodude.png new file mode 100644 index 0000000..96d284e Binary files /dev/null and b/images/shiny/Geodude.png differ diff --git a/images/shiny/Girafarig.png b/images/shiny/Girafarig.png new file mode 100644 index 0000000..3086efe Binary files /dev/null and b/images/shiny/Girafarig.png differ diff --git a/images/shiny/Glalie.png b/images/shiny/Glalie.png new file mode 100644 index 0000000..db019a6 Binary files /dev/null and b/images/shiny/Glalie.png differ diff --git a/images/shiny/Gloom.png b/images/shiny/Gloom.png new file mode 100644 index 0000000..f63e8d4 Binary files /dev/null and b/images/shiny/Gloom.png differ diff --git a/images/shiny/Golbat.png b/images/shiny/Golbat.png new file mode 100644 index 0000000..e86f89f Binary files /dev/null and b/images/shiny/Golbat.png differ diff --git a/images/shiny/Goldeen.png b/images/shiny/Goldeen.png new file mode 100644 index 0000000..75957c1 Binary files /dev/null and b/images/shiny/Goldeen.png differ diff --git a/images/shiny/Golduck.png b/images/shiny/Golduck.png new file mode 100644 index 0000000..7663252 Binary files /dev/null and b/images/shiny/Golduck.png differ diff --git a/images/shiny/Golem.png b/images/shiny/Golem.png new file mode 100644 index 0000000..32df06f Binary files /dev/null and b/images/shiny/Golem.png differ diff --git a/images/shiny/Gorebyss.png b/images/shiny/Gorebyss.png new file mode 100644 index 0000000..d381220 Binary files /dev/null and b/images/shiny/Gorebyss.png differ diff --git a/images/shiny/Graveler.png b/images/shiny/Graveler.png new file mode 100644 index 0000000..a568930 Binary files /dev/null and b/images/shiny/Graveler.png differ diff --git a/images/shiny/Grimer.png b/images/shiny/Grimer.png new file mode 100644 index 0000000..d065407 Binary files /dev/null and b/images/shiny/Grimer.png differ diff --git a/images/shiny/Groudon.png b/images/shiny/Groudon.png new file mode 100644 index 0000000..30a03aa Binary files /dev/null and b/images/shiny/Groudon.png differ diff --git a/images/shiny/Grovyle.png b/images/shiny/Grovyle.png new file mode 100644 index 0000000..e29af3f Binary files /dev/null and b/images/shiny/Grovyle.png differ diff --git a/images/shiny/Grumpig.png b/images/shiny/Grumpig.png new file mode 100644 index 0000000..07030f5 Binary files /dev/null and b/images/shiny/Grumpig.png differ diff --git a/images/shiny/Gulpin.png b/images/shiny/Gulpin.png new file mode 100644 index 0000000..f946e94 Binary files /dev/null and b/images/shiny/Gulpin.png differ diff --git a/images/shiny/Gyarados.png b/images/shiny/Gyarados.png new file mode 100644 index 0000000..986f788 Binary files /dev/null and b/images/shiny/Gyarados.png differ diff --git a/images/shiny/Hariyama.png b/images/shiny/Hariyama.png new file mode 100644 index 0000000..92ffd9d Binary files /dev/null and b/images/shiny/Hariyama.png differ diff --git a/images/shiny/Heracross.png b/images/shiny/Heracross.png new file mode 100644 index 0000000..159874d Binary files /dev/null and b/images/shiny/Heracross.png differ diff --git a/images/shiny/Horsea.png b/images/shiny/Horsea.png new file mode 100644 index 0000000..a6a3a9b Binary files /dev/null and b/images/shiny/Horsea.png differ diff --git a/images/shiny/Huntail.png b/images/shiny/Huntail.png new file mode 100644 index 0000000..7b32ba4 Binary files /dev/null and b/images/shiny/Huntail.png differ diff --git a/images/shiny/Igglybuff.png b/images/shiny/Igglybuff.png new file mode 100644 index 0000000..de52b5d Binary files /dev/null and b/images/shiny/Igglybuff.png differ diff --git a/images/shiny/Illumise.png b/images/shiny/Illumise.png new file mode 100644 index 0000000..dea9889 Binary files /dev/null and b/images/shiny/Illumise.png differ diff --git a/images/shiny/Jigglypuff.png b/images/shiny/Jigglypuff.png new file mode 100644 index 0000000..91c73ea Binary files /dev/null and b/images/shiny/Jigglypuff.png differ diff --git a/images/shiny/Jirachi.png b/images/shiny/Jirachi.png new file mode 100644 index 0000000..7deea63 Binary files /dev/null and b/images/shiny/Jirachi.png differ diff --git a/images/shiny/Kadabra.png b/images/shiny/Kadabra.png new file mode 100644 index 0000000..d9008f6 Binary files /dev/null and b/images/shiny/Kadabra.png differ diff --git a/images/shiny/Kecleon.png b/images/shiny/Kecleon.png new file mode 100644 index 0000000..816f3c9 Binary files /dev/null and b/images/shiny/Kecleon.png differ diff --git a/images/shiny/Kingdra.png b/images/shiny/Kingdra.png new file mode 100644 index 0000000..efbcbbb Binary files /dev/null and b/images/shiny/Kingdra.png differ diff --git a/images/shiny/Kirlia.png b/images/shiny/Kirlia.png new file mode 100644 index 0000000..829d100 Binary files /dev/null and b/images/shiny/Kirlia.png differ diff --git a/images/shiny/Koffing.png b/images/shiny/Koffing.png new file mode 100644 index 0000000..3c200a6 Binary files /dev/null and b/images/shiny/Koffing.png differ diff --git a/images/shiny/Kyogre.png b/images/shiny/Kyogre.png new file mode 100644 index 0000000..2e1238b Binary files /dev/null and b/images/shiny/Kyogre.png differ diff --git a/images/shiny/Lairon.png b/images/shiny/Lairon.png new file mode 100644 index 0000000..34040df Binary files /dev/null and b/images/shiny/Lairon.png differ diff --git a/images/shiny/Lanturn.png b/images/shiny/Lanturn.png new file mode 100644 index 0000000..1dcc4f9 Binary files /dev/null and b/images/shiny/Lanturn.png differ diff --git a/images/shiny/Latias.png b/images/shiny/Latias.png new file mode 100644 index 0000000..b2c4e80 Binary files /dev/null and b/images/shiny/Latias.png differ diff --git a/images/shiny/Latios.png b/images/shiny/Latios.png new file mode 100644 index 0000000..fa2dcbe Binary files /dev/null and b/images/shiny/Latios.png differ diff --git a/images/shiny/Lileep.png b/images/shiny/Lileep.png new file mode 100644 index 0000000..b8d25d8 Binary files /dev/null and b/images/shiny/Lileep.png differ diff --git a/images/shiny/Linoone.png b/images/shiny/Linoone.png new file mode 100644 index 0000000..58a2a41 Binary files /dev/null and b/images/shiny/Linoone.png differ diff --git a/images/shiny/Lombre.png b/images/shiny/Lombre.png new file mode 100644 index 0000000..bcbbcf1 Binary files /dev/null and b/images/shiny/Lombre.png differ diff --git a/images/shiny/Lotad.png b/images/shiny/Lotad.png new file mode 100644 index 0000000..8455ed5 Binary files /dev/null and b/images/shiny/Lotad.png differ diff --git a/images/shiny/Loudred.png b/images/shiny/Loudred.png new file mode 100644 index 0000000..91748b3 Binary files /dev/null and b/images/shiny/Loudred.png differ diff --git a/images/shiny/Ludicolo.png b/images/shiny/Ludicolo.png new file mode 100644 index 0000000..ef94922 Binary files /dev/null and b/images/shiny/Ludicolo.png differ diff --git a/images/shiny/Lunatone.png b/images/shiny/Lunatone.png new file mode 100644 index 0000000..6bdcf45 Binary files /dev/null and b/images/shiny/Lunatone.png differ diff --git a/images/shiny/Luvdisc.png b/images/shiny/Luvdisc.png new file mode 100644 index 0000000..ffbaf7f Binary files /dev/null and b/images/shiny/Luvdisc.png differ diff --git a/images/shiny/Machamp.png b/images/shiny/Machamp.png new file mode 100644 index 0000000..72e28d6 Binary files /dev/null and b/images/shiny/Machamp.png differ diff --git a/images/shiny/Machoke.png b/images/shiny/Machoke.png new file mode 100644 index 0000000..1c33f7a Binary files /dev/null and b/images/shiny/Machoke.png differ diff --git a/images/shiny/Machop.png b/images/shiny/Machop.png new file mode 100644 index 0000000..0c535a3 Binary files /dev/null and b/images/shiny/Machop.png differ diff --git a/images/shiny/Magcargo.png b/images/shiny/Magcargo.png new file mode 100644 index 0000000..6f1f976 Binary files /dev/null and b/images/shiny/Magcargo.png differ diff --git a/images/shiny/Magikarp.png b/images/shiny/Magikarp.png new file mode 100644 index 0000000..3c23667 Binary files /dev/null and b/images/shiny/Magikarp.png differ diff --git a/images/shiny/Magnemite.png b/images/shiny/Magnemite.png new file mode 100644 index 0000000..69e931e Binary files /dev/null and b/images/shiny/Magnemite.png differ diff --git a/images/shiny/Magneton.png b/images/shiny/Magneton.png new file mode 100644 index 0000000..b14331c Binary files /dev/null and b/images/shiny/Magneton.png differ diff --git a/images/shiny/Makuhita.png b/images/shiny/Makuhita.png new file mode 100644 index 0000000..a591931 Binary files /dev/null and b/images/shiny/Makuhita.png differ diff --git a/images/shiny/Manectric.png b/images/shiny/Manectric.png new file mode 100644 index 0000000..779550b Binary files /dev/null and b/images/shiny/Manectric.png differ diff --git a/images/shiny/Marill.png b/images/shiny/Marill.png new file mode 100644 index 0000000..646285d Binary files /dev/null and b/images/shiny/Marill.png differ diff --git a/images/shiny/Marshtomp.png b/images/shiny/Marshtomp.png new file mode 100644 index 0000000..8331f65 Binary files /dev/null and b/images/shiny/Marshtomp.png differ diff --git a/images/shiny/Masquerain.png b/images/shiny/Masquerain.png new file mode 100644 index 0000000..e9227d7 Binary files /dev/null and b/images/shiny/Masquerain.png differ diff --git a/images/shiny/Mawile.png b/images/shiny/Mawile.png new file mode 100644 index 0000000..a9bda0b Binary files /dev/null and b/images/shiny/Mawile.png differ diff --git a/images/shiny/Medicham.png b/images/shiny/Medicham.png new file mode 100644 index 0000000..4da5cff Binary files /dev/null and b/images/shiny/Medicham.png differ diff --git a/images/shiny/Meditite.png b/images/shiny/Meditite.png new file mode 100644 index 0000000..7d82e26 Binary files /dev/null and b/images/shiny/Meditite.png differ diff --git a/images/shiny/Metagross.png b/images/shiny/Metagross.png new file mode 100644 index 0000000..44fd85a Binary files /dev/null and b/images/shiny/Metagross.png differ diff --git a/images/shiny/Metang.png b/images/shiny/Metang.png new file mode 100644 index 0000000..6362d9b Binary files /dev/null and b/images/shiny/Metang.png differ diff --git a/images/shiny/Mightyena.png b/images/shiny/Mightyena.png new file mode 100644 index 0000000..7c93471 Binary files /dev/null and b/images/shiny/Mightyena.png differ diff --git a/images/shiny/Milotic.png b/images/shiny/Milotic.png new file mode 100644 index 0000000..f0b78d6 Binary files /dev/null and b/images/shiny/Milotic.png differ diff --git a/images/shiny/Minun.png b/images/shiny/Minun.png new file mode 100644 index 0000000..e622d3a Binary files /dev/null and b/images/shiny/Minun.png differ diff --git a/images/shiny/Mudkip.png b/images/shiny/Mudkip.png new file mode 100644 index 0000000..32984fd Binary files /dev/null and b/images/shiny/Mudkip.png differ diff --git a/images/shiny/Muk.png b/images/shiny/Muk.png new file mode 100644 index 0000000..35b5510 Binary files /dev/null and b/images/shiny/Muk.png differ diff --git a/images/shiny/Natu.png b/images/shiny/Natu.png new file mode 100644 index 0000000..d187f6d Binary files /dev/null and b/images/shiny/Natu.png differ diff --git a/images/shiny/Nincada.png b/images/shiny/Nincada.png new file mode 100644 index 0000000..cd68b63 Binary files /dev/null and b/images/shiny/Nincada.png differ diff --git a/images/shiny/Ninetales.png b/images/shiny/Ninetales.png new file mode 100644 index 0000000..b845f9d Binary files /dev/null and b/images/shiny/Ninetales.png differ diff --git a/images/shiny/Ninjask.png b/images/shiny/Ninjask.png new file mode 100644 index 0000000..ca3e751 Binary files /dev/null and b/images/shiny/Ninjask.png differ diff --git a/images/shiny/Nosepass.png b/images/shiny/Nosepass.png new file mode 100644 index 0000000..7e50f2f Binary files /dev/null and b/images/shiny/Nosepass.png differ diff --git a/images/shiny/Numel.png b/images/shiny/Numel.png new file mode 100644 index 0000000..00a27df Binary files /dev/null and b/images/shiny/Numel.png differ diff --git a/images/shiny/Nuzleaf.png b/images/shiny/Nuzleaf.png new file mode 100644 index 0000000..2bf9ed9 Binary files /dev/null and b/images/shiny/Nuzleaf.png differ diff --git a/images/shiny/Oddish.png b/images/shiny/Oddish.png new file mode 100644 index 0000000..655fbb4 Binary files /dev/null and b/images/shiny/Oddish.png differ diff --git a/images/shiny/Pelipper.png b/images/shiny/Pelipper.png new file mode 100644 index 0000000..d898193 Binary files /dev/null and b/images/shiny/Pelipper.png differ diff --git a/images/shiny/Phanpy.png b/images/shiny/Phanpy.png new file mode 100644 index 0000000..949d3d9 Binary files /dev/null and b/images/shiny/Phanpy.png differ diff --git a/images/shiny/Pichu.png b/images/shiny/Pichu.png new file mode 100644 index 0000000..b08b23e Binary files /dev/null and b/images/shiny/Pichu.png differ diff --git a/images/shiny/Pikachu.png b/images/shiny/Pikachu.png new file mode 100644 index 0000000..938bcb1 Binary files /dev/null and b/images/shiny/Pikachu.png differ diff --git a/images/shiny/Pinsir.png b/images/shiny/Pinsir.png new file mode 100644 index 0000000..4ce75e5 Binary files /dev/null and b/images/shiny/Pinsir.png differ diff --git a/images/shiny/Plusle.png b/images/shiny/Plusle.png new file mode 100644 index 0000000..878f755 Binary files /dev/null and b/images/shiny/Plusle.png differ diff --git a/images/shiny/Poochyena.png b/images/shiny/Poochyena.png new file mode 100644 index 0000000..8659dea Binary files /dev/null and b/images/shiny/Poochyena.png differ diff --git a/images/shiny/Psyduck.png b/images/shiny/Psyduck.png new file mode 100644 index 0000000..518ecb9 Binary files /dev/null and b/images/shiny/Psyduck.png differ diff --git a/images/shiny/Raichu.png b/images/shiny/Raichu.png new file mode 100644 index 0000000..7dc83c6 Binary files /dev/null and b/images/shiny/Raichu.png differ diff --git a/images/shiny/Ralts.png b/images/shiny/Ralts.png new file mode 100644 index 0000000..958698c Binary files /dev/null and b/images/shiny/Ralts.png differ diff --git a/images/shiny/Rayquaza.png b/images/shiny/Rayquaza.png new file mode 100644 index 0000000..0c73f7a Binary files /dev/null and b/images/shiny/Rayquaza.png differ diff --git a/images/shiny/Regice.png b/images/shiny/Regice.png new file mode 100644 index 0000000..7d7cd0c Binary files /dev/null and b/images/shiny/Regice.png differ diff --git a/images/shiny/Regirock.png b/images/shiny/Regirock.png new file mode 100644 index 0000000..c82f2a5 Binary files /dev/null and b/images/shiny/Regirock.png differ diff --git a/images/shiny/Registeel.png b/images/shiny/Registeel.png new file mode 100644 index 0000000..f4d5200 Binary files /dev/null and b/images/shiny/Registeel.png differ diff --git a/images/shiny/Relicanth.png b/images/shiny/Relicanth.png new file mode 100644 index 0000000..f8e8ca0 Binary files /dev/null and b/images/shiny/Relicanth.png differ diff --git a/images/shiny/Rhydon.png b/images/shiny/Rhydon.png new file mode 100644 index 0000000..bf91c77 Binary files /dev/null and b/images/shiny/Rhydon.png differ diff --git a/images/shiny/Rhyhorn.png b/images/shiny/Rhyhorn.png new file mode 100644 index 0000000..95ddcc1 Binary files /dev/null and b/images/shiny/Rhyhorn.png differ diff --git a/images/shiny/Roselia.png b/images/shiny/Roselia.png new file mode 100644 index 0000000..9013cbb Binary files /dev/null and b/images/shiny/Roselia.png differ diff --git a/images/shiny/Sableye.png b/images/shiny/Sableye.png new file mode 100644 index 0000000..7f502b6 Binary files /dev/null and b/images/shiny/Sableye.png differ diff --git a/images/shiny/Salamence.png b/images/shiny/Salamence.png new file mode 100644 index 0000000..df822d0 Binary files /dev/null and b/images/shiny/Salamence.png differ diff --git a/images/shiny/Sandshrew.png b/images/shiny/Sandshrew.png new file mode 100644 index 0000000..f6d494b Binary files /dev/null and b/images/shiny/Sandshrew.png differ diff --git a/images/shiny/Sandslash.png b/images/shiny/Sandslash.png new file mode 100644 index 0000000..95616c0 Binary files /dev/null and b/images/shiny/Sandslash.png differ diff --git a/images/shiny/Sceptile.png b/images/shiny/Sceptile.png new file mode 100644 index 0000000..a947525 Binary files /dev/null and b/images/shiny/Sceptile.png differ diff --git a/images/shiny/Seadra.png b/images/shiny/Seadra.png new file mode 100644 index 0000000..2e3ea7a Binary files /dev/null and b/images/shiny/Seadra.png differ diff --git a/images/shiny/Seaking.png b/images/shiny/Seaking.png new file mode 100644 index 0000000..875a2f2 Binary files /dev/null and b/images/shiny/Seaking.png differ diff --git a/images/shiny/Sealeo.png b/images/shiny/Sealeo.png new file mode 100644 index 0000000..05ceb6d Binary files /dev/null and b/images/shiny/Sealeo.png differ diff --git a/images/shiny/Seedot.png b/images/shiny/Seedot.png new file mode 100644 index 0000000..f476a30 Binary files /dev/null and b/images/shiny/Seedot.png differ diff --git a/images/shiny/Seviper.png b/images/shiny/Seviper.png new file mode 100644 index 0000000..65ad62e Binary files /dev/null and b/images/shiny/Seviper.png differ diff --git a/images/shiny/Sharpedo.png b/images/shiny/Sharpedo.png new file mode 100644 index 0000000..c8075ae Binary files /dev/null and b/images/shiny/Sharpedo.png differ diff --git a/images/shiny/Shedinja.png b/images/shiny/Shedinja.png new file mode 100644 index 0000000..2395c6b Binary files /dev/null and b/images/shiny/Shedinja.png differ diff --git a/images/shiny/Shelgon.png b/images/shiny/Shelgon.png new file mode 100644 index 0000000..7863af9 Binary files /dev/null and b/images/shiny/Shelgon.png differ diff --git a/images/shiny/Shiftry.png b/images/shiny/Shiftry.png new file mode 100644 index 0000000..5881a06 Binary files /dev/null and b/images/shiny/Shiftry.png differ diff --git a/images/shiny/Shroomish.png b/images/shiny/Shroomish.png new file mode 100644 index 0000000..b52e8c4 Binary files /dev/null and b/images/shiny/Shroomish.png differ diff --git a/images/shiny/Shuppet.png b/images/shiny/Shuppet.png new file mode 100644 index 0000000..107055a Binary files /dev/null and b/images/shiny/Shuppet.png differ diff --git a/images/shiny/Silcoon.png b/images/shiny/Silcoon.png new file mode 100644 index 0000000..78ee207 Binary files /dev/null and b/images/shiny/Silcoon.png differ diff --git a/images/shiny/Skarmory.png b/images/shiny/Skarmory.png new file mode 100644 index 0000000..44bfad7 Binary files /dev/null and b/images/shiny/Skarmory.png differ diff --git a/images/shiny/Skitty.png b/images/shiny/Skitty.png new file mode 100644 index 0000000..cfbc64a Binary files /dev/null and b/images/shiny/Skitty.png differ diff --git a/images/shiny/Slaking.png b/images/shiny/Slaking.png new file mode 100644 index 0000000..985143c Binary files /dev/null and b/images/shiny/Slaking.png differ diff --git a/images/shiny/Slakoth.png b/images/shiny/Slakoth.png new file mode 100644 index 0000000..02c1e16 Binary files /dev/null and b/images/shiny/Slakoth.png differ diff --git a/images/shiny/Slugma.png b/images/shiny/Slugma.png new file mode 100644 index 0000000..1072b54 Binary files /dev/null and b/images/shiny/Slugma.png differ diff --git a/images/shiny/Snorunt.png b/images/shiny/Snorunt.png new file mode 100644 index 0000000..b90ff8c Binary files /dev/null and b/images/shiny/Snorunt.png differ diff --git a/images/shiny/Solrock.png b/images/shiny/Solrock.png new file mode 100644 index 0000000..34e23dd Binary files /dev/null and b/images/shiny/Solrock.png differ diff --git a/images/shiny/Spheal.png b/images/shiny/Spheal.png new file mode 100644 index 0000000..9747db2 Binary files /dev/null and b/images/shiny/Spheal.png differ diff --git a/images/shiny/Spinda.png b/images/shiny/Spinda.png new file mode 100644 index 0000000..4e3381f Binary files /dev/null and b/images/shiny/Spinda.png differ diff --git a/images/shiny/Spoink.png b/images/shiny/Spoink.png new file mode 100644 index 0000000..198eac7 Binary files /dev/null and b/images/shiny/Spoink.png differ diff --git a/images/shiny/Starmie.png b/images/shiny/Starmie.png new file mode 100644 index 0000000..13bcb2d Binary files /dev/null and b/images/shiny/Starmie.png differ diff --git a/images/shiny/Staryu.png b/images/shiny/Staryu.png new file mode 100644 index 0000000..fe302cf Binary files /dev/null and b/images/shiny/Staryu.png differ diff --git a/images/shiny/Surskit.png b/images/shiny/Surskit.png new file mode 100644 index 0000000..2e69e60 Binary files /dev/null and b/images/shiny/Surskit.png differ diff --git a/images/shiny/Swablu.png b/images/shiny/Swablu.png new file mode 100644 index 0000000..19e3ddd Binary files /dev/null and b/images/shiny/Swablu.png differ diff --git a/images/shiny/Swalot.png b/images/shiny/Swalot.png new file mode 100644 index 0000000..476a47b Binary files /dev/null and b/images/shiny/Swalot.png differ diff --git a/images/shiny/Swampert.png b/images/shiny/Swampert.png new file mode 100644 index 0000000..1545a37 Binary files /dev/null and b/images/shiny/Swampert.png differ diff --git a/images/shiny/Swellow.png b/images/shiny/Swellow.png new file mode 100644 index 0000000..46bb3b1 Binary files /dev/null and b/images/shiny/Swellow.png differ diff --git a/images/shiny/Taillow.png b/images/shiny/Taillow.png new file mode 100644 index 0000000..a3e8f46 Binary files /dev/null and b/images/shiny/Taillow.png differ diff --git a/images/shiny/Tentacool.png b/images/shiny/Tentacool.png new file mode 100644 index 0000000..882bc1b Binary files /dev/null and b/images/shiny/Tentacool.png differ diff --git a/images/shiny/Tentacruel.png b/images/shiny/Tentacruel.png new file mode 100644 index 0000000..6e3cadf Binary files /dev/null and b/images/shiny/Tentacruel.png differ diff --git a/images/shiny/Torchic.png b/images/shiny/Torchic.png new file mode 100644 index 0000000..00b12d5 Binary files /dev/null and b/images/shiny/Torchic.png differ diff --git a/images/shiny/Torkoal.png b/images/shiny/Torkoal.png new file mode 100644 index 0000000..7ee7224 Binary files /dev/null and b/images/shiny/Torkoal.png differ diff --git a/images/shiny/Trapinch.png b/images/shiny/Trapinch.png new file mode 100644 index 0000000..870d10f Binary files /dev/null and b/images/shiny/Trapinch.png differ diff --git a/images/shiny/Treecko.png b/images/shiny/Treecko.png new file mode 100644 index 0000000..b54bbb1 Binary files /dev/null and b/images/shiny/Treecko.png differ diff --git a/images/shiny/Tropius.png b/images/shiny/Tropius.png new file mode 100644 index 0000000..6f0b575 Binary files /dev/null and b/images/shiny/Tropius.png differ diff --git a/images/shiny/Vibrava.png b/images/shiny/Vibrava.png new file mode 100644 index 0000000..335cca9 Binary files /dev/null and b/images/shiny/Vibrava.png differ diff --git a/images/shiny/Vigoroth.png b/images/shiny/Vigoroth.png new file mode 100644 index 0000000..92e3a77 Binary files /dev/null and b/images/shiny/Vigoroth.png differ diff --git a/images/shiny/Vileplume.png b/images/shiny/Vileplume.png new file mode 100644 index 0000000..d9adc55 Binary files /dev/null and b/images/shiny/Vileplume.png differ diff --git a/images/shiny/Volbeat.png b/images/shiny/Volbeat.png new file mode 100644 index 0000000..24f118f Binary files /dev/null and b/images/shiny/Volbeat.png differ diff --git a/images/shiny/Voltorb.png b/images/shiny/Voltorb.png new file mode 100644 index 0000000..37fc0d7 Binary files /dev/null and b/images/shiny/Voltorb.png differ diff --git a/images/shiny/Vulpix.png b/images/shiny/Vulpix.png new file mode 100644 index 0000000..80aebc7 Binary files /dev/null and b/images/shiny/Vulpix.png differ diff --git a/images/shiny/Wailmer.png b/images/shiny/Wailmer.png new file mode 100644 index 0000000..a23cf36 Binary files /dev/null and b/images/shiny/Wailmer.png differ diff --git a/images/shiny/Wailord.png b/images/shiny/Wailord.png new file mode 100644 index 0000000..7025005 Binary files /dev/null and b/images/shiny/Wailord.png differ diff --git a/images/shiny/Walrein.png b/images/shiny/Walrein.png new file mode 100644 index 0000000..f2d4dac Binary files /dev/null and b/images/shiny/Walrein.png differ diff --git a/images/shiny/Weezing.png b/images/shiny/Weezing.png new file mode 100644 index 0000000..3bd1780 Binary files /dev/null and b/images/shiny/Weezing.png differ diff --git a/images/shiny/Whiscash.png b/images/shiny/Whiscash.png new file mode 100644 index 0000000..6766623 Binary files /dev/null and b/images/shiny/Whiscash.png differ diff --git a/images/shiny/Whismur.png b/images/shiny/Whismur.png new file mode 100644 index 0000000..55a463d Binary files /dev/null and b/images/shiny/Whismur.png differ diff --git a/images/shiny/Wigglytuff.png b/images/shiny/Wigglytuff.png new file mode 100644 index 0000000..ccc0cdd Binary files /dev/null and b/images/shiny/Wigglytuff.png differ diff --git a/images/shiny/Wingull.png b/images/shiny/Wingull.png new file mode 100644 index 0000000..644fae6 Binary files /dev/null and b/images/shiny/Wingull.png differ diff --git a/images/shiny/Wobbuffet.png b/images/shiny/Wobbuffet.png new file mode 100644 index 0000000..518802c Binary files /dev/null and b/images/shiny/Wobbuffet.png differ diff --git a/images/shiny/Wurmple.png b/images/shiny/Wurmple.png new file mode 100644 index 0000000..86297fb Binary files /dev/null and b/images/shiny/Wurmple.png differ diff --git a/images/shiny/Wynaut.png b/images/shiny/Wynaut.png new file mode 100644 index 0000000..02e3693 Binary files /dev/null and b/images/shiny/Wynaut.png differ diff --git a/images/shiny/Xatu.png b/images/shiny/Xatu.png new file mode 100644 index 0000000..9b77698 Binary files /dev/null and b/images/shiny/Xatu.png differ diff --git a/images/shiny/Zangoose.png b/images/shiny/Zangoose.png new file mode 100644 index 0000000..74333b0 Binary files /dev/null and b/images/shiny/Zangoose.png differ diff --git a/images/shiny/Zigzagoon.png b/images/shiny/Zigzagoon.png new file mode 100644 index 0000000..a8fa1f2 Binary files /dev/null and b/images/shiny/Zigzagoon.png differ diff --git a/images/shiny/Zubat.png b/images/shiny/Zubat.png new file mode 100644 index 0000000..e4cfd1c Binary files /dev/null and b/images/shiny/Zubat.png differ diff --git a/src/app.rs b/src/app.rs index 501ad14..c5c0f2c 100644 --- a/src/app.rs +++ b/src/app.rs @@ -1,19 +1,23 @@ -use crate::ui::screen::ScreenTrait; -use eframe::emath::Align; -use egui::panel::TopBottomSide; -use egui::{CursorIcon, Direction, Id, Label, Layout, RichText, Sense}; -use std::fs::File; -use std::io::{Cursor, Write}; -use std::sync::{Arc, OnceLock, RwLock, RwLockReadGuard}; -use crate::logger::Logger; +use crate::logger::{get_log_file, get_log_path, Logger}; use crate::save::pokemon::SelectedMon; +use crate::ui::image::ImageCache; use crate::ui::menu::render_menu_bar; -use crate::ui::screen::party_screen::PartyScreen; use crate::ui::screen::home_screen::HomeScreen; -use crate::ui::screen::{render_screen, Screen, }; +use crate::ui::screen::party_screen::PartyScreen; use crate::ui::screen::single_screen::SingleScreen; +use crate::ui::screen::ScreenTrait; +use crate::ui::screen::{render_screen, Screen}; +use egui::panel::TopBottomSide; +use egui::{CursorIcon, Id, Label, RichText, Sense}; use gvas::GvasFile; use rfd::MessageLevel; +use rust_embed::Embed; +use std::fs::File; +use std::io::{Cursor, Write}; +use std::sync::{Arc, OnceLock, RwLock, RwLockReadGuard}; +use eframe::IntegrationInfo; +use egui::util::undoer::Settings; +use crate::ui::screen::settings_screen::SettingsScreen; pub static GVAS_FILE: OnceLock>> = OnceLock::>>::new(); @@ -22,18 +26,17 @@ pub struct App { pub gvas_file: Option>>, pub screen: Screen, pub selected_mon: Option, + pub image_cache: ImageCache, } pub struct Screens { pub party_screen: PartyScreen, - pub single_screen: SingleScreen + pub single_screen: SingleScreen, } - impl App { pub fn new(cc: &eframe::CreationContext<'_>) -> Self { - - let logger = match Logger::init() { + match Logger::init() { Ok(_) => {} Err(e) => { rfd::MessageDialog::new() @@ -42,17 +45,26 @@ impl App { .set_description(format!( "Logger failed to start.\ Please check the app has sufficient permissions to create files.\ - {}", e) - ) + {}", + e + )) .show(); panic!() } }; - + Logger::info("Loading image cache"); + let start = chrono::Local::now().timestamp_millis(); + let mut cache = ImageCache::new(); + for path in Asset::iter() { + cache.get(&cc.egui_ctx, &path); + } + let end = chrono::Local::now().timestamp_millis(); + Logger::info(format!("Image cache loaded in: {} ms", end - start)); Self { gvas_file: None, screen: Screen::Home(HomeScreen), selected_mon: None, + image_cache: cache, } } @@ -75,7 +87,8 @@ impl App { }; let mut file = File::create(&path).map_err(|e| e.to_string())?; - file.write_all(&writer.into_inner()).map_err(|e| e.to_string())?; + file.write_all(&writer.into_inner()) + .map_err(|e| e.to_string())?; Ok(()) } @@ -86,24 +99,20 @@ impl App { let res = GVAS_FILE.set(guard); match res { - Ok(_) => { Ok(()) } + Ok(_) => Ok(()), Err(e) => { let msg = "Failed to load save (is it already loaded?)"; - Logger::error(msg.clone()); + Logger::error(msg); - Err(msg.to_string()) + Err(format!("{}: {:?}", msg, e)) } } } pub(crate) fn is_save_loaded(&self) -> bool { match &self.gvas_file { - None => { - false - } - Some(_) => { - true - } + None => false, + Some(_) => true, } } pub fn load_screen(&mut self, next: Screen) -> Result { @@ -119,6 +128,10 @@ impl App { Screen::Home(mut s) => { s.load(self); Screen::Home(s) + }, + Screen::Settings(mut s) => { + s.load(self); + Screen::Settings(s) } }; @@ -129,7 +142,7 @@ impl App { pub fn set_screen(&mut self, next: Screen) { Logger::info("Setting screen inside app"); self.screen = match self.load_screen(next) { - Ok(s) => {s} + Ok(s) => s, Err(_) => { Logger::error("Failed to set screen..."); return; @@ -138,15 +151,17 @@ impl App { } } +#[derive(Embed)] +#[folder = "images"] +pub struct Asset; + impl eframe::App for App { fn update(&mut self, ctx: &egui::Context, frame: &mut eframe::Frame) { ctx.data_mut(|map| { - map.insert_persisted( - Id::new("selected_mon"), - None::> - ) + map.insert_persisted(Id::new("selected_mon"), None::>) }); - render_menu_bar(ctx, self); + + render_menu_bar(self, ctx); render_navigation_bar(self, ctx); render_screen(self, ctx); } @@ -157,13 +172,15 @@ fn render_navigation_bar(app: &mut App, ctx: &egui::Context) { ui.horizontal_centered(|ui| { for screen in [ Screen::Home(HomeScreen), - Screen::Party(PartyScreen { loaded: false, containers: vec![] }), + Screen::Party(PartyScreen { + loaded: false, + containers: vec![], + }), + Screen::Settings(SettingsScreen::new()) ] { let text: RichText = RichText::new(screen.as_str()).size(18.0); - let response = ui.add( - Label::new(text).sense(Sense::click()) - ); + let response = ui.add(Label::new(text).sense(Sense::click())); if response.hovered() { ui.ctx().set_cursor_icon(CursorIcon::PointingHand); @@ -177,4 +194,4 @@ fn render_navigation_bar(app: &mut App, ctx: &egui::Context) { } }); }); -} \ No newline at end of file +} diff --git a/src/file/mod.rs b/src/file/mod.rs index e0b6ed1..3adf9d5 100644 --- a/src/file/mod.rs +++ b/src/file/mod.rs @@ -8,6 +8,4 @@ pub fn parse_with_root(string: String) -> PathBuf { let mut path: PathBuf = get_root(); path.push(string); path - - -} \ No newline at end of file +} diff --git a/src/lib.rs b/src/lib.rs index bed1108..412345d 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,12 +1,11 @@ extern crate core; -pub mod save; -pub mod pkmn; -pub mod property; -pub mod utils; +pub mod app; +pub mod file; pub mod logger; pub mod macros; +pub mod pkmn; +pub mod property; +pub mod save; pub mod ui; -pub mod file; -pub mod app; - +pub mod utils; diff --git a/src/logger/mod.rs b/src/logger/mod.rs index 88389d6..7870843 100644 --- a/src/logger/mod.rs +++ b/src/logger/mod.rs @@ -1,12 +1,12 @@ +use chrono::{DateTime, Local, Utc}; use std::env::current_dir; use std::fs::{File, OpenOptions}; -use std::{io, thread}; use std::io::Write; use std::path::PathBuf; -use std::sync::{mpsc, Mutex, OnceLock}; use std::sync::mpsc::{Receiver, Sender}; +use std::sync::{mpsc, Mutex, OnceLock}; use std::time::SystemTime; -use chrono::{DateTime, Local, Utc}; +use std::{io, thread}; pub fn info(message: &str) { let mut file: File = get_log_file(); @@ -24,10 +24,8 @@ pub fn get_log_file() -> File { let curr: DateTime = Utc::now(); let file_name: String = format!("logs/{}.log", curr.format("%d-%m-%y")); - let file: Result = OpenOptions::new() - .create(true) - .append(true) - .open(file_name); + let file: Result = + OpenOptions::new().create(true).append(true).open(file_name); match file { Ok(file) => file, @@ -37,13 +35,19 @@ pub fn get_log_file() -> File { } } +pub fn get_log_path() -> String { + let curr: DateTime = Utc::now(); + let file_name: String = format!("logs/{}.log", curr.format("%d-%m-%y")); + + file_name +} + static LOGGER_SENDER: OnceLock>> = OnceLock::new(); static LAST_LOGGED: OnceLock>> = OnceLock::new(); - #[derive(Clone)] pub struct Logger { - sender: Sender + sender: Sender, } pub struct LogMessage { @@ -59,17 +63,14 @@ pub enum LogLevel { } impl Logger { - - pub fn create_dir() -> Result<(), String>{ + pub fn create_dir() -> Result<(), String> { if let Err(e) = std::fs::create_dir_all("logs") { return Err("Failed to create log dir: {e}".to_string()); }; - Ok(()) } - pub fn create_file() -> Result { let now: DateTime = Utc::now(); let file_name = format!("logs/{}.log", now.format("%d-%m-%y")); @@ -80,23 +81,19 @@ impl Logger { .open(&file_name) { Ok(f) => Ok(f), - Err(e) => Err("Failed to open log file: {e}".to_string()) + Err(e) => Err("Failed to open log file: {e}".to_string()), } } pub fn init() -> Result<(), String> { let dir_created: () = match Self::create_dir() { - Ok(_) => { - - } - Err(err) => { - return Err(err) - } + Ok(_) => {} + Err(err) => return Err(err), }; let mut file: File = match Self::create_file() { - Ok(f) => {f} - Err(e) => { return Err(e)} + Ok(f) => f, + Err(e) => return Err(e), }; let (tx, rx): (Sender, Receiver) = mpsc::channel::(); @@ -109,7 +106,7 @@ impl Logger { let prefix: &str = match msg.level { LogLevel::Info => "[INFO]", LogLevel::Error => "[ERROR]", - LogLevel::Warn => "[WARN]" + LogLevel::Warn => "[WARN]", }; let line: String = format!("{timestamp} > {prefix} {}", msg.content); if let Err(e) = writeln!(file, "{}", line) { @@ -132,10 +129,8 @@ impl Logger { LOGGER_SENDER.get() } - /// Send a non-blocking log message pub fn log_once(level: LogLevel, message: impl Into) { - let msg = message.into(); // Initialise on first use @@ -165,7 +160,9 @@ impl Logger { if let Some(mtx) = Self::sender() { if let Ok(sender) = mtx.lock() { let string: String = message.into().clone(); - println!("{:?} > {}", level, string); + if cfg!(debug_assertions) { + println!("{:?} > {}", level, string); + } let _ = sender.send(LogMessage { level, content: string, @@ -174,9 +171,17 @@ impl Logger { } } - pub fn info_once(msg: impl Into) { Self::log_once(LogLevel::Info, msg); } + pub fn info_once(msg: impl Into) { + Self::log_once(LogLevel::Info, msg); + } - pub fn info(msg: impl Into) { Self::log(LogLevel::Info, msg); } - pub fn warn(msg: impl Into) { Self::log(LogLevel::Warn, msg); } - pub fn error(msg: impl Into) { Self::log(LogLevel::Error, msg); } + pub fn info(msg: impl Into) { + Self::log(LogLevel::Info, msg); + } + pub fn warn(msg: impl Into) { + Self::log(LogLevel::Warn, msg); + } + pub fn error(msg: impl Into) { + Self::log(LogLevel::Error, msg); + } } diff --git a/src/macros.rs b/src/macros.rs index 48dc070..b22c424 100644 --- a/src/macros.rs +++ b/src/macros.rs @@ -75,8 +75,8 @@ macro_rules! unwrap_gvas_mut { #[macro_export] macro_rules! try_gvas_read { ($cell:expr) => {{ - use $crate::logger::Logger; use std::sync::TryLockError; + use $crate::logger::Logger; match $cell.get() { Some(cell) => match cell.try_read() { @@ -101,8 +101,8 @@ macro_rules! try_gvas_read { #[macro_export] macro_rules! try_gvas_write { ($cell:expr) => {{ - use $crate::logger::Logger; use std::sync::TryLockError; + use $crate::logger::Logger; match $cell.get() { Some(cell) => match cell.try_write() { @@ -122,4 +122,4 @@ macro_rules! try_gvas_write { } } }}; -} \ No newline at end of file +} diff --git a/src/main.rs b/src/main.rs index 59247c1..294abea 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,37 +1,32 @@ -use std::process; +#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")] + use eframe::NativeOptions; +use egui::{TextBuffer, ViewportBuilder}; use gammaeditor::app::App; use gammaeditor::logger::Logger; - +use std::process; +use std::sync::Arc; fn main() { Logger::init().unwrap(); + let mut builder = ViewportBuilder::default(); + let icon_bytes = include_bytes!("../images/pokeball.ico"); + let icon = eframe::icon_data::from_png_bytes(icon_bytes).unwrap(); + builder.icon = Some(Arc::new(icon)); + let native_options: NativeOptions = NativeOptions { + viewport: builder, + ..Default::default() + }; - let native_options: NativeOptions = NativeOptions::default(); - let app_name: &str = "GammaEditor"; + let app_name: String = format!("GammaEditor {}", env!("CARGO_PKG_VERSION")); eframe::run_native( - app_name, + app_name.as_str(), native_options, Box::new(|cc| { egui_extras::install_image_loaders(&cc.egui_ctx); Ok(Box::new(App::new(cc))) - }) + }), ) - .expect("How did we get here?"); -} - - -fn run_generator(args: Vec) -> Result { - println!("Starting generator"); - - let output = process::Command::new("bin/generator.exe") - .args(args) - .output() - .map_err(|e| format!("Failed to run generator.exe: {e}"))?; - - if !output.status.success() { - return Err(String::from_utf8_lossy(&output.stderr).to_string()); - } - Ok(String::from_utf8_lossy(&output.stdout).to_string()) + .expect("How did we get here?"); } \ No newline at end of file diff --git a/src/pkmn/gender.rs b/src/pkmn/gender.rs index b5c8617..68ff4f3 100644 --- a/src/pkmn/gender.rs +++ b/src/pkmn/gender.rs @@ -1,4 +1,3 @@ - pub fn get_gender_from_enum(enum_str: &str) -> Option<&str> { let gender = match enum_str { "ENUM_Gender::NewEnumerator0" => "MALE", @@ -13,18 +12,17 @@ pub fn get_gender_from_enum(enum_str: &str) -> Option<&str> { pub enum Gender { Male, Female, - Unknown + Unknown, } -pub enum GenderStrings { -} +pub enum GenderStrings {} impl Gender { pub fn from_str(string: &str) -> Gender { match string.to_uppercase().as_str() { "MALE" => Gender::Male, "FEMALE" => Gender::Female, - _ => Gender::Unknown + _ => Gender::Unknown, } } @@ -33,9 +31,9 @@ impl Gender { let string = match &self { Gender::Male => "ENUM_Gender::NewEnumerator0", Gender::Female => "ENUM_Gender::NewEnumerator1", - Gender::Unknown => "ENUM_Gender::NewEnumerator2" + Gender::Unknown => "ENUM_Gender::NewEnumerator2", }; string.to_string() } -} \ No newline at end of file +} diff --git a/src/pkmn/mod.rs b/src/pkmn/mod.rs index 5ee8035..353d2eb 100644 --- a/src/pkmn/mod.rs +++ b/src/pkmn/mod.rs @@ -1,9 +1,9 @@ use serde::Serialize; -pub mod types; -pub mod natures; pub mod gender; +pub mod natures; pub mod stats; +pub mod types; #[derive(Debug, Serialize, Clone)] pub struct EnrichedMon { @@ -45,19 +45,19 @@ pub struct TotalMon { pub box_id: Option, pub pokeball: Option, pub shiny: bool, - pub is_empty: bool + pub is_empty: bool, } #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] pub struct Types { pub primary: String, - pub secondary: String + pub secondary: String, } #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] pub struct GridPos { pub slot: i64, - pub row: i64 + pub row: i64, } #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] @@ -67,14 +67,14 @@ pub struct Stats { pub defense: f64, pub special_attack: f64, pub special_defense: f64, - pub speed: f64 + pub speed: f64, } #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] pub struct Move { pub name: String, pub pp: i64, - pub max_pp: i64 + pub max_pp: i64, } impl TotalMon { @@ -90,10 +90,7 @@ impl TotalMon { types: None, nature: "".to_string(), class: "".to_string(), - grid_pos: GridPos { - slot, - row - }, + grid_pos: GridPos { slot, row }, pokemon_id: Some(0), storage_index: Some(0), box_id: Some(box_number), diff --git a/src/pkmn/natures.rs b/src/pkmn/natures.rs index ee0fc4f..04d213e 100644 --- a/src/pkmn/natures.rs +++ b/src/pkmn/natures.rs @@ -1,7 +1,7 @@ // ENUM_Natures::NewEnumerator0 hardy // 1 lonely // 2 brave -// 3 adamant +// 3 adamant // ENUM_Natures::NewEnumerator6 docile // ENUM_Natures::NewEnumerator7 relaxed // 8 impish @@ -22,8 +22,8 @@ // 23 careful // ENUM_Natures::NewEnumerator24 quirky -use std::str::FromStr; use crate::pkmn::natures::Nature::{Adamant, Brave, Docile, Hardy, Lonely}; +use std::str::FromStr; /// Returns nature as a lowercase string pub fn get_nature_from_enum(enum_str: &str) -> Option<&str> { @@ -55,35 +55,35 @@ pub fn get_nature_from_enum(enum_str: &str) -> Option<&str> { "ENUM_Natures::NewEnumerator24" => "quirky", _ => return None, }; - + Some(nature) } #[derive(Debug, Clone, Copy, PartialEq, Eq)] pub enum Nature { - Hardy, // 0 - Lonely, // 1 - Brave, // 2 - Adamant, // 3 - Docile, // 6 - Relaxed, // 7 - Impish, // 8 - Lax, // 9 - Timid, // 10 - Hasty, // 11 - Serious, // 12 - Jolly, // 13 - Naive, // 14 - Modest, // 15 - Mild, // 16 - Quiet, // 17 - Bashful, // 18 - Rash, // 19 - Calm, // 20 - Gentle, // 21 - Sassy, // 22 - Careful, // 23 - Quirky, // 24 + Hardy, // 0 + Lonely, // 1 + Brave, // 2 + Adamant, // 3 + Docile, // 6 + Relaxed, // 7 + Impish, // 8 + Lax, // 9 + Timid, // 10 + Hasty, // 11 + Serious, // 12 + Jolly, // 13 + Naive, // 14 + Modest, // 15 + Mild, // 16 + Quiet, // 17 + Bashful, // 18 + Rash, // 19 + Calm, // 20 + Gentle, // 21 + Sassy, // 22 + Careful, // 23 + Quirky, // 24 } impl FromStr for Nature { @@ -94,6 +94,4 @@ impl FromStr for Nature { } } -pub enum NatureNamespace { - -} \ No newline at end of file +pub enum NatureNamespace {} diff --git a/src/pkmn/stats.rs b/src/pkmn/stats.rs index db6933b..9470e15 100644 --- a/src/pkmn/stats.rs +++ b/src/pkmn/stats.rs @@ -9,7 +9,7 @@ pub enum Stats { DEF, SATK, SDEF, - SPEED + SPEED, } impl Stats { @@ -21,8 +21,9 @@ impl Stats { Stats::DEF, Stats::SATK, Stats::SDEF, - Stats::SPEED - ].into_iter() + Stats::SPEED, + ] + .into_iter() } pub fn as_str(&self) -> &str { @@ -40,7 +41,7 @@ impl Stats { #[derive(Clone, Debug)] pub struct StatStruct { - pub values: HashMap + pub values: HashMap, } impl FromStr for Stats { @@ -67,18 +68,18 @@ pub enum IVs { DEF, SATK, SDEF, - SPEED + SPEED, } impl IVs { pub fn as_str(&self) -> &str { match self { - IVs::HP => {"HP"} - IVs::ATK => {"ATK"} - IVs::DEF => {"DEF"} - IVs::SATK => {"SATK"} - IVs::SDEF => {"SDEF"} - IVs::SPEED => {"SPEED"} + IVs::HP => "HP", + IVs::ATK => "ATK", + IVs::DEF => "DEF", + IVs::SATK => "SATK", + IVs::SDEF => "SDEF", + IVs::SPEED => "SPEED", } } pub fn iter() -> impl Iterator { @@ -88,24 +89,24 @@ impl IVs { IVs::DEF, IVs::SATK, IVs::SDEF, - IVs::SPEED - ].into_iter() + IVs::SPEED, + ] + .into_iter() } pub fn from_stat(stat: Stats) -> Option { match stat { - Stats::MaxHp => { Some(IVs::HP) } - Stats::ATK => { Some(IVs::ATK) } - Stats::DEF => { Some(IVs::DEF) } - Stats::SATK => { Some(IVs::SATK) } - Stats::SDEF => { Some(IVs::SDEF) } - Stats::SPEED => { Some(IVs::SPEED) } - _ => None + Stats::MaxHp => Some(IVs::HP), + Stats::ATK => Some(IVs::ATK), + Stats::DEF => Some(IVs::DEF), + Stats::SATK => Some(IVs::SATK), + Stats::SDEF => Some(IVs::SDEF), + Stats::SPEED => Some(IVs::SPEED), + _ => None, } } } - #[derive(Clone, Debug)] pub struct IVSpread { pub hp: i32, @@ -119,12 +120,12 @@ pub struct IVSpread { impl IVs { pub fn get_index(self) -> usize { match self { - IVs::HP => {0} - IVs::ATK => {1} - IVs::DEF => {2} - IVs::SATK => {3} - IVs::SDEF => {4} - IVs::SPEED => {5} + IVs::HP => 0, + IVs::ATK => 1, + IVs::DEF => 2, + IVs::SATK => 3, + IVs::SDEF => 4, + IVs::SPEED => 5, } } } diff --git a/src/pkmn/types.rs b/src/pkmn/types.rs index a072dae..2e841c2 100644 --- a/src/pkmn/types.rs +++ b/src/pkmn/types.rs @@ -67,7 +67,8 @@ impl FromStr for Types { } } fn get_enum_number(enum_str: &str) -> Option { - enum_str.to_string() + enum_str + .to_string() .split("::") .last() .and_then(|part| part.strip_prefix("NewEnumerator")) @@ -75,7 +76,6 @@ fn get_enum_number(enum_str: &str) -> Option { } pub fn from_enum(enum_str: &str) -> Option<&str> { - let num: i32 = get_enum_number(enum_str)?; let t = match num { 0 => "BUG", @@ -95,15 +95,11 @@ pub fn from_enum(enum_str: &str) -> Option<&str> { 18 => "FAIRY", _ => return None, }; - + Some(t) } pub enum TypeOrder { PRIMARY, - SECONDARY + SECONDARY, } - - - - diff --git a/src/property/mod.rs b/src/property/mod.rs index d36fc60..f6ac8fc 100644 --- a/src/property/mod.rs +++ b/src/property/mod.rs @@ -1 +1 @@ -pub mod traits; \ No newline at end of file +pub mod traits; diff --git a/src/property/traits.rs b/src/property/traits.rs index 7f5c7f3..eefa81d 100644 --- a/src/property/traits.rs +++ b/src/property/traits.rs @@ -3,7 +3,7 @@ use gvas::properties::struct_property::{StructProperty, StructPropertyValue}; use gvas::properties::Property; pub struct ParentProperty<'a> { - property: Option<&'a Property> + property: Option<&'a Property>, } pub trait FromProperty<'a> { @@ -29,7 +29,6 @@ pub trait StartsWith { fn get_starts_with(&self, string: &str) -> Option<&Vec>; fn get_starts_with_mut(&mut self, string: &str) -> Option<&mut Vec>; - } impl StartsWith for StructProperty { @@ -37,29 +36,31 @@ impl StartsWith for StructProperty { fn get_starts_with(&self, string: &str) -> Option<&Vec> { match &self.value { StructPropertyValue::CustomStruct { properties, .. } => { - for (k,v) in properties.0.iter() { + for (k, v) in properties.0.iter() { if k.starts_with(string) { - return Some(v) + return Some(v); } } None } - _ => None + _ => None, } } /// Returns a mutable vector of properties in a StructProperty, - fn get_starts_with_mut(& mut self, string: &str) -> Option<&mut Vec> { + fn get_starts_with_mut(&mut self, string: &str) -> Option<&mut Vec> { match &mut self.value { - StructPropertyValue::CustomStruct { ref mut properties, .. } => { - for (k,v) in properties.0.iter_mut() { + StructPropertyValue::CustomStruct { + ref mut properties, .. + } => { + for (k, v) in properties.0.iter_mut() { if k.starts_with(string) { - return Some(v) + return Some(v); } } None } - _ => None + _ => None, } } } @@ -83,8 +84,8 @@ impl PropertyPath for Property { } fn get_starts_with_mut(&mut self, prefix: &str) -> Option<&mut Property> { - if let Property::StructProperty(StructProperty { value, ..}) = self { - if let StructPropertyValue::CustomStruct { properties, ..} = value { + if let Property::StructProperty(StructProperty { value, .. }) = self { + if let StructPropertyValue::CustomStruct { properties, .. } = value { for (k, v) in properties.0.iter_mut() { if k.starts_with(prefix) { return v.first_mut(); @@ -105,32 +106,26 @@ impl NamespacedValue for Property { fn get_namespaced_value(&self, string: &str) -> Option<&String> { let prop = self.get_starts_with(string)?; let byte = match prop { - Property::ByteProperty(byte) => { - Some(byte) - } - _ => None + Property::ByteProperty(byte) => Some(byte), + _ => None, }?; match &byte.value { - BytePropertyValue::Namespaced(namespaced) => { - Some(namespaced) - } - _ => None + BytePropertyValue::Namespaced(namespaced) => Some(namespaced), + _ => None, } } fn get_namespaced_value_mut(&mut self, string: &str) -> Option<&mut String> { let prop: &mut Property = self.get_starts_with_mut(string)?; let byte = match prop { - Property::ByteProperty(ref mut byte) => { - Some(byte) - } - _ => None + Property::ByteProperty(ref mut byte) => Some(byte), + _ => None, }?; match &mut byte.value { BytePropertyValue::Namespaced(namespaced) => Some(namespaced), - _ => None + _ => None, } } } @@ -140,21 +135,17 @@ impl NamespacedValue for StructProperty { let vec = self.get_starts_with(string)?; let prop = vec.first()?; let byte = match prop { - Property::ByteProperty(byte) => { - Some(byte) - } - _ => None + Property::ByteProperty(byte) => Some(byte), + _ => None, }?; match &byte.value { - BytePropertyValue::Namespaced(namespace) => { - Some(namespace) - } - _ => None + BytePropertyValue::Namespaced(namespace) => Some(namespace), + _ => None, } } fn get_namespaced_value_mut(&mut self, string: &str) -> Option<&mut String> { todo!() } -} \ No newline at end of file +} diff --git a/src/save/backup.rs b/src/save/backup.rs index db36e06..e66fb4b 100644 --- a/src/save/backup.rs +++ b/src/save/backup.rs @@ -1,9 +1,6 @@ use std::fs; use std::path::Path; -use tauri::command; - -#[command] -pub fn create_backup() -> Result{ +pub fn create_backup() -> Result { let local_appdata = std::env::var("LOCALAPPDATA") .map_err(|_| "Could not find LOCALAPPDATA variable...".to_string())?; @@ -15,7 +12,10 @@ pub fn create_backup() -> Result{ let original_path = save_dir.join("Slot1.sav"); if !original_path.exists() { - return Err(format!("Slot1.sav does not exist: {:?}", original_path.display())); + return Err(format!( + "Slot1.sav does not exist: {:?}", + original_path.display() + )); } let timestamp = chrono::Local::now().format("%d %m %Y %H-%M-%S").to_string(); @@ -32,9 +32,7 @@ pub fn create_backup() -> Result{ let new_filename = format!("{file_stem} - {timestamp}.{}", extension); let new_path = save_dir.join(new_filename); - fs::copy(&original_path, &new_path) - .map_err(|e| format!("Failed to copy file: {}", e))?; + fs::copy(&original_path, &new_path).map_err(|e| format!("Failed to copy file: {}", e))?; Ok("Success!".to_string()) - -} \ No newline at end of file +} diff --git a/src/save/mod.rs b/src/save/mod.rs index 7e8f58c..e97d71c 100644 --- a/src/save/mod.rs +++ b/src/save/mod.rs @@ -1,20 +1,20 @@ +use gvas::game_version::GameVersion; +use gvas::properties::Property; +use gvas::GvasFile; use std::fs::File; use std::io; use std::io::Write; use std::path::PathBuf; use std::sync::{Arc, RwLock, RwLockReadGuard, RwLockWriteGuard}; -use gvas::game_version::GameVersion; -use gvas::GvasFile; -use gvas::properties::Property; -pub mod utils; +pub mod backup; pub mod pokemon; +pub mod utils; pub type SharedGvas = Arc>; pub type SharedState = Arc>; pub struct Shared(SharedState); - pub trait SharedStateExt { fn with(&self, f: impl FnOnce(&AppState) -> R) -> Option; fn with_mut(&self, f: impl FnOnce(&mut AppState) -> R) -> Option; @@ -34,10 +34,9 @@ impl SharedStateExt for SharedState { pub struct AppState { pub file_path: Option, pub gvas_file: Option, - pub json: Option + pub json: Option, } impl AppState { - pub fn empty() -> Self { Self { file_path: None, @@ -57,7 +56,7 @@ impl AppState { if let Some(path) = &self.file_path { let file: Result = File::open(path); match file { - Ok(f) => { Some(f) } + Ok(f) => Some(f), Err(_e) => { // todo!() add logging, why did it fail, etc None @@ -66,21 +65,18 @@ impl AppState { } else { None } - } pub fn load_gvas(&mut self) -> () { match self.get_file_from_path() { - Some(mut file) => { - match GvasFile::read(&mut file, GameVersion::Default) { - Ok(gvas) => { - self.gvas_file = Some(Arc::new(RwLock::new(gvas))); - }, - Err(e) => { - eprintln!("{e}"); - } + Some(mut file) => match GvasFile::read(&mut file, GameVersion::Default) { + Ok(gvas) => { + self.gvas_file = Some(Arc::new(RwLock::new(gvas))); } - } + Err(e) => { + eprintln!("{e}"); + } + }, None => {} } } @@ -95,7 +91,11 @@ impl AppState { { let mut guard = self.gvas_file.as_ref()?.write().ok()?; println!("{:?}", guard.properties.keys()); - println!("Contains key '{}': {}", &key, guard.properties.contains_key(key)); + println!( + "Contains key '{}': {}", + &key, + guard.properties.contains_key(key) + ); let prop = guard.properties.get_mut(key)?; Some(f(prop)) @@ -115,7 +115,11 @@ impl AppState { match gvas.read() { Ok(guard) => { eprintln!("Lock succeeded!"); - eprintln!("Contains key '{}': {}", key, guard.properties.contains_key(key)); + eprintln!( + "Contains key '{}': {}", + key, + guard.properties.contains_key(key) + ); if let Some(prop) = guard.properties.get(key) { Some(f(prop)) } else { @@ -130,6 +134,3 @@ impl AppState { } } } - - - diff --git a/src/save/pokemon/attack_lists.rs b/src/save/pokemon/attack_lists.rs index 31f875d..e2e38ec 100644 --- a/src/save/pokemon/attack_lists.rs +++ b/src/save/pokemon/attack_lists.rs @@ -1,12 +1,12 @@ use gvas::properties::array_property::ArrayProperty; -use gvas::properties::Property; use gvas::properties::struct_property::StructProperty; +use gvas::properties::Property; // Takes the "PartyAttackLists" property pub fn attack_array(property: &Property) -> Option<&ArrayProperty> { let cs: &ArrayProperty = match &property { Property::ArrayProperty(arr) => Some(arr), - _ => return None + _ => return None, }?; Some(cs) @@ -15,7 +15,7 @@ pub fn attack_array(property: &Property) -> Option<&ArrayProperty> { pub fn attacks_at(array: &ArrayProperty, index: usize) -> Option<&ArrayProperty> { let property: &StructProperty = match &array { ArrayProperty::Structs { structs, .. } => structs.get(index)?, - _ => return None + _ => return None, }; let (_, v) = property.value.get_custom_struct()?; @@ -24,7 +24,7 @@ pub fn attacks_at(array: &ArrayProperty, index: usize) -> Option<&ArrayProperty> let first = val.first()?; return match &first { Property::ArrayProperty(arr) => Some(arr), - _ => None + _ => None, }; } } @@ -35,16 +35,12 @@ pub fn attacks_at(array: &ArrayProperty, index: usize) -> Option<&ArrayProperty> /// Takes attacks_at custom struct. Returns the attack string pub fn attack_at(array: &ArrayProperty, index: usize) -> Option<&String> { let property = match &array { - ArrayProperty::Properties { properties, .. } => { - properties.get(index) - } + ArrayProperty::Properties { properties, .. } => properties.get(index), _ => None, }?; let object = match &property { - Property::ObjectProperty(obj) => { - obj - } + Property::ObjectProperty(obj) => obj, _ => return None, }; diff --git a/src/save/pokemon/gender.rs b/src/save/pokemon/gender.rs index 412d266..d1477b2 100644 --- a/src/save/pokemon/gender.rs +++ b/src/save/pokemon/gender.rs @@ -4,19 +4,15 @@ use gvas::properties::Property; pub fn gender_string_at(array: &ArrayProperty, index: usize) -> Option<&String> { let prop = match array { - ArrayProperty::Properties { properties, .. } => { - properties.get(index) - }, - _ => None + ArrayProperty::Properties { properties, .. } => properties.get(index), + _ => None, }?; match prop { - Property::ByteProperty(byte) => { - match &byte.value { - BytePropertyValue::Byte(_) => { None } - BytePropertyValue::Namespaced(namespace) => { Some(namespace) } - } - } - _ => None + Property::ByteProperty(byte) => match &byte.value { + BytePropertyValue::Byte(_) => None, + BytePropertyValue::Namespaced(namespace) => Some(namespace), + }, + _ => None, } -} \ No newline at end of file +} diff --git a/src/save/pokemon/iv_struct.rs b/src/save/pokemon/iv_struct.rs index dea7ec6..330a35b 100644 --- a/src/save/pokemon/iv_struct.rs +++ b/src/save/pokemon/iv_struct.rs @@ -1,14 +1,13 @@ - -use std::ops::Index; -use gvas::GvasFile; -use gvas::properties::int_property::IntProperty; -use gvas::properties::Property; -use gvas::properties::struct_property::{StructProperty, StructPropertyValue}; use crate::gvas; use crate::pkmn::stats::{IVSpread, IVs}; use crate::property::traits::StartsWith; use crate::save::pokemon::StorageType; use crate::utils::custom_struct::{get_struct_property_at_idx, get_struct_property_at_idx_mut}; +use gvas::properties::int_property::IntProperty; +use gvas::properties::struct_property::{StructProperty, StructPropertyValue}; +use gvas::properties::Property; +use gvas::GvasFile; +use std::ops::Index; pub fn get_ivs<'a>(properties: &'a StructProperty) -> Option> { match &properties.value { @@ -21,7 +20,7 @@ pub fn get_ivs<'a>(properties: &'a StructProperty) -> Option> { } Some(ivs) } - _ => None + _ => None, } } @@ -37,7 +36,7 @@ pub fn get_iv_at_mut(properties: &mut StructProperty, index: usize, ivs: IVs) -> pub struct IV<'a> { property: &'a Property, box_number: Option, - storage_type: StorageType + storage_type: StorageType, } impl<'a> IV<'a> { @@ -84,7 +83,7 @@ impl<'a> IV<'a> { pub struct IVMut<'a> { property: &'a mut Property, box_number: Option, - storage_type: StorageType + storage_type: StorageType, } impl<'a> IVMut<'a> { @@ -103,7 +102,7 @@ impl<'a> IVMut<'a> { None => { return Err("Failed to get struct property mutably.".to_string()); } - Some(prop) => {prop} + Some(prop) => prop, }; match &mut sp.value { @@ -111,21 +110,23 @@ impl<'a> IVMut<'a> { for (k, v) in properties.0.iter_mut() { if k.starts_with(iv.as_str()) { let prop: &mut Property = match v.first_mut() { - None => { return Err("Failed to get first".to_string())} - Some(prop) => {prop} + None => return Err("Failed to get first".to_string()), + Some(prop) => prop, }; match prop { Property::IntProperty(ref mut prop) => { prop.value = value; } - _ => {return Err(format!("Failed to get int: {:?}", prop));} + _ => { + return Err(format!("Failed to get int: {:?}", prop)); + } } } } } - _ => return Err("set_iv_at failed.".to_string()) + _ => return Err("set_iv_at failed.".to_string()), }; Ok(()) } -} \ No newline at end of file +} diff --git a/src/save/pokemon/mod.rs b/src/save/pokemon/mod.rs index fb7c42c..74aa949 100644 --- a/src/save/pokemon/mod.rs +++ b/src/save/pokemon/mod.rs @@ -1,18 +1,18 @@ use std::cmp::PartialEq; pub mod attack_lists; +pub mod gender; +pub mod iv_struct; +pub mod pokemon_classes; pub mod pokemon_id; pub mod pokemon_info; -pub mod pokemon_classes; -pub mod shiny_list; pub mod pp_moves_lists; -pub mod iv_struct; -pub mod gender; +pub mod shiny_list; #[derive(PartialEq, Clone, Debug)] pub enum StorageType { PARTY, - BOXES + BOXES, } #[derive(Clone)] @@ -25,17 +25,16 @@ impl Default for SelectedMon { fn default() -> Self { Self { storage_type: StorageType::PARTY, - index: 0 + index: 0, } } } - impl SelectedMon { pub fn new(storage_type: StorageType, index: usize) -> SelectedMon { SelectedMon { storage_type, - index + index, } } @@ -54,4 +53,13 @@ impl SelectedMon { true } -} \ No newline at end of file +} + +/// Corrects an invalid mon's name +pub fn correct_name(name: String) -> String { + match name.as_str() { + "Metacross" => "Metagross", + other => other, + } + .to_string() +} diff --git a/src/save/pokemon/pokemon_classes.rs b/src/save/pokemon/pokemon_classes.rs index 8c306af..ee9853c 100644 --- a/src/save/pokemon/pokemon_classes.rs +++ b/src/save/pokemon/pokemon_classes.rs @@ -1,37 +1,31 @@ -use gvas::GvasFile; use gvas::properties::array_property::ArrayProperty; use gvas::properties::Property; +use gvas::GvasFile; -pub fn class_at(array: &ArrayProperty, idx: usize) -> Option<&String>{ +pub fn class_at(array: &ArrayProperty, idx: usize) -> Option<&String> { let class_property = match &array { - ArrayProperty::Properties { properties, .. } => { - properties.get(idx)? - }, - _ => return None + ArrayProperty::Properties { properties, .. } => properties.get(idx)?, + _ => return None, }; match &class_property { - Property::ObjectProperty(prop) => { - Some(&prop.value) - } - _ => None + Property::ObjectProperty(prop) => Some(&prop.value), + _ => None, } } /// Probably shouldn't be used, at least not until an enum for every class is written... pub fn class_at_mut(array: &mut ArrayProperty, idx: usize) -> Option<&mut String> { let class_property: &mut Property = match array { - ArrayProperty::Properties { ref mut properties, .. } => { - properties.get_mut(idx)? - } - _ => return None + ArrayProperty::Properties { + ref mut properties, .. + } => properties.get_mut(idx)?, + _ => return None, }; match class_property { - Property::ObjectProperty(ref mut prop) => { - Some(&mut prop.value) - }, - _ => None + Property::ObjectProperty(ref mut prop) => Some(&mut prop.value), + _ => None, } } @@ -48,9 +42,8 @@ pub fn parse_class(class: &str) -> Option { Some(name) } - pub struct PokemonClasses<'a> { - property: &'a Property + property: &'a Property, } impl<'a> PokemonClasses<'a> { @@ -66,7 +59,39 @@ impl<'a> PokemonClasses<'a> { class } + pub fn classes(&self) -> Option> { + let array: &ArrayProperty = match self.property.get_array() { + None => return None, + Some(arr) => arr, + }; + let mut strings: Vec<&String> = Vec::new(); + match array { + ArrayProperty::Properties { properties, .. } => { + for i in properties.iter() { + match i { + Property::ObjectProperty(prop) => { + let val = &prop.value; + strings.push(val); + } + _ => {} + } + } + } + _ => {} + }; + + Some(strings) + } + pub fn parse_class(&self, class: &str) -> Option { parse_class(class) } -} \ No newline at end of file + pub fn parse_classes(&self, classes: Vec<&String>) -> Option> { + let mut class_vec = Vec::new(); + for class in classes.iter() { + let parsed = self.parse_class(class)?; + class_vec.push(parsed) + } + Some(class_vec) + } +} diff --git a/src/save/pokemon/pokemon_id.rs b/src/save/pokemon/pokemon_id.rs index 2338e1f..4d500a4 100644 --- a/src/save/pokemon/pokemon_id.rs +++ b/src/save/pokemon/pokemon_id.rs @@ -13,7 +13,7 @@ pub fn id_array_mut(property: &mut Property) -> Option<&mut ArrayProperty> { pub fn id_at(array: &ArrayProperty, index: usize) -> Option<&i32> { match array { ArrayProperty::Ints { ints, .. } => ints.get(index), - _ => None + _ => None, } } @@ -23,4 +23,4 @@ pub fn id_at_mut(array: &mut ArrayProperty, index: usize) -> Option<&mut i32> { pub struct PokemonID; -impl PokemonID {} \ No newline at end of file +impl PokemonID {} diff --git a/src/save/pokemon/pokemon_info.rs b/src/save/pokemon/pokemon_info.rs index 70d5d44..0102c1a 100644 --- a/src/save/pokemon/pokemon_info.rs +++ b/src/save/pokemon/pokemon_info.rs @@ -1,27 +1,25 @@ -use std::collections::HashMap; -use std::fmt::format; -use gvas::GvasFile; +use crate::logger::Logger; +use crate::pkmn::stats::{StatStruct, Stats}; +use crate::property::traits::{NamespacedValue, PropertyPath, StartsWith}; +use crate::utils::custom_struct::{ + get_struct_at_idx, get_struct_at_idx_mut, get_struct_property_at_idx, CustomStruct, +}; use gvas::properties::array_property::ArrayProperty; use gvas::properties::int_property::BytePropertyValue; -use gvas::properties::Property; -use gvas::properties::struct_property::{StructProperty}; +use gvas::properties::struct_property::StructProperty; use gvas::properties::text_property::FTextHistory; +use gvas::properties::Property; +use gvas::GvasFile; use rfd::MessageDialogResult::No; -use crate::logger::Logger; -use crate::pkmn::stats::{StatStruct, Stats}; -use crate::property::traits::{NamespacedValue, PropertyPath, StartsWith}; -use crate::utils::custom_struct::{get_struct_at_idx, get_struct_at_idx_mut, get_struct_property_at_idx, CustomStruct}; +use std::collections::HashMap; +use std::fmt::format; pub fn get_is_fainted(struct_property: &StructProperty) -> Option { - let is_fainted: &Vec = struct_property.get_starts_with("isFainted")?; let first: &Property = is_fainted.first()?; match first { - - Property::BoolProperty(bool) => { - Some(bool.value) - } - _ => None + Property::BoolProperty(bool) => Some(bool.value), + _ => None, } } @@ -71,10 +69,8 @@ pub fn get_stat(properties: &StructProperty, stat: Stats) -> Option { let stat_str: &str = stat.as_str(); let stat_property = properties.get_starts_with(stat_str)?.first()?; match &stat_property { - Property::DoubleProperty(double) => { - Some(double.value.0) - } - _ => None + Property::DoubleProperty(double) => Some(double.value.0), + _ => None, } } @@ -93,7 +89,6 @@ pub fn get_stat_mut(properties: &mut StructProperty, stat: Stats) -> Option<&mut val } - pub fn get_stats(properties: &StructProperty) -> Option { fn get_value(props: &StructProperty, stat: Stats) -> Option { let name = stat.as_str(); @@ -112,9 +107,7 @@ pub fn get_stats(properties: &StructProperty) -> Option { map.insert(stat.clone(), get_value(properties, stat)?); } - Some(StatStruct { - values: map - }) + Some(StatStruct { values: map }) } pub fn get_level(properties: &StructProperty) -> Option { @@ -122,10 +115,8 @@ pub fn get_level(properties: &StructProperty) -> Option { let level_prop = vec.first()?; match level_prop { - Property::IntProperty(int) => { - Some(int.value) - } - _ => None + Property::IntProperty(int) => Some(int.value), + _ => None, } } @@ -134,27 +125,38 @@ pub fn get_name(properties: &StructProperty) -> Option<&String> { let name_prop = vec.first()?; let history = match name_prop { - Property::TextProperty(text) => { - Some(&text.value.history) - } - _ => None + Property::TextProperty(text) => Some(&text.value.history), + _ => None, }?; let source_string = match history { - FTextHistory::Base { source_string, .. } => { - match source_string { - None => None, - Some(str) => { - Some(str) - } - } - } - _ => return None + FTextHistory::Base { source_string, .. } => match source_string { + None => None, + Some(str) => Some(str), + }, + _ => return None, }; source_string } +pub fn get_name_mut(properties: &mut StructProperty) -> Option<&mut String> { + let vec = properties.get_starts_with_mut("Name")?; + let name_prop = vec.first_mut()?; + + if let Property::TextProperty(text) = name_prop { + if let FTextHistory::Base { + source_string: Some(ref mut s), + .. + } = &mut text.value.history + { + return Some(s); + } + } + + None +} + /// Returns a namespaced string pub fn get_nature<'a>(properties: &StructProperty) -> Option<&String> { let vec = properties.get_starts_with("Nature")?; @@ -162,14 +164,12 @@ pub fn get_nature<'a>(properties: &StructProperty) -> Option<&String> { match nature_prop { Property::ByteProperty(byte) => { let val = &byte.value; - match &val { - BytePropertyValue::Namespaced(namespace) => { - Some(namespace) - } - _ => None + match &val { + BytePropertyValue::Namespaced(namespace) => Some(namespace), + _ => None, } } - _ => None + _ => None, } } @@ -186,20 +186,16 @@ pub fn get_nature_string(properties: &StructProperty) -> Option<&String> { properties.get_namespaced_value("Nature") } - pub struct PokemonInfo<'a> { /// The actual property containing isFainted, IVs, name, etc. property: &'a Property, - } impl<'a> PokemonInfo<'a> { /// Todo: turn this into a trait pub fn new_party(gvas_file: &'a GvasFile) -> Option { let prop = gvas_file.properties.get("PartyPokemonInfo")?; - Some(Self { - property: prop - }) + Some(Self { property: prop }) } pub fn get_name(&self, index: usize) -> Option<&String> { @@ -237,12 +233,9 @@ pub struct PokemonInfoMut<'a> { } impl<'a> PokemonInfoMut<'a> { - pub fn new_party(gvas_file: &'a mut GvasFile) -> Option { let prop = gvas_file.properties.get_mut("PartyPokemonInfo")?; - Some(Self { - property: prop - }) + Some(Self { property: prop }) } pub fn set_stat(&mut self, index: usize, stat: Stats, value: f64) { @@ -252,5 +245,12 @@ impl<'a> PokemonInfoMut<'a> { } } } -} + pub fn set_name(&mut self, index: usize, name: String) { + if let Some(s) = get_struct_at_idx_mut(self.property, index) { + if let Some(name_ref) = get_name_mut(s) { + *name_ref = name; + } + } + } +} diff --git a/src/save/pokemon/pp_moves_lists.rs b/src/save/pokemon/pp_moves_lists.rs index ba88a11..7264dbb 100644 --- a/src/save/pokemon/pp_moves_lists.rs +++ b/src/save/pokemon/pp_moves_lists.rs @@ -1,6 +1,6 @@ use gvas::properties::array_property::ArrayProperty; -use gvas::properties::Property; use gvas::properties::struct_property::{StructProperty, StructPropertyValue}; +use gvas::properties::Property; use indexmap::IndexMap; pub fn moves_array(property: &Property) -> Option<&ArrayProperty> { @@ -21,12 +21,10 @@ pub fn moves_at(array: &ArrayProperty, index: usize) -> Option<&ArrayProperty> { _ => return None, }; - properties - .values() - .find_map(|v| match v.first()? { - Property::ArrayProperty(arr) => Some(arr), - _ => None, - }) + properties.values().find_map(|v| match v.first()? { + Property::ArrayProperty(arr) => Some(arr), + _ => None, + }) } /// Gets max pp at an index @@ -34,27 +32,27 @@ pub fn moves_at(array: &ArrayProperty, index: usize) -> Option<&ArrayProperty> { pub fn max_pp_at(moves: &ArrayProperty, index: usize) -> Option<&i32> { let pp_struct: &StructProperty = match &moves { ArrayProperty::Structs { structs, .. } => structs.get(index)?, - _ => return None + _ => return None, }; let map: &IndexMap> = pp_struct.value.get_custom_struct()?.1; - let prop: &Property = map.iter() - .find(|(k,_)| k.starts_with("MaxPP")) - .and_then(|(_,v)| v.first())?; + let prop: &Property = map + .iter() + .find(|(k, _)| k.starts_with("MaxPP")) + .and_then(|(_, v)| v.first())?; Some(&prop.get_int()?.value) } pub fn current_pp_at(moves: &ArrayProperty, index: usize) -> Option<&i32> { let pp_struct: &StructProperty = match &moves { ArrayProperty::Structs { structs, .. } => structs.get(index)?, - _ => return None + _ => return None, }; let map: &IndexMap> = pp_struct.value.get_custom_struct()?.1; // Typo "Curremt" is intentional, it's like that in the file... - let prop: &Property = map.iter() - .find(|(k,_)| k.starts_with("CurremtPP")) - .and_then(|(_,v)| v.first())?; + let prop: &Property = map + .iter() + .find(|(k, _)| k.starts_with("CurremtPP")) + .and_then(|(_, v)| v.first())?; Some(&prop.get_int()?.value) } pub struct PPMovesLists; - - diff --git a/src/save/pokemon/shiny_list.rs b/src/save/pokemon/shiny_list.rs index 2fa4bda..6527c81 100644 --- a/src/save/pokemon/shiny_list.rs +++ b/src/save/pokemon/shiny_list.rs @@ -4,34 +4,24 @@ use gvas::properties::struct_property::{StructProperty, StructPropertyValue}; use gvas::properties::Property; use gvas::GvasFile; -pub fn get_shiny_list(array: &ArrayProperty) -> Option<&Vec>{ +pub fn get_shiny_list(array: &ArrayProperty) -> Option<&Vec> { match array { - ArrayProperty::Bools { bools } => { - Some(bools) - } - _ => None + ArrayProperty::Bools { bools } => Some(bools), + _ => None, } } pub fn get_shiny_at(array: &ArrayProperty, index: usize) -> Option<&bool> { match array { - ArrayProperty::Bools { bools } => { - bools.get(index) - } - _ => { - None - } + ArrayProperty::Bools { bools } => bools.get(index), + _ => None, } } pub fn get_shiny_at_mut(array: &mut ArrayProperty, index: usize) -> Option<&mut bool> { match array { - ArrayProperty::Bools { ref mut bools } => { - bools.get_mut(index) - } - _ => { - None - } + ArrayProperty::Bools { ref mut bools } => bools.get_mut(index), + _ => None, } } @@ -46,16 +36,14 @@ pub fn set_shiny_at(array: &mut ArrayProperty, index: usize, value: bool) -> boo } pub struct ShinyList<'a> { - pub property: &'a Property + pub property: &'a Property, } impl<'a> ShinyList<'a> { pub fn new_party(gvas_file: &'a GvasFile) -> Option { - let prop = match gvas_file.properties.get("PartyShinyList"){ - None => {None} - Some(p) => { - Some(Self { property: p }) - } + let prop = match gvas_file.properties.get("PartyShinyList") { + None => None, + Some(p) => Some(Self { property: p }), }; prop @@ -79,18 +67,18 @@ impl<'a> ShinyList<'a> { } pub struct ShinyListMut<'a> { - property: &'a mut Property + property: &'a mut Property, } impl<'a> ShinyListMut<'a> { pub fn new_party(gvas_file: &'a mut GvasFile) -> Option { let property: &mut Property = match gvas_file.properties.get_mut("PartyShinyList") { - None => {return None;} - Some(p) => {p} + None => { + return None; + } + Some(p) => p, }; - Some(Self { - property - }) + Some(Self { property }) } pub fn set_shiny_at(&mut self, index: usize, value: bool) -> Result<(), String> { @@ -100,10 +88,13 @@ impl<'a> ShinyListMut<'a> { *shiny = value; Ok(()) } else { - Err(format!("Failed to set shiny at index {} (does it exist?)", index)) + Err(format!( + "Failed to set shiny at index {} (does it exist?)", + index + )) } } - _ => { Err(format!("Failed to set shiny at index {}", index)) } + _ => Err(format!("Failed to set shiny at index {}", index)), } } -} \ No newline at end of file +} diff --git a/src/save/utils.rs b/src/save/utils.rs index 701a337..5cb4fa2 100644 --- a/src/save/utils.rs +++ b/src/save/utils.rs @@ -2,25 +2,44 @@ use serde_json::Value; use std::collections::HashMap; pub fn get_f64(info: &HashMap, prefix: &str) -> Option { - info.iter().find(|(k, _)| k.starts_with(prefix))?.1.get(0)?.get("value")?.as_f64() + info.iter() + .find(|(k, _)| k.starts_with(prefix))? + .1 + .get(0)? + .get("value")? + .as_f64() } pub fn get_i64(info: &HashMap, prefix: &str) -> Option { - info.iter().find(|(k, _)| k.starts_with(prefix))?.1.get(0)?.get("value")?.as_i64() + info.iter() + .find(|(k, _)| k.starts_with(prefix))? + .1 + .get(0)? + .get("value")? + .as_i64() } pub fn get_namespaced(info: &HashMap, prefix: &str) -> Option { - info.iter().find(|(k, _)| k.starts_with(prefix))? - .1.get(0)?.get("Namespaced")?.as_str().map(String::from) + info.iter() + .find(|(k, _)| k.starts_with(prefix))? + .1 + .get(0)? + .get("Namespaced")? + .as_str() + .map(String::from) } - pub fn get_name(info: &HashMap) -> Option { - info.iter().find(|(k, _)| k.starts_with("Name_"))? - .1.get(0)?.get("source_string")?.as_str().map(String::from) + info.iter() + .find(|(k, _)| k.starts_with("Name_"))? + .1 + .get(0)? + .get("source_string")? + .as_str() + .map(String::from) } -pub fn get_box_key(box_number: i64) -> Option{ +pub fn get_box_key(box_number: i64) -> Option { Option::from(format!("Box{}", box_number)) } @@ -34,7 +53,10 @@ pub fn get_first_starts_with<'a>( } // get the key name that starts with prefix -pub fn get_starts_with(prefix: String, map: &serde_json::Map) -> Option { +pub fn get_starts_with( + prefix: String, + map: &serde_json::Map, +) -> Option { for key in map.keys() { if key.starts_with(&prefix) { return Some(key.clone()); @@ -49,4 +71,4 @@ pub fn match_bool(string: &str) -> Option { "false" => Some(false), _ => None, } -} \ No newline at end of file +} diff --git a/src/ui/image.rs b/src/ui/image.rs index f0f6a63..15df40d 100644 --- a/src/ui/image.rs +++ b/src/ui/image.rs @@ -1,28 +1,31 @@ -use egui::{Color32, Vec2}; -use crate::save::pokemon::StorageType; -use crate::ui::menu::OnClick; -use crate::ui::screen::render_pokemon_path; +use crate::app::Asset; +use crate::save::pokemon::pokemon_classes::parse_class; +use crate::save::pokemon::{correct_name, StorageType}; +use egui::{Color32, ColorImage, Context, TextureHandle, Vec2}; +use std::collections::HashMap; -#[derive(Clone)] +#[derive(Clone, Debug)] pub struct ImageContainer { pub(crate) path: String, pub storage_type: StorageType, pub index: usize, - pub name: String, - pub is_shiny: bool + pub parsed_class: String, + pub is_shiny: bool, } impl ImageContainer { - pub fn new_party(name: String, is_shiny: bool, index: usize) -> Self { - let path: String = render_pokemon_path(name.clone(), is_shiny); + pub fn new_party(class: String, is_shiny: bool, index: usize) -> Option { + let shiny_text = if is_shiny { "shiny" } else { "normal" }; + let parsed_class = parse_class(class.as_str())?; + let path = format!("{}/{}.png", shiny_text, correct_name(parsed_class)); - Self { + Some(Self { path, storage_type: StorageType::PARTY, - name, + parsed_class: class, is_shiny, index, - } + }) } } @@ -31,4 +34,44 @@ pub struct ImageSettings { pub size: Option, pub bg_color: Option, pub corner_radius: Option, -} \ No newline at end of file +} + +#[derive(Clone)] +pub struct ImageCache { + pub map: HashMap, +} + +impl ImageCache { + pub fn new() -> Self { + Self { + map: HashMap::new(), + } + } + + pub fn get(&mut self, ctx: &Context, path: &str) -> Option<&TextureHandle> { + if !self.map.contains_key(path) { + if let Some(texture) = Self::load_texture(ctx, path) { + self.map.insert(path.to_string(), texture); + } + } + self.map.get(path) + } + + fn load_texture(ctx: &Context, path: &str) -> Option { + let file = Asset::get(path)?; + let img = image::load_from_memory(&file.data).ok()?; + let rgba = img.to_rgba8(); + let (w, h) = (img.width() as usize, img.height() as usize); + let color_image = ColorImage::from_rgba_unmultiplied([w, h], &rgba); + Some(ctx.load_texture(path.to_owned(), color_image, egui::TextureOptions::LINEAR)) + } + + pub fn list_all(&self) -> String { + let keys = self.map.keys(); + let mut list = String::new(); + keys.for_each(|key| { + list.push_str(&format!("{} ", key)); + }); + list + } +} diff --git a/src/ui/menu/buttons.rs b/src/ui/menu/buttons.rs index eb70746..b13fc43 100644 --- a/src/ui/menu/buttons.rs +++ b/src/ui/menu/buttons.rs @@ -1,7 +1,7 @@ -use std::io; -use std::process::{Child, Command}; use crate::logger::Logger; use crate::ui::menu::{MenuButton, OnClick}; +use std::io; +use std::process::{Child, Command}; pub struct DiscordButton; @@ -50,4 +50,4 @@ impl OnClick for DiscordButton { .spawn(); } } -} \ No newline at end of file +} diff --git a/src/ui/menu/discord.rs b/src/ui/menu/discord.rs index e69de29..8b13789 100644 --- a/src/ui/menu/discord.rs +++ b/src/ui/menu/discord.rs @@ -0,0 +1 @@ + diff --git a/src/ui/menu/mod.rs b/src/ui/menu/mod.rs index fac6ae6..b0b4a83 100644 --- a/src/ui/menu/mod.rs +++ b/src/ui/menu/mod.rs @@ -1,20 +1,19 @@ -use std::fs::File; -use std::path::{Path, PathBuf}; -use std::process::Command; -use egui::containers::menu; -use egui::{Context, ViewportCommand}; -use gvas::error::Error; -use gvas::game_version::GameVersion; -use gvas::GvasFile; use crate::app::App; use crate::logger::Logger; use crate::ui::menu::buttons::DiscordButton; use crate::ui::screen::party_screen::PartyScreen; use crate::ui::screen::Screen; +use egui::containers::menu; +use egui::{Context, ViewportCommand}; +use gvas::error::Error; +use gvas::game_version::GameVersion; +use gvas::GvasFile; +use std::fs::File; +use std::path::{Path, PathBuf}; +use std::process::Command; -pub mod discord; mod buttons; - +pub mod discord; pub trait MenuButton { fn get_identifier(&self) -> String; @@ -34,76 +33,74 @@ pub trait OnChange { fn on_change(&self); } -pub fn render_menu_bar(ctx: &Context, state: &mut App) { +pub fn render_menu_bar(state: &mut App, ctx: &Context) { egui::TopBottomPanel::top("menu_bar").show(ctx, |ui| { - menu::MenuBar::new().ui(ui, |ui| { - ui.menu_button("File", |ui| { - if ui.button("Open").clicked() { - let dialog = rfd::FileDialog::new() - .add_filter("Save files", &["sav"]) - .pick_file(); - - let path: PathBuf = match dialog { - None => { return } - Some(path) => { - path - } - }; - let mut file: File = match File::open(path) { - Ok(f) => { f } - Err(error) => { - Logger::error(error.to_string()); - return; - } - }; + menu::MenuBar::new().ui(ui, |ui| { + ui.menu_button("File", |ui| { + if ui.button("Open").clicked() { + let dialog = rfd::FileDialog::new() + .add_filter("Save files", &["sav"]) + .pick_file(); - let gvas: GvasFile = match GvasFile::read(&mut file, GameVersion::Default) { - Ok(res) => { - res - } - Err(error) => { - Logger::error(String::from(format!("Failed to read gvas file: {}", error))); - return - } - }; + let path: PathBuf = match dialog { + None => return, + Some(path) => path, + }; + let mut file: File = match File::open(path) { + Ok(f) => f, + Err(error) => { + Logger::error(error.to_string()); + return; + } + }; - match state.load_save(gvas) { - Ok(_) => { - Logger::info("Save loaded successfully"); - } - Err(e) => { - Logger::error(e); - } - } + let gvas: GvasFile = match GvasFile::read(&mut file, GameVersion::Default) { + Ok(res) => res, + Err(error) => { + Logger::error(String::from(format!( + "Failed to read gvas file: {}", + error + ))); + return; + } + }; - state.set_screen(Screen::Party(PartyScreen { - loaded: false, - containers: vec![], - })); + match state.load_save(gvas) { + Ok(_) => { + Logger::info("Save loaded successfully"); + } + Err(e) => { + Logger::error(e); + } + } - } + state.set_screen(Screen::Party(PartyScreen { + loaded: false, + containers: vec![], + })); + } - if ui.button("Save").clicked() { - let res = App::save_to(); - match res { - Ok(_) => { - Logger::info("Saved successfully"); - } - Err(s) => { - Logger::error(format!("Failed to save: {}", s)); - } - }; - } - if ui.button("Quit").clicked() { - ui.ctx().send_viewport_cmd(ViewportCommand::Close); - } - }); - ui.menu_button("Help", |ui| { - let discord = DiscordButton::new(); - if ui.button(discord.display()).clicked() { - discord.on_click(); - } - }); - }); + if ui.button("Save").clicked() { + let res = App::save_to(); + match res { + Ok(_) => { + Logger::info("Saved successfully"); + } + Err(s) => { + Logger::error(format!("Failed to save: {}", s)); + } + }; + } + if ui.button("Quit").clicked() { + ui.ctx().send_viewport_cmd(ViewportCommand::Close); + } + }); + ui.menu_button("Help", |ui| { + let discord = DiscordButton::new(); + if ui.button(discord.display()).clicked() { + discord.on_click(); + } + }); + }); }); } diff --git a/src/ui/mod.rs b/src/ui/mod.rs index b6b8538..20e9e09 100644 --- a/src/ui/mod.rs +++ b/src/ui/mod.rs @@ -1,9 +1,12 @@ -use egui::{Color32, Image, Vec2}; +use crate::app::Asset; use crate::ui::image::ImageContainer; +use egui::load::SizedTexture; +use egui::{Color32, Image, TextureHandle, Vec2}; +use rust_embed::EmbeddedFile; -pub mod screen; +pub(crate) mod image; pub mod menu; -mod image; +pub mod screen; fn render_image<'a>(path: String) -> Image<'a> { Image::new(path) @@ -13,8 +16,23 @@ fn render_image<'a>(path: String) -> Image<'a> { } fn render_image_container(container: &ImageContainer) -> Image { + // let src = match Asset::get(container.path.clone().as_str()) { + // None => {Image::new("")} + // Some(image) => { + // Image::new(image) + // } + // }; Image::new(container.path.clone()) .corner_radius(5) .bg_fill(Color32::from_rgb(50, 50, 50)) .fit_to_exact_size(Vec2::new(64.0, 64.0)) -} \ No newline at end of file +} + +pub fn render_texture(texture: &TextureHandle) -> Image { + Image::new(SizedTexture { + id: texture.id(), + size: Vec2::new(64.0, 64.0), + }) + .corner_radius(5) + .bg_fill(Color32::from_rgb(50, 50, 50)) +} diff --git a/src/ui/screen/home_screen.rs b/src/ui/screen/home_screen.rs index 14953d1..0df7a05 100644 --- a/src/ui/screen/home_screen.rs +++ b/src/ui/screen/home_screen.rs @@ -1,18 +1,16 @@ -use egui::Ui; -use gvas::GvasFile; use crate::app::App; use crate::ui::screen::{ScreenAction, ScreenTrait}; +use egui::Ui; +use gvas::GvasFile; #[derive(Clone, Debug)] pub struct HomeScreen; impl ScreenTrait for HomeScreen { - fn load(&mut self, app: &mut App) { - - } + fn load(&mut self, app: &mut App) {} fn ui(&mut self, ui: &mut Ui, app: &mut App) -> ScreenAction { ui.heading("Please load a save to begin"); ScreenAction::None } -} \ No newline at end of file +} diff --git a/src/ui/screen/mod.rs b/src/ui/screen/mod.rs index 56236d0..f76b93d 100644 --- a/src/ui/screen/mod.rs +++ b/src/ui/screen/mod.rs @@ -1,20 +1,23 @@ pub mod home_screen; pub mod party_screen; pub(crate) mod single_screen; +pub mod settings_screen; -use std::fmt::format; use crate::app::App; use crate::logger::Logger; +use crate::ui::screen::home_screen::HomeScreen; +use egui::{CentralPanel, Ui}; use party_screen::PartyScreen; use single_screen::SingleScreen; -use egui::{CentralPanel, Ui}; -use crate::ui::screen::home_screen::HomeScreen; +use std::fmt::format; +use crate::ui::screen::settings_screen::SettingsScreen; #[derive(Clone)] pub enum Screen { Party(PartyScreen), Single(SingleScreen), Home(HomeScreen), + Settings(SettingsScreen) } impl ScreenTrait for Screen { @@ -23,6 +26,7 @@ impl ScreenTrait for Screen { Screen::Home(s) => s.load(app), Screen::Party(s) => s.load(app), Screen::Single(s) => s.load(app), + Screen::Settings(s) => s.load(app) } } @@ -31,28 +35,28 @@ impl ScreenTrait for Screen { Screen::Home(s) => s.ui(ui, app), Screen::Party(s) => s.ui(ui, app), Screen::Single(s) => s.ui(ui, app), + Screen::Settings(s) => s.ui(ui, app) } } } pub enum ScreenState { Party(PartyScreen), - Empty() + Empty(), } - pub enum ScreenAction { None, ChangeTo(Screen), - Reload + Reload, } impl ScreenAction { pub fn as_str(&self) -> &str { match self { - ScreenAction::None => {"None"} - ScreenAction::ChangeTo(_) => {"ChangeTo"} - ScreenAction::Reload => {"Reload"} + ScreenAction::None => "None", + ScreenAction::ChangeTo(_) => "ChangeTo", + ScreenAction::Reload => "Reload", } } } @@ -60,8 +64,8 @@ impl ScreenAction { impl ScreenState { pub fn name(&self) -> &str { match self { - ScreenState::Party(_) => {"Party"} - _ => "" + ScreenState::Party(_) => "Party", + _ => "", } } } @@ -76,14 +80,16 @@ impl Screen { pub fn iter() -> impl Iterator { [ // we dont want Single in here - ].into_iter() + ] + .into_iter() } pub fn as_str(&self) -> &str { match &self { - Screen::Party(PartyScreen) => {"Party"} - Screen::Single(SingleScreen) => {"Single"} - Screen::Home(HomeScreen) => {"Home"} + Screen::Party(party_screen) => "Party", + Screen::Single(single_screen) => "Single", + Screen::Home(home_screen) => "Home", + Screen::Settings(s) => "Settings" } } } @@ -96,7 +102,7 @@ pub trait ScreenTrait { pub fn render_pokemon_path<'a>(name: String, is_shiny: bool) -> String { let shiny_folder: &str = if is_shiny { "shiny" } else { "normal" }; format!( - "file://{}/scraper/images/{}/{}.png", + "file://{}/images/{}/{}.png", env!("CARGO_MANIFEST_DIR").replace("\\", "/"), shiny_folder, name @@ -108,17 +114,15 @@ pub fn get_images_path() -> String { } pub fn render_screen(app_state: &mut App, ctx: &egui::Context) { - CentralPanel::default().show(ctx, |ui| { let mut action: ScreenAction = ScreenAction::None; - if app_state.is_save_loaded() { + if app_state.is_save_loaded() {} - } - action = match &mut app_state.clone().screen { Screen::Home(s) => s.ui(ui, app_state), Screen::Party(s) => s.ui(ui, app_state), Screen::Single(s) => s.ui(ui, app_state), + Screen::Settings(s) => {s.ui(ui, app_state)} }; handle_screen_action(app_state, ctx, action) diff --git a/src/ui/screen/party_screen.rs b/src/ui/screen/party_screen.rs index d971c8b..f3fd730 100644 --- a/src/ui/screen/party_screen.rs +++ b/src/ui/screen/party_screen.rs @@ -1,22 +1,23 @@ -use std::ops::Deref; use crate::app::{App, GVAS_FILE}; use crate::logger::Logger; -use crate::save::pokemon::pokemon_classes::{class_at, parse_class}; +use crate::save::pokemon::pokemon_classes::{class_at, parse_class, PokemonClasses}; use crate::save::pokemon::shiny_list::get_shiny_list; -use crate::save::pokemon::{SelectedMon, StorageType}; -use crate::ui::render_image; -use crate::ui::screen::{render_pokemon_path, Screen, ScreenAction, ScreenTrait}; +use crate::save::pokemon::{correct_name, SelectedMon, StorageType}; +use crate::ui::image::ImageContainer; use crate::ui::screen::single_screen::{SingleScreen, SingleScreenBuffer}; +use crate::ui::screen::{render_pokemon_path, Screen, ScreenAction, ScreenTrait}; +use crate::ui::{render_image, render_texture}; +use crate::unwrap_gvas; use crate::utils::set_data_persisted; -use egui::{CursorIcon, Direction, Layout, Response, RichText, Sense, TextBuffer, Ui}; +use egui::{CursorIcon, Direction, Image, Layout, Response, RichText, Sense, TextBuffer, Ui}; use gvas::properties::Property; use gvas::GvasFile; -use crate::ui::image::ImageContainer; +use std::ops::Deref; #[derive(Clone)] pub struct PartyScreen { pub(crate) loaded: bool, - pub containers: Vec, + pub containers: Vec>, } impl ScreenTrait for PartyScreen { @@ -24,72 +25,113 @@ impl ScreenTrait for PartyScreen { if self.loaded { return; } - - let gvas_file: &GvasFile = match app.gvas_file.as_ref() { - Some(file) => &file.read().unwrap().to_owned(), - None => return, + + let gvas_file: &GvasFile = &*unwrap_gvas!(GVAS_FILE); + + let wrapper: PokemonClasses = match PokemonClasses::new_party(gvas_file) { + None => { + Logger::error("Failed to create classes wrapper"); + return; + } + Some(w) => w, }; - let names = match get_names(gvas_file) { + let classes: Vec<&String> = match wrapper.classes() { None => { Logger::error("Failed to get names"); - Vec::new() - } - Some(n) => { - Logger::info_once(n.join(", ")); - n + return; } + Some(v) => v, }; - let arr = gvas_file.properties.get("PartyShinyList").unwrap().get_array().unwrap(); + + let Some(parsed) = wrapper.parse_classes(classes) else { + Logger::error("Failed to parse classes"); + return; + }; + + let arr = gvas_file + .properties + .get("PartyShinyList") + .unwrap() + .get_array() + .unwrap(); let shiny_vec = get_shiny_list(arr).unwrap(); - let mut container_vec: Vec = Vec::new(); - for (i, (name, is_shiny)) in names.iter().zip(shiny_vec.iter()).enumerate() { - let container = ImageContainer::new_party(name.clone(), is_shiny.clone(), i); + if parsed.len() != shiny_vec.len() { + return; + } + Logger::info(format!("Parsed: {:?}", parsed)); + let mut container_vec: Vec> = Vec::new(); + for i in 0..5 { + let class: String = match parsed.get(i) { + None => { + Logger::info(format!("Failed to get parsed at index {}", i)); + continue; + } + Some(class) => class.clone(), + }; + let shiny = shiny_vec.get(i).unwrap().clone(); + let container = ImageContainer::new_party(class.clone(), shiny, i); container_vec.push(container); } + Logger::info(format!("{:?}", container_vec)); self.containers = container_vec; - } fn ui(&mut self, ui: &mut Ui, app: &mut App) -> ScreenAction { - let mut action: ScreenAction = ScreenAction::None; ui.centered_and_justified(|ui| { egui::Grid::new("party-grid").show(ui, |ui| { if GVAS_FILE.get().is_none() { - ui.with_layout(Layout::centered_and_justified(Direction::LeftToRight), |ui| { - let text: RichText = RichText::new("Party not found. Please load a save file to continue.").size(24.0); - ui.add_sized([ui.available_width(), 24.0],egui::Label::new(text)); - }); + ui.with_layout( + Layout::centered_and_justified(Direction::LeftToRight), + |ui| { + let text: RichText = RichText::new( + "Party not found. Please load a save file to continue.", + ) + .size(24.0); + ui.add_sized([ui.available_width(), 24.0], egui::Label::new(text)); + }, + ); } - for container in self.containers.iter() { - let res: Response = ui.add(render_image(container.path.clone())).interact(Sense::click()); - if res.clicked() { - Logger::info_once(format!("{} Clicked!", container.name)); - - let mon: SelectedMon = SelectedMon { - storage_type: StorageType::PARTY, - index: container.index, - }; - set_data_persisted(ui.ctx(), "selected_mon".into(), mon.clone()); - - app.selected_mon = Some(mon.clone()); - - Logger::info_once("Set selected mon"); - action = ScreenAction::ChangeTo(Screen::Single(SingleScreen { - loaded: false, - mon_data: None, - buf: SingleScreenBuffer::default(), - gvas_file: None, - needs_refresh: true, - })) - } - if res.hovered() { - ui.ctx().set_cursor_icon(CursorIcon::PointingHand); + for option in self.containers.iter() { + let container: &ImageContainer = match option { + None => continue, + Some(p) => p, + }; + if let Some(tex) = app.image_cache.get(ui.ctx(), container.path.as_str()) { + let image: Image = render_texture(tex).sense(Sense::click()); + let res = ui.add(image); + + if res.clicked() { + Logger::info_once(format!("{} Clicked!", container.parsed_class)); + + let mon: SelectedMon = SelectedMon { + storage_type: StorageType::PARTY, + index: container.index, + }; + set_data_persisted(ui.ctx(), "selected_mon".into(), mon.clone()); + + app.selected_mon = Some(mon.clone()); + + Logger::info_once("Set selected mon"); + action = ScreenAction::ChangeTo(Screen::Single(SingleScreen { + loaded: false, + mon_data: None, + buf: SingleScreenBuffer::default(), + gvas_file: None, + needs_refresh: true, + })) + } + + if res.hovered() { + ui.ctx().set_cursor_icon(CursorIcon::PointingHand); + } + } else { + Logger::info(format!("No such image: {}", container.path.as_str())); } } }); @@ -101,19 +143,15 @@ impl ScreenTrait for PartyScreen { pub fn get_names(gvas_file: &GvasFile) -> Option> { let prop: &Property = match gvas_file.properties.get("PartyPokemonClasses") { - None => {return None} - Some(p) => {p} + None => return None, + Some(p) => p, }; let arr = prop.get_array()?; let mut class_vec: Vec = Vec::new(); for i in 0..5 { let class = match class_at(&arr, i) { - None => { - continue - } - Some(c) => { - c - } + None => continue, + Some(c) => c, }; class_vec.push(class.clone()); } @@ -121,10 +159,10 @@ pub fn get_names(gvas_file: &GvasFile) -> Option> { let mut vec: Vec = Vec::new(); for i in class_vec.iter() { let parsed: String = match parse_class(i.as_str()) { - None => {"".to_string()} - Some(c) => {c} + None => "".to_string(), + Some(c) => c, }; vec.push(parsed) } Some(vec) -} \ No newline at end of file +} diff --git a/src/ui/screen/settings_screen.rs b/src/ui/screen/settings_screen.rs new file mode 100644 index 0000000..e80f866 --- /dev/null +++ b/src/ui/screen/settings_screen.rs @@ -0,0 +1,67 @@ +use std::fs; +use std::fs::File; +use std::path::Path; +use egui::{ScrollArea, TextEdit, Ui}; +use crate::app::App; +use crate::logger::{get_log_path, Logger}; +use crate::ui::screen::{ScreenAction, ScreenTrait}; + +#[derive(Clone)] +pub struct SettingsScreen { + log_path: String, + log_contents: Option +} + +impl SettingsScreen { + + pub fn new() -> Self { + Self { + log_path: get_log_path(), + log_contents: None, + } + } +} + +impl ScreenTrait for SettingsScreen { + fn load(&mut self, app: &mut App) { + let file = match File::open(self.log_path.as_str()) { + Ok(f) => {f} + Err(_) => { + Logger::error("Failed to open log file..."); + return; + } + }; + + self.log_contents = match fs::read_to_string(&self.log_path) { + Ok(content) => {Some(content)} + Err(e) => { + Logger::error(format!("{}", e.to_string())); + return; + } + }; + + } + + fn ui(&mut self, ui: &mut Ui, app: &mut App) -> ScreenAction { + let mut action = ScreenAction::None; + ui.heading("Settings"); + + ui.add_space(5.0); + if let Some(logs) = &mut self.log_contents { + ScrollArea::both() + .id_source("log_viewer") + .auto_shrink([false, false]) + .show(ui, |ui| { + ui.add( + TextEdit::multiline(logs) + .code_editor() + .interactive(false) + .desired_width(f32::INFINITY) + .frame(true) + ); + }); + } + + action + } +} \ No newline at end of file diff --git a/src/ui/screen/single_screen.rs b/src/ui/screen/single_screen.rs index 5f63980..cfead18 100644 --- a/src/ui/screen/single_screen.rs +++ b/src/ui/screen/single_screen.rs @@ -3,20 +3,24 @@ use crate::logger::Logger; use crate::pkmn::stats::{IVSpread, IVs, StatStruct, Stats}; use crate::save::pokemon::iv_struct::IVMut; use crate::save::pokemon::iv_struct::IV; +use crate::save::pokemon::pokemon_classes::{parse_class, PokemonClasses}; use crate::save::pokemon::pokemon_info::{InfoStruct, PokemonInfo, PokemonInfoMut}; use crate::save::pokemon::shiny_list::{ShinyList, ShinyListMut}; +use crate::save::pokemon::{correct_name, StorageType}; +use crate::ui::image::ImageContainer; use crate::ui::screen::{get_images_path, render_pokemon_path, Reload, ScreenAction, ScreenTrait}; +use crate::ui::{render_image_container, render_texture}; use crate::{try_gvas_read, try_gvas_write, unwrap_gvas}; -use egui::{Button, Image, Response, Sense, TextEdit, Ui}; +use eframe::emath::Vec2; +use eframe::epaint::Color32; +use egui::Shape::Path; +use egui::{Button, Image, Response, RichText, Sense, TextEdit, Ui}; use egui_extras::{Column, TableBuilder, TableRow}; use gvas::GvasFile; +use rfd::MessageDialogResult::No; use std::collections::HashMap; +use std::fmt::format; use std::sync::RwLockWriteGuard; -use eframe::emath::Vec2; -use eframe::epaint::Color32; -use crate::save::pokemon::StorageType; -use crate::ui::image::ImageContainer; -use crate::ui::render_image_container; #[derive(Clone, Debug)] pub struct SingleScreen { @@ -34,6 +38,7 @@ pub struct Buffer { #[derive(Clone, Debug)] pub struct SingleMon { index: usize, + class: String, storage_type: StorageType, is_shiny: bool, name: String, @@ -41,12 +46,11 @@ pub struct SingleMon { ivs: IVSpread, } - #[derive(Default, Clone, Debug)] pub struct SingleScreenBuffer { pub pokemon_info: Option, pub is_shiny: Option, - pub ivs: Option> + pub ivs: Option>, } impl SingleScreenBuffer { @@ -62,17 +66,18 @@ impl SingleScreenBuffer { impl SingleScreen { fn render_row(&mut self, row: &mut TableRow, stat: Stats) -> ScreenAction { let mon: SingleMon = match self.mon_data.clone() { - None => {return ScreenAction::None;} - Some(mon) => {mon} + None => { + return ScreenAction::None; + } + Some(mon) => mon, }; - fn get_stat(mon: &SingleMon, stat: Stats) -> Option { match try_gvas_read!(GVAS_FILE) { None => {} Some(gvas_file) => { if let Some(party) = PokemonInfo::new_party(&*gvas_file) { - return party.get_stat(mon.index, stat) + return party.get_stat(mon.index, stat); } } } @@ -107,34 +112,38 @@ impl SingleScreen { row.col(|ui| { // todo!() CACHE ALL THIS ON LOAD, GET, AND SET! THEN AFTER CHANGES, TAKE NEW VALUE! fn create(ui: &mut Ui, mon: &SingleMon, iv: IVs) -> ScreenAction { - let current_iv_guard: Option = { - get_iv(mon, iv.clone()) + let current_iv_guard: Option = { get_iv(mon, iv.clone()) }; + let Some(current_iv) = current_iv_guard else { + return ScreenAction::None; }; - let Some(current_iv) = current_iv_guard else { return ScreenAction::None; }; let mut display: String = current_iv.to_string(); let text_edit: TextEdit = TextEdit::singleline(&mut display); let res: Response = ui.add(text_edit); - - if res.changed() { let mut guard: RwLockWriteGuard = match try_gvas_write!(GVAS_FILE) { - None => {return ScreenAction::None} - Some(g) => {g} + None => return ScreenAction::None, + Some(g) => g, }; - let gvas= &mut *guard; + let gvas = &mut *guard; Logger::info("Res changed"); if let Ok(val) = display.parse::() { if let Some(mut info) = IVMut::new_party(gvas) { match info.set_iv_at(mon.index, iv.clone(), val) { Ok(_) => {} - Err(e) => {Logger::error(e.to_string());} + Err(e) => { + Logger::error(e.to_string()); + } }; let ivs = IV::new_party(&gvas).unwrap(); - Logger::info(format!("Updated iv: {} to: {:?}", iv.clone().as_str(), ivs.get_iv_at(mon.index, iv.clone()).unwrap())); - return ScreenAction::Reload + Logger::info(format!( + "Updated iv: {} to: {:?}", + iv.clone().as_str(), + ivs.get_iv_at(mon.index, iv.clone()).unwrap() + )); + return ScreenAction::Reload; } } } @@ -145,7 +154,9 @@ impl SingleScreen { let act: ScreenAction = create(ui, &mon.clone(), iv.clone()); match act { ScreenAction::None => {} - other => { action = other; } + other => { + action = other; + } } } else { ui.add_enabled(false, TextEdit::singleline(&mut String::new())); @@ -153,20 +164,20 @@ impl SingleScreen { }); row.col(|ui| { fn create(ui: &mut Ui, mon: &SingleMon, stat: Stats) -> ScreenAction { - let current_stat_guard: Option = { - get_stat(mon, stat.clone()) + let current_stat_guard: Option = { get_stat(mon, stat.clone()) }; + let Some(current_stat) = current_stat_guard else { + return ScreenAction::None; }; - let Some(current_stat) = current_stat_guard else { return ScreenAction::None; }; let mut display: String = current_stat.to_string(); let text_edit: TextEdit = TextEdit::singleline(&mut display); let res: Response = ui.add(text_edit); let mut guard: RwLockWriteGuard = match try_gvas_write!(GVAS_FILE) { - None => {return ScreenAction::None} - Some(g) => {g} + None => return ScreenAction::None, + Some(g) => g, }; - let gvas= &mut *guard; + let gvas = &mut *guard; if res.changed() { Logger::info("Res changed"); @@ -175,8 +186,12 @@ impl SingleScreen { info.set_stat(mon.index, stat.clone(), val); let info_read = PokemonInfo::new_party(&gvas).unwrap(); - Logger::info(format!("Updated stat: {} to: {:?}", stat.clone().as_str(), info_read.get_stat(mon.index, stat.clone()).unwrap())); - return ScreenAction::Reload + Logger::info(format!( + "Updated stat: {} to: {:?}", + stat.clone().as_str(), + info_read.get_stat(mon.index, stat.clone()).unwrap() + )); + return ScreenAction::Reload; } } } @@ -186,7 +201,11 @@ impl SingleScreen { match act { ScreenAction::None => {} _ => { - Logger::info(format!("Action for stat {:?}: {:?}", stat.as_str(), act.as_str())); + Logger::info(format!( + "Action for stat {:?}: {:?}", + stat.as_str(), + act.as_str() + )); action = act } } @@ -297,70 +316,90 @@ impl SingleScreen { // todo: refresh after successful save } - } } impl ScreenTrait for SingleScreen { fn load(&mut self, app: &mut App) { Logger::info("Loading SingleScreen"); - Logger::info("Getting gvas"); - let gvas_file = &*unwrap_gvas!(GVAS_FILE); - Logger::info("Got gvas"); + let gvas_file: &GvasFile = &*unwrap_gvas!(GVAS_FILE); - Logger::info("Getting idx"); let idx = match app.selected_mon.clone() { - None => {return} - Some(sel) => {sel.index} + None => { + Logger::info("Failed to get mon.idx"); + return; + } + Some(sel) => sel.index, }; - Logger::info("Getting is_shiny"); let is_shiny = match ShinyList::new_party(gvas_file) { - None => {return} - Some(l) => { - match l.get_shiny_at(idx) { - None => {return} - Some(s) => {s.clone()} + None => return, + Some(l) => match l.get_shiny_at(idx) { + None => { + Logger::info("Failed to get is_shiny"); + return; } - } + Some(s) => s.clone(), + }, }; - Logger::info(is_shiny.clone().to_string()); - Logger::info("Getting name"); let party = match PokemonInfo::new_party(gvas_file) { - None => {return} - Some(c) => { - c + None => { + Logger::info("Failed to get mon name"); + return; } + Some(c) => c, }; let name = match party.get_name(idx) { - None => { return; } - Some(name) => {name} + None => { + return; + } + Some(name) => name, }; - Logger::info("Getting stats"); - let stats: StatStruct = match party.get_stats(idx) { - None => { return; } - Some(s) => { - s + None => { + Logger::info("Failed to get stats"); + return; } + Some(s) => s, }; // todo!() wget ALL mon data, ivs, stats, moves, pp, etc. let iv_wrapper: IV = match IV::new_party(gvas_file) { - None => { return; } - Some(wrapper) => { - wrapper + None => { + Logger::info("Failed to create IV wrapper"); + return; } + Some(wrapper) => wrapper, }; + let ivs: IVSpread = match iv_wrapper.get_ivs_at(idx) { - None => { return; } - Some(ivs) => { - match IV::to_struct(ivs.iter().map(|&v| *v).collect()) { - None => {return;} - Some(s) => {s} + None => { + Logger::info("Failed to get IVs"); + return; + } + Some(ivs) => match IV::to_struct(ivs.iter().map(|&v| *v).collect()) { + None => { + Logger::info("Failed to map IVs to struct"); + return; + } + Some(s) => s, + }, + }; + + let class = match PokemonClasses::new_party(gvas_file) { + None => { + Logger::info("Failed to create Classes wrapper"); + return; + } + Some(party) => { + if let Some(c) = party.class_at(idx.clone()) { + c.clone() + } else { + Logger::info(format!("Failed to get class at index: {}", idx.clone())); + return; } } }; @@ -368,13 +407,17 @@ impl ScreenTrait for SingleScreen { self.mon_data = Some(SingleMon { index: idx, storage_type: StorageType::PARTY, + class: class.clone(), is_shiny, name: name.clone(), stats, - ivs + ivs, }); self.loaded = true; - Logger::info(format!("Loaded info in SingleScreen for: {}", name)); + Logger::info(format!( + "Loaded info in SingleScreen for: {:?}", + parse_class(class.as_str()) + )); } fn ui(&mut self, ui: &mut Ui, app: &mut App) -> ScreenAction { @@ -382,60 +425,102 @@ impl ScreenTrait for SingleScreen { self.load(app); } if let Some(data) = &self.mon_data { - let action = ui.horizontal(|ui| { - ui.add(render_image_container(&ImageContainer::new_party(data.name.clone(), data.is_shiny.clone(), data.index.clone()))); - fn flip_shiny(mut guard: RwLockWriteGuard, data: &SingleMon) -> ScreenAction { + let shiny = ui.horizontal(|ui| { + let parsed_class = parse_class(data.class.clone().as_str()).unwrap(); + let shiny_text = if data.is_shiny { "shiny" } else { "normal" }; + + let path = format!("{}/{}.png", shiny_text, correct_name(parsed_class)); + if let Some(tex) = app.image_cache.get(ui.ctx(), path.as_str()) { + let image: Image = render_texture(tex); + ui.add(image); + } else { + Logger::info(format!("No such image: {}", path.as_str())); + } + + fn flip_shiny( + mut guard: RwLockWriteGuard, + data: &SingleMon, + ) -> ScreenAction { let gvas = &mut *guard; if let Some(mut list) = ShinyListMut::new_party(gvas) { match list.set_shiny_at(data.index, !data.is_shiny) { Ok(_) => { - Logger::info(format!("Shiny toggle success!")); + Logger::info("Shiny toggle success!".to_string()); return ScreenAction::Reload; } - Err(e) => {Logger::info(format!("Failed to set shiny at: {}", e));} + Err(e) => { + Logger::info(format!("Failed to set shiny at: {}", e)); + } }; } ScreenAction::None } if data.is_shiny { - let res: Response = ui.add(Image::new(format!("{}/shiny.png", get_images_path())) - .corner_radius(5) - .bg_fill(Color32::from_rgb(50, 50, 50)) - .fit_to_exact_size(Vec2::new(16.0, 16.0)) - .sense(Sense::click())); + let res: Response = ui.add( + Image::new(format!("{}shiny.png", get_images_path())) + .corner_radius(5) + .bg_fill(Color32::from_rgb(50, 50, 50)) + .fit_to_exact_size(Vec2::new(16.0, 16.0)) + .sense(Sense::click()), + ); if res.clicked() { let mut guard = match try_gvas_write!(GVAS_FILE) { - None => {return ScreenAction::None;} - Some(g) => {g} + None => { + return ScreenAction::None; + } + Some(g) => g, }; return flip_shiny(guard, data); } } else { - let res: Response = ui.add(Image::new(format!("{}/non_shiny.png", get_images_path())) - .corner_radius(5) - .bg_fill(Color32::from_rgb(0, 0, 0)) - .fit_to_exact_size(Vec2::new(16.0, 16.0)) - .sense(Sense::click())); + let res: Response = ui.add( + Image::new(format!("{}non_shiny.png", get_images_path())) + .corner_radius(5) + .bg_fill(Color32::from_rgb(0, 0, 0)) + .fit_to_exact_size(Vec2::new(16.0, 16.0)) + .sense(Sense::click()), + ); if res.clicked() { - Logger::info(format!("Shiny toggle clicked!")); + Logger::info("Shiny toggle clicked!".to_string()); let guard = match try_gvas_write!(GVAS_FILE) { - None => {return ScreenAction::None;} - Some(g) => {g} + None => { + return ScreenAction::None; + } + Some(g) => g, }; return flip_shiny(guard, data); } } ScreenAction::None }); - if let ScreenAction::Reload = action.inner { + if let ScreenAction::Reload = shiny.inner { self.loaded = false; return ScreenAction::Reload; } + ui.label("Nickname"); + let mut display: String = data.name.clone(); + let res: Response = ui.add(TextEdit::singleline(&mut display).desired_width(200.0)); + if res.changed() { + let mut guard = match try_gvas_write!(GVAS_FILE) { + None => { + return ScreenAction::None; + } + Some(g) => g, + }; + match PokemonInfoMut::new_party(&mut *guard) { + None => { + return ScreenAction::None; + } + Some(mut party) => { + party.set_name(data.index.clone(), display); + return ScreenAction::Reload; + } + }; + } } - if let Some(action) = self.iv_table(ui) { return action; } @@ -448,4 +533,4 @@ impl Reload for SingleScreen { self.loaded = false; self.load(app); } -} \ No newline at end of file +} diff --git a/src/utils/custom_struct.rs b/src/utils/custom_struct.rs index dab770c..63b793e 100644 --- a/src/utils/custom_struct.rs +++ b/src/utils/custom_struct.rs @@ -1,6 +1,6 @@ use gvas::properties::array_property::ArrayProperty; -use gvas::properties::Property; use gvas::properties::struct_property::{StructProperty, StructPropertyValue}; +use gvas::properties::Property; use indexmap::IndexMap; pub type CustomStruct<'a> = (&'a String, &'a IndexMap>); @@ -17,61 +17,61 @@ pub type CustomStruct<'a> = (&'a String, &'a IndexMap>); fn get_starts_with<'a>(value: &'a StructProperty, string: &str) -> Option<&'a Vec> { match &value.value { StructPropertyValue::CustomStruct { properties, .. } => { - for (k,v) in properties.0.iter() { + for (k, v) in properties.0.iter() { if k.starts_with(string) { - return Some(v) + return Some(v); } } None } - _ => None + _ => None, } } -fn get_starts_with_mut<'a>(value: &'a mut StructProperty, string: &str) -> Option<&'a mut Vec> { +fn get_starts_with_mut<'a>( + value: &'a mut StructProperty, + string: &str, +) -> Option<&'a mut Vec> { match &mut value.value { - StructPropertyValue::CustomStruct { ref mut properties, .. } => { - for (k,v) in properties.0.iter_mut() { + StructPropertyValue::CustomStruct { + ref mut properties, .. + } => { + for (k, v) in properties.0.iter_mut() { if k.starts_with(string) { - return Some(v) + return Some(v); } } None } - _ => None + _ => None, } } pub fn get_struct_property_at_idx(property: &Property, idx: usize) -> Option<&StructProperty> { let array = match property { - Property::ArrayProperty(prop) => { - prop - } - _ => return None + Property::ArrayProperty(prop) => prop, + _ => return None, }; match array { - ArrayProperty::Structs { structs, .. } => { - structs.get(idx) - } - _ => None + ArrayProperty::Structs { structs, .. } => structs.get(idx), + _ => None, } } // TODO: test this -pub fn get_struct_property_at_idx_mut(property: &mut Property, idx: usize) -> Option<&mut StructProperty> { +pub fn get_struct_property_at_idx_mut( + property: &mut Property, + idx: usize, +) -> Option<&mut StructProperty> { let array = match property { - Property::ArrayProperty(prop) => { - prop - } - _ => return None + Property::ArrayProperty(prop) => prop, + _ => return None, }; match array { - ArrayProperty::Structs { structs, .. } => { - structs.get_mut(idx) - } - _ => None + ArrayProperty::Structs { structs, .. } => structs.get_mut(idx), + _ => None, } } @@ -81,16 +81,14 @@ pub fn get_struct_at_idx(property: &Property, idx: usize) -> Option<&Property> { pub fn get_struct_at_idx_mut(property: &mut Property, idx: usize) -> Option<&mut StructProperty> { let array = match property { - Property::ArrayProperty(ref mut prop) => { - prop - } - _ => return None + Property::ArrayProperty(ref mut prop) => prop, + _ => return None, }; match array { - ArrayProperty::Structs { ref mut structs, .. } => { - structs.get_mut(idx) - } - _ => None + ArrayProperty::Structs { + ref mut structs, .. + } => structs.get_mut(idx), + _ => None, } -} \ No newline at end of file +} diff --git a/src/utils/generator.rs b/src/utils/generator.rs new file mode 100644 index 0000000..0fa7fba --- /dev/null +++ b/src/utils/generator.rs @@ -0,0 +1,124 @@ +use crate::logger::Logger; +use crate::pkmn::Move; +use std::io::Error; + +#[cfg(target_os = "windows")] +pub const GENERATOR_BIN: &[u8] = include_bytes!("../../bin/generator.exe"); + +#[derive(Default)] +pub struct Generator { + pub version: Option, + pub species: Option, + pub nickname: Option, + pub trainer_name: Option, + pub level: Option, + pub ball: Option, + pub gender: Option, + pub nature: Option, + pub shiny: Option, + pub moves: Option>, + pub form: Option, + pub ivs: Option>, + pub evs: Option>, +} + +impl Generator { + pub fn new() -> Generator { + Self::default() + } + + /// Create a string of args + fn args(&self) -> String { + let mut args: Vec = Vec::new(); + + if let Some(v) = &self.version { + args.push(format!("--version {}", v)); + } + if let Some(s) = self.species { + args.push(format!("--species {}", s)); + } + if let Some(n) = &self.nickname { + args.push(format!("--nickname {}", n)); + } + if let Some(t) = &self.trainer_name { + args.push(format!("--trainer-name {}", t)); + } + if let Some(l) = self.level { + args.push(format!("--level {}", l)); + } + if let Some(b) = self.ball { + args.push(format!("--ball {}", b)); + } + if let Some(g) = self.gender { + args.push(format!("--gender {}", g)); + } + if let Some(n) = &self.nature { + args.push(format!("--nature {}", n)); + } + if let Some(s) = &self.shiny { + args.push(format!("--shiny {}", s)); + } + if let Some(f) = self.form { + args.push(format!("--form {}", f)); + } + if let Some(ivs) = &self.ivs { + args.push(format!( + "--ivs {}", + ivs.iter() + .map(|v| v.to_string()) + .collect::>() + .join(",") + )); + } + if let Some(evs) = &self.evs { + args.push(format!( + "--evs {}", + evs.iter() + .map(|v| v.to_string()) + .collect::>() + .join(",") + )); + } + if let Some(moves) = &self.moves { + for (i, m) in moves.iter().enumerate() { + args.push(format!("--move{} {}", i + 1, m.name)); + } + } + + args.join(" ") + } + + pub fn run(self) { + match run_generator(self) { + Ok(_) => { + Logger::info("Generator complete."); + } + Err(e) => { + Logger::error(e.to_string()); + } + }; + } +} + +#[cfg(target_os = "windows")] +fn run_generator(_settings: Generator) -> std::io::Result<()> { + use std::{env, fs, process::Command}; + + let path = env::temp_dir().join("generator.exe"); + fs::write(&path, GENERATOR_BIN)?; + + Command::new(&path).arg("--example").spawn()?; + + Ok(()) +} + +#[cfg(not(target_os = "windows"))] +fn run_generator(_settings: Generator) -> std::io::Result<()> { + let msg = format!( + "Generator not available on this platform: {}", + std::env::consts::OS.to_string() + ); + + Logger::info(msg.clone()); + Ok(()) +} diff --git a/src/utils/mod.rs b/src/utils/mod.rs index 95e8ff3..269f5a6 100644 --- a/src/utils/mod.rs +++ b/src/utils/mod.rs @@ -1,19 +1,23 @@ -use std::cell::OnceCell; -use std::sync::{Arc, RwLock}; -use egui::{Context, Id}; use egui::util::id_type_map::SerializableAny; +use egui::{Context, Id}; use gvas::GvasFile; +use std::cell::OnceCell; +use std::sync::{Arc, RwLock}; pub mod custom_struct; +pub mod generator; pub fn get_data_persisted(context: &Context, key: String) -> Option where - T: SerializableAny + Clone + Send + Sync + 'static { + T: SerializableAny + Clone + Send + Sync + 'static, +{ context.data_mut(|map| map.get_persisted(Id::new(key))) } pub fn set_data_persisted(context: &Context, key: String, data: T) -> () -where T: SerializableAny + Clone { +where + T: SerializableAny + Clone, +{ context.data_mut(|map| { let persisted = map.get_persisted_mut_or(Id::new(key), data.clone()); *persisted = data; diff --git a/tests/common.rs b/tests/common.rs index 2a63fa9..3b6b082 100644 --- a/tests/common.rs +++ b/tests/common.rs @@ -1,10 +1,12 @@ -use std::fs::File; -use std::sync::{Arc, RwLock}; use gvas::game_version::GameVersion; -use gvas::GvasFile; -use gvas::properties::int_property::{BoolProperty, ByteProperty, BytePropertyValue, DoubleProperty}; +use gvas::properties::int_property::{ + BoolProperty, ByteProperty, BytePropertyValue, DoubleProperty, +}; use gvas::properties::Property; +use gvas::GvasFile; use ordered_float::OrderedFloat; +use std::fs::File; +use std::sync::{Arc, RwLock}; pub fn get_gvas<'a>() -> GvasFile { let mut file = File::open("Slot1.sav").expect("save file not found"); @@ -20,7 +22,6 @@ pub fn get_gvas_mut<'a>() -> GvasFile { gvas.clone() } - fn make_bool_property(value: bool) -> Property { Property::BoolProperty(BoolProperty { value }) } @@ -36,4 +37,4 @@ fn make_namespaced_property(value: &str) -> Property { name: None, value: BytePropertyValue::Namespaced(value.to_string()), }) -} \ No newline at end of file +} diff --git a/tests/main.rs b/tests/main.rs index aae87c4..f801f25 100644 --- a/tests/main.rs +++ b/tests/main.rs @@ -1 +1 @@ -mod pokemon; \ No newline at end of file +mod pokemon; diff --git a/tests/pokemon/attack_lists.rs b/tests/pokemon/attack_lists.rs index 3e7e1ac..682ce04 100644 --- a/tests/pokemon/attack_lists.rs +++ b/tests/pokemon/attack_lists.rs @@ -1,7 +1,7 @@ -use gvas::GvasFile; -use gvas::properties::Property; -use gammaeditor::save::pokemon::attack_lists::{attack_array, attack_at, attacks_at, parse_attack}; use crate::pokemon::common::get_gvas; +use gammaeditor::save::pokemon::attack_lists::{attack_array, attack_at, attacks_at, parse_attack}; +use gvas::properties::Property; +use gvas::GvasFile; #[test] fn attack_at_gets_class_string() { @@ -17,7 +17,9 @@ fn attack_at_gets_class_string() { #[test] fn parse_attack_parses() { - let actual = parse_attack("/Game/BPS/ABILITIES/BuffSkills/GHOST/Astonish/BP_Astonish.BP_Astonish_C").expect("parsed"); + let actual = + parse_attack("/Game/BPS/ABILITIES/BuffSkills/GHOST/Astonish/BP_Astonish.BP_Astonish_C") + .expect("parsed"); let expected = "Astonish"; assert_eq!(actual, expected); @@ -29,9 +31,9 @@ fn get_attack_gets() { let prop: &Property = gvas.properties.get("PartyAttackLists").expect("get prop"); let array = attack_array(prop).expect("get array"); let attacks = attacks_at(array, 0).expect("get attacks at"); - + let actual = attack_at(attacks, 0).expect("get attack at"); let expected = "/Game/BPS/ABILITIES/BuffSkills/GHOST/Astonish/BP_Astonish.BP_Astonish_C"; assert_eq!(actual, expected); -} \ No newline at end of file +} diff --git a/tests/pokemon/gender.rs b/tests/pokemon/gender.rs index dd58547..1bc57be 100644 --- a/tests/pokemon/gender.rs +++ b/tests/pokemon/gender.rs @@ -1,5 +1,5 @@ -use gammaeditor::save::pokemon::gender::gender_string_at; use crate::pokemon::common::get_gvas; +use gammaeditor::save::pokemon::gender::gender_string_at; #[test] pub fn gender_string_at_returns_class_string() { @@ -11,4 +11,4 @@ pub fn gender_string_at_returns_class_string() { let expected = "ENUM_Gender::NewEnumerator0"; assert_eq!(gender_at, expected) -} \ No newline at end of file +} diff --git a/tests/pokemon/iv_struct.rs b/tests/pokemon/iv_struct.rs index a256b34..eb85bd3 100644 --- a/tests/pokemon/iv_struct.rs +++ b/tests/pokemon/iv_struct.rs @@ -1,7 +1,7 @@ +use crate::pokemon::common::{get_gvas, get_gvas_mut}; use gammaeditor::pkmn::stats::IVs; use gammaeditor::save::pokemon::iv_struct::{get_ivs, IVMut, IV}; use gammaeditor::utils::custom_struct::get_struct_property_at_idx; -use crate::pokemon::common::{get_gvas, get_gvas_mut}; #[test] fn get_ivs_returns_correctly() { @@ -10,7 +10,7 @@ fn get_ivs_returns_correctly() { let iv_struct = get_struct_property_at_idx(prop, 0).expect("get struct at"); let ivs = get_ivs(iv_struct).expect("get ivs"); - let expected = vec!(&1000, &1000, &1000, &1000, &1000, &1000); + let expected = vec![&1000, &1000, &1000, &1000, &1000, &1000]; assert_eq!(ivs, expected); } @@ -22,7 +22,7 @@ fn get_ivs_fails_correctly() { let iv_struct = get_struct_property_at_idx(prop, 0).expect("get struct at"); let ivs = get_ivs(iv_struct).expect("get ivs"); - let not_expected = vec!(&1000, &1000, &1000, &1000, &1000, &999); + let not_expected = vec![&1000, &1000, &1000, &1000, &1000, &999]; assert_ne!(ivs, not_expected); } @@ -33,9 +33,8 @@ fn set_ivs_returns_correctly() { let mut ivs = IVMut::new_party(&mut gvas).expect("get ivmut"); let res = ivs.set_iv_at(0, IVs::SDEF, 32).expect("set iv"); - let ivs_read = IV::new_party(&gvas).expect("get party"); let iv = ivs_read.get_iv_at(0, IVs::SDEF).expect("get iv"); assert_eq!(*iv, 32) -} \ No newline at end of file +} diff --git a/tests/pokemon/mod.rs b/tests/pokemon/mod.rs index 3ee03b6..e3e73b1 100644 --- a/tests/pokemon/mod.rs +++ b/tests/pokemon/mod.rs @@ -1,11 +1,11 @@ #[path = "../common.rs"] pub(crate) mod common; -pub mod pokemon_id; +mod attack_lists; +mod gender; +mod iv_struct; pub mod pokemon_classes; +pub mod pokemon_id; mod pokemon_info; -mod attack_lists; mod pp_moves_lists; mod shiny_list; -mod iv_struct; -mod gender; \ No newline at end of file diff --git a/tests/pokemon/pokemon_classes.rs b/tests/pokemon/pokemon_classes.rs index 069a593..aed12e0 100644 --- a/tests/pokemon/pokemon_classes.rs +++ b/tests/pokemon/pokemon_classes.rs @@ -1,5 +1,5 @@ -use gammaeditor::save::pokemon::pokemon_classes::{class_at}; use crate::pokemon::pokemon_classes::common::get_gvas; +use gammaeditor::save::pokemon::pokemon_classes::class_at; #[path = "../common.rs"] pub(crate) mod common; @@ -21,4 +21,4 @@ fn test_class_at_out_of_bounds() { let array = prop.get_array().expect("get array"); let val = class_at(&array, 99); assert!(val.is_none()); -} \ No newline at end of file +} diff --git a/tests/pokemon/pokemon_id.rs b/tests/pokemon/pokemon_id.rs index fdec7cb..86d0e33 100644 --- a/tests/pokemon/pokemon_id.rs +++ b/tests/pokemon/pokemon_id.rs @@ -1,16 +1,16 @@ #[path = "../common.rs"] mod common; -use gvas::properties::array_property::ArrayProperty; -use gammaeditor::save::pokemon::pokemon_id::{id_array, id_at, PokemonID}; use crate::pokemon::pokemon_id::common::get_gvas; +use gammaeditor::save::pokemon::pokemon_id::{id_array, id_at, PokemonID}; +use gvas::properties::array_property::ArrayProperty; #[test] fn id_array_gets_array() { let gvas = get_gvas(); let prop = gvas.properties.get("PartyPokemonID").expect("get prop"); let array: &ArrayProperty = id_array(&prop).expect("array unwrapped"); - if let ArrayProperty::Ints { ints, ..} = &array { + if let ArrayProperty::Ints { ints, .. } = &array { let actual = vec![981811, 486465, 220984]; let expected = ints.clone(); @@ -23,7 +23,7 @@ fn id_array_fails_properly() { let gvas = get_gvas(); let prop = gvas.properties.get("PartyPokemonID").expect("get prop"); let array: &ArrayProperty = id_array(&prop).expect("array unwrapped"); - if let ArrayProperty::Ints { ints, ..} = &array { + if let ArrayProperty::Ints { ints, .. } = &array { // add +1 to each let actual = vec![981812, 486466, 220985]; let expected = ints.clone(); @@ -41,4 +41,4 @@ fn id_at_gets_id() { assert_eq!(id, 220984); () -} \ No newline at end of file +} diff --git a/tests/pokemon/pokemon_info.rs b/tests/pokemon/pokemon_info.rs index 99d3e3e..c4f1885 100644 --- a/tests/pokemon/pokemon_info.rs +++ b/tests/pokemon/pokemon_info.rs @@ -1,28 +1,34 @@ -use gvas::GvasFile; -use gvas::properties::int_property::{BoolProperty, ByteProperty, BytePropertyValue, DoubleProperty}; -use gvas::properties::Property; -use gvas::properties::struct_property::{StructProperty, StructPropertyValue}; -use ordered_float::OrderedFloat; +use crate::pokemon::common::get_gvas_mut; +use crate::pokemon::pokemon_classes::common::get_gvas; use gammaeditor::pkmn; use gammaeditor::pkmn::stats::Stats; use gammaeditor::property::traits::StartsWith; use gammaeditor::save::pokemon::pokemon_info; use gammaeditor::save::pokemon::pokemon_info::{PokemonInfo, PokemonInfoMut}; use gammaeditor::utils::custom_struct::get_struct_property_at_idx; -use crate::pokemon::common::get_gvas_mut; -use crate::pokemon::pokemon_classes::common::get_gvas; +use gvas::properties::int_property::{ + BoolProperty, ByteProperty, BytePropertyValue, DoubleProperty, +}; +use gvas::properties::struct_property::{StructProperty, StructPropertyValue}; +use gvas::properties::Property; +use gvas::GvasFile; +use ordered_float::OrderedFloat; #[test] fn get_sturct_at_idx_gets() { let gvas = get_gvas(); - let prop = gvas.properties.get("PartyPokemonInfo").expect("unwrap prop"); + let prop = gvas + .properties + .get("PartyPokemonInfo") + .expect("unwrap prop"); let cs = get_struct_property_at_idx(prop, 0).expect("unwrap struct"); let is_fainted = cs.get_starts_with("isFainted").expect("get isfainted"); let first = is_fainted.first().expect("get first"); let val = match first { Property::BoolProperty(bool) => Some(bool.value), - _ => None - }.expect("unwrap bool"); + _ => None, + } + .expect("unwrap bool"); println!("{}", serde_json::to_string_pretty(&val).expect("unwrapp")); assert_eq!(val, false) @@ -31,7 +37,10 @@ fn get_sturct_at_idx_gets() { #[test] fn get_struct_at_idx_gets() { let gvas = get_gvas(); - let prop = gvas.properties.get("PartyPokemonInfo").expect("unwrap prop"); + let prop = gvas + .properties + .get("PartyPokemonInfo") + .expect("unwrap prop"); let cs = get_struct_property_at_idx(prop, 0).expect("unwrap struct"); let expected = r#" { @@ -137,7 +146,6 @@ fn get_struct_at_idx_gets() { assert_eq!(actual.trim(), expected.trim()) } - #[test] fn get_stat() { let gvas = get_gvas(); @@ -232,7 +240,6 @@ fn get_secondary_type() { assert_eq!(secondary, expected) } - #[test] fn get_nature_string() { let gvas = get_gvas(); @@ -283,4 +290,22 @@ fn set_stat() { let party_reader = PokemonInfo::new_party(&gvas).unwrap(); let stat = party_reader.get_stat(0, Stats::ATK).expect("get stat"); assert_eq!(100.0, stat); -} \ No newline at end of file +} + +#[test] +fn set_name() { + let mut gvas = get_gvas_mut(); + { + let party_reader = PokemonInfo::new_party(&gvas).unwrap(); + let first_name = party_reader.get_name(0).expect("get stat"); + println!("{:?}", first_name); + assert_ne!("thisshoudlntbearandomname", first_name); + } + + let mut party = PokemonInfoMut::new_party(&mut gvas).unwrap(); + party.set_name(0, "foo".to_string()); + let party_reader = PokemonInfo::new_party(&gvas).unwrap(); + let name = party_reader.get_name(0).expect("get name"); + + assert_eq!("foo", name); +} diff --git a/tests/pokemon/pp_moves_lists.rs b/tests/pokemon/pp_moves_lists.rs index 2a0e6dd..964b11a 100644 --- a/tests/pokemon/pp_moves_lists.rs +++ b/tests/pokemon/pp_moves_lists.rs @@ -1,8 +1,8 @@ -use gvas::GvasFile; +use crate::pokemon::common::get_gvas; +use gammaeditor::save::pokemon::pp_moves_lists::{current_pp_at, max_pp_at, moves_array, moves_at}; use gvas::properties::array_property::ArrayProperty; use gvas::properties::Property; -use gammaeditor::save::pokemon::pp_moves_lists::{current_pp_at, max_pp_at, moves_array, moves_at}; -use crate::pokemon::common::get_gvas; +use gvas::GvasFile; #[test] fn moves_at_returns_moves() { @@ -113,7 +113,7 @@ fn max_pp_at_returns() { let moves_at = moves_at(moves, 0).expect("get moves at"); let max_pp = max_pp_at(moves_at, 0).expect("hi").clone(); - assert_eq!(max_pp ,15) + assert_eq!(max_pp, 15) } #[test] @@ -125,4 +125,4 @@ fn current_pp_returns() { let current_pp = current_pp_at(moves_at, 1).expect("hi").clone(); assert_eq!(current_pp, 19) -} \ No newline at end of file +} diff --git a/tests/pokemon/shiny_list.rs b/tests/pokemon/shiny_list.rs index 8347cd3..27780c2 100644 --- a/tests/pokemon/shiny_list.rs +++ b/tests/pokemon/shiny_list.rs @@ -1,10 +1,13 @@ -use gammaeditor::save::pokemon::shiny_list::{get_shiny_at, get_shiny_list}; use crate::pokemon::common::get_gvas; +use gammaeditor::save::pokemon::shiny_list::{get_shiny_at, get_shiny_list}; #[test] fn get_shiny_list_gets_shinies() { let gvas = get_gvas(); - let prop = gvas.properties.get("PartyShinyList").expect("party shiny list"); + let prop = gvas + .properties + .get("PartyShinyList") + .expect("party shiny list"); let arr = prop.get_array().expect("get array"); let shinies = get_shiny_list(&arr).expect("get shiny list"); @@ -18,7 +21,10 @@ fn get_shiny_list_gets_shinies() { #[test] fn get_shiny_gets_shiny() { let gvas = get_gvas(); - let prop = gvas.properties.get("PartyShinyList").expect("party shiny list"); + let prop = gvas + .properties + .get("PartyShinyList") + .expect("party shiny list"); let arr = prop.get_array().expect("get array"); @@ -26,4 +32,4 @@ fn get_shiny_gets_shiny() { let expected = true; assert_eq!(*actual, expected) -} \ No newline at end of file +} diff --git a/tests/property.rs b/tests/property.rs index 2c08b82..98f4c56 100644 --- a/tests/property.rs +++ b/tests/property.rs @@ -1,3 +1,4 @@ +use gammaeditor::property::traits::PropertyPath; use gvas::game_version::GameVersion; use gvas::properties::array_property::ArrayProperty; use gvas::properties::int_property::BytePropertyValue; @@ -5,7 +6,6 @@ use gvas::properties::struct_property::{StructProperty, StructPropertyValue}; use gvas::properties::Property; use gvas::GvasFile; use std::fs::File; -use gammaeditor::property::traits::PropertyPath; #[test] fn test_get_starts_with_gets_level() { @@ -13,7 +13,8 @@ fn test_get_starts_with_gets_level() { let mut f = File::open("Slot1.sav").expect("open sav"); let gvas = GvasFile::read(&mut f, GameVersion::Default).expect("read gvas"); - let party = gvas.properties + let party = gvas + .properties .get("PartyPokemonInfo") .expect("PartyPokemonInfo present"); @@ -50,7 +51,8 @@ fn get_vec() -> Option> { let mut f = File::open("Slot1.sav").expect("open sav"); let gvas = GvasFile::read(&mut f, GameVersion::Default).expect("read gvas"); - let party = gvas.properties + let party = gvas + .properties .get("PartyPokemonInfo") .expect("PartyPokemonInfo present"); @@ -60,9 +62,7 @@ fn get_vec() -> Option> { }; match arr { - ArrayProperty::Structs { structs, .. } => { - Some(structs.clone()) - } + ArrayProperty::Structs { structs, .. } => Some(structs.clone()), _ => panic!("ArrayProperty but not Structs"), } } @@ -85,7 +85,6 @@ fn test_get_starts_with_gets_is_fainted() { } } } - } _ => { println!("not a struct"); @@ -128,7 +127,12 @@ fn test_get_starts_with_gets_primary_type() { match satk { Property::ByteProperty(inner) => { println!("{:?}", inner.value); - assert_eq!(inner.value, BytePropertyValue::Namespaced("ENUM_PokemonTypePrimary::NewEnumerator8".to_string())); + assert_eq!( + inner.value, + BytePropertyValue::Namespaced( + "ENUM_PokemonTypePrimary::NewEnumerator8".to_string() + ) + ); } _ => { panic!("expected DoubleProperty"); @@ -140,4 +144,4 @@ fn test_get_starts_with_gets_primary_type() { println!("not a struct"); } } -} \ No newline at end of file +}