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,
|
install_path: std::path::PathBuf,
|
||||||
active_version: String,
|
active_version: String,
|
||||||
active_version_folder: String,
|
active_version_folder: String,
|
||||||
|
tooling_version: Version,
|
||||||
}
|
}
|
||||||
|
|
||||||
fn common_prelude(
|
fn common_prelude(
|
||||||
|
@ -58,10 +59,14 @@ fn common_prelude(
|
||||||
"No active version folder set, can't perform operation".to_owned(),
|
"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 {
|
Ok(CommonConfigData {
|
||||||
install_path: install_path.to_path_buf(),
|
install_path: install_path.to_path_buf(),
|
||||||
active_version: active_version.clone(),
|
active_version: active_version.clone(),
|
||||||
active_version_folder: active_version_folder.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]
|
fn generate_launch_game_string(
|
||||||
pub async fn launch_game(
|
config_info: &CommonConfigData,
|
||||||
config: tauri::State<'_, tokio::sync::Mutex<LauncherConfig>>,
|
|
||||||
app_handle: tauri::AppHandle,
|
|
||||||
game_name: String,
|
game_name: String,
|
||||||
in_debug: bool,
|
in_debug: bool,
|
||||||
) -> Result<(), CommandError> {
|
) -> Result<Vec<String>, 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
|
|
||||||
|
|
||||||
let data_folder = get_data_dir(&config_info, &game_name, false)?;
|
let data_folder = get_data_dir(&config_info, &game_name, false)?;
|
||||||
let exec_info = get_exec_location(&config_info, "gk")?;
|
|
||||||
|
|
||||||
let mut args;
|
let mut args;
|
||||||
// NOTE - order unfortunately matters for gk 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
|
// old argument format
|
||||||
args = vec![
|
args = vec![
|
||||||
"-boot".to_string(),
|
"-boot".to_string(),
|
||||||
|
@ -675,11 +669,44 @@ pub async fn launch_game(
|
||||||
args.push("-debug".to_string());
|
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!(
|
log::info!(
|
||||||
"Launching game version {:?} -> {:?} with args: {:?}",
|
"Launching game version {:?} -> {:?} with args: {:?}",
|
||||||
&config_info.active_version,
|
&config_info.active_version,
|
||||||
tooling_version,
|
&config_info.tooling_version,
|
||||||
args
|
args
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
@ -132,17 +132,19 @@ fn main() {
|
||||||
.invoke_handler(tauri::generate_handler![
|
.invoke_handler(tauri::generate_handler![
|
||||||
commands::binaries::extract_and_validate_iso,
|
commands::binaries::extract_and_validate_iso,
|
||||||
commands::binaries::get_end_of_logs,
|
commands::binaries::get_end_of_logs,
|
||||||
|
commands::binaries::get_launch_game_string,
|
||||||
commands::binaries::launch_game,
|
commands::binaries::launch_game,
|
||||||
commands::binaries::open_repl,
|
commands::binaries::open_repl,
|
||||||
commands::binaries::run_compiler,
|
commands::binaries::run_compiler,
|
||||||
commands::binaries::run_decompiler,
|
commands::binaries::run_decompiler,
|
||||||
commands::binaries::update_data_directory,
|
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::delete_old_data_directory,
|
||||||
commands::config::finalize_installation,
|
commands::config::finalize_installation,
|
||||||
commands::config::get_active_tooling_version_folder,
|
commands::config::get_active_tooling_version_folder,
|
||||||
commands::config::get_active_tooling_version,
|
commands::config::get_active_tooling_version,
|
||||||
commands::config::get_bypass_requirements,
|
commands::config::get_bypass_requirements,
|
||||||
|
commands::config::get_enabled_texture_packs,
|
||||||
commands::config::get_install_directory,
|
commands::config::get_install_directory,
|
||||||
commands::config::get_installed_version_folder,
|
commands::config::get_installed_version_folder,
|
||||||
commands::config::get_installed_version,
|
commands::config::get_installed_version,
|
||||||
|
@ -154,18 +156,17 @@ fn main() {
|
||||||
commands::config::reset_to_defaults,
|
commands::config::reset_to_defaults,
|
||||||
commands::config::save_active_version_change,
|
commands::config::save_active_version_change,
|
||||||
commands::config::set_bypass_requirements,
|
commands::config::set_bypass_requirements,
|
||||||
|
commands::config::set_enabled_texture_packs,
|
||||||
commands::config::set_install_directory,
|
commands::config::set_install_directory,
|
||||||
commands::config::set_locale,
|
commands::config::set_locale,
|
||||||
commands::config::get_enabled_texture_packs,
|
|
||||||
commands::config::cleanup_enabled_texture_packs,
|
|
||||||
commands::download::download_file,
|
commands::download::download_file,
|
||||||
commands::game::reset_game_settings,
|
commands::features::delete_texture_packs,
|
||||||
commands::game::uninstall_game,
|
|
||||||
commands::game::get_furthest_game_milestone,
|
|
||||||
commands::features::update_texture_pack_data,
|
|
||||||
commands::features::extract_new_texture_pack,
|
commands::features::extract_new_texture_pack,
|
||||||
commands::features::list_extracted_texture_pack_info,
|
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::logging::frontend_log,
|
||||||
commands::support::generate_support_package,
|
commands::support::generate_support_package,
|
||||||
commands::versions::download_version,
|
commands::versions::download_version,
|
||||||
|
|
|
@ -39,6 +39,9 @@
|
||||||
},
|
},
|
||||||
"allowlist": {
|
"allowlist": {
|
||||||
"all": true,
|
"all": true,
|
||||||
|
"clipboard": {
|
||||||
|
"writeText": true
|
||||||
|
},
|
||||||
"fs": {
|
"fs": {
|
||||||
"scope": [
|
"scope": [
|
||||||
"$APP/",
|
"$APP/",
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
import IconCog from "~icons/mdi/cog";
|
import IconCog from "~icons/mdi/cog";
|
||||||
import { configDir, join } from "@tauri-apps/api/path";
|
import { configDir, join } from "@tauri-apps/api/path";
|
||||||
import { createEventDispatcher, onMount } from "svelte";
|
import { createEventDispatcher, onMount } from "svelte";
|
||||||
|
import { writeText } from "@tauri-apps/api/clipboard";
|
||||||
import { confirm } from "@tauri-apps/api/dialog";
|
import { confirm } from "@tauri-apps/api/dialog";
|
||||||
import {
|
import {
|
||||||
Button,
|
Button,
|
||||||
|
@ -14,9 +15,10 @@
|
||||||
} 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 { launchGame, openREPL } from "$lib/rpc/binaries";
|
import { getLaunchGameString, launchGame, openREPL } from "$lib/rpc/binaries";
|
||||||
import { _ } from "svelte-i18n";
|
import { _ } from "svelte-i18n";
|
||||||
import { navigate } from "svelte-navigator";
|
import { navigate } from "svelte-navigator";
|
||||||
|
import { toastStore } from "$lib/stores/ToastStore";
|
||||||
|
|
||||||
export let activeGame: SupportedGame;
|
export let activeGame: SupportedGame;
|
||||||
|
|
||||||
|
@ -131,6 +133,21 @@
|
||||||
}}>{$_("gameControls_button_openSavesFolder")}</DropdownItem
|
}}>{$_("gameControls_button_openSavesFolder")}</DropdownItem
|
||||||
>
|
>
|
||||||
<DropdownDivider />
|
<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 -->
|
<!-- TODO - verify installation -->
|
||||||
<!-- <DropdownItem>Verify Install</DropdownItem> -->
|
<!-- <DropdownItem>Verify Install</DropdownItem> -->
|
||||||
<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(
|
export async function launchGame(
|
||||||
gameName: string,
|
gameName: string,
|
||||||
inDebug: boolean,
|
inDebug: boolean,
|
||||||
|
|
Loading…
Reference in a new issue