From bcdb0217ade88eb9ac226d76a884f041ae11049d Mon Sep 17 00:00:00 2001 From: Observer KRypt0n_ Date: Thu, 4 Aug 2022 17:23:05 +0200 Subject: [PATCH] Several changes - updated core library; this fixes getting available space on systems with lots of disks - added patch folder selection during initial setup - fixed error panicking when you're closing folder selection dialogue during initial setup --- Cargo.lock | 2 +- anime-game-core | 2 +- assets/ui/first_run/default_paths.blp | 6 +++++- src/ui/first_run/default_paths.rs | 16 +++++++++++++--- src/ui/main.rs | 12 ++++++++++-- 5 files changed, 30 insertions(+), 8 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index d9690e0..e65ef37 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -31,7 +31,7 @@ dependencies = [ [[package]] name = "anime-game-core" -version = "0.3.2" +version = "0.3.4" dependencies = [ "bzip2", "curl", diff --git a/anime-game-core b/anime-game-core index 7c1279a..ea6d863 160000 --- a/anime-game-core +++ b/anime-game-core @@ -1 +1 @@ -Subproject commit 7c1279a6c3df8ea1eda70064aaa5b7b340aef4ce +Subproject commit ea6d8638d8167badf2ef1753621560003412e3c8 diff --git a/assets/ui/first_run/default_paths.blp b/assets/ui/first_run/default_paths.blp index b2a5a7e..8174c21 100644 --- a/assets/ui/first_run/default_paths.blp +++ b/assets/ui/first_run/default_paths.blp @@ -9,7 +9,6 @@ Gtk.Box page { Adw.PreferencesGroup { Gtk.Label { label: "Set default paths"; - margin-top: 16; styles ["title-1"] } @@ -39,6 +38,11 @@ Gtk.Box page { activatable: true; } + Adw.ActionRow patch_folder { + title: "Patch storing folder"; + activatable: true; + } + Adw.ActionRow temp_folder { title: "Temp data saving folder"; activatable: true; diff --git a/src/ui/first_run/default_paths.rs b/src/ui/first_run/default_paths.rs index 4807ba0..9fac97a 100644 --- a/src/ui/first_run/default_paths.rs +++ b/src/ui/first_run/default_paths.rs @@ -9,7 +9,7 @@ use wait_not_await::Await; use crate::lib::config; use crate::ui::*; -pub fn choose_dir>(current_folder: String, parent: &T) -> Await { +pub fn choose_dir>(current_folder: String, parent: &T) -> Await> { let dialogue = gtk::FileChooserDialog::new( Some("Select folder"), Some(parent), @@ -32,7 +32,10 @@ pub fn choose_dir>(current_folder: String, parent: &T) -> Aw dialogue.show(); Await::new(move || { - receiver.recv().unwrap() + match receiver.recv() { + Ok(path) => Some(path), + Err(_) => None + } }) } @@ -45,6 +48,7 @@ pub struct Page { pub dxvk_folder: adw::ActionRow, pub prefix_folder: adw::ActionRow, pub game_folder: adw::ActionRow, + pub patch_folder: adw::ActionRow, pub temp_folder: adw::ActionRow, pub continue_button: gtk::Button, @@ -63,6 +67,7 @@ impl Page { dxvk_folder: get_object(&builder, "dxvk_folder")?, prefix_folder: get_object(&builder, "prefix_folder")?, game_folder: get_object(&builder, "game_folder")?, + patch_folder: get_object(&builder, "patch_folder")?, temp_folder: get_object(&builder, "temp_folder")?, continue_button: get_object(&builder, "continue_button")?, @@ -79,6 +84,7 @@ impl Page { result.dxvk_folder.set_subtitle(&config.game.dxvk.builds); result.prefix_folder.set_subtitle(&config.game.wine.prefix); result.game_folder.set_subtitle(&config.game.path); + result.patch_folder.set_subtitle(&config.patch.path); result.temp_folder.set_subtitle(&match config.launcher.temp { Some(temp) => temp, None => String::from("/tmp") @@ -89,6 +95,7 @@ impl Page { result.connect_activated(&result.dxvk_folder); result.connect_activated(&result.prefix_folder); result.connect_activated(&result.game_folder); + result.connect_activated(&result.patch_folder); result.connect_activated(&result.temp_folder); Ok(result) @@ -99,7 +106,9 @@ impl Page { let (sender, receiver) = glib::MainContext::channel::(glib::PRIORITY_DEFAULT); choose_dir(row.subtitle().unwrap().to_string(), &window).then(move |path| { - sender.send(path.clone()).unwrap(); + if let Some(path) = path { + sender.send(path.clone()).unwrap(); + } }); let row = row.clone(); @@ -117,6 +126,7 @@ impl Page { config.game.dxvk.builds = self.dxvk_folder.subtitle().unwrap().to_string(); config.game.wine.prefix = self.prefix_folder.subtitle().unwrap().to_string(); config.game.path = self.game_folder.subtitle().unwrap().to_string(); + config.patch.path = self.patch_folder.subtitle().unwrap().to_string(); config.launcher.temp = Some(self.temp_folder.subtitle().unwrap().to_string()); config diff --git a/src/ui/main.rs b/src/ui/main.rs index 7aa95aa..2322d82 100644 --- a/src/ui/main.rs +++ b/src/ui/main.rs @@ -474,7 +474,9 @@ impl App { LauncherState::GameUpdateAvailable(diff) | LauncherState::GameNotInstalled(diff) => { let (sender, receiver) = glib::MainContext::channel::(glib::PRIORITY_DEFAULT); + let this = this.clone(); + let this_copy = this.clone(); this.update(Actions::ShowProgressBar).unwrap(); @@ -516,9 +518,15 @@ impl App { // Download diff in separate thread to not to freeze the main one std::thread::spawn(move || { - diff.install_to_by(config.game.path, config.launcher.temp, move |state| { + let result = diff.install_to_by(config.game.path, config.launcher.temp, move |state| { sender.send(state).unwrap(); - }).unwrap(); + }); + + if let Err(err) = result { + this_copy.update(Actions::Toast(Rc::new(( + String::from("Downloading failed"), err.into() + )))).unwrap(); + } }); },