From 0a505a6562465718858d3e02d7b081d3df637e7e Mon Sep 17 00:00:00 2001 From: Observer KRypt0n_ Date: Fri, 24 Mar 2023 20:36:11 +0200 Subject: [PATCH 01/31] 3.3.0 --- CHANGELOG.md | 5 +++-- Cargo.lock | 2 +- Cargo.toml | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 571ed0d0..985a4b10 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,7 +5,7 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). -## [Unreleased] +## [3.3.0] - 24.03.2023 ### Added @@ -138,7 +138,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
-[unreleased]: https://github.com/an-anime-team/an-anime-game-launcher/compare/3.2.1...next +[unreleased]: https://github.com/an-anime-team/an-anime-game-launcher/compare/3.3.0...next +[3.3.0]: https://github.com/an-anime-team/an-anime-game-launcher/compare/3.2.1...3.3.0 [3.2.1]: https://github.com/an-anime-team/an-anime-game-launcher/compare/3.2.0...3.2.1 [3.2.0]: https://github.com/an-anime-team/an-anime-game-launcher/compare/3.1.5...3.2.0 [3.1.5]: https://github.com/an-anime-team/an-anime-game-launcher/compare/3.1.4...3.1.5 diff --git a/Cargo.lock b/Cargo.lock index 5bf421cd..948eb7b8 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -54,7 +54,7 @@ dependencies = [ [[package]] name = "anime-game-launcher" -version = "3.2.1" +version = "3.3.0" dependencies = [ "anime-launcher-sdk", "anyhow", diff --git a/Cargo.toml b/Cargo.toml index 61c8e2a4..4d7b18fb 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "anime-game-launcher" -version = "3.2.1" +version = "3.3.0" description = "Anime Game launcher" authors = ["Nikita Podvirnyy "] license = "GPL-3.0" From 6a306e98069fb5a00e84d5d7d5f834ce0895a5d2 Mon Sep 17 00:00:00 2001 From: Observer KRypt0n_ Date: Sat, 25 Mar 2023 10:58:44 +0200 Subject: [PATCH 02/31] chore(core): replaced sdk's git submodule by cargo git dependency --- .gitmodules | 3 --- Cargo.lock | 4 +++- Cargo.toml | 2 +- anime-launcher-sdk | 1 - 4 files changed, 4 insertions(+), 6 deletions(-) delete mode 160000 anime-launcher-sdk diff --git a/.gitmodules b/.gitmodules index c332b4a6..e69de29b 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +0,0 @@ -[submodule "anime-launcher-sdk"] - path = anime-launcher-sdk - url = https://github.com/an-anime-team/anime-launcher-sdk diff --git a/Cargo.lock b/Cargo.lock index 948eb7b8..b86711bf 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -31,7 +31,8 @@ dependencies = [ [[package]] name = "anime-game-core" -version = "1.4.5" +version = "1.4.4" +source = "git+https://github.com/an-anime-team/anime-launcher-sdk?tag=0.5.7#f84ad39d86fe436678f2ceedf0861609d54bfd6d" dependencies = [ "anyhow", "bzip2", @@ -77,6 +78,7 @@ dependencies = [ [[package]] name = "anime-launcher-sdk" version = "0.5.7" +source = "git+https://github.com/an-anime-team/anime-launcher-sdk?tag=0.5.7#f84ad39d86fe436678f2ceedf0861609d54bfd6d" dependencies = [ "anime-game-core", "anyhow", diff --git a/Cargo.toml b/Cargo.toml index 4d7b18fb..908baf73 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -22,7 +22,7 @@ adw = { package = "libadwaita", version = "0.3", features = ["v1_2"] } rfd = { version = "0.11", features = ["xdg-portal"], default-features = false } open = "4.0.0" -anime-launcher-sdk = { path = "anime-launcher-sdk" } +anime-launcher-sdk = { git = "https://github.com/an-anime-team/anime-launcher-sdk", tag = "0.5.7" } tracing = "0.1" tracing-subscriber = "0.3" diff --git a/anime-launcher-sdk b/anime-launcher-sdk deleted file mode 160000 index 19ceddca..00000000 --- a/anime-launcher-sdk +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 19ceddca82367514b5c806cfbc94f527ccd75167 From 017f0309225d468915986581c0f9b51b43eb8d52 Mon Sep 17 00:00:00 2001 From: Observer KRypt0n_ Date: Sat, 25 Mar 2023 11:11:10 +0200 Subject: [PATCH 03/31] style: updated sdk dependency style --- Cargo.toml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 908baf73..3f625fe4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -15,6 +15,10 @@ opt-level = "s" [build-dependencies] glib-build-tools = "0.17" +[dependencies.anime-launcher-sdk] +git = "https://github.com/an-anime-team/anime-launcher-sdk" +tag = "0.5.7" + [dependencies] relm4 = { version = "0.6.0-alpha.2", features = ["macros", "libadwaita"] } gtk = { package = "gtk4", version = "0.6", features = ["v4_8"] } @@ -22,8 +26,6 @@ adw = { package = "libadwaita", version = "0.3", features = ["v1_2"] } rfd = { version = "0.11", features = ["xdg-portal"], default-features = false } open = "4.0.0" -anime-launcher-sdk = { git = "https://github.com/an-anime-team/anime-launcher-sdk", tag = "0.5.7" } - tracing = "0.1" tracing-subscriber = "0.3" From 71d454d87cbeee644a1f332ed7fc92f95f907374 Mon Sep 17 00:00:00 2001 From: Observer KRypt0n_ Date: Sat, 25 Mar 2023 13:34:54 +0200 Subject: [PATCH 04/31] feat(ui): small ui fixes --- .gitmodules | 0 src/ui/main/mod.rs | 11 ++++------- src/ui/preferences/general.rs | 2 +- 3 files changed, 5 insertions(+), 8 deletions(-) delete mode 100644 .gitmodules diff --git a/.gitmodules b/.gitmodules deleted file mode 100644 index e69de29b..00000000 diff --git a/src/ui/main/mod.rs b/src/ui/main/mod.rs index 174090d1..3fbf1e57 100644 --- a/src/ui/main/mod.rs +++ b/src/ui/main/mod.rs @@ -387,7 +387,7 @@ impl SimpleComponent for App { }, #[watch] - set_sensitive: match model.state.as_ref() { + set_sensitive: !model.disabled_buttons && match &model.state { Some(LauncherState::GameOutdated { .. }) | Some(LauncherState::VoiceOutdated(_)) => false, @@ -407,7 +407,7 @@ impl SimpleComponent for App { }, #[watch] - set_css_classes: match model.state.as_ref() { + set_css_classes: match &model.state { Some(LauncherState::GameOutdated { .. }) | Some(LauncherState::VoiceOutdated(_)) => &["warning"], @@ -427,7 +427,7 @@ impl SimpleComponent for App { }, #[watch] - set_tooltip_text: Some(&match model.state.as_ref() { + set_tooltip_text: Some(&match &model.state { Some(LauncherState::GameOutdated { .. }) | Some(LauncherState::VoiceOutdated(_)) => tr("main-window--version-outdated-tooltip"), @@ -444,9 +444,6 @@ impl SimpleComponent for App { _ => String::new() }), - #[watch] - set_sensitive: !model.disabled_buttons, - set_hexpand: false, set_width_request: 200, @@ -668,7 +665,7 @@ impl SimpleComponent for App { sender.input(AppMsg::SetLoadingStatus(Some(Some(tr("downloading-background-picture"))))); if let Err(err) = crate::background::download_background() { - tracing::error!("Failed to download background picture"); + tracing::error!("Failed to download background picture: {err}"); sender.input(AppMsg::Toast { title: tr("background-downloading-failed"), diff --git a/src/ui/preferences/general.rs b/src/ui/preferences/general.rs index 79b0cced..c44e97c5 100644 --- a/src/ui/preferences/general.rs +++ b/src/ui/preferences/general.rs @@ -346,7 +346,7 @@ impl SimpleAsyncComponent for GeneralApp { VersionDiff::NotInstalled { .. } => &[] } - None => &["success"] + None => &[] }, #[watch] From f1b10c6bea05f876c5a26fb2885a17f0606ebef6 Mon Sep 17 00:00:00 2001 From: Observer KRypt0n_ Date: Sat, 25 Mar 2023 13:37:03 +0200 Subject: [PATCH 05/31] feat: first run: made default game folder name depend on game edition --- src/ui/first_run/default_paths.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/ui/first_run/default_paths.rs b/src/ui/first_run/default_paths.rs index 3c5d7a61..d2543d9e 100644 --- a/src/ui/first_run/default_paths.rs +++ b/src/ui/first_run/default_paths.rs @@ -264,12 +264,16 @@ impl SimpleAsyncComponent for DefaultPathsApp { self.runners = result.join("runners"); self.dxvks = result.join("dxvks"); self.prefix = result.join("prefix"); - self.game = result.join("Genshin Impact"); // TODO: change it based on GameEdition self.fps_unlocker = result.join("fps-unlocker"); self.components = result.join("components"); self.patch = result.join("patch"); self.temp = result.clone(); + self.game = result.join(match CONFIG.launcher.edition.into() { + GameEdition::Global => concat!("Ge", "nshi", "n Imp", "act"), + GameEdition::China => concat!("Yu", "anS", "hen") + }); + self.launcher = result; } From 5a4eeb563689b761500bf9f8ecae3c1fc3e4d012 Mon Sep 17 00:00:00 2001 From: Observer KRypt0n_ Date: Sat, 25 Mar 2023 14:00:20 +0200 Subject: [PATCH 06/31] feat: improved game repairing feature Added support for xlua patch, stopped launcher from repairing one forgotten anti-cheat related file --- src/ui/main/repair_game.rs | 39 +++++++++++++++++++++++++++++++------- 1 file changed, 32 insertions(+), 7 deletions(-) diff --git a/src/ui/main/repair_game.rs b/src/ui/main/repair_game.rs index d48719b9..dcf3a7c7 100644 --- a/src/ui/main/repair_game.rs +++ b/src/ui/main/repair_game.rs @@ -104,25 +104,46 @@ pub fn repair_game(sender: ComponentSender, progress_bar_input: Sender bool { - for part in ["UnityPlayer.dll", "xlua.dll", "crashreport.exe", "upload_crash.exe", "vulkan-1.dll"] { + fn should_ignore(path: &Path, player_patch: bool, xlua_patch: bool) -> bool { + // Files managed by launch.bat file + for part in ["crashreport.exe", "upload_crash.exe"] { if path.ends_with(part) { return true; } } + // UnityPlayer patch related files + if player_patch { + for part in ["UnityPlayer.dll", "vulkan-1.dll"] { + if path.ends_with(part) { + return true; + } + } + } + + // Xlua patch related files + if xlua_patch { + for part in ["xlua.dll", "mhypbase.dll"] { + if path.ends_with(part) { + return true; + } + } + } + false } for (i, file) in broken.into_iter().enumerate() { - if !is_patch_applied || !should_ignore(&file.path) { - tracing::debug!("Repairing: {}", file.path.to_string_lossy()); + if !should_ignore(&file.path, player_patch, xlua_patch) { + tracing::debug!("Repairing file: {}", file.path.to_string_lossy()); if let Err(err) = file.repair(&config.game.path) { sender.input(AppMsg::Toast { @@ -134,6 +155,10 @@ pub fn repair_game(sender: ComponentSender, progress_bar_input: Sender Date: Wed, 29 Mar 2023 18:45:31 +0200 Subject: [PATCH 07/31] feat(ui): added initial installation migration window support --- Cargo.toml | 2 + src/ui/first_run/main.rs | 4 +- src/ui/main/mod.rs | 6 +-- src/ui/migrate_installation.rs | 71 ++++++++++++++++++++++++++++++++++ src/ui/mod.rs | 1 + src/ui/preferences/general.rs | 22 +++++++++++ 6 files changed, 101 insertions(+), 5 deletions(-) create mode 100644 src/ui/migrate_installation.rs diff --git a/Cargo.toml b/Cargo.toml index 3f625fe4..fd2c196e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -19,6 +19,8 @@ glib-build-tools = "0.17" git = "https://github.com/an-anime-team/anime-launcher-sdk" tag = "0.5.7" +# path = "../anime-launcher-sdk" # ! for dev purposes only + [dependencies] relm4 = { version = "0.6.0-alpha.2", features = ["macros", "libadwaita"] } gtk = { package = "gtk4", version = "0.6", features = ["v4_8"] } diff --git a/src/ui/first_run/main.rs b/src/ui/first_run/main.rs index c2d0fc25..03863b4f 100644 --- a/src/ui/first_run/main.rs +++ b/src/ui/first_run/main.rs @@ -17,7 +17,7 @@ use super::select_voiceovers::*; use super::download_components::*; use super::finish::*; -pub static mut MAIN_WINDOW: Option = None; +pub static mut MAIN_WINDOW: Option = None; // TODO: add special page for launcher style selection @@ -61,7 +61,7 @@ impl SimpleComponent for FirstRunApp { type Output = (); view! { - window = adw::Window { + window = adw::ApplicationWindow { set_default_size: (780, 560), #[watch] diff --git a/src/ui/main/mod.rs b/src/ui/main/mod.rs index 3fbf1e57..4fb1b311 100644 --- a/src/ui/main/mod.rs +++ b/src/ui/main/mod.rs @@ -38,9 +38,9 @@ relm4::new_stateless_action!(WishUrl, WindowActionGroup, "wish_url"); relm4::new_stateless_action!(About, WindowActionGroup, "about"); -static mut MAIN_WINDOW: Option = None; -static mut PREFERENCES_WINDOW: Option> = None; -static mut ABOUT_DIALOG: Option> = None; +pub static mut MAIN_WINDOW: Option = None; +pub static mut PREFERENCES_WINDOW: Option> = None; +pub static mut ABOUT_DIALOG: Option> = None; pub struct App { progress_bar: AsyncController, diff --git a/src/ui/migrate_installation.rs b/src/ui/migrate_installation.rs new file mode 100644 index 00000000..76187a29 --- /dev/null +++ b/src/ui/migrate_installation.rs @@ -0,0 +1,71 @@ +use relm4::prelude::*; +use relm4::component::*; + +use gtk::prelude::*; +use adw::prelude::*; + +use crate::*; + +use super::first_run::default_paths::DefaultPathsApp; + +pub struct MigrateInstallationApp { + default_paths: AsyncController, +} + +#[derive(Debug)] +pub enum MigrateInstallationAppMsg { + Migrate +} + +#[relm4::component(pub)] +impl SimpleComponent for MigrateInstallationApp { + type Init = (); + type Input = MigrateInstallationAppMsg; + type Output = (); + + view! { + adw::Window { + set_default_size: (780, 560), + set_modal: true, + + #[watch] + set_title: Some("Migrate installation"), + + gtk::Box { + set_orientation: gtk::Orientation::Vertical, + + adw::HeaderBar { + add_css_class: "flat" + }, + + append = model.default_paths.widget(), + } + } + } + + fn init( + _init: Self::Init, + root: &Self::Root, + sender: ComponentSender, + ) -> ComponentParts { + tracing::info!("Initializing migration window"); + + let model = Self { + default_paths: DefaultPathsApp::builder() + .launch(()) + .detach() + }; + + let widgets = view_output!(); + + ComponentParts { model, widgets } + } + + fn update(&mut self, msg: Self::Input, _sender: ComponentSender) { + match msg { + MigrateInstallationAppMsg::Migrate => { + todo!() + } + } + } +} diff --git a/src/ui/mod.rs b/src/ui/mod.rs index e5365c9a..eae65455 100644 --- a/src/ui/mod.rs +++ b/src/ui/mod.rs @@ -3,3 +3,4 @@ pub mod about; pub mod preferences; pub mod components; pub mod first_run; +pub mod migrate_installation; diff --git a/src/ui/preferences/general.rs b/src/ui/preferences/general.rs index c44e97c5..a16412cf 100644 --- a/src/ui/preferences/general.rs +++ b/src/ui/preferences/general.rs @@ -17,6 +17,7 @@ use anime_launcher_sdk::components::wine::WincompatlibWine; use anime_launcher_sdk::wincompatlib::prelude::*; use super::main::PreferencesAppMsg; +use crate::ui::migrate_installation::MigrateInstallationApp; use crate::ui::components; use crate::ui::components::*; use crate::i18n::*; @@ -102,6 +103,7 @@ impl AsyncFactoryComponent for VoicePackageComponent { pub struct GeneralApp { voice_packages: AsyncFactoryVecDeque, + migrate_installation: Controller, wine_components: AsyncController>, dxvk_components: AsyncController>, @@ -145,6 +147,7 @@ pub enum GeneralAppMsg { RemoveVoicePackage(DynamicIndex), SetVoicePackageSensitivity(DynamicIndex, bool), + OpenMigrateInstallation, RepairGame, UpdateLauncherStyle(LauncherStyle), @@ -307,6 +310,13 @@ impl SimpleAsyncComponent for GeneralApp { set_spacing: 8, set_margin_top: 16, + gtk::Button { + set_label: "Migrate installation", + set_tooltip_text: Some("Open special window where you can change your game installation folder"), + + connect_clicked => GeneralAppMsg::OpenMigrateInstallation + }, + gtk::Button { set_label: &tr("repair-game"), @@ -674,6 +684,10 @@ impl SimpleAsyncComponent for GeneralApp { let mut model = Self { voice_packages: AsyncFactoryVecDeque::new(adw::ExpanderRow::new(), sender.input_sender()), + migrate_installation: MigrateInstallationApp::builder() + .launch(()) + .detach(), + wine_components: ComponentsList::builder() .launch(ComponentsListInit { pattern: ComponentsListPattern { @@ -839,6 +853,14 @@ impl SimpleAsyncComponent for GeneralApp { } } + GeneralAppMsg::OpenMigrateInstallation => unsafe { + if let Some(window) = crate::ui::main::PREFERENCES_WINDOW.as_ref() { + self.migrate_installation.widget().set_transient_for(Some(window.widget())); + } + + self.migrate_installation.widget().show(); + } + #[allow(unused_must_use)] GeneralAppMsg::RepairGame => { sender.output(Self::Output::RepairGame); From 02323bad4fac8e1bb87e1ec1c3d1051304b16e07 Mon Sep 17 00:00:00 2001 From: Observer KRypt0n_ Date: Fri, 31 Mar 2023 10:21:06 +0200 Subject: [PATCH 08/31] feat(core): implemented core 0.5.8 --- Cargo.lock | 247 ++++++++++++++++++++++----------------------- Cargo.toml | 2 +- src/background.rs | 6 +- src/main.rs | 4 +- src/ui/about.rs | 14 +-- src/ui/main/mod.rs | 5 +- 6 files changed, 133 insertions(+), 145 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index b86711bf..c7f10f43 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2,6 +2,15 @@ # It is not intended for manual editing. version = 3 +[[package]] +name = "addr2line" +version = "0.19.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a76fd60b23679b7d19bd066031410fb7e458ccc5e958eb5c325888ce4baedc97" +dependencies = [ + "gimli", +] + [[package]] name = "adler" version = "1.0.2" @@ -31,18 +40,18 @@ dependencies = [ [[package]] name = "anime-game-core" -version = "1.4.4" -source = "git+https://github.com/an-anime-team/anime-launcher-sdk?tag=0.5.7#f84ad39d86fe436678f2ceedf0861609d54bfd6d" +version = "1.5.0" +source = "git+https://github.com/an-anime-team/anime-game-core?tag=1.5.0#3d6f5e48168d7daaa5bf4b6388732564947dbe45" dependencies = [ "anyhow", "bzip2", "cached", - "curl", "flate2", "fs_extra", "kinda-virtual-fs", "lazy_static", "md-5", + "minreq", "serde", "serde_json", "sysinfo", @@ -77,13 +86,12 @@ dependencies = [ [[package]] name = "anime-launcher-sdk" -version = "0.5.7" -source = "git+https://github.com/an-anime-team/anime-launcher-sdk?tag=0.5.7#f84ad39d86fe436678f2ceedf0861609d54bfd6d" +version = "0.5.8" +source = "git+https://github.com/an-anime-team/anime-launcher-sdk?tag=0.5.8#7aa54126c8263efc697feafd3c902d783dcf9bb4" dependencies = [ "anime-game-core", "anyhow", "cached", - "dirs 5.0.0", "discord-rich-presence", "enum-ordinalize", "lazy_static", @@ -99,6 +107,9 @@ name = "anyhow" version = "1.0.70" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7de8ce5e0f9f8d88245311066a578d72b7af3e7088f32783804676302df237e4" +dependencies = [ + "backtrace", +] [[package]] name = "arc-swap" @@ -225,11 +236,26 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" +[[package]] +name = "backtrace" +version = "0.3.67" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "233d376d6d185f2a3093e58f283f60f880315b6c60075b01f36b3b85154564ca" +dependencies = [ + "addr2line", + "cc", + "cfg-if", + "libc", + "miniz_oxide", + "object", + "rustc-demangle", +] + [[package]] name = "base64" -version = "0.13.1" +version = "0.21.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e1b586273c5702936fe7b7d6896644d8be71e6314cfe09d3167c95f712589e8" +checksum = "a4a4ddaa51a5bc52a6948f74c06d20aaaddb71924eab79b8c97a8c556e942d6a" [[package]] name = "base64ct" @@ -412,6 +438,16 @@ version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "245097e9a4535ee1e3e3931fcfcd55a796a44c643e8596ff6566d68f09b87bbc" +[[package]] +name = "core-foundation" +version = "0.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "194a7a9e6de53fa55116934067c844d9d749312f75c6f6d0980e8c252f8c2146" +dependencies = [ + "core-foundation-sys", + "libc", +] + [[package]] name = "core-foundation-sys" version = "0.8.3" @@ -489,37 +525,6 @@ dependencies = [ "typenum", ] -[[package]] -name = "curl" -version = "0.4.44" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "509bd11746c7ac09ebd19f0b17782eae80aadee26237658a6b4808afb5c11a22" -dependencies = [ - "curl-sys", - "libc", - "openssl-probe", - "openssl-sys", - "schannel", - "socket2", - "winapi", -] - -[[package]] -name = "curl-sys" -version = "0.4.60+curl-7.88.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "717abe2cb465a5da6ce06617388a3980c9a2844196734bec8ccb8e575250f13f" -dependencies = [ - "cc", - "libc", - "libz-sys", - "openssl-sys", - "pkg-config", - "rustls-ffi", - "vcpkg", - "winapi", -] - [[package]] name = "darling" version = "0.14.4" @@ -583,16 +588,7 @@ version = "4.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ca3aa72a6f96ea37bbc5aa912f6788242832f75369bdfdadcb0e38423f100059" dependencies = [ - "dirs-sys 0.3.7", -] - -[[package]] -name = "dirs" -version = "5.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dece029acd3353e3a58ac2e3eb3c8d6c35827a892edc6cc4138ef9c33df46ecd" -dependencies = [ - "dirs-sys 0.4.0", + "dirs-sys", ] [[package]] @@ -606,17 +602,6 @@ dependencies = [ "winapi", ] -[[package]] -name = "dirs-sys" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "04414300db88f70d74c5ff54e50f9e1d1737d9a5b90f53fcf2e95ca2a9ab554b" -dependencies = [ - "libc", - "redox_users", - "windows-sys 0.45.0", -] - [[package]] name = "discord-rich-presence" version = "0.2.3" @@ -1062,6 +1047,12 @@ dependencies = [ "wasm-bindgen", ] +[[package]] +name = "gimli" +version = "0.27.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ad0a93d233ebf96623465aad4046a8d3aa4da22d4f4beba5388838c8a434bbb4" + [[package]] name = "gio" version = "0.17.4" @@ -1481,18 +1472,6 @@ version = "0.2.140" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "99227334921fae1a979cf0bfdfcc6b3e5ce376ef57e16fb6fb3ea2ed6095f80c" -[[package]] -name = "libz-sys" -version = "1.1.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9702761c3935f8cc2f101793272e202c72b99da8f4224a19ddcf1279a6450bbf" -dependencies = [ - "cc", - "libc", - "pkg-config", - "vcpkg", -] - [[package]] name = "linux-raw-sys" version = "0.1.4" @@ -1590,6 +1569,22 @@ dependencies = [ "adler", ] +[[package]] +name = "minreq" +version = "2.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "41979ac2a5aa373c6e294b4a67fbe5e428e91a4cd0524376681f2bc6d872399b" +dependencies = [ + "log", + "once_cell", + "rustls", + "rustls-native-certs", + "serde", + "serde_json", + "webpki", + "webpki-roots", +] + [[package]] name = "nanorand" version = "0.7.0" @@ -1671,27 +1666,6 @@ dependencies = [ "libc", ] -[[package]] -name = "num_enum" -version = "0.5.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1f646caf906c20226733ed5b1374287eb97e3c2a5c227ce668c1f2ce20ae57c9" -dependencies = [ - "num_enum_derive", -] - -[[package]] -name = "num_enum_derive" -version = "0.5.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dcbff9bc912032c62bf65ef1d5aea88983b420f4f839db1e9b0c281a25c9c799" -dependencies = [ - "proc-macro-crate", - "proc-macro2", - "quote", - "syn 1.0.109", -] - [[package]] name = "objc" version = "0.2.7" @@ -1721,6 +1695,15 @@ dependencies = [ "objc", ] +[[package]] +name = "object" +version = "0.30.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ea86265d3d3dcb6a27fc51bd29a4bf387fae9d2986b823079d4986af253eb439" +dependencies = [ + "memchr", +] + [[package]] name = "once_cell" version = "1.17.1" @@ -1748,19 +1731,6 @@ version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" -[[package]] -name = "openssl-sys" -version = "0.9.81" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "176be2629957c157240f68f61f2d0053ad3a4ecfdd9ebf1e6521d18d9635cf67" -dependencies = [ - "autocfg", - "cc", - "libc", - "pkg-config", - "vcpkg", -] - [[package]] name = "ordered-stream" version = "0.0.1" @@ -2147,6 +2117,12 @@ dependencies = [ "winapi", ] +[[package]] +name = "rustc-demangle" +version = "0.1.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d4a36c42d1873f9a77c53bde094f9664d9891bc604a45b4798fd2c389ed12e5b" + [[package]] name = "rustc-hash" version = "1.1.0" @@ -2189,25 +2165,22 @@ dependencies = [ ] [[package]] -name = "rustls-ffi" -version = "0.8.2" +name = "rustls-native-certs" +version = "0.6.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9da52707cca59e6eef8a78f3ad8d04024254a168ed1b41eb4dfa9616eace781a" +checksum = "0167bac7a9f490495f3c33013e7722b53cb087ecbe082fb0c6387c96f634ea50" dependencies = [ - "libc", - "log", - "num_enum", - "rustls", + "openssl-probe", "rustls-pemfile", - "sct", - "webpki", + "schannel", + "security-framework", ] [[package]] name = "rustls-pemfile" -version = "0.2.1" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5eebeaeb360c87bfb72e84abdb3447159c0eaececf1bef2aecd65a8be949d1c9" +checksum = "d194b56d58803a43635bdc398cd17e383d6f71f9182b9a192c127ca42494a59b" dependencies = [ "base64", ] @@ -2252,6 +2225,29 @@ dependencies = [ "untrusted", ] +[[package]] +name = "security-framework" +version = "2.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a332be01508d814fed64bf28f798a146d73792121129962fdf335bb3c49a4254" +dependencies = [ + "bitflags", + "core-foundation", + "core-foundation-sys", + "libc", + "security-framework-sys", +] + +[[package]] +name = "security-framework-sys" +version = "2.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "31c9bb296072e961fcbd8853511dd39c2d8be2deb1e17c6860b1d30732b323b4" +dependencies = [ + "core-foundation-sys", + "libc", +] + [[package]] name = "self_cell" version = "0.10.2" @@ -2770,12 +2766,6 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "830b7e5d4d90034032940e4ace0d9a9a057e7a45cd94e6c007832e39edb82f6d" -[[package]] -name = "vcpkg" -version = "0.2.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426" - [[package]] name = "version-compare" version = "0.1.1" @@ -2896,6 +2886,15 @@ dependencies = [ "untrusted", ] +[[package]] +name = "webpki-roots" +version = "0.22.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6c71e40d7d2c34a5106301fb632274ca37242cd0c9d3e64dbece371a40a2d87" +dependencies = [ + "webpki", +] + [[package]] name = "winapi" version = "0.3.9" @@ -3075,7 +3074,7 @@ dependencies = [ "async-trait", "byteorder", "derivative", - "dirs 4.0.0", + "dirs", "enumflags2", "event-listener", "futures-core", diff --git a/Cargo.toml b/Cargo.toml index fd2c196e..a8abe822 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -17,7 +17,7 @@ glib-build-tools = "0.17" [dependencies.anime-launcher-sdk] git = "https://github.com/an-anime-team/anime-launcher-sdk" -tag = "0.5.7" +tag = "0.5.8" # path = "../anime-launcher-sdk" # ! for dev purposes only diff --git a/src/background.rs b/src/background.rs index 5c334b82..3c76e4a3 100644 --- a/src/background.rs +++ b/src/background.rs @@ -1,5 +1,5 @@ use anime_launcher_sdk::anime_game_core::installer::downloader::Downloader; -use anime_launcher_sdk::anime_game_core::curl::fetch; +use anime_launcher_sdk::anime_game_core::minreq; use md5::{Md5, Digest}; @@ -17,7 +17,7 @@ pub fn get_uri() -> String { #[cached::proc_macro::cached(result)] pub fn get_background_info() -> anyhow::Result { - let json = serde_json::from_slice::(&fetch(get_uri(), None)?.get_body()?)?; + let json = serde_json::from_slice::(minreq::get(get_uri()).send()?.as_bytes())?; let uri = match json["data"]["adv"]["background"].as_str() { Some(uri) => uri.to_owned(), @@ -60,7 +60,7 @@ pub fn download_background() -> anyhow::Result<()> { downloader.continue_downloading = false; - if let Err(err) = downloader.download_to(crate::BACKGROUND_FILE.as_path(), |_, _| {}) { + if let Err(err) = downloader.download(crate::BACKGROUND_FILE.as_path(), |_, _| {}) { anyhow::bail!(err); } diff --git a/src/main.rs b/src/main.rs index aa461563..95eb775b 100644 --- a/src/main.rs +++ b/src/main.rs @@ -40,7 +40,7 @@ lazy_static::lazy_static! { pub static ref GAME: Game = Game::new(&CONFIG.game.path); /// Path to launcher folder. Standard is `$HOME/.local/share/anime-game-launcher` - pub static ref LAUNCHER_FOLDER: PathBuf = launcher_dir().unwrap_or_default(); + pub static ref LAUNCHER_FOLDER: PathBuf = launcher_dir().expect("Failed to get launcher folder"); /// Path to `debug.log` file. Standard is `$HOME/.local/share/anime-game-launcher/debug.log` pub static ref DEBUG_FILE: PathBuf = LAUNCHER_FOLDER.join("debug.log"); @@ -160,7 +160,7 @@ fn main() { ", BACKGROUND_FILE.to_string_lossy())); // Set game edition - genshin::set_game_edition(CONFIG.launcher.edition.into()); + GameEdition::from(CONFIG.launcher.edition).select(); // Set UI language let lang = CONFIG.launcher.language.parse().expect("Wrong language format used in config"); diff --git a/src/ui/about.rs b/src/ui/about.rs index 7446fd2e..66153041 100644 --- a/src/ui/about.rs +++ b/src/ui/about.rs @@ -1,20 +1,11 @@ use relm4::prelude::*; - use gtk::prelude::*; use anime_launcher_sdk::VERSION as SDK_VERSION; - -use anime_launcher_sdk::anime_game_core::{ - VERSION as CORE_VERSION, - curl_sys -}; +use anime_launcher_sdk::anime_game_core::VERSION as CORE_VERSION; use crate::*; -lazy_static::lazy_static! { - static ref CURL_INFO: curl_sys::Version = curl_sys::Version::get(); -} - #[derive(Debug)] pub struct AboutDialog { visible: bool @@ -81,9 +72,6 @@ impl SimpleComponent for AboutDialog { format!("Anime Launcher SDK: {SDK_VERSION}"), format!("Anime Game Core: {CORE_VERSION}"), String::new(), - format!("curl: {}", CURL_INFO.version()), - format!("SSL: {}", CURL_INFO.ssl_version().unwrap_or("?")), - String::new(), format!("GTK: {}.{}.{}", gtk::major_version(), gtk::minor_version(), gtk::micro_version()), format!("libadwaita: {}.{}.{}", adw::major_version(), adw::minor_version(), adw::micro_version()), format!("pango: {}", gtk::pango::version_string()), diff --git a/src/ui/main/mod.rs b/src/ui/main/mod.rs index 4fb1b311..26931af4 100644 --- a/src/ui/main/mod.rs +++ b/src/ui/main/mod.rs @@ -20,6 +20,7 @@ mod launch; use anime_launcher_sdk::config::launcher::LauncherStyle; use anime_launcher_sdk::states::LauncherState; use anime_launcher_sdk::components::loader::ComponentsLoader; +use anime_launcher_sdk::anime_game_core::genshin::consts::GameEdition; use crate::*; use crate::i18n::*; @@ -564,7 +565,7 @@ impl SimpleComponent for App { }))); group.add_action::(&RelmAction::new_stateless(clone!(@strong sender => move |_| { - if let Some(file) = anime_launcher_sdk::consts::config_file() { + if let Ok(file) = anime_launcher_sdk::consts::config_file() { if let Err(err) = open::that(file) { sender.input(AppMsg::Toast { title: tr("config-file-opening-error"), @@ -590,7 +591,7 @@ impl SimpleComponent for App { group.add_action::(&RelmAction::new_stateless(clone!(@strong sender => move |_| { std::thread::spawn(clone!(@strong sender => move || { let web_cache = CONFIG.game.path - .join(unsafe { anime_launcher_sdk::anime_game_core::genshin::consts::DATA_FOLDER_NAME }) + .join(GameEdition::selected().data_folder()) .join("webCaches/Cache/Cache_Data/data_2"); if !web_cache.exists() { From b20df574bf7f0d481621f8c16d686fe156ec7e27 Mon Sep 17 00:00:00 2001 From: Observer KRypt0n_ Date: Thu, 6 Apr 2023 19:37:30 +0200 Subject: [PATCH 09/31] docs: updated changelog, added it to about window --- CHANGELOG.md | 8 ++++++++ src/ui/about.rs | 17 ++++++++++++++--- 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 985a4b10..22d51428 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,14 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [Unreleased] + +### Changed + +- Made default game folder name depend on game edition +- Improved game repairing feature +- Replaced `curl` dependency by native code + ## [3.3.0] - 24.03.2023 ### Added diff --git a/src/ui/about.rs b/src/ui/about.rs index 66153041..7a23de14 100644 --- a/src/ui/about.rs +++ b/src/ui/about.rs @@ -1,6 +1,7 @@ use relm4::prelude::*; use gtk::prelude::*; +use crate::APP_VERSION; use anime_launcher_sdk::VERSION as SDK_VERSION; use anime_launcher_sdk::anime_game_core::VERSION as CORE_VERSION; @@ -35,12 +36,12 @@ impl SimpleComponent for AboutDialog { set_version: &{ // Debug build & build's version doesn't contain any suffix (-dev, -beta, etc) - if crate::APP_DEBUG && !crate::APP_VERSION.contains('-') { - format!("{}-dev", crate::APP_VERSION) + if crate::APP_DEBUG && !APP_VERSION.contains('-') { + format!("{APP_VERSION}-dev") } else { - crate::APP_VERSION.to_string() + APP_VERSION.to_string() } }, @@ -78,6 +79,16 @@ impl SimpleComponent for AboutDialog { format!("cairo: {}", gtk::cairo::version_string()), ].join("\n"), + set_release_notes_version: APP_VERSION, + set_release_notes: &[ + "

