diff --git a/Cargo.toml b/Cargo.toml index 9212dc4..6e608b8 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "anime-launcher-sdk" -version = "1.0.7" +version = "1.0.8" authors = ["Nikita Podvirnyy "] license = "GPL-3.0" readme = "README.md" diff --git a/src/genshin/config/schema/mod.rs b/src/genshin/config/schema/mod.rs index 95651f6..08e4e62 100644 --- a/src/genshin/config/schema/mod.rs +++ b/src/genshin/config/schema/mod.rs @@ -98,4 +98,28 @@ impl Schema { None => Ok(None) } } + + #[cfg(feature = "components")] + /// Resolve real wine prefix path using wincompatlib + /// + /// - For general wine build returns `game.wine.prefix` + /// - For proton-like builds return `game.wine.prefix`/`pfx` + pub fn get_wine_prefix_path(&self) -> PathBuf { + if let Ok(Some(wine)) = self.get_selected_wine() { + let wine = wine + .to_wine(&self.components.path, Some(&self.game.wine.builds.join(&wine.name))) + .with_prefix(&self.game.wine.prefix); + + let prefix = match wine { + WincompatlibWine::Default(wine) => wine.prefix, + WincompatlibWine::Proton(proton) => proton.proton_prefix + }; + + if let Some(prefix) = prefix { + return prefix; + } + } + + self.game.wine.prefix.clone() + } } diff --git a/src/honkai/config/schema/mod.rs b/src/honkai/config/schema/mod.rs index 95651f6..b101c87 100644 --- a/src/honkai/config/schema/mod.rs +++ b/src/honkai/config/schema/mod.rs @@ -1,11 +1,18 @@ +use std::path::PathBuf; + use serde::{Serialize, Deserialize}; use serde_json::Value as JsonValue; +use wincompatlib::wine::WineWithExt; + #[cfg(feature = "sandbox")] use crate::config::schema_blanks::sandbox::Sandbox; #[cfg(feature = "components")] -use crate::components::wine::Version as WineVersion; +use crate::components::wine::{ + WincompatlibWine, + Version as WineVersion +}; #[cfg(feature = "components")] use crate::components::dxvk::Version as DxvkVersion; @@ -98,4 +105,28 @@ impl Schema { None => Ok(None) } } + + #[cfg(feature = "components")] + /// Resolve real wine prefix path using wincompatlib + /// + /// - For general wine build returns `game.wine.prefix` + /// - For proton-like builds return `game.wine.prefix`/`pfx` + pub fn get_wine_prefix_path(&self) -> PathBuf { + if let Ok(Some(wine)) = self.get_selected_wine() { + let wine = wine + .to_wine(&self.components.path, Some(&self.game.wine.builds.join(&wine.name))) + .with_prefix(&self.game.wine.prefix); + + let prefix = match wine { + WincompatlibWine::Default(wine) => wine.prefix, + WincompatlibWine::Proton(proton) => proton.proton_prefix + }; + + if let Some(prefix) = prefix { + return prefix; + } + } + + self.game.wine.prefix.clone() + } }