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 @@