Compare commits
5 Commits
6bcce04b72
...
2.1.1
Author | SHA1 | Date | |
---|---|---|---|
eb166c0165 | |||
6bca0b32a9 | |||
401be3c977 | |||
d2d2a618c5 | |||
fc6ec3bd69 |
@@ -1,4 +1,4 @@
|
|||||||
const appName = "EZPPLauncher";
|
const appName = "EZPPLauncher";
|
||||||
const appVersion = "2.1.1";
|
const appVersion = "2.1.0";
|
||||||
|
|
||||||
module.exports = { appName, appVersion };
|
module.exports = { appName, appVersion };
|
||||||
|
@@ -1,15 +0,0 @@
|
|||||||
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 };
|
|
@@ -2,10 +2,7 @@ const DiscordRPC = require("discord-auto-rpc");
|
|||||||
const { appName, appVersion } = require("./appInfo.js");
|
const { appName, appVersion } = require("./appInfo.js");
|
||||||
|
|
||||||
const clientId = "1032772293220384808";
|
const clientId = "1032772293220384808";
|
||||||
|
|
||||||
/** @type {DiscordRPC.AutoClient} */
|
|
||||||
let richPresence;
|
let richPresence;
|
||||||
|
|
||||||
let intervalId;
|
let intervalId;
|
||||||
|
|
||||||
let currentStatus = {
|
let currentStatus = {
|
||||||
@@ -35,7 +32,6 @@ module.exports = {
|
|||||||
richPresence = new DiscordRPC.AutoClient({ transport: "ipc" });
|
richPresence = new DiscordRPC.AutoClient({ transport: "ipc" });
|
||||||
richPresence.endlessLogin({ clientId });
|
richPresence.endlessLogin({ clientId });
|
||||||
richPresence.once("ready", () => {
|
richPresence.once("ready", () => {
|
||||||
console.log("connected presence with user " + richPresence.user.username);
|
|
||||||
richPresence.setActivity(currentStatus);
|
richPresence.setActivity(currentStatus);
|
||||||
intervalId = setInterval(() => {
|
intervalId = setInterval(() => {
|
||||||
richPresence.setActivity(currentStatus);
|
richPresence.setActivity(currentStatus);
|
||||||
@@ -51,17 +47,16 @@ module.exports = {
|
|||||||
richPresence = null;
|
richPresence = null;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
updateStatus: ({ state, details, largeImageKey }) => {
|
updateStatus: ({ state, details }) => {
|
||||||
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" : " ";
|
||||||
currentStatus.smallImageText = osuVersion ? `osu! ${osuVersion}` : " ";
|
currentStatus.smallImageText = osuVersion ? `osu! ${osuVersion}` : " ";
|
||||||
},
|
},
|
||||||
update: () => {
|
update: () => {
|
||||||
if (richPresence && richPresence.user) {
|
if (richPresence) {
|
||||||
richPresence.setActivity(currentStatus);
|
richPresence.setActivity(currentStatus);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
16
main.js
16
main.js
@@ -46,7 +46,6 @@ 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.
|
||||||
@@ -97,24 +96,10 @@ 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:
|
||||||
@@ -159,7 +144,6 @@ function startOsuStatus() {
|
|||||||
richPresence.updateStatus({
|
richPresence.updateStatus({
|
||||||
details,
|
details,
|
||||||
state: infoText,
|
state: infoText,
|
||||||
largeImageKey,
|
|
||||||
});
|
});
|
||||||
|
|
||||||
richPresence.update();
|
richPresence.update();
|
||||||
|
Reference in New Issue
Block a user