From a2d9de42923b5664fee007c545b24c22ec856a96 Mon Sep 17 00:00:00 2001 From: EliteAsian <29520859+EliteAsian123@users.noreply.github.com> Date: Sat, 24 Aug 2024 16:38:14 -0400 Subject: [PATCH] Utilize offline and download location arguments from version --- src/profiles/actions.ts | 19 ++++++++++++++++--- src/profiles/directories.ts | 1 + src/profiles/types.ts | 3 ++- 3 files changed, 19 insertions(+), 4 deletions(-) diff --git a/src/profiles/actions.ts b/src/profiles/actions.ts index e4586f8..997144a 100644 --- a/src/profiles/actions.ts +++ b/src/profiles/actions.ts @@ -6,6 +6,8 @@ import { getOS } from "@app/utils/os"; import { invoke } from "@tauri-apps/api"; import { useDirectories } from "./directories"; import { showErrorDialog } from "@app/dialogs"; +import { useOfflineStatus } from "@app/hooks/useOfflineStatus"; +import { settingsManager } from "@app/settings"; export const downloadAndInstall = async (profile: ActiveProfile, profilePath: string, onFinish?: () => void): Promise => { const directories = useDirectories.getState(); @@ -41,16 +43,27 @@ export const launch = async (activeProfile: ActiveProfile, profilePath: string): return; } - let additionalArguments: string[] = []; + let customArguments: string[] = []; if (activeProfile.launchArguments.trim().length > 0) { - additionalArguments = activeProfile.launchArguments.trim().split(" "); + customArguments = activeProfile.launchArguments.trim().split(" "); + } + + let otherArguments: string[] = []; + + if (launchOptions.offlineArgument !== undefined && useOfflineStatus.getState().isOffline) { + otherArguments.push(launchOptions.offlineArgument); + } + + if (launchOptions.downloadLocationArgument !== undefined) { + otherArguments.push(launchOptions.downloadLocationArgument); + otherArguments.push(settingsManager.getCache("downloadLocation")); } try { await invoke("launch_profile", { profilePath: profilePath, execPath: launchOptions.executablePath, - arguments: [...launchOptions.arguments, ...additionalArguments] + arguments: [...launchOptions.arguments, ...customArguments] }); } catch (e) { showErrorDialog(e as string); diff --git a/src/profiles/directories.ts b/src/profiles/directories.ts index 7dd3b3b..ca5258e 100644 --- a/src/profiles/directories.ts +++ b/src/profiles/directories.ts @@ -8,6 +8,7 @@ export interface ImportantDirs { } export interface CustomDirs { + installFolder: string, yargFolder: string, setlistFolder: string, } diff --git a/src/profiles/types.ts b/src/profiles/types.ts index 8cc12aa..f66c7bf 100644 --- a/src/profiles/types.ts +++ b/src/profiles/types.ts @@ -28,7 +28,8 @@ export interface Version { executablePath: string, arguments: string[], offlineArgument?: string, - languageArgument?: string + languageArgument?: string, + downloadLocationArgument?: string, } } }