diff --git a/electron/netUtils.js b/electron/netUtils.js new file mode 100644 index 0000000..a1a14df --- /dev/null +++ b/electron/netUtils.js @@ -0,0 +1,20 @@ +const { exec } = require("child_process"); + +async function isNet8Installed() { + return new Promise((resolve, reject) => { + exec("dotnet --version", (error, stdout, stderr) => { + if (error) { + resolve(false); + return; + } + if (stderr) { + resolve(false); + return; + } + const version = stdout.trim(); + resolve(version.startsWith("8.")); + }) + }); +} + +module.exports = { isNet8Installed }; \ No newline at end of file diff --git a/main.js b/main.js index fd630ca..94364d2 100644 --- a/main.js +++ b/main.js @@ -37,6 +37,7 @@ const { appName, appVersion } = require("./electron/appInfo"); const { updateAvailable, releasesUrl } = require("./electron/updateCheck"); const fkill = require("fkill"); const { checkImageExists } = require("./electron/imageUtil"); +const { isNet8Installed } = require("./electron/netUtils"); // 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. @@ -209,6 +210,10 @@ function stopOsuStatus() { } function registerIPCPipes() { + (async () => { + const isNet8 = await isNet8Installed(); + console.log("net8:", isNet8); + })(); ipcMain.handle("ezpplauncher:login", async (e, args) => { const hwid = getHwId(); const timeout = new AbortController(); @@ -415,6 +420,17 @@ function registerIPCPipes() { }); return; } + if (patch) { + if (!(await isNet8Installed())) { + mainWindow.webContents.send("ezpplauncher:launchabort"); + mainWindow.webContents.send("ezpplauncher:alert", { + type: "error", + message: ".NET 8 is not installed.", + }); + //open .net 8 download in browser + shell.openExternal('https://dotnet.microsoft.com/en-us/download/dotnet/thank-you/runtime-desktop-8.0.4-windows-x64-installer'); + } + } mainWindow.webContents.send("ezpplauncher:launchstatus", { status: "Checking for osu! updates...", });