Game version checking

This commit is contained in:
Benj
2022-08-31 22:06:52 +08:00
parent ff8f35c52a
commit 8077285e79
3 changed files with 56 additions and 5 deletions

View File

@@ -1,3 +1,4 @@
import { invoke } from '@tauri-apps/api'
import { getConfig } from './configuration'
export async function getGameExecutable() {
@@ -25,3 +26,34 @@ export async function getGameFolder() {
return path
}
export async function getGameDataFolder() {
const gameExec = await getGameExecutable()
if (!gameExec) {
return null
}
return (await getGameFolder()) + '\\' + gameExec.replace('.exe', '_Data')
}
export async function getGameVersion() {
const GameData = await getGameDataFolder();
if (!GameData) {
return null
}
const settings = JSON.parse(await invoke('read_file', {
path: GameData + '\\StreamingAssets\\asb_settings.json',
}))
const versionRaw = settings.variance.split('.');
const version = {
major: parseInt(versionRaw[0]),
minor: parseInt(versionRaw[1].split('_')[0]),
release: parseInt(versionRaw[1].split('_')[1]),
}
return version;
}