add dynamic beatmap images to presence #12
|
@ -56,9 +56,9 @@ module.exports = {
|
||||||
currentStatus.details = details ?? " ";
|
currentStatus.details = details ?? " ";
|
||||||
currentStatus.largeImageKey = largeImageKey ?? "ezppfarm";
|
currentStatus.largeImageKey = largeImageKey ?? "ezppfarm";
|
||||||
},
|
},
|
||||||
updateVersion: (osuVersion) => {
|
updateUser: ({ username, id }) => {
|
||||||
currentStatus.smallImageKey = osuVersion ? "osu" : " ";
|
currentStatus.smallImageKey = id ? `https://a.ez-pp.farm/${id}` : " ";
|
||||||
currentStatus.smallImageText = osuVersion ? `osu! ${osuVersion}` : " ";
|
currentStatus.smallImageText = username ? username : " ";
|
||||||
},
|
},
|
||||||
update: () => {
|
update: () => {
|
||||||
if (richPresence && richPresence.user) {
|
if (richPresence && richPresence.user) {
|
||||||
|
|
39
main.js
39
main.js
|
@ -73,6 +73,25 @@ function startOsuStatus() {
|
||||||
if (firstInstance) {
|
if (firstInstance) {
|
||||||
if (!osuLoaded) {
|
if (!osuLoaded) {
|
||||||
osuLoaded = true;
|
osuLoaded = true;
|
||||||
|
|
||||||
|
try {
|
||||||
|
const currentUserInfo = await fetch(`https://api.ez-pp.farm/get_player_info?name=${currentUser.username}&scope=info`);
|
||||||
|
const currentUserInfoJson = await currentUserInfo.json();
|
||||||
|
if ("player" in currentUserInfoJson && currentUserInfoJson.player != null) {
|
||||||
|
if ("info" in currentUserInfoJson.player && currentUserInfoJson.player.info != null) {
|
||||||
|
const id = currentUserInfoJson.player.info.id;
|
||||||
|
const username = currentUserInfoJson.player.info.name;
|
||||||
|
richPresence.updateUser({
|
||||||
|
id,
|
||||||
|
username,
|
||||||
|
});
|
||||||
|
richPresence.update();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
if (patch) {
|
if (patch) {
|
||||||
const patcherExecuteable = path.join(
|
const patcherExecuteable = path.join(
|
||||||
|
@ -107,6 +126,7 @@ function startOsuStatus() {
|
||||||
currentStatus.player_status.status.beatmap !== null
|
currentStatus.player_status.status.beatmap !== null
|
||||||
) {
|
) {
|
||||||
const setId = currentStatus.player_status.status.beatmap.set_id;
|
const setId = currentStatus.player_status.status.beatmap.set_id;
|
||||||
|
if (setId) {
|
||||||
const coverImage =
|
const coverImage =
|
||||||
`https://assets.ppy.sh/beatmaps/${setId}/covers/list@2x.jpg`;
|
`https://assets.ppy.sh/beatmaps/${setId}/covers/list@2x.jpg`;
|
||||||
if (
|
if (
|
||||||
|
@ -115,11 +135,13 @@ function startOsuStatus() {
|
||||||
largeImageKey = coverImage;
|
largeImageKey = coverImage;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
switch (currentStatus.player_status.status.action) {
|
switch (currentStatus.player_status.status.action) {
|
||||||
case 1:
|
case 1:
|
||||||
details = "AFK...";
|
details = "AFK...";
|
||||||
infoText = " ";
|
infoText = " ";
|
||||||
|
largeImageKey = "ezppfarm";
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
details = "Playing...";
|
details = "Playing...";
|
||||||
|
@ -133,6 +155,7 @@ function startOsuStatus() {
|
||||||
case 5:
|
case 5:
|
||||||
details = "Multiplayer: Selecting a Beatmap...";
|
details = "Multiplayer: Selecting a Beatmap...";
|
||||||
infoText = " ";
|
infoText = " ";
|
||||||
|
largeImageKey = "ezppfarm";
|
||||||
break;
|
break;
|
||||||
case 6:
|
case 6:
|
||||||
details = "Watching...";
|
details = "Watching...";
|
||||||
|
@ -142,10 +165,12 @@ function startOsuStatus() {
|
||||||
break;
|
break;
|
||||||
case 9:
|
case 9:
|
||||||
details = "Submitting...";
|
details = "Submitting...";
|
||||||
|
largeImageKey = "ezppfarm";
|
||||||
break;
|
break;
|
||||||
case 11:
|
case 11:
|
||||||
details = "Multiplayer: Idle...";
|
details = "Multiplayer: Idle...";
|
||||||
infoText = " ";
|
infoText = " ";
|
||||||
|
largeImageKey = "ezppfarm";
|
||||||
break;
|
break;
|
||||||
case 12:
|
case 12:
|
||||||
details = "Multiplayer: Playing...";
|
details = "Multiplayer: Playing...";
|
||||||
|
@ -153,6 +178,7 @@ function startOsuStatus() {
|
||||||
case 13:
|
case 13:
|
||||||
details = "Browsing osu!direct...";
|
details = "Browsing osu!direct...";
|
||||||
infoText = " ";
|
infoText = " ";
|
||||||
|
largeImageKey = "ezppfarm";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -402,8 +428,7 @@ function registerIPCPipes() {
|
||||||
progress: Math.ceil(data.progress),
|
progress: Math.ceil(data.progress),
|
||||||
});
|
});
|
||||||
mainWindow.webContents.send("ezpplauncher:launchstatus", {
|
mainWindow.webContents.send("ezpplauncher:launchstatus", {
|
||||||
status: `Downloading ${data.fileName}(${formatBytes(data.loaded)}/${
|
status: `Downloading ${data.fileName}(${formatBytes(data.loaded)}/${formatBytes(data.total)
|
||||||
formatBytes(data.total)
|
|
||||||
})...`,
|
})...`,
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -433,8 +458,7 @@ function registerIPCPipes() {
|
||||||
progress: Math.ceil(data.progress),
|
progress: Math.ceil(data.progress),
|
||||||
});
|
});
|
||||||
mainWindow.webContents.send("ezpplauncher:launchstatus", {
|
mainWindow.webContents.send("ezpplauncher:launchstatus", {
|
||||||
status: `Downloading ${data.fileName}(${formatBytes(data.loaded)}/${
|
status: `Downloading ${data.fileName}(${formatBytes(data.loaded)}/${formatBytes(data.total)
|
||||||
formatBytes(data.total)
|
|
||||||
})...`,
|
})...`,
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -480,8 +504,7 @@ function registerIPCPipes() {
|
||||||
progress: Math.ceil(data.progress),
|
progress: Math.ceil(data.progress),
|
||||||
});
|
});
|
||||||
mainWindow.webContents.send("ezpplauncher:launchstatus", {
|
mainWindow.webContents.send("ezpplauncher:launchstatus", {
|
||||||
status: `Downloading ${data.fileName}(${formatBytes(data.loaded)}/${
|
status: `Downloading ${data.fileName}(${formatBytes(data.loaded)}/${formatBytes(data.total)
|
||||||
formatBytes(data.total)
|
|
||||||
})...`,
|
})...`,
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -554,11 +577,9 @@ function registerIPCPipes() {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch {}
|
} catch { }
|
||||||
|
|
||||||
const userConfig = getUserConfig(osuPath);
|
const userConfig = getUserConfig(osuPath);
|
||||||
richPresence.updateVersion(await userConfig.get("LastVersion"));
|
|
||||||
richPresence.update();
|
|
||||||
if (richPresence.hasPresence) {
|
if (richPresence.hasPresence) {
|
||||||
await userConfig.set("DiscordRichPresence", "0");
|
await userConfig.set("DiscordRichPresence", "0");
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user