This commit is contained in:
HorizonCode 2024-01-18 18:14:57 +01:00
commit ae566f09a0
23 changed files with 676 additions and 201 deletions

11
electron/cryptoUtil.js Normal file
View File

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

32
electron/hwidUtil.js Normal file
View File

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

View File

@ -3,7 +3,7 @@ const path = require("path");
const crypto = require("crypto"); const crypto = require("crypto");
const EventEmitter = require("events"); const EventEmitter = require("events");
const { default: axios } = require("axios"); const { default: axios } = require("axios");
const { runFile } = require("./executeUtil"); const { runFile } = require("./executeUtil.js");
const checkUpdateURL = const checkUpdateURL =
"https://osu.ppy.sh/web/check-updates.php?action=check&stream="; "https://osu.ppy.sh/web/check-updates.php?action=check&stream=";
@ -38,22 +38,22 @@ const patcherFiles = [
{ {
name: "patcher.exe", name: "patcher.exe",
url_download: "https://ez-pp.farm/assets/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", name: "patch.hook.dll",
url_download: "https://ez-pp.farm/assets/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 = [ const uiFiles = [
{ {
name: "ezpp!ui.dll", name: "ezpp!ui.dll",
url_download: "https://ez-pp.farm/assets/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) { async function isValidOsuFolder(path) {
const allFiles = await fs.promises.readdir(path); const allFiles = await fs.promises.readdir(path);
@ -175,13 +175,17 @@ async function getFilesThatNeedUpdate(osuPath, releaseStreamFiles) {
const fileOnDisk = path.join(osuPath, fileName); const fileOnDisk = path.join(osuPath, fileName);
if (fs.existsSync(fileOnDisk)) { if (fs.existsSync(fileOnDisk)) {
if (ignoredOsuEntities.includes(fileName)) continue; if (ignoredOsuEntities.includes(fileName)) continue;
const fileHashOnDisk = crypto.createHash("md5").update(fs.readFileSync(fileOnDisk)).digest("hex"); const fileHashOnDisk = crypto.createHash("md5").update(
if (fileHashOnDisk.trim().toLowerCase() != fileHash.trim().toLowerCase()) { fs.readFileSync(fileOnDisk),
).digest("hex");
if (
fileHashOnDisk.trim().toLowerCase() != fileHash.trim().toLowerCase()
) {
console.log({ console.log({
fileOnDisk, fileOnDisk,
fileHashOnDisk, fileHashOnDisk,
fileHash fileHash,
}) });
updateFiles.push(updatePatch); updateFiles.push(updatePatch);
} }
} else updateFiles.push(updatePatch); } else updateFiles.push(updatePatch);
@ -207,7 +211,7 @@ function downloadUpdateFiles(osuPath, updateFiles) {
fileName, fileName,
loaded, loaded,
total, total,
progress: Math.floor((loaded / total) * 100) progress: Math.floor((loaded / total) * 100),
}); });
}, },
}); });
@ -216,20 +220,30 @@ function downloadUpdateFiles(osuPath, updateFiles) {
fileName, fileName,
loaded: fileSize, loaded: fileSize,
total: 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 // wait until all files are downloaded
return true; return true;
} };
return { return {
eventEmitter, eventEmitter,
startDownload, startDownload,
} };
} }
function runOsuWithDevServer(osuPath, serverDomain, onExit) { function runOsuWithDevServer(osuPath, serverDomain, onExit) {
@ -238,7 +252,6 @@ function runOsuWithDevServer(osuPath, serverDomain, onExit) {
} }
async function getPatcherUpdates(osuPath) { async function getPatcherUpdates(osuPath) {
const filesToDownload = []; const filesToDownload = [];
const patcherDir = path.join(osuPath, "EZPPLauncher"); const patcherDir = path.join(osuPath, "EZPPLauncher");
@ -246,9 +259,15 @@ async function getPatcherUpdates(osuPath) {
for (const patcherFile of patcherFiles) { for (const patcherFile of patcherFiles) {
if (fs.existsSync(path.join(patcherDir, patcherFile.name))) { if (fs.existsSync(path.join(patcherDir, patcherFile.name))) {
const latestPatchFileHash = await (await fetch(patcherFile.url_hash)).text(); const latestPatchFileHash = await (await fetch(patcherFile.url_hash))
const localPatchFileHash = crypto.createHash("md5").update(fs.readFileSync(path.join(patcherDir, patcherFile.name))).digest("hex"); .text();
if (latestPatchFileHash.trim().toLowerCase() != localPatchFileHash.trim().toLowerCase()) filesToDownload.push(patcherFile); 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); } else filesToDownload.push(patcherFile);
} }
@ -259,7 +278,6 @@ function downloadPatcherUpdates(osuPath, patcherUpdates) {
const eventEmitter = new EventEmitter(); const eventEmitter = new EventEmitter();
const startDownload = async () => { const startDownload = async () => {
const patcherDir = path.join(osuPath, "EZPPLauncher"); const patcherDir = path.join(osuPath, "EZPPLauncher");
if (!fs.existsSync(patcherDir)) fs.mkdirSync(patcherDir); if (!fs.existsSync(patcherDir)) fs.mkdirSync(patcherDir);
@ -274,23 +292,32 @@ function downloadPatcherUpdates(osuPath, patcherUpdates) {
fileName, fileName,
loaded, loaded,
total, 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 { return {
eventEmitter, eventEmitter,
startDownload, startDownload,
} };
} }
async function getUIFiles(osuPath) { async function getUIFiles(osuPath) {
const filesToDownload = []; const filesToDownload = [];
const ezppLauncherDir = path.join(osuPath, "EZPPLauncher"); const ezppLauncherDir = path.join(osuPath, "EZPPLauncher");
@ -299,8 +326,13 @@ async function getUIFiles(osuPath) {
for (const uiFile of uiFiles) { for (const uiFile of uiFiles) {
if (fs.existsSync(path.join(ezppLauncherDir, uiFile.name))) { if (fs.existsSync(path.join(ezppLauncherDir, uiFile.name))) {
const latestPatchFileHash = await (await fetch(uiFile.url_hash)).text(); const latestPatchFileHash = await (await fetch(uiFile.url_hash)).text();
const localPatchFileHash = crypto.createHash("md5").update(fs.readFileSync(path.join(ezppLauncherDir, uiFile.name))).digest("hex"); const localPatchFileHash = crypto.createHash("md5").update(
if (latestPatchFileHash.trim().toLowerCase() != localPatchFileHash.trim().toLowerCase()) filesToDownload.push(uiFile); fs.readFileSync(path.join(ezppLauncherDir, uiFile.name)),
).digest("hex");
if (
latestPatchFileHash.trim().toLowerCase() !=
localPatchFileHash.trim().toLowerCase()
) filesToDownload.push(uiFile);
} else filesToDownload.push(uiFile); } else filesToDownload.push(uiFile);
} }
@ -311,7 +343,6 @@ function downloadUIFiles(osuPath, uiFiles) {
const eventEmitter = new EventEmitter(); const eventEmitter = new EventEmitter();
const startDownload = async () => { const startDownload = async () => {
const ezpplauncherDir = path.join(osuPath, "EZPPLauncher"); const ezpplauncherDir = path.join(osuPath, "EZPPLauncher");
if (!fs.existsSync(ezpplauncherDir)) fs.mkdirSync(ezpplauncherDir); if (!fs.existsSync(ezpplauncherDir)) fs.mkdirSync(ezpplauncherDir);
@ -326,33 +357,85 @@ function downloadUIFiles(osuPath, uiFiles) {
fileName, fileName,
loaded, loaded,
total, total,
progress: Math.floor((loaded / total) * 100) progress: Math.floor((loaded / total) * 100),
}); });
}, },
}); });
try {
await fs.promises.writeFile(path.join(osuPath, "EZPPLauncher", fileName), axiosDownloadWithProgress.data); await fs.promises.writeFile(
path.join(osuPath, "EZPPLauncher", fileName),
axiosDownloadWithProgress.data,
);
} catch (err) {
console.log(err);
eventEmitter.emit("error", {
fileName,
});
}
} }
} };
return { return {
eventEmitter, eventEmitter,
startDownload, startDownload,
} };
} }
async function replaceUIFile(osuPath, revert) { async function replaceUIFile(osuPath, revert) {
if (!revert) { if (!revert) {
const ezppUIFile = path.join(osuPath, "EZPPLauncher", "ezpp!ui.dll"); const ezppUIFile = path.join(osuPath, "EZPPLauncher", "ezpp!ui.dll");
const oldOsuUIFile = path.join(osuPath, "osu!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); await fs.promises.rename(ezppUIFile, oldOsuUIFile);
} else { } else {
const oldOsuUIFile = path.join(osuPath, "osu!ui.dll"); const oldOsuUIFile = path.join(osuPath, "osu!ui.dll");
const ezppUIFile = path.join(osuPath, "EZPPLauncher", "ezpp!ui.dll"); const ezppUIFile = path.join(osuPath, "EZPPLauncher", "ezpp!ui.dll");
await fs.promises.rename(oldOsuUIFile, ezppUIFile); 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 }; 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,
getGlobalConfig,
getUpdateFiles,
getFilesThatNeedUpdate,
downloadUpdateFiles,
runOsuWithDevServer,
getPatcherUpdates,
downloadPatcherUpdates,
downloadUIFiles,
getUIFiles,
replaceUIFile,
findOsuInstallation,
};

55
electron/richPresence.js Normal file
View File

@ -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}` : " ";
},
};

148
main.js
View File

@ -3,16 +3,32 @@ const { app, BrowserWindow, Menu, ipcMain, dialog } = require("electron");
const path = require("path"); const path = require("path");
const serve = require("electron-serve"); const serve = require("electron-serve");
const loadURL = serve({ directory: "public" }); const loadURL = serve({ directory: "public" });
const config = require("./src/config/config"); const config = require("./electron/config");
const { setupTitlebar, attachTitlebarToWindow } = require( const { setupTitlebar, attachTitlebarToWindow } = require(
"custom-electron-titlebar/main", "custom-electron-titlebar/main",
); );
const { isValidOsuFolder, getUpdateFiles, getGlobalConfig, getFilesThatNeedUpdate, downloadUpdateFiles, getUserConfig, runOsuWithDevServer, getPatcherUpdates, downloadPatcherUpdates, getUIFiles, downloadUIFiles, replaceUIFile } = require("./src/util/osuUtil"); const {
const { formatBytes } = require("./src/util/formattingUtil"); isValidOsuFolder,
getUpdateFiles,
getGlobalConfig,
getFilesThatNeedUpdate,
downloadUpdateFiles,
getUserConfig,
runOsuWithDevServer,
getPatcherUpdates,
downloadPatcherUpdates,
getUIFiles,
downloadUIFiles,
replaceUIFile,
findOsuInstallation,
} = require("./electron/osuUtil");
const { formatBytes } = require("./electron/formattingUtil");
const windowName = require("get-window-by-name"); const windowName = require("get-window-by-name");
const { existsSync } = require("fs"); const { existsSync } = require("fs");
const { runFileDetached } = require("./src/util/executeUtil"); const { runFileDetached } = require("./electron/executeUtil");
const richPresence = require("./src/discord/richPresence"); 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 // 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. // be closed automatically when the JavaScript object is garbage collected.
@ -40,7 +56,11 @@ function startOsuStatus() {
if (!osuLoaded) { if (!osuLoaded) {
osuLoaded = true; osuLoaded = true;
setTimeout(() => { setTimeout(() => {
const patcherExecuteable = path.join(userOsuPath, "EZPPLauncher", "patcher.exe"); const patcherExecuteable = path.join(
userOsuPath,
"EZPPLauncher",
"patcher.exe",
);
if (existsSync(patcherExecuteable)) { if (existsSync(patcherExecuteable)) {
runFileDetached(userOsuPath, patcherExecuteable); runFileDetached(userOsuPath, patcherExecuteable);
} }
@ -102,15 +122,6 @@ function startOsuStatus() {
details, details,
state: infoText state: infoText
}) })
/* const components = windowTitle.split(" - ");
const splitTitle = [components.shift(), components.join(" - ")]
const currentMap = splitTitle[1];
if (!currentMap.endsWith(".osu")) {
richPresence.updateStatus({
state: "Playing...",
details: currentMap
})
} */
} }
}, 2500); }, 2500);
} }
@ -121,6 +132,7 @@ function stopOsuStatus() {
function registerIPCPipes() { function registerIPCPipes() {
ipcMain.handle("ezpplauncher:login", async (e, args) => { ipcMain.handle("ezpplauncher:login", async (e, args) => {
const hwid = getHwId();
const timeout = new AbortController(); const timeout = new AbortController();
const timeoutId = setTimeout(() => timeout.abort(), 8000); const timeoutId = setTimeout(() => timeout.abort(), 8000);
try { try {
@ -143,7 +155,7 @@ function registerIPCPipes() {
if ("user" in result) { if ("user" in result) {
if (args.saveCredentials) { if (args.saveCredentials) {
config.set("username", args.username); config.set("username", args.username);
config.set("password", args.password); config.set("password", cryptUtil.encrypt(args.password, hwid));
} }
currentUser = args; currentUser = args;
config.remove("guest"); config.remove("guest");
@ -162,11 +174,23 @@ function registerIPCPipes() {
} }
}); });
ipcMain.handle("ezpplauncher:autologin", async (e) => { ipcMain.handle("ezpplauncher:autologin-active", async (e) => {
const username = config.get("username"); const username = config.get("username");
const password = config.get("password"); const password = config.get("password");
const guest = config.get("guest"); 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 (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);
if (username == undefined || password == undefined) { if (username == undefined || password == undefined) {
return { code: 200, message: "No autologin" }; return { code: 200, message: "No autologin" };
} }
@ -196,6 +220,8 @@ function registerIPCPipes() {
}; };
} }
return result; return result;
} else {
config.remove("password");
} }
return { return {
code: 500, code: 500,
@ -220,7 +246,7 @@ function registerIPCPipes() {
config.remove("username"); config.remove("username");
config.remove("password"); config.remove("password");
config.remove("guest"); config.remove("guest");
currentUser = undefined currentUser = undefined;
return true; return true;
}); });
@ -228,6 +254,18 @@ function registerIPCPipes() {
return config.all(); 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) => { ipcMain.handle("ezpplauncher:set-folder", async (e) => {
const folderResult = await dialog.showOpenDialog({ const folderResult = await dialog.showOpenDialog({
title: "Select osu! installation directory", title: "Select osu! installation directory",
@ -285,33 +323,65 @@ function registerIPCPipes() {
const updateFiles = await getFilesThatNeedUpdate(osuPath, latestFiles); const updateFiles = await getFilesThatNeedUpdate(osuPath, latestFiles);
if (uiFiles.length > 0) { if (uiFiles.length > 0) {
const uiDownloader = downloadUIFiles(osuPath, uiFiles); 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) => { uiDownloader.eventEmitter.on("data", (data) => {
mainWindow.webContents.send("ezpplauncher:launchprogress", { mainWindow.webContents.send("ezpplauncher:launchprogress", {
progress: Math.ceil(data.progress), progress: Math.ceil(data.progress),
}); });
mainWindow.webContents.send("ezpplauncher:launchstatus", { 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(); await uiDownloader.startDownload();
mainWindow.webContents.send("ezpplauncher:launchprogress", { mainWindow.webContents.send("ezpplauncher:launchprogress", {
progress: -1, progress: -1,
}); });
if (errored) {
mainWindow.webContents.send("ezpplauncher:launchabort");
return;
}
} }
if (updateFiles.length > 0) { if (updateFiles.length > 0) {
const updateDownloader = downloadUpdateFiles(osuPath, updateFiles); 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) => { updateDownloader.eventEmitter.on("data", (data) => {
mainWindow.webContents.send("ezpplauncher:launchprogress", { mainWindow.webContents.send("ezpplauncher:launchprogress", {
progress: Math.ceil(data.progress), progress: Math.ceil(data.progress),
}); });
mainWindow.webContents.send("ezpplauncher:launchstatus", { 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(); await updateDownloader.startDownload();
mainWindow.webContents.send("ezpplauncher:launchprogress", { mainWindow.webContents.send("ezpplauncher:launchprogress", {
progress: -1, progress: -1,
}); });
if (errored) {
mainWindow.webContents.send("ezpplauncher:launchabort");
return;
}
mainWindow.webContents.send("ezpplauncher:launchstatus", { mainWindow.webContents.send("ezpplauncher:launchstatus", {
status: "osu! is now up to date!", status: "osu! is now up to date!",
}); });
@ -331,18 +401,34 @@ function registerIPCPipes() {
const patchFiles = await getPatcherUpdates(osuPath); const patchFiles = await getPatcherUpdates(osuPath);
if (patchFiles.length > 0) { if (patchFiles.length > 0) {
const patcherDownloader = downloadPatcherUpdates(osuPath, patchFiles); 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) => { patcherDownloader.eventEmitter.on("data", (data) => {
mainWindow.webContents.send("ezpplauncher:launchprogress", { mainWindow.webContents.send("ezpplauncher:launchprogress", {
progress: Math.ceil(data.progress), progress: Math.ceil(data.progress),
}); });
mainWindow.webContents.send("ezpplauncher:launchstatus", { 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(); await patcherDownloader.startDownload();
mainWindow.webContents.send("ezpplauncher:launchprogress", { mainWindow.webContents.send("ezpplauncher:launchprogress", {
progress: -1, progress: -1,
}) });
if (errored) {
mainWindow.webContents.send("ezpplauncher:launchabort");
return;
}
mainWindow.webContents.send("ezpplauncher:launchstatus", { mainWindow.webContents.send("ezpplauncher:launchstatus", {
status: "Patcher is now up to date!", status: "Patcher is now up to date!",
}); });
@ -375,8 +461,8 @@ function registerIPCPipes() {
stopOsuStatus(); stopOsuStatus();
richPresence.updateVersion(); richPresence.updateVersion();
richPresence.updateStatus({ richPresence.updateStatus({
details: "Idle in Launcher...", state: "Idle in Launcher...",
state: undefined details: undefined
}) })
mainWindow.webContents.send("ezpplauncher:launchstatus", { mainWindow.webContents.send("ezpplauncher:launchstatus", {
status: "Waiting for cleanup...", status: "Waiting for cleanup...",
@ -386,11 +472,19 @@ function registerIPCPipes() {
await replaceUIFile(osuPath, true); await replaceUIFile(osuPath, true);
mainWindow.webContents.send("ezpplauncher:launchabort"); mainWindow.webContents.send("ezpplauncher:launchabort");
}, 5000); }, 5000);
} };
await replaceUIFile(osuPath, false); await replaceUIFile(osuPath, false);
runOsuWithDevServer(osuPath, "ez-pp.farm", onExitHook); runOsuWithDevServer(osuPath, "ez-pp.farm", onExitHook);
mainWindow.hide(); mainWindow.hide();
startOsuStatus(); startOsuStatus();
/* mainWindow.webContents.send("ezpplauncher:launchprogress", {
progress: 0,
});
mainWindow.webContents.send("ezpplauncher:launchprogress", {
progress: 100,
}); */
return true; return true;
}); });
} }
@ -400,8 +494,8 @@ function createWindow() {
// Create the browser window. // Create the browser window.
mainWindow = new BrowserWindow({ mainWindow = new BrowserWindow({
width: 600, width: 550,
height: 380, height: 350,
resizable: false, resizable: false,
frame: false, frame: false,
titleBarStyle: "hidden", titleBarStyle: "hidden",

94
package-lock.json generated
View File

@ -7,17 +7,21 @@
"": { "": {
"name": "ezpplauncher-next", "name": "ezpplauncher-next",
"version": "2.0.0", "version": "2.0.0",
"hasInstallScript": true,
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"@types/better-sqlite3": "^7.6.8", "@types/better-sqlite3": "^7.6.8",
"axios": "^1.6.5", "axios": "^1.6.5",
"better-sqlite3": "^9.2.2", "better-sqlite3": "^9.2.2",
"crypto": "^1.0.1", "crypto": "^1.0.1",
"crypto-js": "^4.2.0",
"custom-electron-titlebar": "^4.2.7", "custom-electron-titlebar": "^4.2.7",
"discord-auto-rpc": "^1.0.17", "discord-auto-rpc": "^1.0.17",
"electron-serve": "^1.1.0", "electron-serve": "^1.1.0",
"get-window-by-name": "^2.0.0", "get-window-by-name": "^2.0.0",
"svelte-french-toast": "^1.2.0" "regedit-rs": "^1.0.2",
"svelte-french-toast": "^1.2.0",
"systeminformation": "^5.21.22"
}, },
"devDependencies": { "devDependencies": {
"@electron/rebuild": "^3.5.0", "@electron/rebuild": "^3.5.0",
@ -3071,6 +3075,11 @@
"integrity": "sha512-VxBKmeNcqQdiUQUW2Tzq0t377b54N2bMtXO/qiLa+6eRRmmC4qT3D4OnTGoT/U6O9aklQ/jTwbOtRMTTY8G0Ig==", "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." "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": { "node_modules/css-declaration-sorter": {
"version": "6.4.1", "version": "6.4.1",
"resolved": "https://registry.npmjs.org/css-declaration-sorter/-/css-declaration-sorter-6.4.1.tgz", "resolved": "https://registry.npmjs.org/css-declaration-sorter/-/css-declaration-sorter-6.4.1.tgz",
@ -7044,6 +7053,64 @@
"node": ">=8.10.0" "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": { "node_modules/regenerator-runtime": {
"version": "0.14.1", "version": "0.14.1",
"resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.14.1.tgz", "resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.14.1.tgz",
@ -8521,6 +8588,31 @@
"integrity": "sha512-dn6wd0uw5GsdswPFfsgMp5NSB0/aDe6fK94YJV/AJDYXL6HVLWBsxeq7js7Ad+mU2K9LAlwpk6kN2D5mwCPVow==", "integrity": "sha512-dn6wd0uw5GsdswPFfsgMp5NSB0/aDe6fK94YJV/AJDYXL6HVLWBsxeq7js7Ad+mU2K9LAlwpk6kN2D5mwCPVow==",
"dev": true "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": { "node_modules/tailwind-merge": {
"version": "2.2.0", "version": "2.2.0",
"resolved": "https://registry.npmjs.org/tailwind-merge/-/tailwind-merge-2.2.0.tgz", "resolved": "https://registry.npmjs.org/tailwind-merge/-/tailwind-merge-2.2.0.tgz",

View File

@ -12,9 +12,12 @@
"files": [ "files": [
"public/**/*", "public/**/*",
"main.js", "main.js",
"preload.js" "preload.js",
"electron/*",
"electron/**/*"
], ],
"win": { "win": {
"requestedExecutionLevel": "requireAdministrator",
"target": [ "target": [
"portable" "portable"
] ]
@ -29,8 +32,9 @@
"start": "sirv public --no-clear", "start": "sirv public --no-clear",
"electron": "wait-on http://localhost:8080 && electron .", "electron": "wait-on http://localhost:8080 && electron .",
"electron-dev": "concurrently \"yarn run dev\" \"yarn run 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", "electron-pack": "electron-builder",
"postinstall": "electron-builder install-app-deps",
"check": "svelte-check --tsconfig ./tsconfig.json" "check": "svelte-check --tsconfig ./tsconfig.json"
}, },
"dependencies": { "dependencies": {
@ -38,11 +42,14 @@
"axios": "^1.6.5", "axios": "^1.6.5",
"better-sqlite3": "^9.2.2", "better-sqlite3": "^9.2.2",
"crypto": "^1.0.1", "crypto": "^1.0.1",
"crypto-js": "^4.2.0",
"custom-electron-titlebar": "^4.2.7", "custom-electron-titlebar": "^4.2.7",
"discord-auto-rpc": "^1.0.17", "discord-auto-rpc": "^1.0.17",
"electron-serve": "^1.1.0", "electron-serve": "^1.1.0",
"get-window-by-name": "^2.0.0", "get-window-by-name": "^2.0.0",
"svelte-french-toast": "^1.2.0" "regedit-rs": "^1.0.2",
"svelte-french-toast": "^1.2.0",
"systeminformation": "^5.21.22"
}, },
"devDependencies": { "devDependencies": {
"@electron/rebuild": "^3.5.0", "@electron/rebuild": "^3.5.0",

View File

@ -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 () => { window.addEventListener("autologin-attempt", async () => {
const loginResult = await ipcRenderer.invoke("ezpplauncher:autologin"); const loginResult = await ipcRenderer.invoke("ezpplauncher:autologin");
window.dispatchEvent( window.dispatchEvent(
@ -48,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) => { window.addEventListener("folder-set", async (e) => {
const result = await ipcRenderer.invoke("ezpplauncher:set-folder"); const result = await ipcRenderer.invoke("ezpplauncher:set-folder");
window.dispatchEvent( window.dispatchEvent(

View File

@ -18,5 +18,5 @@
<script defer src="/build/bundle.js"></script> <script defer src="/build/bundle.js"></script>
</head> </head>
<body class="select-none bg-gray-100 dark:bg-gray-900"></body> <body class="select-none bg-gray-100 dark:bg-gray-900 overflow-hidden"></body>
</html> </html>

View File

@ -9,7 +9,6 @@ import image from "@rollup/plugin-image";
import sveltePreprocess from "svelte-preprocess"; import sveltePreprocess from "svelte-preprocess";
import typescript from "@rollup/plugin-typescript"; import typescript from "@rollup/plugin-typescript";
import progress from "rollup-plugin-progress"; import progress from "rollup-plugin-progress";
import findUnused from "rollup-plugin-unused";
const production = !process.env.ROLLUP_WATCH; const production = !process.env.ROLLUP_WATCH;
@ -48,8 +47,7 @@ export default {
file: "public/build/bundle.js", file: "public/build/bundle.js",
}, },
plugins: [ plugins: [
findUnused(), !production && progress({ clearLine: true }),
progress({ clearLine: true }),
svelte({ svelte({
preprocess: sveltePreprocess({ sourceMap: !production }), preprocess: sveltePreprocess({ sourceMap: !production }),
compilerOptions: { compilerOptions: {
@ -61,7 +59,7 @@ export default {
// we'll extract any component CSS out into // we'll extract any component CSS out into
// a separate file - better for performance // a separate file - better for performance
css({ output: "bundle.css" }), css({ output: "bundle.css" }),
postcss(), postcss({ sourceMap: "inline" }),
// If you have external dependencies installed from // If you have external dependencies installed from
// npm, you'll most likely need these plugins. In // npm, you'll most likely need these plugins. In

View File

@ -5,8 +5,10 @@
DropdownItem, DropdownItem,
DropdownHeader, DropdownHeader,
DropdownDivider, DropdownDivider,
Button,
} from "flowbite-svelte"; } from "flowbite-svelte";
import { import {
ArrowLeftSolid,
ArrowRightFromBracketSolid, ArrowRightFromBracketSolid,
ArrowRightToBracketSolid, ArrowRightToBracketSolid,
UserSettingsSolid, UserSettingsSolid,
@ -38,6 +40,12 @@
window.dispatchEvent(new CustomEvent("logout")); window.dispatchEvent(new CustomEvent("logout"));
currentUser.set(undefined); currentUser.set(undefined);
currentPage.set(Page.Login); 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) => { window.addEventListener("launchStatusUpdate", (e) => {
@ -67,7 +75,7 @@
position: "bottom-center", position: "bottom-center",
className: className:
"dark:!bg-gray-800 border-1 dark:!border-gray-700 dark:!text-gray-100", "dark:!bg-gray-800 border-1 dark:!border-gray-700 dark:!text-gray-100",
duration: 1500, duration: 2000,
}); });
break; break;
} }
@ -76,7 +84,7 @@
position: "bottom-center", position: "bottom-center",
className: className:
"dark:!bg-gray-800 border-1 dark:!border-gray-700 dark:!text-gray-100", "dark:!bg-gray-800 border-1 dark:!border-gray-700 dark:!text-gray-100",
duration: 1500, duration: 4000,
}); });
break; break;
} }
@ -96,14 +104,27 @@
<Toaster></Toaster> <Toaster></Toaster>
<div class="p-2 flex flex-row justify-between items-center"> <div class="p-2 flex flex-row justify-between items-center">
<div class="flex flex-row items-center"> <div class="flex flex-row items-center animate-fadeIn opacity-0">
{#if $currentPage == Page.Settings}
<Button
class="dark:!bg-gray-800 dark:active:!bg-gray-950 !ring-0 outline-none !border-none dark:text-white w-10 h-10 mr-1 rounded-lg animate-sideIn opacity-0"
color="none"
on:click={() => {
currentPage.set(Page.Launch);
}}
>
<ArrowLeftSolid class="outline-none border-none" size="sm" />
</Button>
{/if}
<img src={ezppLogo} alt="EZPPFarm Logo" class="w-12 h-12 mr-2" /> <img src={ezppLogo} alt="EZPPFarm Logo" class="w-12 h-12 mr-2" />
<span class="text-gray-700 dark:text-gray-100 text-xl font-extralight"> <span class="text-gray-700 dark:text-gray-100 text-xl font-extralight">
EZPPLauncher EZPPLauncher
</span> </span>
</div> </div>
{#if $currentPage == Page.Launch} {#if $currentPage == Page.Launch}
<div class="flex flex-row gap-2 w-fill cursor-pointer md:order-2"> <div
class="flex flex-row gap-2 w-fill cursor-pointer md:order-2 animate-fadeIn opacity-0"
>
<Avatar <Avatar
class="rounded-lg border dark:border-gray-700 hover:ring-4 hover:ring-gray-200 dark:hover:ring-gray-800" class="rounded-lg border dark:border-gray-700 hover:ring-4 hover:ring-gray-200 dark:hover:ring-gray-800"
src={loggedIn src={loggedIn
@ -167,11 +188,3 @@
{:else} {:else}
<Launch /> <Launch />
{/if} {/if}
<style>
.container {
text-align: center;
padding: 1em;
margin: auto;
}
</style>

View File

@ -20,6 +20,10 @@ html .cet-titlebar .cet-control-icon svg {
display: none; display: none;
} }
.cet-container {
overflow: hidden !important;
}
.indeterminate { .indeterminate {
background-image: repeating-linear-gradient( background-image: repeating-linear-gradient(
90deg, 90deg,

View File

@ -15,81 +15,118 @@
const processLogin = async () => { const processLogin = async () => {
loading = true; loading = true;
window.addEventListener( const loginPromise = new Promise<void>((res, rej) => {
"login-result", window.addEventListener(
(e) => { "login-result",
const customEvent = e as CustomEvent; (e) => {
const resultData = customEvent.detail; const customEvent = e as CustomEvent;
const wasSuccessful = "user" in resultData; const resultData = customEvent.detail;
const wasSuccessful = "user" in resultData;
if (!wasSuccessful) { if (!wasSuccessful) {
const errorResult = resultData as Error; /* const errorResult = resultData as Error;
toast.error(errorResult.message, { toast.error(errorResult.message, {
position: "bottom-center", position: "bottom-center",
className: className:
"dark:!bg-gray-800 border-1 dark:!border-gray-700 dark:!text-gray-100", "dark:!bg-gray-800 border-1 dark:!border-gray-700 dark:!text-gray-100",
duration: 1500, duration: 1500,
}); }); */
loading = false; rej();
return; loading = false;
} return;
const userResult = resultData.user as User; }
currentUser.set(userResult); const userResult = resultData.user as User;
currentPage.set(Page.Launch); currentUser.set(userResult);
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) {
currentPage.set(Page.Launch); currentPage.set(Page.Launch);
toast.success(`Logged in as Guest`, { res();
toast.success(`Welcome back, ${userResult.name}!`, {
position: "bottom-center", position: "bottom-center",
className: className:
"dark:!bg-gray-800 border-1 dark:!border-gray-700 dark:!text-gray-100", "dark:!bg-gray-800 border-1 dark:!border-gray-700 dark:!text-gray-100",
duration: 3000, duration: 3000,
}); });
return; },
} { once: true }
if (!wasSuccessful) { );
loading = false; window.dispatchEvent(
return; new CustomEvent("login-attempt", {
} detail: { username, password, saveCredentials },
const userResult = resultData.user as User; })
currentUser.set(userResult); );
currentPage.set(Page.Launch); });
toast.success(`Welcome back, ${userResult.name}!`, { toast.promise(
position: "bottom-center", loginPromise,
className: {
"dark:!bg-gray-800 border-1 dark:!border-gray-700 dark:!text-gray-100", loading: "Logging in...",
duration: 3000, success: "Successfully logged in!",
}); error: "Failed to login.",
loading = false;
}, },
{ 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<void>((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;
console.log(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 = () => { const proceedAsGuest = () => {
@ -103,10 +140,24 @@
}); });
}; };
if (!$startup) { const shouldAutologin = async () => {
startup.set(true); const shouldAutologin = await new Promise<boolean>((res) => {
tryAutoLogin(); 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();
}
})();
</script> </script>
<main <main

View File

@ -1,11 +1,21 @@
<script lang="ts"> <script lang="ts">
import { Button, ButtonGroup, Input } from "flowbite-svelte"; import {
import { FolderSolid } from "flowbite-svelte-icons"; Button,
ButtonGroup,
Input,
Label,
Toggle,
Tooltip,
} from "flowbite-svelte";
import { FileSearchSolid, FolderSolid } from "flowbite-svelte-icons";
import { currentPage } from "../storage/localStore"; import { currentPage } from "../storage/localStore";
import { Page } from "../consts/pages"; import { Page } from "../consts/pages";
let folderPath: string = ""; let folderPath: string = "";
let patching: boolean = true;
let presence: boolean = true;
window.addEventListener("settings-result", (e) => { window.addEventListener("settings-result", (e) => {
const settings: Record<string, string>[] = (e as CustomEvent).detail; const settings: Record<string, string>[] = (e as CustomEvent).detail;
const osuPath = settings.find((setting) => setting.key == "osuPath"); const osuPath = settings.find((setting) => setting.key == "osuPath");
@ -16,17 +26,38 @@
const setFolderPath = () => { const setFolderPath = () => {
window.dispatchEvent(new CustomEvent("folder-set")); window.dispatchEvent(new CustomEvent("folder-set"));
}; };
const detectFolderPath = () => {
window.dispatchEvent(new CustomEvent("folder-auto"));
};
const togglePatching = () => {
patching = !patching;
};
const togglePresence = () => {
presence = !presence;
};
</script> </script>
<main <main
class="h-[265px] my-auto flex flex-col justify-center items-center p-5 animate-fadeIn opacity-0" class="h-[265px] flex flex-col justify-start p-3 animate-fadeIn opacity-0"
> >
<div class="flex flex-col gap-2 p-3">
<Toggle class="w-fit" bind:checked={presence} on:click={togglePresence}
>Discord Presence</Toggle
>
<Toggle class="w-fit" bind:checked={patching} on:click={togglePatching}
>Patching</Toggle
>
</div>
<div <div
class="container flex flex-col items-center justify-center gap-5 rounded-lg p-3" class="container flex flex-col items-center justify-center gap-5 rounded-lg p-3"
> >
<ButtonGroup class="w-full"> <ButtonGroup class="w-full">
<Input <Input
type="text" type="text"
id="oip"
placeholder="Path to your osu! installation" placeholder="Path to your osu! installation"
value={folderPath} value={folderPath}
readonly readonly
@ -34,19 +65,23 @@
<Button <Button
color="light" color="light"
class="dark:active:!bg-gray-900" class="dark:active:!bg-gray-900"
on:click={setFolderPath} on:click={detectFolderPath}
><FolderSolid >
<FileSearchSolid
size="sm" size="sm"
class="dark:text-gray-300 text-gray-500 outline-none border-none select-none pointer-events-none" class="dark:text-gray-300 text-gray-500 outline-none border-none select-none pointer-events-none"
/></Button />
> </Button>
</ButtonGroup>
<div class="flex flex-row justify-center items-center gap-5">
<Button <Button
color="light" color="light"
class="dark:active:!bg-gray-900" class="dark:active:!bg-gray-900 active:!rounded-lg"
on:click={() => currentPage.set(Page.Launch)}>Go Back</Button on:click={setFolderPath}
> >
</div> <FolderSolid
size="sm"
class="dark:text-gray-300 text-gray-500 outline-none border-none select-none pointer-events-none"
/>
</Button>
</ButtonGroup>
</div> </div>
</main> </main>

View File

@ -8,6 +8,10 @@ const config = {
theme: { theme: {
extend: { extend: {
keyframes: { keyframes: {
slideIn: {
"0%": { opacity: "0", transform: "translateX(-5px)" },
"100%": { opacity: "1" },
},
fadeIn: { fadeIn: {
"0%": { opacity: "0", transform: "translateY(5px)" }, "0%": { opacity: "0", transform: "translateY(5px)" },
"100%": { opacity: "1" }, "100%": { opacity: "1" },
@ -18,11 +22,12 @@ const config = {
}, },
}, },
animation: { animation: {
sideIn: "slideIn 1s ease forwards",
fadeIn: "fadeIn 1s ease forwards", fadeIn: "fadeIn 1s ease forwards",
fadeOut: "fadeOut 1s ease forwards", fadeOut: "fadeOut 1s ease forwards",
}, },
transitionProperty: { transitionProperty: {
'width': 'width', "width": "width",
}, },
colors: { colors: {
// flowbite-svelte // flowbite-svelte

View File

@ -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,
})
})();

View File

@ -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);
})();

View File

@ -1,7 +0,0 @@
const { getUpdateFiles } = require("../src/util/osuUtil");
(async () => {
const osuPath = "";
const latestFiles = await getUpdateFiles("stable40");
console.log(latestFiles);
})();

View File

@ -1,7 +1,16 @@
{ {
"extends": "./node_modules/@tsconfig/svelte/tsconfig.json", "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/*"], "exclude": ["node_modules/*", "__sapper__/*", "public/*"],
"compilerOptions": { "compilerOptions": {
"typeRoots": [ "typeRoots": [