add mode and global rank to rpc

This commit is contained in:
HorizonCode 2024-03-16 18:48:44 +01:00
parent a9de377456
commit 1c4a40c495
2 changed files with 32 additions and 0 deletions

View File

@ -10,6 +10,16 @@ const checkUpdateURL =
const ignoredOsuEntities = [ const ignoredOsuEntities = [
"osu!auth.dll", "osu!auth.dll",
]; ];
const gamemodes = {
0: "osu!",
1: "taiko",
2: "catch",
3: "mania",
4: "osu!(rx)",
5: "taiko(rx)",
6: "catch(rx)",
8: "osu!(ap)"
}
const osuEntities = [ const osuEntities = [
"avcodec-51.dll", "avcodec-51.dll",
"avformat-52.dll", "avformat-52.dll",
@ -481,4 +491,5 @@ module.exports = {
findOsuInstallation, findOsuInstallation,
updateOsuConfigHashes, updateOsuConfigHashes,
runOsuUpdater, runOsuUpdater,
gamemodes
}; };

21
main.js
View File

@ -35,6 +35,7 @@ const {
findOsuInstallation, findOsuInstallation,
updateOsuConfigHashes, updateOsuConfigHashes,
runOsuUpdater, runOsuUpdater,
gamemodes,
} = require("./electron/osuUtil"); } = require("./electron/osuUtil");
const { formatBytes } = require("./electron/formattingUtil"); const { formatBytes } = require("./electron/formattingUtil");
const windowName = require("get-window-by-name"); const windowName = require("get-window-by-name");
@ -116,6 +117,19 @@ 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;
const currentMode = currentStatus.player_status.status.mode;
const currentModeString = gamemodes[currentMode];
const currentInfoRequest = await fetch(
"https://api.ez-pp.farm/get_player_info?name=" + currentUser.username + "&scope=all",
);
const currentInfo = await currentInfoRequest.json();
let currentUsername = currentInfo.player.info.name;
const currentId = currentInfo.player.info.id;
const currentStats = currentInfo.player.stats[currentMode];
currentUsername += ` (#${currentStats.rank})`;
let largeImageKey = "ezppfarm"; 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
@ -182,6 +196,13 @@ function startOsuStatus() {
break; break;
} }
details = `[${currentModeString}] ${details}`;
richPresence.updateUser({
username: currentUsername,
id: currentId,
})
richPresence.updateStatus({ richPresence.updateStatus({
details, details,
state: infoText, state: infoText,