Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src-tauri/bindings/NorthstarLaunchOptions.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.

export interface NorthstarLaunchOptions { launch_via_steam: boolean, bypass_checks: boolean, }
19 changes: 12 additions & 7 deletions src-tauri/src/northstar/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,15 @@ use crate::util::check_ea_app_or_origin_running;
use crate::{constants::CORE_MODS, platform_specific::get_host_os, GameInstall, InstallType};
use crate::{NorthstarThunderstoreRelease, NorthstarThunderstoreReleaseWrapper};
use anyhow::anyhow;
use serde::{Deserialize, Serialize};
use ts_rs::TS;

#[derive(Serialize, Deserialize, Debug, Clone, TS)]
#[ts(export)]
pub struct NorthstarLaunchOptions {
launch_via_steam: bool,
bypass_checks: bool,
}

/// Gets list of available Northstar versions from Thunderstore
#[tauri::command]
Expand Down Expand Up @@ -150,13 +159,11 @@ pub fn get_northstar_version_number(game_install: GameInstall) -> Result<String,
#[tauri::command]
pub fn launch_northstar(
game_install: GameInstall,
launch_via_steam: Option<bool>,
bypass_checks: Option<bool>,
launch_options: NorthstarLaunchOptions,
) -> Result<String, String> {
dbg!(game_install.clone());

let launch_via_steam = launch_via_steam.unwrap_or(false);
if launch_via_steam {
if launch_options.launch_via_steam {
return launch_northstar_steam(game_install);
}

Expand All @@ -175,10 +182,8 @@ pub fn launch_northstar(
return launch_northstar_steam(game_install);
}

let bypass_checks = bypass_checks.unwrap_or(false);

// Only check guards if bypassing checks is not enabled
if !bypass_checks {
if !launch_options.bypass_checks {
// Some safety checks before, should have more in the future
if get_northstar_version_number(game_install.clone()).is_err() {
return Err(anyhow!("Not all checks were met").to_string());
Expand Down
18 changes: 14 additions & 4 deletions src-vue/src/plugins/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import { router } from "../main";
import { ReleaseInfo } from "../../../src-tauri/bindings/ReleaseInfo";
import { ThunderstoreMod } from "../../../src-tauri/bindings/ThunderstoreMod";
import { NorthstarMod } from "../../../src-tauri/bindings/NorthstarMod";
import { NorthstarLaunchOptions } from "../../../src-tauri/bindings/NorthstarLaunchOptions"
import { searchModule } from './modules/search';
import { i18n } from '../main';
import { pullRequestModule } from './modules/pull_requests';
Expand Down Expand Up @@ -173,8 +174,13 @@ export const store = createStore<FlightCoreStore>({
}
},
async launchGame(state: any, no_checks = false) {
if (no_checks) {
await invoke("launch_northstar", { gameInstall: state.game_install, bypassChecks: no_checks })
const launch_options: NorthstarLaunchOptions = {
launch_via_steam: false,
bypass_checks: no_checks,
};

if (launch_options.bypass_checks) {
await invoke("launch_northstar", { gameInstall: state.game_install, launchOptions: launch_options })
.then((message) => {
console.log("Launched with bypassed checks");
console.log(message);
Expand Down Expand Up @@ -224,7 +230,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, launchOptions: launch_options })
.then((message) => {
console.log(message);
// NorthstarState.RUNNING
Expand All @@ -241,7 +247,11 @@ export const store = createStore<FlightCoreStore>({
}
},
async launchGameSteam(state: any, no_checks = false) {
await invoke("launch_northstar", { gameInstall: state.game_install, launchViaSteam: true, bypassChecks: no_checks })
const launch_options: NorthstarLaunchOptions = {
launch_via_steam: true,
bypass_checks: false,
};
await invoke("launch_northstar", { gameInstall: state.game_install, launchOptions: launch_options })
.then((message) => {
showNotification('Success');
})
Expand Down