From ecb509478599da4629d96022e7e6768343ce90cc Mon Sep 17 00:00:00 2001 From: Observer KRypt0n_ Date: Thu, 28 Jul 2022 09:39:24 +0200 Subject: [PATCH] 0.2.0 - updated core library to 0.1.3 - added soda wine version - added default patch servers for config file - with core modifications now first run window finally works --- Cargo.toml | 2 +- anime-game-core | 2 +- assets/ui/first_run.blp | 47 ++++++++++ assets/wine.json | 45 ++++++++++ src/lib/config/mod.rs | 5 +- src/ui/components/progress_bar.rs | 17 +++- src/ui/first_run.rs | 140 ++++++++++++++++++++---------- 7 files changed, 207 insertions(+), 51 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index aa30a88..5b97ba3 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "anime-game-launcher" -version = "0.1.1" +version = "0.2.0" description = "Anime Game launcher" authors = ["Nikita Podvirnyy "] license = "GPL-3.0" diff --git a/anime-game-core b/anime-game-core index f5c91f0..33893a3 160000 --- a/anime-game-core +++ b/anime-game-core @@ -1 +1 @@ -Subproject commit f5c91f01561cd12873e92bb51b37c7d68ca0cd99 +Subproject commit 33893a336d4051e14ce6ed1da81a18910f0a82b0 diff --git a/assets/ui/first_run.blp b/assets/ui/first_run.blp index 7466bdb..7d83c2a 100644 --- a/assets/ui/first_run.blp +++ b/assets/ui/first_run.blp @@ -255,6 +255,53 @@ Adw.ApplicationWindow window { } } } + + // Fourth page (downloading finished) + + Gtk.Box fourth_page { + orientation: vertical; + hexpand: true; + + Adw.PreferencesPage { + Adw.PreferencesGroup { + Gtk.Label { + label: "Downloading finished!"; + margin-top: 16; + + styles ["title-1"] + } + + Gtk.Label { + label: "All the basic components were downloaded. Now you can restart the launcher and download the game. Welcome to our club!"; + + wrap: true; + justify: center; + margin-top: 32; + } + } + + Adw.PreferencesGroup { + vexpand: true; + valign: center; + + Gtk.Box { + orientation: horizontal; + spacing: 8; + halign: center; + + Gtk.Button fourth_page_restart { + label: "Restart"; + + styles ["suggested-action"] + } + + Gtk.Button fourth_page_exit { + label: "Exit"; + } + } + } + } + } } Adw.CarouselIndicatorDots { diff --git a/assets/wine.json b/assets/wine.json index 9ae5d73..f21ebac 100644 --- a/assets/wine.json +++ b/assets/wine.json @@ -492,6 +492,51 @@ } ] }, + { + "title": "Soda", + "subtitle": "New runner based on Valveā€™s Wine, with patches from Proton, TKG and GE. Developed by Bottles", + "versions": [ + { + "family": "Soda", + "name": "soda-7.0-2-x86_64", + "title": "Soda 7.0-2", + "uri": "https://github.com/bottlesdevs/wine/releases/download/soda-7.0-2/soda-7.0-2-x86_64.tar.xz", + "files": { + "wine": "bin/wine64", + "wineserver": "bin/wineserver", + "wineboot": "bin/wineboot", + "winecfg": "lib/wine/x86_64-windows/winecfg.exe" + }, + "recommended": true + }, + { + "family": "Soda", + "name": "soda-7.0-1-x86_64", + "title": "Soda 7.0-1", + "uri": "https://github.com/bottlesdevs/wine/releases/download/soda-7.0-1/soda-7.0-1-x86_64.tar.xz", + "files": { + "wine": "bin/wine64", + "wineserver": "bin/wineserver", + "wineboot": "bin/wineboot", + "winecfg": "lib/wine/x86_64-windows/winecfg.exe" + }, + "recommended": true + }, + { + "family": "Soda", + "name": "soda-7.0-x86_64", + "title": "Soda 7.0", + "uri": "https://github.com/bottlesdevs/wine/releases/download/soda-7.0/soda-7.0-x86_64.tar.xz", + "files": { + "wine": "bin/wine64", + "wineserver": "bin/wineserver", + "wineboot": "bin/wineboot", + "winecfg": "lib/wine/x86_64-windows/winecfg.exe" + }, + "recommended": true + } + ] + }, { "title": "Lutris", "subtitle": null, diff --git a/src/lib/config/mod.rs b/src/lib/config/mod.rs index 7c6f7be..8f62832 100644 --- a/src/lib/config/mod.rs +++ b/src/lib/config/mod.rs @@ -197,7 +197,10 @@ impl Default for Patch { Some(dir) => format!("{}/patch", dir), None => String::new() }, - servers: Vec::new() + servers: vec![ + "https://notabug.org/Krock/dawn".to_string(), + "https://dev.kaifa.ch/Maroxy/dawn".to_string() + ] } } } diff --git a/src/ui/components/progress_bar.rs b/src/ui/components/progress_bar.rs index b345720..05ab179 100644 --- a/src/ui/components/progress_bar.rs +++ b/src/ui/components/progress_bar.rs @@ -6,7 +6,8 @@ use gtk::glib; use std::io::Error; use anime_game_core::prelude::*; -use wait_not_await::Await; + +use crate::lib::prettify_bytes::prettify_bytes; #[derive(Debug)] pub enum ProgressUpdateResult { @@ -56,13 +57,23 @@ impl ProgressBar { InstallerUpdate::DownloadingProgress(curr, total) => { let progress = curr as f64 / total as f64; - self.update(progress, None); + self.update(progress, Some(&format!( + "Downloading: {:.2}% ({} of {})", + progress * 100.0, + prettify_bytes(curr), + prettify_bytes(total) + ))); } InstallerUpdate::UnpackingProgress(curr, total) => { let progress = curr as f64 / total as f64; - self.update(progress, None); + self.update(progress, Some(&format!( + "Unpacking: {:.2}% ({} of {})", + progress * 100.0, + prettify_bytes(curr), + prettify_bytes(total) + ))); } InstallerUpdate::DownloadingFinished => (), diff --git a/src/ui/first_run.rs b/src/ui/first_run.rs index a34b2de..4546410 100644 --- a/src/ui/first_run.rs +++ b/src/ui/first_run.rs @@ -45,7 +45,12 @@ pub struct AppWidgets { pub third_page_download: gtk::Button, pub third_page_exit: gtk::Button, - pub third_page_progress_bar: ProgressBar + pub third_page_progress_bar: ProgressBar, + + // Fourth page + pub fourth_page: gtk::Box, + pub fourth_page_restart: gtk::Button, + pub fourth_page_exit: gtk::Button } impl AppWidgets { @@ -79,6 +84,11 @@ impl AppWidgets { get_object(&builder, "third_page_buttons_group")?, get_object(&builder, "third_page_progress_bar_group")? ), + + // Fourth page + fourth_page: get_object(&builder, "fourth_page")?, + fourth_page_restart: get_object(&builder, "fourth_page_restart")?, + fourth_page_exit: get_object(&builder, "fourth_page_exit")? }) } } @@ -93,6 +103,8 @@ pub enum Actions { FirstPageContinue, SecondPageContinue, ThirdPageDownload, + ThirdPageContinue, + FourthPageRestart, Exit } @@ -151,9 +163,11 @@ impl App { self.widgets.first_page_continue.connect_clicked(Actions::FirstPageContinue.into_fn(&self)); self.widgets.second_page_continue.connect_clicked(Actions::SecondPageContinue.into_fn(&self)); self.widgets.third_page_download.connect_clicked(Actions::ThirdPageDownload.into_fn(&self)); + self.widgets.fourth_page_restart.connect_clicked(Actions::FourthPageRestart.into_fn(&self)); self.widgets.second_page_exit.connect_clicked(Actions::Exit.into_fn(&self)); self.widgets.third_page_exit.connect_clicked(Actions::Exit.into_fn(&self)); + self.widgets.fourth_page_exit.connect_clicked(Actions::Exit.into_fn(&self)); self } @@ -185,58 +199,94 @@ impl App { this.widgets.third_page_progress_bar.show(); - let this = this.clone(); + let (sender, receiver) = glib::MainContext::channel::(glib::PRIORITY_DEFAULT); + let progress_bar = this.widgets.third_page_progress_bar.clone(); + + let wine_version = WineVersion::latest().unwrap(); + let dxvk_version = DxvkVersion::latest().unwrap(); + + let wine_version_copy = wine_version.clone(); + + // Download wine std::thread::spawn(move || { let config = config::get().unwrap(); - let wine_version = WineVersion::latest().unwrap(); - let dxvk_version = DxvkVersion::latest().unwrap(); - - let mut wine_version_installer = Installer::new(&wine_version.uri).unwrap(); - - let progress_bar = this.widgets.third_page_progress_bar.clone(); + let mut wine_version_installer = Installer::new(&wine_version_copy.uri).unwrap(); wine_version_installer.install(&config.game.wine.builds, move |state| { - match progress_bar.update_from_state(state) { - ProgressUpdateResult::Updated => (), - ProgressUpdateResult::Error(_, _) => todo!(), - - ProgressUpdateResult::Finished => { - let mut config = config::get().unwrap(); - let prefix = WinePrefix::new(&config.game.wine.prefix); - - config.game.wine.selected = Some(wine_version.name.clone()); - - config::update_raw(config.clone()).unwrap(); - - prefix.update(&config.game.wine.builds, wine_version.clone()).unwrap(); - - let mut dxvk_version_installer = Installer::new(&dxvk_version.uri).unwrap(); - - let dxvk_version = dxvk_version.clone(); - let progress_bar = progress_bar.clone(); - - dxvk_version_installer.install(&config.game.dxvk.builds, move |state| { - match progress_bar.update_from_state(state) { - ProgressUpdateResult::Updated => (), - ProgressUpdateResult::Error(_, _) => todo!(), - - ProgressUpdateResult::Finished => { - let mut config = config::get().unwrap(); - - config.game.dxvk.selected = Some(dxvk_version.name.clone()); - - config::update_raw(config.clone()).unwrap(); - - println!("Done!!"); - } - } - }); - } - } + sender.send(state).unwrap(); }); }); + + let this = this.clone(); + + // Download wine (had to do so this way) + receiver.attach(None, move |state| { + match progress_bar.update_from_state(state) { + ProgressUpdateResult::Updated => (), + ProgressUpdateResult::Error(_, _) => todo!(), + + ProgressUpdateResult::Finished => { + let mut config = config::get().unwrap(); + let prefix = WinePrefix::new(&config.game.wine.prefix); + + // Update wine config + config.game.wine.selected = Some(wine_version.name.clone()); + + config::update_raw(config.clone()).unwrap(); + + // Create wine prefix + prefix.update(&config.game.wine.builds, wine_version.clone()).unwrap(); + + // Prepare DXVK downloader + let mut dxvk_version_installer = Installer::new(&dxvk_version.uri).unwrap(); + + let dxvk_version = dxvk_version.clone(); + let progress_bar = progress_bar.clone(); + + let this = this.clone(); + + // Download DXVK + dxvk_version_installer.install(&config.game.dxvk.builds, move |state| { + match progress_bar.update_from_state(state) { + ProgressUpdateResult::Updated => (), + ProgressUpdateResult::Error(_, _) => todo!(), + + ProgressUpdateResult::Finished => { + let mut config = config::get().unwrap(); + + // Apply DXVK + println!("{}", dxvk_version.apply(&config.game.dxvk.builds, &config.game.wine.prefix).unwrap()); + + // Update dxvk config + config.game.dxvk.selected = Some(dxvk_version.name.clone()); + + config::update_raw(config.clone()).unwrap(); + + // Remove .first-run file + let launcher_dir = crate::lib::consts::launcher_dir().unwrap(); + std::fs::remove_file(format!("{}/.first-run", launcher_dir)).unwrap(); + + // Show next page + this.update(Actions::ThirdPageContinue).unwrap(); + } + } + }); + } + } + + glib::Continue(true) + }); + } + + Actions::ThirdPageContinue => { + this.widgets.carousel.scroll_to(&this.widgets.fourth_page, true); + } + + // FIXME + Actions::FourthPageRestart => { + this.widgets.window.close(); } Actions::Exit => {