diff options
-rw-r--r-- | src-tauri/src/northstar/mod.rs | 25 | ||||
-rw-r--r-- | src-vue/src/components/PlayButton.vue | 2 | ||||
-rw-r--r-- | src-vue/src/plugins/store.ts | 14 | ||||
-rw-r--r-- | src-vue/src/utils/LaunchObject.d.ts | 4 | ||||
-rw-r--r-- | src-vue/src/views/DeveloperView.vue | 27 |
5 files changed, 59 insertions, 13 deletions
diff --git a/src-tauri/src/northstar/mod.rs b/src-tauri/src/northstar/mod.rs index 173495c6..e79123fd 100644 --- a/src-tauri/src/northstar/mod.rs +++ b/src-tauri/src/northstar/mod.rs @@ -62,6 +62,7 @@ pub fn get_northstar_version_number(game_install: GameInstall) -> Result<String, pub fn launch_northstar( game_install: GameInstall, bypass_checks: Option<bool>, + launch_parameters: Option<String>, ) -> Result<String, String> { dbg!(game_install.clone()); @@ -77,7 +78,7 @@ pub fn launch_northstar( )); } - return launch_northstar_steam(game_install, bypass_checks); + return launch_northstar_steam(game_install, bypass_checks, launch_parameters); } let bypass_checks = bypass_checks.unwrap_or(false); @@ -112,10 +113,22 @@ pub fn launch_northstar( || matches!(game_install.install_type, InstallType::UNKNOWN)) { let ns_exe_path = format!("{}/NorthstarLauncher.exe", game_install.game_path); - let ns_profile_arg = format!("-profile={}", game_install.profile); + let mut args = vec!["/C", "start", "", &ns_exe_path]; + let ns_profile_arg = format!("-profile={}", game_install.profile); + // We cannot add the params directly because of limitations with cmd.exe + // https://stackoverflow.com/questions/9964865/c-system-not-working-when-there-are-spaces-in-two-different-parameters/9965141#9965141 + + let launch_parameters = format!( + "{} {}", + ns_profile_arg, + launch_parameters.unwrap_or_default() + ); + let ns_params: Vec<&str> = launch_parameters.split_whitespace().collect(); + dbg!(ns_params.clone()); + args.extend(ns_params); let _output = std::process::Command::new("C:\\Windows\\System32\\cmd.exe") - .args(["/C", "start", "", &ns_exe_path, &ns_profile_arg]) + .args(args) .spawn() .expect("failed to execute process"); return Ok("Launched game".to_string()); @@ -133,6 +146,7 @@ pub fn launch_northstar( pub fn launch_northstar_steam( game_install: GameInstall, _bypass_checks: Option<bool>, + launch_parameters: Option<String>, ) -> Result<String, String> { if !matches!(game_install.install_type, InstallType::STEAM) { return Err("Titanfall2 was not installed via Steam".to_string()); @@ -175,9 +189,10 @@ pub fn launch_northstar_steam( return Err("Couldn't access Titanfall2 directory".to_string()); } + let launch_parameters = launch_parameters.unwrap_or_default(); match open::that(format!( - "steam://run/{}//-profile={} --northstar/", - TITANFALL2_STEAM_ID, game_install.profile + "steam://run/{}//-profile={} --northstar {}/", + TITANFALL2_STEAM_ID, game_install.profile, launch_parameters )) { Ok(()) => Ok("Started game".to_string()), Err(_err) => Err("Failed to launch Titanfall 2 via Steam".to_string()), diff --git a/src-vue/src/components/PlayButton.vue b/src-vue/src/components/PlayButton.vue index 83a23ae5..ba40d68e 100644 --- a/src-vue/src/components/PlayButton.vue +++ b/src-vue/src/components/PlayButton.vue @@ -87,7 +87,7 @@ export default defineComponent({ }, methods: { async launchGame() { - this.$store.commit('launchGame'); + this.$store.commit('launchGame', {}); } } }); diff --git a/src-vue/src/plugins/store.ts b/src-vue/src/plugins/store.ts index 9865b992..b28dd5a8 100644 --- a/src-vue/src/plugins/store.ts +++ b/src-vue/src/plugins/store.ts @@ -4,6 +4,7 @@ import { Tabs } from "../utils/Tabs"; import { InstallType } from "../utils/InstallType"; import { invoke } from "@tauri-apps/api"; import { GameInstall } from "../utils/GameInstall"; +import { LaunchObject } from "../utils/LaunchObject.d"; import { ReleaseCanal } from "../utils/ReleaseCanal"; import { FlightCoreVersion } from "../../../src-tauri/bindings/FlightCoreVersion"; import { NotificationHandle } from 'element-plus'; @@ -160,9 +161,10 @@ export const store = createStore<FlightCoreStore>({ } } }, - async launchGame(state: any, no_checks = false) { + async launchGame(state: any, payload: LaunchObject) { + const { no_checks = false, launch_args = undefined } = payload; if (no_checks) { - await invoke("launch_northstar", { gameInstall: state.game_install, bypassChecks: no_checks }) + await invoke("launch_northstar", { gameInstall: state.game_install, bypassChecks: no_checks, launchParameters: launch_args }) .then((message) => { console.log("Launched with bypassed checks"); console.log(message); @@ -212,7 +214,7 @@ export const store = createStore<FlightCoreStore>({ // Game is ready to play. case NorthstarState.READY_TO_PLAY: - await invoke("launch_northstar", { gameInstall: state.game_install }) + await invoke("launch_northstar", { gameInstall: state.game_install, launchParameters: launch_args }) .then((message) => { console.log(message); // NorthstarState.RUNNING @@ -228,8 +230,10 @@ export const store = createStore<FlightCoreStore>({ break; } }, - async launchGameSteam(state: any, no_checks = false) { - await invoke("launch_northstar_steam", { gameInstall: state.game_install, bypassChecks: no_checks }) + async launchGameSteam(state: any, payload: LaunchObject) { + const { no_checks = false, launch_args = undefined } = payload; + + await invoke("launch_northstar_steam", { gameInstall: state.game_install, bypassChecks: no_checks, launchParametres: launch_args }) .then((message) => { showNotification('Success'); }) diff --git a/src-vue/src/utils/LaunchObject.d.ts b/src-vue/src/utils/LaunchObject.d.ts new file mode 100644 index 00000000..2fbd4732 --- /dev/null +++ b/src-vue/src/utils/LaunchObject.d.ts @@ -0,0 +1,4 @@ +export interface LaunchObject { + no_checks: boolean, + launch_args: string, +} diff --git a/src-vue/src/views/DeveloperView.vue b/src-vue/src/views/DeveloperView.vue index de83c9a8..8adc7587 100644 --- a/src-vue/src/views/DeveloperView.vue +++ b/src-vue/src/views/DeveloperView.vue @@ -43,6 +43,21 @@ Launch Northstar via Steam </el-button> + <br /> + <br /> + + <el-input v-model="launch_args" placeholder="Launch args" clearable /> + <el-button type="primary" @click="launchGameWithArgs"> + Launch Northstar with args + </el-button> + + <el-button type="primary" @click="launchGameViaSteamWithArgs"> + Launch Northstar with args via Steam + </el-button> + + <br /> + <br /> + <el-button type="primary" @click="installLauncherGitMain"> Install launcher from main branch </el-button> @@ -154,6 +169,7 @@ export default defineComponent({ data() { return { mod_to_install_field_string: "", + launch_args: undefined, release_notes_text: "", first_tag: { label: '', value: { name: '' } }, second_tag: { label: '', value: { name: '' } }, @@ -210,10 +226,17 @@ export default defineComponent({ }); }, async launchGameWithoutChecks() { - this.$store.commit('launchGame', true); + this.$store.commit('launchGame', {no_checks: true}); + }, + async launchGameWithArgs() { + console.log(this.launch_args); + this.$store.commit('launchGame', {no_checks: false, launch_args: this.launch_args}); }, async launchGameViaSteam() { - this.$store.commit('launchGameSteam', true); + this.$store.commit('launchGameSteam', {no_checks: true}); + }, + async launchGameViaSteamWithArgs() { + this.$store.commit('launchGameSteam', {no_checks: false, launch_args: this.launch_args}); }, async getInstalledMods() { await invoke("get_installed_mods_and_properties", { gameInstall: this.$store.state.game_install }).then((message) => { |