mirror of
https://github.com/Grasscutters/Cultivation.git
synced 2026-02-04 09:25:16 +01:00
Return proper value from getGameExecutable
getGameExecutable returns the executable name only. basename can remove filetype instead of splitting.
This commit is contained in:
@@ -2,18 +2,17 @@ import { invoke } from '@tauri-apps/api'
|
|||||||
import { basename, dirname, join } from '@tauri-apps/api/path'
|
import { basename, dirname, join } from '@tauri-apps/api/path'
|
||||||
import { getConfigOption } from './configuration'
|
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 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() {
|
export async function getGameVersion() {
|
||||||
const execPath = await getConfigOption('game_install_path')
|
const execPath = await getConfigOption('game_install_path')
|
||||||
const rootPath = await dirname(execPath)
|
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 datapath = await join(rootPath, `${baseName}_Data`)
|
||||||
const asbPath = await join(datapath, 'StreamingAssets', 'asb_settings.json')
|
const asbPath = await join(datapath, 'StreamingAssets', 'asb_settings.json')
|
||||||
const hasAsb = await invoke<boolean>('dir_exists', { path: asbPath })
|
const hasAsb = await invoke<boolean>('dir_exists', { path: asbPath })
|
||||||
|
|||||||
Reference in New Issue
Block a user