Changed

", + "
    ", + "
  • Made default game folder name depend on game edition
  • ", + "
  • Improved game repairing feature
  • ", + "
  • Replaced curl dependency by native code
  • ", + "
", + ].join("\n"), + set_modal: true, set_hide_on_close: true, From d7a46b25da27710f5bd716e34497ff6aaaa21367 Mon Sep 17 00:00:00 2001 From: Observer KRypt0n_ Date: Thu, 6 Apr 2023 22:09:36 +0200 Subject: [PATCH 10/31] feat: added environment emulation support This experimental feature generates special configuration file which game interprets as different environments. With this, for example, you can access google payment methods --- Cargo.lock | 8 +++---- Cargo.toml | 2 +- src/ui/preferences/general.rs | 40 ++++++++++++++++++++++++++++++++--- 3 files changed, 42 insertions(+), 8 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index c7f10f43..9a7519b0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -40,8 +40,8 @@ dependencies = [ [[package]] name = "anime-game-core" -version = "1.5.0" -source = "git+https://github.com/an-anime-team/anime-game-core?tag=1.5.0#3d6f5e48168d7daaa5bf4b6388732564947dbe45" +version = "1.5.1" +source = "git+https://github.com/an-anime-team/anime-game-core?tag=1.5.1#4af7a14fc7e86d40cd97a7beb448a6d593a7d43d" dependencies = [ "anyhow", "bzip2", @@ -86,8 +86,8 @@ dependencies = [ [[package]] name = "anime-launcher-sdk" -version = "0.5.8" -source = "git+https://github.com/an-anime-team/anime-launcher-sdk?tag=0.5.8#7aa54126c8263efc697feafd3c902d783dcf9bb4" +version = "0.5.9" +source = "git+https://github.com/an-anime-team/anime-launcher-sdk?tag=0.5.9#c38fc3206a4ffa2aa1c6517a8570ea0cd92daecb" dependencies = [ "anime-game-core", "anyhow", diff --git a/Cargo.toml b/Cargo.toml index a8abe822..3ef14335 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -17,7 +17,7 @@ glib-build-tools = "0.17" [dependencies.anime-launcher-sdk] git = "https://github.com/an-anime-team/anime-launcher-sdk" -tag = "0.5.8" +tag = "0.5.9" # path = "../anime-launcher-sdk" # ! for dev purposes only diff --git a/src/ui/preferences/general.rs b/src/ui/preferences/general.rs index a16412cf..b22976a6 100644 --- a/src/ui/preferences/general.rs +++ b/src/ui/preferences/general.rs @@ -9,12 +9,13 @@ use relm4::factory::{ use gtk::prelude::*; use adw::prelude::*; +use anime_launcher_sdk::anime_game_core::prelude::*; +use anime_launcher_sdk::wincompatlib::prelude::*; use anime_launcher_sdk::config; use anime_launcher_sdk::config::launcher::LauncherStyle; -use anime_launcher_sdk::anime_game_core::prelude::*; use anime_launcher_sdk::components::*; use anime_launcher_sdk::components::wine::WincompatlibWine; -use anime_launcher_sdk::wincompatlib::prelude::*; +use anime_launcher_sdk::env_emulation::Environment; use super::main::PreferencesAppMsg; use crate::ui::migrate_installation::MigrateInstallationApp; @@ -302,7 +303,40 @@ impl SimpleAsyncComponent for GeneralApp { #[local_ref] voice_packages -> adw::ExpanderRow { - set_title: &tr("game-voiceovers") + set_title: &tr("game-voiceovers"), + set_subtitle: "List of downloaded game voiceovers. You can select them in the game settings" + }, + + adw::ComboRow { + set_title: "Environment emulation", + set_subtitle: "Experimental feature. Emulate game environment to get specific features like additional payment methods", + + set_model: Some(>k::StringList::new(&[ + "PC", + "Android" + ])), + + set_selected: match CONFIG.launcher.environment { + Environment::PC => 0, + Environment::Android => 1, + + _ => unreachable!() + }, + + connect_selected_notify => |row| { + if is_ready() { + if let Ok(mut config) = config::get() { + config.launcher.environment = match row.selected() { + 0 => Environment::PC, + 1 => Environment::Android, + + _ => unreachable!() + }; + + config::update(config); + } + } + } }, gtk::Box { From 7fb37d925298775f41bdc347c9b350cc6c73ed91 Mon Sep 17 00:00:00 2001 From: Observer KRypt0n_ Date: Thu, 6 Apr 2023 22:13:40 +0200 Subject: [PATCH 11/31] docs: updated changelog --- CHANGELOG.md | 4 ++++ src/ui/about.rs | 7 +++++++ 2 files changed, 11 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 22d51428..aa3c64b2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +### Added + +- Added environment emulation feature + ### Changed - Made default game folder name depend on game edition diff --git a/src/ui/about.rs b/src/ui/about.rs index 7a23de14..c896f05a 100644 --- a/src/ui/about.rs +++ b/src/ui/about.rs @@ -81,7 +81,14 @@ impl SimpleComponent for AboutDialog { set_release_notes_version: APP_VERSION, set_release_notes: &[ + "

