- added automatic downloading if you already clicked "download" button
  so e.g. you don't need to press "download" button two times to download the game
  and then download its voiceover
- reduced amount of action calls
- added "WIP" tooltips for progress pause buttons
This commit is contained in:
Observer KRypt0n_ 2022-07-28 18:54:28 +02:00
parent 2ce9e44a86
commit 9ff00c7085
No known key found for this signature in database
GPG key ID: 844DA47BA25FE1E2
5 changed files with 45 additions and 12 deletions

View file

@ -1,6 +1,6 @@
[package] [package]
name = "anime-game-launcher" name = "anime-game-launcher"
version = "0.3.0" version = "0.3.1"
description = "Anime Game launcher" description = "Anime Game launcher"
authors = ["Nikita Podvirnyy <suimin.tu.mu.ga.mi@gmail.com>"] authors = ["Nikita Podvirnyy <suimin.tu.mu.ga.mi@gmail.com>"]
license = "GPL-3.0" license = "GPL-3.0"

View file

@ -250,6 +250,7 @@ Adw.ApplicationWindow window {
Gtk.Button { Gtk.Button {
label: "Pause"; label: "Pause";
sensitive: false; sensitive: false;
tooltip-text: "Work in progress";
} }
} }
} }

View file

@ -103,6 +103,7 @@ Adw.ApplicationWindow window {
Gtk.Button { Gtk.Button {
label: "Pause"; label: "Pause";
sensitive: false; sensitive: false;
tooltip-text: "Work in progress";
} }
} }
} }

View file

@ -26,7 +26,8 @@ async fn main() {
.expect("Failed to register resources"); .expect("Failed to register resources");
// Set application's title // Set application's title
gtk::glib::set_prgname(Some("An Anime Game Launcher")); gtk::glib::set_application_name("An Anime Game Launcher");
gtk::glib::set_program_name(Some("An Anime Game Launcher"));
// Create app // Create app
let application = gtk::Application::new( let application = gtk::Application::new(

View file

@ -9,6 +9,7 @@ use std::cell::Cell;
use std::io::Error; use std::io::Error;
use anime_game_core::prelude::*; use anime_game_core::prelude::*;
use wait_not_await::Await;
use crate::ui::*; use crate::ui::*;
@ -293,8 +294,9 @@ impl App {
ProgressUpdateResult::Updated => (), ProgressUpdateResult::Updated => (),
ProgressUpdateResult::Error(msg, err) => { ProgressUpdateResult::Error(msg, err) => {
this.update(Actions::ToastError(Rc::new((msg, err)))).unwrap(); this.widgets.progress_bar.hide();
this.update(Actions::HideProgressBar).unwrap();
this.toast_error(msg, err);
} }
ProgressUpdateResult::Finished => { ProgressUpdateResult::Finished => {
@ -304,7 +306,8 @@ impl App {
config::update(config); config::update(config);
this.update(Actions::HideProgressBar).unwrap(); this.widgets.progress_bar.hide();
this.update_state(); this.update_state();
} }
} }
@ -345,7 +348,9 @@ impl App {
this.widgets.launch_game.set_sensitive(false); this.widgets.launch_game.set_sensitive(false);
if let Err(err) = prefix.update(&config.game.wine.builds, wine) { if let Err(err) = prefix.update(&config.game.wine.builds, wine) {
this.toast_error("Failed to create wine prefix", err); this.update(Actions::ToastError(Rc::new((
String::from("Failed to create wine prefix"), err
)))).unwrap();
} }
this.widgets.launch_game.set_sensitive(true); this.widgets.launch_game.set_sensitive(true);
@ -373,14 +378,29 @@ impl App {
ProgressUpdateResult::Updated => (), ProgressUpdateResult::Updated => (),
ProgressUpdateResult::Error(msg, err) => { ProgressUpdateResult::Error(msg, err) => {
this.update(Actions::ToastError(Rc::new((msg, err)))).unwrap(); this.widgets.progress_bar.hide();
this.update(Actions::HideProgressBar).unwrap();
this.toast_error(msg, err);
} }
ProgressUpdateResult::Finished => { ProgressUpdateResult::Finished => {
this.update(Actions::HideProgressBar).unwrap(); this.widgets.progress_bar.hide();
this.update_state(); let this = this.clone();
this.update_state().then(move |result| {
if let Ok(state) = result {
match state {
LauncherState::VoiceUpdateAvailable(_) |
LauncherState::VoiceNotInstalled(_) |
LauncherState::GameUpdateAvailable(_) |
LauncherState::GameNotInstalled(_) => {
this.update(Actions::PerformButtonEvent).unwrap();
},
_ => ()
}
}
});
} }
} }
@ -497,27 +517,37 @@ impl App {
self.values.set(values); self.values.set(values);
} }
pub fn update_state(&self) { pub fn update_state(&self) -> Await<Result<LauncherState, String>> {
let this = self.clone(); let this = self.clone();
let (send, recv) = std::sync::mpsc::channel();
this.widgets.status_page.show(); this.widgets.status_page.show();
this.widgets.launcher_content.hide(); this.widgets.launcher_content.hide();
std::thread::spawn(move || { std::thread::spawn(move || {
match LauncherState::get(Some(&this.widgets.status_page)) { match LauncherState::get(Some(&this.widgets.status_page)) {
Ok(state) => { Ok(state) => {
this.set_state(state); this.set_state(state.clone());
this.widgets.status_page.hide(); this.widgets.status_page.hide();
this.widgets.launcher_content.show(); this.widgets.launcher_content.show();
send.send(Ok(state)).unwrap();
}, },
Err(err) => { Err(err) => {
send.send(Err(err.to_string())).unwrap();
glib::MainContext::default().invoke(move || { glib::MainContext::default().invoke(move || {
this.toast_error("Failed to get initial launcher state", err); this.toast_error("Failed to get initial launcher state", err);
}); });
} }
} }
}); });
Await::new(move || {
recv.recv().unwrap()
})
} }
} }