mirror of
https://github.com/an-anime-team/an-anime-game-launcher.git
synced 2024-12-24 10:38:14 +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 () => {
|
ipcMain.on('prefix-con', async () => {
|
||||||
const result = await dialog.showOpenDialog({ properties: ['openDirectory'] });
|
const result = await dialog.showOpenDialog({ properties: ['openDirectory'] });
|
||||||
if(result.filePaths.length == 0) return;
|
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 () => {
|
ipcMain.on('prefix-changed', async () => {
|
||||||
|
|
|
@ -116,6 +116,7 @@
|
||||||
<span id="setprefix">empty</span>
|
<span id="setprefix">empty</span>
|
||||||
|
|
||||||
<button class="button" id="prefixdir" i18id="ChangePrefix">Change Prefix</button>
|
<button class="button" id="prefixdir" i18id="ChangePrefix">Change Prefix</button>
|
||||||
|
<button class="button" id="defprefix" i18id="DefPrefix">Reset</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="selected-item">
|
<div class="selected-item">
|
||||||
|
|
|
@ -61,7 +61,8 @@ $(() => {
|
||||||
});
|
});
|
||||||
|
|
||||||
ipcRenderer.on('change-prefix', (event: void, data: any) => {
|
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();
|
LauncherUI.updateLauncherState();
|
||||||
ipcRenderer.send('prefix-changed');
|
ipcRenderer.send('prefix-changed');
|
||||||
});
|
});
|
||||||
|
|
|
@ -40,16 +40,24 @@ export default class PrefixSelector
|
||||||
|
|
||||||
if (fs.existsSync(path.join(dp, 'drive_c', 'Program Files', 'Genshin Impact', 'GenshinImpact_Data', 'Persistent'))) {
|
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();
|
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'))) {
|
} 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 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];
|
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 {
|
} else {
|
||||||
console.log('Game not found.');
|
console.log('Game not found.');
|
||||||
|
|
||||||
// Unset version if game is not found.
|
// Unset version if game is not found.
|
||||||
LauncherLib.updateConfig('version', null);
|
LauncherLib.updateConfig('version', null);
|
||||||
|
LauncherLib.updateConfig('prefix', dp);
|
||||||
|
this.prefix = dp;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -68,6 +68,10 @@ $(() => {
|
||||||
ipcRenderer.send('prefix-con');
|
ipcRenderer.send('prefix-con');
|
||||||
})
|
})
|
||||||
|
|
||||||
|
$('#prefixloc #defprefix').on('click', () => {
|
||||||
|
ipcRenderer.send('prefix-reset');
|
||||||
|
})
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Game voice language
|
* Game voice language
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Reference in a new issue