mirror of
https://github.com/open-goal/launcher.git
synced 2024-10-20 04:57:38 -04:00
game: Add a new settings option to dump the command to run gk
(#319)
This commit is contained in:
parent
5cfba6a5d4
commit
3e351136bc
|
@ -29,6 +29,7 @@ struct CommonConfigData {
|
|||
install_path: std::path::PathBuf,
|
||||
active_version: String,
|
||||
active_version_folder: String,
|
||||
tooling_version: Version,
|
||||
}
|
||||
|
||||
fn common_prelude(
|
||||
|
@ -58,10 +59,14 @@ fn common_prelude(
|
|||
"No active version folder set, can't perform operation".to_owned(),
|
||||
))?;
|
||||
|
||||
let tooling_version = Version::parse(active_version.strip_prefix('v').unwrap_or(&active_version))
|
||||
.unwrap_or(Version::new(0, 1, 35)); // assume new format if none can be found
|
||||
|
||||
Ok(CommonConfigData {
|
||||
install_path: install_path.to_path_buf(),
|
||||
active_version: active_version.clone(),
|
||||
active_version_folder: active_version_folder.clone(),
|
||||
tooling_version: tooling_version,
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -626,30 +631,19 @@ pub async fn run_game_gpu_test(
|
|||
}
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn launch_game(
|
||||
config: tauri::State<'_, tokio::sync::Mutex<LauncherConfig>>,
|
||||
app_handle: tauri::AppHandle,
|
||||
fn generate_launch_game_string(
|
||||
config_info: &CommonConfigData,
|
||||
game_name: String,
|
||||
in_debug: bool,
|
||||
) -> Result<(), CommandError> {
|
||||
let config_lock = config.lock().await;
|
||||
let config_info = common_prelude(&config_lock)?;
|
||||
|
||||
let tooling_version = Version::parse(
|
||||
config_info
|
||||
.active_version
|
||||
.strip_prefix('v')
|
||||
.unwrap_or(&config_info.active_version),
|
||||
)
|
||||
.unwrap_or(Version::new(0, 1, 35)); // assume new format if none can be found
|
||||
|
||||
) -> Result<Vec<String>, CommandError> {
|
||||
let data_folder = get_data_dir(&config_info, &game_name, false)?;
|
||||
let exec_info = get_exec_location(&config_info, "gk")?;
|
||||
|
||||
let mut args;
|
||||
// NOTE - order unfortunately matters for gk args
|
||||
if tooling_version.major == 0 && tooling_version.minor <= 1 && tooling_version.patch < 35 {
|
||||
if config_info.tooling_version.major == 0
|
||||
&& config_info.tooling_version.minor <= 1
|
||||
&& config_info.tooling_version.patch < 35
|
||||
{
|
||||
// old argument format
|
||||
args = vec![
|
||||
"-boot".to_string(),
|
||||
|
@ -675,11 +669,44 @@ pub async fn launch_game(
|
|||
args.push("-debug".to_string());
|
||||
}
|
||||
}
|
||||
Ok(args)
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn get_launch_game_string(
|
||||
config: tauri::State<'_, tokio::sync::Mutex<LauncherConfig>>,
|
||||
game_name: String,
|
||||
) -> Result<String, CommandError> {
|
||||
let config_lock = config.lock().await;
|
||||
let config_info = common_prelude(&config_lock)?;
|
||||
|
||||
let exec_info = get_exec_location(&config_info, "gk")?;
|
||||
let args = generate_launch_game_string(&config_info, game_name, false)?;
|
||||
|
||||
Ok(format!(
|
||||
"{} {}",
|
||||
exec_info.executable_path.display(),
|
||||
args.join(" ")
|
||||
))
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn launch_game(
|
||||
config: tauri::State<'_, tokio::sync::Mutex<LauncherConfig>>,
|
||||
app_handle: tauri::AppHandle,
|
||||
game_name: String,
|
||||
in_debug: bool,
|
||||
) -> 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 args = generate_launch_game_string(&config_info, game_name, in_debug)?;
|
||||
|
||||
log::info!(
|
||||
"Launching game version {:?} -> {:?} with args: {:?}",
|
||||
&config_info.active_version,
|
||||
tooling_version,
|
||||
&config_info.tooling_version,
|
||||
args
|
||||
);
|
||||
|
||||
|
|
|
@ -132,17 +132,19 @@ fn main() {
|
|||
.invoke_handler(tauri::generate_handler![
|
||||
commands::binaries::extract_and_validate_iso,
|
||||
commands::binaries::get_end_of_logs,
|
||||
commands::binaries::get_launch_game_string,
|
||||
commands::binaries::launch_game,
|
||||
commands::binaries::open_repl,
|
||||
commands::binaries::run_compiler,
|
||||
commands::binaries::run_decompiler,
|
||||
commands::binaries::update_data_directory,
|
||||
commands::config::set_enabled_texture_packs,
|
||||
commands::config::cleanup_enabled_texture_packs,
|
||||
commands::config::delete_old_data_directory,
|
||||
commands::config::finalize_installation,
|
||||
commands::config::get_active_tooling_version_folder,
|
||||
commands::config::get_active_tooling_version,
|
||||
commands::config::get_bypass_requirements,
|
||||
commands::config::get_enabled_texture_packs,
|
||||
commands::config::get_install_directory,
|
||||
commands::config::get_installed_version_folder,
|
||||
commands::config::get_installed_version,
|
||||
|
@ -154,18 +156,17 @@ fn main() {
|
|||
commands::config::reset_to_defaults,
|
||||
commands::config::save_active_version_change,
|
||||
commands::config::set_bypass_requirements,
|
||||
commands::config::set_enabled_texture_packs,
|
||||
commands::config::set_install_directory,
|
||||
commands::config::set_locale,
|
||||
commands::config::get_enabled_texture_packs,
|
||||
commands::config::cleanup_enabled_texture_packs,
|
||||
commands::download::download_file,
|
||||
commands::game::reset_game_settings,
|
||||
commands::game::uninstall_game,
|
||||
commands::game::get_furthest_game_milestone,
|
||||
commands::features::update_texture_pack_data,
|
||||
commands::features::delete_texture_packs,
|
||||
commands::features::extract_new_texture_pack,
|
||||
commands::features::list_extracted_texture_pack_info,
|
||||
commands::features::delete_texture_packs,
|
||||
commands::features::update_texture_pack_data,
|
||||
commands::game::get_furthest_game_milestone,
|
||||
commands::game::reset_game_settings,
|
||||
commands::game::uninstall_game,
|
||||
commands::logging::frontend_log,
|
||||
commands::support::generate_support_package,
|
||||
commands::versions::download_version,
|
||||
|
|
|
@ -39,6 +39,9 @@
|
|||
},
|
||||
"allowlist": {
|
||||
"all": true,
|
||||
"clipboard": {
|
||||
"writeText": true
|
||||
},
|
||||
"fs": {
|
||||
"scope": [
|
||||
"$APP/",
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
import IconCog from "~icons/mdi/cog";
|
||||
import { configDir, join } from "@tauri-apps/api/path";
|
||||
import { createEventDispatcher, onMount } from "svelte";
|
||||
import { writeText } from "@tauri-apps/api/clipboard";
|
||||
import { confirm } from "@tauri-apps/api/dialog";
|
||||
import {
|
||||
Button,
|
||||
|
@ -14,9 +15,10 @@
|
|||
} from "flowbite-svelte";
|
||||
import { resetGameSettings, uninstallGame } from "$lib/rpc/game";
|
||||
import { platform } from "@tauri-apps/api/os";
|
||||
import { launchGame, openREPL } from "$lib/rpc/binaries";
|
||||
import { getLaunchGameString, launchGame, openREPL } from "$lib/rpc/binaries";
|
||||
import { _ } from "svelte-i18n";
|
||||
import { navigate } from "svelte-navigator";
|
||||
import { toastStore } from "$lib/stores/ToastStore";
|
||||
|
||||
export let activeGame: SupportedGame;
|
||||
|
||||
|
@ -131,6 +133,21 @@
|
|||
}}>{$_("gameControls_button_openSavesFolder")}</DropdownItem
|
||||
>
|
||||
<DropdownDivider />
|
||||
<DropdownItem
|
||||
on:click={async () => {
|
||||
const launchString = await getLaunchGameString(
|
||||
getInternalName(activeGame),
|
||||
);
|
||||
await writeText(launchString);
|
||||
toastStore.makeToast("Copied to clipboard!", "info");
|
||||
}}
|
||||
>Copy Game Executable Command<Helper
|
||||
helperClass="!text-neutral-400 !text-xs"
|
||||
>For running the game outside the launcher.<br />The command is
|
||||
tooling-version specific.</Helper
|
||||
></DropdownItem
|
||||
>
|
||||
<DropdownDivider />
|
||||
<!-- TODO - verify installation -->
|
||||
<!-- <DropdownItem>Verify Install</DropdownItem> -->
|
||||
<DropdownItem
|
||||
|
|
|
@ -56,6 +56,14 @@ export async function runCompiler(
|
|||
);
|
||||
}
|
||||
|
||||
export async function getLaunchGameString(gameName: string): Promise<string> {
|
||||
return await invoke_rpc(
|
||||
"get_launch_game_string",
|
||||
{ gameName },
|
||||
() => "_mirror_",
|
||||
);
|
||||
}
|
||||
|
||||
export async function launchGame(
|
||||
gameName: string,
|
||||
inDebug: boolean,
|
||||
|
|
Loading…
Reference in a new issue