some little fixes (and nixos fix specific)

This commit is contained in:
ALEZ-DEV 2025-12-19 00:52:35 +01:00
parent 1795b9d580
commit e41eece4a8
5 changed files with 44 additions and 22 deletions

7
Cargo.lock generated
View File

@ -374,6 +374,7 @@ dependencies = [
"serde_json",
"tar",
"tokio",
"whatadistro",
"wincompatlib",
"xz2",
]
@ -3963,6 +3964,12 @@ version = "0.1.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "53a85b86a771b1c87058196170769dd264f66c0782acf1ae6cc51bfd64b39082"
[[package]]
name = "whatadistro"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1c97ebad4f59809511083f2161587445631bff21bb78d9e046b9ca5b2d05d913"
[[package]]
name = "winapi"
version = "0.3.9"

View File

@ -27,6 +27,7 @@ serde = { version = "1.0.197", features = ["derive"] }
serde_json = "1.0.115"
tar = "0.4.40"
tokio = { version = "1.37.0", features = ["fs"] }
whatadistro = "0.1.0"
wincompatlib = { version = "0.7.5", features = [
"dxvk",
"wine-bundles",

View File

@ -111,6 +111,7 @@ impl WineComponent {
debug!("Wine binary path : {:?}", wine_bin_location);
let mut wine = wincompatlib::prelude::Wine::from_binary(wine_bin_location);
wine.prefix = prefix.clone();
wine.init_prefix(Some(prefix)).unwrap();

View File

@ -292,11 +292,21 @@ impl GameManager {
let wine_path = GameConfig::get_config_directory()
.await
.join("wine")
.join("bin")
.join("wine");
let mut wine_path = wine_path.to_str().unwrap();
if let Some(distro) = whatadistro::identify() {
if distro.is_similar("nixos") {
wine_path = "wine";
info!("Nixos detected, using system Wine...");
};
};
//command.push(wine.python.to_str().unwrap());
command.push(wine_path.to_str().unwrap());
command.push("run");
command.push(wine_path);
//command.push("run");
command.push(binary_path.to_str().unwrap());
let launch_option;
@ -324,11 +334,14 @@ impl GameManager {
}
debug!("Command preview -> {}", command.join(" "));
debug!(
"Command envs -> {:?}",
wine.get_envs()["WINEPREFIX"].clone()
);
Ok(Command::new(command[0])
.args(&command[1..command.len()])
.envs(wine.get_envs())
.env("Wine_LOG", "1")
.env("WINE_PREFIX", wine.get_envs()["WINEPREFIX"].clone())
.stdin(Stdio::piped())
.stdout(Stdio::piped())
.stderr(Stdio::piped())

View File

@ -58,29 +58,29 @@ pub async fn patch_game(game_dir: PathBuf) -> anyhow::Result<()> {
// section to replace the executable with the patched one
let executable_path = game_dir
.join(get_game_name())
.join(get_game_name_with_executable());
//let executable_path = game_dir
// .join(get_game_name())
// .join(get_game_name_with_executable());
debug!("{:?}", executable_path);
//debug!("{:?}", executable_path);
if executable_path.exists() {
remove_file(executable_path.clone()).await?;
}
//if executable_path.exists() {
// remove_file(executable_path.clone()).await?;
//}
match PatchedGameExecutable::get_exectable() {
Some(exe) => {
let mut file = File::create(executable_path).await?;
//match PatchedGameExecutable::get_exectable() {
// Some(exe) => {
// let mut file = File::create(executable_path).await?;
let data: Result<Vec<_>, _> = exe.data.bytes().collect();
let data = data.expect("Unable to read executable data");
// let data: Result<Vec<_>, _> = exe.data.bytes().collect();
// let data = data.expect("Unable to read executable data");
file.write_all(&data).await?;
}
None => anyhow::bail!(
"Game executable not included in the binary! Please report this to the developer!"
),
}
// file.write_all(&data).await?;
// }
// None => anyhow::bail!(
// "Game executable not included in the binary! Please report this to the developer!"
// ),
//}
let mut config = GameConfig::get_config().await;
config.is_game_patched = true;