mirror of
https://github.com/open-goal/launcher.git
synced 2024-10-20 04:57:38 -04:00
help: allow launching the game with a one-off gk
executable
This commit is contained in:
parent
105ea35f28
commit
dcb7dc6119
|
@ -4,6 +4,7 @@ use std::{
|
||||||
collections::HashMap,
|
collections::HashMap,
|
||||||
path::{Path, PathBuf},
|
path::{Path, PathBuf},
|
||||||
process::Command,
|
process::Command,
|
||||||
|
str::FromStr,
|
||||||
time::Instant,
|
time::Instant,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -762,18 +763,31 @@ pub async fn launch_game(
|
||||||
app_handle: tauri::AppHandle,
|
app_handle: tauri::AppHandle,
|
||||||
game_name: String,
|
game_name: String,
|
||||||
in_debug: bool,
|
in_debug: bool,
|
||||||
|
executable_location: Option<String>,
|
||||||
) -> Result<(), CommandError> {
|
) -> Result<(), CommandError> {
|
||||||
let config_lock = config.lock().await;
|
let config_lock = config.lock().await;
|
||||||
let config_info = common_prelude(&config_lock)?;
|
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)?;
|
let args = generate_launch_game_string(&config_info, game_name.clone(), in_debug, false)?;
|
||||||
|
|
||||||
log::info!(
|
log::info!(
|
||||||
"Launching game version {:?} -> {:?} with args: {:?}",
|
"Launching game version {:?} -> {:?} with args: {:?}. Working Directory: {:?}, Path: {:?}",
|
||||||
&config_info.active_version,
|
&config_info.active_version,
|
||||||
&config_info.tooling_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)?;
|
let log_file = create_log_file(&app_handle, "game.log", false)?;
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
} from "flowbite-svelte";
|
} from "flowbite-svelte";
|
||||||
import { resetGameSettings, uninstallGame } from "$lib/rpc/game";
|
import { resetGameSettings, uninstallGame } from "$lib/rpc/game";
|
||||||
import { platform } from "@tauri-apps/api/os";
|
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 {
|
import {
|
||||||
doesActiveToolingVersionMeetMinimum,
|
doesActiveToolingVersionMeetMinimum,
|
||||||
getInstallationDirectory,
|
getInstallationDirectory,
|
||||||
|
@ -167,6 +167,11 @@
|
||||||
launchGame(getInternalName(activeGame), true);
|
launchGame(getInternalName(activeGame), true);
|
||||||
}}>{$_("gameControls_button_playInDebug")}</DropdownItem
|
}}>{$_("gameControls_button_playInDebug")}</DropdownItem
|
||||||
>
|
>
|
||||||
|
<DropdownItem
|
||||||
|
on:click={async () => {
|
||||||
|
launchGameWithCustomExecutable(getInternalName(activeGame));
|
||||||
|
}}>Launch with Custom Executable</DropdownItem
|
||||||
|
>
|
||||||
{#if !isLinux}
|
{#if !isLinux}
|
||||||
<DropdownItem
|
<DropdownItem
|
||||||
on:click={async () => {
|
on:click={async () => {
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
import { filePrompt } from "$lib/utils/file-dialogs";
|
||||||
import { invoke_rpc } from "./rpc";
|
import { invoke_rpc } from "./rpc";
|
||||||
|
|
||||||
interface InstallationOutput {
|
interface InstallationOutput {
|
||||||
|
@ -70,12 +71,27 @@ export async function launchGame(
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
return await invoke_rpc(
|
return await invoke_rpc(
|
||||||
"launch_game",
|
"launch_game",
|
||||||
{ gameName, inDebug },
|
{ gameName, inDebug, executableLocation: null },
|
||||||
() => {},
|
() => {},
|
||||||
"_mirror_",
|
"_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> {
|
export async function openREPL(gameName: string): Promise<void> {
|
||||||
return await invoke_rpc(
|
return await invoke_rpc(
|
||||||
"open_repl",
|
"open_repl",
|
||||||
|
|
Loading…
Reference in a new issue