Added

", + + "
    ", + "
  • Added environment emulation feature
  • ", + "
", + "

Changed

", + "
    ", "
  • Made default game folder name depend on game edition
  • ", "
  • Improved game repairing feature
  • ", From 487fdd79ee8bf4f3f5f01cc857656b21c2089caf Mon Sep 17 00:00:00 2001 From: Observer KRypt0n_ Date: Thu, 6 Apr 2023 23:16:24 +0200 Subject: [PATCH 12/31] feat(ui): used dxvk component's title field --- Cargo.lock | 4 ++-- Cargo.toml | 2 +- src/ui/components/mod.rs | 12 ++++++++---- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 9a7519b0..9a16cd1c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -86,8 +86,8 @@ dependencies = [ [[package]] name = "anime-launcher-sdk" -version = "0.5.9" -source = "git+https://github.com/an-anime-team/anime-launcher-sdk?tag=0.5.9#c38fc3206a4ffa2aa1c6517a8570ea0cd92daecb" +version = "0.5.10" +source = "git+https://github.com/an-anime-team/anime-launcher-sdk?tag=0.5.10#186aa204d6a87a26198a00c9fb59e0a313f68227" dependencies = [ "anime-game-core", "anyhow", diff --git a/Cargo.toml b/Cargo.toml index 3ef14335..35e28d45 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -17,7 +17,7 @@ glib-build-tools = "0.17" [dependencies.anime-launcher-sdk] git = "https://github.com/an-anime-team/anime-launcher-sdk" -tag = "0.5.9" +tag = "0.5.10" # path = "../anime-launcher-sdk" # ! for dev purposes only diff --git a/src/ui/components/mod.rs b/src/ui/components/mod.rs index 8daae2fb..09c418b6 100644 --- a/src/ui/components/mod.rs +++ b/src/ui/components/mod.rs @@ -25,6 +25,7 @@ pub struct ComponentsListGroup { } impl From for ComponentsListGroup { + #[inline] fn from(group: wine::Group) -> Self { Self { title: group.title, @@ -34,6 +35,7 @@ impl From for ComponentsListGroup { } impl From for ComponentsListGroup { + #[inline] fn from(group: dxvk::Group) -> Self { Self { title: group.title, @@ -51,23 +53,25 @@ pub struct ComponentsListVersion { } impl From for ComponentsListVersion { + #[inline] fn from(version: wine::Version) -> Self { Self { name: version.name, title: version.title, uri: version.uri, - recommended: true // FIXME + recommended: true } } } impl From for ComponentsListVersion { + #[inline] fn from(version: dxvk::Version) -> Self { Self { - name: version.name.clone(), - title: version.name, + name: version.name, + title: version.title, uri: version.uri, - recommended: true // FIXME + recommended: true } } } From 941851c2348fd7be4d169b3e7237dbd3dd754077 Mon Sep 17 00:00:00 2001 From: Observer KRypt0n_ Date: Fri, 7 Apr 2023 21:25:27 +0200 Subject: [PATCH 13/31] feat(ui): utilized new `recommended` feature for wine / dxvk versions --- Cargo.lock | 4 ++-- Cargo.toml | 2 +- src/ui/components/mod.rs | 16 ++++++++++++---- src/ui/preferences/general.rs | 35 +++++++++++++++++++++-------------- 4 files changed, 36 insertions(+), 21 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 9a16cd1c..a11a135d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -86,8 +86,8 @@ dependencies = [ [[package]] name = "anime-launcher-sdk" -version = "0.5.10" -source = "git+https://github.com/an-anime-team/anime-launcher-sdk?tag=0.5.10#186aa204d6a87a26198a00c9fb59e0a313f68227" +version = "0.5.11" +source = "git+https://github.com/an-anime-team/anime-launcher-sdk?tag=0.5.11#46547a886f51ba8c58918c0903273c3d3c63d5fa" dependencies = [ "anime-game-core", "anyhow", diff --git a/Cargo.toml b/Cargo.toml index 35e28d45..c1cbad78 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -17,7 +17,7 @@ glib-build-tools = "0.17" [dependencies.anime-launcher-sdk] git = "https://github.com/an-anime-team/anime-launcher-sdk" -tag = "0.5.10" +tag = "0.5.11" # path = "../anime-launcher-sdk" # ! for dev purposes only diff --git a/src/ui/components/mod.rs b/src/ui/components/mod.rs index 09c418b6..2e81eac0 100644 --- a/src/ui/components/mod.rs +++ b/src/ui/components/mod.rs @@ -56,10 +56,14 @@ impl From for ComponentsListVersion { #[inline] fn from(version: wine::Version) -> Self { Self { + recommended: match version.version_features() { + Some(features) => features.recommended, + None => true + }, + name: version.name, title: version.title, - uri: version.uri, - recommended: true + uri: version.uri } } } @@ -68,10 +72,14 @@ impl From for ComponentsListVersion { #[inline] fn from(version: dxvk::Version) -> Self { Self { + recommended: match version.version_features() { + Some(features) => features.recommended, + None => true + }, + name: version.name, title: version.title, - uri: version.uri, - recommended: true + uri: version.uri } } } diff --git a/src/ui/preferences/general.rs b/src/ui/preferences/general.rs index b22976a6..278b97f0 100644 --- a/src/ui/preferences/general.rs +++ b/src/ui/preferences/general.rs @@ -732,9 +732,14 @@ impl SimpleAsyncComponent for GeneralApp { group.versions = group.versions.into_iter().take(12).collect(); let mut group: ComponentsListGroup = group.into(); + let mut recommended = 6; - if group.versions.len() > 6 { - for i in 6..group.versions.len() { + for i in 0..group.versions.len() { + if recommended > 0 && group.versions[i].recommended { + recommended -= 1; + } + + else { group.versions[i].recommended = false; } } @@ -758,9 +763,14 @@ impl SimpleAsyncComponent for GeneralApp { group.versions = group.versions.into_iter().take(12).collect(); let mut group: ComponentsListGroup = group.into(); + let mut recommended = 6; + + for i in 0..group.versions.len() { + if recommended > 0 && group.versions[i].recommended { + recommended -= 1; + } - if group.versions.len() > 6 { - for i in 6..group.versions.len() { + else { group.versions[i].recommended = false; } } @@ -940,16 +950,13 @@ impl SimpleAsyncComponent for GeneralApp { self.downloaded_wine_versions = wine::get_downloaded(&CONFIG.components.path, &CONFIG.game.wine.builds) .unwrap_or_default() .into_iter() - .flat_map(|group| group.versions - .into_iter() - .map(move |version| ( - version.clone(), - version.features.unwrap_or_else( - || group.features.to_owned().unwrap_or_default() - )) - ) - ) - .collect(); + .flat_map(|group| group.versions.clone().into_iter() + .map(move |version| { + let features = version.features_in(&group).unwrap_or_default(); + + (version, features) + }) + ).collect(); self.selected_wine_version = if let Some(selected) = &CONFIG.game.wine.selected { let mut index = 0; From deacef37591131c758229c1cec0738f2412a217c Mon Sep 17 00:00:00 2001 From: Observer KRypt0n_ Date: Sat, 8 Apr 2023 19:46:28 +0200 Subject: [PATCH 14/31] feat(core): implemented SDK 0.5.12 This change allows to support game edition switching in settings --- Cargo.lock | 4 +- Cargo.toml | 2 +- src/main.rs | 2 +- src/ui/first_run/default_paths.rs | 37 ++++++++++----- src/ui/main/apply_patch.rs | 2 +- src/ui/main/download_diff.rs | 3 +- src/ui/main/mod.rs | 13 ++++-- src/ui/main/repair_game.rs | 18 +++---- src/ui/preferences/general.rs | 78 ++++++++++++++++++++++++++----- 9 files changed, 118 insertions(+), 41 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index a11a135d..c64db322 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -86,8 +86,8 @@ dependencies = [ [[package]] name = "anime-launcher-sdk" -version = "0.5.11" -source = "git+https://github.com/an-anime-team/anime-launcher-sdk?tag=0.5.11#46547a886f51ba8c58918c0903273c3d3c63d5fa" +version = "0.5.12" +source = "git+https://github.com/an-anime-team/anime-launcher-sdk?tag=0.5.12#06f0f486b9e099fc96db71be339332e1961dd0f6" dependencies = [ "anime-game-core", "anyhow", diff --git a/Cargo.toml b/Cargo.toml index c1cbad78..6a3bca94 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -17,7 +17,7 @@ glib-build-tools = "0.17" [dependencies.anime-launcher-sdk] git = "https://github.com/an-anime-team/anime-launcher-sdk" -tag = "0.5.11" +tag = "0.5.12" # path = "../anime-launcher-sdk" # ! for dev purposes only diff --git a/src/main.rs b/src/main.rs index 95eb775b..70c2f777 100644 --- a/src/main.rs +++ b/src/main.rs @@ -37,7 +37,7 @@ lazy_static::lazy_static! { /// This one is used to prepare some launcher UI components on start pub static ref CONFIG: config::Config = config::get().expect("Failed to load config"); - pub static ref GAME: Game = Game::new(&CONFIG.game.path); + pub static ref GAME: Game = Game::new(CONFIG.game.path.for_edition(CONFIG.launcher.edition)); /// Path to launcher folder. Standard is `$HOME/.local/share/anime-game-launcher` pub static ref LAUNCHER_FOLDER: PathBuf = launcher_dir().expect("Failed to get launcher folder"); diff --git a/src/ui/first_run/default_paths.rs b/src/ui/first_run/default_paths.rs index d2543d9e..78cc3206 100644 --- a/src/ui/first_run/default_paths.rs +++ b/src/ui/first_run/default_paths.rs @@ -18,7 +18,8 @@ pub struct DefaultPathsApp { runners: PathBuf, dxvks: PathBuf, prefix: PathBuf, - game: PathBuf, + game_global: PathBuf, + game_china: PathBuf, fps_unlocker: PathBuf, components: PathBuf, patch: PathBuf, @@ -31,7 +32,8 @@ pub enum Folders { Runners, DXVK, Prefix, - Game, + GameGlobal, + GameChina, FpsUnlocker, Components, Patch, @@ -144,9 +146,20 @@ impl SimpleAsyncComponent for DefaultPathsApp { set_activatable: true, #[watch] - set_subtitle: model.game.to_str().unwrap(), + set_subtitle: model.game_global.to_str().unwrap(), - connect_activated => DefaultPathsAppMsg::ChoosePath(Folders::Game) + connect_activated => DefaultPathsAppMsg::ChoosePath(Folders::GameGlobal) + }, + + adw::ActionRow { + set_title: &tr("game-installation-folder"), // FIXME + set_icon_name: Some("folder-symbolic"), + set_activatable: true, + + #[watch] + set_subtitle: model.game_china.to_str().unwrap(), + + connect_activated => DefaultPathsAppMsg::ChoosePath(Folders::GameChina) }, adw::ActionRow { @@ -233,7 +246,8 @@ impl SimpleAsyncComponent for DefaultPathsApp { runners: CONFIG.game.wine.builds.clone(), dxvks: CONFIG.game.dxvk.builds.clone(), prefix: CONFIG.game.wine.prefix.clone(), - game: CONFIG.game.path.clone(), + game_global: CONFIG.game.path.global.clone(), + game_china: CONFIG.game.path.china.clone(), fps_unlocker: CONFIG.game.enhancements.fps_unlocker.path.clone(), components: CONFIG.components.path.clone(), patch: CONFIG.patch.path.clone(), @@ -264,23 +278,21 @@ impl SimpleAsyncComponent for DefaultPathsApp { self.runners = result.join("runners"); self.dxvks = result.join("dxvks"); self.prefix = result.join("prefix"); + self.game_global = result.join(concat!("Ge", "nshi", "n Imp", "act")); + self.game_china = result.join(concat!("Yu", "anS", "hen")); self.fps_unlocker = result.join("fps-unlocker"); self.components = result.join("components"); self.patch = result.join("patch"); self.temp = result.clone(); - self.game = result.join(match CONFIG.launcher.edition.into() { - GameEdition::Global => concat!("Ge", "nshi", "n Imp", "act"), - GameEdition::China => concat!("Yu", "anS", "hen") - }); - self.launcher = result; } Folders::Runners => self.runners = result, Folders::DXVK => self.dxvks = result, Folders::Prefix => self.prefix = result, - Folders::Game => self.game = result, + Folders::GameGlobal => self.game_global = result, + Folders::GameChina => self.game_china = result, Folders::FpsUnlocker => self.fps_unlocker = result, Folders::Components => self.components = result, Folders::Patch => self.patch = result, @@ -313,7 +325,8 @@ impl DefaultPathsApp { config.game.wine.builds = self.runners.clone(); config.game.dxvk.builds = self.dxvks.clone(); config.game.wine.prefix = self.prefix.clone(); - config.game.path = self.game.clone(); + config.game.path.global = self.game_global.clone(); + config.game.path.china = self.game_china.clone(); config.components.path = self.components.clone(); config.patch.path = self.patch.clone(); config.launcher.temp = Some(self.temp.clone()); diff --git a/src/ui/main/apply_patch.rs b/src/ui/main/apply_patch.rs index 6cecf8c9..794a3bed 100644 --- a/src/ui/main/apply_patch.rs +++ b/src/ui/main/apply_patch.rs @@ -21,7 +21,7 @@ pub fn apply_patch(sender: ComponentSender< std::thread::spawn(move || { let mut apply_patch_if_needed = true; - if let Err(err) = patch.apply(&config.game.path, config.patch.root) { + if let Err(err) = patch.apply(config.game.path.for_edition(config.launcher.edition), config.patch.root) { tracing::error!("Failed to patch the game"); sender.input(AppMsg::Toast { diff --git a/src/ui/main/download_diff.rs b/src/ui/main/download_diff.rs index 5aa88590..48a778ad 100644 --- a/src/ui/main/download_diff.rs +++ b/src/ui/main/download_diff.rs @@ -18,9 +18,10 @@ pub fn download_diff(sender: ComponentSender, progress_bar_input: Sender move |state| { + let result = diff.install_to_by(game_path, config.launcher.temp, clone!(@strong sender => move |state| { match &state { InstallerUpdate::DownloadingError(err) => { tracing::error!("Downloading failed: {err}"); diff --git a/src/ui/main/mod.rs b/src/ui/main/mod.rs index 26931af4..060b899a 100644 --- a/src/ui/main/mod.rs +++ b/src/ui/main/mod.rs @@ -554,7 +554,12 @@ impl SimpleComponent for App { }))); group.add_action::(&RelmAction::new_stateless(clone!(@strong sender => move |_| { - if let Err(err) = open::that(&CONFIG.game.path) { + let path = match config::get() { + Ok(config) => config.game.path.for_edition(config.launcher.edition).to_path_buf(), + Err(_) => CONFIG.game.path.for_edition(CONFIG.launcher.edition).to_path_buf(), + }; + + if let Err(err) = open::that(path) { sender.input(AppMsg::Toast { title: tr("game-folder-opening-error"), description: Some(err.to_string()) @@ -590,8 +595,10 @@ impl SimpleComponent for App { group.add_action::(&RelmAction::new_stateless(clone!(@strong sender => move |_| { std::thread::spawn(clone!(@strong sender => move || { - let web_cache = CONFIG.game.path - .join(GameEdition::selected().data_folder()) + let config = config::get().unwrap_or_else(|_| CONFIG.clone()); + + let web_cache = config.game.path.for_edition(config.launcher.edition) + .join(GameEdition::from(config.launcher.edition).data_folder()) .join("webCaches/Cache/Cache_Data/data_2"); if !web_cache.exists() { diff --git a/src/ui/main/repair_game.rs b/src/ui/main/repair_game.rs index dcf3a7c7..243c699b 100644 --- a/src/ui/main/repair_game.rs +++ b/src/ui/main/repair_game.rs @@ -3,6 +3,8 @@ use relm4::{ Sender }; +use gtk::glib::clone; + use std::path::Path; use anime_launcher_sdk::config; @@ -23,7 +25,8 @@ pub fn repair_game(sender: ComponentSender, progress_bar_input: Sender { // Add voiceovers files - let game = Game::new(&config.game.path); + let game_path = config.game.path.for_edition(config.launcher.edition).to_path_buf(); + let game = Game::new(&game_path); if let Ok(voiceovers) = game.get_voice_packages() { for package in voiceovers { @@ -61,10 +64,9 @@ pub fn repair_game(sender: ComponentSender, progress_bar_input: Sender move || { for file in thread_files { let status = if config.launcher.repairer.fast { file.fast_verify(&game_path) @@ -74,7 +76,7 @@ pub fn repair_game(sender: ComponentSender, progress_bar_input: Sender, progress_bar_input: Sender, progress_bar_input: Sender adw::ExpanderRow { - set_title: &tr("game-voiceovers"), - set_subtitle: "List of downloaded game voiceovers. You can select them in the game settings" + adw::ComboRow { + set_title: "Game edition", + + set_model: Some(>k::StringList::new(&[ + "Global", + "China" + ])), + + set_selected: match CONFIG.launcher.edition { + GameEdition::Global => 0, + GameEdition::China => 1 + }, + + connect_selected_notify[sender] => move |row| { + if is_ready() { + #[allow(unused_must_use)] + if let Ok(mut config) = config::get() { + config.launcher.edition = match row.selected() { + 0 => GameEdition::Global, + 1 => GameEdition::China, + + _ => unreachable!() + }; + + config::update(config); + + sender.output(PreferencesAppMsg::UpdateLauncherState); + } + } + } }, adw::ComboRow { - set_title: "Environment emulation", - set_subtitle: "Experimental feature. Emulate game environment to get specific features like additional payment methods", + set_title: "Game environment", + set_subtitle: "Get specific features like additional payment methods", set_model: Some(>k::StringList::new(&[ "PC", @@ -339,6 +366,12 @@ impl SimpleAsyncComponent for GeneralApp { } }, + #[local_ref] + voice_packages -> adw::ExpanderRow { + set_title: &tr("game-voiceovers"), + set_subtitle: "List of downloaded game voiceovers. You can select them in the game settings" + }, + gtk::Box { set_orientation: gtk::Orientation::Horizontal, set_spacing: 8, @@ -442,7 +475,12 @@ impl SimpleAsyncComponent for GeneralApp { PatchStatus::Preparation { .. } | PatchStatus::Testing { .. } => &["warning"], PatchStatus::Available { .. } => unsafe { - if let Ok(true) = model.unity_player_patch.as_ref().unwrap_unchecked().is_applied(&CONFIG.game.path) { + let path = match config::get() { + Ok(config) => config.game.path.for_edition(config.launcher.edition).to_path_buf(), + Err(_) => CONFIG.game.path.for_edition(CONFIG.launcher.edition).to_path_buf(), + }; + + if let Ok(true) = model.unity_player_patch.as_ref().unwrap_unchecked().is_applied(path) { &["success"] } else { &["warning"] @@ -464,7 +502,12 @@ impl SimpleAsyncComponent for GeneralApp { PatchStatus::Preparation { .. } => tr("patch-preparation-tooltip"), PatchStatus::Testing { .. } => tr("patch-testing-tooltip"), PatchStatus::Available { .. } => unsafe { - if let Ok(true) = model.unity_player_patch.as_ref().unwrap_unchecked().is_applied(&CONFIG.game.path) { + let path = match config::get() { + Ok(config) => config.game.path.for_edition(config.launcher.edition).to_path_buf(), + Err(_) => CONFIG.game.path.for_edition(CONFIG.launcher.edition).to_path_buf(), + }; + + if let Ok(true) = model.unity_player_patch.as_ref().unwrap_unchecked().is_applied(path) { String::new() } else { tr("patch-not-applied-tooltip") @@ -503,7 +546,12 @@ impl SimpleAsyncComponent for GeneralApp { PatchStatus::Preparation { .. } | PatchStatus::Testing { .. } => &["warning"], PatchStatus::Available { .. } => unsafe { - if let Ok(true) = model.xlua_patch.as_ref().unwrap_unchecked().is_applied(&CONFIG.game.path) { + let path = match config::get() { + Ok(config) => config.game.path.for_edition(config.launcher.edition).to_path_buf(), + Err(_) => CONFIG.game.path.for_edition(CONFIG.launcher.edition).to_path_buf(), + }; + + if let Ok(true) = model.xlua_patch.as_ref().unwrap_unchecked().is_applied(path) { &["success"] } else { &["warning"] @@ -525,7 +573,12 @@ impl SimpleAsyncComponent for GeneralApp { PatchStatus::Preparation { .. } => tr("patch-preparation-tooltip"), PatchStatus::Testing { .. } => tr("patch-testing-tooltip"), PatchStatus::Available { .. } => unsafe { - if let Ok(true) = model.xlua_patch.as_ref().unwrap_unchecked().is_applied(&CONFIG.game.path) { + let path = match config::get() { + Ok(config) => config.game.path.for_edition(config.launcher.edition).to_path_buf(), + Err(_) => CONFIG.game.path.for_edition(CONFIG.launcher.edition).to_path_buf(), + }; + + if let Ok(true) = model.xlua_patch.as_ref().unwrap_unchecked().is_applied(path) { String::new() } else { tr("patch-not-applied-tooltip") @@ -867,10 +920,11 @@ impl SimpleAsyncComponent for GeneralApp { config::update(config.clone()); let package = VoicePackage::with_locale(package.locale).unwrap(); + let game_path = config.game.path.for_edition(config.launcher.edition).to_path_buf(); - if package.is_installed_in(&config.game.path) { + if package.is_installed_in(&game_path) { std::thread::spawn(move || { - if let Err(err) = package.delete_in(&config.game.path) { + if let Err(err) = package.delete_in(game_path) { tracing::error!("Failed to delete voice package: {:?}", package.locale()); sender.input(GeneralAppMsg::Toast { From 22598efb156459cff90462f095211cf13d186a87 Mon Sep 17 00:00:00 2001 From: Observer KRypt0n_ Date: Sat, 8 Apr 2023 19:54:32 +0200 Subject: [PATCH 15/31] docs: updated changelog --- CHANGELOG.md | 5 +++-- src/ui/about.rs | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index aa3c64b2..54f6bf2a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,11 +9,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added -- Added environment emulation feature +- Added installation migration feature +- Added game environment switcher +- Added game edition switcher ### Changed -- Made default game folder name depend on game edition - Improved game repairing feature - Replaced `curl` dependency by native code diff --git a/src/ui/about.rs b/src/ui/about.rs index c896f05a..a2551088 100644 --- a/src/ui/about.rs +++ b/src/ui/about.rs @@ -84,13 +84,14 @@ impl SimpleComponent for AboutDialog { "

    Added

    ", "
      ", - "
    • Added environment emulation feature
    • ", + "
    • Added installation migration feature
    • ", + "
    • Added game environment switcher
    • ", + "
    • Added game edition switcher
    • ", "
    ", "

    Changed

    ", "
      ", - "
    • Made default game folder name depend on game edition
    • ", "
    • Improved game repairing feature
    • ", "
    • Replaced curl dependency by native code
    • ", "
    ", From 49ebbc35a207833c4307434626c8bbe3353e53ec Mon Sep 17 00:00:00 2001 From: Observer KRypt0n_ Date: Sat, 8 Apr 2023 21:57:52 +0200 Subject: [PATCH 16/31] feat(ui): added changelog to updated components toast Implemented SDK 0.5.13 --- Cargo.lock | 8 ++++---- Cargo.toml | 2 +- src/ui/first_run/main.rs | 3 +-- src/ui/main/mod.rs | 28 ++++++++++++---------------- 4 files changed, 18 insertions(+), 23 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index c64db322..c0d3483d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -40,8 +40,8 @@ dependencies = [ [[package]] name = "anime-game-core" -version = "1.5.1" -source = "git+https://github.com/an-anime-team/anime-game-core?tag=1.5.1#4af7a14fc7e86d40cd97a7beb448a6d593a7d43d" +version = "1.5.2" +source = "git+https://github.com/an-anime-team/anime-game-core?tag=1.5.2#002bed907fc47c53d18764fb87aec2398413f1a0" dependencies = [ "anyhow", "bzip2", @@ -86,8 +86,8 @@ dependencies = [ [[package]] name = "anime-launcher-sdk" -version = "0.5.12" -source = "git+https://github.com/an-anime-team/anime-launcher-sdk?tag=0.5.12#06f0f486b9e099fc96db71be339332e1961dd0f6" +version = "0.5.13" +source = "git+https://github.com/an-anime-team/anime-launcher-sdk?tag=0.5.13#66a80e5f5906b1cfc1b9716a4448dd03cf854ae8" dependencies = [ "anime-game-core", "anyhow", diff --git a/Cargo.toml b/Cargo.toml index 6a3bca94..b0428722 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -17,7 +17,7 @@ glib-build-tools = "0.17" [dependencies.anime-launcher-sdk] git = "https://github.com/an-anime-team/anime-launcher-sdk" -tag = "0.5.12" +tag = "0.5.13" # path = "../anime-launcher-sdk" # ! for dev purposes only diff --git a/src/ui/first_run/main.rs b/src/ui/first_run/main.rs index 03863b4f..f93099d0 100644 --- a/src/ui/first_run/main.rs +++ b/src/ui/first_run/main.rs @@ -232,8 +232,7 @@ impl SimpleComponent for FirstRunApp { Ok(None) => { for host in &CONFIG.components.servers { match components.sync(host) { - Ok(true) => break, - Ok(false) => continue, + Ok(_) => break, Err(err) => { tracing::error!("Failed to sync components index"); diff --git a/src/ui/main/mod.rs b/src/ui/main/mod.rs index 060b899a..830dcc12 100644 --- a/src/ui/main/mod.rs +++ b/src/ui/main/mod.rs @@ -694,19 +694,24 @@ impl SimpleComponent for App { Ok(None) => { for host in &CONFIG.components.servers { match components.sync(host) { - Ok(true) => { - // TODO: add changelog log here - + Ok(changes) => { sender.input(AppMsg::Toast { title: tr("components-index-updated"), - description: None + description: if changes.is_empty() { + None + } else { + let max_len = changes.iter().map(|line| line.len()).max().unwrap_or(80); + + Some(changes.into_iter() + .map(|line| format!("- {line}{}", " ".repeat(max_len - line.len()))) + .collect::>() + .join("\n")) + } }); break; } - Ok(false) => continue, - Err(err) => { tracing::error!("Failed to sync components index"); @@ -742,16 +747,7 @@ impl SimpleComponent for App { Ok(None) => { for server in &CONFIG.patch.servers { match patch.sync(server) { - Ok(true) => break, - - Ok(false) => { - tracing::error!("Failed to sync patch folder with remote: {server}"); - - sender.input(AppMsg::Toast { - title: tr("patch-sync-failed"), - description: None - }); - } + Ok(_) => break, Err(err) => { tracing::error!("Failed to sync patch folder with remote: {server}: {err}"); From 285195954efc59c720b1efd495318630b0c5030e Mon Sep 17 00:00:00 2001 From: Observer KRypt0n_ Date: Sat, 8 Apr 2023 22:45:38 +0200 Subject: [PATCH 17/31] fix: fixed game edition changing on switcher change --- CHANGELOG.md | 1 + src/ui/about.rs | 1 + src/ui/preferences/general.rs | 4 ++++ 3 files changed, 6 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 54f6bf2a..c34c032e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Added installation migration feature - Added game environment switcher - Added game edition switcher +- Added changelog to updated components toast ### Changed diff --git a/src/ui/about.rs b/src/ui/about.rs index a2551088..f255a6d4 100644 --- a/src/ui/about.rs +++ b/src/ui/about.rs @@ -87,6 +87,7 @@ impl SimpleComponent for AboutDialog { "
  • Added installation migration feature
  • ", "
  • Added game environment switcher
  • ", "
  • Added game edition switcher
  • ", + "
  • Added changelog to updated components toast
  • ", "
