mirror of
https://github.com/an-anime-team/sleepy-launcher.git
synced 2025-03-15 06:28:27 +03:00
feat(core): updated core library & sdk, changed game running mechanism
New core library version contain updated voice packages sizes for more precise versioning New SDK version's `game::run()` function freezes thread so now game launching should work better
This commit is contained in:
parent
f11b527e8d
commit
24c8f7fb7c
3 changed files with 24 additions and 23 deletions
4
Cargo.lock
generated
4
Cargo.lock
generated
|
@ -31,7 +31,7 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "anime-game-core"
|
||||
version = "1.3.5"
|
||||
version = "1.3.6"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"bzip2",
|
||||
|
@ -74,7 +74,7 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "anime-launcher-sdk"
|
||||
version = "0.2.2"
|
||||
version = "0.2.4"
|
||||
dependencies = [
|
||||
"anime-game-core",
|
||||
"anyhow",
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit 6fa47d033864dbb5cf8628346ccf2894b35fca9a
|
||||
Subproject commit 2af464536c09432290a7737522420e10479645df
|
|
@ -81,6 +81,9 @@ pub enum AppMsg {
|
|||
PredownloadUpdate,
|
||||
PerformAction,
|
||||
|
||||
HideWindow,
|
||||
ShowWindow,
|
||||
|
||||
Toast {
|
||||
title: String,
|
||||
description: Option<String>
|
||||
|
@ -799,30 +802,20 @@ impl SimpleComponent for App {
|
|||
LauncherState::PatchAvailable(Patch::NotAvailable) |
|
||||
LauncherState::PredownloadAvailable { .. } |
|
||||
LauncherState::Launch => {
|
||||
// TODO: make game::run() freeze current process while the game is running
|
||||
if let Err(err) = anime_launcher_sdk::game::run() {
|
||||
tracing::error!("Failed to launch game: {err}");
|
||||
sender.input(AppMsg::HideWindow);
|
||||
|
||||
self.toast(tr("game-launching-failed"), Some(err.to_string()));
|
||||
}
|
||||
std::thread::spawn(move || {
|
||||
if let Err(err) = anime_launcher_sdk::game::run() {
|
||||
tracing::error!("Failed to launch game: {err}");
|
||||
|
||||
else {
|
||||
MAIN_WINDOW.as_ref().unwrap_unchecked().hide();
|
||||
|
||||
std::thread::sleep(std::time::Duration::from_secs(2));
|
||||
|
||||
while let Ok(output) = std::process::Command::new("ps").arg("-A").stdout(std::process::Stdio::piped()).output() {
|
||||
let output = String::from_utf8_lossy(&output.stdout);
|
||||
|
||||
if !output.contains("GenshinImpact.e") && !output.contains("unlocker.exe") {
|
||||
break;
|
||||
}
|
||||
|
||||
std::thread::sleep(std::time::Duration::from_secs(3));
|
||||
sender.input(AppMsg::Toast {
|
||||
title: tr("game-launching-failed"),
|
||||
description: Some(err.to_string())
|
||||
});
|
||||
}
|
||||
|
||||
MAIN_WINDOW.as_ref().unwrap_unchecked().show();
|
||||
}
|
||||
sender.input(AppMsg::ShowWindow);
|
||||
});
|
||||
}
|
||||
|
||||
LauncherState::PatchAvailable(patch) => {
|
||||
|
@ -1091,6 +1084,14 @@ impl SimpleComponent for App {
|
|||
}
|
||||
}
|
||||
|
||||
AppMsg::HideWindow => unsafe {
|
||||
MAIN_WINDOW.as_ref().unwrap_unchecked().hide();
|
||||
}
|
||||
|
||||
AppMsg::ShowWindow => unsafe {
|
||||
MAIN_WINDOW.as_ref().unwrap_unchecked().show();
|
||||
}
|
||||
|
||||
AppMsg::Toast { title, description } => self.toast(title, description)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue