55 Commits
1.0.0 ... 1.1.2

Author SHA1 Message Date
b111cf4fa4 fix building scripts, update electron 2023-05-04 21:47:21 +02:00
e2713179c8 bump version 2023-05-04 21:29:22 +02:00
92ee92d636 reformat index 2023-05-04 21:28:04 +02:00
b3463378e9 reformat index 2023-05-04 21:23:22 +02:00
00e3e80d43 fix ignored list 2023-05-04 21:23:06 +02:00
2df9f533fe set buttons to constant array 2023-05-04 21:22:51 +02:00
cc93e24ab6 update action 2023-05-04 21:22:32 +02:00
48cd81f28d update url 2023-05-04 21:22:22 +02:00
068d02f1f7 remove logging, exclude certain osu files from updating 2023-05-04 21:07:09 +02:00
e725592ef1 remove patch checkbox for now 2023-05-04 21:05:01 +02:00
6bc0b215d7 change action button links 2023-05-04 21:04:48 +02:00
da1b05c9a1 bg tokyo night style 2023-01-25 15:50:50 +01:00
f1ef41dfea Update 'README.md' 2022-12-31 06:37:01 +00:00
a358ff08fa Merge branch 'master' of https://git.ez-pp.farm/EZPPFarm/EZPPLauncher 2022-12-23 21:43:34 +01:00
5db981228e distro info for linux 2022-12-23 21:41:47 +01:00
3247a3fcdf reformat and add distro check for linux 2022-12-23 21:41:39 +01:00
7b9a6d77ab change colors to tokyo night 2022-12-23 21:41:23 +01:00
337a8af68f add util method to detect osu folder, still needs to be tested on different systems. 2022-10-27 16:28:22 +02:00
84c13331d2 add launch button folder choose if not set 2022-10-27 15:42:45 +02:00
e77cb22028 increase height of window 2022-10-27 15:42:29 +02:00
b673b74eee make checkbox disabled for now 2022-10-27 14:41:26 +02:00
53a2fb55a6 forgot to revert display 2022-10-27 14:35:51 +02:00
3e4186d3a7 added checkbox for patching 2022-10-27 14:30:46 +02:00
89cdc8f316 preperations for the patch method 2022-10-27 13:58:15 +02:00
67a53fdd2d readd rebuild script for get-window-by-name 2022-10-27 11:00:10 +02:00
78c554be2d add editing status 2022-10-27 06:38:58 +02:00
586857146c remove unused scripts 2022-10-27 06:38:14 +02:00
2cea272836 make server logo non-draggable 2022-10-27 06:38:03 +02:00
02d4fa2199 add package issue notification 2022-10-27 06:37:48 +02:00
72a0d9b780 Update 'README.md' 2022-10-24 12:38:32 +00:00
1489d44a31 Upload files to 'preview' 2022-10-24 12:36:16 +00:00
adaaf32acf remove rebuild script usage, add other used libs i forgot to add 2022-10-24 12:29:33 +00:00
033ce8f3a4 make playing status work under linux 2022-10-24 06:36:03 +02:00
2857345997 only update currentState on certain types 2022-10-24 05:46:22 +02:00
4f3eaddfc7 style sweetalert2 2022-10-23 17:31:32 +02:00
573bcd393c add notice under Linux 2022-10-23 17:07:20 +02:00
11c3f9f657 forgot to remove image tag in html 2022-10-23 17:01:39 +02:00
c3c5390830 fix user images, many thanks to Wopiie! 2022-10-23 01:31:17 +02:00
67de9b7c16 remove wincript(PASSWORD IS PLAIN IN CONFIG FOR NOW!) make linux compatible 2022-10-23 01:08:58 +02:00
37567b5767 bump version 2022-10-21 00:59:19 +02:00
0a780b84e4 forgor to remove debug log 2022-10-21 00:59:11 +02:00
c8a07fbb0d add basic discord rpc, showing osu status 2022-10-21 00:57:42 +02:00
1de9fce504 show error modal when update failed 2022-10-20 19:08:48 +02:00
73fb9464d2 bump version 2022-10-18 01:46:11 +02:00
5c819938c8 login mechanics and launch is working now 2022-10-18 01:46:04 +02:00
4f84dd3248 add encrypt test 2022-10-18 01:45:17 +02:00
2fa6a9b3d5 push electron to latest 2022-10-17 21:31:48 +02:00
258c01ccc7 add build from source section to readme 2022-10-17 21:30:46 +02:00
d80d6dc889 make logo on lauch page a bit bigger 2022-10-17 20:19:22 +02:00
7a8495d88a downgrade electron to propper version, add rebuild script 2022-10-17 20:10:04 +02:00
9ac75a309b update electron, add dpapi function wip 2022-10-17 18:10:17 +02:00
8ef809be5c add loading page on startup 2022-10-17 16:37:12 +02:00
e6ccec3e93 do previous page fadeout and not immediately hide 2022-10-17 12:58:56 +02:00
7785ebec92 fixed user image misplacement 2022-10-17 12:58:07 +02:00
3edf2ce8a3 new design rollout, function still not given 2022-10-17 12:47:47 +02:00
19 changed files with 1136 additions and 77 deletions

1
.gitignore vendored
View File

@@ -1,3 +1,4 @@
node_modules/ node_modules/
release/ release/
yarn.lock yarn.lock
pnpm-lock.yaml

View File

