add util method to detect osu folder, still needs to be tested on different systems.

This commit is contained in:
HorizonCode 2022-10-27 16:28:22 +02:00
parent 84c13331d2
commit 337a8af68f
3 changed files with 25 additions and 1 deletions

8
app.js
View File

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

View File

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

View File

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