help: allow launching the game with a one-off gk executable

This commit is contained in:
Tyler Wilding 2024-09-19 01:01:30 -04:00
parent 105ea35f28
commit dcb7dc6119
No known key found for this signature in database
GPG key ID: BF7B068C2FEFD7EF
3 changed files with 40 additions and 5 deletions

View file

@ -4,6 +4,7 @@ use std::{
collections::HashMap,
path::{Path, PathBuf},
process::Command,
str::FromStr,
time::Instant,
};
@ -762,18 +763,31 @@ pub async fn launch_game(
app_handle: tauri::AppHandle,
game_name: String,
in_debug: bool,
executable_location: Option<String>,
) -> Result<(), CommandError> {
let config_lock = config.lock().await;
let config_info = common_prelude(&config_lock)?;
let exec_info = get_exec_location(&config_info, "gk")?;
let mut exec_info = get_exec_location(&config_info, "gk")?;
if executable_location.is_some() {
let exec_path = PathBuf::from_str(executable_location.unwrap().as_str());
if exec_path.is_ok() {
exec_info = ExecutableLocation {
executable_dir: exec_path.clone().unwrap().parent().unwrap().to_path_buf(),
executable_path: exec_path.clone().unwrap(),
};
}
}
let args = generate_launch_game_string(&config_info, game_name.clone(), in_debug, false)?;
log::info!(
"Launching game version {:?} -> {:?} with args: {:?}",
"Launching game version {:?} -> {:?} with args: {:?}. Working Directory: {:?}, Path: {:?}",
&config_info.active_version,
&config_info.tooling_version,
args
args,
exec_info.executable_dir,
exec_info.executable_path,
);
let log_file = create_log_file(&app_handle, "game.log", false)?;

View file

@ -17,7 +17,7 @@
} from "flowbite-svelte";
import { resetGameSettings, uninstallGame } from "$lib/rpc/game";
import { platform } from "@tauri-apps/api/os";
import { getLaunchGameString, launchGame, openREPL } from "$lib/rpc/binaries";
import { getLaunchGameString, launchGame, launchGameWithCustomExecutable, openREPL } from "$lib/rpc/binaries";
import {
doesActiveToolingVersionMeetMinimum,
getInstallationDirectory,
@ -167,6 +167,11 @@
launchGame(getInternalName(activeGame), true);
}}>{$_("gameControls_button_playInDebug")}</DropdownItem
>
<DropdownItem
on:click={async () => {
launchGameWithCustomExecutable(getInternalName(activeGame));
}}>Launch with Custom Executable</DropdownItem
>
{#if !isLinux}
<DropdownItem
on:click={async () => {

View file

@ -1,3 +1,4 @@
import { filePrompt } from "$lib/utils/file-dialogs";
import { invoke_rpc } from "./rpc";
interface InstallationOutput {
@ -70,12 +71,27 @@ export async function launchGame(
): Promise<void> {
return await invoke_rpc(
"launch_game",
{ gameName, inDebug },
{ gameName, inDebug, executableLocation: null },
() => {},
"_mirror_",
);
}
export async function launchGameWithCustomExecutable(
gameName: string,
): Promise<void> {
// Get custom executable location
const customExecutable = await filePrompt(["exe"], "executables", "pick exe");
if (customExecutable !== null) {
return await invoke_rpc(
"launch_game",
{ gameName, inDebug: false, executableLocation: customExecutable},
() => {},
"_mirror_",
);
}
}
export async function openREPL(gameName: string): Promise<void> {
return await invoke_rpc(
"open_repl",