6 Commits

Author SHA1 Message Date
22815e74b6 check if beatmap is not null 2024-03-11 15:46:07 +01:00
c4d9862860 assign the cover url to a const 2024-03-11 15:42:08 +01:00
d56d4875e0 add dynamic beatmap image to presence 2024-03-11 15:38:20 +01:00
da8e237679 oops 2024-01-30 09:51:23 +01:00
c4cd8fed12 bump patch version 2024-01-29 08:58:42 +01:00
72d466b1ec disable unhandled error logging for now 2024-01-29 08:57:28 +01:00
5 changed files with 37 additions and 5 deletions

View File

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

15
electron/imageUtil.js Normal file
View File

@@ -0,0 +1,15 @@
async function checkImageExists(url) {
try {
const response = await fetch(url, { method: "HEAD" });
if (!response.ok) {
return false;
}
const contentType = response.headers.get("content-type");
if (!contentType) return false;
return contentType.startsWith("image/");
} catch (error) {
return false;
}
}
module.exports = { checkImageExists };

View File

@@ -47,9 +47,10 @@ module.exports = {
richPresence = null; richPresence = null;
} }
}, },
updateStatus: ({ state, details }) => { updateStatus: ({ state, details, largeImageKey }) => {
currentStatus.state = state ?? " "; currentStatus.state = state ?? " ";
currentStatus.details = details ?? " "; currentStatus.details = details ?? " ";
currentStatus.largeImageKey = largeImageKey ?? "ezppfarm";
}, },
updateVersion: (osuVersion) => { updateVersion: (osuVersion) => {
currentStatus.smallImageKey = osuVersion ? "osu" : " "; currentStatus.smallImageKey = osuVersion ? "osu" : " ";

20
main.js
View File

@@ -3,14 +3,14 @@ const { app, BrowserWindow, Menu, ipcMain, dialog, shell } = require(
"electron", "electron",
); );
const unhandled = require("electron-unhandled"); /* const unhandled = require("electron-unhandled");
unhandled({ unhandled({
logger: console.error, logger: console.error,
showDialog: true, showDialog: true,
reportButton: () => { reportButton: () => {
shell.openExternal("https://ez-pp.farm/discord"); shell.openExternal("https://ez-pp.farm/discord");
}, },
}); }); */
const path = require("path"); const path = require("path");
const serve = require("electron-serve"); const serve = require("electron-serve");
@@ -46,6 +46,7 @@ const { getHwId } = require("./electron/hwidUtil");
const { appName, appVersion } = require("./electron/appInfo"); const { appName, appVersion } = require("./electron/appInfo");
const { updateAvailable, releasesUrl } = require("./electron/updateCheck"); const { updateAvailable, releasesUrl } = require("./electron/updateCheck");
const fkill = require("fkill"); const fkill = require("fkill");
const { checkImageExists } = require("./electron/imageUtil");
// Keep a global reference of the window object, if you don't, the window will // Keep a global reference of the window object, if you don't, the window will
// be closed automatically when the JavaScript object is garbage collected. // be closed automatically when the JavaScript object is garbage collected.
@@ -96,10 +97,24 @@ function startOsuStatus() {
if (!("player_status" in currentStatus)) return; if (!("player_status" in currentStatus)) return;
if (!("status" in currentStatus.player_status)) return; if (!("status" in currentStatus.player_status)) return;
let largeImageKey = "ezppfarm";
let details = "Idle..."; let details = "Idle...";
let infoText = currentStatus.player_status.status.info_text.length > 0 let infoText = currentStatus.player_status.status.info_text.length > 0
? currentStatus.player_status.status.info_text ? currentStatus.player_status.status.info_text
: " "; : " ";
if (
"beatmap" in currentStatus.player_status.status &&
currentStatus.player_status.status.beatmap !== null
) {
const setId = currentStatus.player_status.status.beatmap.set_id;
const coverImage =
`https://assets.ppy.sh/beatmaps/${setId}/covers/list@2x.jpg`;
if (
checkImageExists(coverImage)
) {
largeImageKey = coverImage;
}
}
switch (currentStatus.player_status.status.action) { switch (currentStatus.player_status.status.action) {
case 1: case 1:
@@ -144,6 +159,7 @@ function startOsuStatus() {
richPresence.updateStatus({ richPresence.updateStatus({
details, details,
state: infoText, state: infoText,
largeImageKey,
}); });
richPresence.update(); richPresence.update();

View File

@@ -1,6 +1,6 @@
{ {
"name": "ezpplauncher-next", "name": "ezpplauncher-next",
"version": "2.1.0", "version": "2.1.1",
"description": "EZPPLauncher rewritten with Svelte.", "description": "EZPPLauncher rewritten with Svelte.",
"private": false, "private": false,
"license": "MIT", "license": "MIT",