Compare commits
19 Commits
Author | SHA1 | Date | |
---|---|---|---|
f870b48b25 | |||
94db97ef30 | |||
7e2fe2ec96 | |||
7cba78b270 | |||
f6e5ead7ed | |||
7ed7d3045f | |||
37b7bbd2e3 | |||
47f86501b8 | |||
42777c9e0c | |||
769a88521e | |||
f5287b6378 | |||
dd6866f680 | |||
cb1a05d58c | |||
fdfedab77f | |||
fc284e08f0 | |||
361db1df17 | |||
0a664d1f64 | |||
232043d686 | |||
10a4c540dd |
50
.github/workflows/build.yml
vendored
Normal file
50
.github/workflows/build.yml
vendored
Normal file
@@ -0,0 +1,50 @@
|
|||||||
|
name: Compile and Release
|
||||||
|
|
||||||
|
on:
|
||||||
|
release:
|
||||||
|
types: [released]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build-linux:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
node-version: [20.x]
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
- name: Use Node.js ${{ matrix.node-version }}
|
||||||
|
uses: actions/setup-node@v3
|
||||||
|
with:
|
||||||
|
node-version: ${{ matrix.node-version }}
|
||||||
|
- run: npm ci
|
||||||
|
- run: npm run rebuild
|
||||||
|
- run: npm run pack-linux
|
||||||
|
- name: Add Artifact to Workflow
|
||||||
|
uses: actions/upload-artifact@v3
|
||||||
|
with:
|
||||||
|
name: artifact
|
||||||
|
path: |
|
||||||
|
release/*.AppImage
|
||||||
|
|
||||||
|
build-win:
|
||||||
|
runs-on: windows-latest
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
node-version: [20.x]
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
- name: Use Node.js ${{ matrix.node-version }}
|
||||||
|
uses: actions/setup-node@v3
|
||||||
|
with:
|
||||||
|
node-version: ${{ matrix.node-version }}
|
||||||
|
- run: npm ci
|
||||||
|
- run: npm run rebuild
|
||||||
|
- run: npm run pack-win
|
||||||
|
- name: Add Artifact to Workflow
|
||||||
|
uses: actions/upload-artifact@v3
|
||||||
|
with:
|
||||||
|
name: artifact
|
||||||
|
path: |
|
||||||
|
release/*.exe
|
17
.vscode/launch.json
vendored
Normal file
17
.vscode/launch.json
vendored
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
{
|
||||||
|
"version": "0.2.0",
|
||||||
|
"configurations": [
|
||||||
|
{
|
||||||
|
"name": "Debug Main Process",
|
||||||
|
"type": "node",
|
||||||
|
"request": "launch",
|
||||||
|
"cwd": "${workspaceFolder}",
|
||||||
|
"runtimeExecutable": "${workspaceFolder}/node_modules/.bin/electron",
|
||||||
|
"windows": {
|
||||||
|
"runtimeExecutable": "${workspaceFolder}/node_modules/.bin/electron.cmd"
|
||||||
|
},
|
||||||
|
"args" : ["."],
|
||||||
|
"outputCapture": "std"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
81
app.js
81
app.js
@@ -1,14 +1,17 @@
|
|||||||
const { app, BrowserWindow, ipcMain, dialog } = require('electron');
|
const { app, BrowserWindow, ipcMain, dialog, Tray, Menu } = require('electron');
|
||||||
const { setupTitlebar, attachTitlebarToWindow } = require('custom-electron-titlebar/main');
|
const { setupTitlebar } = 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 ezppUtil = require('./ezppUtil');
|
||||||
const config = require('./config');
|
const config = require('./config');
|
||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
|
const path = require('path');
|
||||||
const rpc = require('./discordPresence');
|
const rpc = require('./discordPresence');
|
||||||
const windowName = require('get-window-by-name');
|
const windowName = require('get-window-by-name');
|
||||||
const terminalUtil = require('./terminalUtil');
|
const terminalUtil = require('./terminalUtil');
|
||||||
const osUtil = require('./osUtil');
|
const osUtil = require('./osUtil');
|
||||||
|
const appInfo = require('./appInfo');
|
||||||
|
const { DownloaderHelper } = require('node-downloader-helper');
|
||||||
|
|
||||||
let tempOsuPath;
|
let tempOsuPath;
|
||||||
let osuWindowInfo;
|
let osuWindowInfo;
|
||||||
@@ -117,12 +120,48 @@ const run = () => {
|
|||||||
|
|
||||||
rpc.connect();
|
rpc.connect();
|
||||||
|
|
||||||
|
|
||||||
let mainWindow;
|
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 () {
|
||||||
|
if (isIngame) return;
|
||||||
|
app.exit(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
|
let trayMenu = Menu.buildFromTemplate(trayMenuTemplate)
|
||||||
|
tray.setContextMenu(trayMenu)
|
||||||
|
|
||||||
mainWindow = createWindow();
|
mainWindow = createWindow();
|
||||||
mainWindow.on('show', async () => {
|
mainWindow.on('close', (e) => {
|
||||||
|
if (isIngame) e.preventDefault();
|
||||||
|
});
|
||||||
|
mainWindow.once('show', async () => {
|
||||||
await updateConfigVars(mainWindow);
|
await updateConfigVars(mainWindow);
|
||||||
await tryLogin(mainWindow);
|
await tryLogin(mainWindow);
|
||||||
await doUpdateCheck(mainWindow);
|
await doUpdateCheck(mainWindow);
|
||||||
@@ -161,9 +200,14 @@ const run = () => {
|
|||||||
const osuFolder = await config.get("osuPath");
|
const osuFolder = await config.get("osuPath");
|
||||||
if (!osuFolder || osuFolder == "") {
|
if (!osuFolder || osuFolder == "") {
|
||||||
const foundFolder = await osuUtil.findOsuInstallation();
|
const foundFolder = await osuUtil.findOsuInstallation();
|
||||||
console.log("osu! Installation located at: ",foundFolder);
|
if (foundFolder && osuUtil.isValidOsuFolder(foundFolder)) {
|
||||||
|
mainWindow.webContents.send('alert_message', foundFolder);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
ipcMain.on("alert_response", async (event, path) => {
|
||||||
|
await config.set("osuPath", path);
|
||||||
})
|
})
|
||||||
app.on('activate', function () {
|
app.on('activate', function () {
|
||||||
if (BrowserWindow.getAllWindows().length === 0) mainWindow = createWindow();
|
if (BrowserWindow.getAllWindows().length === 0) mainWindow = createWindow();
|
||||||
@@ -172,6 +216,8 @@ const run = () => {
|
|||||||
app.quit()
|
app.quit()
|
||||||
})
|
})
|
||||||
ipcMain.handle('launch', async () => {
|
ipcMain.handle('launch', async () => {
|
||||||
|
const osuFolder = await config.get("osuPath");
|
||||||
|
await osuUtil.updateOsuCfg(path.join(osuFolder, "osu!.cfg"));
|
||||||
const osuConfig = await osuUtil.getLatestConfig(tempOsuPath);
|
const osuConfig = await osuUtil.getLatestConfig(tempOsuPath);
|
||||||
const username = await config.get('username');
|
const username = await config.get('username');
|
||||||
const password = await config.get('password');
|
const password = await config.get('password');
|
||||||
@@ -185,13 +231,19 @@ const run = () => {
|
|||||||
await osuUtil.setConfigValue(osuConfig.path, "Username", "");
|
await osuUtil.setConfigValue(osuConfig.path, "Username", "");
|
||||||
await osuUtil.setConfigValue(osuConfig.path, "Password", "");
|
await osuUtil.setConfigValue(osuConfig.path, "Password", "");
|
||||||
}
|
}
|
||||||
|
await osuUtil.replaceUI(osuFolder, true);
|
||||||
rpc.updateState("Launching osu!...");
|
rpc.updateState("Launching osu!...");
|
||||||
isIngame = true;
|
isIngame = true;
|
||||||
mainWindow.hide();
|
mainWindow.closable = false;
|
||||||
|
if (mainWindow.isVisible()) mainWindow.hide();
|
||||||
const result = await osuUtil.startOsuWithDevServer(tempOsuPath, "ez-pp.farm", async () => {
|
const result = await osuUtil.startOsuWithDevServer(tempOsuPath, "ez-pp.farm", async () => {
|
||||||
|
if (!mainWindow.isVisible()) mainWindow.show();
|
||||||
|
setTimeout(async () => {
|
||||||
isIngame = false;
|
isIngame = false;
|
||||||
mainWindow.show();
|
await osuUtil.replaceUI(osuFolder, false);
|
||||||
await doUpdateCheck(mainWindow);
|
await doUpdateCheck(mainWindow);
|
||||||
|
mainWindow.closable = true;
|
||||||
|
}, 2000);
|
||||||
});
|
});
|
||||||
return result;
|
return result;
|
||||||
})
|
})
|
||||||
@@ -285,10 +337,13 @@ async function tryLogin(window) {
|
|||||||
window.webContents.send('account_update', {
|
window.webContents.send('account_update', {
|
||||||
type: "loggedin",
|
type: "loggedin",
|
||||||
user: loginResponse.user
|
user: loginResponse.user
|
||||||
})
|
});
|
||||||
} else {
|
} else {
|
||||||
|
await config.remove("username");
|
||||||
|
await config.remove("password");
|
||||||
window.webContents.send('account_update', {
|
window.webContents.send('account_update', {
|
||||||
type: "login-failed"
|
type: "login-failed",
|
||||||
|
message: loginResponse.message
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -296,6 +351,11 @@ async function tryLogin(window) {
|
|||||||
type: "not-loggedin"
|
type: "not-loggedin"
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const checkUpdate = await appInfo.hasUpdate();
|
||||||
|
if (checkUpdate) {
|
||||||
|
window.webContents.send('launcher_update', checkUpdate);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function doUpdateCheck(window) {
|
async function doUpdateCheck(window) {
|
||||||
@@ -340,7 +400,6 @@ function createWindow() {
|
|||||||
|
|
||||||
win.loadFile('./html/index.html');
|
win.loadFile('./html/index.html');
|
||||||
|
|
||||||
attachTitlebarToWindow(win);
|
|
||||||
win.webContents.setWindowOpenHandler(() => "deny");
|
win.webContents.setWindowOpenHandler(() => "deny");
|
||||||
win.webContents.on('did-finish-load', function () {
|
win.webContents.on('did-finish-load', function () {
|
||||||
if (win.webContents.getZoomFactor() != 0.9)
|
if (win.webContents.getZoomFactor() != 0.9)
|
||||||
|
22
appInfo.js
22
appInfo.js
@@ -1,4 +1,20 @@
|
|||||||
const appName = "EZPPLauncher"
|
const { default: axios } = require("axios");
|
||||||
const appVersion = "1.1.2";
|
const { compareVersions } = require("compare-versions");
|
||||||
|
|
||||||
module.exports = { appName, appVersion };
|
const appName = "EZPPLauncher"
|
||||||
|
const appVersion = "1.1.5";
|
||||||
|
|
||||||
|
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 };
|
@@ -13,6 +13,19 @@ body {
|
|||||||
background-color: hsl(var(--main-bg), 24%, 19%);
|
background-color: hsl(var(--main-bg), 24%, 19%);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
p.text-white {
|
||||||
|
margin: .5rem 0;
|
||||||
|
color: white;
|
||||||
|
}
|
||||||
|
|
||||||
|
.quotetext {
|
||||||
|
color: white;
|
||||||
|
background-color: #727272;
|
||||||
|
border-radius: .35rem;
|
||||||
|
font-size: .95rem;
|
||||||
|
padding: .25rem .5rem;
|
||||||
|
}
|
||||||
|
|
||||||
.sections {
|
.sections {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-flow: column;
|
flex-flow: column;
|
||||||
@@ -176,7 +189,7 @@ body {
|
|||||||
|
|
||||||
.btn-accent:hover {
|
.btn-accent:hover {
|
||||||
background: hsl(var(--main-accent), 93%, 42%);
|
background: hsl(var(--main-accent), 93%, 42%);
|
||||||
color: #fff ;
|
color: #fff;
|
||||||
}
|
}
|
||||||
|
|
||||||
.btn-grey,
|
.btn-grey,
|
||||||
|
@@ -68,4 +68,4 @@ async function remove(key) {
|
|||||||
await fs.promises.writeFile(configLocation, arr.join('\n'));
|
await fs.promises.writeFile(configLocation, arr.join('\n'));
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = { get, set, remove }
|
module.exports = { get, set, remove, configFolder }
|
@@ -1,7 +1,5 @@
|
|||||||
const appInfo = require('./appInfo.js');
|
const appInfo = require('./appInfo.js');
|
||||||
const DiscordAutoRPC = require("discord-auto-rpc");
|
const DiscordAutoRPC = require("discord-auto-rpc");
|
||||||
const { app } = require('electron');
|
|
||||||
const DiscordRPC = require("discord-rpc").default;
|
|
||||||
const clientId = "1032772293220384808";
|
const clientId = "1032772293220384808";
|
||||||
let client = undefined;
|
let client = undefined;
|
||||||
let lastState = "Idle in Launcher...";
|
let lastState = "Idle in Launcher...";
|
||||||
|
@@ -1,10 +1,18 @@
|
|||||||
const axios = require('axios').default;
|
const axios = require('axios').default;
|
||||||
|
|
||||||
const loginCheckEndpoint = 'https://ez-pp.farm/login/check';
|
const loginCheckEndpoint = 'https://ez-pp.farm/login/check';
|
||||||
|
let retries = 0;
|
||||||
|
|
||||||
const performLogin = async (username, password) => {
|
const performLogin = async (username, password) => {
|
||||||
const result = await axios.post(loginCheckEndpoint, { 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;
|
return result.data;
|
||||||
|
} else {
|
||||||
|
if (retries++ >= 5) return { code: 403, message: "Login failed." }
|
||||||
|
return await performLogin(username, password);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = { performLogin };
|
module.exports = { performLogin };
|
@@ -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>
|
|
116
osuUtil.js
116
osuUtil.js
@@ -8,8 +8,11 @@ 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 customUIDLLPath = "https://ez-pp.farm/assets/ezpp!ui.dll";
|
||||||
|
const customUIDLLHash = "https://ez-pp.farm/assets/ezpp!ui.md5";
|
||||||
|
const customUIDLLName = "ezpp!ui.dll";
|
||||||
const ignoredOsuEntities = [
|
const ignoredOsuEntities = [
|
||||||
'osu!auth.dll'
|
'osu!auth.dll',
|
||||||
]
|
]
|
||||||
const osuEntities = [
|
const osuEntities = [
|
||||||
'avcodec-51.dll',
|
'avcodec-51.dll',
|
||||||
@@ -19,11 +22,8 @@ const osuEntities = [
|
|||||||
'bass_fx.dll',
|
'bass_fx.dll',
|
||||||
'collection.db',
|
'collection.db',
|
||||||
'd3dcompiler_47.dll',
|
'd3dcompiler_47.dll',
|
||||||
'Data',
|
|
||||||
'Downloads',
|
|
||||||
'libEGL.dll',
|
'libEGL.dll',
|
||||||
'libGLESv2.dll',
|
'libGLESv2.dll',
|
||||||
'Logs',
|
|
||||||
'Microsoft.Ink.dll',
|
'Microsoft.Ink.dll',
|
||||||
'OpenTK.dll',
|
'OpenTK.dll',
|
||||||
'osu!.cfg',
|
'osu!.cfg',
|
||||||
@@ -36,8 +36,6 @@ const osuEntities = [
|
|||||||
'presence.db',
|
'presence.db',
|
||||||
'pthreadGC2.dll',
|
'pthreadGC2.dll',
|
||||||
'scores.db',
|
'scores.db',
|
||||||
'Skins',
|
|
||||||
'Songs'
|
|
||||||
]
|
]
|
||||||
|
|
||||||
async function isValidOsuFolder(path) {
|
async function isValidOsuFolder(path) {
|
||||||
@@ -83,12 +81,25 @@ async function getUpdateFiles(releaseStream) {
|
|||||||
return releaseData.data;
|
return releaseData.data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function getEZPPUIMD5() {
|
||||||
|
const releaseData = await axios.get(customUIDLLHash, {});
|
||||||
|
return releaseData.data;
|
||||||
|
}
|
||||||
|
|
||||||
async function filesThatNeedUpdate(osuPath, updateFiles) {
|
async function filesThatNeedUpdate(osuPath, updateFiles) {
|
||||||
const filesToDownload = [];
|
const filesToDownload = [];
|
||||||
for (const updatedFile of updateFiles) {
|
for (const updatedFile of updateFiles) {
|
||||||
const fileName = updatedFile.filename;
|
let fileName = updatedFile.filename;
|
||||||
const fileHash = updatedFile.file_hash;
|
let fileHash = updatedFile.file_hash;
|
||||||
const fileURL = updatedFile.url_full;
|
let fileURL = updatedFile.url_full;
|
||||||
|
|
||||||
|
if ("url_patch" in updatedFile && updatedFile.url_patch != undefined) {
|
||||||
|
const stripped = updatedFile.url_patch.split("_");
|
||||||
|
fileHash = stripped[stripped.length - 1];
|
||||||
|
const lastIndex = fileURL.lastIndexOf("/");
|
||||||
|
const baseUrl = fileURL.slice(0, lastIndex);
|
||||||
|
fileURL = baseUrl + "/f_" + fileHash;
|
||||||
|
}
|
||||||
|
|
||||||
if (ignoredOsuEntities.includes(fileName)) continue;
|
if (ignoredOsuEntities.includes(fileName)) continue;
|
||||||
|
|
||||||
@@ -100,7 +111,7 @@ async function filesThatNeedUpdate(osuPath, updateFiles) {
|
|||||||
filesToDownload.push({
|
filesToDownload.push({
|
||||||
fileName,
|
fileName,
|
||||||
fileURL
|
fileURL
|
||||||
})
|
});
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
filesToDownload.push({
|
filesToDownload.push({
|
||||||
@@ -109,6 +120,27 @@ async function filesThatNeedUpdate(osuPath, updateFiles) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const ezppUI = path.join(osuPath, "EZPPLauncher", customUIDLLName);
|
||||||
|
if (await fu.existsAsync(ezppUI)) {
|
||||||
|
const latestMd5Hash = await getEZPPUIMD5();
|
||||||
|
const binaryUIContents = await fs.promises.readFile(ezppUI);
|
||||||
|
const existingUIMD5 = crypto.createHash("md5").update(binaryUIContents).digest("hex");
|
||||||
|
if (existingUIMD5 != latestMd5Hash) {
|
||||||
|
filesToDownload.push({
|
||||||
|
folder: "EZPPLauncher",
|
||||||
|
fileName: "ezpp!ui.dll",
|
||||||
|
fileURL: customUIDLLPath
|
||||||
|
})
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
filesToDownload.push({
|
||||||
|
folder: "EZPPLauncher",
|
||||||
|
fileName: "ezpp!ui.dll",
|
||||||
|
fileURL: customUIDLLPath
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
return filesToDownload;
|
return filesToDownload;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -116,8 +148,13 @@ async function downloadUpdateFiles(osuPath, filesToUpdate) {
|
|||||||
const eventEmitter = new EventEmitter();
|
const eventEmitter = new EventEmitter();
|
||||||
let completedIndex = 0;
|
let completedIndex = 0;
|
||||||
filesToUpdate.forEach(async (fileToUpdate) => {
|
filesToUpdate.forEach(async (fileToUpdate) => {
|
||||||
|
|
||||||
|
if ("folder" in fileToUpdate) {
|
||||||
|
osuPath = path.join(osuPath, fileToUpdate.folder);
|
||||||
|
if (!(await fu.existsAsync(osuPath))) await fs.promises.mkdir(osuPath);
|
||||||
|
}
|
||||||
|
|
||||||
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);
|
||||||
|
|
||||||
@@ -174,6 +211,41 @@ async function setConfigValue(configPath, key, value) {
|
|||||||
}
|
}
|
||||||
await fs.promises.writeFile(configPath, configLines.join("\n"), 'utf-8');
|
await fs.promises.writeFile(configPath, configLines.join("\n"), 'utf-8');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function updateOsuCfg(cfgPath) {
|
||||||
|
const osuFolder = path.dirname(cfgPath);
|
||||||
|
const fileStream = await fs.promises.readFile(cfgPath, "utf-8");
|
||||||
|
const lines = fileStream.split(/\r?\n/);
|
||||||
|
const newLines = [];
|
||||||
|
for (const line of lines) {
|
||||||
|
if (line.includes(' = ')) {
|
||||||
|
const argsPair = line.split(' = ', 2);
|
||||||
|
const keyname = argsPair[0]
|
||||||
|
const value = argsPair[1];
|
||||||
|
|
||||||
|
if (keyname.startsWith("h_")) {
|
||||||
|
const filename = keyname.substring(2, keyname.length);
|
||||||
|
const filepath = path.join(osuFolder, filename);
|
||||||
|
if (!fs.existsSync(filepath)) continue;
|
||||||
|
const binaryFileContents = await fs.promises.readFile(filepath);
|
||||||
|
const existingFileMD5 = crypto.createHash("md5").update(binaryFileContents).digest("hex");
|
||||||
|
if (value == existingFileMD5) newLines.push(line)
|
||||||
|
else newLines.push(`${keyname} = ${existingFileMD5}`);
|
||||||
|
} else {
|
||||||
|
newLines.push(line);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const ezppUI = path.join(osuFolder, customUIDLLName);
|
||||||
|
if (fs.existsSync(ezppUI)) {
|
||||||
|
const binaryFileContents = await fs.promises.readFile(ezppUI);
|
||||||
|
const existingFileMD5 = crypto.createHash("md5").update(binaryFileContents).digest("hex");
|
||||||
|
newLines.push(`h_${customUIDLLName} = ${existingFileMD5}`);
|
||||||
|
}
|
||||||
|
await fs.promises.writeFile(cfgPath, newLines.join("\n"), 'utf-8');
|
||||||
|
}
|
||||||
|
|
||||||
async function findOsuInstallation() {
|
async function findOsuInstallation() {
|
||||||
const regedit = require('qiao-regedit');
|
const regedit = require('qiao-regedit');
|
||||||
|
|
||||||
@@ -183,14 +255,32 @@ async function findOsuInstallation() {
|
|||||||
if (line.includes("REG_SZ")) {
|
if (line.includes("REG_SZ")) {
|
||||||
let value = (line.trim().split(" ")[2]);
|
let value = (line.trim().split(" ")[2]);
|
||||||
value = value.substring(1, value.length - 3);
|
value = value.substring(1, value.length - 3);
|
||||||
return value.trim();
|
return path.dirname(value.trim());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function replaceUI(folder, isStart) {
|
||||||
|
const ezppUIFile = path.join(folder, "EZPPLauncher", customUIDLLName);
|
||||||
|
const osuUIFile = path.join(folder, "osu!ui.dll");
|
||||||
|
const osuUIFileBackup = path.join(folder, "osu!ui.dll.bak");
|
||||||
|
if (isStart) {
|
||||||
|
if (fs.existsSync(osuUIFileBackup)) await fs.promises.unlink(osuUIFileBackup);
|
||||||
|
await fs.promises.rename(osuUIFile, osuUIFileBackup);
|
||||||
|
await new Promise((res) => setTimeout(res, 1000));
|
||||||
|
await fs.promises.copyFile(ezppUIFile, osuUIFile);
|
||||||
|
} else {
|
||||||
|
if (!fs.existsSync(osuUIFileBackup)) return;
|
||||||
|
await fs.promises.unlink(osuUIFile);
|
||||||
|
await new Promise((res) => setTimeout(res, 1000));
|
||||||
|
await fs.promises.rename(osuUIFileBackup, osuUIFile);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
isValidOsuFolder, getLatestConfig, getUpdateFiles, filesThatNeedUpdate,
|
isValidOsuFolder, getLatestConfig, getUpdateFiles, filesThatNeedUpdate,
|
||||||
downloadUpdateFiles, startOsuWithDevServer: startWithDevServer, setConfigValue,
|
downloadUpdateFiles, startOsuWithDevServer: startWithDevServer, setConfigValue,
|
||||||
findOsuInstallation
|
findOsuInstallation, replaceUI, updateOsuCfg, getEZPPUIMD5
|
||||||
}
|
}
|
3963
package-lock.json
generated
Normal file
3963
package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
11
package.json
11
package.json
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "ezpplauncher",
|
"name": "ezpplauncher",
|
||||||
"version": "1.1.2",
|
"version": "1.1.5",
|
||||||
"main": "app.js",
|
"main": "app.js",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"author": "HorizonCode",
|
"author": "HorizonCode",
|
||||||
@@ -22,7 +22,7 @@
|
|||||||
"runAfterFinish": true
|
"runAfterFinish": true
|
||||||
},
|
},
|
||||||
"portable": {
|
"portable": {
|
||||||
"artifactName": "EZPPLauncher.exe"
|
"artifactName": "ezpplauncher-${version}.exe"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"frontend": {
|
"frontend": {
|
||||||
@@ -33,9 +33,9 @@
|
|||||||
"scripts": {
|
"scripts": {
|
||||||
"start": "electron .",
|
"start": "electron .",
|
||||||
"rebuild": "electron-rebuild -f -w get-window-by-name",
|
"rebuild": "electron-rebuild -f -w get-window-by-name",
|
||||||
"pack-win": "electron-builder --win --arm64 --x64",
|
"pack-win": "electron-builder --win --x64",
|
||||||
"pack-linux": "electron-builder --linux --arm64 --x64",
|
"pack-linux": "electron-builder --linux --x64",
|
||||||
"pack-mac": "electron-builder --mac --arm64 --x64",
|
"pack-mac": "electron-builder --mac --x64",
|
||||||
"dist": "electron-builder"
|
"dist": "electron-builder"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
@@ -46,6 +46,7 @@
|
|||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"axios": "^0.27.2",
|
"axios": "^0.27.2",
|
||||||
|
"compare-versions": "^6.0.0-rc.1",
|
||||||
"custom-electron-titlebar": "^4.1.1",
|
"custom-electron-titlebar": "^4.1.1",
|
||||||
"discord-auto-rpc": "^1.0.17",
|
"discord-auto-rpc": "^1.0.17",
|
||||||
"discord-rpc": "^4.0.1",
|
"discord-rpc": "^4.0.1",
|
||||||
|
@@ -1,16 +1,16 @@
|
|||||||
const { ipcRenderer } = require('electron');
|
const { ipcRenderer, shell } = require('electron');
|
||||||
const { Titlebar, Color } = require('custom-electron-titlebar');
|
const { Titlebar, TitlebarColor } = require('custom-electron-titlebar');
|
||||||
const appInfo = require('../appInfo');
|
const appInfo = require('../appInfo');
|
||||||
let titlebar;
|
|
||||||
let currentPage = "loading";
|
let currentPage = "loading";
|
||||||
let loggedIn = false;
|
let loggedIn = false;
|
||||||
|
|
||||||
window.addEventListener('DOMContentLoaded', () => {
|
window.addEventListener('DOMContentLoaded', () => {
|
||||||
titlebar = new Titlebar({
|
const titlebar = new Titlebar({
|
||||||
backgroundColor: Color.fromHex("#24283B"),
|
backgroundColor: TitlebarColor.fromHex("#24283B"),
|
||||||
itemBackgroundColor: Color.fromHex("#121212"),
|
itemBackgroundColor: TitlebarColor.fromHex("#121212"),
|
||||||
menu: null,
|
menu: null,
|
||||||
maximizable: false
|
enableMnemonics: false,
|
||||||
|
maximizable: false,
|
||||||
});
|
});
|
||||||
|
|
||||||
titlebar.updateTitle(`${appInfo.appName} ${appInfo.appVersion}`);
|
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) => {
|
ipcRenderer.on('account_update', (event, data) => {
|
||||||
switch (data.type) {
|
switch (data.type) {
|
||||||
|
case "login-failed":
|
||||||
|
Swal.fire({
|
||||||
|
title: 'Uh oh!',
|
||||||
|
text: data.message,
|
||||||
|
icon: 'error',
|
||||||
|
confirmButtonText: 'Okay'
|
||||||
|
});
|
||||||
|
changePage("launch");
|
||||||
|
break;
|
||||||
case "not-loggedin":
|
case "not-loggedin":
|
||||||
changePage("launch");
|
changePage("launch");
|
||||||
break;
|
break;
|
||||||
@@ -165,6 +188,28 @@ window.addEventListener('DOMContentLoaded', () => {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
ipcRenderer.on('alert_message', async (event, path) => {
|
||||||
|
const res = await Swal.fire({
|
||||||
|
title: 'Hey!',
|
||||||
|
html: `<p class="text-white">Detected a osu! installation at</p><span class="quotetext">${path}</span><p class="text-white">Is this correct?</p>`,
|
||||||
|
icon: 'info',
|
||||||
|
showCancelButton: true,
|
||||||
|
confirmButtonText: 'Yes',
|
||||||
|
cancelButtonText: 'No',
|
||||||
|
});
|
||||||
|
if (res.isConfirmed) {
|
||||||
|
$('#currentOsuPath').text(path);
|
||||||
|
ipcRenderer.send('alert_response', path);
|
||||||
|
Swal.fire({
|
||||||
|
title: 'Success!',
|
||||||
|
text: 'osu! folder set.',
|
||||||
|
icon: 'success',
|
||||||
|
confirmButtonText: 'Cool'
|
||||||
|
})
|
||||||
|
ipcRenderer.send("do-update-check");
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
ipcRenderer.on('status_update', (event, status) => {
|
ipcRenderer.on('status_update', (event, status) => {
|
||||||
switch (status.type) {
|
switch (status.type) {
|
||||||
case "up-to-date":
|
case "up-to-date":
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
const path = require("path");
|
const path = require("path");
|
||||||
const appInfo = require('../appInfo');
|
const appInfo = require('../appInfo');
|
||||||
const { BrowserWindow } = require('electron');
|
const { BrowserWindow, Menu } = require('electron');
|
||||||
const { attachTitlebarToWindow } = require('custom-electron-titlebar/main');
|
const { attachTitlebarToWindow } = require('custom-electron-titlebar/main');
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
@@ -26,6 +26,10 @@ module.exports = {
|
|||||||
},
|
},
|
||||||
icon: './assets/logo.png'
|
icon: './assets/logo.png'
|
||||||
})
|
})
|
||||||
|
|
||||||
|
const menu = Menu.buildFromTemplate([])
|
||||||
|
Menu.setApplicationMenu(menu);
|
||||||
|
|
||||||
window.hide();
|
window.hide();
|
||||||
|
|
||||||
window.webContents.once("did-finish-load", function (event, input) {
|
window.webContents.once("did-finish-load", function (event, input) {
|
||||||
@@ -33,6 +37,7 @@ module.exports = {
|
|||||||
});
|
});
|
||||||
|
|
||||||
window.webContents.setUserAgent(`${appInfo.appName} ${appInfo.appVersion}`);
|
window.webContents.setUserAgent(`${appInfo.appName} ${appInfo.appVersion}`);
|
||||||
|
|
||||||
attachTitlebarToWindow(window);
|
attachTitlebarToWindow(window);
|
||||||
|
|
||||||
return window;
|
return window;
|
||||||
|
Reference in New Issue
Block a user