diff --git a/app.js b/app.js index c95d893..32bd079 100644 --- a/app.js +++ b/app.js @@ -147,6 +147,12 @@ const run = () => { message: "Seems like you are missing the wmctrl package, please install it for the RPC to work!" }); } else linuxWMCtrlFound = true; + } else { + const osuFolder = await config.get("osuPath"); + if (!osuFolder || osuFolder == "") { + const foundFolder = await osuUtil.findOsuInstallation(); + console.log("osu! Installation located at: ",foundFolder); + } } }) app.on('activate', function () { @@ -171,8 +177,10 @@ const run = () => { } rpc.updateState("Launching osu!..."); isIngame = true; + mainWindow.hide(); const result = await osuUtil.startOsuWithDevServer(tempOsuPath, "ez-pp.farm", async () => { isIngame = false; + mainWindow.show(); await doUpdateCheck(mainWindow); }); return result; diff --git a/osuUtil.js b/osuUtil.js index 83efc58..f3dc1f3 100644 --- a/osuUtil.js +++ b/osuUtil.js @@ -171,8 +171,23 @@ async function setConfigValue(configPath, key, value) { } await fs.promises.writeFile(configPath, configLines.join("\n"), 'utf-8'); } +async function findOsuInstallation() { + const regedit = require('qiao-regedit'); + + const osuLocationFromDefaultIcon = "HKLM\\SOFTWARE\\Classes\\osu\\DefaultIcon"; + 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 value.trim(); + } + } + return undefined; +} module.exports = { isValidOsuFolder, getLatestConfig, getUpdateFiles, filesThatNeedUpdate, - downloadUpdateFiles, startOsuWithDevServer: startWithDevServer, setConfigValue + downloadUpdateFiles, startOsuWithDevServer: startWithDevServer, setConfigValue, + findOsuInstallation } \ No newline at end of file diff --git a/package.json b/package.json index 57a75aa..1eba78e 100644 --- a/package.json +++ b/package.json @@ -54,6 +54,7 @@ "get-window-by-name": "^2.0.0", "jquery": "^3.6.0", "node-downloader-helper": "^2.1.4", + "qiao-regedit": "^0.1.5", "sweetalert2": "^11.5.2" } }