- updated core library;
  added `lib::consts::TELEMETRY_CHECK_TIMEOUT` and `PATCH_FETCHING_TIMEOUT`
  to specify new core-required timeouts
- fixed error message toasting when failed to run the game
- added telemetry servers acessibility checking before running the game

From previous commits:
- fixed setting game command default value in environment settings
- use `patch.root = false` by default in flatpak
This commit is contained in:
Observer KRypt0n_ 2022-08-03 13:44:48 +02:00
parent cb1936bb6f
commit a5caf1a217
No known key found for this signature in database
GPG key ID: 844DA47BA25FE1E2
8 changed files with 31 additions and 10 deletions

4
Cargo.lock generated
View file

@ -31,7 +31,7 @@ dependencies = [
[[package]] [[package]]
name = "anime-game-core" name = "anime-game-core"
version = "0.2.2" version = "0.3.0"
dependencies = [ dependencies = [
"bzip2", "bzip2",
"curl", "curl",
@ -51,7 +51,7 @@ dependencies = [
[[package]] [[package]]
name = "anime-game-launcher" name = "anime-game-launcher"
version = "0.6.2" version = "0.6.3"
dependencies = [ dependencies = [
"anime-game-core", "anime-game-core",
"dirs", "dirs",

View file

@ -1,6 +1,6 @@
[package] [package]
name = "anime-game-launcher" name = "anime-game-launcher"
version = "0.6.2" version = "0.6.3"
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"

@ -1 +1 @@
Subproject commit 9820453d6fdc5ccdc832fd0a8bbe80e210df2b2e Subproject commit 8c7a8f9bcbe008f164e810aeddbe33366fa541ec

View file

@ -1,6 +1,14 @@
use std::time::Duration;
static mut LAUNCHER_DIR: Option<Option<String>> = None; static mut LAUNCHER_DIR: Option<Option<String>> = None;
static mut CONFIG_FILE: Option<Option<String>> = None; static mut CONFIG_FILE: Option<Option<String>> = None;
/// Timeout used by `anime_game_core::telemetry::is_disabled` to check acessibility of telemetry servers
pub const TELEMETRY_CHECK_TIMEOUT: Option<Duration> = Some(Duration::from_secs(3));
/// Timeout used by `anime_game_core::linux_patch::Patch::try_fetch` to fetch patch info
pub const PATCH_FETCHING_TIMEOUT: Option<Duration> = Some(Duration::from_secs(5));
pub fn launcher_dir() -> Option<String> { pub fn launcher_dir() -> Option<String> {
unsafe { unsafe {
match &LAUNCHER_DIR { match &LAUNCHER_DIR {

View file

@ -2,6 +2,9 @@ use std::io::{Error, ErrorKind};
use std::path::Path; use std::path::Path;
use std::process::Command; use std::process::Command;
use anime_game_core::telemetry;
use super::consts;
use super::config; use super::config;
#[derive(Debug, Clone, Copy, PartialEq, Eq)] #[derive(Debug, Clone, Copy, PartialEq, Eq)]
@ -73,6 +76,12 @@ pub fn run(debug: bool) -> std::io::Result<()> {
None => return Err(Error::new(ErrorKind::Other, "Couldn't find wine executable")) None => return Err(Error::new(ErrorKind::Other, "Couldn't find wine executable"))
}; };
// Check telemetry servers
if let Some(server) = telemetry::is_disabled(consts::TELEMETRY_CHECK_TIMEOUT) {
return Err(Error::new(ErrorKind::Other, format!("Telemetry server is not disabled: {server}")));
}
// Prepare bash -c '<command>' // Prepare bash -c '<command>'
let mut bash_chain = String::new(); let mut bash_chain = String::new();

View file

@ -2,6 +2,7 @@ use std::io::{Error, ErrorKind};
use anime_game_core::prelude::*; use anime_game_core::prelude::*;
use crate::lib::consts;
use crate::lib::config; use crate::lib::config;
use crate::lib::wine_prefix::WinePrefix; use crate::lib::wine_prefix::WinePrefix;
@ -93,7 +94,7 @@ impl LauncherState {
status("Updating patch info..."); status("Updating patch info...");
let patch = Patch::try_fetch(config.patch.servers.clone())?; let patch = Patch::try_fetch(config.patch.servers.clone(), consts::PATCH_FETCHING_TIMEOUT)?;
if patch.is_applied(&config.game.path)? { if patch.is_applied(&config.game.path)? {
Self::Launch Self::Launch

View file

@ -18,6 +18,7 @@ use super::preferences::PreferencesStack;
use super::traits::toast::Toast; use super::traits::toast::Toast;
use super::components::progress_bar::*; use super::components::progress_bar::*;
use crate::lib::consts;
use crate::lib::config; use crate::lib::config;
use crate::lib::game; use crate::lib::game;
use crate::lib::launcher::states::LauncherState; use crate::lib::launcher::states::LauncherState;
@ -275,7 +276,9 @@ impl App {
if let Err(err) = game::run(false) { if let Err(err) = game::run(false) {
this.widgets.window.show(); this.widgets.window.show();
this.toast("Failed to run game", err); this.update(Actions::Toast(Rc::new((
String::from("Failed to run game"), err
)))).unwrap();
} }
else { else {
@ -635,7 +638,7 @@ impl App {
let total = broken.len() as f64; let total = broken.len() as f64;
let is_patch_applied = match Patch::try_fetch(config.patch.servers) { let is_patch_applied = match Patch::try_fetch(config.patch.servers, consts::PATCH_FETCHING_TIMEOUT) {
Ok(patch) => patch.is_applied(&config.game.path).unwrap_or(true), Ok(patch) => patch.is_applied(&config.game.path).unwrap_or(true),
Err(_) => true Err(_) => true
}; };

View file

@ -649,7 +649,7 @@ impl App {
self.widgets.game_version.set_label(&current.to_string()); self.widgets.game_version.set_label(&current.to_string());
self.widgets.game_version.set_css_classes(&["error"]); self.widgets.game_version.set_css_classes(&["error"]);
self.widgets.game_version.set_tooltip_text(Some(&format!("Game is too outdated and can't be updated. Latest version: {}", latest))); self.widgets.game_version.set_tooltip_text(Some(&format!("Game is too outdated and can't be updated. Latest version: {latest}")));
}, },
VersionDiff::NotInstalled { .. } => { VersionDiff::NotInstalled { .. } => {
self.widgets.game_version.set_label("not installed"); self.widgets.game_version.set_label("not installed");
@ -660,7 +660,7 @@ impl App {
// Update patch version // Update patch version
status_page.set_description(Some("Updating patch info...")); status_page.set_description(Some("Updating patch info..."));
let patch = Patch::try_fetch(config.patch.servers)?; let patch = Patch::try_fetch(config.patch.servers, consts::PATCH_FETCHING_TIMEOUT)?;
match patch { match patch {
Patch::NotAvailable => { Patch::NotAvailable => {
@ -673,7 +673,7 @@ impl App {
self.widgets.patch_version.set_label("outdated"); self.widgets.patch_version.set_label("outdated");
self.widgets.patch_version.set_css_classes(&["warning"]); self.widgets.patch_version.set_css_classes(&["warning"]);
self.widgets.patch_version.set_tooltip_text(Some(&format!("Patch is outdated ({} -> {})", current, latest))); self.widgets.patch_version.set_tooltip_text(Some(&format!("Patch is outdated ({current} -> {latest})")));
}, },
Patch::Preparation { .. } => { Patch::Preparation { .. } => {
self.widgets.patch_version.set_label("preparation"); self.widgets.patch_version.set_label("preparation");