Skip to content

Commit

Permalink
Utilize offline and download location arguments from version
Browse files Browse the repository at this point in the history
  • Loading branch information
EliteAsian123 committed Aug 24, 2024
1 parent 41d762f commit a2d9de4
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 4 deletions.
19 changes: 16 additions & 3 deletions src/profiles/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<void> => {
const directories = useDirectories.getState();
Expand Down Expand Up @@ -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);
Expand Down
1 change: 1 addition & 0 deletions src/profiles/directories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export interface ImportantDirs {
}

export interface CustomDirs {
installFolder: string,
yargFolder: string,
setlistFolder: string,
}
Expand Down
3 changes: 2 additions & 1 deletion src/profiles/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ export interface Version {
executablePath: string,
arguments: string[],
offlineArgument?: string,
languageArgument?: string
languageArgument?: string,
downloadLocationArgument?: string,
}
}
}
Expand Down

0 comments on commit a2d9de4

Please sign in to comment.