@@ -1,16 +1,18 @@
# EZPPLauncher # EZPPLauncher
Welcome to the EZPPLauncher! A new way to connect to the EZPPFarm server. Welcome to the EZPPLauncher! A new way to connect to the EZPPFarm server.
Just one click and you are ready to go! Just one click and you are ready to go!
## Preview Image
![preview](https://git.ez-pp.farm/EZPPFarm/EZPPLauncher/raw/branch/master/preview/EZPPLauncher.png)
## Installation ## Installation
The Launcher is a "plug and play thing", download it, place it on the desktop and execute! The Launcher is a "plug and play thing", download it, place it on the desktop and execute!
## Features ## Features
* Automatic osu! client updating before Launch * Automatic osu! client updating before Launch
* Account saving (soon) * Account saving
## Used Libraries ## Used Libraries
@@ -18,6 +20,17 @@ The Launcher is a "plug and play thing", download it, place it on the desktop an
* [custom-electron-titlebar](https://www.npmjs.com/package/custom-electron-titlebar) * [custom-electron-titlebar](https://www.npmjs.com/package/custom-electron-titlebar)
* [axios](https://www.npmjs.com/package/axios) * [axios](https://www.npmjs.com/package/axios)
* [jquery](https://www.npmjs.com/package/jquery) * [jquery](https://www.npmjs.com/package/jquery)
* [discord-auto-rpc](https://www.npmjs.com/package/discord-auto-rpc)
* [get-window-by-name](https://www.npmjs.com/package/get-window-by-name)
* [sweetalert2](https://www.npmjs.com/package/sweetalert2)
* [node-downloader-helper](https://www.npmjs.com/package/node-downloader-helper)
## Build from source
- clone repo
- cd into the repo
- use `yarn install` to install all dependencies
- use the buildscript `pack-win` to build a executeable
## License ## License
[AGPL-3.0](https://choosealicense.com/licenses/agpl-3.0/) [AGPL-3.0](https://choosealicense.com/licenses/agpl-3.0/)

223
app.js
View File

@@ -2,10 +2,20 @@ const { app, BrowserWindow, ipcMain, dialog } = require('electron');
const { setupTitlebar, attachTitlebarToWindow } = require('custom-electron-titlebar/main'); const { setupTitlebar, attachTitlebarToWindow } = require('custom-electron-titlebar/main');
const windowManager = require('./ui/windowManager'); const windowManager = require('./ui/windowManager');
const osuUtil = require('./osuUtil'); const osuUtil = require('./osuUtil');
const ezppUtil = require('./ezppUtil');
const config = require('./config'); const config = require('./config');
const fs = require('fs'); const fs = require('fs');
const rpc = require('./discordPresence');
const windowName = require('get-window-by-name');
const terminalUtil = require('./terminalUtil');
const osUtil = require('./osUtil');
let tempOsuPath; let tempOsuPath;
let osuWindowInfo;
let isIngame;
const platform = process.platform;
let linuxWMCtrlFound = false;
let osuLoaded = false;
const run = () => { const run = () => {
const gotTheLock = app.requestSingleInstanceLock() const gotTheLock = app.requestSingleInstanceLock()
@@ -14,14 +24,146 @@ const run = () => {
return; return;
} }
setInterval(async () => {
if (platform == "win32") {
osuWindowInfo = windowName.getWindowText("osu!.exe");
const firstInstance = osuWindowInfo[0];
if (firstInstance) {
if (firstInstance.processTitle && firstInstance.processTitle.length > 0) {
if (!osuLoaded) {
osuLoaded = true;
//TODO: do patch
}
const windowTitle = firstInstance.processTitle;
let rpcOsuVersion = "";
let currentMap = undefined;
if (!windowTitle.includes("-")) {
rpcOsuVersion = windowTitle;
rpc.updateState("Idle...");
} else {
var string = windowTitle;
var components = string.split(' - ');
const splitArray = [components.shift(), components.join(' - ')];
rpcOsuVersion = splitArray[0];
currentMap = splitArray[1];
if (currentMap.endsWith(".osu")) {
rpc.updateState("Editing...");
currentMap = currentMap.substring(0, currentMap.length - 4);
} else rpc.updateState("Playing...");
}
rpc.updateStatus(currentMap, rpcOsuVersion);
} else {
if (osuLoaded) osuLoaded = false;
rpc.updateState("Idle in Launcher...");
rpc.updateStatus(undefined, undefined);
}
} else {
if (osuLoaded) osuLoaded = false;
rpc.updateState("Idle in Launcher...");
rpc.updateStatus(undefined, undefined);
}
} else if (platform == "linux") {
if (!linuxWMCtrlFound) {
if (isIngame) {
rpc.updateState("Playing...");
rpc.updateStatus("Clicking circles!", "runningunderwine");
} else {
rpc.updateState("Idle in Launcher...");
rpc.updateStatus(undefined, undefined);
}
return;
}
const processesOutput = await terminalUtil.execCommand(`wmctrl -l|awk '{$3=""; $2=""; $1=""; print $0}'`);
const allLines = processesOutput.split("\n");
const filteredProcesses = allLines.filter((line) => line.trim().startsWith("osu!"));
if (filteredProcesses.length > 0) {
const windowTitle = filteredProcesses[0].trim();
let rpcOsuVersion = "";
let currentMap = undefined;
if (!windowTitle.includes("-")) {
rpcOsuVersion = windowTitle;
rpc.updateState("Idle...");
} else {
var string = windowTitle;
var components = string.split(' - ');
const splitArray = [components.shift(), components.join(' - ')];
rpcOsuVersion = splitArray[0];
currentMap = splitArray[1];
if (currentMap.endsWith(".osu")) {
rpc.updateState("Editing/Modding...");
currentMap = currentMap.substring(0, currentMap.length - 4);
}
else rpc.updateState("Playing...");
}
rpc.updateStatus(currentMap, rpcOsuVersion);
} else {
rpc.updateState("Idle in Launcher...");
rpc.updateStatus(undefined, undefined);
}
} else {
if (isIngame) {
rpc.updateState("Playing...");
rpc.updateStatus("Clicking circles!", "runningunderwine");
} else {
rpc.updateState("Idle in Launcher...");
rpc.updateStatus(undefined, undefined);
}
}
}, 2000);
setupTitlebar(); setupTitlebar();
rpc.connect();
let mainWindow; let mainWindow;
app.whenReady().then(() => { app.whenReady().then(() => {
mainWindow = createWindow(); mainWindow = createWindow();
mainWindow.on('show', async () => { mainWindow.on('show', async () => {
await updateConfigVars(mainWindow);
await tryLogin(mainWindow);
await doUpdateCheck(mainWindow); await doUpdateCheck(mainWindow);
if (platform === "linux") {
const linuxDistroInfo = await osUtil.getLinuxDistroInfo();
if (linuxDistroInfo?.id != "arch") {
if (linuxDistroInfo?.id_like != "arch") {
mainWindow.webContents.send('status_update', {
type: "info",
message: "We detected that you are running the Launcher under Linux. It's currently just compatible with Arch like distributions!"
});
}
}
try {
await terminalUtil.execCommand(`osu-stable -h`);
} catch (err) {
mainWindow.webContents.send('status_update', {
type: "package-issue",
message: "Seems like you dont have the osu AUR Package installed, please install it."
});
return;
}
/* mainWindow.webContents.send('status_update', {
type: "info",
message: "We detected that you are running the Launcher under Linux. It's currently just compatible with Arch and the osu AUR package!"
}); */
const terminalTest = await terminalUtil.execCommand(`wmctrl -l|awk '{$3=""; $2=""; $1=""; print $0}'`);
const isFailed = terminalTest.trim() == "";
if (isFailed) {
mainWindow.webContents.send('status_update', {
type: "info",
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 () { app.on('activate', function () {
if (BrowserWindow.getAllWindows().length === 0) mainWindow = createWindow(); if (BrowserWindow.getAllWindows().length === 0) mainWindow = createWindow();
@@ -30,7 +172,25 @@ const run = () => {
app.quit() app.quit()
}) })
ipcMain.handle('launch', async () => { ipcMain.handle('launch', async () => {
const osuConfig = await osuUtil.getLatestConfig(tempOsuPath);
const username = await config.get('username');
const password = await config.get('password');
if (password && username) {
await osuUtil.setConfigValue(osuConfig.path, "SaveUsername", "1");
await osuUtil.setConfigValue(osuConfig.path, "SavePassword", "1");
await osuUtil.setConfigValue(osuConfig.path, "Username", username);
await osuUtil.setConfigValue(osuConfig.path, "Password", password);
await osuUtil.setConfigValue(osuConfig.path, "CredentialEndpoint", "ez-pp.farm");
} else {
await osuUtil.setConfigValue(osuConfig.path, "Username", "");
await osuUtil.setConfigValue(osuConfig.path, "Password", "");
}
rpc.updateState("Launching osu!...");
isIngame = true;
mainWindow.hide();
const result = await osuUtil.startOsuWithDevServer(tempOsuPath, "ez-pp.farm", async () => { const result = await osuUtil.startOsuWithDevServer(tempOsuPath, "ez-pp.farm", async () => {
isIngame = false;
mainWindow.show();
await doUpdateCheck(mainWindow); await doUpdateCheck(mainWindow);
}); });
return result; return result;
@@ -66,6 +226,12 @@ const run = () => {
type: "update-complete" type: "update-complete"
}) })
}); });
downloadTask.on('error', () => {
mainWindow.webContents.send('status_update', {
type: "error",
message: "An error occured while updating."
});
});
} else } else
mainWindow.webContents.send('status_update', { mainWindow.webContents.send('status_update', {
@@ -84,15 +250,64 @@ const run = () => {
if (validOsuDir) await config.set("osuPath", folderPath); if (validOsuDir) await config.set("osuPath", folderPath);
return validOsuDir; return { validOsuDir, folderPath };
})
ipcMain.handle('perform-login', async (event, data) => {
const { username, password } = data;
const loginData = await ezppUtil.performLogin(username, password);
if (loginData && loginData.code === 200) {
await config.set("username", username);
await config.set("password", password);
}
return loginData;
})
ipcMain.on('perform-logout', async (event) => {
await config.remove("username");
await config.remove("password");
}) })
}) })
} }
async function doUpdateCheck(window) { async function updateConfigVars(window) {
const osuPath = await config.get("osuPath", ""); const osuPath = await config.get("osuPath", "");
window.webContents.send('config_update', {
osuPath: osuPath
})
}
async function tryLogin(window) {
const username = await config.get("username", "");
const password = await config.get("password", "");
if ((username && username.length > 0) && (password && password.length > 0)) {
const passwordPlain = password;
const loginResponse = await ezppUtil.performLogin(username, passwordPlain);
if (loginResponse && loginResponse.code === 200) {
window.webContents.send('account_update', {
type: "loggedin",
user: loginResponse.user
})
} else {
window.webContents.send('account_update', {
type: "login-failed"
})
}
} else {
window.webContents.send('account_update', {
type: "not-loggedin"
})
}
}
async function doUpdateCheck(window) {
const osuPath = await config.get("osuPath");
if (!osuPath || osuPath.trim == "") {
window.webContents.send('status_update', {
type: "missing-folder"
})
return;
}
const isValid = await osuUtil.isValidOsuFolder(osuPath); const isValid = await osuUtil.isValidOsuFolder(osuPath);
if (osuPath.trim == "" || !isValid) { if (!isValid) {
window.webContents.send('status_update', { window.webContents.send('status_update', {
type: "missing-folder" type: "missing-folder"
}) })
@@ -121,7 +336,7 @@ async function doUpdateCheck(window) {
function createWindow() { function createWindow() {
// Create the browser window. // Create the browser window.
const win = windowManager.createWindow(520, 350); const win = windowManager.createWindow(700, 460);
win.loadFile('./html/index.html'); win.loadFile('./html/index.html');

View File

@@ -1,4 +1,4 @@
const appName = "EZPPLauncher" const appName = "EZPPLauncher"
const appVersion = "1.0.0"; const appVersion = "1.1.2";
module.exports = { appName, appVersion }; module.exports = { appName, appVersion };

85
assets/checkbox.css Normal file
View File

@@ -0,0 +1,85 @@
[type="checkbox"]:not(:checked),
[type="checkbox"]:checked {
position: absolute;
left: 0;
opacity: 0.01;
}
[type="checkbox"]:not(:checked)+label,
[type="checkbox"]:checked+label {
position: relative;
padding-left: 2.3em;
font-size: 1.05em;
line-height: 1.7;
cursor: pointer;
}
/* checkbox aspect */
[type="checkbox"]:not(:checked)+label:before,
[type="checkbox"]:checked+label:before {
content: '';
position: absolute;
left: 0;
top: 0;
width: 1.4em;
height: 1.4em;
border: 1px solid #565656;
background: #4c4c4c;
border-radius: .2em;
box-shadow: inset 0 1px 3px rgba(0, 0, 0, .1), 0 0 0 hsla(var(--main-accent), 93%, 48%, 20%);
-webkit-transition: all .275s;
transition: all .275s;
}
/* checked mark aspect */
[type="checkbox"]:not(:checked)+label:after,
[type="checkbox"]:checked+label:after {
content: '✕';
position: absolute;
top: .525em;
left: .18em;
font-size: 1.375em;
font-weight: bolder;
color: hsl(var(--main-accent), 93%, 48%);
line-height: 0;
-webkit-transition: all .2s;
transition: all .2s;
}
/* checked mark aspect changes */
[type="checkbox"]:not(:checked)+label:after {
opacity: 0;
-webkit-transform: scale(0) rotate(45deg);
transform: scale(0) rotate(45deg);
}
[type="checkbox"]:checked+label:after {
opacity: 1;
-webkit-transform: scale(1) rotate(0);
transform: scale(1) rotate(0);
translate: -1.5px -1px;
}
/* Disabled checkbox */
[type="checkbox"]:disabled:not(:checked)+label:before,
[type="checkbox"]:disabled:checked+label:before {
box-shadow: none;
border-color: #565656;
background-color: #4c4c4c;
cursor: not-allowed;
}
[type="checkbox"]:disabled:checked+label:after {
color: #777;
}
[type="checkbox"]:disabled+label {
color: #aaa;
cursor: not-allowed;
}
/* Accessibility */
[type="checkbox"]:checked:focus+label:before,
[type="checkbox"]:not(:checked):focus+label:before {
box-shadow: inset 0 1px 3px rgba(0, 0, 0, .1), 0 0 0 6px hsla(var(--main-accent), 93%, 48%, 20%);
}

322
assets/launcher.css Normal file
View File

@@ -0,0 +1,322 @@
@import url('https://fonts.googleapis.com/css2?family=Exo+2:ital,wght@0,100;0,200;0,300;0,400;0,500;0,600;0,700;0,800;0,900;1,100;1,200;1,300;1,400;1,500;1,600;1,700;1,800;1,900&display=swap');
:root {
--main-accent: 335deg;
--main-bg: 230deg;
}
* {
font-family: 'Exo 2', 'Roboto' !important;
}
body {
background-color: hsl(var(--main-bg), 24%, 19%);
}
.sections {
display: flex;
flex-flow: column;
}
.app-name {
font-size: 40px;
font-weight: 500;
text-shadow: 0 0 15px rgba(255, 255, 255, 0.37);
}
.launcher-window {
width: 100%;
}
.launch-button-section {
display: flex;
flex-direction: column;
}
.launch-button-section button {
margin-bottom: 10px;
}
.loading-section,
.login-section {
margin-top: 35px;
display: flex;
flex-flow: column;
justify-content: center;
align-items: center;
}
.loading-section {
margin-top: 0;
}
.loading-section {}
.loading-indicator {}
.loading-indicator-text {
display: flex;
flex-flow: column;
justify-content: center;
align-items: center;
}
.folder-section {
margin-top: 50px;
display: flex;
flex-flow: column;
justify-content: center;
align-items: center;
color: #aaa;
font-weight: 500;
}
.folder-action {
font-style: italic;
cursor: pointer;
width: fit-content;
line-height: .9;
}
.launch-section {
width: 100%;
display: flex;
flex-flow: column;
align-items: center;
justify-content: center;
}
.btn.btn-launch {
margin-top: 10px;
width: 300px;
font-size: 23px;
text-transform: none;
}
.account-section {
display: flex;
align-items: center;
gap: 20px;
}
.server-logo img {
user-select: none;
pointer-events: none;
}
.user-info {
text-align: start;
display: flex;
flex-flow: column;
justify-content: center;
align-content: center;
overflow: hidden;
text-overflow: ellipsis;
}
.user-info .welcome-text {
font-size: 31px;
letter-spacing: .02rem;
height: 30px;
line-height: .8;
text-shadow: 0 0 10px rgba(0, 0, 0, 0.349);
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.user-info .account-action {
font-size: 21px;
letter-spacing: .05rem;
font-weight: 500;
font-style: italic;
color: #aaa;
text-shadow: 0 0 10px rgba(0, 0, 0, 0.349);
cursor: pointer;
line-height: 1.2;
width: fit-content;
}
.user-image {
border: 5px solid white;
border-radius: 0.4rem;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.349);
background-image: url(https://a.ez-pp.farm/0);
width: 100px;
height: 100px;
background-size: cover;
background-position: center;
}
.form-outline .form-control:focus~.form-notch .form-notch-leading {
border-color: hsl(var(--main-accent), 93%, 48%);
box-shadow: -1px 0 0 0 hsl(var(--main-accent), 93%, 48%), 0 1px 0 0 hsl(var(--main-accent), 93%, 48%), 0 -1px 0 0 hsl(var(--main-accent), 93%, 48%);
}
.form-outline .form-control:focus~.form-notch .form-notch-middle {
border-color: hsl(var(--main-accent), 93%, 48%);
box-shadow: 0 1px 0 0 hsl(var(--main-accent), 93%, 48%);
border-top: 1px solid transparent;
}
.form-outline .form-control:focus~.form-notch .form-notch-trailing {
border-color: hsl(var(--main-accent), 93%, 48%);
box-shadow: 1px 0 0 0 hsl(var(--main-accent), 93%, 48%), 0 -1px 0 0 hsl(var(--main-accent), 93%, 48%), 0 1px 0 0 hsl(var(--main-accent), 93%, 48%);
}
.form-outline .form-control:focus~.form-label {
color: hsl(var(--main-accent), 93%, 48%);
}
.btn-accent,
.btn-accent:active {
background: hsl(var(--main-accent), 93%, 48%);
color: #fff;
}
.btn-accent:hover {
background: hsl(var(--main-accent), 93%, 42%);
color: #fff ;
}
.btn-grey,
.btn-grey:active {
background: #727272;
color: #fff;
}
.btn-grey:hover {
background: #626262;
color: #fff;
}
.btn-grouped {
display: flex;
gap: 50px;
}
.clickable {
cursor: pointer;
}
.loader {
position: relative;
margin: 0px auto;
width: 200px;
height: 200px;
transform: scale(0.5);
}
.loader:before {
content: '';
display: block;
padding-top: 100%;
}
.circular-loader {
-webkit-animation: rotate 2s linear infinite;
animation: rotate 2s linear infinite;
height: 100%;
-webkit-transform-origin: center center;
-ms-transform-origin: center center;
transform-origin: center center;
width: 100%;
position: absolute;
top: 0;
left: 0;
margin: auto;
}
.loader-path {
stroke-dasharray: 150, 200;
stroke-dashoffset: -10;
-webkit-animation: dash 1.5s ease-in-out infinite, color 6s ease-in-out infinite;
animation: dash 1.5s ease-in-out infinite, color 6s ease-in-out infinite;
stroke-linecap: round;
}
@-webkit-keyframes rotate {
100% {
-webkit-transform: rotate(360deg);
transform: rotate(360deg);
}
}
@keyframes rotate {
100% {
-webkit-transform: rotate(360deg);
transform: rotate(360deg);
}
}
@-webkit-keyframes dash {
0% {
stroke-dasharray: 1, 200;
stroke-dashoffset: 0;
}
50% {
stroke-dasharray: 89, 200;
stroke-dashoffset: -35;
}
100% {
stroke-dasharray: 89, 200;
stroke-dashoffset: -124;
}
}
@keyframes dash {
0% {
stroke-dasharray: 1, 200;
stroke-dashoffset: 0;
}
50% {
stroke-dasharray: 89, 200;
stroke-dashoffset: -35;
}
100% {
stroke-dasharray: 89, 200;
stroke-dashoffset: -124;
}
}
@-webkit-keyframes color {
0% {
stroke: #fff;
}
40% {
stroke: #fff;
}
66% {
stroke: #fff;
}
80%,
90% {
stroke: #fff;
}
}
@keyframes color {
0% {
stroke: #fff;
}
40% {
stroke: #fff;
}
66% {
stroke: #fff;
}
80%,
90% {
stroke: #fff;
}
}

View File

@@ -346,12 +346,17 @@
border: 0; border: 0;
border-radius: 0.25em; border-radius: 0.25em;
background: initial; background: initial;
background-color: #7066e0; background: hsl(var(--main-accent), 93%, 48%);
color: #fff; color: #fff;
transition: all .35s ease;
font-size: 1em; font-size: 1em;
} }
.swal2-styled.swal2-confirm:hover {
background: hsl(var(--main-accent), 93%, 42%);
color: #fff;
}
.swal2-styled.swal2-confirm:focus { .swal2-styled.swal2-confirm:focus {
box-shadow: 0 0 0 3px rgba(112, 102, 224, 0.5); box-shadow: 0 0 0 0px rgba(112, 102, 224, 0.0);
} }
.swal2-styled.swal2-deny { .swal2-styled.swal2-deny {
border: 0; border: 0;

View File

@@ -1,14 +1,13 @@
const path = require('path'); const path = require('path');
const fs = require('fs'); const fs = require('fs');
const configFolder = path.join(process.env['LOCALAPPDATA'], 'EZPPLauncher'); const configFolder = path.join(process.platform == "win32" ? process.env['LOCALAPPDATA'] : process.env['HOME'], 'EZPPLauncher');
if (!fs.existsSync(configFolder)) fs.mkdirSync(configFolder); if (!fs.existsSync(configFolder)) fs.mkdirSync(configFolder);
const configLocation = path.join(configFolder, `ezpplauncher.${path.basename(process.env['USERNAME'])}.cfg`); const configLocation = path.join(configFolder, `ezpplauncher.${path.basename(process.env['USERNAME'])}.cfg`);
if (!fs.existsSync(configLocation)) fs.writeFileSync(configLocation, ""); if (!fs.existsSync(configLocation)) fs.writeFileSync(configLocation, "");
async function get(key, defaultValue) { async function get(key, defaultValue) {
const fileStream = await fs.promises.readFile(configLocation, "utf-8"); const fileStream = await fs.promises.readFile(configLocation, "utf-8");
const lines = fileStream.split(/\r?\n/) const lines = fileStream.split(/\r?\n/)
@@ -47,4 +46,26 @@ async function set(key, value) {
await fs.promises.writeFile(configLocation, arr.join('\n')); await fs.promises.writeFile(configLocation, arr.join('\n'));
} }
module.exports = { get, set } async function remove(key) {
const configValues = new Map();
const fileStream = await fs.promises.readFile(configLocation, "utf-8");
const lines = fileStream.split(/\r?\n/)
for (const line of lines) {
if (line.includes('=')) {
const argsPair = line.split('=', 2);
const keyname = argsPair[0]
const value = argsPair[1];
configValues.set(keyname, value);
}
}
const arr = [];
for (var [storkey, storvalue] of configValues.entries()) {
if (storkey != key)
arr.push(`${storkey}=${storvalue}`);
}
await fs.promises.writeFile(configLocation, arr.join('\n'));
}
module.exports = { get, set, remove }

61
discordPresence.js Normal file
View File

@@ -0,0 +1,61 @@
const appInfo = require('./appInfo.js');
const DiscordAutoRPC = require("discord-auto-rpc");
const { app } = require('electron');
const DiscordRPC = require("discord-rpc").default;
const clientId = "1032772293220384808";
let client = undefined;
let lastState = "Idle in Launcher...";
let presenceEnabled = true;
let startDate = new Date();
const actionButtons = [
{
label: "Download the Launcher",
url: "https://git.ez-pp.farm/EZPPFarm/EZPPLauncher/releases/latest"
},
{
label: "Join EZPPFarm",
url: "https://ez-pp.farm/discord"
}
]
let lastActivity = {
details: " ",
state: lastState,
startTimestamp: startDate,
largeImageKey: "ezppfarm",
largeImageText: appInfo.appName + " " + appInfo.appVersion,
buttons: actionButtons,
instance: false,
};
module.exports = {
connect: () => {
if (client === undefined) {
client = new DiscordAutoRPC.AutoClient({ transport: "ipc" });
client.endlessLogin({ clientId: clientId });
client.once("ready", () => {
setInterval(() => {
if (lastActivity !== undefined)
lastActivity.state = lastState;
client.setActivity(presenceEnabled ? lastActivity : undefined);
}, 2500);
});
}
},
enablePresence: () => presenceEnabled = true,
disablePresence: () => presenceEnabled = false,
updateStartDate: () => startDate = new Date(),
updateState: (state) => lastState = state,
updateStatus: (details, osuVersion) => {
lastActivity = {
details: details ? details : " ",
state: lastState,
startTimestamp: startDate,
smallImageKey: osuVersion ? "osu" : " ",
smallImageText: osuVersion ? osuVersion : " ",
largeImageKey: "ezppfarm",
largeImageText: appInfo.appName + " " + appInfo.appVersion,
buttons: actionButtons,
instance: false,
}
}
}

10
ezppUtil.js Normal file
View File

@@ -0,0 +1,10 @@
const axios = require('axios').default;
const loginCheckEndpoint = 'https://ez-pp.farm/login/check';
const performLogin = async (username, password) => {
const result = await axios.post(loginCheckEndpoint, { username, password });
return result.data;
}
module.exports = { performLogin };

View File

@@ -7,6 +7,8 @@
<meta name="viewport" content="width=device-width, initial-scale=1" /> <meta name="viewport" content="width=device-width, initial-scale=1" />
<link rel="icon" type="image/png" href="../assets/logo.png" /> <link rel="icon" type="image/png" href="../assets/logo.png" />
<link href="../assets/mdb.min.css" rel="stylesheet" /> <link href="../assets/mdb.min.css" rel="stylesheet" />
<link href="../assets/launcher.css" rel="stylesheet" />
<link href="../assets/checkbox.css" rel="stylesheet" />
<style> <style>
* { * {
user-select: none; user-select: none;
@@ -19,35 +21,91 @@
oncontextmenu="return false;"> oncontextmenu="return false;">
<main> <main>
<div class="noselect"> <div class="noselect">
<div class="position-relative overflow-hidden p-3 p-md-5 m-md-3 text-center text-lg-end d-flex align-items-center justify-content-center" <div class="position-relative overflow-hidden p-1 w-100 text-center text-lg-end d-flex align-items-center justify-content-center"
style="border-radius: 0.5em;"> style="border-radius: 0.5em;">
<div class="position-relative overflow-hidden p-3 p-md-5 m-md-3"> <div class="launcher-window position-relative overflow-hidden">
<div class="container py-2 h-100"> <div class="container px-1 py-2 w-100 mw-100 h-100">
<div class="row d-flex justify-content-center align-items-center h-100"> <div class="row d-flex justify-content-center align-items-center h-100">
<div class="col col-xl-10"> <div id="loading-page" class="sections col col-xl-10">
<div class="card" style="border-radius: 1rem;"> <div class="launch-section flex-row">
<div class="row g-0"> <div class="server-logo">
<div class="card-body p-4 p-lg-5 text-black"> <img src="../assets/logo.png" height="120">
<div class="d-flex align-items-center mb-2 pb-1 text-white"> </div>
<span class="h1 fw-bold mb-0">EZPPLauncher</span> <div class="app-name">EZPPLauncher</div>
</div> </div>
<h5 class="fw-lighter fs-5 mb-3 pb-3 text-white text-start" <div class="loading-section">
style="letter-spacing: 1px;"> <div class="loading-indicator">
Launch osu! with connection to the EZPPFarm server <div class="loader">
</h5> <svg class="circular-loader" viewBox="25 25 50 50">
<div class="pt-1 mb-4"> <circle class="loader-path" cx="50" cy="50" r="20" fill="none"
<button id="launch-btn" class="btn btn-primary btn-lg btn-block" stroke="#fff" stroke-width="2" />
type="button" style="background-color:#d6016f" disabled>Looking for </svg>
updates...</button>
</div>
<button class="btn btn-dark btn-sm float-start" id="account-btn" disabled>
set account
</button>
<button class="btn btn-dark btn-sm float-end" id="folder-btn">
set osu! directory
</button>
</div> </div>
</div> </div>
<div class="loading-indicator-text">Loading... Please wait</div>
</div>
</div>
<div id="launch-page" class="sections col col-xl-10" style="display: none;">
<div class="account-section">
<div class="user-image">
</div>
<div class="user-info">
<div class="welcome-text" id="welcome-text">
Nice to see you!
</div>
<div class="account-action" id="account-action">
Click to login
</div>
</div>
</div>
<div class="launch-section">
<div class="server-logo">
<img src="../assets/logo.png" height="150">
</div>
<div class="launch-button-section">
<button class="btn btn-lg btn-launch btn-accent" id="launch-btn">Launch</button>
<div class="patch-checkbox" style="display: none;">
<input type="checkbox" id="enablePatching" disabled />
<label for="enablePatching" style="display: initial;">enable
Patching</label>
</div>
</div>
</div>
<div class="folder-section">
<div class="folder-location">
Current osu! directory: <span id="currentOsuPath"></span>
</div>
<div class="folder-action" id="change-folder-btn">
Not correct?
</div>
</div>
</div>
<div id="login-page" class="sections col col-xl-10" style="display: none;">
<div class="launch-section flex-row">
<div class="server-logo">
<img src="../assets/logo.png" height="120">
</div>
<div class="app-name">EZPPLauncher</div>
</div>
<div class="login-section">
<div class="form-outline mb-3 w-50">
<input type="text" id="login-username" class="form-control form-control-lg" />
<label class="form-label" for="login-username">Username</label>
</div>
<div class="form-outline mb-3 w-50">
<input type="password" id="login-password"
class="form-control form-control-lg" />
<label class="form-label" for="login-password">Password</label>
</div>
<div class="pt-1 mb-4">
<div class="btn-grouped">
<button id="action-cancel" class="btn btn-grey btn-lg"
type="button">Cancel</button>
<button id="action-login" class="btn btn-accent btn-lg"
type="button">Login</button>
</div>
</div>
<p class="text-muted clickable" id="register">Don't have an account?</p>
</div> </div>
</div> </div>
</div> </div>
@@ -57,6 +115,7 @@
</div> </div>
</main> </main>
</body> </body>
<script type="text/javascript" src="../assets/mdb.min.js"></script> <script type="text/javascript" src="../assets/mdb.min.js"></script>
</html> </html>

62
html/index_old.html Normal file
View File

@@ -0,0 +1,62 @@
<!DOCTYPE html>
<html lang="en">
<head>
<title>EZPPLauncher</title>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link rel="icon" type="image/png" href="../assets/logo.png" />
<link href="../assets/mdb.min.css" rel="stylesheet" />
<style>
* {
user-select: none;
-webkit-user-select: none;
}
</style>
</head>
<body class="fixed-sn mdb-skin-custom" data-spy="scroll" data-target="#scrollspy" data-offset="15"
oncontextmenu="return false;">
<main>
<div class="noselect">
<div class="position-relative overflow-hidden p-3 p-md-5 m-md-3 text-center text-lg-end d-flex align-items-center justify-content-center"
style="border-radius: 0.5em;">
<div class="position-relative overflow-hidden p-3 p-md-5 m-md-3">
<div class="container py-2 h-100">
<div class="row d-flex justify-content-center align-items-center h-100">
<div class="col col-xl-10">
<div class="card" style="border-radius: 1rem;">
<div class="row g-0">
<div class="card-body p-4 p-lg-5 text-black">
<div class="d-flex align-items-center mb-2 pb-1 text-white">
<span class="h1 fw-bold mb-0">EZPPLauncher</span>
</div>
<h5 class="fw-lighter fs-5 mb-3 pb-3 text-white text-start"
style="letter-spacing: 1px;">
Launch osu! with connection to the EZPPFarm server
</h5>
<div class="pt-1 mb-4">
<button id="launch-btn" class="btn btn-primary btn-lg btn-block"
type="button" style="background-color:#d6016f" disabled>Looking for
updates...</button>
</div>
<button class="btn btn-dark btn-sm float-start" id="account-btn" disabled>
set account
</button>
<button class="btn btn-dark btn-sm float-end" id="folder-btn">
set osu! directory
</button>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</main>
</body>
<script type="text/javascript" src="../assets/mdb.min.js"></script>
</html>

17
osUtil.js Normal file
View File

@@ -0,0 +1,17 @@
const fs = require("fs");
const getLinuxDistroInfo = async() => {
let os = await fs.promises.readFile('/etc/os-release', 'utf8')
let opj = {}
os?.split('\n')?.forEach((line, index) => {
let words = line?.split('=')
let key = words[0]?.toLowerCase()
if (key === '') return
let value = words[1]?.replace(/"/g, '')
opj[key] = value
})
return opj;
}
module.exports = { getLinuxDistroInfo };

View File

@@ -8,6 +8,9 @@ const { EventEmitter } = require('events');
const { DownloaderHelper } = require('node-downloader-helper'); const { DownloaderHelper } = require('node-downloader-helper');
const checkUpdateURL = "https://osu.ppy.sh/web/check-updates.php?action=check&stream="; const checkUpdateURL = "https://osu.ppy.sh/web/check-updates.php?action=check&stream=";
const ignoredOsuEntities = [
'osu!auth.dll'
]
const osuEntities = [ const osuEntities = [
'avcodec-51.dll', 'avcodec-51.dll',
'avformat-52.dll', 'avformat-52.dll',
@@ -47,12 +50,12 @@ async function isValidOsuFolder(path) {
} }
async function getLatestConfig(osuPath) { async function getLatestConfig(osuPath) {
const allFiles = await fs.promises.readdir(osuPath);
const configFileInfo = { const configFileInfo = {
name: "", name: "",
path: "", path: "",
lastModified: 0,
get: async (key) => { get: async (key) => {
if (!configFileInfo.path)
return "";
const fileStream = await fs.promises.readFile(configFileInfo.path, "utf-8"); const fileStream = await fs.promises.readFile(configFileInfo.path, "utf-8");
const lines = fileStream.split(/\r?\n/) const lines = fileStream.split(/\r?\n/)
for (const line of lines) { for (const line of lines) {
@@ -67,17 +70,10 @@ async function getLatestConfig(osuPath) {
} }
} }
} }
for (const file of allFiles) { const userOsuConfig = path.join(osuPath, `osu!.${process.env['USERNAME']}.cfg`)
if (file.startsWith('osu!.') && file.endsWith('.cfg') && file !== "osu!.cfg") { if (fs.existsSync(userOsuConfig)) {
const fullFilePath = path.join(osuPath, file); configFileInfo.name = `osu!.${process.env['USERNAME']}.cfg`;
const fileStats = await fs.promises.stat(fullFilePath); configFileInfo.path = userOsuConfig;
const lastModified = fileStats.mtimeMs;
if (lastModified > configFileInfo.lastModified) {
configFileInfo.name = file;
configFileInfo.path = fullFilePath;
configFileInfo.lastModified = lastModified;
}
}
} }
return configFileInfo; return configFileInfo;
} }
@@ -94,6 +90,8 @@ async function filesThatNeedUpdate(osuPath, updateFiles) {
const fileHash = updatedFile.file_hash; const fileHash = updatedFile.file_hash;
const fileURL = updatedFile.url_full; const fileURL = updatedFile.url_full;
if (ignoredOsuEntities.includes(fileName)) continue;
const fileOnDisk = path.join(osuPath, fileName); const fileOnDisk = path.join(osuPath, fileName);
if (await fu.existsAsync(fileOnDisk)) { if (await fu.existsAsync(fileOnDisk)) {
const binaryFileContents = await fs.promises.readFile(fileOnDisk); const binaryFileContents = await fs.promises.readFile(fileOnDisk);
@@ -103,14 +101,12 @@ async function filesThatNeedUpdate(osuPath, updateFiles) {
fileName, fileName,
fileURL fileURL
}) })
// console.log("hashes are not matching", `(${existingFileMD5} - ${fileHash})`);
} }
} else { } else {
filesToDownload.push({ filesToDownload.push({
fileName, fileName,
fileURL fileURL
}); });
// console.log("new file " + fileName);
} }
} }
return filesToDownload; return filesToDownload;
@@ -121,6 +117,7 @@ async function downloadUpdateFiles(osuPath, filesToUpdate) {
let completedIndex = 0; let completedIndex = 0;
filesToUpdate.forEach(async (fileToUpdate) => { filesToUpdate.forEach(async (fileToUpdate) => {
const filePath = path.join(osuPath, fileToUpdate.fileName); const filePath = path.join(osuPath, fileToUpdate.fileName);
console.log(filePath);
if (await fu.existsAsync(filePath)) if (await fu.existsAsync(filePath))
await fs.promises.rm(filePath); await fs.promises.rm(filePath);
@@ -133,6 +130,10 @@ async function downloadUpdateFiles(osuPath, filesToUpdate) {
if (completedIndex >= filesToUpdate.length) if (completedIndex >= filesToUpdate.length)
eventEmitter.emit('completed'); eventEmitter.emit('completed');
}); });
fileDownload.on('error', (err) => {
console.log(err);
eventEmitter.emit('error');
});
fileDownload.start().catch(err => console.error(err)); fileDownload.start().catch(err => console.error(err));
}); });
@@ -143,8 +144,53 @@ async function downloadUpdateFiles(osuPath, filesToUpdate) {
async function startWithDevServer(osuPath, serverDomain, onExit) { async function startWithDevServer(osuPath, serverDomain, onExit) {
const osuExe = path.join(osuPath, "osu!.exe"); const osuExe = path.join(osuPath, "osu!.exe");
if (!await fu.existsAsync(osuExe)) return false; if (!await fu.existsAsync(osuExe)) return false;
executeUtil.runFile(osuPath, osuExe, ["-devserver", serverDomain], onExit); switch (process.platform) {
return true; case "linux":
executeUtil.runFile(osuPath, 'osu-stable', ["-devserver", serverDomain], onExit);
return true;
case "win32":
executeUtil.runFile(osuPath, osuExe, ["-devserver", serverDomain], onExit);
return true;
}
return false;
} }
module.exports = { isValidOsuFolder, getLatestConfig, getUpdateFiles, filesThatNeedUpdate, downloadUpdateFiles, startOsuWithDevServer: startWithDevServer } async function setConfigValue(configPath, key, value) {
const configLines = new Array();
const fileStream = await fs.promises.readFile(configPath, "utf-8");
const lines = fileStream.split(/\r?\n/)
for (const line of lines) {
if (line.includes(' = ')) {
const argsPair = line.split(' = ', 2);
const keyname = argsPair[0].trim();
if (key == keyname) {
configLines.push(`${keyname} = ${value}`);
} else {
configLines.push(line);
}
} else {
configLines.push(line);
}
}
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,
findOsuInstallation
}

View File

@@ -1,6 +1,6 @@
{ {
"name": "ezpplauncher", "name": "ezpplauncher",
"version": "1.0.0", "version": "1.1.2",
"main": "app.js", "main": "app.js",
"license": "MIT", "license": "MIT",
"author": "HorizonCode", "author": "HorizonCode",
@@ -32,23 +32,27 @@
}, },
"scripts": { "scripts": {
"start": "electron .", "start": "electron .",
"pack-win": "electron-builder --x64", "rebuild": "electron-rebuild -f -w get-window-by-name",
"pack-win32": "electron-builder --ia32", "pack-win": "electron-builder --win --arm64 --x64",
"pack-winarm": "electron-builder --arm64", "pack-linux": "electron-builder --linux --arm64 --x64",
"pack-linux": "electron-builder --dir --linux --ia32 --arm64 --x64", "pack-mac": "electron-builder --mac --arm64 --x64",
"pack-mac": "electron-builder --dir --mac --ia32 --arm64 --x64",
"dist": "electron-builder" "dist": "electron-builder"
}, },
"devDependencies": { "devDependencies": {
"electron": "^17.4.3", "electron": "^24.2.0",
"electron-builder": "^23.0.3", "electron-builder": "^23.6.0",
"electron-packager": "^15.5.1" "electron-packager": "^17.1.1",
"electron-rebuild": "^3.2.9"
}, },
"dependencies": { "dependencies": {
"axios": "^0.27.2", "axios": "^0.27.2",
"custom-electron-titlebar": "^4.1.1", "custom-electron-titlebar": "^4.1.1",
"discord-auto-rpc": "^1.0.17",
"discord-rpc": "^4.0.1",
"get-window-by-name": "^2.0.0",
"jquery": "^3.6.0", "jquery": "^3.6.0",
"node-downloader-helper": "^2.1.4", "node-downloader-helper": "^2.1.4",
"qiao-regedit": "^0.1.5",
"sweetalert2": "^11.5.2" "sweetalert2": "^11.5.2"
} }
} }

View File

@@ -2,10 +2,12 @@ const { ipcRenderer } = require('electron');
const { Titlebar, Color } = require('custom-electron-titlebar'); const { Titlebar, Color } = require('custom-electron-titlebar');
const appInfo = require('../appInfo'); const appInfo = require('../appInfo');
let titlebar; let titlebar;
let currentPage = "loading";
let loggedIn = false;
window.addEventListener('DOMContentLoaded', () => { window.addEventListener('DOMContentLoaded', () => {
titlebar = new Titlebar({ titlebar = new Titlebar({
backgroundColor: Color.fromHex("#303030"), backgroundColor: Color.fromHex("#24283B"),
itemBackgroundColor: Color.fromHex("#121212"), itemBackgroundColor: Color.fromHex("#121212"),
menu: null, menu: null,
maximizable: false maximizable: false
@@ -16,8 +18,31 @@ window.addEventListener('DOMContentLoaded', () => {
const $ = require('jquery'); const $ = require('jquery');
const Swal = require('sweetalert2'); const Swal = require('sweetalert2');
let currentState; $('#account-action').on('click', () => {
if (!loggedIn) {
changePage('login');
} else {
$('#welcome-text').text(`Nice to see you!`);
$('#account-action').text('Click to login');
$('.user-image').css('background-image', `url(https://a.ez-pp.farm/0)`)
loggedIn = false;
ipcRenderer.send("perform-logout");
Swal.fire({
title: 'See ya soon!',
text: "Successfully logged out!",
icon: 'success',
confirmButtonText: 'Okay'
});
}
});
$('#action-cancel').on('click', () => {
if (!loggedIn) {
changePage('launch');
}
});
let currentState;
$("#launch-btn").on('click', async () => { $("#launch-btn").on('click', async () => {
switch (currentState) { switch (currentState) {
case "up-to-date": case "up-to-date":
@@ -43,20 +68,71 @@ window.addEventListener('DOMContentLoaded', () => {
$('#launch-btn').html('Updating...'); $('#launch-btn').html('Updating...');
ipcRenderer.send("do-update"); ipcRenderer.send("do-update");
break; break;
case "missing-folder":
const responseData = await ipcRenderer.invoke('set-osu-dir');
if (!responseData)
return;
if (responseData.validOsuDir) {
Swal.fire({
title: 'Success!',
text: 'osu! folder set.',
icon: 'success',
confirmButtonText: 'Cool'
})
$('#currentOsuPath').text(responseData.folderPath);
ipcRenderer.send("do-update-check");
} else {
Swal.fire({
title: 'Uh oh!',
text: 'The selected folder is not a osu! directory.',
icon: 'error',
confirmButtonText: 'Oops.. my bad!'
})
}
break;
} }
}); });
$("#folder-btn").on('click', async () => { $("#action-login").on('click', async () => {
const success = await ipcRenderer.invoke('set-osu-dir'); const username = $('#login-username').val();
if (success == undefined) const password = $('#login-password').val();
$("#action-login").attr('disabled', true);
$("#action-cancel").attr('disabled', true);
const responseData = await ipcRenderer.invoke('perform-login', { username, password });
$("#action-login").attr('disabled', false);
$("#action-cancel").attr('disabled', false);
if (!responseData)
return; return;
if (success) { if (responseData.code != 200) {
Swal.fire({
title: 'Uh oh!',
text: responseData.message,
icon: 'error',
confirmButtonText: 'Oops.. my bad!'
})
return;
}
$('#login-username').val("");
$('#login-password').val("");
$('#welcome-text').text(`Welcome back, ${responseData.user.name}!`);
$('#account-action').text('Not you?');
$('.user-image').css('background-image', `url(https://a.ez-pp.farm/${responseData.user.id})`);
loggedIn = true;
changePage('launch');
})
$("#change-folder-btn").on('click', async () => {
const responseData = await ipcRenderer.invoke('set-osu-dir');
if (!responseData)
return;
if (responseData.validOsuDir) {
Swal.fire({ Swal.fire({
title: 'Success!', title: 'Success!',
text: 'osu! folder set.', text: 'osu! folder set.',
icon: 'success', icon: 'success',
confirmButtonText: 'Cool' confirmButtonText: 'Cool'
}) })
$('#currentOsuPath').text(responseData.folderPath);
ipcRenderer.send("do-update-check"); ipcRenderer.send("do-update-check");
} else { } else {
Swal.fire({ Swal.fire({
@@ -68,19 +144,43 @@ window.addEventListener('DOMContentLoaded', () => {
} }
}); });
ipcRenderer.on('config_update', (event, data) => {
if (data.osuPath) {
$('#currentOsuPath').text(data.osuPath);
}
})
ipcRenderer.on('account_update', (event, data) => {
switch (data.type) {
case "not-loggedin":
changePage("launch");
break;
case "loggedin":
changePage("launch");
$('#welcome-text').text(`Welcome back, ${data.user.name}!`);
$('#account-action').text('Not you?');
$('.user-image').css('background-image', `url(https://a.ez-pp.farm/${data.user.id})`);
loggedIn = true;
break;
}
})
ipcRenderer.on('status_update', (event, status) => { ipcRenderer.on('status_update', (event, status) => {
currentState = status.type;
switch (status.type) { switch (status.type) {
case "up-to-date": case "up-to-date":
$("#launch-btn").attr('disabled', false); $("#launch-btn").attr('disabled', false);
$('#launch-btn').html('Launch'); $('#launch-btn').html('Launch');
currentState = status.type;
break; break;
case "update-available": case "update-available":
$("#launch-btn").attr('disabled', false); $("#launch-btn").attr('disabled', false);
$('#launch-btn').html('Update'); $('#launch-btn').html('Update');
currentState = status.type;
break; break;
case "missing-folder": case "missing-folder":
$('#launch-btn').html('Please set your osu! folder'); $("#launch-btn").attr('disabled', false);
$('#launch-btn').html('set your osu! folder');
currentState = status.type;
break; break;
case "error": case "error":
Swal.fire({ Swal.fire({
@@ -91,6 +191,24 @@ window.addEventListener('DOMContentLoaded', () => {
}); });
ipcRenderer.send("do-update-check"); ipcRenderer.send("do-update-check");
break; break;
case "info":
Swal.fire({
title: 'Info!',
text: status.message,
icon: 'info',
confirmButtonText: 'Okay'
});
break;
case "package-issue":
Swal.fire({
title: 'Uh oh!',
text: status.message,
icon: 'error',
confirmButtonText: 'Okay'
});
$("#launch-btn").attr('disabled', true);
$('#launch-btn').html('missing packages');
break;
case "update-complete": case "update-complete":
Swal.fire({ Swal.fire({
title: 'Yaaay!', title: 'Yaaay!',
@@ -103,6 +221,13 @@ window.addEventListener('DOMContentLoaded', () => {
} }
}) })
function changePage(page) {
$(`#${currentPage}-page`).fadeOut(50, "swing", () => {
$(`#${page}-page`).fadeIn(350);
});
currentPage = page;
}
// workaround for the dark theme // workaround for the dark theme
$('head').append($('<link href="../assets/sweetalert2.dark.css" rel="stylesheet" />')); $('head').append($('<link href="../assets/sweetalert2.dark.css" rel="stylesheet" />'));
}) })

BIN
preview/EZPPLauncher.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 49 KiB

16
terminalUtil.js Normal file
View File

@@ -0,0 +1,16 @@
const exec = require('child_process').exec;
const execPromise = function (cmd) {
return new Promise(function (resolve, reject) {
exec(cmd, function (err, stdout) {
if (err) return reject(err);
resolve(stdout);
});
});
}
const execCommand = async (command) => {
return await execPromise(command);
}
module.exports = { execCommand };

View File

@@ -12,7 +12,7 @@ module.exports = {
minWidth: windowWidth / 1.25, minWidth: windowWidth / 1.25,
frame: false, frame: false,
titleBarStyle: 'hidden', titleBarStyle: 'hidden',
backgroundColor: "#121212", backgroundColor: "#24283B",
resizable: false, resizable: false,
maximizable: false, maximizable: false,
minimizable: true, minimizable: true,
@@ -34,9 +34,6 @@ module.exports = {
window.webContents.setUserAgent(`${appInfo.appName} ${appInfo.appVersion}`); window.webContents.setUserAgent(`${appInfo.appName} ${appInfo.appVersion}`);
attachTitlebarToWindow(window); attachTitlebarToWindow(window);
// window.webContents.openDevTools({
// mode: "detach"
// });
return window; return window;
}, },