- added `Config::get_wine_prefix_path` method
This commit is contained in:
Observer KRypt0n_ 2023-04-18 15:24:40 +02:00
parent a8323a47b7
commit b86ec8eb55
No known key found for this signature in database
GPG key ID: 844DA47BA25FE1E2
3 changed files with 57 additions and 2 deletions

View file

@ -1,6 +1,6 @@
[package] [package]
name = "anime-launcher-sdk" name = "anime-launcher-sdk"
version = "1.0.7" version = "1.0.8"
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"
readme = "README.md" readme = "README.md"

View file

@ -98,4 +98,28 @@ impl Schema {
None => Ok(None) 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()
}
} }

View file

@ -1,11 +1,18 @@
use std::path::PathBuf;
use serde::{Serialize, Deserialize}; use serde::{Serialize, Deserialize};
use serde_json::Value as JsonValue; use serde_json::Value as JsonValue;
use wincompatlib::wine::WineWithExt;
#[cfg(feature = "sandbox")] #[cfg(feature = "sandbox")]
use crate::config::schema_blanks::sandbox::Sandbox; use crate::config::schema_blanks::sandbox::Sandbox;
#[cfg(feature = "components")] #[cfg(feature = "components")]
use crate::components::wine::Version as WineVersion; use crate::components::wine::{
WincompatlibWine,
Version as WineVersion
};
#[cfg(feature = "components")] #[cfg(feature = "components")]
use crate::components::dxvk::Version as DxvkVersion; use crate::components::dxvk::Version as DxvkVersion;
@ -98,4 +105,28 @@ impl Schema {
None => Ok(None) 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()
}
} }