mirror of
https://github.com/an-anime-team/an-anime-game-launcher.git
synced 2025-02-16 15:22:01 +03:00
0.3.1
- 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:
parent
2ce9e44a86
commit
9ff00c7085
5 changed files with 45 additions and 12 deletions
|
@ -1,6 +1,6 @@
|
|||
[package]
|
||||
name = "anime-game-launcher"
|
||||
version = "0.3.0"
|
||||
version = "0.3.1"
|
||||
description = "Anime Game launcher"
|
||||
authors = ["Nikita Podvirnyy <suimin.tu.mu.ga.mi@gmail.com>"]
|
||||
license = "GPL-3.0"
|
||||
|
|
|
@ -250,6 +250,7 @@ Adw.ApplicationWindow window {
|
|||
Gtk.Button {
|
||||
label: "Pause";
|
||||
sensitive: false;
|
||||
tooltip-text: "Work in progress";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -103,6 +103,7 @@ Adw.ApplicationWindow window {
|
|||
Gtk.Button {
|
||||
label: "Pause";
|
||||
sensitive: false;
|
||||
tooltip-text: "Work in progress";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,7 +26,8 @@ async fn main() {
|
|||
.expect("Failed to register resources");
|
||||
|
||||
// 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
|
||||
let application = gtk::Application::new(
|
||||
|
|
|
@ -9,6 +9,7 @@ use std::cell::Cell;
|
|||
use std::io::Error;
|
||||
|
||||
use anime_game_core::prelude::*;
|
||||
use wait_not_await::Await;
|
||||
|
||||
use crate::ui::*;
|
||||
|
||||
|
@ -293,8 +294,9 @@ impl App {
|
|||
ProgressUpdateResult::Updated => (),
|
||||
|
||||
ProgressUpdateResult::Error(msg, err) => {
|
||||
this.update(Actions::ToastError(Rc::new((msg, err)))).unwrap();
|
||||
this.update(Actions::HideProgressBar).unwrap();
|
||||
this.widgets.progress_bar.hide();
|
||||
|
||||
this.toast_error(msg, err);
|
||||
}
|
||||
|
||||
ProgressUpdateResult::Finished => {
|
||||
|
@ -304,7 +306,8 @@ impl App {
|
|||
|
||||
config::update(config);
|
||||
|
||||
this.update(Actions::HideProgressBar).unwrap();
|
||||
this.widgets.progress_bar.hide();
|
||||
|
||||
this.update_state();
|
||||
}
|
||||
}
|
||||
|
@ -345,7 +348,9 @@ impl App {
|
|||
this.widgets.launch_game.set_sensitive(false);
|
||||
|
||||
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);
|
||||
|
@ -373,14 +378,29 @@ impl App {
|
|||
ProgressUpdateResult::Updated => (),
|
||||
|
||||
ProgressUpdateResult::Error(msg, err) => {
|
||||
this.update(Actions::ToastError(Rc::new((msg, err)))).unwrap();
|
||||
this.update(Actions::HideProgressBar).unwrap();
|
||||
this.widgets.progress_bar.hide();
|
||||
|
||||
this.toast_error(msg, err);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
pub fn update_state(&self) {
|
||||
pub fn update_state(&self) -> Await<Result<LauncherState, String>> {
|
||||
let this = self.clone();
|
||||
|
||||
let (send, recv) = std::sync::mpsc::channel();
|
||||
|
||||
this.widgets.status_page.show();
|
||||
this.widgets.launcher_content.hide();
|
||||
|
||||
std::thread::spawn(move || {
|
||||
match LauncherState::get(Some(&this.widgets.status_page)) {
|
||||
Ok(state) => {
|
||||
this.set_state(state);
|
||||
this.set_state(state.clone());
|
||||
|
||||
this.widgets.status_page.hide();
|
||||
this.widgets.launcher_content.show();
|
||||
|
||||
send.send(Ok(state)).unwrap();
|
||||
},
|
||||
Err(err) => {
|
||||
send.send(Err(err.to_string())).unwrap();
|
||||
|
||||
glib::MainContext::default().invoke(move || {
|
||||
this.toast_error("Failed to get initial launcher state", err);
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
Await::new(move || {
|
||||
recv.recv().unwrap()
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue