mirror of
https://github.com/an-anime-team/an-anime-game-launcher.git
synced 2024-11-26 06:47:07 +03:00
Add Update Voice Pack
This commit is contained in:
parent
b5a549ce70
commit
35f5d5c04e
3 changed files with 58 additions and 0 deletions
4
entry.js
4
entry.js
|
@ -86,6 +86,10 @@ app.whenReady().then(() => {
|
|||
app.commandLine.appendSwitch('lang', Genshinlib.getConfig().lang.launcher);
|
||||
mainWindow.webContents.send('changelang', { 'lang': args.lang });
|
||||
});
|
||||
|
||||
ipcMain.on('updateVP', (event, args) => {
|
||||
mainWindow.webContents.send('updateVP', { 'oldvp': args.oldvp });
|
||||
});
|
||||
});
|
||||
|
||||
// Quit when all windows are closed, except on macOS. There, it's common
|
||||
|
|
|
@ -27,6 +27,57 @@ $(() => {
|
|||
LauncherUI.setState(LauncherUI.launcherState);
|
||||
});
|
||||
|
||||
ipcRenderer.on('updateVP', (event: void, remotedata: any) => {
|
||||
Genshinlib.getData().then(data => {
|
||||
LauncherUI.initProgressBar();
|
||||
|
||||
let voicePack = data.game.latest.voice_packs[1]; // en-us
|
||||
let old;
|
||||
|
||||
for (let i = 0; i < data.game.latest.voice_packs.length; ++i)
|
||||
if (data.game.latest.voice_packs[i].language == Genshinlib.lang.voice)
|
||||
{
|
||||
voicePack = data.game.latest.voice_packs[i];
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
for (let i = 0; i < data.game.latest.voice_packs.length; ++i)
|
||||
if (data.game.latest.voice_packs[i].language == remotedata.oldvp)
|
||||
{
|
||||
old = data.game.latest.voice_packs[i];
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
let oldstring = old.name.replace(`_${data.game.latest.version}.zip`, '');
|
||||
|
||||
// Check if the directory and file exists to prevent errors.
|
||||
if (fs.existsSync(path.join(Genshinlib.gameDir, oldstring + '_pkg_version')))
|
||||
fs.rmSync(path.join(Genshinlib.gameDir, oldstring + '_pkg_version'));
|
||||
if (fs.existsSync(path.join(Genshinlib.gameDir, 'GenshinImpact_Data', 'StreamingAssets', 'Audio', 'GeneratedSoundBanks', 'Windows', oldstring.replace('Audio_', ''))))
|
||||
fs.rmSync(path.join(Genshinlib.gameDir, 'GenshinImpact_Data', 'StreamingAssets', 'Audio', 'GeneratedSoundBanks', 'Windows', oldstring.replace('Audio_', '')), { recursive: true });
|
||||
|
||||
console.log(`%c> Downloading voice data...`, 'font-size: 16px');
|
||||
|
||||
// For some reason this keeps breaking and locking up most of the time.
|
||||
Genshinlib.downloadFile(voicePack.path, path.join(Genshinlib.launcherDir, voicePack.name), (current: number, total: number, difference: number) => {
|
||||
LauncherUI.updateProgressBar(i18n.translate('Downloading'), current, total, difference);
|
||||
}).then(() => {
|
||||
console.log(`%c> Unpacking voice data...`, 'font-size: 16px');
|
||||
|
||||
LauncherUI.initProgressBar();
|
||||
|
||||
Genshinlib.unzip(path.join(Genshinlib.launcherDir, voicePack.name), Genshinlib.gameDir, (current: number, total: number, difference: number) => {
|
||||
LauncherUI.updateProgressBar(i18n.translate('Unpack'), current, total, difference);
|
||||
}).then(() => {
|
||||
fs.unlinkSync(path.join(Genshinlib.launcherDir, voicePack.name));
|
||||
LauncherUI.setState('game-launch-available');
|
||||
})
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Genshinlib.getBackgroundUri().then(uri => $('body').css('background-image', `url(${ uri })`));
|
||||
|
||||
fetch(`https://genshin.mihoyo.com/launcher/10/${Genshinlib.lang.launcher}?api_url=https%3A%2F%2Fapi-os-takumi.mihoyo.com%2Fhk4e_global&prev=false`)
|
||||
|
|
|
@ -41,6 +41,9 @@ $(() => {
|
|||
voice: e.target.value
|
||||
}
|
||||
});
|
||||
|
||||
ipcRenderer.send('updateVP', { 'oldvp': activeVP });
|
||||
|
||||
$(`#voice-list option[value="${activeVP}"]`).removeProp('selected');
|
||||
$(`#voice-list option[value="${e.target.value}"]`).prop('selected', true);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue