From 58c43a58d472124f05585109e2fa83c94f42261f Mon Sep 17 00:00:00 2001 From: Turleynerd <4308353+turleynerd@users.noreply.github.com> Date: Sat, 2 Sep 2023 20:19:56 -0400 Subject: [PATCH] init --- app.ts | 92 +++++++++++++++++++++++++++++++++++++++++++++++++++++ index.html | 18 +++++++++++ renderer.js | 38 ++++++++++++++++++++++ style.css | 67 ++++++++++++++++++++++++++++++++++++++ 4 files changed, 215 insertions(+) create mode 100644 app.ts create mode 100644 index.html create mode 100644 renderer.js create mode 100644 style.css diff --git a/app.ts b/app.ts new file mode 100644 index 0000000..c4c95ad --- /dev/null +++ b/app.ts @@ -0,0 +1,92 @@ +import { app, BrowserWindow } from 'electron'; +import { download } from 'electron-dl'; + +// Files to download +const files: string[] = [ + 'info.txt', + 'patch-4.mpq', + 'patch-5.mpq', + 'patch-7.mpq', + 'patch-9.mpq', + 'patch-B.mpq', + 'patch-C.mpq', + 'patch-D.mpq', + 'patch-F.mpq', + 'patch-G.mpq', + 'patch-J.mpq', + 'patch-L.mpq', + 'patch-S.mpq', + 'patch-T.mpq', + 'patch-U.mpq', +]; + +const patchSource = 'https://storage.googleapis.com/araxia-client-patches/'; +const appName = 'Araxia Client Patch Downloader'; + +let mainWindow: BrowserWindow | null; + +function createWindow() { + // Create the browser window + mainWindow = new BrowserWindow({ + width: 800, + height: 600, + webPreferences: { + nodeIntegration: true, + }, + }); + + // Load the index.html file + mainWindow.loadFile('index.html'); + + // Open the DevTools. + // mainWindow.webContents.openDevTools(); + + // Emitted when the window is closed + mainWindow.on('closed', function () { + mainWindow = null; + }); + + // Handle the close button click + mainWindow.on('close', function (e) { + // Prevent the window from closing immediately + e.preventDefault(); + app.quit(); + }); +} + +// Create the main window when the app is ready +app.on('ready', createWindow); + +// Quit the app when all windows are closed (except on macOS) +app.on('window-all-closed', function () { + if (process.platform !== 'darwin') { + app.quit(); + } +}); + +// Create a new window when the app is activated (on macOS) +app.on('activate', function () { + if (mainWindow === null) { + createWindow(); + } +}); + +// Handle file downloads +app.on('ready', function () { + // Specify the directory where files will be downloaded + const directory = app.getPath('userData'); + + // Download each file in parallel + files.forEach((file, index) => { + download(mainWindow, patchSource + file, { directory, filename: file }) + .then(() => { + // File downloaded successfully + console.log(`File ${file} downloaded.`); + mainWindow?.webContents.send('update-progress', { index, progress: 100 }); + }) + .catch((error) => { + // Error occurred during download + console.error(`Error downloading file ${file}: ${error}`); + }); + }); +}); diff --git a/index.html b/index.html new file mode 100644 index 0000000..85cd24c --- /dev/null +++ b/index.html @@ -0,0 +1,18 @@ + + +
+ + +