Fix Constants

This commit is contained in:
Maroxy 2021-11-28 19:13:42 +01:00
parent b5a7007baa
commit acfa96c4ae
No known key found for this signature in database
GPG key ID: F4B27EADB21E3021
2 changed files with 9 additions and 1 deletions

View file

@ -1,5 +1,6 @@
const fs = require('fs');
import LauncherLib from "./LauncherLib";
import constants from "./constants";
const path = require('path');
const os = require('os');
@ -15,6 +16,7 @@ export default class PrefixSelector
LauncherLib.updateConfig('version', version);
LauncherLib.updateConfig('prefix', location);
constants.prefixDir = location;
this.prefix = location;
} else if (fs.existsSync(path.join(location, 'drive_c', 'Program Files', 'Genshin Impact', 'GenshinImpact_Data', 'globalgamemanagers'))) {
const config = fs.readFileSync(path.join(location, 'drive_c', 'Program Files', 'Genshin Impact', 'GenshinImpact_Data', 'globalgamemanagers'), { encoding: 'ascii' });
@ -22,6 +24,7 @@ export default class PrefixSelector
LauncherLib.updateConfig('version', version);
LauncherLib.updateConfig('prefix', location);
constants.prefixDir = location;
this.prefix = location;
} else {
console.log('Game not found.');
@ -29,6 +32,7 @@ export default class PrefixSelector
// Unset version if game is not found.
LauncherLib.updateConfig('version', null);
LauncherLib.updateConfig('prefix', location);
constants.prefixDir = location;
this.prefix = location;
}
}
@ -43,6 +47,7 @@ export default class PrefixSelector
LauncherLib.updateConfig('version', version);
LauncherLib.updateConfig('prefix', dp);
constants.prefixDir = dp;
this.prefix = dp;
} else if (fs.existsSync(path.join(dp, 'drive_c', 'Program Files', 'Genshin Impact', 'GenshinImpact_Data', 'globalgamemanagers'))) {
const config = fs.readFileSync(path.join(dp, 'drive_c', 'Program Files', 'Genshin Impact', 'GenshinImpact_Data', 'globalgamemanagers'), { encoding: 'ascii' });
@ -50,6 +55,7 @@ export default class PrefixSelector
LauncherLib.updateConfig('version', version);
LauncherLib.updateConfig('prefix', dp);
constants.prefixDir = dp;
this.prefix = dp;
} else {
console.log('Game not found.');
@ -57,6 +63,7 @@ export default class PrefixSelector
// Unset version if game is not found.
LauncherLib.updateConfig('version', null);
LauncherLib.updateConfig('prefix', dp);
constants.prefixDir = dp;
this.prefix = dp;
}
}

View file

@ -1,5 +1,6 @@
const path = require('path');
const os = require('os');
import LauncherLib from "./LauncherLib";
export default class constants
{
@ -44,7 +45,7 @@ export default class constants
public static readonly launcherDir: string = path.join(os.homedir(), '.local', 'share', 'anime-game-launcher');
public static readonly prefixDir: string = path.join(this.launcherDir, 'game');
public static prefixDir: string = LauncherLib.getConfig('prefix');
public static readonly gameDir: string = path.join(this.prefixDir, 'drive_c', 'Program Files', this.placeholders.uppercase.full);
public static readonly voiceDir: string = path.join(this.gameDir, `${this.placeholders.uppercase.first + this.placeholders.uppercase.second}_Data`, 'StreamingAssets', 'Audio', 'GeneratedSoundBanks', 'Windows');