diff --git a/Cargo.lock b/Cargo.lock index adfa6d2..bf5645b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -63,8 +63,8 @@ checksum = "5c6cb57a04249c6480766f7f7cef5467412af1490f8d1e243141daddada3264f" [[package]] name = "anime-game-core" -version = "1.24.2" -source = "git+https://github.com/an-anime-team/anime-game-core?tag=1.24.2#dd0e9fd265d7600005840fe4cbda9f1a76d7b520" +version = "1.25.0" +source = "git+https://github.com/an-anime-team/anime-game-core?tag=1.25.0#4c6efced5fccacc82831d31881ae80635306db20" dependencies = [ "anyhow", "bzip2", @@ -113,13 +113,11 @@ dependencies = [ [[package]] name = "anime-launcher-sdk" -version = "1.20.3" -source = "git+https://github.com/an-anime-team/anime-launcher-sdk?tag=1.20.3#a101b856e8e2d7b57ca6566b2752d2c8ab7cc3d9" +version = "1.21.0" dependencies = [ "anime-game-core", "anyhow", "cached", - "discord-rich-presence", "enum-ordinalize", "lazy_static", "md-5", @@ -756,18 +754,6 @@ dependencies = [ "subtle", ] -[[package]] -name = "discord-rich-presence" -version = "0.2.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f632a41e3e97febf8edff46b1405f9875894c29e20a25c5abe566872226b3f84" -dependencies = [ - "serde", - "serde_derive", - "serde_json", - "uuid 0.8.2", -] - [[package]] name = "dispatch" version = "0.2.0" @@ -1489,7 +1475,7 @@ dependencies = [ "serde", "serde_derive", "toml", - "uuid 1.10.0", + "uuid", ] [[package]] @@ -2926,15 +2912,6 @@ version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821" -[[package]] -name = "uuid" -version = "0.8.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bc5cf98d8186244414c848017f0e2676b3fcb46807f6668a97dfe67359a3c4b7" -dependencies = [ - "getrandom", -] - [[package]] name = "uuid" version = "1.10.0" diff --git a/Cargo.toml b/Cargo.toml index 26af3f4..b56fd79 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -18,11 +18,11 @@ opt-level = "s" glib-build-tools = "0.20" [dependencies.anime-launcher-sdk] -git = "https://github.com/an-anime-team/anime-launcher-sdk" -tag = "1.20.3" +# git = "https://github.com/an-anime-team/anime-launcher-sdk" +# tag = "1.20.3" features = ["all", "genshin"] -# path = "../anime-launcher-sdk" # ! for dev purposes only +path = "../anime-launcher-sdk" # ! for dev purposes only [dependencies] relm4 = { version = "0.9.0", features = ["macros", "libadwaita"] } diff --git a/src/ui/preferences/enhancements/mod.rs b/src/ui/preferences/enhancements/mod.rs index a2e5969..5dc481e 100644 --- a/src/ui/preferences/enhancements/mod.rs +++ b/src/ui/preferences/enhancements/mod.rs @@ -1,20 +1,10 @@ use relm4::prelude::*; - -use relm4::factory::{ - AsyncFactoryComponent, - AsyncFactorySender, - AsyncFactoryVecDeque -}; - use adw::prelude::*; use anime_launcher_sdk::config::ConfigExt; use anime_launcher_sdk::genshin::config::Config; use anime_launcher_sdk::config::schema_blanks::prelude::*; -use anime_launcher_sdk::anime_game_core::installer::downloader::Downloader; - -use anime_launcher_sdk::discord_rpc::DiscordRpc; use anime_launcher_sdk::is_available; use enum_ordinalize::Ordinalize; @@ -32,64 +22,7 @@ use crate::*; use super::gamescope::*; use super::main::PreferencesAppMsg; -#[derive(Debug)] -struct DiscordRpcIcon { - pub check_button: gtk::CheckButton, - - pub name: String, - pub path: PathBuf -} - -#[relm4::factory(async)] -impl AsyncFactoryComponent for DiscordRpcIcon { - type Init = Self; - type Input = EnhancementsAppMsg; - type Output = EnhancementsAppMsg; - type CommandOutput = (); - type ParentWidget = adw::ExpanderRow; - - view! { - root = adw::ActionRow { - set_title: &self.name, - // set_subtitle: &self.name, - - // Don't even try to understand - add_prefix = &self.check_button.clone(), - - add_suffix = >k::Picture { - set_margin_start: 4, - set_margin_top: 4, - set_margin_end: 4, - set_margin_bottom: 4, - - add_css_class: "round-bin", - - set_filename: Some(&self.path) - }, - - set_activatable: true, - - connect_activated[sender, index] => move |_| { - sender.output(EnhancementsAppMsg::SetDiscordRpcIcon(index.clone())) - .unwrap(); - } - } - } - - #[inline] - async fn init_model( - init: Self::Init, - _index: &DynamicIndex, - _sender: AsyncFactorySender, - ) -> Self { - init - } -} - pub struct EnhancementsApp { - discord_rpc_icons: AsyncFactoryVecDeque, - discord_rpc_root_check_button: gtk::CheckButton, - gamescope: AsyncController, game_page: AsyncController, sandbox_page: AsyncController, @@ -99,9 +32,6 @@ pub struct EnhancementsApp { #[derive(Debug)] pub enum EnhancementsAppMsg { SetGamescopeParent, - - SetDiscordRpcIcon(DynamicIndex), - OpenGamescope, OpenMainPage, OpenGameSettingsPage, @@ -488,65 +418,6 @@ impl SimpleAsyncComponent for EnhancementsApp { } }, - add = &adw::PreferencesGroup { - set_title: &tr!("discord-rpc"), - - adw::ActionRow { - set_title: &tr!("enabled"), - set_subtitle: &tr!("discord-rpc-description"), - - add_suffix = >k::Switch { - set_valign: gtk::Align::Center, - set_active: CONFIG.launcher.discord_rpc.enabled, - - connect_state_notify => |switch| { - if is_ready() { - if let Ok(mut config) = Config::get() { - config.launcher.discord_rpc.enabled = switch.is_active(); - - Config::update(config); - } - } - } - } - }, - - #[local_ref] - discord_rpc_icons -> adw::ExpanderRow { - set_title: &tr!("icon") - }, - - adw::EntryRow { - set_title: &tr!("title"), - set_text: &CONFIG.launcher.discord_rpc.title, - - connect_changed: |row| { - if is_ready() { - if let Ok(mut config) = Config::get() { - config.launcher.discord_rpc.title = row.text().to_string(); - - Config::update(config); - } - } - } - }, - - adw::EntryRow { - set_title: &tr!("description"), - set_text: &CONFIG.launcher.discord_rpc.subtitle, - - connect_changed: |row| { - if is_ready() { - if let Ok(mut config) = Config::get() { - config.launcher.discord_rpc.subtitle = row.text().to_string(); - - Config::update(config); - } - } - } - } - }, - add = &adw::PreferencesGroup { set_title: &tr!("fps-unlocker"), @@ -646,13 +517,7 @@ impl SimpleAsyncComponent for EnhancementsApp { ) -> AsyncComponentParts { tracing::info!("Initializing enhancements settings"); - let mut model = Self { - discord_rpc_icons: AsyncFactoryVecDeque::builder() - .launch_default() - .forward(sender.input_sender(), std::convert::identity), - - discord_rpc_root_check_button: gtk::CheckButton::new(), - + let model = Self { gamescope: GamescopeApp::builder() .launch(()) .detach(), @@ -670,73 +535,6 @@ impl SimpleAsyncComponent for EnhancementsApp { .forward(sender.input_sender(), std::convert::identity) }; - match DiscordRpc::get_assets(CONFIG.launcher.discord_rpc.app_id) { - Ok(icons) => { - for icon in icons { - let cache_file = CACHE_FOLDER - .join("discord-rpc") - .join(&icon.name) - .join(&icon.id); - - // let sender = sender.clone(); - - // Workaround for old folder structure (pre 3.7.3) - let old_path = CACHE_FOLDER.join("discord-rpc").join(&icon.name); - - if old_path.exists() { - if let Ok(metadata) = old_path.metadata() { - if metadata.is_file() { - std::fs::remove_file(old_path).expect("Failed to delete old discord rpc icon"); - } - } - } - - if !cache_file.exists() { - std::thread::spawn(move || { - Downloader::new(icon.get_uri()) - .expect("Failed to init Discord RPC icon downloader") - .with_continue_downloading(false) - .with_free_space_check(false) - .download(cache_file, |_, _| {}) - .expect("Failed to download Discord RPC icon"); - - /*if let Err(err) = result { - sender.input(EnhancementsAppMsg::Toast { - title: tr!("discord-rpc-icon-download-failed"), - description: Some(err.to_string()) - }); - }*/ - }); - } - - // TODO: add icons after thread above finishes its work as well - else { - let check_button = gtk::CheckButton::new(); - - check_button.set_group(Some(&model.discord_rpc_root_check_button)); - - if CONFIG.launcher.discord_rpc.icon == icon.name { - check_button.set_active(true); - } - - model.discord_rpc_icons.guard().push_back(DiscordRpcIcon { - check_button, - - name: icon.name.clone(), - path: cache_file.clone() - }); - } - } - } - - Err(err) => sender.input(EnhancementsAppMsg::Toast { - title: tr!("discord-rpc-icons-fetch-failed"), - description: Some(err.to_string()) - }) - } - - let discord_rpc_icons = model.discord_rpc_icons.widget(); - let game_page = model.game_page.widget(); let sandbox_page = model.sandbox_page.widget(); let environment_page = model.environment_page.widget(); @@ -752,18 +550,6 @@ impl SimpleAsyncComponent for EnhancementsApp { self.gamescope.widget().set_transient_for(super::main::PREFERENCES_WINDOW.as_ref()); } - EnhancementsAppMsg::SetDiscordRpcIcon(index) => { - if let Some(icon) = self.discord_rpc_icons.guard().get(index.current_index()) { - if let Ok(mut config) = Config::get() { - config.launcher.discord_rpc.icon.clone_from(&icon.name); - - Config::update(config); - - icon.check_button.set_active(true); - } - } - } - EnhancementsAppMsg::OpenGamescope => { self.gamescope.widget().present(); }