feat(core): implemented SDK 1.3.0

This commit is contained in:
Observer KRypt0n_ 2023-05-20 16:49:30 +02:00
parent 4e9f6e43c4
commit 8d8087443e
No known key found for this signature in database
GPG key ID: 844DA47BA25FE1E2
7 changed files with 133 additions and 59 deletions

147
Cargo.lock generated
View file

@ -40,8 +40,8 @@ dependencies = [
[[package]]
name = "anime-game-core"
version = "1.8.0"
source = "git+https://github.com/an-anime-team/anime-game-core?tag=1.8.0#dbb9008bcdd6a7b8026567ff35417671a77c740e"
version = "1.9.0"
source = "git+https://github.com/an-anime-team/anime-game-core?tag=1.9.0#74f8e4ac00ad60ba5106f386529155b65afa1622"
dependencies = [
"anyhow",
"bzip2",
@ -65,8 +65,8 @@ dependencies = [
[[package]]
name = "anime-launcher-sdk"
version = "1.2.2"
source = "git+https://github.com/an-anime-team/anime-launcher-sdk?tag=1.2.2#f2efb2c8bf339e065ecafc53cfcc9c02a129124e"
version = "1.3.0"
source = "git+https://github.com/an-anime-team/anime-launcher-sdk?tag=1.3.0#e1f864c7fbb5175541c70ed236d7d313ca855538"
dependencies = [
"anime-game-core",
"anyhow",
@ -161,7 +161,7 @@ dependencies = [
"parking",
"polling",
"slab",
"socket2",
"socket2 0.4.9",
"waker-fn",
"windows-sys 0.42.0",
]
@ -230,6 +230,12 @@ dependencies = [
"rustc-demangle",
]
[[package]]
name = "base64"
version = "0.12.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3441f0f7b02788e948e47f457ca01f1d7e6d92c693bc132c22b087d3141c03ff"
[[package]]
name = "base64"
version = "0.21.0"
@ -612,14 +618,14 @@ dependencies = [
[[package]]
name = "dns-lookup"
version = "1.0.8"
version = "2.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "53ecafc952c4528d9b51a458d1a8904b81783feff9fde08ab6ed2545ff396872"
checksum = "8f332aa79f9e9de741ac013237294ef42ce2e9c6394dc7d766725812f1238812"
dependencies = [
"cfg-if",
"libc",
"socket2",
"winapi",
"socket2 0.5.3",
"windows-sys 0.48.0",
]
[[package]]
@ -1481,9 +1487,9 @@ dependencies = [
[[package]]
name = "libc"
version = "0.2.140"
version = "0.2.144"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "99227334921fae1a979cf0bfdfcc6b3e5ce376ef57e16fb6fb3ea2ed6095f80c"
checksum = "2b00cc1c228a6782d0f076e7b232802e0c5689d41bb5df366f2a6b6621cfdfe1"
[[package]]
name = "linux-raw-sys"
@ -1584,10 +1590,11 @@ dependencies = [
[[package]]
name = "minreq"
version = "2.7.0"
version = "2.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "41979ac2a5aa373c6e294b4a67fbe5e428e91a4cd0524376681f2bc6d872399b"
checksum = "cb6c6973f78ef55d0e5fc04fdb8f9ad67c87c9e86bca0ff77b6a3102b0eb36b7"
dependencies = [
"base64 0.12.3",
"log",
"once_cell",
"rustls",
@ -2195,7 +2202,7 @@ version = "1.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d194b56d58803a43635bdc398cd17e383d6f71f9182b9a192c127ca42494a59b"
dependencies = [
"base64",
"base64 0.21.0",
]
[[package]]
@ -2408,6 +2415,16 @@ dependencies = [
"winapi",
]
[[package]]
name = "socket2"
version = "0.5.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2538b18701741680e0322a2302176d3253a35388e2e62f172f64f4f16605f877"
dependencies = [
"libc",
"windows-sys 0.48.0",
]
[[package]]
name = "spin"
version = "0.5.2"
@ -2465,9 +2482,9 @@ dependencies = [
[[package]]
name = "sysinfo"
version = "0.28.3"
version = "0.29.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f69e0d827cce279e61c2f3399eb789271a8f136d8245edef70f06e3c9601a670"
checksum = "02f1dc6930a439cc5d154221b5387d153f8183529b07c19aca24ea31e0a167e1"
dependencies = [
"cfg-if",
"core-foundation-sys",
@ -2951,7 +2968,7 @@ version = "0.44.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9e745dab35a0c4c77aa3ce42d595e13d2003d6902d6b08c9ef5fc326d08da12b"
dependencies = [
"windows-targets",
"windows-targets 0.42.2",
]
[[package]]
@ -2960,13 +2977,13 @@ version = "0.42.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5a3e1820f08b8513f676f7ab6c1f99ff312fb97b553d30ff4dd86f9f15728aa7"
dependencies = [
"windows_aarch64_gnullvm",
"windows_aarch64_msvc",
"windows_i686_gnu",
"windows_i686_msvc",
"windows_x86_64_gnu",
"windows_x86_64_gnullvm",
"windows_x86_64_msvc",
"windows_aarch64_gnullvm 0.42.2",
"windows_aarch64_msvc 0.42.2",
"windows_i686_gnu 0.42.2",
"windows_i686_msvc 0.42.2",
"windows_x86_64_gnu 0.42.2",
"windows_x86_64_gnullvm 0.42.2",
"windows_x86_64_msvc 0.42.2",
]
[[package]]
@ -2975,7 +2992,16 @@ version = "0.45.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "75283be5efb2831d37ea142365f009c02ec203cd29a3ebecbc093d52315b66d0"
dependencies = [
"windows-targets",
"windows-targets 0.42.2",
]
[[package]]
name = "windows-sys"
version = "0.48.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9"
dependencies = [
"windows-targets 0.48.0",
]
[[package]]
@ -2984,13 +3010,28 @@ version = "0.42.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8e5180c00cd44c9b1c88adb3693291f1cd93605ded80c250a75d472756b4d071"
dependencies = [
"windows_aarch64_gnullvm",
"windows_aarch64_msvc",
"windows_i686_gnu",
"windows_i686_msvc",
"windows_x86_64_gnu",
"windows_x86_64_gnullvm",
"windows_x86_64_msvc",
"windows_aarch64_gnullvm 0.42.2",
"windows_aarch64_msvc 0.42.2",
"windows_i686_gnu 0.42.2",
"windows_i686_msvc 0.42.2",
"windows_x86_64_gnu 0.42.2",
"windows_x86_64_gnullvm 0.42.2",
"windows_x86_64_msvc 0.42.2",
]
[[package]]
name = "windows-targets"
version = "0.48.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7b1eb6f0cd7c80c79759c929114ef071b87354ce476d9d94271031c0497adfd5"
dependencies = [
"windows_aarch64_gnullvm 0.48.0",
"windows_aarch64_msvc 0.48.0",
"windows_i686_gnu 0.48.0",
"windows_i686_msvc 0.48.0",
"windows_x86_64_gnu 0.48.0",
"windows_x86_64_gnullvm 0.48.0",
"windows_x86_64_msvc 0.48.0",
]
[[package]]
@ -2999,42 +3040,84 @@ version = "0.42.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "597a5118570b68bc08d8d59125332c54f1ba9d9adeedeef5b99b02ba2b0698f8"
[[package]]
name = "windows_aarch64_gnullvm"
version = "0.48.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "91ae572e1b79dba883e0d315474df7305d12f569b400fcf90581b06062f7e1bc"
[[package]]
name = "windows_aarch64_msvc"
version = "0.42.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e08e8864a60f06ef0d0ff4ba04124db8b0fb3be5776a5cd47641e942e58c4d43"
[[package]]
name = "windows_aarch64_msvc"
version = "0.48.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b2ef27e0d7bdfcfc7b868b317c1d32c641a6fe4629c171b8928c7b08d98d7cf3"
[[package]]
name = "windows_i686_gnu"
version = "0.42.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c61d927d8da41da96a81f029489353e68739737d3beca43145c8afec9a31a84f"
[[package]]
name = "windows_i686_gnu"
version = "0.48.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "622a1962a7db830d6fd0a69683c80a18fda201879f0f447f065a3b7467daa241"
[[package]]
name = "windows_i686_msvc"
version = "0.42.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "44d840b6ec649f480a41c8d80f9c65108b92d89345dd94027bfe06ac444d1060"
[[package]]
name = "windows_i686_msvc"
version = "0.48.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4542c6e364ce21bf45d69fdd2a8e455fa38d316158cfd43b3ac1c5b1b19f8e00"
[[package]]
name = "windows_x86_64_gnu"
version = "0.42.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8de912b8b8feb55c064867cf047dda097f92d51efad5b491dfb98f6bbb70cb36"
[[package]]
name = "windows_x86_64_gnu"
version = "0.48.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ca2b8a661f7628cbd23440e50b05d705db3686f894fc9580820623656af974b1"
[[package]]
name = "windows_x86_64_gnullvm"
version = "0.42.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "26d41b46a36d453748aedef1486d5c7a85db22e56aff34643984ea85514e94a3"
[[package]]
name = "windows_x86_64_gnullvm"
version = "0.48.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7896dbc1f41e08872e9d5e8f8baa8fdd2677f29468c4e156210174edc7f7b953"
[[package]]
name = "windows_x86_64_msvc"
version = "0.42.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9aec5da331524158c6d1a4ac0ab1541149c0b9505fde06423b02f5ef0106b9f0"
[[package]]
name = "windows_x86_64_msvc"
version = "0.48.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1a515f5799fe4961cb532f983ce2b23082366b898e52ffbce459c86f67c8378a"
[[package]]
name = "winnow"
version = "0.3.6"

View file

@ -17,7 +17,7 @@ glib-build-tools = "0.17"
[dependencies.anime-launcher-sdk]
git = "https://github.com/an-anime-team/anime-launcher-sdk"
tag = "1.2.2"
tag = "1.3.0"
features = ["all", "star-rail"]
# path = "../anime-launcher-sdk" # ! for dev purposes only

View file

@ -4,6 +4,7 @@ use relm4::component::*;
use adw::prelude::*;
use anime_launcher_sdk::anime_game_core::prelude::*;
use anime_launcher_sdk::anime_game_core::star_rail::prelude::*;
use crate::i18n::*;

View file

@ -7,6 +7,7 @@ use adw::prelude::*;
use gtk::glib::clone;
use anime_launcher_sdk::anime_game_core::prelude::*;
use anime_launcher_sdk::anime_game_core::star_rail::prelude::*;
use anime_launcher_sdk::config::ConfigExt;
use anime_launcher_sdk::star_rail::config::Config;
@ -147,11 +148,8 @@ impl SimpleAsyncComponent for ComponentVersion {
if let Ok(config) = Config::get() {
// todo
let mut installer = Installer::new(&self.download_uri)
.expect("Failed to create installer instance for this version");
if let Some(temp) = config.launcher.temp {
installer.set_temp_folder(temp);
}
.expect("Failed to create installer instance for this version")
.with_temp_folder(config.launcher.temp.unwrap_or_else(std::env::temp_dir));
self.state = VersionState::Downloading;

View file

@ -19,14 +19,8 @@ use crate::ui::components::*;
use crate::i18n::*;
use crate::*;
fn get_installer(uri: &str, temp: Option<&PathBuf>) -> anyhow::Result<Installer> {
let mut installer = Installer::new(uri)?;
if let Some(temp) = temp {
installer.set_temp_folder(temp);
}
Ok(installer)
fn get_installer(uri: &str, temp: Option<PathBuf>) -> anyhow::Result<Installer> {
Ok(Installer::new(uri)?.with_temp_folder(temp.unwrap_or_else(std::env::temp_dir)))
}
pub struct DownloadComponentsApp {
@ -375,7 +369,7 @@ impl SimpleAsyncComponent for DownloadComponentsApp {
tracing::info!("Installing wine: {}", wine.name);
// Install wine
match get_installer(&wine.uri, config.launcher.temp.as_ref()) {
match get_installer(&wine.uri, config.launcher.temp.clone()) {
Ok(mut installer) => {
// Create wine builds folder
if config.game.wine.builds.exists() {
@ -496,7 +490,7 @@ impl SimpleAsyncComponent for DownloadComponentsApp {
// Install DXVK
tracing::info!("Installing DXVK: {}", dxvk.name);
match get_installer(&dxvk.uri, config.launcher.temp.as_ref()) {
match get_installer(&dxvk.uri, config.launcher.temp.clone()) {
Ok(mut installer) => {
let progress_bar_input = progress_bar_input.clone();
let sender = sender.clone();

View file

@ -5,21 +5,24 @@ use relm4::{
use gtk::glib::clone;
use anime_launcher_sdk::anime_game_core::installer::diff::VersionDiff;
use crate::*;
use crate::i18n::*;
use crate::ui::components::*;
use super::{App, AppMsg};
pub fn download_diff(sender: ComponentSender<App>, progress_bar_input: Sender<ProgressBarMsg>, diff: VersionDiff) {
pub fn download_diff(sender: ComponentSender<App>, progress_bar_input: Sender<ProgressBarMsg>, mut diff: VersionDiff) {
sender.input(AppMsg::SetDownloading(true));
std::thread::spawn(move || {
let config = Config::get().unwrap();
let game_path = config.game.path.for_edition(config.launcher.edition).to_path_buf();
let result = diff.install_to_by(game_path, config.launcher.temp, clone!(@strong sender => move |state| {
if let Some(temp) = config.launcher.temp {
diff = diff.with_temp_folder(temp);
}
let result = diff.install_to(game_path, clone!(@strong sender => move |state| {
match &state {
DiffUpdate::InstallerUpdate(InstallerUpdate::DownloadingError(err)) => {
tracing::error!("Downloading failed: {err}");

View file

@ -316,12 +316,7 @@ impl SimpleComponent for App {
}.into()),
("size", match model.state.as_ref() {
Some(LauncherState::PredownloadAvailable(game)) => {
let size = game.size().unwrap_or((0, 0)).0;
prettify_bytes(size)
}
Some(LauncherState::PredownloadAvailable(game)) => prettify_bytes(game.downloaded_size().unwrap_or(0)),
_ => String::from("?")
}.into())
])),
@ -917,7 +912,7 @@ impl SimpleComponent for App {
progress_bar_input.send(ProgressBarMsg::UpdateCaption(Some(tr("downloading"))));
std::thread::spawn(move || {
let result = game.download_in(&tmp, clone!(@strong progress_bar_input => move |curr, total| {
let result = game.download_to(&tmp, clone!(@strong progress_bar_input => move |curr, total| {
progress_bar_input.send(ProgressBarMsg::UpdateProgress(curr, total));
}));