diff --git a/Cargo.lock b/Cargo.lock index 6a904f6..74b0dbe 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -31,9 +31,11 @@ dependencies = [ [[package]] name = "anime-game-core" -version = "0.5.1" +version = "0.5.2" dependencies = [ + "anyhow", "bzip2", + "cached", "curl", "flate2", "fs_extra", @@ -44,7 +46,6 @@ dependencies = [ "serde_json", "sysinfo", "tar", - "uuid", "xz", "zip", ] @@ -54,6 +55,7 @@ name = "anime-game-launcher" version = "1.0.3" dependencies = [ "anime-game-core", + "anyhow", "dirs", "gtk4", "lazy_static", @@ -70,6 +72,23 @@ version = "1.0.58" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bb07d2053ccdbe10e2af2995a2f116c1330396493dc1269f6a91d0ae82e19704" +[[package]] +name = "async-trait" +version = "0.1.57" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "76464446b8bc32758d7e88ee1a804d9914cd9b1cb264c029899680b0be29826f" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "async_once" +version = "0.2.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2ce4f10ea3abcd6617873bae9f91d1c5332b4a778bd9ce34d0cd517474c1de82" + [[package]] name = "autocfg" version = "1.1.0" @@ -136,6 +155,43 @@ dependencies = [ "pkg-config", ] +[[package]] +name = "cached" +version = "0.38.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "27e6092f8c7ba6e65a46f6f26d7d7997201d3a6f0e69ff5d2440b930d7c0513a" +dependencies = [ + "async-trait", + "async_once", + "cached_proc_macro", + "cached_proc_macro_types", + "futures", + "hashbrown", + "instant", + "lazy_static", + "once_cell", + "thiserror", + "tokio", +] + +[[package]] +name = "cached_proc_macro" +version = "0.15.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "751f7f4e7a091545e7f6c65bacc404eaee7e87bfb1f9ece234a1caa173dc16f2" +dependencies = [ + "cached_proc_macro_types", + "darling", + "quote", + "syn", +] + +[[package]] +name = "cached_proc_macro_types" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3a4f925191b4367301851c6d99b09890311d74b0d43f274c0b34c86d308a3663" + [[package]] name = "cairo-rs" version = "0.15.12" @@ -309,6 +365,41 @@ dependencies = [ "winapi", ] +[[package]] +name = "darling" +version = "0.13.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a01d95850c592940db9b8194bc39f4bc0e89dee5c4265e4b1807c34a9aba453c" +dependencies = [ + "darling_core", + "darling_macro", +] + +[[package]] +name = "darling_core" +version = "0.13.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "859d65a907b6852c9361e3185c862aae7fafd2887876799fa55f5f99dc40d610" +dependencies = [ + "fnv", + "ident_case", + "proc-macro2", + "quote", + "strsim", + "syn", +] + +[[package]] +name = "darling_macro" +version = "0.13.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c972679f83bdf9c42bd905396b6c3588a843a17f0f16dfcfa3e2c5d57441835" +dependencies = [ + "darling_core", + "quote", + "syn", +] + [[package]] name = "digest" version = "0.10.3" @@ -378,6 +469,12 @@ dependencies = [ "miniz_oxide", ] +[[package]] +name = "fnv" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" + [[package]] name = "fs_extra" version = "1.2.0" @@ -385,19 +482,34 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2022715d62ab30faffd124d40b76f4134a550a87792276512b18d63272333394" [[package]] -name = "futures-channel" -version = "0.3.21" +name = "futures" +version = "0.3.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3083ce4b914124575708913bca19bfe887522d6e2e6d0952943f5eac4a74010" +checksum = "7f21eda599937fba36daeb58a22e8f5cee2d14c4a17b5b7739c7c8e5e3b8230c" +dependencies = [ + "futures-channel", + "futures-core", + "futures-io", + "futures-sink", + "futures-task", + "futures-util", +] + +[[package]] +name = "futures-channel" +version = "0.3.24" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "30bdd20c28fadd505d0fd6712cdfcb0d4b5648baf45faef7f852afb2399bb050" dependencies = [ "futures-core", + "futures-sink", ] [[package]] name = "futures-core" -version = "0.3.21" +version = "0.3.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c09fd04b7e4073ac7156a9539b57a484a8ea920f79c7c675d05d289ab6110d3" +checksum = "4e5aa3de05362c3fb88de6531e6296e85cde7739cccad4b9dfeeb7f6ebce56bf" [[package]] name = "futures-executor" @@ -412,23 +524,30 @@ dependencies = [ [[package]] name = "futures-io" -version = "0.3.21" +version = "0.3.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fc4045962a5a5e935ee2fdedaa4e08284547402885ab326734432bed5d12966b" +checksum = "bbf4d2a7a308fd4578637c0b17c7e1c7ba127b8f6ba00b29f717e9655d85eb68" + +[[package]] +name = "futures-sink" +version = "0.3.24" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "21b20ba5a92e727ba30e72834706623d94ac93a725410b6a6b6fbc1b07f7ba56" [[package]] name = "futures-task" -version = "0.3.21" +version = "0.3.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "57c66a976bf5909d801bbef33416c41372779507e7a6b3a5e25e4749c58f776a" +checksum = "a6508c467c73851293f390476d4491cf4d227dbabcd4170f3bb6044959b294f1" [[package]] name = "futures-util" -version = "0.3.21" +version = "0.3.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d8b7abd5d659d9b90c8cba917f6ec750a74e2dc23902ef9cd4cc8c8b22e6036a" +checksum = "44fb6cb1be61cc1d2e43b262516aafcf63b241cffdb1d3fa115f91d9c7b09c90" dependencies = [ "futures-core", + "futures-sink", "futures-task", "pin-project-lite", "pin-utils", @@ -713,6 +832,12 @@ dependencies = [ "system-deps", ] +[[package]] +name = "hashbrown" +version = "0.12.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" + [[package]] name = "heck" version = "0.4.0" @@ -737,6 +862,21 @@ dependencies = [ "digest", ] +[[package]] +name = "ident_case" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" + +[[package]] +name = "instant" +version = "0.1.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a5bbe824c507c5da5956355e86a746d82e0e1464f65d862cc5e71da70e94b2c" +dependencies = [ + "cfg-if", +] + [[package]] name = "itoa" version = "1.0.2" @@ -1028,12 +1168,6 @@ version = "0.3.25" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1df8c4ec4b0627e53bdf214615ad287367e482558cf84b109250b37464dc03ae" -[[package]] -name = "ppv-lite86" -version = "0.2.16" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eb9f9e6e233e5c4a35559a617bf40a4ec447db2e84c20b55a6f83167b7e57872" - [[package]] name = "proc-macro-crate" version = "1.1.3" @@ -1095,35 +1229,11 @@ dependencies = [ "proc-macro2", ] -[[package]] -name = "rand" -version = "0.8.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" -dependencies = [ - "libc", - "rand_chacha", - "rand_core", -] - -[[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", -] - [[package]] name = "rand_core" version = "0.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d34f1408f55294453790c48b2f1ebbb1c5b4b7563eb1f418bcfcfdbb06ebb4e7" -dependencies = [ - "getrandom", -] [[package]] name = "rayon" @@ -1377,6 +1487,12 @@ version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6e63cff320ae2c57904679ba7cb63280a3dc4613885beafb148ee7bf9aa9042d" +[[package]] +name = "strsim" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" + [[package]] name = "subtle" version = "2.4.1" @@ -1396,9 +1512,9 @@ dependencies = [ [[package]] name = "sysinfo" -version = "0.25.1" +version = "0.26.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "373e4bc9213f734126e2be3e2e118dbc9b909c37487d8d755822bc90f70ae62a" +checksum = "621609553b14bca49448b3c97e625d7187980cc2a42fd169b4c3b306dcc4a7e9" dependencies = [ "cfg-if", "core-foundation-sys", @@ -1471,6 +1587,30 @@ version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "42657b1a6f4d817cda8e7a0ace261fe0cc946cf3a80314390b22cc61ae080792" +[[package]] +name = "tokio" +version = "1.20.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a8325f63a7d4774dd041e363b2409ed1c5cbbd0f867795e661df066b2b0a581" +dependencies = [ + "autocfg", + "num_cpus", + "once_cell", + "pin-project-lite", + "tokio-macros", +] + +[[package]] +name = "tokio-macros" +version = "1.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9724f9a975fb987ef7a3cd9be0350edcbe130698af5b8f7a631e23d42d052484" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "toml" version = "0.5.9" @@ -1504,16 +1644,6 @@ version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a156c684c91ea7d62626509bce3cb4e1d9ed5c4d978f7b4352658f96a4c26b4a" -[[package]] -name = "uuid" -version = "1.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd6469f4314d5f1ffec476e05f17cc9a78bc7a27a6a857842170bdf8d6f98d2f" -dependencies = [ - "getrandom", - "rand", -] - [[package]] name = "vcpkg" version = "0.2.15" diff --git a/Cargo.toml b/Cargo.toml index 9eef725..8b0f745 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -19,7 +19,7 @@ gtk4 = "0.4" gtk4 = "0.4" libadwaita = "0.1" -anime-game-core = { path = "anime-game-core", features = ["all", "static"] } +anime-game-core = { path = "anime-game-core", features = ["all", "static", "genshin"] } serde = { version = "1.0", features = ["derive"] } serde_json = "1.0" @@ -28,3 +28,4 @@ dirs = "4.0.0" wait_not_await = "0.2.1" regex = "1.6.0" lazy_static = "1.4.0" +anyhow = "1.0" diff --git a/anime-game-core b/anime-game-core index ecf84da..50e612c 160000 --- a/anime-game-core +++ b/anime-game-core @@ -1 +1 @@ -Subproject commit ecf84daa6554486a580225f8b498d2e645e50d64 +Subproject commit 50e612c865eef41076ba70d153051b63ff4ecc1e diff --git a/assets/dxvk.json b/assets/dxvk.json deleted file mode 100644 index bb04e10..0000000 --- a/assets/dxvk.json +++ /dev/null @@ -1,162 +0,0 @@ -{ - "vanilla": [ - { - "name": "dxvk-1.10.3", - "version": "1.10.3", - "uri": "https://github.com/doitsujin/dxvk/releases/download/v1.10.3/dxvk-1.10.3.tar.gz", - "recommended": true - }, - { - "name": "dxvk-1.10.2", - "version": "1.10.2", - "uri": "https://github.com/doitsujin/dxvk/releases/download/v1.10.2/dxvk-1.10.2.tar.gz", - "recommended": true - }, - { - "name": "dxvk-1.10.1", - "version": "1.10.1", - "uri": "https://github.com/doitsujin/dxvk/releases/download/v1.10.1/dxvk-1.10.1.tar.gz", - "recommended": true - }, - { - "name": "dxvk-1.10", - "version": "1.10", - "uri": "https://github.com/doitsujin/dxvk/releases/download/v1.10/dxvk-1.10.tar.gz", - "recommended": true - }, - { - "name": "dxvk-1.9.4", - "version": "1.9.4", - "uri": "https://github.com/doitsujin/dxvk/releases/download/v1.9.4/dxvk-1.9.4.tar.gz", - "recommended": true - }, - { - "name": "dxvk-1.9.3", - "version": "1.9.3", - "uri": "https://github.com/doitsujin/dxvk/releases/download/v1.9.3/dxvk-1.9.3.tar.gz", - "recommended": true - }, - { - "name": "dxvk-1.9.2", - "version": "1.9.2", - "uri": "https://github.com/doitsujin/dxvk/releases/download/v1.9.2/dxvk-1.9.2.tar.gz", - "recommended": false - }, - { - "name": "dxvk-1.9.1", - "version": "1.9.1", - "uri": "https://github.com/doitsujin/dxvk/releases/download/v1.9.1/dxvk-1.9.1.tar.gz", - "recommended": false - }, - { - "name": "dxvk-1.9", - "version": "1.9", - "uri": "https://github.com/doitsujin/dxvk/releases/download/v1.9/dxvk-1.9.tar.gz", - "recommended": false - }, - { - "name": "dxvk-1.8.1", - "version": "1.8.1", - "uri": "https://github.com/doitsujin/dxvk/releases/download/v1.8.1/dxvk-1.8.1.tar.gz", - "recommended": false - }, - { - "name": "dxvk-1.8", - "version": "1.8", - "uri": "https://github.com/doitsujin/dxvk/releases/download/v1.8/dxvk-1.8.tar.gz", - "recommended": false - }, - { - "name": "dxvk-1.7.3", - "version": "1.7.3", - "uri": "https://github.com/doitsujin/dxvk/releases/download/v1.7.3/dxvk-1.7.3.tar.gz", - "recommended": false - }, - { - "name": "dxvk-1.7.2", - "version": "1.7.2", - "uri": "https://github.com/doitsujin/dxvk/releases/download/v1.7.2/dxvk-1.7.2.tar.gz", - "recommended": false - } - ], - "async": [ - { - "name": "dxvk-async-1.10.3", - "version": "1.10.3", - "uri": "https://github.com/Sporif/dxvk-async/releases/download/1.10.3/dxvk-async-1.10.3.tar.gz", - "recommended": true - }, - { - "name": "dxvk-async-1.10.2", - "version": "1.10.2", - "uri": "https://github.com/Sporif/dxvk-async/releases/download/1.10.2/dxvk-async-1.10.2.tar.gz", - "recommended": true - }, - { - "name": "dxvk-async-1.10.1", - "version": "1.10.1", - "uri": "https://github.com/Sporif/dxvk-async/releases/download/1.10.1/dxvk-async-1.10.1.tar.gz", - "recommended": true - }, - { - "name": "dxvk-async-1.10", - "version": "1.10", - "uri": "https://github.com/Sporif/dxvk-async/releases/download/1.10/dxvk-async-1.10.tar.gz", - "recommended": true - }, - { - "name": "dxvk-async-1.9.4", - "version": "1.9.4", - "uri": "https://github.com/Sporif/dxvk-async/releases/download/1.9.4/dxvk-async-1.9.4.tar.gz", - "recommended": true - }, - { - "name": "dxvk-async-1.9.3", - "version": "1.9.3", - "uri": "https://github.com/Sporif/dxvk-async/releases/download/1.9.3/dxvk-async-1.9.3.tar.gz", - "recommended": true - }, - { - "name": "dxvk-async-1.9.2", - "version": "1.9.2", - "uri": "https://github.com/Sporif/dxvk-async/releases/download/1.9.4/dxvk-async-1.9.4.tar.gz", - "recommended": false - }, - { - "name": "dxvk-async-1.9.1", - "version": "1.9.1", - "uri": "https://github.com/Sporif/dxvk-async/releases/download/1.9.1/dxvk-async-1.9.1.tar.gz", - "recommended": false - }, - { - "name": "dxvk-async-1.9", - "version": "1.9", - "uri": "https://github.com/Sporif/dxvk-async/releases/download/1.9/dxvk-async-1.9.tar.gz", - "recommended": false - }, - { - "name": "dxvk-async-1.8.1", - "version": "1.8.1", - "uri": "https://github.com/Sporif/dxvk-async/releases/download/1.8.1/dxvk-async-1.8.1.tar.gz", - "recommended": false - }, - { - "name": "dxvk-async-1.8", - "version": "1.8", - "uri": "https://github.com/Sporif/dxvk-async/releases/download/1.8.1/dxvk-async-1.8.1.tar.gz", - "recommended": false - }, - { - "name": "dxvk-async-1.7.3", - "version": "1.7.3", - "uri": "https://github.com/Sporif/dxvk-async/releases/download/1.7.3/dxvk-async-1.7.3.tar.gz", - "recommended": false - }, - { - "name": "dxvk-async-1.7.2", - "version": "1.7.2", - "uri": "https://github.com/Sporif/dxvk-async/releases/download/1.7.2/dxvk-async-1.7.2.tar.gz", - "recommended": false - } - ] -} \ No newline at end of file diff --git a/assets/wine.json b/assets/wine.json deleted file mode 100644 index d9b56a0..0000000 --- a/assets/wine.json +++ /dev/null @@ -1,598 +0,0 @@ -[ - { - "title": "Wine-GE-Proton", - "subtitle": null, - "versions": [ - { - "family": "Wine-GE-Proton", - "name": "lutris-GE-Proton7-26-x86_64", - "title": "Wine-GE-Proton 7-26", - "uri": "https://github.com/GloriousEggroll/wine-ge-custom/releases/download/GE-Proton7-26/wine-lutris-GE-Proton7-26-x86_64.tar.xz", - "files": { - "wine64": "bin/wine64", - "wineserver": "bin/wineserver", - "wineboot": "bin/wineboot", - "winecfg": "lib64/wine/x86_64-windows/winecfg.exe" - }, - "recommended": true - }, - { - "family": "Wine-GE-Proton", - "name": "lutris-GE-Proton7-25-x86_64", - "title": "Wine-GE-Proton 7-25", - "uri": "https://github.com/GloriousEggroll/wine-ge-custom/releases/download/GE-Proton7-25/wine-lutris-GE-Proton7-25-x86_64.tar.xz", - "files": { - "wine64": "bin/wine64", - "wineserver": "bin/wineserver", - "wineboot": "bin/wineboot", - "winecfg": "lib64/wine/x86_64-windows/winecfg.exe" - }, - "recommended": true - }, - { - "family": "Wine-GE-Proton", - "name": "lutris-GE-Proton7-24-x86_64", - "title": "Wine-GE-Proton 7-24", - "uri": "https://github.com/GloriousEggroll/wine-ge-custom/releases/download/GE-Proton7-24/wine-lutris-GE-Proton7-24-x86_64.tar.xz", - "files": { - "wine64": "bin/wine64", - "wineserver": "bin/wineserver", - "wineboot": "bin/wineboot", - "winecfg": "lib64/wine/x86_64-windows/winecfg.exe" - }, - "recommended": true - }, - { - "family": "Wine-GE-Proton", - "name": "lutris-GE-Proton7-23-x86_64", - "title": "Wine-GE-Proton 7-23", - "uri": "https://github.com/GloriousEggroll/wine-ge-custom/releases/download/GE-Proton7-23/wine-lutris-GE-Proton7-23-x86_64.tar.xz", - "files": { - "wine64": "bin/wine64", - "wineserver": "bin/wineserver", - "wineboot": "bin/wineboot", - "winecfg": "lib64/wine/x86_64-windows/winecfg.exe" - }, - "recommended": true - }, - { - "family": "Wine-GE-Proton", - "name": "lutris-GE-Proton7-22-x86_64", - "title": "Wine-GE-Proton 7-22", - "uri": "https://github.com/GloriousEggroll/wine-ge-custom/releases/download/GE-Proton7-22/wine-lutris-GE-Proton7-22-x86_64.tar.xz", - "files": { - "wine64": "bin/wine64", - "wineserver": "bin/wineserver", - "wineboot": "bin/wineboot", - "winecfg": "lib64/wine/x86_64-windows/winecfg.exe" - }, - "recommended": true - }, - { - "family": "Wine-GE-Proton", - "name": "lutris-GE-Proton7-20-x86_64", - "title": "Wine-GE-Proton 7-20", - "uri": "https://github.com/GloriousEggroll/wine-ge-custom/releases/download/GE-Proton7-20/wine-lutris-GE-Proton7-20-x86_64.tar.xz", - "files": { - "wine64": "bin/wine64", - "wineserver": "bin/wineserver", - "wineboot": "bin/wineboot", - "winecfg": "lib64/wine/x86_64-windows/winecfg.exe" - }, - "recommended": true - }, - { - "family": "Wine-GE-Proton", - "name": "lutris-GE-Proton7-18-x86_64", - "title": "Wine-GE-Proton 7-18", - "uri": "https://github.com/GloriousEggroll/wine-ge-custom/releases/download/GE-Proton7-18/wine-lutris-GE-Proton7-18-x86_64.tar.xz", - "files": { - "wine64": "bin/wine64", - "wineserver": "bin/wineserver", - "wineboot": "bin/wineboot", - "winecfg": "lib64/wine/x86_64-windows/winecfg.exe" - }, - "recommended": false - }, - { - "family": "Wine-GE-Proton", - "name": "lutris-GE-Proton7-16-x86_64", - "title": "Wine-GE-Proton 7-16", - "uri": "https://github.com/GloriousEggroll/wine-ge-custom/releases/download/GE-Proton7-16/wine-lutris-GE-Proton7-16-x86_64.tar.xz", - "files": { - "wine64": "bin/wine64", - "wineserver": "bin/wineserver", - "wineboot": "bin/wineboot", - "winecfg": "lib64/wine/x86_64-windows/winecfg.exe" - }, - "recommended": false - }, - { - "family": "Wine-GE-Proton", - "name": "lutris-GE-Proton7-15-x86_64", - "title": "Wine-GE-Proton 7-15", - "uri": "https://github.com/GloriousEggroll/wine-ge-custom/releases/download/GE-Proton7-15/wine-lutris-GE-Proton7-15-x86_64.tar.xz", - "files": { - "wine64": "bin/wine64", - "wineserver": "bin/wineserver", - "wineboot": "bin/wineboot", - "winecfg": "lib64/wine/x86_64-windows/winecfg.exe" - }, - "recommended": false - }, - { - "family": "Wine-GE-Proton", - "name": "lutris-GE-Proton7-14-x86_64", - "title": "Wine-GE-Proton 7-14", - "uri": "https://github.com/GloriousEggroll/wine-ge-custom/releases/download/GE-Proton7-14/wine-lutris-GE-Proton7-14-x86_64.tar.xz", - "files": { - "wine64": "bin/wine64", - "wineserver": "bin/wineserver", - "wineboot": "bin/wineboot", - "winecfg": "lib64/wine/x86_64-windows/winecfg.exe" - }, - "recommended": false - }, - { - "family": "Wine-GE-Proton", - "name": "lutris-GE-Proton7-12-x86_64", - "title": "Wine-GE-Proton 7-12", - "uri": "https://github.com/GloriousEggroll/wine-ge-custom/releases/download/GE-Proton7-12/wine-lutris-GE-Proton7-12-x86_64.tar.xz", - "files": { - "wine64": "bin/wine64", - "wineserver": "bin/wineserver", - "wineboot": "bin/wineboot", - "winecfg": "lib64/wine/x86_64-windows/winecfg.exe" - }, - "recommended": false - }, - { - "family": "Wine-GE-Proton", - "name": "lutris-GE-Proton7-11-x86_64", - "title": "Wine-GE-Proton 7-11", - "uri": "https://github.com/GloriousEggroll/wine-ge-custom/releases/download/GE-Proton7-11/wine-lutris-GE-Proton7-11-x86_64.tar.xz", - "files": { - "wine64": "bin/wine64", - "wineserver": "bin/wineserver", - "wineboot": "bin/wineboot", - "winecfg": "lib64/wine/x86_64-windows/winecfg.exe" - }, - "recommended": false - }, - { - "family": "Wine-GE-Proton", - "name": "lutris-GE-Proton7-10-x86_64", - "title": "Wine-GE-Proton 7-10", - "uri": "https://github.com/GloriousEggroll/wine-ge-custom/releases/download/GE-Proton7-10/wine-lutris-GE-Proton7-10-x86_64.tar.xz", - "files": { - "wine64": "bin/wine64", - "wineserver": "bin/wineserver", - "wineboot": "bin/wineboot", - "winecfg": "lib64/wine/x86_64-windows/winecfg.exe" - }, - "recommended": false - } - ] - }, - { - "title": "GE-Proton", - "subtitle": "This version includes its own DXVK builds and you can use DXVK_ASYNC variable", - "versions": [ - { - "family": "GE-Proton", - "name": "GE-Proton7-30", - "title": "GE-Proton 7-30", - "uri": "https://github.com/GloriousEggroll/proton-ge-custom/releases/download/GE-Proton7-30/GE-Proton7-30.tar.gz", - "files": { - "wine64": "files/bin/wine64", - "wineserver": "files/bin/wineserver", - "wineboot": "files/bin/wineboot", - "winecfg": "files/lib64/wine/x86_64-windows/winecfg.exe" - }, - "recommended": true - }, - { - "family": "GE-Proton", - "name": "GE-Proton7-29", - "title": "GE-Proton 7-29", - "uri": "https://github.com/GloriousEggroll/proton-ge-custom/releases/download/GE-Proton7-29/GE-Proton7-29.tar.gz", - "files": { - "wine64": "files/bin/wine64", - "wineserver": "files/bin/wineserver", - "wineboot": "files/bin/wineboot", - "winecfg": "files/lib64/wine/x86_64-windows/winecfg.exe" - }, - "recommended": true - }, - { - "family": "GE-Proton", - "name": "GE-Proton7-28", - "title": "GE-Proton 7-28", - "uri": "https://github.com/GloriousEggroll/proton-ge-custom/releases/download/GE-Proton7-28/GE-Proton7-28.tar.gz", - "files": { - "wine64": "files/bin/wine64", - "wineserver": "files/bin/wineserver", - "wineboot": "files/bin/wineboot", - "winecfg": "files/lib64/wine/x86_64-windows/winecfg.exe" - }, - "recommended": true - }, - { - "family": "GE-Proton", - "name": "GE-Proton7-27", - "title": "GE-Proton 7-27", - "uri": "https://github.com/GloriousEggroll/proton-ge-custom/releases/download/GE-Proton7-27/GE-Proton7-27.tar.gz", - "files": { - "wine64": "files/bin/wine64", - "wineserver": "files/bin/wineserver", - "wineboot": "files/bin/wineboot", - "winecfg": "files/lib64/wine/x86_64-windows/winecfg.exe" - }, - "recommended": true - }, - { - "family": "GE-Proton", - "name": "GE-Proton7-26", - "title": "GE-Proton 7-26", - "uri": "https://github.com/GloriousEggroll/proton-ge-custom/releases/download/GE-Proton7-26/GE-Proton7-26.tar.gz", - "files": { - "wine64": "files/bin/wine64", - "wineserver": "files/bin/wineserver", - "wineboot": "files/bin/wineboot", - "winecfg": "files/lib64/wine/x86_64-windows/winecfg.exe" - }, - "recommended": true - }, - { - "family": "GE-Proton", - "name": "GE-Proton7-24", - "title": "GE-Proton 7-24", - "uri": "https://github.com/GloriousEggroll/proton-ge-custom/releases/download/GE-Proton7-24/GE-Proton7-24.tar.gz", - "files": { - "wine64": "files/bin/wine64", - "wineserver": "files/bin/wineserver", - "wineboot": "files/bin/wineboot", - "winecfg": "files/lib64/wine/x86_64-windows/winecfg.exe" - }, - "recommended": true - }, - { - "family": "GE-Proton", - "name": "GE-Proton7-20", - "title": "GE-Proton 7-20", - "uri": "https://github.com/GloriousEggroll/proton-ge-custom/releases/download/GE-Proton7-20/GE-Proton7-20.tar.gz", - "files": { - "wine64": "files/bin/wine64", - "wineserver": "files/bin/wineserver", - "wineboot": "files/bin/wineboot", - "winecfg": "files/lib64/wine/x86_64-windows/winecfg.exe" - }, - "recommended": false - }, - { - "family": "GE-Proton", - "name": "GE-Proton7-19", - "title": "GE-Proton 7-19", - "uri": "https://github.com/GloriousEggroll/proton-ge-custom/releases/download/GE-Proton7-19/GE-Proton7-19.tar.gz", - "files": { - "wine64": "files/bin/wine64", - "wineserver": "files/bin/wineserver", - "wineboot": "files/bin/wineboot", - "winecfg": "files/lib64/wine/x86_64-windows/winecfg.exe" - }, - "recommended": false - }, - { - "family": "GE-Proton", - "name": "GE-Proton7-18", - "title": "GE-Proton 7-18", - "uri": "https://github.com/GloriousEggroll/proton-ge-custom/releases/download/GE-Proton7-18/GE-Proton7-18.tar.gz", - "files": { - "wine64": "files/bin/wine64", - "wineserver": "files/bin/wineserver", - "wineboot": "files/bin/wineboot", - "winecfg": "files/lib64/wine/x86_64-windows/winecfg.exe" - }, - "recommended": false - }, - { - "family": "GE-Proton", - "name": "GE-Proton7-17", - "title": "GE-Proton 7-17", - "uri": "https://github.com/GloriousEggroll/proton-ge-custom/releases/download/GE-Proton7-17/GE-Proton7-17.tar.gz", - "files": { - "wine64": "files/bin/wine64", - "wineserver": "files/bin/wineserver", - "wineboot": "files/bin/wineboot", - "winecfg": "files/lib64/wine/x86_64-windows/winecfg.exe" - }, - "recommended": false - }, - { - "family": "GE-Proton", - "name": "GE-Proton7-16", - "title": "GE-Proton 7-16", - "uri": "https://github.com/GloriousEggroll/proton-ge-custom/releases/download/GE-Proton7-16/GE-Proton7-16.tar.gz", - "files": { - "wine64": "files/bin/wine64", - "wineserver": "files/bin/wineserver", - "wineboot": "files/bin/wineboot", - "winecfg": "files/lib64/wine/x86_64-windows/winecfg.exe" - }, - "recommended": false - }, - { - "family": "GE-Proton", - "name": "GE-Proton7-15", - "title": "GE-Proton 7-15", - "uri": "https://github.com/GloriousEggroll/proton-ge-custom/releases/download/GE-Proton7-15/GE-Proton7-15.tar.gz", - "files": { - "wine64": "files/bin/wine64", - "wineserver": "files/bin/wineserver", - "wineboot": "files/bin/wineboot", - "winecfg": "files/lib64/wine/x86_64-windows/winecfg.exe" - }, - "recommended": false - }, - { - "family": "GE-Proton", - "name": "GE-Proton7-13", - "title": "GE-Proton 7-13", - "uri": "https://github.com/GloriousEggroll/proton-ge-custom/releases/download/GE-Proton7-13/GE-Proton7-13.tar.gz", - "files": { - "wine64": "files/bin/wine64", - "wineserver": "files/bin/wineserver", - "wineboot": "files/bin/wineboot", - "winecfg": "files/lib64/wine/x86_64-windows/winecfg.exe" - }, - "recommended": false - }, - { - "family": "GE-Proton", - "name": "GE-Proton7-10", - "title": "GE-Proton 7-10", - "uri": "https://github.com/GloriousEggroll/proton-ge-custom/releases/download/GE-Proton7-10/GE-Proton7-10.tar.gz", - "files": { - "wine64": "files/bin/wine64", - "wineserver": "files/bin/wineserver", - "wineboot": "files/bin/wineboot", - "winecfg": "files/lib64/wine/x86_64-windows/winecfg.exe" - }, - "recommended": false - } - ] - }, - { - "title": "Soda", - "subtitle": "New runner based on Valve’s Wine, with patches from Proton, TKG and GE. Developed by Bottles", - "versions": [ - { - "family": "Soda", - "name": "soda-7.0-3-x86_64", - "title": "Soda 7.0-3", - "uri": "https://github.com/bottlesdevs/wine/releases/download/soda-7.0-3/soda-7.0-3-x86_64.tar.xz", - "files": { - "wine64": "bin/wine64", - "wineserver": "bin/wineserver", - "wineboot": "bin/wineboot", - "winecfg": "lib/wine/x86_64-windows/winecfg.exe" - }, - "recommended": true - }, - { - "family": "Soda", - "name": "soda-7.0-2-x86_64", - "title": "Soda 7.0-2", - "uri": "https://github.com/bottlesdevs/wine/releases/download/soda-7.0-2/soda-7.0-2-x86_64.tar.xz", - "files": { - "wine64": "bin/wine64", - "wineserver": "bin/wineserver", - "wineboot": "bin/wineboot", - "winecfg": "lib/wine/x86_64-windows/winecfg.exe" - }, - "recommended": true - }, - { - "family": "Soda", - "name": "soda-7.0-1-x86_64", - "title": "Soda 7.0-1", - "uri": "https://github.com/bottlesdevs/wine/releases/download/soda-7.0-1/soda-7.0-1-x86_64.tar.xz", - "files": { - "wine64": "bin/wine64", - "wineserver": "bin/wineserver", - "wineboot": "bin/wineboot", - "winecfg": "lib/wine/x86_64-windows/winecfg.exe" - }, - "recommended": true - }, - { - "family": "Soda", - "name": "soda-7.0-x86_64", - "title": "Soda 7.0", - "uri": "https://github.com/bottlesdevs/wine/releases/download/soda-7.0/soda-7.0-x86_64.tar.xz", - "files": { - "wine64": "bin/wine64", - "wineserver": "bin/wineserver", - "wineboot": "bin/wineboot", - "winecfg": "lib/wine/x86_64-windows/winecfg.exe" - }, - "recommended": true - } - ] - }, - { - "title": "Lutris", - "subtitle": null, - "versions": [ - { - "family": "Lutris", - "name": "lutris-7.2-2-x86_64", - "title": "Lutris 7.2-2", - "uri": "https://github.com/lutris/wine/releases/download/lutris-wine-7.2-2/wine-lutris-7.2-2-x86_64.tar.xz", - "files": { - "wine64": "bin/wine64", - "wineserver": "bin/wineserver", - "wineboot": "bin/wineboot", - "winecfg": "lib64/wine/x86_64-windows/winecfg.exe" - }, - "recommended": true - }, - { - "family": "Lutris", - "name": "lutris-7.2-x86_64", - "title": "Lutris 7.2", - "uri": "https://github.com/lutris/wine/releases/download/lutris-wine-7.2/wine-lutris-7.2-x86_64.tar.xz", - "files": { - "wine64": "bin/wine64", - "wineserver": "bin/wineserver", - "wineboot": "bin/wineboot", - "winecfg": "lib64/wine/x86_64-windows/winecfg.exe" - }, - "recommended": true - }, - { - "family": "Lutris", - "name": "lutris-7.1-x86_64", - "title": "Lutris 7.1", - "uri": "https://github.com/lutris/wine/releases/download/lutris-7.1/wine-lutris-7.1-x86_64.tar.xz", - "files": { - "wine64": "bin/wine64", - "wineserver": "bin/wineserver", - "wineboot": "bin/wineboot", - "winecfg": "lib64/wine/x86_64-windows/winecfg.exe" - }, - "recommended": true - }, - { - "family": "Lutris", - "name": "lutris-6.21-6-x86_64", - "title": "Lutris 6.21-6", - "uri": "https://github.com/lutris/wine/releases/download/lutris-6.21-6/wine-lutris-6.21-6-x86_64.tar.xz", - "files": { - "wine64": "bin/wine64", - "wineserver": "bin/wineserver", - "wineboot": "bin/wineboot", - "winecfg": "lib64/wine/x86_64-windows/winecfg.exe" - }, - "recommended": true - }, - { - "family": "Lutris", - "name": "lutris-6.21-5-x86_64", - "title": "Lutris 6.21-5", - "uri": "https://github.com/lutris/wine/releases/download/lutris-6.21-5/wine-lutris-6.21-5-x86_64.tar.xz", - "files": { - "wine64": "bin/wine64", - "wineserver": "bin/wineserver", - "wineboot": "bin/wineboot", - "winecfg": "lib64/wine/x86_64-windows/winecfg.exe" - }, - "recommended": true - }, - { - "family": "Lutris", - "name": "lutris-6.21-4-x86_64", - "title": "Lutris 6.21-4", - "uri": "https://github.com/lutris/wine/releases/download/lutris-6.21-4/wine-lutris-6.21-4-x86_64.tar.xz", - "files": { - "wine64": "bin/wine64", - "wineserver": "bin/wineserver", - "wineboot": "bin/wineboot", - "winecfg": "lib64/wine/x86_64-windows/winecfg.exe" - }, - "recommended": false - }, - { - "family": "Lutris", - "name": "lutris-6.21-3-x86_64", - "title": "Lutris 6.21-3", - "uri": "https://github.com/lutris/wine/releases/download/lutris-6.21-3/wine-lutris-6.21-3-x86_64.tar.xz", - "files": { - "wine64": "bin/wine64", - "wineserver": "bin/wineserver", - "wineboot": "bin/wineboot", - "winecfg": "lib64/wine/x86_64-windows/winecfg.exe" - }, - "recommended": false - }, - { - "family": "Lutris", - "name": "lutris-6.21-2-x86_64", - "title": "Lutris 6.21-2", - "uri": "https://github.com/lutris/wine/releases/download/lutris-6.21-2/wine-lutris-6.21-2-x86_64.tar.xz", - "files": { - "wine64": "bin/wine64", - "wineserver": "bin/wineserver", - "wineboot": "bin/wineboot", - "winecfg": "lib64/wine/x86_64-windows/winecfg.exe" - }, - "recommended": false - }, - { - "family": "Lutris", - "name": "lutris-6.21-x86_64", - "title": "Lutris 6.21", - "uri": "https://github.com/lutris/wine/releases/download/lutris-6.21/wine-lutris-6.21-x86_64.tar.xz", - "files": { - "wine64": "bin/wine64", - "wineserver": "bin/wineserver", - "wineboot": "bin/wineboot", - "winecfg": "lib64/wine/x86_64-windows/winecfg.exe" - }, - "recommended": false - }, - { - "family": "Lutris", - "name": "lutris-6.14-4-x86_64", - "title": "Lutris 6.14-4", - "uri": "https://github.com/lutris/wine/releases/download/lutris-6.14-4/wine-lutris-6.14-4-x86_64.tar.xz", - "files": { - "wine64": "bin/wine64", - "wineserver": "bin/wineserver", - "wineboot": "bin/wineboot", - "winecfg": "lib64/wine/x86_64-windows/winecfg.exe" - }, - "recommended": true - }, - { - "family": "Lutris", - "name": "lutris-6.14-3-x86_64", - "title": "Lutris 6.14-3", - "uri": "https://github.com/lutris/wine/releases/download/lutris-6.14-3/wine-lutris-6.14-3-x86_64.tar.xz", - "files": { - "wine64": "bin/wine64", - "wineserver": "bin/wineserver", - "wineboot": "bin/wineboot", - "winecfg": "lib64/wine/x86_64-windows/winecfg.exe" - }, - "recommended": false - }, - { - "family": "Lutris", - "name": "lutris-6.14-2-x86_64", - "title": "Lutris 6.14-2", - "uri": "https://github.com/lutris/wine/releases/download/lutris-6.14-2/wine-lutris-6.14-2-x86_64.tar.xz", - "files": { - "wine64": "bin/wine64", - "wineserver": "bin/wineserver", - "wineboot": "bin/wineboot", - "winecfg": "lib64/wine/x86_64-windows/winecfg.exe" - }, - "recommended": false - }, - { - "family": "Lutris", - "name": "lutris-6.14-x86_64", - "title": "Lutris 6.14", - "uri": "https://github.com/lutris/wine/releases/download/lutris-6.14/wine-lutris-6.14-x86_64.tar.xz", - "files": { - "wine64": "bin/wine64", - "wineserver": "bin/wineserver", - "wineboot": "bin/wineboot", - "winecfg": "lib64/wine/x86_64-windows/winecfg.exe" - }, - "recommended": false - } - ] - } -] \ No newline at end of file diff --git a/src/lib/config/launcher/mod.rs b/src/lib/config/launcher/mod.rs index ea2dfc0..895c26e 100644 --- a/src/lib/config/launcher/mod.rs +++ b/src/lib/config/launcher/mod.rs @@ -1,7 +1,7 @@ use serde::{Serialize, Deserialize}; use serde_json::Value as JsonValue; -use anime_game_core::consts::GameEdition as CoreGameEdition; +use anime_game_core::genshin::consts::GameEdition as CoreGameEdition; use crate::lib::consts::launcher_dir; diff --git a/src/lib/config/mod.rs b/src/lib/config/mod.rs index 4fe5465..f9f2022 100644 --- a/src/lib/config/mod.rs +++ b/src/lib/config/mod.rs @@ -135,20 +135,15 @@ impl Config { pub fn try_get_selected_wine_info(&self) -> Option { match &self.game.wine.selected { Some(selected) => { - match WineList::get() { - Ok(list) => { - for group in list { - for version in group.versions { - if &version.name == selected { - return Some(version.clone()); - } - } + for group in WineList::get() { + for version in group.versions { + if &version.name == selected { + return Some(version.clone()); } - - None - }, - Err(_) => None + } } + + None }, None => None } diff --git a/src/lib/dxvk.rs b/src/lib/dxvk.rs index a3617d1..4c88e0b 100644 --- a/src/lib/dxvk.rs +++ b/src/lib/dxvk.rs @@ -8,7 +8,10 @@ use regex::Regex; use crate::lib::config; -const LIST: &str = include_str!("../../assets/dxvk.json"); +lazy_static! { + static ref VANILLA_LIST: Vec = serde_json::from_str(include_str!("../../components/dxvk/vanilla.json")).unwrap(); + static ref ASYNC_LIST: Vec = serde_json::from_str(include_str!("../../components/dxvk/async.json")).unwrap(); +} #[derive(Debug, Clone, Serialize, Deserialize)] pub struct List { @@ -17,8 +20,11 @@ pub struct List { } impl List { - pub fn get() -> Result { - Ok(serde_json::from_str(LIST)?) + pub fn get() -> Self { + Self { + vanilla: VANILLA_LIST.clone(), + r#async: ASYNC_LIST.clone() + } } /// List only downloaded DXVK versions in some specific folder @@ -26,7 +32,7 @@ impl List { let mut vanilla = Vec::new(); let mut r#async = Vec::new(); - let list = Self::get()?; + let list = Self::get(); for entry in std::fs::read_dir(folder.to_string())? { let name = entry?.file_name(); @@ -63,7 +69,7 @@ pub struct Version { impl Version { pub fn latest() -> Result { - Ok(List::get()?.vanilla[0].clone()) + Ok(List::get().vanilla[0].clone()) } pub fn is_downloaded_in(&self, folder: T) -> bool { diff --git a/src/lib/game.rs b/src/lib/game.rs index 28f023e..55e7ba3 100644 --- a/src/lib/game.rs +++ b/src/lib/game.rs @@ -2,7 +2,7 @@ use std::io::{Error, ErrorKind}; use std::path::Path; use std::process::Command; -use anime_game_core::telemetry; +use anime_game_core::genshin::telemetry; use super::consts; use super::config; diff --git a/src/lib/launcher/states.rs b/src/lib/launcher/states.rs index b6bbd15..3a23301 100644 --- a/src/lib/launcher/states.rs +++ b/src/lib/launcher/states.rs @@ -1,6 +1,5 @@ -use std::io::{Error, ErrorKind}; - use anime_game_core::prelude::*; +use anime_game_core::genshin::prelude::*; use crate::lib::consts; use crate::lib::config; @@ -40,7 +39,7 @@ impl Default for LauncherState { } impl LauncherState { - pub fn get(status: T) -> std::io::Result { + pub fn get(status: T) -> anyhow::Result { let config = config::get()?; // Check wine existence @@ -66,7 +65,7 @@ impl LauncherState { for voice_package in &config.game.voices { let mut voice_package = VoicePackage::with_locale(match VoiceLocale::from_str(voice_package) { Some(locale) => locale, - None => return Err(Error::new(ErrorKind::Other, format!("Incorrect voice locale \"{}\" specified in the config", voice_package))) + None => return Err(anyhow::anyhow!("Incorrect voice locale \"{}\" specified in the config", voice_package)) })?; status(format!("Updating voice info ({})...", voice_package.locale().to_name()).as_str()); @@ -76,7 +75,7 @@ impl LauncherState { if voice_package.is_installed_in(&config.game.path) { voice_package = match VoicePackage::new(get_voice_package_path(&config.game.path, voice_package.locale())) { Some(locale) => locale, - None => return Err(Error::new(ErrorKind::Other, format!("Failed to load {} voice package", voice_package.locale().to_name()))) + None => return Err(anyhow::anyhow!("Failed to load {} voice package", voice_package.locale().to_name())) }; } diff --git a/src/lib/wine.rs b/src/lib/wine.rs index bb0aac5..8fb1e57 100644 --- a/src/lib/wine.rs +++ b/src/lib/wine.rs @@ -1,19 +1,42 @@ use serde::{Serialize, Deserialize}; -const LIST: &str = include_str!("../../assets/wine.json"); +lazy_static::lazy_static! { + static ref GROUPS: Vec = vec![ + Group { + title: String::from("Wine-GE-Proton"), + subtitle: None, + versions: serde_json::from_str(include_str!("../../components/wine/wine-ge-proton.json")).unwrap() + }, + Group { + title: String::from("GE-Proton"), + subtitle: Some(String::from("This version includes its own DXVK builds and you can use DXVK_ASYNC variable")), + versions: serde_json::from_str(include_str!("../../components/wine/ge-proton.json")).unwrap() + }, + Group { + title: String::from("Soda"), + subtitle: Some(String::from("New runner based on Valve’s Wine, with patches from Proton, TKG and GE. Developed by Bottles")), + versions: serde_json::from_str(include_str!("../../components/wine/soda.json")).unwrap() + }, + Group { + title: String::from("Lutris"), + subtitle: None, + versions: serde_json::from_str(include_str!("../../components/wine/lutris.json")).unwrap() + } + ]; +} pub struct List; impl List { - pub fn get() -> Result, serde_json::Error> { - Ok(serde_json::from_str(LIST)?) + pub fn get() -> Vec { + GROUPS.clone() } /// List only downloaded wine versions in some specific folder pub fn list_downloaded(folder: T) -> std::io::Result> { let mut downloaded = Vec::new(); - let list = Self::get()?; + let list = Self::get(); for entry in std::fs::read_dir(folder.to_string())? { let name = entry?.file_name(); @@ -44,7 +67,6 @@ pub struct Group { #[derive(Debug, Clone, Serialize, Deserialize)] pub struct Version { - pub family: String, pub name: String, pub title: String, pub uri: String, @@ -54,7 +76,7 @@ pub struct Version { impl Version { pub fn latest() -> Result { - Ok(List::get()?[0].versions[0].clone()) + Ok(List::get()[0].versions[0].clone()) } pub fn is_downloaded_in(&self, folder: T) -> bool { @@ -64,6 +86,7 @@ impl Version { #[derive(Debug, Clone, Serialize, Deserialize)] pub struct Files { + pub wine: String, pub wine64: String, pub wineserver: String, pub wineboot: String, diff --git a/src/main.rs b/src/main.rs index 8d7623f..4d76286 100644 --- a/src/main.rs +++ b/src/main.rs @@ -96,7 +96,7 @@ fn main() { } // Set game edition - anime_game_core::consts::set_game_edition(config.launcher.edition.into()); + anime_game_core::genshin::consts::set_game_edition(config.launcher.edition.into()); // Load main window let main = MainApp::new(app).expect("Failed to init MainApp"); diff --git a/src/ui/components/progress_bar.rs b/src/ui/components/progress_bar.rs index 7364e7b..60aa679 100644 --- a/src/ui/components/progress_bar.rs +++ b/src/ui/components/progress_bar.rs @@ -10,7 +10,7 @@ use crate::lib::prettify_bytes::prettify_bytes; #[derive(Debug)] pub enum ProgressUpdateResult { Updated, - Error(String, std::io::Error), + Error(String, String), Finished } @@ -78,10 +78,14 @@ impl ProgressBar { InstallerUpdate::DownloadingFinished => (), InstallerUpdate::UnpackingStarted(_) => (), - InstallerUpdate::DownloadingError(err) => return ProgressUpdateResult::Error(String::from("Failed to download"), err.into()), - InstallerUpdate::UnpackingError => return ProgressUpdateResult::Error(String::from("Failed to unpack"), std::io::Error::last_os_error()), + InstallerUpdate::DownloadingError(err) => { + let err: std::io::Error = err.into(); - InstallerUpdate::UnpackingFinished => return ProgressUpdateResult::Finished, + return ProgressUpdateResult::Error(String::from("Failed to download"), err.to_string()); + } + + InstallerUpdate::UnpackingError(err) => return ProgressUpdateResult::Error(String::from("Failed to unpack"), err), + InstallerUpdate::UnpackingFinished => return ProgressUpdateResult::Finished } ProgressUpdateResult::Updated diff --git a/src/ui/components/voiceover_row.rs b/src/ui/components/voiceover_row.rs index c6928bb..76d9900 100644 --- a/src/ui/components/voiceover_row.rs +++ b/src/ui/components/voiceover_row.rs @@ -1,7 +1,7 @@ use gtk4::{self as gtk, prelude::*}; use libadwaita::{self as adw, prelude::*}; -use anime_game_core::prelude::*; +use anime_game_core::genshin::voice_data::package::VoicePackage; #[derive(Debug, Clone)] pub struct VoiceoverRow { diff --git a/src/ui/first_run/download_components.rs b/src/ui/first_run/download_components.rs index 2e4576f..fc534bb 100644 --- a/src/ui/first_run/download_components.rs +++ b/src/ui/first_run/download_components.rs @@ -49,12 +49,7 @@ impl Page { // Add wine versions let model = gtk::StringList::new(&[]); - let versions = match WineList::get() { - Ok(versions) => versions, - Err(err) => return Err(err.to_string()) - }; - - for version in &versions[0].versions { + for version in &WineList::get()[0].versions { if version.recommended { model.append(&version.title); @@ -67,12 +62,7 @@ impl Page { // Add DXVK versions let model = gtk::StringList::new(&[]); - let versions = match DxvkList::get() { - Ok(versions) => versions, - Err(err) => return Err(err.to_string()) - }; - - for version in &versions.vanilla { + for version in &DxvkList::get().vanilla { if version.recommended { model.append(&version.version); diff --git a/src/ui/first_run/voice_packages.rs b/src/ui/first_run/voice_packages.rs index 7a87732..94440e8 100644 --- a/src/ui/first_run/voice_packages.rs +++ b/src/ui/first_run/voice_packages.rs @@ -1,7 +1,7 @@ use gtk4 as gtk; use libadwaita::{self as adw, prelude::*}; -use anime_game_core::voice_data::prelude::*; +use anime_game_core::genshin::voice_data::prelude::*; use crate::lib::config; use crate::ui::*; diff --git a/src/ui/main.rs b/src/ui/main.rs index 356fd34..fee7213 100644 --- a/src/ui/main.rs +++ b/src/ui/main.rs @@ -9,9 +9,11 @@ use std::cell::Cell; use std::io::Error; use std::process::{Command, Stdio}; -use anime_game_core::prelude::*; use wait_not_await::Await; +use anime_game_core::prelude::*; +use anime_game_core::genshin::prelude::*; + use crate::ui::*; use super::preferences::PreferencesStack; @@ -151,7 +153,7 @@ pub enum Actions { ShowProgressBar, UpdateProgress { fraction: Rc, title: Rc }, HideProgressBar, - Toast(Rc<(String, Error)>) + Toast(Rc<(String, String)>) } impl Actions { @@ -215,7 +217,7 @@ impl App { if let Some(launcher_dir) = consts::launcher_dir() { if let Err(err) = Command::new("xdg-open").arg(launcher_dir).spawn() { this.update(Actions::Toast(Rc::new(( - String::from("Failed to open launcher folder"), err + String::from("Failed to open launcher folder"), err.to_string() )))).unwrap(); } } @@ -225,7 +227,7 @@ impl App { if let Ok(config) = config::get() { if let Err(err) = Command::new("xdg-open").arg(config.game.path).spawn() { this.update(Actions::Toast(Rc::new(( - String::from("Failed to open game folder"), err + String::from("Failed to open game folder"), err.to_string() )))).unwrap(); } } @@ -235,7 +237,7 @@ impl App { if let Some(config_file) = consts::config_file() { if let Err(err) = Command::new("xdg-open").arg(config_file).spawn() { this.update(Actions::Toast(Rc::new(( - String::from("Failed to open config file"), err + String::from("Failed to open config file"), err.to_string() )))).unwrap(); } } @@ -319,7 +321,7 @@ impl App { this.widgets.window.show(); this.update(Actions::Toast(Rc::new(( - String::from("Failed to run game"), err + String::from("Failed to run game"), err.to_string() )))).unwrap(); } @@ -371,20 +373,20 @@ impl App { Ok(false) => { this.update(Actions::Toast(Rc::new(( - String::from("Failed to sync patch folder"), Error::last_os_error() + String::from("Failed to sync patch folder"), Error::last_os_error().to_string() )))).unwrap(); } Err(err) => { this.update(Actions::Toast(Rc::new(( - String::from("Failed to sync patch folder"), err + String::from("Failed to sync patch folder"), err.to_string() )))).unwrap(); } } } Err(err) => this.update(Actions::Toast(Rc::new(( - String::from("Failed to check patch folder state"), err + String::from("Failed to check patch folder state"), err.to_string() )))).unwrap() } @@ -394,7 +396,7 @@ impl App { Err(err) => { this.update(Actions::Toast(Rc::new(( - String::from("Failed to patch game"), err + String::from("Failed to patch game"), err.to_string() )))).unwrap(); } } @@ -498,7 +500,7 @@ impl App { if let Err(err) = prefix.update(&config.game.wine.builds, wine) { this.update(Actions::Toast(Rc::new(( - String::from("Failed to create wine prefix"), err + String::from("Failed to create wine prefix"), err.to_string() )))).unwrap(); } @@ -565,8 +567,10 @@ impl App { }); if let Err(err) = result { + let err: Error = err.into(); + this_copy.update(Actions::Toast(Rc::new(( - String::from("Downloading failed"), err.into() + String::from("Downloading failed"), err.to_string() )))).unwrap(); } }); @@ -586,14 +590,14 @@ impl App { let this = this.clone(); std::thread::spawn(move || { - match repairer::try_get_integrity_files() { + match repairer::try_get_integrity_files(None) { Ok(mut files) => { // Add voiceovers files let game = Game::new(&config.game.path); if let Ok(voiceovers) = game.get_voice_packages() { for package in voiceovers { - if let Ok(mut voiceover_files) = repairer::try_get_voice_integrity_files(package.locale()) { + if let Ok(mut voiceover_files) = repairer::try_get_voice_integrity_files(package.locale(), None) { files.append(&mut voiceover_files); } } @@ -708,8 +712,10 @@ impl App { for (i, file) in broken.into_iter().enumerate() { if !is_patch_applied || !should_ignore(&file.path) { if let Err(err) = file.repair(&config.game.path) { + let err: Error = err.into(); + this.update(Actions::Toast(Rc::new(( - String::from("Failed to repair game file"), err.into() + String::from("Failed to repair game file"), err.to_string() )))).unwrap(); } } @@ -727,7 +733,7 @@ impl App { }, Err(err) => { this.update(Actions::Toast(Rc::new(( - String::from("Failed to get integrity files"), err + String::from("Failed to get integrity files"), err.to_string() )))).unwrap(); this.update(Actions::HideProgressBar).unwrap(); diff --git a/src/ui/preferences/general.rs b/src/ui/preferences/general.rs index e4c935b..332ec71 100644 --- a/src/ui/preferences/general.rs +++ b/src/ui/preferences/general.rs @@ -6,9 +6,9 @@ use gtk::glib::clone; use std::rc::Rc; use std::cell::Cell; -use std::io::Error; use anime_game_core::prelude::*; +use anime_game_core::genshin::prelude::*; use crate::lib::consts; use crate::lib::config; @@ -110,14 +110,9 @@ impl AppWidgets { result.voieover_components = Rc::new(components); // Update wine versions lists - let groups = match wine::List::get() { - Ok(list) => list, - Err(err) => return Err(err.to_string()) - }; - let mut components = Vec::new(); - for group in groups { + for group in wine::List::get() { let group = WineGroup::new(group); group.update_states(&config.game.wine.builds); @@ -130,10 +125,7 @@ impl AppWidgets { result.wine_components = Rc::new(components); // Update DXVK list - let list = match dxvk::List::get() { - Ok(list) => list, - Err(err) => return Err(err.to_string()) - }; + let list = dxvk::List::get(); let mut components = Vec::new(); @@ -172,7 +164,7 @@ pub enum Actions { SelectDxvkVersion(Rc), UpdateWineComboRow, SelectWineVersion(Rc), - Toast(Rc<(String, Error)>) + Toast(Rc<(String, String)>) } impl Actions { @@ -306,7 +298,7 @@ impl App { Ok(output) => println!("{}", String::from_utf8_lossy(&output.stdout)), Err(err) => { this.update(Actions::Toast(Rc::new(( - String::from("Failed to apply DXVK"), err + String::from("Failed to apply DXVK"), err.to_string() )))).unwrap(); } } @@ -354,7 +346,7 @@ impl App { std::thread::spawn(move || { if let Err(err) = component.package.delete_in(&config.game.path) { this.update(Actions::Toast(Rc::new(( - String::from("Failed to delete voiceover"), err + String::from("Failed to delete voiceover"), err.to_string() )))).unwrap(); } @@ -391,7 +383,7 @@ impl App { if component.is_downloaded(&config.game.dxvk.builds) { if let Err(err) = component.delete(&config.game.dxvk.builds) { this.update(Actions::Toast(Rc::new(( - String::from("Failed to delete DXVK"), err + String::from("Failed to delete DXVK"), err.to_string() )))).unwrap(); } @@ -407,7 +399,7 @@ impl App { Ok(output) => println!("{}", String::from_utf8_lossy(&output.stdout)), Err(err) => { this.update(Actions::Toast(Rc::new(( - String::from("Failed to apply DXVK"), err + String::from("Failed to apply DXVK"), err.to_string() )))).unwrap(); } } @@ -428,7 +420,7 @@ impl App { if component.is_downloaded(&config.game.wine.builds) { if let Err(err) = component.delete(&config.game.wine.builds) { this.update(Actions::Toast(Rc::new(( - String::from("Failed to delete wine"), err + String::from("Failed to delete wine"), err.to_string() )))).unwrap(); } @@ -503,7 +495,7 @@ impl App { Ok(output) => println!("{}", String::from_utf8_lossy(&output.stdout)), Err(err) => { this.update(Actions::Toast(Rc::new(( - String::from("Failed to apply DXVK"), err + String::from("Failed to apply DXVK"), err.to_string() )))).unwrap(); } } @@ -605,7 +597,7 @@ impl App { } /// This method is being called by the `PreferencesStack::update` - pub fn prepare(&self, status_page: &adw::StatusPage) -> Result<(), Error> { + pub fn prepare(&self, status_page: &adw::StatusPage) -> anyhow::Result<()> { let config = config::get()?; let game = Game::new(&config.game.path); diff --git a/src/ui/preferences/mod.rs b/src/ui/preferences/mod.rs index 7f9c038..f25fc61 100644 --- a/src/ui/preferences/mod.rs +++ b/src/ui/preferences/mod.rs @@ -5,7 +5,6 @@ use gtk::glib; use std::rc::Rc; use std::cell::Cell; -use std::io::Error; use crate::ui::*; use crate::ui::traits::prelude::*; @@ -75,7 +74,7 @@ impl PreferencesStack { /// Update page info before opening it /// /// Being called from the `MainApp` struct - pub fn update(&self) -> Result<(), Error> { + pub fn update(&self) -> anyhow::Result<()> { self.status_page.show(); self.status_page.set_description(None); self.flap.hide(); diff --git a/src/ui/traits/download_component.rs b/src/ui/traits/download_component.rs index 6f32e63..2616e2d 100644 --- a/src/ui/traits/download_component.rs +++ b/src/ui/traits/download_component.rs @@ -12,7 +12,7 @@ use crate::lib::config; #[derive(Debug)] pub enum DownloadingResult { DownloadingError(DownloadingError), - UnpackingError, + UnpackingError(String), Done } @@ -69,8 +69,8 @@ pub trait DownloadComponent { downl_send.send(DownloadingResult::DownloadingError(err.into())).unwrap(); } - InstallerUpdate::UnpackingError => { - downl_send.send(DownloadingResult::UnpackingError).unwrap(); + InstallerUpdate::UnpackingError(err) => { + downl_send.send(DownloadingResult::UnpackingError(err.to_string())).unwrap(); } }