Return proper value from getGameExecutable

getGameExecutable returns the executable name only.
basename can remove filetype instead of splitting.
This commit is contained in:
Thoronium
2025-11-27 00:31:12 -07:00
committed by GitHub
parent 0370576c11
commit d9b820c842

View File

@@ -2,18 +2,17 @@ import { invoke } from '@tauri-apps/api'
import { basename, dirname, join } from '@tauri-apps/api/path'
import { getConfigOption } from './configuration'
// For god's sake i don't know why the game's EXECUTABLE is called game install PATH.
// either game_install_dir or game_exectuable_path. not a mix of them :sob:
// The following method is just an adapter to limit the scope of changes in this commit.
// Ideally, all instances of these single, autonomous, disjointed methods should be replaced with methods in configuration.ts which are much nicer. (if named correctly)
export const getGameExecutable = () => getConfigOption('game_install_path')
export const getGrasscutterJar = () => getConfigOption('grasscutter_path')
export async function getGameExecutable() {
const exe_path = await getConfigOption('game_install_path')
return await basename(exe_path)
}
export async function getGameVersion() {
const execPath = await getConfigOption('game_install_path')
const rootPath = await dirname(execPath)
const baseName = (await basename(execPath)).split('.exe')[0]
const baseName = (await basename(execPath, ".exe"))
const datapath = await join(rootPath, `${baseName}_Data`)
const asbPath = await join(datapath, 'StreamingAssets', 'asb_settings.json')
const hasAsb = await invoke<boolean>('dir_exists', { path: asbPath })