diff --git a/public/locales/de.json b/public/locales/de.json index 09db099..6140d10 100644 --- a/public/locales/de.json +++ b/public/locales/de.json @@ -2,6 +2,7 @@ "Install": "Installieren", "Update": "Updaten", "Launch": "Starten", + "ResumeDownload": "Download Fortsetzen", "Runners": "Runners", "Language": "Sprache", "Voice": "Sprachpaket", diff --git a/public/locales/en-us.json b/public/locales/en-us.json index 128b5aa..22b350d 100644 --- a/public/locales/en-us.json +++ b/public/locales/en-us.json @@ -2,6 +2,7 @@ "Install": "Install", "Update": "Update", "Launch": "Launch", + "ResumeDownload": "Resume Download", "Runners": "Runners", "Language": "Language", "Voice": "Voice Pack", diff --git a/public/locales/en.json b/public/locales/en.json index dd04010..efc9022 100644 --- a/public/locales/en.json +++ b/public/locales/en.json @@ -2,6 +2,7 @@ "Install": "Install", "Update": "Update", "Launch": "Launch", + "ResumeDownload": "Resume Download", "Runners": "Runners", "Language": "Language", "Voice": "Voice Pack", diff --git a/public/locales/es.json b/public/locales/es.json index dd04010..efc9022 100644 --- a/public/locales/es.json +++ b/public/locales/es.json @@ -2,6 +2,7 @@ "Install": "Install", "Update": "Update", "Launch": "Launch", + "ResumeDownload": "Resume Download", "Runners": "Runners", "Language": "Language", "Voice": "Voice Pack", diff --git a/public/locales/fr.json b/public/locales/fr.json index dd04010..efc9022 100644 --- a/public/locales/fr.json +++ b/public/locales/fr.json @@ -2,6 +2,7 @@ "Install": "Install", "Update": "Update", "Launch": "Launch", + "ResumeDownload": "Resume Download", "Runners": "Runners", "Language": "Language", "Voice": "Voice Pack", diff --git a/public/locales/id.json b/public/locales/id.json index 5c782e9..22e4129 100644 --- a/public/locales/id.json +++ b/public/locales/id.json @@ -2,6 +2,7 @@ "Install": "Pasang", "Update": "Perbarui", "Launch": "Luncurkan", + "ResumeDownload": "Resume Download", "Runners": "Runners", "Language": "Bahasa", "Voice": "Paket Suara", diff --git a/public/locales/ja.json b/public/locales/ja.json index ca2c39a..2950490 100644 --- a/public/locales/ja.json +++ b/public/locales/ja.json @@ -2,6 +2,7 @@ "Install": "インストール", "Update": "アップデート", "Launch": "打ち上げ", + "ResumeDownload": "Resume Download", "Runners": "Runners", "Language": "言語", "Voice": "ボイスパック", diff --git a/public/locales/ko.json b/public/locales/ko.json index fdf4942..786cd69 100644 --- a/public/locales/ko.json +++ b/public/locales/ko.json @@ -2,6 +2,7 @@ "Install": "설치", "Update": "업데이트", "Launch": "발사", + "ResumeDownload": "Resume Download", "Runners": "주자", "Language": "언어", "Voice": "음성 팩", diff --git a/public/locales/pt.json b/public/locales/pt.json index dd04010..efc9022 100644 --- a/public/locales/pt.json +++ b/public/locales/pt.json @@ -2,6 +2,7 @@ "Install": "Install", "Update": "Update", "Launch": "Launch", + "ResumeDownload": "Resume Download", "Runners": "Runners", "Language": "Language", "Voice": "Voice Pack", diff --git a/public/locales/ru.json b/public/locales/ru.json index ddb8165..1b7457a 100644 --- a/public/locales/ru.json +++ b/public/locales/ru.json @@ -2,6 +2,7 @@ "Install": "Установить", "Update": "Обновить", "Launch": "Запустить", + "ResumeDownload": "Resume Download", "Runners": "Версии Wine", "Language": "Язык", "Voice": "Озвучка", diff --git a/public/locales/th.json b/public/locales/th.json index dd04010..efc9022 100644 --- a/public/locales/th.json +++ b/public/locales/th.json @@ -2,6 +2,7 @@ "Install": "Install", "Update": "Update", "Launch": "Launch", + "ResumeDownload": "Resume Download", "Runners": "Runners", "Language": "Language", "Voice": "Voice Pack", diff --git a/public/locales/vi.json b/public/locales/vi.json index dd04010..efc9022 100644 --- a/public/locales/vi.json +++ b/public/locales/vi.json @@ -2,6 +2,7 @@ "Install": "Install", "Update": "Update", "Launch": "Launch", + "ResumeDownload": "Resume Download", "Runners": "Runners", "Language": "Language", "Voice": "Voice Pack", diff --git a/public/locales/zh-cn.json b/public/locales/zh-cn.json index 1b60e56..bcc83db 100644 --- a/public/locales/zh-cn.json +++ b/public/locales/zh-cn.json @@ -2,6 +2,7 @@ "Install": "安装", "Update": "更新", "Launch": "发射", + "ResumeDownload": "Resume Download", "Runners": "Runners", "Language": "语言", "Voice": "语音包", diff --git a/public/locales/zh-tw.json b/public/locales/zh-tw.json index 3ba4209..82d610b 100644 --- a/public/locales/zh-tw.json +++ b/public/locales/zh-tw.json @@ -2,6 +2,7 @@ "Install": "安裝", "Update": "更新", "Launch": "啟動遊戲", + "ResumeDownload": "Resume Download", "Runners": "執行器", "Language": "界面語言", "Voice": "語音包", diff --git a/src/ts/lib/LauncherUI.ts b/src/ts/lib/LauncherUI.ts index 4e8ee7e..668e7bb 100644 --- a/src/ts/lib/LauncherUI.ts +++ b/src/ts/lib/LauncherUI.ts @@ -1,6 +1,8 @@ const { ipcRenderer } = require('electron'); import $ from 'cash-dom'; +import path from 'path'; +import fs from 'fs'; import constants from './constants'; import LauncherLib from './LauncherLib'; @@ -15,6 +17,7 @@ type LauncherState = 'game-update-available' | 'game-installation-available' | 'game-voice-update-required' | + 'download-resumable' | 'game-launch-available'; type Theme = 'light' | 'dark'; @@ -99,6 +102,8 @@ export default class LauncherUI $('#launch').text(this.i18n.translate('Launch')); break; + case 'download-resumable': + $('#launch').text(this.i18n.translate('ResumeDownload')); } this._launcherState = state; @@ -110,8 +115,11 @@ export default class LauncherUI const patchInfo = await LauncherLib.getPatchInfo(); // Update available - if (LauncherLib.version != gameData.game.latest.version) - this.setState(LauncherLib.version === null ? 'game-installation-available' : 'game-update-available'); + if (LauncherLib.version != gameData.game.latest.version) { + if(!fs.existsSync(path.join(constants.launcherDir, `latest-${gameData.game.latest.version}.zip`))) + this.setState(LauncherLib.version === null ? 'game-installation-available' : 'game-update-available'); + else this.setState('download-resumable'); + } // Voice pack update required else if (LauncherLib.getConfig('lang.voice.active') != LauncherLib.getConfig('lang.voice.installed')) diff --git a/src/ts/lib/Tools.ts b/src/ts/lib/Tools.ts index 6706cf5..c5f080e 100644 --- a/src/ts/lib/Tools.ts +++ b/src/ts/lib/Tools.ts @@ -126,9 +126,20 @@ export default class Tools public static async downloadFile (uri: string, savePath: string, progress: null|((current: number, total: number, difference: number) => void) = null): Promise { return new Promise((resolve, reject) => { - https.get(uri, (response: any) => { - let length = parseInt(response.headers['content-length'], 10), - total = 0; + let rangeStart = 0; + + if(fs.existsSync(savePath)) { + // Part of the file was already downloaded, resume the download + rangeStart = fs.statSync(savePath).size; + } + + https.get(uri, { + headers: { + Range: `bytes=${rangeStart}-` + } + }, (response: any) => { + let length = parseInt(response.headers['content-length'], 10) + rangeStart, + total = rangeStart; response.on('data', (chunk: any) => { total += chunk.length;