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