mirror of
https://github.com/an-anime-team/an-anime-game-launcher.git
synced 2024-12-20 00:41:48 +03:00
Configure reset to default
This commit is contained in:
parent
391d293555
commit
b5a7007baa
5 changed files with 24 additions and 6 deletions
6
entry.js
6
entry.js
|
@ -124,7 +124,11 @@ app.whenReady().then(() => {
|
|||
ipcMain.on('prefix-con', async () => {
|
||||
const result = await dialog.showOpenDialog({ properties: ['openDirectory'] });
|
||||
if(result.filePaths.length == 0) return;
|
||||
mainWindow.webContents.send('change-prefix', { 'dir': result.filePaths[0] });
|
||||
mainWindow.webContents.send('change-prefix', { 'type': 'change', 'dir': result.filePaths[0] });
|
||||
});
|
||||
|
||||
ipcMain.on('prefix-reset', async () => {
|
||||
mainWindow.webContents.send('change-prefix', { 'type': 'reset' });
|
||||
});
|
||||
|
||||
ipcMain.on('prefix-changed', async () => {
|
||||
|
|
|
@ -116,6 +116,7 @@
|
|||
<span id="setprefix">empty</span>
|
||||
|
||||
<button class="button" id="prefixdir" i18id="ChangePrefix">Change Prefix</button>
|
||||
<button class="button" id="defprefix" i18id="DefPrefix">Reset</button>
|
||||
</div>
|
||||
|
||||
<div class="selected-item">
|
||||
|
|
|
@ -61,7 +61,8 @@ $(() => {
|
|||
});
|
||||
|
||||
ipcRenderer.on('change-prefix', (event: void, data: any) => {
|
||||
PrefixSelector.set(data.dir);
|
||||
if(data.type == 'change') PrefixSelector.set(data.dir);
|
||||
if(data.type == 'reset') PrefixSelector.Default();
|
||||
LauncherUI.updateLauncherState();
|
||||
ipcRenderer.send('prefix-changed');
|
||||
});
|
||||
|
|
|
@ -19,7 +19,7 @@ export default class PrefixSelector
|
|||
} 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' });
|
||||
const version = /([1-9]+\.[0-9]+\.[0-9]+)_[\d]+_[\d]+/.exec(config)![1];
|
||||
|
||||
|
||||
LauncherLib.updateConfig('version', version);
|
||||
LauncherLib.updateConfig('prefix', location);
|
||||
this.prefix = location;
|
||||
|
@ -40,16 +40,24 @@ export default class PrefixSelector
|
|||
|
||||
if (fs.existsSync(path.join(dp, 'drive_c', 'Program Files', 'Genshin Impact', 'GenshinImpact_Data', 'Persistent'))) {
|
||||
const version = fs.readFileSync(path.join(dp, 'drive_c', 'Program Files', 'Genshin Impact', 'GenshinImpact_Data', 'Persistent', 'ScriptVersion'), { encoding: 'UTF-8' }).toString();
|
||||
console.log(version);
|
||||
|
||||
LauncherLib.updateConfig('version', version);
|
||||
LauncherLib.updateConfig('prefix', 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' });
|
||||
const version = /([1-9]+\.[0-9]+\.[0-9]+)_[\d]+_[\d]+/.exec(config)![1];
|
||||
console.log(version);
|
||||
|
||||
LauncherLib.updateConfig('version', version);
|
||||
LauncherLib.updateConfig('prefix', dp);
|
||||
this.prefix = dp;
|
||||
} else {
|
||||
console.log('Game not found.');
|
||||
|
||||
// Unset version if game is not found.
|
||||
LauncherLib.updateConfig('version', null);
|
||||
LauncherLib.updateConfig('prefix', dp);
|
||||
this.prefix = dp;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -59,7 +59,7 @@ $(() => {
|
|||
*/
|
||||
|
||||
$('#prefixloc span').text(LauncherLib.getConfig('prefix'));
|
||||
|
||||
|
||||
ipcRenderer.on('prefix-changed', () => {
|
||||
$('#prefixloc span').text(LauncherLib.getConfig('prefix'));
|
||||
})
|
||||
|
@ -68,6 +68,10 @@ $(() => {
|
|||
ipcRenderer.send('prefix-con');
|
||||
})
|
||||
|
||||
$('#prefixloc #defprefix').on('click', () => {
|
||||
ipcRenderer.send('prefix-reset');
|
||||
})
|
||||
|
||||
/**
|
||||
* Game voice language
|
||||
*/
|
||||
|
|
Loading…
Reference in a new issue