Now launcher will run the game with --run-game flag

even when predownloading is available, but if
update was already predownloaded
This commit is contained in:
Observer KRypt0n_ 2022-10-31 15:53:30 +02:00
parent a462583b7b
commit e375af1c95
No known key found for this signature in database
GPG key ID: 844DA47BA25FE1E2
2 changed files with 39 additions and 7 deletions

View file

@ -107,14 +107,46 @@ fn main() {
}
else {
use lib::launcher::states::LauncherState;
awaiter.then(move |state| {
match state.as_ref().expect("Failed to load launcher state") {
lib::launcher::states::LauncherState::Launch => {
let mut state = state.as_ref().expect("Failed to load launcher state");
#[allow(clippy::or_fun_call)]
if let LauncherState::PredownloadAvailable { game, voices } = state {
if let Ok(config) = lib::config::get() {
let mut predownloaded = true;
let temp = config.launcher.temp.unwrap_or("/tmp".into());
if !temp.join(game.file_name().unwrap_or(String::from("\0"))).exists() {
predownloaded = false;
}
else {
for voice in voices {
if !temp.join(voice.file_name().unwrap_or(String::from("\0"))).exists() {
predownloaded = false;
break;
}
}
}
if predownloaded {
state = &LauncherState::Launch;
}
}
}
match state {
LauncherState::Launch => {
main.update(ui::main::Actions::PerformButtonEvent).unwrap();
std::thread::sleep(std::time::Duration::from_secs(5));
std::process::exit(0);
},
}
_ => main.show()
}
});

View file

@ -357,7 +357,7 @@ impl App {
this.widgets.window.show();
}
});
},
}
LauncherState::PatchAvailable(patch) => {
match patch {
@ -624,15 +624,15 @@ impl App {
std::thread::spawn(clone!(@strong this => move || {
for mut diff in diffs {
let sender = sender.clone();
#[allow(unused_must_use)]
let result = diff.download_in(config.launcher.temp.as_ref().unwrap(), move |curr, total| {
sender.send(InstallerUpdate::DownloadingProgress(curr, total));
});
if let Err(err) = result {
let err: Error = err.into();
this.update(Actions::Toast(Rc::new((
String::from("Downloading failed"), err.to_string()
)))).unwrap();