From c5ca8d533c25ecd469caf46e2f8aeeb054a4bb2d Mon Sep 17 00:00:00 2001 From: Observer KRypt0n_ Date: Wed, 15 Mar 2023 23:04:58 +0200 Subject: [PATCH] 0.5.2 - updated `wincompatlib` version - made `LauncherState::get_from_config` use proper prefix path --- Cargo.toml | 4 ++-- src/components/wine.rs | 12 +++++++----- src/states.rs | 25 +++++++++++++++++++++++-- 3 files changed, 32 insertions(+), 9 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 5b75cb8..f85eb0c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "anime-launcher-sdk" -version = "0.5.1" +version = "0.5.2" authors = ["Nikita Podvirnyy "] license = "GPL-3.0" readme = "README.md" @@ -18,7 +18,7 @@ serde = { version = "1.0", features = ["derive"], optional = true } serde_json = { version = "1.0", optional = true } enum-ordinalize = { version = "3.1", optional = true } -wincompatlib = { version = "0.3", features = ["all"], optional = true } +wincompatlib = { version = "0.4", features = ["all"], optional = true } lazy_static = { version = "1.4", optional = true } md-5 = { version = "0.10", features = ["asm"], optional = true } discord-rich-presence = { version = "0.2.3", optional = true } diff --git a/src/components/wine.rs b/src/components/wine.rs index 756ff29..2cf80a8 100644 --- a/src/components/wine.rs +++ b/src/components/wine.rs @@ -1,5 +1,7 @@ use std::path::PathBuf; use std::collections::HashMap; +use std::process::Output; +use std::io::Result; use serde::{Serialize, Deserialize}; use serde_json::Value as JsonValue; @@ -327,35 +329,35 @@ impl WineBootExt for WincompatlibWine { } } - fn update_prefix>(&self, path: T) -> std::io::Result { + fn update_prefix>(&self, path: Option) -> Result { match self { Self::Default(wine) => wine.update_prefix(path), Self::Proton(proton) => proton.update_prefix(path) } } - fn stop_processes(&self, force: bool) -> std::io::Result { + fn stop_processes(&self, force: bool) -> Result { match self { Self::Default(wine) => wine.stop_processes(force), Self::Proton(proton) => proton.stop_processes(force) } } - fn restart(&self) -> std::io::Result { + fn restart(&self) -> Result { match self { Self::Default(wine) => wine.restart(), Self::Proton(proton) => proton.restart() } } - fn shutdown(&self) -> std::io::Result { + fn shutdown(&self) -> Result { match self { Self::Default(wine) => wine.shutdown(), Self::Proton(proton) => proton.shutdown() } } - fn end_session(&self) -> std::io::Result { + fn end_session(&self) -> Result { match self { Self::Default(wine) => wine.end_session(), Self::Proton(proton) => proton.end_session() diff --git a/src/states.rs b/src/states.rs index ccaddb3..4cde909 100644 --- a/src/states.rs +++ b/src/states.rs @@ -3,9 +3,12 @@ use std::path::PathBuf; use anime_game_core::prelude::*; use anime_game_core::genshin::prelude::*; +use wincompatlib::prelude::*; + use serde::{Serialize, Deserialize}; use crate::consts; +use super::components::wine::WincompatlibWine; #[derive(Debug, Clone, Serialize, Deserialize)] pub enum LauncherState { @@ -145,10 +148,28 @@ impl LauncherState { let config = crate::config::get()?; + let mut wine_prefix = config.game.wine.prefix.clone(); + // Check wine existence #[cfg(feature = "components")] { - if config.get_selected_wine()?.is_none() { + if let Some(wine) = config.get_selected_wine()? { + let wine = wine + .to_wine(&config.components.path, Some(&config.game.wine.builds.join(&wine.name))) + .with_prefix(&config.game.wine.prefix); + + match wine { + WincompatlibWine::Default(wine) => if let Some(prefix) = wine.prefix { + wine_prefix = prefix; + } + + WincompatlibWine::Proton(proton) => if let Some(prefix) = proton.wine().prefix.clone() { + wine_prefix = prefix; + } + } + } + + else { return Ok(Self::WineNotInstalled); } } @@ -162,6 +183,6 @@ impl LauncherState { }); } - Self::get(config.game.wine.prefix, config.game.path, voices, config.patch.servers, status) + Self::get(wine_prefix, config.game.path, voices, config.patch.servers, status) } }