", "

Changed

", diff --git a/src/ui/preferences/general.rs b/src/ui/preferences/general.rs index 6c65836f..a59a3aca 100644 --- a/src/ui/preferences/general.rs +++ b/src/ui/preferences/general.rs @@ -17,6 +17,7 @@ use anime_launcher_sdk::components::*; use anime_launcher_sdk::components::wine::WincompatlibWine; use anime_launcher_sdk::env_emulation::Environment; use anime_launcher_sdk::config::launcher::GameEdition; +use anime_launcher_sdk::anime_game_core::genshin::consts::GameEdition as CoreGameEdition; use super::main::PreferencesAppMsg; use crate::ui::migrate_installation::MigrateInstallationApp; @@ -326,6 +327,9 @@ impl SimpleAsyncComponent for GeneralApp { _ => unreachable!() }; + // Select new game edition + CoreGameEdition::from(config.launcher.edition).select(); + config::update(config); sender.output(PreferencesAppMsg::UpdateLauncherState); From 567df16610d2df902b6dd1eb1d028eff0df76264 Mon Sep 17 00:00:00 2001 From: Observer KRypt0n_ Date: Sun, 9 Apr 2023 17:06:05 +0200 Subject: [PATCH 18/31] feat: made migrate installation button work --- assets/locales/en/first_run.ftl | 1 + src/ui/first_run/default_paths.rs | 162 +++++++++++++++++++++++++++--- src/ui/first_run/main.rs | 2 +- src/ui/migrate_installation.rs | 23 +---- 4 files changed, 153 insertions(+), 35 deletions(-) diff --git a/assets/locales/en/first_run.ftl b/assets/locales/en/first_run.ftl index 2e719eb4..b18632a4 100644 --- a/assets/locales/en/first_run.ftl +++ b/assets/locales/en/first_run.ftl @@ -42,6 +42,7 @@ components-index = Components index patch-folder = Patch folder temp-folder = Temp folder +migrate = Migrate select-voice-packages = Select voice packages diff --git a/src/ui/first_run/default_paths.rs b/src/ui/first_run/default_paths.rs index 78cc3206..1d09d295 100644 --- a/src/ui/first_run/default_paths.rs +++ b/src/ui/first_run/default_paths.rs @@ -5,14 +5,19 @@ use adw::prelude::*; use anime_launcher_sdk::config; -use std::path::PathBuf; +use std::path::{Path, PathBuf}; use crate::*; use crate::i18n::*; use super::main::*; +use crate::ui::components::progress_bar::*; pub struct DefaultPathsApp { + progress_bar: AsyncController, + show_additional: bool, + migrate_installation: bool, + show_progress: bool, launcher: PathBuf, runners: PathBuf, @@ -50,7 +55,8 @@ pub enum DefaultPathsAppMsg { #[relm4::component(async, pub)] impl SimpleAsyncComponent for DefaultPathsApp { - type Init = (); + /// If `true`, then use migrate installation mode + type Init = bool; type Input = DefaultPathsAppMsg; type Output = FirstRunAppMsg; @@ -72,6 +78,9 @@ impl SimpleAsyncComponent for DefaultPathsApp { set_valign: gtk::Align::End, set_vexpand: true, + #[watch] + set_sensitive: !model.show_progress, + adw::ActionRow { set_title: &tr("launcher-folder"), set_icon_name: Some("folder-symbolic"), @@ -107,6 +116,9 @@ impl SimpleAsyncComponent for DefaultPathsApp { #[watch] set_visible: model.show_additional, + #[watch] + set_sensitive: !model.show_progress, + adw::ActionRow { set_title: &tr("runners-folder"), set_icon_name: Some("folder-symbolic"), @@ -210,37 +222,76 @@ impl SimpleAsyncComponent for DefaultPathsApp { add = &adw::PreferencesGroup { set_valign: gtk::Align::Center, set_vexpand: true, - + + #[watch] + set_visible: !model.show_progress, + gtk::Box { set_orientation: gtk::Orientation::Horizontal, set_halign: gtk::Align::Center, set_spacing: 8, - + gtk::Button { - set_label: &tr("continue"), + set_label: &if model.migrate_installation { + tr("migrate") + } else { + tr("continue") + }, + set_css_classes: &["suggested-action", "pill"], connect_clicked => DefaultPathsAppMsg::Continue }, gtk::Button { - set_label: &tr("exit"), + set_label: &if model.migrate_installation { + tr("close") + } else { + tr("exit") + }, + add_css_class: "pill", connect_clicked => DefaultPathsAppMsg::Exit } } + }, + + add = &adw::PreferencesGroup { + set_valign: gtk::Align::Center, + set_vexpand: true, + + #[watch] + set_visible: model.show_progress, + + gtk::Box { + set_orientation: gtk::Orientation::Horizontal, + set_halign: gtk::Align::Center, + + append = model.progress_bar.widget(), + } } } } async fn init( - _init: Self::Init, + init: Self::Init, root: Self::Root, _sender: AsyncComponentSender, ) -> AsyncComponentParts { let model = Self { + progress_bar: ProgressBar::builder() + .launch(ProgressBarInit { + caption: None, + display_progress: true, + display_fraction: false, + visible: false + }) + .detach(), + show_additional: false, + migrate_installation: init, + show_progress: false, launcher: LAUNCHER_FOLDER.to_path_buf(), runners: CONFIG.game.wine.builds.clone(), @@ -256,6 +307,9 @@ impl SimpleAsyncComponent for DefaultPathsApp { temp: CONFIG.launcher.temp.clone().unwrap_or(std::env::temp_dir()) }; + // Set progress bar width + model.progress_bar.widget().set_width_request(400); + let widgets = view_output!(); AsyncComponentParts { model, widgets } @@ -303,17 +357,95 @@ impl SimpleAsyncComponent for DefaultPathsApp { #[allow(unused_must_use)] DefaultPathsAppMsg::Continue => { + let old_config = config::get().unwrap_or_else(|_| CONFIG.clone()); + match self.update_config() { - Ok(_) => sender.output(Self::Output::ScrollToSelectVoiceovers), - - Err(err) => sender.output(Self::Output::Toast { - title: tr("config-update-error"), - description: Some(err.to_string()) - }) - }; + Ok(_) => { + if self.migrate_installation { + self.progress_bar.sender().send(ProgressBarMsg::SetVisible(true)); + + self.show_progress = true; + + let folders = [ + (old_config.game.wine.builds, &self.runners), + (old_config.game.dxvk.builds, &self.dxvks), + (old_config.game.wine.prefix, &self.prefix), + (old_config.game.path.global, &self.game_global), + (old_config.game.path.china, &self.game_china), + (old_config.components.path, &self.components), + (old_config.patch.path, &self.patch), + + (old_config.game.enhancements.fps_unlocker.path, &self.fps_unlocker) + ]; + + fn move_folder(from: &Path, to: &Path) -> std::io::Result<()> { + if !to.exists() { + std::fs::create_dir_all(to); + } + + for entry in from.read_dir()?.flatten() { + let to_path = to.join(entry.file_name()); + + if entry.metadata()?.is_dir() { + move_folder(&entry.path(), &to_path)?; + } + + else if entry.metadata()?.is_file() { + std::fs::copy(entry.path(), &to_path); + } + + // TODO: symlinks? + } + + std::fs::remove_dir_all(from)?; + + Ok(()) + } + + #[allow(clippy::expect_fun_call)] + for (i, (from, to)) in folders.iter().enumerate() { + self.progress_bar.sender().send(ProgressBarMsg::UpdateCaption(Some( + from.to_str().map(|str| str.to_string()).unwrap_or_else(|| format!("{:?}", from)) + ))); + + if &from != to && from.exists() { + move_folder(from, to).expect(&format!("Failed to move folder: {:?} -> {:?}", from, to)); + } + + self.progress_bar.sender().send(ProgressBarMsg::UpdateProgress(i as u64 + 1, folders.len() as u64)); + } + + // Restart the app + + std::process::Command::new(std::env::current_exe().unwrap()).spawn().unwrap(); + + relm4::main_application().quit(); + } + + else { + sender.output(Self::Output::ScrollToSelectVoiceovers); + } + } + + Err(err) => { + sender.output(Self::Output::Toast { + title: tr("config-update-error"), + description: Some(err.to_string()) + }); + } + } } - DefaultPathsAppMsg::Exit => relm4::main_application().quit() + DefaultPathsAppMsg::Exit => { + if self.migrate_installation { + // TODO: this shit should return message to general preferences component somehow to close MigrateInstallation window + todo!(); + } + + else { + relm4::main_application().quit(); + } + } } } } diff --git a/src/ui/first_run/main.rs b/src/ui/first_run/main.rs index f93099d0..43b8b9f1 100644 --- a/src/ui/first_run/main.rs +++ b/src/ui/first_run/main.rs @@ -145,7 +145,7 @@ impl SimpleComponent for FirstRunApp { .forward(sender.input_sender(), std::convert::identity), default_paths: DefaultPathsApp::builder() - .launch(()) + .launch(false) .forward(sender.input_sender(), std::convert::identity), select_voiceovers: SelectVoiceoversApp::builder() diff --git a/src/ui/migrate_installation.rs b/src/ui/migrate_installation.rs index 76187a29..4b97f945 100644 --- a/src/ui/migrate_installation.rs +++ b/src/ui/migrate_installation.rs @@ -2,9 +2,6 @@ use relm4::prelude::*; use relm4::component::*; use gtk::prelude::*; -use adw::prelude::*; - -use crate::*; use super::first_run::default_paths::DefaultPathsApp; @@ -12,21 +9,17 @@ pub struct MigrateInstallationApp { default_paths: AsyncController, } -#[derive(Debug)] -pub enum MigrateInstallationAppMsg { - Migrate -} - #[relm4::component(pub)] impl SimpleComponent for MigrateInstallationApp { type Init = (); - type Input = MigrateInstallationAppMsg; + type Input = (); type Output = (); view! { adw::Window { set_default_size: (780, 560), set_modal: true, + set_hide_on_close: true, #[watch] set_title: Some("Migrate installation"), @@ -46,13 +39,13 @@ impl SimpleComponent for MigrateInstallationApp { fn init( _init: Self::Init, root: &Self::Root, - sender: ComponentSender, + _sender: ComponentSender, ) -> ComponentParts { tracing::info!("Initializing migration window"); let model = Self { default_paths: DefaultPathsApp::builder() - .launch(()) + .launch(true) .detach() }; @@ -60,12 +53,4 @@ impl SimpleComponent for MigrateInstallationApp { ComponentParts { model, widgets } } - - fn update(&mut self, msg: Self::Input, _sender: ComponentSender) { - match msg { - MigrateInstallationAppMsg::Migrate => { - todo!() - } - } - } } From f7779635481b3443ee5ca76291399bb989b71b87 Mon Sep 17 00:00:00 2001 From: Observer KRypt0n_ Date: Sun, 9 Apr 2023 17:58:23 +0200 Subject: [PATCH 19/31] feat: added wine tools to settings --- Cargo.lock | 8 ++-- Cargo.toml | 5 ++- assets/locales/en/errors.ftl | 2 + src/ui/preferences/general.rs | 75 ++++++++++++++++++++++++++++++++++- 4 files changed, 83 insertions(+), 7 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index c0d3483d..8e61321c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -86,8 +86,8 @@ dependencies = [ [[package]] name = "anime-launcher-sdk" -version = "0.5.13" -source = "git+https://github.com/an-anime-team/anime-launcher-sdk?tag=0.5.13#66a80e5f5906b1cfc1b9716a4448dd03cf854ae8" +version = "0.5.14" +source = "git+https://github.com/an-anime-team/anime-launcher-sdk?tag=0.5.14#98de4c7d707ed7428257953526625e8f168f7d84" dependencies = [ "anime-game-core", "anyhow", @@ -1718,9 +1718,9 @@ checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5" [[package]] name = "open" -version = "4.0.0" +version = "4.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bd61e3bf9d78956c72ee864bba52431f7f43994b21a17e9e72596a81bd61075b" +checksum = "075c5203b3a2b698bc72c6c10b1f6263182135751d5013ea66e8a4b3d0562a43" dependencies = [ "pathdiff", ] diff --git a/Cargo.toml b/Cargo.toml index b0428722..66ef36a4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -17,7 +17,7 @@ glib-build-tools = "0.17" [dependencies.anime-launcher-sdk] git = "https://github.com/an-anime-team/anime-launcher-sdk" -tag = "0.5.13" +tag = "0.5.14" # path = "../anime-launcher-sdk" # ! for dev purposes only @@ -25,8 +25,9 @@ tag = "0.5.13" relm4 = { version = "0.6.0-alpha.2", features = ["macros", "libadwaita"] } gtk = { package = "gtk4", version = "0.6", features = ["v4_8"] } adw = { package = "libadwaita", version = "0.3", features = ["v1_2"] } + rfd = { version = "0.11", features = ["xdg-portal"], default-features = false } -open = "4.0.0" +open = "4.0" tracing = "0.1" tracing-subscriber = "0.3" diff --git a/assets/locales/en/errors.ftl b/assets/locales/en/errors.ftl index cb76fc48..8271f849 100644 --- a/assets/locales/en/errors.ftl +++ b/assets/locales/en/errors.ftl @@ -6,6 +6,8 @@ debug-file-opening-error = Failed to open debug file wish-url-search-failed = No wishes url found wish-url-opening-error = Could not open wishes url +wine-run-error = Failed to run {$executable} executable using wine + game-launching-failed = Failed to launch game failed-get-selected-wine = Failed to get selected wine version downloading-failed = Downloading failed diff --git a/src/ui/preferences/general.rs b/src/ui/preferences/general.rs index a59a3aca..8f1aa453 100644 --- a/src/ui/preferences/general.rs +++ b/src/ui/preferences/general.rs @@ -152,6 +152,7 @@ pub enum GeneralAppMsg { OpenMigrateInstallation, RepairGame, + WineOpen(&'static [&'static str]), UpdateLauncherStyle(LauncherStyle), @@ -696,6 +697,57 @@ impl SimpleAsyncComponent for GeneralApp { add = model.wine_components.widget(), }, + add = &adw::PreferencesGroup { + adw::ExpanderRow { + set_title: "Wine tools", + + add_row = &adw::ActionRow { + set_title: "Command line", + set_subtitle: "start cmd", + + set_activatable: true, + + connect_activated => GeneralAppMsg::WineOpen(&["start", "cmd"]) + }, + + add_row = &adw::ActionRow { + set_title: "Registry editor", + set_subtitle: "regedit", + + set_activatable: true, + + connect_activated => GeneralAppMsg::WineOpen(&["regedit"]) + }, + + add_row = &adw::ActionRow { + set_title: "Explorer", + set_subtitle: "explorer", + + set_activatable: true, + + connect_activated => GeneralAppMsg::WineOpen(&["explorer"]) + }, + + add_row = &adw::ActionRow { + set_title: "Task manager", + set_subtitle: "taskmgr", + + set_activatable: true, + + connect_activated => GeneralAppMsg::WineOpen(&["taskmgr"]) + }, + + add_row = &adw::ActionRow { + set_title: "Configuration", + set_subtitle: "winecfg", + + set_activatable: true, + + connect_activated => GeneralAppMsg::WineOpen(&["winecfg"]) + } + } + }, + add = &adw::PreferencesGroup { set_title: &tr("dxvk-version"), @@ -968,12 +1020,33 @@ impl SimpleAsyncComponent for GeneralApp { sender.output(Self::Output::RepairGame); } + GeneralAppMsg::WineOpen(executable) => { + let config = config::get().unwrap_or_else(|_| CONFIG.clone()); + + if let Ok(Some(wine)) = config.get_selected_wine() { + let result = wine.to_wine(config.components.path, Some(config.game.wine.builds.join(&wine.name))) + .with_prefix(config.game.wine.prefix) + .run_args(executable); + + if let Err(err) = result { + sender.input(GeneralAppMsg::Toast { + title: tr_args("wine-run-error", [ + ("executable", executable.join(" ").into()) + ]), + description: Some(err.to_string()) + }); + + tracing::error!("Failed to run {:?} using wine: {err}", executable); + } + } + } + #[allow(unused_must_use)] GeneralAppMsg::UpdateLauncherStyle(style) => { if style == LauncherStyle::Classic && !KEEP_BACKGROUND_FILE.exists() { if let Err(err) = crate::background::download_background() { tracing::error!("Failed to download background picture"); - + sender.input(GeneralAppMsg::Toast { title: tr("background-downloading-failed"), description: Some(err.to_string()) From 13fd1ebb4ffcbc2ab28b885a18a6d363954c6940 Mon Sep 17 00:00:00 2001 From: Observer KRypt0n_ Date: Sun, 9 Apr 2023 18:03:46 +0200 Subject: [PATCH 20/31] feat: added whitespaces removing from environment values One user somehow got it in game running command. Have no idea how could it happend but just in case added `trim()` calls --- src/ui/preferences/environment.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/ui/preferences/environment.rs b/src/ui/preferences/environment.rs index 19d168d0..e94d7bd1 100644 --- a/src/ui/preferences/environment.rs +++ b/src/ui/preferences/environment.rs @@ -91,11 +91,11 @@ impl SimpleAsyncComponent for EnvironmentApp { adw::EntryRow { set_title: "%command%", - set_text: CONFIG.game.command.as_ref().unwrap_or(&String::new()), + set_text: CONFIG.game.command.as_ref().unwrap_or(&String::new()).trim(), connect_changed => |entry| { if let Ok(mut config) = config::get() { - let command = entry.text().to_string(); + let command = entry.text().trim().to_string(); config.game.command = if command.is_empty() { None @@ -158,7 +158,7 @@ impl SimpleAsyncComponent for EnvironmentApp { }; for (name, value) in &CONFIG.game.environment { - model.variables.guard().push_back((name.clone(), value.clone())); + model.variables.guard().push_back((name.trim().to_string(), value.trim().to_string())); } let variables = model.variables.widget(); @@ -175,8 +175,8 @@ impl SimpleAsyncComponent for EnvironmentApp { match msg { EnvironmentMsg::Add => { if let Ok(mut config) = config::get() { - let name = self.name.text().to_string(); - let value = self.value.text().to_string(); + let name = self.name.text().trim().to_string(); + let value = self.value.text().trim().to_string(); config.game.environment.insert(name.clone(), value.clone()); From 16e6c8e1d2a6101712b8ed0f36c6923b28db866d Mon Sep 17 00:00:00 2001 From: Observer KRypt0n_ Date: Sun, 9 Apr 2023 18:38:15 +0200 Subject: [PATCH 21/31] feat(ui): replaced static image by spinner in wine / dxvk version selection --- src/ui/preferences/general.rs | 34 ++++++++++++++++++---------------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/src/ui/preferences/general.rs b/src/ui/preferences/general.rs index 8f1aa453..8559a177 100644 --- a/src/ui/preferences/general.rs +++ b/src/ui/preferences/general.rs @@ -660,18 +660,18 @@ impl SimpleAsyncComponent for GeneralApp { #[watch] set_activatable: !model.selecting_wine_version, - #[watch] - set_icon_name: if model.selecting_wine_version { - Some("process-working-symbolic") - } else { - None - }, - connect_selected_notify[sender] => move |row| { if is_ready() { sender.input(GeneralAppMsg::SelectWine(row.selected() as usize)); } - } @wine_selected_notify + } @wine_selected_notify, + + add_suffix = >k::Spinner { + set_spinning: true, + + #[watch] + set_visible: model.selecting_wine_version + } }, adw::ActionRow { @@ -775,18 +775,18 @@ impl SimpleAsyncComponent for GeneralApp { #[watch] set_activatable: !model.selecting_dxvk_version, - #[watch] - set_icon_name: if model.selecting_dxvk_version { - Some("process-working-symbolic") - } else { - None - }, - connect_selected_notify[sender] => move |row| { if is_ready() { sender.input(GeneralAppMsg::SelectDxvk(row.selected() as usize)); } - } @dxvk_selected_notify + } @dxvk_selected_notify, + + add_suffix = >k::Spinner { + set_spinning: true, + + #[watch] + set_visible: model.selecting_dxvk_version + } }, adw::ActionRow { @@ -1026,6 +1026,8 @@ impl SimpleAsyncComponent for GeneralApp { if let Ok(Some(wine)) = config.get_selected_wine() { let result = wine.to_wine(config.components.path, Some(config.game.wine.builds.join(&wine.name))) .with_prefix(config.game.wine.prefix) + .with_loader(WineLoader::Current) + .with_arch(WineArch::Win64) .run_args(executable); if let Err(err) = result { From 9453a2bbc5d5342da7a816a9449177d5ca7db96c Mon Sep 17 00:00:00 2001 From: Observer KRypt0n_ Date: Sun, 9 Apr 2023 18:45:38 +0200 Subject: [PATCH 22/31] feat(ui): made wine / dxvk versions always visible if they're downloaded --- src/ui/components/version.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ui/components/version.rs b/src/ui/components/version.rs index c794daba..6e7e9f1c 100644 --- a/src/ui/components/version.rs +++ b/src/ui/components/version.rs @@ -52,7 +52,7 @@ impl SimpleAsyncComponent for ComponentVersion { set_title: &model.title, #[watch] - set_visible: !model.show_recommended_only || model.recommended, + set_visible: !model.show_recommended_only || model.recommended || model.state != VersionState::NotDownloaded, add_suffix = >k::Button { #[watch] From 032e6be5826d146c4eddcfb9ff00a7839383d93a Mon Sep 17 00:00:00 2001 From: Observer KRypt0n_ Date: Sun, 9 Apr 2023 18:50:28 +0200 Subject: [PATCH 23/31] docs: updated changelog --- CHANGELOG.md | 7 +++++++ src/ui/about.rs | 9 +++++++++ 2 files changed, 16 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index c34c032e..a69d53e1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,11 +13,18 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Added game environment switcher - Added game edition switcher - Added changelog to updated components toast +- Added wine tools to settings + +### Fixed + +- Added whitespaces removing from environment values ### Changed - Improved game repairing feature - Replaced `curl` dependency by native code +- Replaced static image by spinner in wine / dxvk version selection +- Made wine / dxvk versions always visible if they're downloaded ## [3.3.0] - 24.03.2023 diff --git a/src/ui/about.rs b/src/ui/about.rs index f255a6d4..e590d088 100644 --- a/src/ui/about.rs +++ b/src/ui/about.rs @@ -88,6 +88,13 @@ impl SimpleComponent for AboutDialog { "
  • Added game environment switcher
  • ", "
  • Added game edition switcher
  • ", "
  • Added changelog to updated components toast
  • ", + "
  • Added wine tools to settings
  • ", + "", + + "

    Fixed

    ", + + "
      ", + "
    • Added whitespaces removing from environment values
    • ", "
    ", "

    Changed

    ", @@ -95,6 +102,8 @@ impl SimpleComponent for AboutDialog { "
      ", "
    • Improved game repairing feature
    • ", "
    • Replaced curl dependency by native code
    • ", + "
    • Replaced static image by spinner in wine / dxvk version selection
    • ", + "
    • Made wine / dxvk versions always visible if they're downloaded
    • ", "
    ", ].join("\n"), From 3b8ec109384ef82e2c2065586733d5b30763dfc9 Mon Sep 17 00:00:00 2001 From: Observer KRypt0n_ Date: Sun, 9 Apr 2023 18:56:13 +0200 Subject: [PATCH 24/31] feat(ui): fixed app version display in changelog --- src/ui/about.rs | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/src/ui/about.rs b/src/ui/about.rs index e590d088..163adebf 100644 --- a/src/ui/about.rs +++ b/src/ui/about.rs @@ -1,12 +1,19 @@ use relm4::prelude::*; use gtk::prelude::*; -use crate::APP_VERSION; use anime_launcher_sdk::VERSION as SDK_VERSION; use anime_launcher_sdk::anime_game_core::VERSION as CORE_VERSION; use crate::*; +lazy_static::lazy_static! { + pub static ref APP_VERSION: String = if crate::APP_DEBUG && !crate::APP_VERSION.contains('-') { + format!("{}-dev", crate::APP_VERSION) + } else { + crate::APP_VERSION.to_string() + }; +} + #[derive(Debug)] pub struct AboutDialog { visible: bool @@ -33,17 +40,7 @@ impl SimpleComponent for AboutDialog { set_issue_url: "https://github.com/an-anime-team/an-anime-game-launcher/issues", set_license_type: gtk::License::Gpl30, - - set_version: &{ - // Debug build & build's version doesn't contain any suffix (-dev, -beta, etc) - if crate::APP_DEBUG && !APP_VERSION.contains('-') { - format!("{APP_VERSION}-dev") - } - - else { - APP_VERSION.to_string() - } - }, + set_version: &APP_VERSION, set_developers: &[ "Nikita Podvirnyy https://github.com/krypt0nn" @@ -79,7 +76,7 @@ impl SimpleComponent for AboutDialog { format!("cairo: {}", gtk::cairo::version_string()), ].join("\n"), - set_release_notes_version: APP_VERSION, + set_release_notes_version: &APP_VERSION, set_release_notes: &[ "

    Added

    ", From 9189a6722b316d4ca71c4397906bd926b2b025e9 Mon Sep 17 00:00:00 2001 From: Observer KRypt0n_ Date: Sun, 9 Apr 2023 19:00:07 +0200 Subject: [PATCH 25/31] feat(ui): Added preferences search --- CHANGELOG.md | 1 + src/ui/about.rs | 1 + src/ui/preferences/main.rs | 5 ++--- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a69d53e1..fb804912 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Added game edition switcher - Added changelog to updated components toast - Added wine tools to settings +- Added preferences search ### Fixed diff --git a/src/ui/about.rs b/src/ui/about.rs index 163adebf..50f1f20f 100644 --- a/src/ui/about.rs +++ b/src/ui/about.rs @@ -86,6 +86,7 @@ impl SimpleComponent for AboutDialog { "
  • Added game edition switcher
  • ", "
  • Added changelog to updated components toast
  • ", "
  • Added wine tools to settings
  • ", + "
  • Added preferences search
  • ", "", "

    Fixed

    ", diff --git a/src/ui/preferences/main.rs b/src/ui/preferences/main.rs index 1d232a38..a95c80c6 100644 --- a/src/ui/preferences/main.rs +++ b/src/ui/preferences/main.rs @@ -57,11 +57,10 @@ impl SimpleAsyncComponent for PreferencesApp { preferences_window = adw::PreferencesWindow { set_title: Some(&tr("preferences")), set_default_size: (700, 560), + set_hide_on_close: true, set_modal: true, - - // FIXME: doesn't work for any reason - set_search_enabled: false, + set_search_enabled: true, add = model.general.widget(), add = model.enhancements.widget(), From 5fe9c70122aea6b23c8da733e36946996bf67753 Mon Sep 17 00:00:00 2001 From: Observer KRypt0n_ Date: Sun, 9 Apr 2023 19:15:36 +0200 Subject: [PATCH 26/31] feat(i18n): updated Chinese --- assets/locales/zh-cn/errors.ftl | 4 ++-- assets/locales/zh-cn/first_run.ftl | 2 +- assets/locales/zh-cn/general.ftl | 16 ++++++++-------- assets/locales/zh-cn/main.ftl | 4 ++-- 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/assets/locales/zh-cn/errors.ftl b/assets/locales/zh-cn/errors.ftl index bd415ce7..00cd7c2a 100644 --- a/assets/locales/zh-cn/errors.ftl +++ b/assets/locales/zh-cn/errors.ftl @@ -3,8 +3,8 @@ game-folder-opening-error = 打开游戏文件夹失败 config-file-opening-error = 打开配置文件失败 debug-file-opening-error = 打开调试文件失败 -wish-url-search-failed = No wishes url found -wish-url-opening-error = Could not open wishes url +wish-url-search-failed = 找不到祈愿 URL +wish-url-opening-error = 无法转到祈愿 URL game-launching-failed = 启动游戏失败 failed-get-selected-wine = 选择 Wine 版本失败 diff --git a/assets/locales/zh-cn/first_run.ftl b/assets/locales/zh-cn/first_run.ftl index 553cfe17..5753d3d7 100644 --- a/assets/locales/zh-cn/first_run.ftl +++ b/assets/locales/zh-cn/first_run.ftl @@ -37,7 +37,7 @@ runners-folder = 运行程序文件夹 dxvks-folder = DXVK 文件夹 wine-prefix-folder = Wine prefix 文件夹 game-installation-folder = 游戏安装文件夹 -fps-unlocker-folder = FPS Unlocker folder +fps-unlocker-folder = FPS Unlocker 文件夹 components-index = 成分指数 patch-folder = 补丁文件夹 temp-folder = 临时文件夹 diff --git a/assets/locales/zh-cn/general.ftl b/assets/locales/zh-cn/general.ftl index a3b002d5..7797f282 100644 --- a/assets/locales/zh-cn/general.ftl +++ b/assets/locales/zh-cn/general.ftl @@ -24,11 +24,11 @@ game-predownload-available = 可以预下载游戏更新: {$old} -> {$new} game-update-available = 游戏版本更新: {$old} -> {$new} game-outdated = 游戏版本过旧,无法更新。最新版本: {$latest} -player-patch-version = Player patch version -player-patch-version-description = Main patch that lets you play the game on Linux +player-patch-version = 主补丁版本 +player-patch-version-description = UnitPlayer.dll 的补丁,在 Linux 上运行游戏必备 -xlua-patch-version = Xlua patch version -xlua-patch-version-description = Additional patch that fixes some issues and improves performance on low-end PCs +xlua-patch-version = xLua 补丁版本 +xlua-patch-version-description = 额外的补丁,用于修复某些问题以及改善低端 PC 的游戏性能 patch-not-available = 不可用 patch-not-available-tooltip = 无法连接补丁服务器 @@ -40,12 +40,12 @@ patch-preparation = 开发中 patch-preparation-tooltip = 补丁还在开发中 patch-testing-tooltip = 有测试版补丁可用 -patch-not-applied-tooltip = Patch is not applied +patch-not-applied-tooltip = 补丁未应用 -apply-xlua-patch = Apply xlua patch +apply-xlua-patch = 应用 xLua 补丁 -ask-superuser-permissions = Ask superuser permissions -ask-superuser-permissions-description = Launcher will use them to automatically update your hosts file. This is not needed in flatpak edition +ask-superuser-permissions = 请求超级用户权限 +ask-superuser-permissions-description = 启动器需要超级用户权限来修改 hosts 文件。flatpak 版无需此权限 selected-version = 选择版本 recommended-only = 仅显示推荐版本 diff --git a/assets/locales/zh-cn/main.ftl b/assets/locales/zh-cn/main.ftl index 823989c6..4d45fb22 100644 --- a/assets/locales/zh-cn/main.ftl +++ b/assets/locales/zh-cn/main.ftl @@ -12,7 +12,7 @@ launcher-folder = 启动器文件夹 game-folder = 游戏文件夹 config-file = 配置文件 debug-file = 调试文件 -wish-url = Open wishes +wish-url = 转到祈愿 URL about = 关于 @@ -42,7 +42,7 @@ verifying-files = 正在检验文件 repairing-files = 正在修复文件 -components-index-updated = Components index was updated +components-index-updated = 组件索引已更新 launch = 启动 From 01748695b265bb2c984050341191111126400deb Mon Sep 17 00:00:00 2001 From: Observer KRypt0n_ Date: Sun, 9 Apr 2023 19:38:13 +0200 Subject: [PATCH 27/31] feat(i18n): added base 3.4.0 localization --- assets/locales/de/errors.ftl | 2 ++ assets/locales/de/general.ftl | 17 +++++++++++++++++ assets/locales/en/general.ftl | 17 +++++++++++++++++ assets/locales/es/errors.ftl | 2 ++ assets/locales/es/general.ftl | 17 +++++++++++++++++ assets/locales/fr/errors.ftl | 2 ++ assets/locales/fr/general.ftl | 17 +++++++++++++++++ assets/locales/ru/errors.ftl | 2 ++ assets/locales/ru/general.ftl | 19 ++++++++++++++++++- assets/locales/tr/errors.ftl | 2 ++ assets/locales/tr/general.ftl | 17 +++++++++++++++++ assets/locales/zh-cn/errors.ftl | 2 ++ assets/locales/zh-cn/general.ftl | 17 +++++++++++++++++ src/ui/preferences/general.rs | 30 ++++++++++++++---------------- 14 files changed, 146 insertions(+), 17 deletions(-) diff --git a/assets/locales/de/errors.ftl b/assets/locales/de/errors.ftl index 75f49c41..7644b571 100644 --- a/assets/locales/de/errors.ftl +++ b/assets/locales/de/errors.ftl @@ -6,6 +6,8 @@ debug-file-opening-error = Debug-Datei konnte nicht geöffnet werden wish-url-search-failed = Kein Wünsche URL gefunden wish-url-opening-error = Wünsche URL konnte nicht geöffnet werden +wine-run-error = Failed to run {$executable} executable using wine + game-launching-failed = Spiel konnte nicht gestartet werden failed-get-selected-wine = Die ausgewählte Wine version konnte nicht abgerufen werden. downloading-failed = Herunterladen fehlgeschlagen diff --git a/assets/locales/de/general.ftl b/assets/locales/de/general.ftl index 640ed50f..3fa9c9c1 100644 --- a/assets/locales/de/general.ftl +++ b/assets/locales/de/general.ftl @@ -7,12 +7,22 @@ update-background-description = Lädt das offizielle Hintergrundbild herunter f launcher-language = Launcher Sprache launcher-language-description = Gilt nach Neustart +game-edition = Game edition +global = Global +china = China + +game-environment = Game environment +game-environment-description = Get specific features like additional payment methods + game-voiceovers = Spiel Sprachen +game-voiceovers-description = List of downloaded game voiceovers. You can select them in the game settings english = Englisch japanese = Japanisch korean = Koreanisch chinese = Chinesisch +migrate-installation = Migrate installation +migrate-installation-description = Open special window where you can change your game installation folder repair-game = Spiel Reparieren status = Status @@ -53,6 +63,13 @@ recommended-only = Nur empfohlene wine-version = Wine version wine-recommended-description = Nur empfohlene wine versionen anzeigen +wine-tools = Wine tools +command-line = Command line +registry-editor = Registry editor +explorer = Explorer +task-manager = Task manager +configuration = Configuration + dxvk-version = DXVK version dxvk-selection-disabled = DXVK auswahl ist durch ihre Wine auswahl deaktiviert dxvk-recommended-description = Nur empfohlene dxvk versionen anzeigen diff --git a/assets/locales/en/general.ftl b/assets/locales/en/general.ftl index 17e715db..a85cd76f 100644 --- a/assets/locales/en/general.ftl +++ b/assets/locales/en/general.ftl @@ -7,12 +7,22 @@ update-background-description = Download official background picture for the lau launcher-language = Launcher language launcher-language-description = Applies after restart +game-edition = Game edition +global = Global +china = China + +game-environment = Game environment +game-environment-description = Get specific features like additional payment methods + game-voiceovers = Game voiceovers +game-voiceovers-description = List of downloaded game voiceovers. You can select them in the game settings english = English japanese = Japanese korean = Korean chinese = Chinese +migrate-installation = Migrate installation +migrate-installation-description = Open special window where you can change your game installation folder repair-game = Repair game status = Status @@ -53,6 +63,13 @@ recommended-only = Recommended only wine-version = Wine version wine-recommended-description = Show only recommended wine versions +wine-tools = Wine tools +command-line = Command line +registry-editor = Registry editor +explorer = Explorer +task-manager = Task manager +configuration = Configuration + dxvk-version = DXVK version dxvk-selection-disabled = DXVK selection is disabled by your wine group preferences dxvk-recommended-description = Show only recommended dxvk versions diff --git a/assets/locales/es/errors.ftl b/assets/locales/es/errors.ftl index 4d9b9c49..cb1db5b0 100755 --- a/assets/locales/es/errors.ftl +++ b/assets/locales/es/errors.ftl @@ -6,6 +6,8 @@ debug-file-opening-error = Fallo al abrir el archivo de debug wish-url-search-failed = No se encontró la URL del historial de deseos wish-url-opening-error = No se pudo abrir la URL del historial de deseos +wine-run-error = Failed to run {$executable} executable using wine + game-launching-failed = Fallo al iniciar el juego failed-get-selected-wine = Fallo al buscar la versión elegida de Wine downloading-failed = Descarga fallida diff --git a/assets/locales/es/general.ftl b/assets/locales/es/general.ftl index 0d23d2db..0ad2ad83 100755 --- a/assets/locales/es/general.ftl +++ b/assets/locales/es/general.ftl @@ -7,12 +7,22 @@ update-background-description = Descarga la imagen de fondo oficial para el laun launcher-language = Idioma del launcher launcher-language-description = Se aplica tras un reinicio. +game-edition = Game edition +global = Global +china = China + +game-environment = Game environment +game-environment-description = Get specific features like additional payment methods + game-voiceovers = Voces del juego +game-voiceovers-description = List of downloaded game voiceovers. You can select them in the game settings english = Inglés japanese = Japonés korean = Coreano chinese = Chino +migrate-installation = Migrate installation +migrate-installation-description = Open special window where you can change your game installation folder repair-game = Reparar juego status = Estado @@ -53,6 +63,13 @@ recommended-only = Sólo recomendadas wine-version = Versión de Wine wine-recommended-description = Mostrar sólo versiones recomendadas de Wine +wine-tools = Wine tools +command-line = Command line +registry-editor = Registry editor +explorer = Explorer +task-manager = Task manager +configuration = Configuration + dxvk-version = Versión de DXVK dxvk-selection-disabled = La selección de DXVK está deshabilitada por las preferencias de su grupo de vinos dxvk-recommended-description = Mostrar sólo versiones recomendadas de DXVK diff --git a/assets/locales/fr/errors.ftl b/assets/locales/fr/errors.ftl index 5a442f82..a1fda2ef 100644 --- a/assets/locales/fr/errors.ftl +++ b/assets/locales/fr/errors.ftl @@ -6,6 +6,8 @@ debug-file-opening-error = Impossible d'ouvrir le fichier débug wish-url-search-failed = No wishes url found wish-url-opening-error = Could not open wishes url +wine-run-error = Failed to run {$executable} executable using wine + game-launching-failed = Impossible de lancer le jeu failed-get-selected-wine = Impossible de récupérer la version de wine sélectionnée downloading-failed = Le téléchargement a échoué diff --git a/assets/locales/fr/general.ftl b/assets/locales/fr/general.ftl index 3384f702..3bed0d96 100644 --- a/assets/locales/fr/general.ftl +++ b/assets/locales/fr/general.ftl @@ -7,12 +7,22 @@ update-background-description = Télécharger l'image de fond du launcher offici launcher-language = Langue du launcher launcher-language-description = S'applique après un redémarrage +game-edition = Game edition +global = Global +china = China + +game-environment = Game environment +game-environment-description = Get specific features like additional payment methods + game-voiceovers = Voiceover en jeu +game-voiceovers-description = List of downloaded game voiceovers. You can select them in the game settings english = Anglais japanese = Japonais korean = Coréen chinese = Chinois +migrate-installation = Migrate installation +migrate-installation-description = Open special window where you can change your game installation folder repair-game = Réparer le jeu status = Statut @@ -53,6 +63,13 @@ recommended-only = Versions recommandées uniquement wine-version = Version de wine wine-recommended-description = N'afficher que les versions recommandées de wine +wine-tools = Wine tools +command-line = Command line +registry-editor = Registry editor +explorer = Explorer +task-manager = Task manager +configuration = Configuration + dxvk-version = Version de DXVK dxvk-selection-disabled = La sélection de versions DXVK est désactivé par vos préférences de groupe wine dxvk-recommended-description = N'afficher que les versions recommandées de DXVK diff --git a/assets/locales/ru/errors.ftl b/assets/locales/ru/errors.ftl index aeae56b0..bc6731ad 100644 --- a/assets/locales/ru/errors.ftl +++ b/assets/locales/ru/errors.ftl @@ -6,6 +6,8 @@ debug-file-opening-error = Не удалось открыть файл отла wish-url-search-failed = Ссылка на историю молитв не найдена wish-url-opening-error = Не удалось открыть ссылку с историей молитв +wine-run-error = Не удалось запустить {$executable} используя Wine + game-launching-failed = Не удалось запустить игру failed-get-selected-wine = Не удалось найти выбранную версию Wine downloading-failed = Ошибка загрузки diff --git a/assets/locales/ru/general.ftl b/assets/locales/ru/general.ftl index 40bb9f01..75b33f86 100644 --- a/assets/locales/ru/general.ftl +++ b/assets/locales/ru/general.ftl @@ -7,12 +7,22 @@ update-background-description = Скачивать фоновое изображ launcher-language = Язык лаунчера launcher-language-description = Применяется после перезапуска +game-edition = Редакция игры +global = Глобальная +china = Китайская + +game-environment = Окружение игры +game-environment-description = Получить особые функции такие как дополнительные методы оплаты + game-voiceovers = Язык озвучки +game-voiceovers-description = Список установленных озвучек игры. Вы можете выбрать их в настройках игры english = Английский japanese = Японский korean = Корейский chinese = Китайский +migrate-installation = Перенести лаунчер +migrate-installation-description = Открыть специальное окно в котором вы сможете перенести установленную игру repair-game = Починить игру status = Статус @@ -45,7 +55,7 @@ patch-not-applied-tooltip = Патч не применен apply-xlua-patch = Применить патч xlua ask-superuser-permissions = Запрашивать права суперпользователя -ask-superuser-permissions-description = Лаунчер будет использовать их чтобы автоматически обновлять ваш hosts файл. Это не требуется при использовании Flatpak +ask-superuser-permissions-description = Лаунчер будет использовать их чтобы автоматически обновлять ваш hosts файл. Это не требуется при использовании flatpak selected-version = Выбранная версия recommended-only = Только рекомендуемое @@ -53,6 +63,13 @@ recommended-only = Только рекомендуемое wine-version = Версия Wine wine-recommended-description = Показывать только рекомендуемые версии Wine +wine-tools = Инструменты Wine +command-line = Коммандная строка +registry-editor = Редактор реестра +explorer = Проводник +task-manager = Диспетчер задач +configuration = Настройки + dxvk-version = Версия DXVK dxvk-selection-disabled = Выбор версии DXVK отключен настройками выбранного вами Wine dxvk-recommended-description = Показывать только рекомендуемые версии DXVK diff --git a/assets/locales/tr/errors.ftl b/assets/locales/tr/errors.ftl index ac99d690..de9bf315 100644 --- a/assets/locales/tr/errors.ftl +++ b/assets/locales/tr/errors.ftl @@ -6,6 +6,8 @@ debug-file-opening-error = Debug dosyasını açma başarısız oldu wish-url-search-failed = Dilekler urlsi bulunamadı wish-url-opening-error = Dilekler urlsi açılamadı +wine-run-error = Failed to run {$executable} executable using wine + game-launching-failed = Oyunu açma başarısız oldu failed-get-selected-wine = Seçilen Wine versiyonunu alma başarısız oldu downloading-failed = İndirme başarısız oldu diff --git a/assets/locales/tr/general.ftl b/assets/locales/tr/general.ftl index 0b4a02ba..02b3dd1e 100644 --- a/assets/locales/tr/general.ftl +++ b/assets/locales/tr/general.ftl @@ -7,12 +7,22 @@ update-background-description = İstemci için resmi arka plan resmini indirin. launcher-language = İstemci dili launcher-language-description = Restart attıktan sonra uygulanır +game-edition = Game edition +global = Global +china = China + +game-environment = Game environment +game-environment-description = Get specific features like additional payment methods + game-voiceovers = Oyun içi sesler +game-voiceovers-description = List of downloaded game voiceovers. You can select them in the game settings english = İngilizce japanese = Japonca korean = Korece chinese = Çince +migrate-installation = Migrate installation +migrate-installation-description = Open special window where you can change your game installation folder repair-game = Oyunu tamir et status = Durum @@ -53,6 +63,13 @@ recommended-only = Sadece önerilenler wine-version = Wine versiyonu wine-recommended-description = Sadece önerilen wine versiyonlarını göster +wine-tools = Wine tools +command-line = Command line +registry-editor = Registry editor +explorer = Explorer +task-manager = Task manager +configuration = Configuration + dxvk-version = DXVK versiyonu dxvk-selection-disabled = DXVK özelliği Wine grup tercihleriniz yüzünden devre dışı dxvk-recommended-description = Sadece önerilen dxvk versiyonlarını göster diff --git a/assets/locales/zh-cn/errors.ftl b/assets/locales/zh-cn/errors.ftl index 00cd7c2a..540f4953 100644 --- a/assets/locales/zh-cn/errors.ftl +++ b/assets/locales/zh-cn/errors.ftl @@ -6,6 +6,8 @@ debug-file-opening-error = 打开调试文件失败 wish-url-search-failed = 找不到祈愿 URL wish-url-opening-error = 无法转到祈愿 URL +wine-run-error = Failed to run {$executable} executable using wine + game-launching-failed = 启动游戏失败 failed-get-selected-wine = 选择 Wine 版本失败 downloading-failed = 下载失败 diff --git a/assets/locales/zh-cn/general.ftl b/assets/locales/zh-cn/general.ftl index 7797f282..03665f7f 100644 --- a/assets/locales/zh-cn/general.ftl +++ b/assets/locales/zh-cn/general.ftl @@ -7,12 +7,22 @@ update-background-description = 下载官方启动器背景图片。你可以关 launcher-language = 启动器语言 launcher-language-description = 重启后生效 +game-edition = Game edition +global = Global +china = China + +game-environment = Game environment +game-environment-description = Get specific features like additional payment methods + game-voiceovers = 游戏语音 +game-voiceovers-description = List of downloaded game voiceovers. You can select them in the game settings english = 英语 japanese = 日语 korean = 韩语 chinese = 汉语 +migrate-installation = Migrate installation +migrate-installation-description = Open special window where you can change your game installation folder repair-game = 修复游戏 status = 状态 @@ -53,6 +63,13 @@ recommended-only = 仅显示推荐版本 wine-version = Wine 版本 wine-recommended-description = 仅显示推荐的 Wine 版本 +wine-tools = Wine tools +command-line = Command line +registry-editor = Registry editor +explorer = Explorer +task-manager = Task manager +configuration = Configuration + dxvk-version = DXVK 版本 dxvk-selection-disabled = 您的葡萄酒组首选项禁用 DXVK 选择 dxvk-recommended-description = 仅显示推荐的 DXVK 版本 diff --git a/src/ui/preferences/general.rs b/src/ui/preferences/general.rs index 8559a177..7d9bc8a1 100644 --- a/src/ui/preferences/general.rs +++ b/src/ui/preferences/general.rs @@ -279,8 +279,6 @@ impl SimpleAsyncComponent for GeneralApp { set_title: &tr("launcher-language"), set_subtitle: &tr("launcher-language-description"), - // TODO: maybe simplify it by some way? e.g. specify such stuff in i18n mod - set_model: Some(>k::StringList::new(&model.languages.iter().map(|lang| lang.as_str()).collect::>())), set_selected: { @@ -305,11 +303,11 @@ impl SimpleAsyncComponent for GeneralApp { }, adw::ComboRow { - set_title: "Game edition", + set_title: &tr("game-edition"), set_model: Some(>k::StringList::new(&[ - "Global", - "China" + &tr("global"), + &tr("china") ])), set_selected: match CONFIG.launcher.edition { @@ -340,8 +338,8 @@ impl SimpleAsyncComponent for GeneralApp { }, adw::ComboRow { - set_title: "Game environment", - set_subtitle: "Get specific features like additional payment methods", + set_title: &tr("game-environment"), + set_subtitle: &tr("game-environment-description"), set_model: Some(>k::StringList::new(&[ "PC", @@ -374,7 +372,7 @@ impl SimpleAsyncComponent for GeneralApp { #[local_ref] voice_packages -> adw::ExpanderRow { set_title: &tr("game-voiceovers"), - set_subtitle: "List of downloaded game voiceovers. You can select them in the game settings" + set_subtitle: &tr("game-voiceovers-description") }, gtk::Box { @@ -383,8 +381,8 @@ impl SimpleAsyncComponent for GeneralApp { set_margin_top: 16, gtk::Button { - set_label: "Migrate installation", - set_tooltip_text: Some("Open special window where you can change your game installation folder"), + set_label: &tr("migrate-installation"), + set_tooltip_text: Some(&tr("migrate-installation-description")), connect_clicked => GeneralAppMsg::OpenMigrateInstallation }, @@ -699,10 +697,10 @@ impl SimpleAsyncComponent for GeneralApp { add = &adw::PreferencesGroup { adw::ExpanderRow { - set_title: "Wine tools", + set_title: &tr("wine-tools"), add_row = &adw::ActionRow { - set_title: "Command line", + set_title: &tr("command-line"), set_subtitle: "start cmd", set_activatable: true, @@ -711,7 +709,7 @@ impl SimpleAsyncComponent for GeneralApp { }, add_row = &adw::ActionRow { - set_title: "Registry editor", + set_title: &tr("registry-editor"), set_subtitle: "regedit", set_activatable: true, @@ -720,7 +718,7 @@ impl SimpleAsyncComponent for GeneralApp { }, add_row = &adw::ActionRow { - set_title: "Explorer", + set_title: &tr("explorer"), set_subtitle: "explorer", set_activatable: true, @@ -729,7 +727,7 @@ impl SimpleAsyncComponent for GeneralApp { }, add_row = &adw::ActionRow { - set_title: "Task manager", + set_title: &tr("task-manager"), set_subtitle: "taskmgr", set_activatable: true, @@ -738,7 +736,7 @@ impl SimpleAsyncComponent for GeneralApp { }, add_row = &adw::ActionRow { - set_title: "Configuration", + set_title: &tr("configuration"), set_subtitle: "winecfg", set_activatable: true, From 4e173fe9b1594bf27f995ac58198226d6d082a34 Mon Sep 17 00:00:00 2001 From: Observer KRypt0n_ Date: Sun, 9 Apr 2023 19:52:43 +0200 Subject: [PATCH 28/31] feat(i18n): added base migration-related locales --- assets/locales/de/first_run.ftl | 5 ++++- assets/locales/en/first_run.ftl | 4 +++- assets/locales/es/first_run.ftl | 5 ++++- assets/locales/fr/first_run.ftl | 5 ++++- assets/locales/ru/first_run.ftl | 5 ++++- assets/locales/tr/first_run.ftl | 5 ++++- assets/locales/zh-cn/first_run.ftl | 5 ++++- src/ui/first_run/default_paths.rs | 7 +++++-- src/ui/migrate_installation.rs | 3 ++- 9 files changed, 34 insertions(+), 10 deletions(-) diff --git a/assets/locales/de/first_run.ftl b/assets/locales/de/first_run.ftl index 87b72a40..d82bd1fb 100644 --- a/assets/locales/de/first_run.ftl +++ b/assets/locales/de/first_run.ftl @@ -36,12 +36,15 @@ show-all-folders-subtitle = Zusätzliche Pfadauswahl-Einstellungen anzeigen. Tu runners-folder = Runners-Ordner dxvks-folder = DXVKs-Ordner wine-prefix-folder = Wine prefix-Ordner -game-installation-folder = Spiel-Installationsordner +global-game-installation-folder = Global game version installation folder +chinese-game-installation-folder = Chinese game version installation folder fps-unlocker-folder = FPS Unlocker Ordner components-index = Komponentenverzeichnis patch-folder = Patch-Ordner temp-folder = Temp-Ordner +migrate = Migrate + select-voice-packages = Sprachpakete auswählen diff --git a/assets/locales/en/first_run.ftl b/assets/locales/en/first_run.ftl index b18632a4..9ab26c60 100644 --- a/assets/locales/en/first_run.ftl +++ b/assets/locales/en/first_run.ftl @@ -36,7 +36,8 @@ show-all-folders-subtitle = Show additional path selection settings. Do as I say runners-folder = Runners folder dxvks-folder = DXVKs folder wine-prefix-folder = Wine prefix folder -game-installation-folder = Game installation folder +global-game-installation-folder = Global game version installation folder +chinese-game-installation-folder = Chinese game version installation folder fps-unlocker-folder = FPS Unlocker folder components-index = Components index patch-folder = Patch folder @@ -44,6 +45,7 @@ temp-folder = Temp folder migrate = Migrate + select-voice-packages = Select voice packages diff --git a/assets/locales/es/first_run.ftl b/assets/locales/es/first_run.ftl index 6be90811..d526661c 100755 --- a/assets/locales/es/first_run.ftl +++ b/assets/locales/es/first_run.ftl @@ -36,12 +36,15 @@ show-all-folders-subtitle = Muestra opciones de selección de rutas adicionales. runners-folder = Carpeta de runners dxvks-folder = Carpeta de DXVKs wine-prefix-folder = Carpeta de prefijo de Wine -game-installation-folder = Carpeta de instalación del juego +global-game-installation-folder = Global game version installation folder +chinese-game-installation-folder = Chinese game version installation folder fps-unlocker-folder = Carpeta del liberador de FPS components-index = Índice de componentes patch-folder = Carpeta del parche temp-folder = Carpeta temporal +migrate = Migrate + select-voice-packages = Elegir paquetes de voz diff --git a/assets/locales/fr/first_run.ftl b/assets/locales/fr/first_run.ftl index 6fff9989..42cc3b79 100644 --- a/assets/locales/fr/first_run.ftl +++ b/assets/locales/fr/first_run.ftl @@ -36,12 +36,15 @@ show-all-folders-subtitle = Afficher plus de paramètres de sélection d'emplace runners-folder = Emplacement des runners dxvks-folder = Emplacement des versions de DXVK wine-prefix-folder = Emplacement du préfix wine -game-installation-folder = Emplacement d'installation du jeu +global-game-installation-folder = Global game version installation folder +chinese-game-installation-folder = Chinese game version installation folder fps-unlocker-folder = Emplacement des fichiers du débloqueur de FPS components-index = Indice des composants patch-folder = Emplacement du patch temp-folder = Dossier temporaire +migrate = Migrate + select-voice-packages = Sélectionnez les packs de voix diff --git a/assets/locales/ru/first_run.ftl b/assets/locales/ru/first_run.ftl index 78b80fdb..760df537 100644 --- a/assets/locales/ru/first_run.ftl +++ b/assets/locales/ru/first_run.ftl @@ -38,12 +38,15 @@ show-all-folders-subtitle = Отобразить дополнительные о runners-folder = Папка версий Wine dxvks-folder = Папка версий DXVK wine-prefix-folder = Папка префикса Wine -game-installation-folder = Путь установки игры +global-game-installation-folder = Путь установки глобальной версии игры +chinese-game-installation-folder = Путь установки китайской версии игры fps-unlocker-folder = Папка FPS Unlocker components-index = Индекс компонентов patch-folder = Папка скачивания патча temp-folder = Временная папка +migrate = Перенести + select-voice-packages = Выбрать языковые пакеты diff --git a/assets/locales/tr/first_run.ftl b/assets/locales/tr/first_run.ftl index 25575f7c..cb61eea8 100644 --- a/assets/locales/tr/first_run.ftl +++ b/assets/locales/tr/first_run.ftl @@ -36,12 +36,15 @@ show-all-folders-subtitle = Ek yol seçimi ayarlarını göster. Dediğimi yap.. runners-folder = Başlatıcılar(Runnerlar) klasörü dxvks-folder = DXVKnın klasörü wine-prefix-folder = Wine prefixnin klasörü -game-installation-folder = Oyunun indrildiği klasör +global-game-installation-folder = Global game version installation folder +chinese-game-installation-folder = Chinese game version installation folder fps-unlocker-folder = FPS Unlocker folder components-index = Bileşenlerin dizini patch-folder = Yama klasörü temp-folder = "Geçici" klasörü +migrate = Migrate + select-voice-packages = Ses paketlerini seç diff --git a/assets/locales/zh-cn/first_run.ftl b/assets/locales/zh-cn/first_run.ftl index 5753d3d7..8ec7824a 100644 --- a/assets/locales/zh-cn/first_run.ftl +++ b/assets/locales/zh-cn/first_run.ftl @@ -36,12 +36,15 @@ show-all-folders-subtitle = 显示额外的路径选项。按我说的做... runners-folder = 运行程序文件夹 dxvks-folder = DXVK 文件夹 wine-prefix-folder = Wine prefix 文件夹 -game-installation-folder = 游戏安装文件夹 +global-game-installation-folder = Global game version installation folder +chinese-game-installation-folder = Chinese game version installation folder fps-unlocker-folder = FPS Unlocker 文件夹 components-index = 成分指数 patch-folder = 补丁文件夹 temp-folder = 临时文件夹 +migrate = Migrate + select-voice-packages = 选择语音包 diff --git a/src/ui/first_run/default_paths.rs b/src/ui/first_run/default_paths.rs index 1d09d295..d20fb297 100644 --- a/src/ui/first_run/default_paths.rs +++ b/src/ui/first_run/default_paths.rs @@ -153,7 +153,7 @@ impl SimpleAsyncComponent for DefaultPathsApp { }, adw::ActionRow { - set_title: &tr("game-installation-folder"), + set_title: &tr("global-game-installation-folder"), set_icon_name: Some("folder-symbolic"), set_activatable: true, @@ -164,7 +164,7 @@ impl SimpleAsyncComponent for DefaultPathsApp { }, adw::ActionRow { - set_title: &tr("game-installation-folder"), // FIXME + set_title: &tr("chinese-game-installation-folder"), set_icon_name: Some("folder-symbolic"), set_activatable: true, @@ -252,6 +252,9 @@ impl SimpleAsyncComponent for DefaultPathsApp { add_css_class: "pill", + #[watch] + set_visible: !model.migrate_installation, + connect_clicked => DefaultPathsAppMsg::Exit } } diff --git a/src/ui/migrate_installation.rs b/src/ui/migrate_installation.rs index 4b97f945..2c554ffe 100644 --- a/src/ui/migrate_installation.rs +++ b/src/ui/migrate_installation.rs @@ -3,6 +3,7 @@ use relm4::component::*; use gtk::prelude::*; +use crate::i18n::*; use super::first_run::default_paths::DefaultPathsApp; pub struct MigrateInstallationApp { @@ -22,7 +23,7 @@ impl SimpleComponent for MigrateInstallationApp { set_hide_on_close: true, #[watch] - set_title: Some("Migrate installation"), + set_title: Some(&tr("migrate-installation")), gtk::Box { set_orientation: gtk::Orientation::Vertical, From f66111f8e9926f8b51c7f3a9b8f37e81695ff445 Mon Sep 17 00:00:00 2001 From: Observer KRypt0n_ Date: Tue, 11 Apr 2023 20:08:54 +0200 Subject: [PATCH 29/31] feat: preparations for upcoming 3.6 changes Added support for the game files structure updating mechanism form the latest launcher SDK. Also added new progress bar statuses for applyign hdiff patches and removing outdated files --- Cargo.lock | 8 ++-- Cargo.toml | 2 +- README.md | 1 - assets/locales/de/main.ftl | 5 +++ assets/locales/en/main.ftl | 5 +++ assets/locales/es/main.ftl | 5 +++ assets/locales/fr/main.ftl | 5 +++ assets/locales/ru/main.ftl | 5 +++ assets/locales/tr/main.ftl | 5 +++ assets/locales/zh-cn/main.ftl | 5 +++ src/main.rs | 3 +- src/move_folder.rs | 26 +++++++++++++ src/ui/components/progress_bar.rs | 50 +++++++++++++++++++------ src/ui/components/version.rs | 12 +++--- src/ui/first_run/default_paths.rs | 28 +------------- src/ui/first_run/download_components.rs | 6 +-- src/ui/main/download_diff.rs | 9 +++-- src/ui/main/download_wine.rs | 5 ++- src/ui/main/migrate_folder.rs | 25 +++++++++++++ src/ui/main/mod.rs | 34 ++++++++++------- 20 files changed, 171 insertions(+), 73 deletions(-) create mode 100644 src/move_folder.rs create mode 100644 src/ui/main/migrate_folder.rs diff --git a/Cargo.lock b/Cargo.lock index 8e61321c..896c865d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -40,8 +40,8 @@ dependencies = [ [[package]] name = "anime-game-core" -version = "1.5.2" -source = "git+https://github.com/an-anime-team/anime-game-core?tag=1.5.2#002bed907fc47c53d18764fb87aec2398413f1a0" +version = "1.6.0" +source = "git+https://github.com/an-anime-team/anime-game-core?tag=1.6.0#e08cef50412928cca426534644142de0fe6a8499" dependencies = [ "anyhow", "bzip2", @@ -86,8 +86,8 @@ dependencies = [ [[package]] name = "anime-launcher-sdk" -version = "0.5.14" -source = "git+https://github.com/an-anime-team/anime-launcher-sdk?tag=0.5.14#98de4c7d707ed7428257953526625e8f168f7d84" +version = "0.5.15" +source = "git+https://github.com/an-anime-team/anime-launcher-sdk?tag=0.5.15#5ebd018a5d5bd6fd0e06d0ab9459a7aec53dcd98" dependencies = [ "anime-game-core", "anyhow", diff --git a/Cargo.toml b/Cargo.toml index 66ef36a4..ebc72a10 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -17,7 +17,7 @@ glib-build-tools = "0.17" [dependencies.anime-launcher-sdk] git = "https://github.com/an-anime-team/anime-launcher-sdk" -tag = "0.5.14" +tag = "0.5.15" # path = "../anime-launcher-sdk" # ! for dev purposes only diff --git a/README.md b/README.md index 4bc73528..310e9453 100644 --- a/README.md +++ b/README.md @@ -55,7 +55,6 @@ This should be automatically enabled if you're using zh_cn (Chinese) as your sys | Folder | Description | | - | - | -| anime-launcher-sdk | Unified core functionality for the launcher | | src | Rust source code | | assets | App assets folder | | assets/locales | App localizations | diff --git a/assets/locales/de/main.ftl b/assets/locales/de/main.ftl index f58f4fbe..e2c9a862 100644 --- a/assets/locales/de/main.ftl +++ b/assets/locales/de/main.ftl @@ -40,12 +40,17 @@ downloading = Lade Herunter unpacking = Entpacken verifying-files = Verifiziere Dateien repairing-files = Repariere Dateien +migrating-folders = Migrating folders +applying-hdiff = Applying hdiff patches +removing-outdated = Removing outdated files components-index-updated = Kompontentenverzeichnis würde aktualisiert launch = Starten +migrate-folders = Migrate folders +migrate-folders-tooltip = Update game folders structure apply-patch = Patch anwenden download-wine = Wine Herunterladen create-prefix = Prefix erstellen diff --git a/assets/locales/en/main.ftl b/assets/locales/en/main.ftl index 8f921d15..f36da468 100644 --- a/assets/locales/en/main.ftl +++ b/assets/locales/en/main.ftl @@ -40,12 +40,17 @@ downloading = Downloading unpacking = Unpacking verifying-files = Verifying files repairing-files = Repairing files +migrating-folders = Migrating folders +applying-hdiff = Applying hdiff patches +removing-outdated = Removing outdated files components-index-updated = Components index was updated launch = Launch +migrate-folders = Migrate folders +migrate-folders-tooltip = Update game folders structure apply-patch = Apply patch download-wine = Download wine create-prefix = Create prefix diff --git a/assets/locales/es/main.ftl b/assets/locales/es/main.ftl index 975fa7f1..3510d72e 100755 --- a/assets/locales/es/main.ftl +++ b/assets/locales/es/main.ftl @@ -40,12 +40,17 @@ downloading = Descargando unpacking = Descomprimiendo verifying-files = Verificación de archivos repairing-files = Reparación de archivos +migrating-folders = Migrating folders +applying-hdiff = Applying hdiff patches +removing-outdated = Removing outdated files components-index-updated = Se actualizó el índice de componentes launch = Iniciar +migrate-folders = Migrate folders +migrate-folders-tooltip = Update game folders structure apply-patch = Aplicar parche download-wine = Descargar wine create-prefix = Crear prefijo diff --git a/assets/locales/fr/main.ftl b/assets/locales/fr/main.ftl index 2244e865..f473b7dd 100644 --- a/assets/locales/fr/main.ftl +++ b/assets/locales/fr/main.ftl @@ -40,12 +40,17 @@ downloading = Téléchargement unpacking = Décompression verifying-files = Vérification des fichiers repairing-files = Réparation des fichiers +migrating-folders = Migrating folders +applying-hdiff = Applying hdiff patches +removing-outdated = Removing outdated files components-index-updated = L'index des composants a été mis à jour launch = Lancer +migrate-folders = Migrate folders +migrate-folders-tooltip = Update game folders structure apply-patch = Appliquer le patch download-wine = Télécharger wine create-prefix = Créer le préfix wine diff --git a/assets/locales/ru/main.ftl b/assets/locales/ru/main.ftl index eea1e757..1cb3861b 100644 --- a/assets/locales/ru/main.ftl +++ b/assets/locales/ru/main.ftl @@ -46,12 +46,17 @@ downloading = Загрузка unpacking = Распаковка verifying-files = Проверка файлов repairing-files = Починка файлов +migrating-folders = Перемещение папок +applying-hdiff = Применение патчей hdiff +removing-outdated = Удаление устаревших файлов components-index-updated = Индекс компонентов был обновлен launch = Запустить +migrate-folders = Переместить папки +migrate-folders-tooltip = Обновить структуру файлов игры apply-patch = Применить патч download-wine = Установить Wine create-prefix = Создать префикс diff --git a/assets/locales/tr/main.ftl b/assets/locales/tr/main.ftl index 67c0e45b..0dd70c61 100644 --- a/assets/locales/tr/main.ftl +++ b/assets/locales/tr/main.ftl @@ -40,12 +40,17 @@ downloading = İndiriliyor unpacking = Paketten çıkartılıyor verifying-files = Dosyalar Doğrulanıyor repairing-files = Dosyalar tamir ediliyor +migrating-folders = Migrating folders +applying-hdiff = Applying hdiff patches +removing-outdated = Removing outdated files components-index-updated = Components index was updated launch = Çalıştır +migrate-folders = Migrate folders +migrate-folders-tooltip = Update game folders structure apply-patch = Yamayı uygula download-wine = Wine indir create-prefix = Prefix oluştur diff --git a/assets/locales/zh-cn/main.ftl b/assets/locales/zh-cn/main.ftl index 4d45fb22..38ea420e 100644 --- a/assets/locales/zh-cn/main.ftl +++ b/assets/locales/zh-cn/main.ftl @@ -40,12 +40,17 @@ downloading = 正在下载 unpacking = 正在解压缩 verifying-files = 正在检验文件 repairing-files = 正在修复文件 +migrating-folders = Migrating folders +applying-hdiff = Applying hdiff patches +removing-outdated = Removing outdated files components-index-updated = 组件索引已更新 launch = 启动 +migrate-folders = Migrate folders +migrate-folders-tooltip = Update game folders structure apply-patch = 安装补丁 download-wine = 下载 Wine create-prefix = 创建 Wine prefix diff --git a/src/main.rs b/src/main.rs index 70c2f777..f17433f0 100644 --- a/src/main.rs +++ b/src/main.rs @@ -12,9 +12,10 @@ use tracing_subscriber::filter::*; use std::path::PathBuf; +pub mod move_folder; pub mod i18n; -pub mod ui; pub mod background; +pub mod ui; use ui::main::*; use ui::first_run::main::*; diff --git a/src/move_folder.rs b/src/move_folder.rs new file mode 100644 index 00000000..c9756074 --- /dev/null +++ b/src/move_folder.rs @@ -0,0 +1,26 @@ +use std::path::Path; + +pub fn move_folder(from: &Path, to: &Path) -> std::io::Result<()> { + if !to.exists() { + std::fs::create_dir_all(to)?; + } + + for entry in from.read_dir()?.flatten() { + let to_path = to.join(entry.file_name()); + + if entry.metadata()?.is_dir() { + move_folder(&entry.path(), &to_path)?; + } + + else if entry.metadata()?.is_file() { + std::fs::copy(entry.path(), to_path)?; + std::fs::remove_file(entry.path())?; + } + + // TODO: symlinks? + } + + std::fs::remove_dir_all(from)?; + + Ok(()) +} diff --git a/src/ui/components/progress_bar.rs b/src/ui/components/progress_bar.rs index 2d86ddfa..681e0289 100644 --- a/src/ui/components/progress_bar.rs +++ b/src/ui/components/progress_bar.rs @@ -3,8 +3,7 @@ use relm4::component::*; use adw::prelude::*; -use anime_launcher_sdk::anime_game_core::installer::installer::Update as InstallerUpdate; -use anime_launcher_sdk::anime_game_core::prettify_bytes::prettify_bytes; +use anime_launcher_sdk::anime_game_core::prelude::*; use crate::i18n::*; @@ -44,7 +43,7 @@ pub enum ProgressBarMsg { /// (current bytes, total bytes) UpdateProgress(u64, u64), - UpdateFromState(InstallerUpdate), + UpdateFromState(DiffUpdate), SetVisible(bool) } @@ -128,12 +127,36 @@ impl SimpleAsyncComponent for ProgressBar { ProgressBarMsg::UpdateFromState(state) => { match state { - InstallerUpdate::CheckingFreeSpace(_) => self.caption = Some(tr("checking-free-space")), - InstallerUpdate::DownloadingStarted(_) => self.caption = Some(tr("downloading")), - InstallerUpdate::UnpackingStarted(_) => self.caption = Some(tr("unpacking")), + DiffUpdate::InstallerUpdate(InstallerUpdate::CheckingFreeSpace(_)) => self.caption = Some(tr("checking-free-space")), - InstallerUpdate::DownloadingProgress(curr, total) | - InstallerUpdate::UnpackingProgress(curr, total) => { + DiffUpdate::InstallerUpdate(InstallerUpdate::DownloadingStarted(_)) => { + self.caption = Some(tr("downloading")); + + self.display_fraction = true; + } + + DiffUpdate::InstallerUpdate(InstallerUpdate::UnpackingStarted(_)) => { + self.caption = Some(tr("unpacking")); + + self.display_fraction = true; + } + + DiffUpdate::ApplyingHdiffStarted => { + self.caption = Some(tr("applying-hdiff")); + + self.display_fraction = false; + } + + DiffUpdate::RemovingOutdatedStarted => { + self.caption = Some(tr("removing-outdated")); + + self.display_fraction = false; + } + + DiffUpdate::InstallerUpdate(InstallerUpdate::DownloadingProgress(curr, total)) | + DiffUpdate::InstallerUpdate(InstallerUpdate::UnpackingProgress(curr, total)) | + DiffUpdate::ApplyingHdiffProgress(curr, total) | + DiffUpdate::RemovingOutdatedProgress(curr, total) => { self.fraction = curr as f64 / total as f64; self.downloaded = Some(( @@ -142,11 +165,14 @@ impl SimpleAsyncComponent for ProgressBar { )); } - InstallerUpdate::DownloadingFinished => tracing::info!("Downloading finished"), - InstallerUpdate::UnpackingFinished => tracing::info!("Unpacking finished"), + DiffUpdate::InstallerUpdate(InstallerUpdate::DownloadingFinished) => tracing::info!("Downloading finished"), + DiffUpdate::InstallerUpdate(InstallerUpdate::UnpackingFinished) => tracing::info!("Unpacking finished"), + + DiffUpdate::ApplyingHdiffFinished => tracing::info!("Applying hdiffs finished"), + DiffUpdate::RemovingOutdatedFinished => tracing::info!("Removing outdated files finished"), - InstallerUpdate::DownloadingError(err) => tracing::error!("Downloading error: {:?}", err), - InstallerUpdate::UnpackingError(err) => tracing::error!("Unpacking error: {:?}", err) + DiffUpdate::InstallerUpdate(InstallerUpdate::DownloadingError(err)) => tracing::error!("Downloading error: {:?}", err), + DiffUpdate::InstallerUpdate(InstallerUpdate::UnpackingError(err)) => tracing::error!("Unpacking error: {:?}", err) } } diff --git a/src/ui/components/version.rs b/src/ui/components/version.rs index 6e7e9f1c..5f10ca3f 100644 --- a/src/ui/components/version.rs +++ b/src/ui/components/version.rs @@ -9,7 +9,7 @@ use gtk::glib::clone; use super::progress_bar::ProgressBarMsg; use anime_launcher_sdk::config; -use anime_launcher_sdk::anime_game_core::installer::installer::*; +use anime_launcher_sdk::anime_game_core::prelude::*; use std::path::PathBuf; @@ -162,12 +162,12 @@ impl SimpleAsyncComponent for ComponentVersion { installer.install(download_folder, move |state| { match &state { - Update::UnpackingFinished | - Update::DownloadingError(_) | - Update::UnpackingError(_) => { + InstallerUpdate::UnpackingFinished | + InstallerUpdate::DownloadingError(_) | + InstallerUpdate::UnpackingError(_) => { progress_bar_sender.send(ProgressBarMsg::SetVisible(false)); - if let Update::UnpackingFinished = &state { + if let InstallerUpdate::UnpackingFinished = &state { sender.input(AppMsg::SetState(VersionState::Downloaded)); sender.output(super::group::AppMsg::CallOnDownloaded); } @@ -180,7 +180,7 @@ impl SimpleAsyncComponent for ComponentVersion { _ => () } - progress_bar_sender.send(ProgressBarMsg::UpdateFromState(state)); + progress_bar_sender.send(ProgressBarMsg::UpdateFromState(DiffUpdate::InstallerUpdate(state))); }); })); } diff --git a/src/ui/first_run/default_paths.rs b/src/ui/first_run/default_paths.rs index d20fb297..ca78482f 100644 --- a/src/ui/first_run/default_paths.rs +++ b/src/ui/first_run/default_paths.rs @@ -5,7 +5,7 @@ use adw::prelude::*; use anime_launcher_sdk::config; -use std::path::{Path, PathBuf}; +use std::path::PathBuf; use crate::*; use crate::i18n::*; @@ -381,30 +381,6 @@ impl SimpleAsyncComponent for DefaultPathsApp { (old_config.game.enhancements.fps_unlocker.path, &self.fps_unlocker) ]; - fn move_folder(from: &Path, to: &Path) -> std::io::Result<()> { - if !to.exists() { - std::fs::create_dir_all(to); - } - - for entry in from.read_dir()?.flatten() { - let to_path = to.join(entry.file_name()); - - if entry.metadata()?.is_dir() { - move_folder(&entry.path(), &to_path)?; - } - - else if entry.metadata()?.is_file() { - std::fs::copy(entry.path(), &to_path); - } - - // TODO: symlinks? - } - - std::fs::remove_dir_all(from)?; - - Ok(()) - } - #[allow(clippy::expect_fun_call)] for (i, (from, to)) in folders.iter().enumerate() { self.progress_bar.sender().send(ProgressBarMsg::UpdateCaption(Some( @@ -412,7 +388,7 @@ impl SimpleAsyncComponent for DefaultPathsApp { ))); if &from != to && from.exists() { - move_folder(from, to).expect(&format!("Failed to move folder: {:?} -> {:?}", from, to)); + move_folder::move_folder(from, to).expect(&format!("Failed to move folder: {:?} -> {:?}", from, to)); } self.progress_bar.sender().send(ProgressBarMsg::UpdateProgress(i as u64 + 1, folders.len() as u64)); diff --git a/src/ui/first_run/download_components.rs b/src/ui/first_run/download_components.rs index 6d187011..987e6e6f 100644 --- a/src/ui/first_run/download_components.rs +++ b/src/ui/first_run/download_components.rs @@ -3,9 +3,9 @@ use relm4::component::*; use adw::prelude::*; +use anime_launcher_sdk::anime_game_core::prelude::*; use anime_launcher_sdk::components::*; use anime_launcher_sdk::components::wine::WincompatlibWine; -use anime_launcher_sdk::anime_game_core::installer::prelude::*; use anime_launcher_sdk::config; use anime_launcher_sdk::wincompatlib::prelude::*; @@ -421,7 +421,7 @@ impl SimpleAsyncComponent for DownloadComponentsApp { _ => () } - progress_bar_input.send(ProgressBarMsg::UpdateFromState(update)); + progress_bar_input.send(ProgressBarMsg::UpdateFromState(DiffUpdate::InstallerUpdate(update))); }); } @@ -532,7 +532,7 @@ impl SimpleAsyncComponent for DownloadComponentsApp { _ => () } - progress_bar_input.send(ProgressBarMsg::UpdateFromState(update)); + progress_bar_input.send(ProgressBarMsg::UpdateFromState(DiffUpdate::InstallerUpdate(update))); }); } diff --git a/src/ui/main/download_diff.rs b/src/ui/main/download_diff.rs index 48a778ad..c35d4d3b 100644 --- a/src/ui/main/download_diff.rs +++ b/src/ui/main/download_diff.rs @@ -20,10 +20,9 @@ pub fn download_diff(sender: ComponentSender, progress_bar_input: Sender move |state| { match &state { - InstallerUpdate::DownloadingError(err) => { + DiffUpdate::InstallerUpdate(InstallerUpdate::DownloadingError(err)) => { tracing::error!("Downloading failed: {err}"); sender.input(AppMsg::Toast { @@ -32,7 +31,7 @@ pub fn download_diff(sender: ComponentSender, progress_bar_input: Sender { + DiffUpdate::InstallerUpdate(InstallerUpdate::UnpackingError(err)) => { tracing::error!("Unpacking failed: {err}"); sender.input(AppMsg::Toast { @@ -44,7 +43,9 @@ pub fn download_diff(sender: ComponentSender, progress_bar_input: Sender () } - progress_bar_input.send(ProgressBarMsg::UpdateFromState(state)); + #[allow(unused_must_use)] { + progress_bar_input.send(ProgressBarMsg::UpdateFromState(state)); + } })); let mut perform_on_download_needed = true; diff --git a/src/ui/main/download_wine.rs b/src/ui/main/download_wine.rs index d8137645..d33ea3c8 100644 --- a/src/ui/main/download_wine.rs +++ b/src/ui/main/download_wine.rs @@ -55,7 +55,6 @@ pub fn download_wine(sender: ComponentSender, progress_bar_input: Sender move || { - #[allow(unused_must_use)] installer.install(&config.game.wine.builds, clone!(@strong sender => move |state| { match &state { InstallerUpdate::DownloadingError(err) => { @@ -79,7 +78,9 @@ pub fn download_wine(sender: ComponentSender, progress_bar_input: Sender () } - progress_bar_input.send(ProgressBarMsg::UpdateFromState(state)); + #[allow(unused_must_use)] { + progress_bar_input.send(ProgressBarMsg::UpdateFromState(DiffUpdate::InstallerUpdate(state))); + } })); config.game.wine.selected = Some(wine.name.clone()); diff --git a/src/ui/main/migrate_folder.rs b/src/ui/main/migrate_folder.rs new file mode 100644 index 00000000..74d6b61f --- /dev/null +++ b/src/ui/main/migrate_folder.rs @@ -0,0 +1,25 @@ +use relm4::prelude::*; + +use std::path::PathBuf; + +use crate::*; +use super::{App, AppMsg}; + +pub fn migrate_folder(sender: ComponentSender, from: PathBuf, to: PathBuf, cleanup_folder: Option) { + sender.input(AppMsg::DisableButtons(true)); + + std::thread::spawn(move || { + move_folder::move_folder(&from, &to).expect("Failed to perform migration"); + + if let Some(cleanup_folder) = cleanup_folder { + std::fs::remove_dir_all(cleanup_folder).expect("Failed to remove cleanup folder"); + } + + sender.input(AppMsg::DisableButtons(false)); + sender.input(AppMsg::UpdateLauncherState { + perform_on_download_needed: false, + apply_patch_if_needed: false, + show_status_page: true + }); + }); +} diff --git a/src/ui/main/mod.rs b/src/ui/main/mod.rs index 830dcc12..0ed377dc 100644 --- a/src/ui/main/mod.rs +++ b/src/ui/main/mod.rs @@ -15,6 +15,7 @@ mod apply_patch; mod download_wine; mod create_prefix; mod download_diff; +mod migrate_folder; mod launch; use anime_launcher_sdk::config::launcher::LauncherStyle; @@ -371,18 +372,19 @@ impl SimpleComponent for App { gtk::Button { #[watch] set_label: &match model.state { - Some(LauncherState::Launch) => tr("launch"), - Some(LauncherState::PredownloadAvailable { .. }) => tr("launch"), - Some(LauncherState::UnityPlayerPatchAvailable(_)) => tr("apply-patch"), - Some(LauncherState::XluaPatchAvailable(_)) => tr("apply-patch"), - Some(LauncherState::WineNotInstalled) => tr("download-wine"), - Some(LauncherState::PrefixNotExists) => tr("create-prefix"), - Some(LauncherState::VoiceUpdateAvailable(_)) => tr("update"), - Some(LauncherState::VoiceOutdated(_)) => tr("update"), - Some(LauncherState::VoiceNotInstalled(_)) => tr("download"), - Some(LauncherState::GameUpdateAvailable(_)) => tr("update"), - Some(LauncherState::GameOutdated(_)) => tr("update"), - Some(LauncherState::GameNotInstalled(_)) => tr("download"), + Some(LauncherState::Launch) => tr("launch"), + Some(LauncherState::PredownloadAvailable { .. }) => tr("launch"), + Some(LauncherState::FolderMigrationRequired { .. }) => tr("migrate-folders"), + Some(LauncherState::UnityPlayerPatchAvailable(_)) => tr("apply-patch"), + Some(LauncherState::XluaPatchAvailable(_)) => tr("apply-patch"), + Some(LauncherState::WineNotInstalled) => tr("download-wine"), + Some(LauncherState::PrefixNotExists) => tr("create-prefix"), + Some(LauncherState::VoiceUpdateAvailable(_)) => tr("update"), + Some(LauncherState::VoiceOutdated(_)) => tr("update"), + Some(LauncherState::VoiceNotInstalled(_)) => tr("download"), + Some(LauncherState::GameUpdateAvailable(_)) => tr("update"), + Some(LauncherState::GameOutdated(_)) => tr("update"), + Some(LauncherState::GameNotInstalled(_)) => tr("download"), None => String::from("...") }, @@ -432,6 +434,8 @@ impl SimpleComponent for App { Some(LauncherState::GameOutdated { .. }) | Some(LauncherState::VoiceOutdated(_)) => tr("main-window--version-outdated-tooltip"), + Some(LauncherState::FolderMigrationRequired { .. }) => tr("migrate-folders-tooltip"), + Some(LauncherState::UnityPlayerPatchAvailable(UnityPlayerPatch { status, .. })) | Some(LauncherState::XluaPatchAvailable(XluaPatch { status, .. })) => match status { PatchStatus::NotAvailable => tr("main-window--patch-unavailable-tooltip"), @@ -1006,6 +1010,9 @@ impl SimpleComponent for App { LauncherState::PredownloadAvailable { .. } | LauncherState::Launch => launch::launch(sender), + LauncherState::FolderMigrationRequired { from, to, cleanup_folder } => + migrate_folder::migrate_folder(sender, from.to_owned(), to.to_owned(), cleanup_folder.to_owned()), + LauncherState::UnityPlayerPatchAvailable(patch) => apply_patch::apply_patch(sender, patch.to_owned()), LauncherState::XluaPatchAvailable(patch) => apply_patch::apply_patch(sender, patch.to_owned()), @@ -1016,7 +1023,8 @@ impl SimpleComponent for App { LauncherState::VoiceUpdateAvailable(diff) | LauncherState::VoiceNotInstalled(diff) | LauncherState::GameUpdateAvailable(diff) | - LauncherState::GameNotInstalled(diff) => download_diff::download_diff(sender, self.progress_bar.sender().to_owned(), diff.to_owned()), + LauncherState::GameNotInstalled(diff) => + download_diff::download_diff(sender, self.progress_bar.sender().to_owned(), diff.to_owned()), LauncherState::VoiceOutdated(_) | LauncherState::GameOutdated(_) => () From 3e17e24348d4fa3a82a5deda27b44b374ac1e034 Mon Sep 17 00:00:00 2001 From: Observer KRypt0n_ Date: Tue, 11 Apr 2023 22:05:07 +0200 Subject: [PATCH 30/31] feat(i18n): updated Spanish --- assets/locales/es/errors.ftl | 2 +- assets/locales/es/first_run.ftl | 6 +++--- assets/locales/es/general.ftl | 24 ++++++++++++------------ 3 files changed, 16 insertions(+), 16 deletions(-) diff --git a/assets/locales/es/errors.ftl b/assets/locales/es/errors.ftl index cb1db5b0..97a76a8a 100755 --- a/assets/locales/es/errors.ftl +++ b/assets/locales/es/errors.ftl @@ -6,7 +6,7 @@ debug-file-opening-error = Fallo al abrir el archivo de debug wish-url-search-failed = No se encontró la URL del historial de deseos wish-url-opening-error = No se pudo abrir la URL del historial de deseos -wine-run-error = Failed to run {$executable} executable using wine +wine-run-error = Fallo al correr el ejecutable {$executable} usando Wine game-launching-failed = Fallo al iniciar el juego failed-get-selected-wine = Fallo al buscar la versión elegida de Wine diff --git a/assets/locales/es/first_run.ftl b/assets/locales/es/first_run.ftl index d526661c..4dff8d14 100755 --- a/assets/locales/es/first_run.ftl +++ b/assets/locales/es/first_run.ftl @@ -36,14 +36,14 @@ show-all-folders-subtitle = Muestra opciones de selección de rutas adicionales. runners-folder = Carpeta de runners dxvks-folder = Carpeta de DXVKs wine-prefix-folder = Carpeta de prefijo de Wine -global-game-installation-folder = Global game version installation folder -chinese-game-installation-folder = Chinese game version installation folder +global-game-installation-folder = Carpeta de instalación de la edición Global +chinese-game-installation-folder = Carpeta de instalación de la edición China fps-unlocker-folder = Carpeta del liberador de FPS components-index = Índice de componentes patch-folder = Carpeta del parche temp-folder = Carpeta temporal -migrate = Migrate +migrate = Migrar select-voice-packages = Elegir paquetes de voz diff --git a/assets/locales/es/general.ftl b/assets/locales/es/general.ftl index 0ad2ad83..74ca0ffa 100755 --- a/assets/locales/es/general.ftl +++ b/assets/locales/es/general.ftl @@ -7,22 +7,22 @@ update-background-description = Descarga la imagen de fondo oficial para el laun launcher-language = Idioma del launcher launcher-language-description = Se aplica tras un reinicio. -game-edition = Game edition +game-edition = Edición del Juego global = Global china = China -game-environment = Game environment -game-environment-description = Get specific features like additional payment methods +game-environment = Entorno del juego +game-environment-description = Da acceso a funciones específicas como medios de pago adicionales game-voiceovers = Voces del juego -game-voiceovers-description = List of downloaded game voiceovers. You can select them in the game settings +game-voiceovers-description = Lista de voces del juego descargadas. Puedes elegirlas en las opciones del juego english = Inglés japanese = Japonés korean = Coreano chinese = Chino -migrate-installation = Migrate installation -migrate-installation-description = Open special window where you can change your game installation folder +migrate-installation = Migrar instalación +migrate-installation-description = Abre una ventana especial donde puedes cambiar tu carpeta de instalación del juego repair-game = Reparar juego status = Estado @@ -63,12 +63,12 @@ recommended-only = Sólo recomendadas wine-version = Versión de Wine wine-recommended-description = Mostrar sólo versiones recomendadas de Wine -wine-tools = Wine tools -command-line = Command line -registry-editor = Registry editor -explorer = Explorer -task-manager = Task manager -configuration = Configuration +wine-tools = Herramientas de Wine +command-line = Línea de Comandos +registry-editor = Editor del Registro +explorer = Explorador +task-manager = Administrador de Tareas +configuration = Configuración dxvk-version = Versión de DXVK dxvk-selection-disabled = La selección de DXVK está deshabilitada por las preferencias de su grupo de vinos From fc096b6e181ae6e281769a487233e03ba85091b6 Mon Sep 17 00:00:00 2001 From: Observer KRypt0n_ Date: Tue, 11 Apr 2023 22:39:12 +0200 Subject: [PATCH 31/31] 3.4.0 --- CHANGELOG.md | 2 ++ Cargo.lock | 10 +++++----- Cargo.toml | 4 ++-- src/ui/about.rs | 2 ++ 4 files changed, 11 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index fb804912..36bd00eb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Added changelog to updated components toast - Added wine tools to settings - Added preferences search +- Added new progress bar statuses for applyign hdiff patches and removing outdated files +- Added automatic 3.5 -> 3.6 voiceover files migration related to changed files structure ### Fixed diff --git a/Cargo.lock b/Cargo.lock index 896c865d..5881b769 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -40,8 +40,8 @@ dependencies = [ [[package]] name = "anime-game-core" -version = "1.6.0" -source = "git+https://github.com/an-anime-team/anime-game-core?tag=1.6.0#e08cef50412928cca426534644142de0fe6a8499" +version = "1.6.1" +source = "git+https://github.com/an-anime-team/anime-game-core?tag=1.6.1#2396d1e6538523c0ea1da2f9e75469fff035e44e" dependencies = [ "anyhow", "bzip2", @@ -64,7 +64,7 @@ dependencies = [ [[package]] name = "anime-game-launcher" -version = "3.3.0" +version = "3.4.0" dependencies = [ "anime-launcher-sdk", "anyhow", @@ -86,8 +86,8 @@ dependencies = [ [[package]] name = "anime-launcher-sdk" -version = "0.5.15" -source = "git+https://github.com/an-anime-team/anime-launcher-sdk?tag=0.5.15#5ebd018a5d5bd6fd0e06d0ab9459a7aec53dcd98" +version = "0.5.16" +source = "git+https://github.com/an-anime-team/anime-launcher-sdk?tag=0.5.16#a36215db4613ba284d8b2215ec822df64ce73404" dependencies = [ "anime-game-core", "anyhow", diff --git a/Cargo.toml b/Cargo.toml index ebc72a10..def4fd55 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "anime-game-launcher" -version = "3.3.0" +version = "3.4.0" description = "Anime Game launcher" authors = ["Nikita Podvirnyy "] license = "GPL-3.0" @@ -17,7 +17,7 @@ glib-build-tools = "0.17" [dependencies.anime-launcher-sdk] git = "https://github.com/an-anime-team/anime-launcher-sdk" -tag = "0.5.15" +tag = "0.5.16" # path = "../anime-launcher-sdk" # ! for dev purposes only diff --git a/src/ui/about.rs b/src/ui/about.rs index 50f1f20f..62e6fb87 100644 --- a/src/ui/about.rs +++ b/src/ui/about.rs @@ -87,6 +87,8 @@ impl SimpleComponent for AboutDialog { "
  • Added changelog to updated components toast
  • ", "
  • Added wine tools to settings
  • ", "
  • Added preferences search
  • ", + "
  • Added new progress bar statuses for applyign hdiff patches and removing outdated files
  • ", + "
  • Added automatic 3.5 -> 3.6 voiceover files migration related to changed files structure
  • ", "", "

    Fixed

    ",