From 72d466b1eccf7d1f0627a45b3f4311f01d93e02b Mon Sep 17 00:00:00 2001 From: HorizonCode Date: Mon, 29 Jan 2024 08:57:28 +0100 Subject: [PATCH 1/6] disable unhandled error logging for now --- main.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/main.js b/main.js index e5574dc..aa8d919 100644 --- a/main.js +++ b/main.js @@ -3,14 +3,14 @@ const { app, BrowserWindow, Menu, ipcMain, dialog, shell } = require( "electron", ); -const unhandled = require("electron-unhandled"); +/* const unhandled = require("electron-unhandled"); unhandled({ logger: console.error, showDialog: true, reportButton: () => { shell.openExternal("https://ez-pp.farm/discord"); }, -}); +}); */ const path = require("path"); const serve = require("electron-serve"); From c4cd8fed12768dc8c2f9d42d1f8c3875c98e0b15 Mon Sep 17 00:00:00 2001 From: HorizonCode Date: Mon, 29 Jan 2024 08:58:42 +0100 Subject: [PATCH 2/6] bump patch version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index c8742db..cf5fa7f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "ezpplauncher-next", - "version": "2.1.0", + "version": "2.1.1", "description": "EZPPLauncher rewritten with Svelte.", "private": false, "license": "MIT", From da8e237679cf97d299f92c5f688544171d0eb40b Mon Sep 17 00:00:00 2001 From: HorizonCode Date: Tue, 30 Jan 2024 09:51:23 +0100 Subject: [PATCH 3/6] oops --- electron/appInfo.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/electron/appInfo.js b/electron/appInfo.js index 546e22d..0b0468e 100644 --- a/electron/appInfo.js +++ b/electron/appInfo.js @@ -1,4 +1,4 @@ const appName = "EZPPLauncher"; -const appVersion = "2.1.0"; +const appVersion = "2.1.1"; module.exports = { appName, appVersion }; From d56d4875e0ebe572d65455511e15d3c2d965fa19 Mon Sep 17 00:00:00 2001 From: HorizonCode Date: Mon, 11 Mar 2024 15:38:20 +0100 Subject: [PATCH 4/6] add dynamic beatmap image to presence --- electron/imageUtil.js | 15 +++++++++++++++ electron/richPresence.js | 3 ++- main.js | 14 ++++++++++++++ 3 files changed, 31 insertions(+), 1 deletion(-) create mode 100644 electron/imageUtil.js diff --git a/electron/imageUtil.js b/electron/imageUtil.js new file mode 100644 index 0000000..065f45e --- /dev/null +++ b/electron/imageUtil.js @@ -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 }; diff --git a/electron/richPresence.js b/electron/richPresence.js index 4489d34..23579f8 100644 --- a/electron/richPresence.js +++ b/electron/richPresence.js @@ -47,9 +47,10 @@ module.exports = { richPresence = null; } }, - updateStatus: ({ state, details }) => { + updateStatus: ({ state, details, largeImageKey }) => { currentStatus.state = state ?? " "; currentStatus.details = details ?? " "; + currentStatus.largeImageKey = largeImageKey ?? "ezppfarm"; }, updateVersion: (osuVersion) => { currentStatus.smallImageKey = osuVersion ? "osu" : " "; diff --git a/main.js b/main.js index aa8d919..4d91f9a 100644 --- a/main.js +++ b/main.js @@ -46,6 +46,7 @@ const { getHwId } = require("./electron/hwidUtil"); const { appName, appVersion } = require("./electron/appInfo"); const { updateAvailable, releasesUrl } = require("./electron/updateCheck"); const fkill = require("fkill"); +const { checkImageExists } = require("./electron/imageUtil"); // 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. @@ -96,10 +97,22 @@ function startOsuStatus() { if (!("player_status" in currentStatus)) return; if (!("status" in currentStatus.player_status)) return; + let largeImageKey = "ezppfarm"; let details = "Idle..."; let infoText = currentStatus.player_status.status.info_text.length > 0 ? currentStatus.player_status.status.info_text : " "; + if ("beatmap" in currentStatus.player_status.status) { + const setId = currentStatus.player_status.status.beatmap.set_id; + if ( + checkImageExists( + `https://assets.ppy.sh/beatmaps/${setId}/covers/list@2x.jpg`, + ) + ) { + largeImageKey = + `https://assets.ppy.sh/beatmaps/${setId}/covers/list@2x.jpg`; + } + } switch (currentStatus.player_status.status.action) { case 1: @@ -144,6 +157,7 @@ function startOsuStatus() { richPresence.updateStatus({ details, state: infoText, + largeImageKey, }); richPresence.update(); From c4d98628608c2d507f90a4090cd54b13f13765db Mon Sep 17 00:00:00 2001 From: HorizonCode Date: Mon, 11 Mar 2024 15:42:08 +0100 Subject: [PATCH 5/6] assign the cover url to a const --- main.js | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/main.js b/main.js index 4d91f9a..8a23942 100644 --- a/main.js +++ b/main.js @@ -104,13 +104,12 @@ function startOsuStatus() { : " "; if ("beatmap" in currentStatus.player_status.status) { const setId = currentStatus.player_status.status.beatmap.set_id; + const coverImage = + `https://assets.ppy.sh/beatmaps/${setId}/covers/list@2x.jpg`; if ( - checkImageExists( - `https://assets.ppy.sh/beatmaps/${setId}/covers/list@2x.jpg`, - ) + checkImageExists(coverImage) ) { - largeImageKey = - `https://assets.ppy.sh/beatmaps/${setId}/covers/list@2x.jpg`; + largeImageKey = coverImage; } } From 22815e74b6f8f89d70e9d6d2b3d377a00554d5b2 Mon Sep 17 00:00:00 2001 From: HorizonCode Date: Mon, 11 Mar 2024 15:46:07 +0100 Subject: [PATCH 6/6] check if beatmap is not null --- main.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/main.js b/main.js index 8a23942..8dd3c3a 100644 --- a/main.js +++ b/main.js @@ -102,7 +102,10 @@ function startOsuStatus() { let infoText = currentStatus.player_status.status.info_text.length > 0 ? currentStatus.player_status.status.info_text : " "; - if ("beatmap" in currentStatus.player_status.status) { + 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`;