From 6aa0a6c9690a5898b8b4112de6bc52ac5b7e7916 Mon Sep 17 00:00:00 2001 From: HorizonCode Date: Thu, 18 Jan 2024 12:43:46 +0100 Subject: [PATCH 1/6] add modules to electron export, fix issues when downloading updates --- appInfo.js => electron/appInfo.js | 0 {src/config => electron}/config.js | 0 electron/cryptoUtil.js | 11 ++ {src/util => electron}/executeUtil.js | 0 {src/util => electron}/formattingUtil.js | 0 electron/hwidUtil.js | 32 ++++++ {src/util => electron}/osuUtil.js | 137 ++++++++++++++++------- electron/richPresence.js | 55 +++++++++ main.js | 112 ++++++++++++++---- package-lock.json | 34 +++++- package.json | 10 +- src/App.svelte | 12 +- src/discord/richPresence.js | 56 --------- tests/fileHash.js | 14 --- tests/osuConfig.js | 9 -- tests/osuUpdate.js | 7 -- tsconfig.json | 11 +- 17 files changed, 338 insertions(+), 162 deletions(-) rename appInfo.js => electron/appInfo.js (100%) rename {src/config => electron}/config.js (100%) create mode 100644 electron/cryptoUtil.js rename {src/util => electron}/executeUtil.js (100%) rename {src/util => electron}/formattingUtil.js (100%) create mode 100644 electron/hwidUtil.js rename {src/util => electron}/osuUtil.js (77%) create mode 100644 electron/richPresence.js delete mode 100644 src/discord/richPresence.js delete mode 100644 tests/fileHash.js delete mode 100644 tests/osuConfig.js delete mode 100644 tests/osuUpdate.js diff --git a/appInfo.js b/electron/appInfo.js similarity index 100% rename from appInfo.js rename to electron/appInfo.js diff --git a/src/config/config.js b/electron/config.js similarity index 100% rename from src/config/config.js rename to electron/config.js diff --git a/electron/cryptoUtil.js b/electron/cryptoUtil.js new file mode 100644 index 0000000..354e176 --- /dev/null +++ b/electron/cryptoUtil.js @@ -0,0 +1,11 @@ +const cryptojs = require("crypto-js"); + +const encrypt = (string, salt) => { + return cryptojs.AES.encrypt(string, salt).toString(); +}; + +const decrypt = (string, salt) => { + return cryptojs.AES.decrypt(string, salt).toString(cryptojs.enc.Utf8); +}; + +module.exports = { encrypt, decrypt }; diff --git a/src/util/executeUtil.js b/electron/executeUtil.js similarity index 100% rename from src/util/executeUtil.js rename to electron/executeUtil.js diff --git a/src/util/formattingUtil.js b/electron/formattingUtil.js similarity index 100% rename from src/util/formattingUtil.js rename to electron/formattingUtil.js diff --git a/electron/hwidUtil.js b/electron/hwidUtil.js new file mode 100644 index 0000000..285ff88 --- /dev/null +++ b/electron/hwidUtil.js @@ -0,0 +1,32 @@ +const child_process = require("child_process"); +const options = { encoding: "ascii", windowsHide: true, timeout: 200 }; +const platforms = { + win32: [ + "REG QUERY HKLM\\SOFTWARE\\Microsoft\\Cryptography /v MachineGuid", + /MachineGuid\s+REG_SZ\s+(.*?)\s/, + ], + darwin: [ + "ioreg -rd1 -c IOPlatformExpertDevice", + /"IOPlatformUUID" = "(.*?)"/, + ], + linux: [ + "cat /var/lib/dbus/machine-id /etc/machine-id 2> /dev/null || true", + /^([\da-f]+)/, + ], +}; +const crypto = require("crypto"); + +/** + * Returns machine hardware id. + * Returns `undefined` if cannot determine. + * @return {string?} + */ +function getHwId() { + const getter = platforms[process.platform]; + if (!getter) return; + const result = getter[1].exec(child_process.execSync(getter[0], options)); + if (!result) return; + return crypto.createHash("md5").update(result[1]).digest("hex") || + undefined; +} +exports.getHwId = getHwId; diff --git a/src/util/osuUtil.js b/electron/osuUtil.js similarity index 77% rename from src/util/osuUtil.js rename to electron/osuUtil.js index 2d1d94c..ea25d56 100644 --- a/src/util/osuUtil.js +++ b/electron/osuUtil.js @@ -3,7 +3,7 @@ const path = require("path"); const crypto = require("crypto"); const EventEmitter = require("events"); const { default: axios } = require("axios"); -const { runFile } = require("./executeUtil"); +const { runFile } = require("./executeUtil.js"); const checkUpdateURL = "https://osu.ppy.sh/web/check-updates.php?action=check&stream="; @@ -38,22 +38,22 @@ const patcherFiles = [ { name: "patcher.exe", url_download: "https://ez-pp.farm/assets/patcher.exe", - url_hash: "https://ez-pp.farm/assets/patcher.md5" + url_hash: "https://ez-pp.farm/assets/patcher.md5", }, { name: "patch.hook.dll", url_download: "https://ez-pp.farm/assets/patch.hook.dll", - url_hash: "https://ez-pp.farm/assets/patch.hook.md5" - } -] + url_hash: "https://ez-pp.farm/assets/patch.hook.md5", + }, +]; const uiFiles = [ { name: "ezpp!ui.dll", url_download: "https://ez-pp.farm/assets/ezpp!ui.dll", - url_hash: "https://ez-pp.farm/assets/ezpp!ui.md5" - } -] + url_hash: "https://ez-pp.farm/assets/ezpp!ui.md5", + }, +]; async function isValidOsuFolder(path) { const allFiles = await fs.promises.readdir(path); @@ -175,13 +175,17 @@ async function getFilesThatNeedUpdate(osuPath, releaseStreamFiles) { const fileOnDisk = path.join(osuPath, fileName); if (fs.existsSync(fileOnDisk)) { if (ignoredOsuEntities.includes(fileName)) continue; - const fileHashOnDisk = crypto.createHash("md5").update(fs.readFileSync(fileOnDisk)).digest("hex"); - if (fileHashOnDisk.trim().toLowerCase() != fileHash.trim().toLowerCase()) { + const fileHashOnDisk = crypto.createHash("md5").update( + fs.readFileSync(fileOnDisk), + ).digest("hex"); + if ( + fileHashOnDisk.trim().toLowerCase() != fileHash.trim().toLowerCase() + ) { console.log({ fileOnDisk, fileHashOnDisk, - fileHash - }) + fileHash, + }); updateFiles.push(updatePatch); } } else updateFiles.push(updatePatch); @@ -207,7 +211,7 @@ function downloadUpdateFiles(osuPath, updateFiles) { fileName, loaded, total, - progress: Math.floor((loaded / total) * 100) + progress: Math.floor((loaded / total) * 100), }); }, }); @@ -216,20 +220,30 @@ function downloadUpdateFiles(osuPath, updateFiles) { fileName, loaded: fileSize, total: fileSize, - progress: 100 + progress: 100, }); - }) - await fs.promises.writeFile(path.join(osuPath, fileName), axiosDownloadWithProgress.data); + }); + try { + await fs.promises.writeFile( + path.join(osuPath, fileName), + axiosDownloadWithProgress.data, + ); + } catch (err) { + console.log(err); + eventEmitter.emit("error", { + fileName, + }); + } } // wait until all files are downloaded return true; - } + }; return { eventEmitter, startDownload, - } + }; } function runOsuWithDevServer(osuPath, serverDomain, onExit) { @@ -238,7 +252,6 @@ function runOsuWithDevServer(osuPath, serverDomain, onExit) { } async function getPatcherUpdates(osuPath) { - const filesToDownload = []; const patcherDir = path.join(osuPath, "EZPPLauncher"); @@ -246,9 +259,15 @@ async function getPatcherUpdates(osuPath) { for (const patcherFile of patcherFiles) { if (fs.existsSync(path.join(patcherDir, patcherFile.name))) { - const latestPatchFileHash = await (await fetch(patcherFile.url_hash)).text(); - const localPatchFileHash = crypto.createHash("md5").update(fs.readFileSync(path.join(patcherDir, patcherFile.name))).digest("hex"); - if (latestPatchFileHash.trim().toLowerCase() != localPatchFileHash.trim().toLowerCase()) filesToDownload.push(patcherFile); + const latestPatchFileHash = await (await fetch(patcherFile.url_hash)) + .text(); + const localPatchFileHash = crypto.createHash("md5").update( + fs.readFileSync(path.join(patcherDir, patcherFile.name)), + ).digest("hex"); + if ( + latestPatchFileHash.trim().toLowerCase() != + localPatchFileHash.trim().toLowerCase() + ) filesToDownload.push(patcherFile); } else filesToDownload.push(patcherFile); } @@ -259,7 +278,6 @@ function downloadPatcherUpdates(osuPath, patcherUpdates) { const eventEmitter = new EventEmitter(); const startDownload = async () => { - const patcherDir = path.join(osuPath, "EZPPLauncher"); if (!fs.existsSync(patcherDir)) fs.mkdirSync(patcherDir); @@ -274,23 +292,32 @@ function downloadPatcherUpdates(osuPath, patcherUpdates) { fileName, loaded, total, - progress: Math.floor((loaded / total) * 100) + progress: Math.floor((loaded / total) * 100), }); }, }); - await fs.promises.writeFile(path.join(osuPath, "EZPPLauncher", fileName), axiosDownloadWithProgress.data); + try { + await fs.promises.writeFile( + path.join(osuPath, "EZPPLauncher", fileName), + axiosDownloadWithProgress.data, + ); + } catch (err) { + console.log(err); + eventEmitter.emit("error", { + fileName, + }); + } } - } + }; return { eventEmitter, startDownload, - } + }; } async function getUIFiles(osuPath) { - const filesToDownload = []; const ezppLauncherDir = path.join(osuPath, "EZPPLauncher"); @@ -299,8 +326,13 @@ async function getUIFiles(osuPath) { for (const uiFile of uiFiles) { if (fs.existsSync(path.join(ezppLauncherDir, uiFile.name))) { const latestPatchFileHash = await (await fetch(uiFile.url_hash)).text(); - const localPatchFileHash = crypto.createHash("md5").update(fs.readFileSync(path.join(ezppLauncherDir, uiFile.name))).digest("hex"); - if (latestPatchFileHash.trim().toLowerCase() != localPatchFileHash.trim().toLowerCase()) filesToDownload.push(uiFile); + const localPatchFileHash = crypto.createHash("md5").update( + fs.readFileSync(path.join(ezppLauncherDir, uiFile.name)), + ).digest("hex"); + if ( + latestPatchFileHash.trim().toLowerCase() != + localPatchFileHash.trim().toLowerCase() + ) filesToDownload.push(uiFile); } else filesToDownload.push(uiFile); } @@ -311,7 +343,6 @@ function downloadUIFiles(osuPath, uiFiles) { const eventEmitter = new EventEmitter(); const startDownload = async () => { - const ezpplauncherDir = path.join(osuPath, "EZPPLauncher"); if (!fs.existsSync(ezpplauncherDir)) fs.mkdirSync(ezpplauncherDir); @@ -326,33 +357,61 @@ function downloadUIFiles(osuPath, uiFiles) { fileName, loaded, total, - progress: Math.floor((loaded / total) * 100) + progress: Math.floor((loaded / total) * 100), }); }, }); - - await fs.promises.writeFile(path.join(osuPath, "EZPPLauncher", fileName), axiosDownloadWithProgress.data); + try { + await fs.promises.writeFile( + path.join(osuPath, "EZPPLauncher", fileName), + axiosDownloadWithProgress.data, + ); + } catch (err) { + console.log(err); + eventEmitter.emit("error", { + fileName, + }); + } } - } + }; return { eventEmitter, startDownload, - } + }; } async function replaceUIFile(osuPath, revert) { if (!revert) { const ezppUIFile = path.join(osuPath, "EZPPLauncher", "ezpp!ui.dll"); const oldOsuUIFile = path.join(osuPath, "osu!ui.dll"); - await fs.promises.rename(oldOsuUIFile, path.join(osuPath, "osu!ui.dll.bak")); + await fs.promises.rename( + oldOsuUIFile, + path.join(osuPath, "osu!ui.dll.bak"), + ); await fs.promises.rename(ezppUIFile, oldOsuUIFile); } else { const oldOsuUIFile = path.join(osuPath, "osu!ui.dll"); const ezppUIFile = path.join(osuPath, "EZPPLauncher", "ezpp!ui.dll"); await fs.promises.rename(oldOsuUIFile, ezppUIFile); - await fs.promises.rename(path.join(osuPath, "osu!ui.dll.bak"), oldOsuUIFile); + await fs.promises.rename( + path.join(osuPath, "osu!ui.dll.bak"), + oldOsuUIFile, + ); } } -module.exports = { isValidOsuFolder, getUserConfig, getGlobalConfig, getUpdateFiles, getFilesThatNeedUpdate, downloadUpdateFiles, runOsuWithDevServer, getPatcherUpdates, downloadPatcherUpdates, downloadUIFiles, getUIFiles, replaceUIFile }; +module.exports = { + isValidOsuFolder, + getUserConfig, + getGlobalConfig, + getUpdateFiles, + getFilesThatNeedUpdate, + downloadUpdateFiles, + runOsuWithDevServer, + getPatcherUpdates, + downloadPatcherUpdates, + downloadUIFiles, + getUIFiles, + replaceUIFile, +}; diff --git a/electron/richPresence.js b/electron/richPresence.js new file mode 100644 index 0000000..976c5f8 --- /dev/null +++ b/electron/richPresence.js @@ -0,0 +1,55 @@ +const DiscordRPC = require("discord-auto-rpc"); +const { appName, appVersion } = require("./appInfo.js"); + +const clientId = "1032772293220384808"; +let richPresence; + +let currentStatus = { + details: " ", + state: "Idle in Launcher...", + startTimestamp: new Date(), + largeImageKey: "ezppfarm", + largeImageText: `${appName} ${appVersion}`, + smallImageKey: " ", + smallImageText: " ", + buttons: [ + { + label: "Download the Launcher", + url: "https://git.ez-pp.farm/EZPPFarm/EZPPLauncher/releases/latest", + }, + { + label: "Join EZPPFarm", + url: "https://ez-pp.farm/discord", + }, + ], + instance: false, +}; + +module.exports = { + connect: () => { + if (!richPresence) { + richPresence = new DiscordRPC.AutoClient({ transport: "ipc" }); + richPresence.endlessLogin({ clientId }); + richPresence.once("ready", () => { + setInterval(() => { + richPresence.setActivity(currentStatus); + }, 2500); + }); + } + }, + disconnect: async () => { + if (richPresence) { + await richPresence.clearActivity(); + await richPresence.destroy(); + richPresence = null; + } + }, + updateStatus: ({ state, details }) => { + currentStatus.state = state ?? " "; + currentStatus.details = details ?? " "; + }, + updateVersion: (osuVersion) => { + currentStatus.smallImageKey = osuVersion ? "osu" : " "; + currentStatus.smallImageText = osuVersion ? `osu! ${osuVersion}` : " "; + }, +}; diff --git a/main.js b/main.js index 32af188..9aefa89 100644 --- a/main.js +++ b/main.js @@ -3,16 +3,31 @@ const { app, BrowserWindow, Menu, ipcMain, dialog } = require("electron"); const path = require("path"); const serve = require("electron-serve"); const loadURL = serve({ directory: "public" }); -const config = require("./src/config/config"); +const config = require("./electron/config"); const { setupTitlebar, attachTitlebarToWindow } = require( "custom-electron-titlebar/main", ); -const { isValidOsuFolder, getUpdateFiles, getGlobalConfig, getFilesThatNeedUpdate, downloadUpdateFiles, getUserConfig, runOsuWithDevServer, getPatcherUpdates, downloadPatcherUpdates, getUIFiles, downloadUIFiles, replaceUIFile } = require("./src/util/osuUtil"); -const { formatBytes } = require("./src/util/formattingUtil"); +const { + isValidOsuFolder, + getUpdateFiles, + getGlobalConfig, + getFilesThatNeedUpdate, + downloadUpdateFiles, + getUserConfig, + runOsuWithDevServer, + getPatcherUpdates, + downloadPatcherUpdates, + getUIFiles, + downloadUIFiles, + replaceUIFile, +} = require("./electron/osuUtil"); +const { formatBytes } = require("./electron/formattingUtil"); const windowName = require("get-window-by-name"); const { existsSync } = require("fs"); -const { runFileDetached } = require("./src/util/executeUtil"); -const richPresence = require("./src/discord/richPresence"); +const { runFileDetached } = require("./electron/executeUtil"); +const richPresence = require("./electron/richPresence"); +const cryptUtil = require("./electron/cryptoUtil"); +const { getHwId } = require("./electron/hwidUtil"); // Keep a global reference of the window object, if you don't, the window will // be closed automatically when the JavaScript object is garbage collected. @@ -40,7 +55,11 @@ function startOsuStatus() { if (!osuLoaded) { osuLoaded = true; setTimeout(() => { - const patcherExecuteable = path.join(userOsuPath, "EZPPLauncher", "patcher.exe"); + const patcherExecuteable = path.join( + userOsuPath, + "EZPPLauncher", + "patcher.exe", + ); if (existsSync(patcherExecuteable)) { runFileDetached(userOsuPath, patcherExecuteable); } @@ -53,17 +72,17 @@ function startOsuStatus() { if (!windowTitle.includes("-")) { richPresence.updateStatus({ details: undefined, - state: "Idle..." - }) + state: "Idle...", + }); } else { const components = windowTitle.split(" - "); - const splitTitle = [components.shift(), components.join(" - ")] + const splitTitle = [components.shift(), components.join(" - ")]; const currentMap = splitTitle[1]; if (!currentMap.endsWith(".osu")) { richPresence.updateStatus({ state: "Playing...", - details: currentMap - }) + details: currentMap, + }); } } } @@ -76,6 +95,7 @@ function stopOsuStatus() { function registerIPCPipes() { ipcMain.handle("ezpplauncher:login", async (e, args) => { + const hwid = getHwId(); const timeout = new AbortController(); const timeoutId = setTimeout(() => timeout.abort(), 8000); try { @@ -98,7 +118,7 @@ function registerIPCPipes() { if ("user" in result) { if (args.saveCredentials) { config.set("username", args.username); - config.set("password", args.password); + config.set("password", cryptUtil.encrypt(args.password, hwid)); } currentUser = args; config.remove("guest"); @@ -118,8 +138,9 @@ function registerIPCPipes() { }); ipcMain.handle("ezpplauncher:autologin", async (e) => { + const hwid = getHwId(); const username = config.get("username"); - const password = config.get("password"); + const password = cryptUtil.decrypt(config.get("password"), hwid); const guest = config.get("guest"); if (guest) return { code: 200, message: "Login as guest", guest: true }; if (username == undefined || password == undefined) { @@ -175,7 +196,7 @@ function registerIPCPipes() { config.remove("username"); config.remove("password"); config.remove("guest"); - currentUser = undefined + currentUser = undefined; return true; }); @@ -240,33 +261,65 @@ function registerIPCPipes() { const updateFiles = await getFilesThatNeedUpdate(osuPath, latestFiles); if (uiFiles.length > 0) { const uiDownloader = downloadUIFiles(osuPath, uiFiles); + let errored = false; + uiDownloader.eventEmitter.on("error", (data) => { + const filename = data.fileName; + errored = true; + mainWindow.webContents.send("ezpplauncher:alert", { + type: "error", + message: + `Failed to download/replace ${filename}!\nMaybe try to rerun the Launcher as Admin.`, + }); + }); uiDownloader.eventEmitter.on("data", (data) => { mainWindow.webContents.send("ezpplauncher:launchprogress", { progress: Math.ceil(data.progress), }); mainWindow.webContents.send("ezpplauncher:launchstatus", { - status: `Downloading ${data.fileName}(${formatBytes(data.loaded)}/${formatBytes(data.total)})...`, + status: `Downloading ${data.fileName}(${formatBytes(data.loaded)}/${ + formatBytes(data.total) + })...`, }); }); await uiDownloader.startDownload(); mainWindow.webContents.send("ezpplauncher:launchprogress", { progress: -1, }); + if (errored) { + mainWindow.webContents.send("ezpplauncher:launchabort"); + return; + } } if (updateFiles.length > 0) { const updateDownloader = downloadUpdateFiles(osuPath, updateFiles); + let errored = false; + updateDownloader.eventEmitter.on("error", (data) => { + const filename = data.fileName; + errored = true; + mainWindow.webContents.send("ezpplauncher:alert", { + type: "error", + message: + `Failed to download/replace ${filename}!\nMaybe try to rerun the Launcher as Admin.`, + }); + }); updateDownloader.eventEmitter.on("data", (data) => { mainWindow.webContents.send("ezpplauncher:launchprogress", { progress: Math.ceil(data.progress), }); mainWindow.webContents.send("ezpplauncher:launchstatus", { - status: `Downloading ${data.fileName}(${formatBytes(data.loaded)}/${formatBytes(data.total)})...`, + status: `Downloading ${data.fileName}(${formatBytes(data.loaded)}/${ + formatBytes(data.total) + })...`, }); }); await updateDownloader.startDownload(); mainWindow.webContents.send("ezpplauncher:launchprogress", { progress: -1, }); + if (errored) { + mainWindow.webContents.send("ezpplauncher:launchabort"); + return; + } mainWindow.webContents.send("ezpplauncher:launchstatus", { status: "osu! is now up to date!", }); @@ -286,18 +339,34 @@ function registerIPCPipes() { const patchFiles = await getPatcherUpdates(osuPath); if (patchFiles.length > 0) { const patcherDownloader = downloadPatcherUpdates(osuPath, patchFiles); + let errored = false; + patcherDownloader.eventEmitter.on("error", (data) => { + const filename = data.fileName; + errored = true; + mainWindow.webContents.send("ezpplauncher:alert", { + type: "error", + message: + `Failed to download/replace ${filename}!\nMaybe try to rerun the Launcher as Admin.`, + }); + }); patcherDownloader.eventEmitter.on("data", (data) => { mainWindow.webContents.send("ezpplauncher:launchprogress", { progress: Math.ceil(data.progress), }); mainWindow.webContents.send("ezpplauncher:launchstatus", { - status: `Downloading ${data.fileName}(${formatBytes(data.loaded)}/${formatBytes(data.total)})...`, + status: `Downloading ${data.fileName}(${formatBytes(data.loaded)}/${ + formatBytes(data.total) + })...`, }); }); await patcherDownloader.startDownload(); mainWindow.webContents.send("ezpplauncher:launchprogress", { progress: -1, - }) + }); + if (errored) { + mainWindow.webContents.send("ezpplauncher:launchabort"); + return; + } mainWindow.webContents.send("ezpplauncher:launchstatus", { status: "Patcher is now up to date!", }); @@ -330,8 +399,8 @@ function registerIPCPipes() { richPresence.updateVersion(); richPresence.updateStatus({ state: "Idle in Launcher...", - details: undefined - }) + details: undefined, + }); mainWindow.webContents.send("ezpplauncher:launchstatus", { status: "Waiting for cleanup...", }); @@ -340,13 +409,12 @@ function registerIPCPipes() { await replaceUIFile(osuPath, true); mainWindow.webContents.send("ezpplauncher:launchabort"); }, 5000); - } + }; await replaceUIFile(osuPath, false); runOsuWithDevServer(osuPath, "ez-pp.farm", onExitHook); mainWindow.hide(); startOsuStatus(); - /* mainWindow.webContents.send("ezpplauncher:launchprogress", { progress: 0, }); diff --git a/package-lock.json b/package-lock.json index e44ad7e..a74f0f8 100644 --- a/package-lock.json +++ b/package-lock.json @@ -13,11 +13,13 @@ "axios": "^1.6.5", "better-sqlite3": "^9.2.2", "crypto": "^1.0.1", + "crypto-js": "^4.2.0", "custom-electron-titlebar": "^4.2.7", "discord-auto-rpc": "^1.0.17", "electron-serve": "^1.1.0", "get-window-by-name": "^2.0.0", - "svelte-french-toast": "^1.2.0" + "svelte-french-toast": "^1.2.0", + "systeminformation": "^5.21.22" }, "devDependencies": { "@electron/rebuild": "^3.5.0", @@ -3071,6 +3073,11 @@ "integrity": "sha512-VxBKmeNcqQdiUQUW2Tzq0t377b54N2bMtXO/qiLa+6eRRmmC4qT3D4OnTGoT/U6O9aklQ/jTwbOtRMTTY8G0Ig==", "deprecated": "This package is no longer supported. It's now a built-in Node module. If you've depended on crypto, you should switch to the one that's built-in." }, + "node_modules/crypto-js": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/crypto-js/-/crypto-js-4.2.0.tgz", + "integrity": "sha512-KALDyEYgpY+Rlob/iriUtjV6d5Eq+Y191A5g4UqLAi8CyGP9N1+FdVbkc1SxKc2r4YAYqG8JzO2KGL+AizD70Q==" + }, "node_modules/css-declaration-sorter": { "version": "6.4.1", "resolved": "https://registry.npmjs.org/css-declaration-sorter/-/css-declaration-sorter-6.4.1.tgz", @@ -8521,6 +8528,31 @@ "integrity": "sha512-dn6wd0uw5GsdswPFfsgMp5NSB0/aDe6fK94YJV/AJDYXL6HVLWBsxeq7js7Ad+mU2K9LAlwpk6kN2D5mwCPVow==", "dev": true }, + "node_modules/systeminformation": { + "version": "5.21.22", + "resolved": "https://registry.npmjs.org/systeminformation/-/systeminformation-5.21.22.tgz", + "integrity": "sha512-gNHloAJSyS+sKWkwvmvozZ1eHrdVTEsynWMTY6lvLGBB70gflkBQFw8drXXr1oEXY84+Vr9tOOrN8xHZLJSycA==", + "os": [ + "darwin", + "linux", + "win32", + "freebsd", + "openbsd", + "netbsd", + "sunos", + "android" + ], + "bin": { + "systeminformation": "lib/cli.js" + }, + "engines": { + "node": ">=8.0.0" + }, + "funding": { + "type": "Buy me a coffee", + "url": "https://www.buymeacoffee.com/systeminfo" + } + }, "node_modules/tailwind-merge": { "version": "2.2.0", "resolved": "https://registry.npmjs.org/tailwind-merge/-/tailwind-merge-2.2.0.tgz", diff --git a/package.json b/package.json index f2c13a1..7fe31fa 100644 --- a/package.json +++ b/package.json @@ -12,9 +12,12 @@ "files": [ "public/**/*", "main.js", - "preload.js" + "preload.js", + "electron/*", + "electron/**/*" ], "win": { + "requestedExecutionLevel": "requireAdministrator", "target": [ "portable" ] @@ -29,7 +32,6 @@ "start": "sirv public --no-clear", "electron": "wait-on http://localhost:8080 && electron .", "electron-dev": "concurrently \"yarn run dev\" \"yarn run electron\"", - "preelectron-pack": "yarn run build", "electron-pack": "electron-builder", "check": "svelte-check --tsconfig ./tsconfig.json" }, @@ -38,11 +40,13 @@ "axios": "^1.6.5", "better-sqlite3": "^9.2.2", "crypto": "^1.0.1", + "crypto-js": "^4.2.0", "custom-electron-titlebar": "^4.2.7", "discord-auto-rpc": "^1.0.17", "electron-serve": "^1.1.0", "get-window-by-name": "^2.0.0", - "svelte-french-toast": "^1.2.0" + "svelte-french-toast": "^1.2.0", + "systeminformation": "^5.21.22" }, "devDependencies": { "@electron/rebuild": "^3.5.0", diff --git a/src/App.svelte b/src/App.svelte index 7c60e2b..5613628 100644 --- a/src/App.svelte +++ b/src/App.svelte @@ -67,7 +67,7 @@ position: "bottom-center", className: "dark:!bg-gray-800 border-1 dark:!border-gray-700 dark:!text-gray-100", - duration: 1500, + duration: 2000, }); break; } @@ -76,7 +76,7 @@ position: "bottom-center", className: "dark:!bg-gray-800 border-1 dark:!border-gray-700 dark:!text-gray-100", - duration: 1500, + duration: 4000, }); break; } @@ -167,11 +167,3 @@ {:else} {/if} - - diff --git a/src/discord/richPresence.js b/src/discord/richPresence.js deleted file mode 100644 index 642c15b..0000000 --- a/src/discord/richPresence.js +++ /dev/null @@ -1,56 +0,0 @@ -const DiscordRPC = require("discord-auto-rpc"); -const { appName, appVersion } = require("../../appInfo"); - -const clientId = "1032772293220384808"; -let richPresence; - -let currentStatus = { - details: " ", - state: "Idle in Launcher...", - startTimestamp: new Date(), - largeImageKey: "ezppfarm", - largeImageText: `${appName} ${appVersion}`, - smallImageKey: " ", - smallImageText: " ", - buttons: [ - { - label: "Download the Launcher", - url: "https://git.ez-pp.farm/EZPPFarm/EZPPLauncher/releases/latest" - }, - { - label: "Join EZPPFarm", - url: "https://ez-pp.farm/discord" - } - ], - instance: false - -} - -module.exports = { - connect: () => { - if (!richPresence) { - richPresence = new DiscordRPC.AutoClient({ transport: "ipc" }); - richPresence.endlessLogin({ clientId }); - richPresence.once("ready", () => { - setInterval(() => { - richPresence.setActivity(currentStatus); - }, 2500) - }); - } - }, - disconnect: async () => { - if (richPresence) { - await richPresence.clearActivity(); - await richPresence.destroy(); - richPresence = null; - } - }, - updateStatus: ({ state, details }) => { - currentStatus.state = state ?? " "; - currentStatus.details = details ?? " "; - }, - updateVersion: (osuVersion) => { - currentStatus.smallImageKey = osuVersion ? "osu" : " "; - currentStatus.smallImageText = osuVersion ? `osu! ${osuVersion}` : " "; - } -} \ No newline at end of file diff --git a/tests/fileHash.js b/tests/fileHash.js deleted file mode 100644 index f2ba454..0000000 --- a/tests/fileHash.js +++ /dev/null @@ -1,14 +0,0 @@ -const fs = require("fs"); -const crypto = require("crypto"); - -(async () => { - const correctHash = 'b66478cc0f9ec50810489a039ced642b'; - const filePath = 'C:\\Users\\horiz\\AppData\\Local\\osu!\\avcodec-51.dll'; - const fileHash = crypto.createHash('md5').update(await fs.promises.readFile(filePath)).digest('hex'); - - console.log({ - correctHash, - fileHash, - matching: correctHash === fileHash, - }) -})(); \ No newline at end of file diff --git a/tests/osuConfig.js b/tests/osuConfig.js deleted file mode 100644 index 7365164..0000000 --- a/tests/osuConfig.js +++ /dev/null @@ -1,9 +0,0 @@ -const { getGlobalConfig } = require("../src/util/osuUtil"); -const config = require("../src/config/config"); -(async () => { - const osuPath = config.get("osuPath"); - const globalConfig = getGlobalConfig(osuPath); - - const globalConfigContent = await globalConfig.get("_ReleaseStream"); - console.log(globalConfigContent); -})(); \ No newline at end of file diff --git a/tests/osuUpdate.js b/tests/osuUpdate.js deleted file mode 100644 index 017b2a5..0000000 --- a/tests/osuUpdate.js +++ /dev/null @@ -1,7 +0,0 @@ -const { getUpdateFiles } = require("../src/util/osuUtil"); - -(async () => { - const osuPath = ""; - const latestFiles = await getUpdateFiles("stable40"); - console.log(latestFiles); -})(); diff --git a/tsconfig.json b/tsconfig.json index 5263aed..8c8fe1f 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,7 +1,16 @@ { "extends": "./node_modules/@tsconfig/svelte/tsconfig.json", - "include": ["src/**/*"], + "include": [ + "src/**/*", + "electron/richPresence.js", + "electron/config.js", + "electron/cryptoUtil.js", + "electron/executeUtil.js", + "electron/formattingUtil.js", + "electron/hwidUtil.js", + "electron/osuUtil.js" + ], "exclude": ["node_modules/*", "__sapper__/*", "public/*"], "compilerOptions": { "typeRoots": [ From e119166c659e00473ab544ccd2338edeaa499ae9 Mon Sep 17 00:00:00 2001 From: HorizonCode Date: Thu, 18 Jan 2024 12:47:14 +0100 Subject: [PATCH 2/6] add animations to header --- src/App.svelte | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/App.svelte b/src/App.svelte index 5613628..c7ff793 100644 --- a/src/App.svelte +++ b/src/App.svelte @@ -96,14 +96,16 @@
-
+
EZPPFarm Logo EZPPLauncher
{#if $currentPage == Page.Launch} -
+
Date: Thu, 18 Jan 2024 12:47:52 +0100 Subject: [PATCH 3/6] re-add pre scripts for deploy --- package.json | 2 ++ 1 file changed, 2 insertions(+) diff --git a/package.json b/package.json index 7fe31fa..987577c 100644 --- a/package.json +++ b/package.json @@ -32,7 +32,9 @@ "start": "sirv public --no-clear", "electron": "wait-on http://localhost:8080 && electron .", "electron-dev": "concurrently \"yarn run dev\" \"yarn run electron\"", + "preelectron-pack": "yarn run build", "electron-pack": "electron-builder", + "postinstall": "electron-builder install-app-deps", "check": "svelte-check --tsconfig ./tsconfig.json" }, "dependencies": { From 05866946a3ea11bb8e19bbc28338d5643c5ec2f2 Mon Sep 17 00:00:00 2001 From: HorizonCode Date: Thu, 18 Jan 2024 12:52:06 +0100 Subject: [PATCH 4/6] do rebuild before packing --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 987577c..e77be14 100644 --- a/package.json +++ b/package.json @@ -32,7 +32,7 @@ "start": "sirv public --no-clear", "electron": "wait-on http://localhost:8080 && electron .", "electron-dev": "concurrently \"yarn run dev\" \"yarn run electron\"", - "preelectron-pack": "yarn run build", + "preelectron-pack": "electron-rebuild && yarn run build", "electron-pack": "electron-builder", "postinstall": "electron-builder install-app-deps", "check": "svelte-check --tsconfig ./tsconfig.json" From d5b2b8012ce79eca8675c7e129e2d713d52db733 Mon Sep 17 00:00:00 2001 From: HorizonCode Date: Thu, 18 Jan 2024 14:10:47 +0100 Subject: [PATCH 5/6] fix autologin toasts --- main.js | 11 +++ preload.js | 9 ++ rollup.config.js | 6 +- src/App.svelte | 6 ++ src/pages/Login.svelte | 190 ++++++++++++++++++++++++-------------- src/pages/Settings.svelte | 23 ++++- 6 files changed, 169 insertions(+), 76 deletions(-) diff --git a/main.js b/main.js index 9aefa89..3785a98 100644 --- a/main.js +++ b/main.js @@ -137,9 +137,18 @@ function registerIPCPipes() { } }); + ipcMain.handle("ezpplauncher:autologin-active", async (e) => { + const username = config.get("username"); + const password = config.get("password"); + return username != undefined && password != undefined; + }); + ipcMain.handle("ezpplauncher:autologin", async (e) => { const hwid = getHwId(); const username = config.get("username"); + if (username == undefined) { + return { code: 200, message: "No autologin" }; + } const password = cryptUtil.decrypt(config.get("password"), hwid); const guest = config.get("guest"); if (guest) return { code: 200, message: "Login as guest", guest: true }; @@ -172,6 +181,8 @@ function registerIPCPipes() { }; } return result; + } else { + config.remove("password"); } return { code: 500, diff --git a/preload.js b/preload.js index 7e15fd6..cde3f14 100644 --- a/preload.js +++ b/preload.js @@ -22,6 +22,15 @@ window.addEventListener("login-attempt", async (e) => { ); }); +window.addEventListener("autologin-active", async (e) => { + const autologin = await ipcRenderer.invoke( + "ezpplauncher:autologin-active", + ); + window.dispatchEvent( + new CustomEvent("autologin-result", { detail: autologin }), + ); +}); + window.addEventListener("autologin-attempt", async () => { const loginResult = await ipcRenderer.invoke("ezpplauncher:autologin"); window.dispatchEvent( diff --git a/rollup.config.js b/rollup.config.js index b722fa7..e1987ea 100644 --- a/rollup.config.js +++ b/rollup.config.js @@ -9,7 +9,6 @@ import image from "@rollup/plugin-image"; import sveltePreprocess from "svelte-preprocess"; import typescript from "@rollup/plugin-typescript"; import progress from "rollup-plugin-progress"; -import findUnused from "rollup-plugin-unused"; const production = !process.env.ROLLUP_WATCH; @@ -48,8 +47,7 @@ export default { file: "public/build/bundle.js", }, plugins: [ - findUnused(), - progress({ clearLine: true }), + !production && progress({ clearLine: true }), svelte({ preprocess: sveltePreprocess({ sourceMap: !production }), compilerOptions: { @@ -61,7 +59,7 @@ export default { // we'll extract any component CSS out into // a separate file - better for performance css({ output: "bundle.css" }), - postcss(), + postcss({ sourceMap: "inline" }), // If you have external dependencies installed from // npm, you'll most likely need these plugins. In diff --git a/src/App.svelte b/src/App.svelte index c7ff793..4e8d051 100644 --- a/src/App.svelte +++ b/src/App.svelte @@ -38,6 +38,12 @@ window.dispatchEvent(new CustomEvent("logout")); currentUser.set(undefined); currentPage.set(Page.Login); + toast.success("Successfully logged out!", { + position: "bottom-center", + className: + "dark:!bg-gray-800 border-1 dark:!border-gray-700 dark:!text-gray-100", + duration: 2000, + }); }; window.addEventListener("launchStatusUpdate", (e) => { diff --git a/src/pages/Login.svelte b/src/pages/Login.svelte index 47bcf62..2d849be 100644 --- a/src/pages/Login.svelte +++ b/src/pages/Login.svelte @@ -15,81 +15,117 @@ const processLogin = async () => { loading = true; - window.addEventListener( - "login-result", - (e) => { - const customEvent = e as CustomEvent; - const resultData = customEvent.detail; - const wasSuccessful = "user" in resultData; + const loginPromise = new Promise((res, rej) => { + window.addEventListener( + "login-result", + (e) => { + const customEvent = e as CustomEvent; + const resultData = customEvent.detail; + const wasSuccessful = "user" in resultData; - if (!wasSuccessful) { - const errorResult = resultData as Error; - toast.error(errorResult.message, { - position: "bottom-center", - className: - "dark:!bg-gray-800 border-1 dark:!border-gray-700 dark:!text-gray-100", - duration: 1500, - }); - loading = false; - return; - } - const userResult = resultData.user as User; - currentUser.set(userResult); - currentPage.set(Page.Launch); - toast.success(`Welcome back, ${userResult.name}!`, { - position: "bottom-center", - className: - "dark:!bg-gray-800 border-1 dark:!border-gray-700 dark:!text-gray-100", - duration: 3000, - }); - }, - { once: true } - ); - window.dispatchEvent( - new CustomEvent("login-attempt", { - detail: { username, password, saveCredentials }, - }) - ); - }; - - const tryAutoLogin = async () => { - loading = true; - await new Promise((res) => setTimeout(res, 1500)); - window.addEventListener( - "login-result", - (e) => { - const customEvent = e as CustomEvent; - const resultData = customEvent.detail; - const isGuest = "guest" in resultData; - const wasSuccessful = "user" in resultData; - if (isGuest) { + if (!wasSuccessful) { + /* const errorResult = resultData as Error; + toast.error(errorResult.message, { + position: "bottom-center", + className: + "dark:!bg-gray-800 border-1 dark:!border-gray-700 dark:!text-gray-100", + duration: 1500, + }); */ + rej(); + loading = false; + return; + } + const userResult = resultData.user as User; + currentUser.set(userResult); currentPage.set(Page.Launch); - toast.success(`Logged in as Guest`, { + res(); + toast.success(`Welcome back, ${userResult.name}!`, { position: "bottom-center", className: "dark:!bg-gray-800 border-1 dark:!border-gray-700 dark:!text-gray-100", duration: 3000, }); - return; - } - if (!wasSuccessful) { - loading = false; - return; - } - const userResult = resultData.user as User; - currentUser.set(userResult); - currentPage.set(Page.Launch); - toast.success(`Welcome back, ${userResult.name}!`, { - position: "bottom-center", - className: - "dark:!bg-gray-800 border-1 dark:!border-gray-700 dark:!text-gray-100", - duration: 3000, - }); - loading = false; + }, + { once: true } + ); + window.dispatchEvent( + new CustomEvent("login-attempt", { + detail: { username, password, saveCredentials }, + }) + ); + }); + toast.promise( + loginPromise, + { + loading: "Logging in...", + success: "Successfully logged in!", + error: "Failed to login.", }, - { once: true } + { + position: "bottom-center", + className: + "dark:!bg-gray-800 border-1 dark:!border-gray-700 dark:!text-gray-100", + duration: 3000, + } + ); + }; + + const tryAutoLogin = async () => { + loading = true; + const loginPromise = new Promise((res, rej) => { + window.addEventListener( + "login-result", + (e) => { + const customEvent = e as CustomEvent; + const resultData = customEvent.detail; + const isGuest = "guest" in resultData; + const wasSuccessful = "user" in resultData; + if (isGuest) { + currentPage.set(Page.Launch); + res(); + toast.success(`Logged in as Guest`, { + position: "bottom-center", + className: + "dark:!bg-gray-800 border-1 dark:!border-gray-700 dark:!text-gray-100", + duration: 3000, + }); + return; + } + if (!wasSuccessful) { + loading = false; + rej(); + return; + } + const userResult = resultData.user as User; + currentUser.set(userResult); + currentPage.set(Page.Launch); + res(); + toast.success(`Welcome back, ${userResult.name}!`, { + position: "bottom-center", + className: + "dark:!bg-gray-800 border-1 dark:!border-gray-700 dark:!text-gray-100", + duration: 3000, + }); + loading = false; + }, + { once: true } + ); + window.dispatchEvent(new CustomEvent("autologin-attempt")); + }); + toast.promise( + loginPromise, + { + loading: "Logging in...", + success: "Successfully logged in!", + error: "Failed to login.", + }, + { + position: "bottom-center", + className: + "dark:!bg-gray-800 border-1 dark:!border-gray-700 dark:!text-gray-100", + duration: 3000, + } ); - window.dispatchEvent(new CustomEvent("autologin-attempt")); }; const proceedAsGuest = () => { @@ -103,10 +139,24 @@ }); }; - if (!$startup) { - startup.set(true); - tryAutoLogin(); - } + const shouldAutologin = async () => { + const shouldAutologin = await new Promise((res) => { + window.addEventListener("autologin-result", (e) => { + const customEvent = e as CustomEvent; + const resultData = customEvent.detail; + res(resultData); + }); + window.dispatchEvent(new CustomEvent("autologin-active")); + }); + return shouldAutologin; + }; + + (async () => { + if (!$startup) { + startup.set(true); + if (await shouldAutologin()) tryAutoLogin(); + } + })();
- import { Button, ButtonGroup, Input } from "flowbite-svelte"; + import { Button, ButtonGroup, Input, Toggle } from "flowbite-svelte"; import { FolderSolid } from "flowbite-svelte-icons"; import { currentPage } from "../storage/localStore"; import { Page } from "../consts/pages"; let folderPath: string = ""; + let patching: boolean = true; + let presence: boolean = true; + window.addEventListener("settings-result", (e) => { const settings: Record[] = (e as CustomEvent).detail; const osuPath = settings.find((setting) => setting.key == "osuPath"); @@ -16,11 +19,27 @@ const setFolderPath = () => { window.dispatchEvent(new CustomEvent("folder-set")); }; + + const togglePatching = () => { + patching = !patching; + }; + + const togglePresence = () => { + presence = !presence; + };
+
+ Discord Presence + Patching +
From 94fa7e7bd82e5699053c2ab7e2b0cc27e114ce72 Mon Sep 17 00:00:00 2001 From: HorizonCode Date: Thu, 18 Jan 2024 16:32:57 +0100 Subject: [PATCH 6/6] fix autologin, add osu folder detection --- electron/osuUtil.js | 24 ++++++++++++++++ main.js | 23 ++++++++++++--- package-lock.json | 60 +++++++++++++++++++++++++++++++++++++++ package.json | 1 + preload.js | 7 +++++ public/index.html | 2 +- src/App.svelte | 13 +++++++++ src/app.pcss | 4 +++ src/pages/Login.svelte | 1 + src/pages/Settings.svelte | 38 ++++++++++++++++++------- tailwind.config.cjs | 7 ++++- 11 files changed, 163 insertions(+), 17 deletions(-) diff --git a/electron/osuUtil.js b/electron/osuUtil.js index ea25d56..962b2d2 100644 --- a/electron/osuUtil.js +++ b/electron/osuUtil.js @@ -401,6 +401,29 @@ async function replaceUIFile(osuPath, revert) { } } +async function findOsuInstallation() { + const regedit = require("regedit-rs"); + + const osuLocationFromDefaultIcon = + "HKLM\\SOFTWARE\\Classes\\osu\\DefaultIcon"; + const osuKey = regedit.listSync(osuLocationFromDefaultIcon); + if (osuKey[osuLocationFromDefaultIcon].exists) { + const key = osuKey[osuLocationFromDefaultIcon].values[""]; + let value = key.value; + value = value.substring(1, value.length - 3); + return path.dirname(value.trim()); + } + /* const osuStruct = await regedit.listValuesSync(osuLocationFromDefaultIcon); + for (const line of osuStruct.split("\n")) { + if (line.includes("REG_SZ")) { + let value = line.trim().split(" ")[2]; + value = value.substring(1, value.length - 3); + return path.dirname(value.trim()); + } + } */ + return undefined; +} + module.exports = { isValidOsuFolder, getUserConfig, @@ -414,4 +437,5 @@ module.exports = { downloadUIFiles, getUIFiles, replaceUIFile, + findOsuInstallation, }; diff --git a/main.js b/main.js index 3785a98..308b634 100644 --- a/main.js +++ b/main.js @@ -20,6 +20,7 @@ const { getUIFiles, downloadUIFiles, replaceUIFile, + findOsuInstallation, } = require("./electron/osuUtil"); const { formatBytes } = require("./electron/formattingUtil"); const windowName = require("get-window-by-name"); @@ -140,18 +141,20 @@ function registerIPCPipes() { ipcMain.handle("ezpplauncher:autologin-active", async (e) => { const username = config.get("username"); const password = config.get("password"); + const guest = config.get("guest"); + if (guest != undefined) return true; return username != undefined && password != undefined; }); ipcMain.handle("ezpplauncher:autologin", async (e) => { const hwid = getHwId(); const username = config.get("username"); + const guest = config.get("guest"); + if (guest) return { code: 200, message: "Login as guest", guest: true }; if (username == undefined) { return { code: 200, message: "No autologin" }; } const password = cryptUtil.decrypt(config.get("password"), hwid); - const guest = config.get("guest"); - if (guest) return { code: 200, message: "Login as guest", guest: true }; if (username == undefined || password == undefined) { return { code: 200, message: "No autologin" }; } @@ -215,6 +218,18 @@ function registerIPCPipes() { return config.all(); }); + ipcMain.handle("ezpplauncher:detect-folder", async (e) => { + const detected = await findOsuInstallation(); + if (detected && await isValidOsuFolder(detected)) { + mainWindow.webContents.send("ezpplauncher:alert", { + type: "success", + message: "osu! path successfully saved!", + }); + config.set("osuPath", detected); + } + return config.all(); + }); + ipcMain.handle("ezpplauncher:set-folder", async (e) => { const folderResult = await dialog.showOpenDialog({ title: "Select osu! installation directory", @@ -441,8 +456,8 @@ function createWindow() { // Create the browser window. mainWindow = new BrowserWindow({ - width: 600, - height: 380, + width: 550, + height: 350, resizable: false, frame: false, titleBarStyle: "hidden", diff --git a/package-lock.json b/package-lock.json index a74f0f8..595d3d3 100644 --- a/package-lock.json +++ b/package-lock.json @@ -7,6 +7,7 @@ "": { "name": "ezpplauncher-next", "version": "2.0.0", + "hasInstallScript": true, "license": "MIT", "dependencies": { "@types/better-sqlite3": "^7.6.8", @@ -18,6 +19,7 @@ "discord-auto-rpc": "^1.0.17", "electron-serve": "^1.1.0", "get-window-by-name": "^2.0.0", + "regedit-rs": "^1.0.2", "svelte-french-toast": "^1.2.0", "systeminformation": "^5.21.22" }, @@ -7051,6 +7053,64 @@ "node": ">=8.10.0" } }, + "node_modules/regedit-rs": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/regedit-rs/-/regedit-rs-1.0.2.tgz", + "integrity": "sha512-4vEgiZNO1FCG8z/Zx3v/6PU1+eZ+ELe6R0ca+VB96Vw+Mi3M0IVHAjtMFbl97lUSX11dJqpyousX/wY8QcI1lA==", + "engines": { + "node": ">= 10" + }, + "optionalDependencies": { + "regedit-rs-win32-arm64-msvc": "1.0.2", + "regedit-rs-win32-ia32-msvc": "1.0.2", + "regedit-rs-win32-x64-msvc": "1.0.2" + } + }, + "node_modules/regedit-rs-win32-arm64-msvc": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/regedit-rs-win32-arm64-msvc/-/regedit-rs-win32-arm64-msvc-1.0.2.tgz", + "integrity": "sha512-hM1sxazOJWKmiC9DM8QXW9Iqm50Mh/Y9G4/rRYQpWXjMzq7lTqjwVZRkAoBrHliFS6d1Lt4qkm5+Ybt6GkbDpw==", + "cpu": [ + "arm64" + ], + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">= 10" + } + }, + "node_modules/regedit-rs-win32-ia32-msvc": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/regedit-rs-win32-ia32-msvc/-/regedit-rs-win32-ia32-msvc-1.0.2.tgz", + "integrity": "sha512-FLINrCJ30wm6NYw7skQUDET8NP1N46kH77dqesCiU+/FjWzzPE5luZYY+j4uf+hKjPY6/MCj2CB9l9VdPhaBVQ==", + "cpu": [ + "ia32" + ], + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">= 10" + } + }, + "node_modules/regedit-rs-win32-x64-msvc": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/regedit-rs-win32-x64-msvc/-/regedit-rs-win32-x64-msvc-1.0.2.tgz", + "integrity": "sha512-ccCSyd5vWBKVWftBKLKzegqwwPMWcQtIW0ub66dCFFuv2s+x2EcZZWGdD9dVXX2Z6V9DU2JRPKgWUNjVPaj6Xg==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">= 10" + } + }, "node_modules/regenerator-runtime": { "version": "0.14.1", "resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.14.1.tgz", diff --git a/package.json b/package.json index e77be14..49e9a40 100644 --- a/package.json +++ b/package.json @@ -47,6 +47,7 @@ "discord-auto-rpc": "^1.0.17", "electron-serve": "^1.1.0", "get-window-by-name": "^2.0.0", + "regedit-rs": "^1.0.2", "svelte-french-toast": "^1.2.0", "systeminformation": "^5.21.22" }, diff --git a/preload.js b/preload.js index cde3f14..add59e5 100644 --- a/preload.js +++ b/preload.js @@ -57,6 +57,13 @@ window.addEventListener("settings-get", async () => { ); }); +window.addEventListener("folder-auto", async (e) => { + const result = await ipcRenderer.invoke("ezpplauncher:detect-folder"); + window.dispatchEvent( + new CustomEvent("settings-result", { detail: result }), + ); +}); + window.addEventListener("folder-set", async (e) => { const result = await ipcRenderer.invoke("ezpplauncher:set-folder"); window.dispatchEvent( diff --git a/public/index.html b/public/index.html index c6ad532..902395f 100644 --- a/public/index.html +++ b/public/index.html @@ -18,5 +18,5 @@ - + diff --git a/src/App.svelte b/src/App.svelte index 4e8d051..bcc4faf 100644 --- a/src/App.svelte +++ b/src/App.svelte @@ -5,8 +5,10 @@ DropdownItem, DropdownHeader, DropdownDivider, + Button, } from "flowbite-svelte"; import { + ArrowLeftSolid, ArrowRightFromBracketSolid, ArrowRightToBracketSolid, UserSettingsSolid, @@ -103,6 +105,17 @@
+ {#if $currentPage == Page.Settings} + + {/if} EZPPFarm Logo EZPPLauncher diff --git a/src/app.pcss b/src/app.pcss index 5e16355..6ede246 100644 --- a/src/app.pcss +++ b/src/app.pcss @@ -20,6 +20,10 @@ html .cet-titlebar .cet-control-icon svg { display: none; } +.cet-container { + overflow: hidden !important; +} + .indeterminate { background-image: repeating-linear-gradient( 90deg, diff --git a/src/pages/Login.svelte b/src/pages/Login.svelte index 2d849be..8545a8d 100644 --- a/src/pages/Login.svelte +++ b/src/pages/Login.svelte @@ -80,6 +80,7 @@ const resultData = customEvent.detail; const isGuest = "guest" in resultData; const wasSuccessful = "user" in resultData; + console.log(resultData); if (isGuest) { currentPage.set(Page.Launch); res(); diff --git a/src/pages/Settings.svelte b/src/pages/Settings.svelte index f7f2186..389917f 100644 --- a/src/pages/Settings.svelte +++ b/src/pages/Settings.svelte @@ -1,6 +1,13 @@