Compare commits
21 Commits
da1b05c9a1
...
1.1.4
Author | SHA1 | Date | |
---|---|---|---|
769a88521e | |||
f5287b6378 | |||
dd6866f680 | |||
cb1a05d58c | |||
fdfedab77f | |||
fc284e08f0 | |||
361db1df17 | |||
0a664d1f64 | |||
232043d686 | |||
10a4c540dd | |||
b111cf4fa4 | |||
e2713179c8 | |||
92ee92d636 | |||
b3463378e9 | |||
00e3e80d43 | |||
2df9f533fe | |||
cc93e24ab6 | |||
48cd81f28d | |||
068d02f1f7 | |||
e725592ef1 | |||
6bc0b215d7 |
65
app.js
65
app.js
@@ -1,14 +1,17 @@
|
||||
const { app, BrowserWindow, ipcMain, dialog } = require('electron');
|
||||
const { setupTitlebar, attachTitlebarToWindow } = require('custom-electron-titlebar/main');
|
||||
const { app, BrowserWindow, ipcMain, dialog, Tray, Menu } = require('electron');
|
||||
const { setupTitlebar } = require('custom-electron-titlebar/main');
|
||||
const windowManager = require('./ui/windowManager');
|
||||
const osuUtil = require('./osuUtil');
|
||||
const ezppUtil = require('./ezppUtil');
|
||||
const config = require('./config');
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const rpc = require('./discordPresence');
|
||||
const windowName = require('get-window-by-name');
|
||||
const terminalUtil = require('./terminalUtil');
|
||||
const osUtil = require('./osUtil');
|
||||
const appInfo = require('./appInfo');
|
||||
const { DownloaderHelper } = require('node-downloader-helper');
|
||||
|
||||
let tempOsuPath;
|
||||
let osuWindowInfo;
|
||||
@@ -91,7 +94,7 @@ const run = () => {
|
||||
rpcOsuVersion = splitArray[0];
|
||||
currentMap = splitArray[1];
|
||||
if (currentMap.endsWith(".osu")) {
|
||||
rpc.updateState("Editing...");
|
||||
rpc.updateState("Editing/Modding...");
|
||||
currentMap = currentMap.substring(0, currentMap.length - 4);
|
||||
}
|
||||
else rpc.updateState("Playing...");
|
||||
@@ -119,10 +122,43 @@ const run = () => {
|
||||
|
||||
|
||||
let mainWindow;
|
||||
app.whenReady().then(() => {
|
||||
let tray = null
|
||||
app.whenReady().then(async () => {
|
||||
const logoFile = path.join(config.configFolder, "logo.png");
|
||||
if (!fs.existsSync(logoFile)) {
|
||||
const logoDownload = new DownloaderHelper("https://ez-pp.farm/assets/img/icon.png", config.configFolder, {
|
||||
fileName: "logo.png",
|
||||
})
|
||||
await logoDownload.start();
|
||||
}
|
||||
tray = new Tray(logoFile);
|
||||
const trayMenuTemplate = [
|
||||
{
|
||||
label: `EZPPLauncher ${appInfo.appVersion}`,
|
||||
enabled: false
|
||||
},
|
||||
|
||||
{
|
||||
label: "Show/Hide",
|
||||
click: function () {
|
||||
if (mainWindow.isVisible()) mainWindow.hide();
|
||||
else mainWindow.show();
|
||||
}
|
||||
},
|
||||
|
||||
{
|
||||
label: 'Exit',
|
||||
click: function () {
|
||||
app.exit(0);
|
||||
}
|
||||
}
|
||||
]
|
||||
|
||||
let trayMenu = Menu.buildFromTemplate(trayMenuTemplate)
|
||||
tray.setContextMenu(trayMenu)
|
||||
|
||||
mainWindow = createWindow();
|
||||
mainWindow.on('show', async () => {
|
||||
mainWindow.once('show', async () => {
|
||||
await updateConfigVars(mainWindow);
|
||||
await tryLogin(mainWindow);
|
||||
await doUpdateCheck(mainWindow);
|
||||
@@ -161,7 +197,7 @@ const run = () => {
|
||||
const osuFolder = await config.get("osuPath");
|
||||
if (!osuFolder || osuFolder == "") {
|
||||
const foundFolder = await osuUtil.findOsuInstallation();
|
||||
console.log("osu! Installation located at: ",foundFolder);
|
||||
console.log("osu! Installation located at: ", foundFolder);
|
||||
}
|
||||
}
|
||||
})
|
||||
@@ -187,10 +223,10 @@ const run = () => {
|
||||
}
|
||||
rpc.updateState("Launching osu!...");
|
||||
isIngame = true;
|
||||
mainWindow.hide();
|
||||
if (mainWindow.isVisible()) mainWindow.hide();
|
||||
const result = await osuUtil.startOsuWithDevServer(tempOsuPath, "ez-pp.farm", async () => {
|
||||
isIngame = false;
|
||||
mainWindow.show();
|
||||
if (!mainWindow.isVisible()) mainWindow.show();
|
||||
await doUpdateCheck(mainWindow);
|
||||
});
|
||||
return result;
|
||||
@@ -285,10 +321,13 @@ async function tryLogin(window) {
|
||||
window.webContents.send('account_update', {
|
||||
type: "loggedin",
|
||||
user: loginResponse.user
|
||||
})
|
||||
});
|
||||
} else {
|
||||
await config.remove("username");
|
||||
await config.remove("password");
|
||||
window.webContents.send('account_update', {
|
||||
type: "login-failed"
|
||||
type: "login-failed",
|
||||
message: loginResponse.message
|
||||
})
|
||||
}
|
||||
} else {
|
||||
@@ -296,6 +335,11 @@ async function tryLogin(window) {
|
||||
type: "not-loggedin"
|
||||
})
|
||||
}
|
||||
|
||||
const checkUpdate = await appInfo.hasUpdate();
|
||||
if (checkUpdate) {
|
||||
window.webContents.send('launcher_update', checkUpdate);
|
||||
}
|
||||
}
|
||||
|
||||
async function doUpdateCheck(window) {
|
||||
@@ -340,7 +384,6 @@ function createWindow() {
|
||||
|
||||
win.loadFile('./html/index.html');
|
||||
|
||||
attachTitlebarToWindow(win);
|
||||
win.webContents.setWindowOpenHandler(() => "deny");
|
||||
win.webContents.on('did-finish-load', function () {
|
||||
if (win.webContents.getZoomFactor() != 0.9)
|
||||
|
22
appInfo.js
22
appInfo.js
@@ -1,4 +1,20 @@
|
||||
const appName = "EZPPLauncher"
|
||||
const appVersion = "1.1.1";
|
||||
const { default: axios } = require("axios");
|
||||
const { compareVersions } = require("compare-versions");
|
||||
|
||||
module.exports = { appName, appVersion };
|
||||
const appName = "EZPPLauncher"
|
||||
const appVersion = "1.1.4";
|
||||
|
||||
const hasUpdate = async () => {
|
||||
const releaseInfo = await axios.get(`https://git.ez-pp.farm/api/v1/repos/EZPPFarm/${appName}/releases/latest`);
|
||||
if (releaseInfo.status !== 200) return false;
|
||||
const latestReleaseVersion = releaseInfo.data.tag_name;
|
||||
const updateAvailable = compareVersions(latestReleaseVersion, appVersion);
|
||||
if(updateAvailable > 0)
|
||||
return {
|
||||
version: latestReleaseVersion,
|
||||
url: releaseInfo.data.html_url,
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
|
||||
module.exports = { appName, appVersion, hasUpdate };
|
@@ -68,4 +68,4 @@ async function remove(key) {
|
||||
await fs.promises.writeFile(configLocation, arr.join('\n'));
|
||||
}
|
||||
|
||||
module.exports = { get, set, remove }
|
||||
module.exports = { get, set, remove, configFolder }
|
@@ -1,28 +1,27 @@
|
||||
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: [
|
||||
{
|
||||
label: "Download the Launcher",
|
||||
url: "https://ez-pp.farm/download"
|
||||
},
|
||||
{
|
||||
label: "Join EZPPFarm",
|
||||
url: "https://discord.com/invite/g8Bh7RaKPg"
|
||||
}
|
||||
],
|
||||
buttons: actionButtons,
|
||||
instance: false,
|
||||
};
|
||||
|
||||
@@ -53,16 +52,7 @@ module.exports = {
|
||||
smallImageText: osuVersion ? osuVersion : " ",
|
||||
largeImageKey: "ezppfarm",
|
||||
largeImageText: appInfo.appName + " " + appInfo.appVersion,
|
||||
buttons: [
|
||||
{
|
||||
label: "Download the Launcher",
|
||||
url: "https://ez-pp.farm/download"
|
||||
},
|
||||
{
|
||||
label: "Join EZPPFarm",
|
||||
url: "https://discord.com/invite/g8Bh7RaKPg"
|
||||
}
|
||||
],
|
||||
buttons: actionButtons,
|
||||
instance: false,
|
||||
}
|
||||
}
|
||||
|
10
ezppUtil.js
10
ezppUtil.js
@@ -1,10 +1,18 @@
|
||||
const axios = require('axios').default;
|
||||
|
||||
const loginCheckEndpoint = 'https://new.ez-pp.farm/login/check';
|
||||
const loginCheckEndpoint = 'https://ez-pp.farm/login/check';
|
||||
let retries = 0;
|
||||
|
||||
const performLogin = async (username, password) => {
|
||||
const result = await axios.post(loginCheckEndpoint, { username, password });
|
||||
const code = result.data.code ?? 404;
|
||||
if (code === 200 || code === 403) {
|
||||
retries = 0;
|
||||
return result.data;
|
||||
} else {
|
||||
if (retries++ >= 5) return { code: 403, message: "Login failed." }
|
||||
return await performLogin(username, password);
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = { performLogin };
|
@@ -64,9 +64,10 @@
|
||||
</div>
|
||||
<div class="launch-button-section">
|
||||
<button class="btn btn-lg btn-launch btn-accent" id="launch-btn">Launch</button>
|
||||
<div class="patch-checkbox">
|
||||
<input type="checkbox" id="enablePatching" disabled/>
|
||||
<label for="enablePatching" style="display: initial;">enable Patching</label>
|
||||
<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>
|
||||
@@ -114,6 +115,7 @@
|
||||
</div>
|
||||
</main>
|
||||
</body>
|
||||
|
||||
<script type="text/javascript" src="../assets/mdb.min.js"></script>
|
||||
|
||||
</html>
|
@@ -1,62 +0,0 @@
|
||||
<!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>
|
@@ -8,6 +8,9 @@ const { EventEmitter } = require('events');
|
||||
const { DownloaderHelper } = require('node-downloader-helper');
|
||||
|
||||
const checkUpdateURL = "https://osu.ppy.sh/web/check-updates.php?action=check&stream=";
|
||||
const ignoredOsuEntities = [
|
||||
'osu!auth.dll'
|
||||
]
|
||||
const osuEntities = [
|
||||
'avcodec-51.dll',
|
||||
'avformat-52.dll',
|
||||
@@ -87,6 +90,8 @@ async function filesThatNeedUpdate(osuPath, updateFiles) {
|
||||
const fileHash = updatedFile.file_hash;
|
||||
const fileURL = updatedFile.url_full;
|
||||
|
||||
if (ignoredOsuEntities.includes(fileName)) continue;
|
||||
|
||||
const fileOnDisk = path.join(osuPath, fileName);
|
||||
if (await fu.existsAsync(fileOnDisk)) {
|
||||
const binaryFileContents = await fs.promises.readFile(fileOnDisk);
|
||||
@@ -96,14 +101,12 @@ async function filesThatNeedUpdate(osuPath, updateFiles) {
|
||||
fileName,
|
||||
fileURL
|
||||
})
|
||||
//console.log("hashes are not matching", `(${existingFileMD5} - ${fileHash})`);
|
||||
}
|
||||
} else {
|
||||
filesToDownload.push({
|
||||
fileName,
|
||||
fileURL
|
||||
});
|
||||
//console.log("new file " + fileName);
|
||||
}
|
||||
}
|
||||
return filesToDownload;
|
||||
|
19
package.json
19
package.json
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "ezpplauncher",
|
||||
"version": "1.1.1",
|
||||
"version": "1.1.4",
|
||||
"main": "app.js",
|
||||
"license": "MIT",
|
||||
"author": "HorizonCode",
|
||||
@@ -22,7 +22,7 @@
|
||||
"runAfterFinish": true
|
||||
},
|
||||
"portable": {
|
||||
"artifactName": "EZPPLauncher.exe"
|
||||
"artifactName": "ezpplauncher-${version}.exe"
|
||||
}
|
||||
},
|
||||
"frontend": {
|
||||
@@ -33,21 +33,20 @@
|
||||
"scripts": {
|
||||
"start": "electron .",
|
||||
"rebuild": "electron-rebuild -f -w get-window-by-name",
|
||||
"pack-win": "electron-builder --x64",
|
||||
"pack-win32": "electron-builder --ia32",
|
||||
"pack-winarm": "electron-builder --arm64",
|
||||
"pack-linux": "electron-builder --dir --linux --ia32 --arm64 --x64",
|
||||
"pack-mac": "electron-builder --dir --mac --ia32 --arm64 --x64",
|
||||
"pack-win": "electron-builder --win --x64",
|
||||
"pack-linux": "electron-builder --linux --x64",
|
||||
"pack-mac": "electron-builder --mac --x64",
|
||||
"dist": "electron-builder"
|
||||
},
|
||||
"devDependencies": {
|
||||
"electron": "^21.1.1",
|
||||
"electron-builder": "^23.0.3",
|
||||
"electron-packager": "^15.5.1",
|
||||
"electron": "^24.2.0",
|
||||
"electron-builder": "^23.6.0",
|
||||
"electron-packager": "^17.1.1",
|
||||
"electron-rebuild": "^3.2.9"
|
||||
},
|
||||
"dependencies": {
|
||||
"axios": "^0.27.2",
|
||||
"compare-versions": "^6.0.0-rc.1",
|
||||
"custom-electron-titlebar": "^4.1.1",
|
||||
"discord-auto-rpc": "^1.0.17",
|
||||
"discord-rpc": "^4.0.1",
|
||||
|
@@ -1,16 +1,16 @@
|
||||
const { ipcRenderer } = require('electron');
|
||||
const { Titlebar, Color } = require('custom-electron-titlebar');
|
||||
const { ipcRenderer, shell } = require('electron');
|
||||
const { Titlebar, TitlebarColor } = require('custom-electron-titlebar');
|
||||
const appInfo = require('../appInfo');
|
||||
let titlebar;
|
||||
let currentPage = "loading";
|
||||
let loggedIn = false;
|
||||
|
||||
window.addEventListener('DOMContentLoaded', () => {
|
||||
titlebar = new Titlebar({
|
||||
backgroundColor: Color.fromHex("#24283B"),
|
||||
itemBackgroundColor: Color.fromHex("#121212"),
|
||||
const titlebar = new Titlebar({
|
||||
backgroundColor: TitlebarColor.fromHex("#24283B"),
|
||||
itemBackgroundColor: TitlebarColor.fromHex("#121212"),
|
||||
menu: null,
|
||||
maximizable: false
|
||||
enableMnemonics: false,
|
||||
maximizable: false,
|
||||
});
|
||||
|
||||
titlebar.updateTitle(`${appInfo.appName} ${appInfo.appVersion}`);
|
||||
@@ -150,8 +150,31 @@ window.addEventListener('DOMContentLoaded', () => {
|
||||
}
|
||||
})
|
||||
|
||||
ipcRenderer.on('launcher_update', async (event, data) => {
|
||||
const res = await Swal.fire({
|
||||
title: 'Update available!',
|
||||
text: `Version ${data.version} has been released!`,
|
||||
icon: 'info',
|
||||
showCancelButton: true,
|
||||
confirmButtonText: 'Download',
|
||||
cancelButtonText: 'Remind me later',
|
||||
});
|
||||
if (res.isConfirmed) {
|
||||
shell.openExternal(data.url);
|
||||
}
|
||||
})
|
||||
|
||||
ipcRenderer.on('account_update', (event, data) => {
|
||||
switch (data.type) {
|
||||
case "login-failed":
|
||||
Swal.fire({
|
||||
title: 'Uh oh!',
|
||||
text: data.message,
|
||||
icon: 'error',
|
||||
confirmButtonText: 'Okay'
|
||||
});
|
||||
changePage("launch");
|
||||
break;
|
||||
case "not-loggedin":
|
||||
changePage("launch");
|
||||
break;
|
||||
|
@@ -1,6 +1,6 @@
|
||||
const path = require("path");
|
||||
const appInfo = require('../appInfo');
|
||||
const { BrowserWindow } = require('electron');
|
||||
const { BrowserWindow, Menu } = require('electron');
|
||||
const { attachTitlebarToWindow } = require('custom-electron-titlebar/main');
|
||||
|
||||
module.exports = {
|
||||
@@ -26,6 +26,10 @@ module.exports = {
|
||||
},
|
||||
icon: './assets/logo.png'
|
||||
})
|
||||
|
||||
const menu = Menu.buildFromTemplate([])
|
||||
Menu.setApplicationMenu(menu);
|
||||
|
||||
window.hide();
|
||||
|
||||
window.webContents.once("did-finish-load", function (event, input) {
|
||||
@@ -33,6 +37,7 @@ module.exports = {
|
||||
});
|
||||
|
||||
window.webContents.setUserAgent(`${appInfo.appName} ${appInfo.appVersion}`);
|
||||
|
||||
attachTitlebarToWindow(window);
|
||||
|
||||
return window;
|
||||
|
Reference in New Issue
Block a user