Make custom wine comamnd do something
This commit is contained in:
@@ -28,6 +28,10 @@ tauri-plugin-dialog = "2.3.3"
|
||||
tauri-plugin-notification = "2.3.1"
|
||||
sysinfo = "0.37.0"
|
||||
|
||||
[target.'cfg(target_os = "linux")'.dependencies]
|
||||
shlex = "1.3.0"
|
||||
|
||||
[target.'cfg(not(any(target_os = "android", target_os = "ios")))'.dependencies]
|
||||
tauri-plugin-single-instance = "2.3.3"
|
||||
|
||||
|
||||
|
||||
@@ -177,8 +177,9 @@ async fn download(
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[allow(unused_variables)]
|
||||
#[tauri::command]
|
||||
fn launch_game(app: AppHandle, name: String, executable: String, wine: bool) {
|
||||
fn launch_game(app: AppHandle, name: String, executable: String, wine: bool, wine_command: String) {
|
||||
let game_folder = app
|
||||
.path()
|
||||
.app_local_data_dir()
|
||||
@@ -195,33 +196,25 @@ fn launch_game(app: AppHandle, name: String, executable: String, wine: bool) {
|
||||
return;
|
||||
}
|
||||
let result = if wine && platform() == "linux" {
|
||||
let wine_path_output = Command::new("which").arg("wine").output();
|
||||
let wine_path = match wine_path_output {
|
||||
Ok(output) if output.status.success() => {
|
||||
let path = String::from_utf8_lossy(&output.stdout).trim().to_string();
|
||||
if path.is_empty() {
|
||||
app.dialog()
|
||||
.message("Wine is not installed. Please install Wine to run this version of Berry Dash.")
|
||||
.kind(MessageDialogKind::Error)
|
||||
.title("Wine not found")
|
||||
.show(|_| {});
|
||||
return;
|
||||
}
|
||||
path
|
||||
}
|
||||
_ => {
|
||||
app.dialog()
|
||||
.message("Wine is not installed. Please install Wine to run this version of Berry Dash.")
|
||||
.kind(MessageDialogKind::Error)
|
||||
.title("Wine not found")
|
||||
.show(|_| {});
|
||||
return;
|
||||
}
|
||||
};
|
||||
Command::new(wine_path)
|
||||
.arg(&game_path)
|
||||
#[cfg(target_os = "linux")]
|
||||
{
|
||||
let wine_cmd_to_use =
|
||||
wine_command.replace("%path%", &format!("\"{}\"", game_path.to_string_lossy()));
|
||||
|
||||
let parts = shlex::split(&wine_cmd_to_use).expect("failed to split command");
|
||||
let exe = &parts[0];
|
||||
let args = &parts[1..];
|
||||
|
||||
Command::new(exe)
|
||||
.args(args)
|
||||
.current_dir(&game_folder)
|
||||
.spawn()
|
||||
}
|
||||
|
||||
#[cfg(not(target_os = "linux"))]
|
||||
{
|
||||
Err(std::io::Error::new(std::io::ErrorKind::Other, "not linux"))
|
||||
}
|
||||
} else {
|
||||
if is_running_by_path(&game_path) {
|
||||
app.dialog()
|
||||
|
||||
@@ -100,27 +100,29 @@ export default function Installs () {
|
||||
onClick={async () => {
|
||||
let plat = platform()
|
||||
let willUseWine = false
|
||||
let cfg = null
|
||||
while (normalConfig != null) {
|
||||
cfg = normalConfig
|
||||
break
|
||||
}
|
||||
if (plat === 'macos' || plat === 'linux') {
|
||||
if (
|
||||
!entry.version.platforms.includes(plat) &&
|
||||
entry.version.platforms.includes('windows')
|
||||
) {
|
||||
while (normalConfig != null) {
|
||||
if (
|
||||
!normalConfig.settings.useWineOnUnixWhenNeeded
|
||||
cfg != null &&
|
||||
!cfg.settings.useWineOnUnixWhenNeeded
|
||||
) {
|
||||
await message(
|
||||
'Wine support is disabled in settings and this version requires wine',
|
||||
{
|
||||
title:
|
||||
'Wine is needed to load this version',
|
||||
title: 'Wine is needed to load this version',
|
||||
kind: 'error'
|
||||
}
|
||||
)
|
||||
return
|
||||
}
|
||||
break
|
||||
}
|
||||
plat = 'windows'
|
||||
willUseWine = true
|
||||
}
|
||||
@@ -131,7 +133,8 @@ export default function Installs () {
|
||||
entry.version.executables[
|
||||
entry.version.platforms.indexOf(plat)
|
||||
],
|
||||
wine: willUseWine
|
||||
wine: willUseWine,
|
||||
wineCommand: cfg?.settings.wineOnUnixCommand
|
||||
})
|
||||
}}
|
||||
>
|
||||
|
||||
Reference in New Issue
Block a user