switch details and state

This commit is contained in:
HorizonCode 2024-01-18 18:12:55 +01:00
parent 6369c0e8af
commit 01905d695a
2 changed files with 67 additions and 29 deletions

76
main.js
View File

@ -48,15 +48,61 @@ function startOsuStatus() {
}
const windowTitle = firstInstance.processTitle;
if (lastOsuStatus == windowTitle) return;
lastOsuStatus = windowTitle;
if (!windowTitle.includes("-")) {
const currentStatusRequest = await fetch("https://api.ez-pp.farm/get_player_status?name=" + currentUser.username);
const currentStatus = await currentStatusRequest.json();
if (!("player_status" in currentStatus)) return;
if (!("status" in currentStatus.player_status)) return;
let details = "Idle...";
let infoText = currentStatus.player_status.status.info_text.length > 0 ? currentStatus.player_status.status.info_text : " ";
switch (currentStatus.player_status.status.action) {
case 1:
details = "AFK..."
infoText = " ";
break;
case 2:
details = "Playing...";
break;
case 3:
details = "Editing...";
break;
case 4:
details = "Modding..."
break;
case 5:
details = "Multiplayer: Selecting a Beatmap...";
infoText = " ";
break;
case 6:
details = "Watching...";
break;
case 8:
details = "Testing...";
break;
case 9:
details = "Submitting...";
break;
case 11:
details = "Multiplayer: Idle...";
infoText = " ";
break;
case 12:
details = "Multiplayer: Playing...";
break;
case 13:
details = "Browsing osu!direct...";
infoText = " ";
break;
}
richPresence.updateStatus({
details: undefined,
state: "Idle..."
details,
state: infoText
})
} else {
const components = windowTitle.split(" - ");
/* const components = windowTitle.split(" - ");
const splitTitle = [components.shift(), components.join(" - ")]
const currentMap = splitTitle[1];
if (!currentMap.endsWith(".osu")) {
@ -64,10 +110,9 @@ function startOsuStatus() {
state: "Playing...",
details: currentMap
})
} */
}
}
}
}, 1000);
}, 2500);
}
function stopOsuStatus() {
@ -326,11 +371,12 @@ function registerIPCPipes() {
const onExitHook = () => {
mainWindow.show();
mainWindow.focus();
stopOsuStatus();
richPresence.updateVersion();
richPresence.updateStatus({
state: "Idle in Launcher...",
details: undefined
details: "Idle in Launcher...",
state: undefined
})
mainWindow.webContents.send("ezpplauncher:launchstatus", {
status: "Waiting for cleanup...",
@ -345,14 +391,6 @@ function registerIPCPipes() {
runOsuWithDevServer(osuPath, "ez-pp.farm", onExitHook);
mainWindow.hide();
startOsuStatus();
/* mainWindow.webContents.send("ezpplauncher:launchprogress", {
progress: 0,
});
mainWindow.webContents.send("ezpplauncher:launchprogress", {
progress: 100,
}); */
return true;
});
}

View File

@ -5,8 +5,8 @@ const clientId = "1032772293220384808";
let richPresence;
let currentStatus = {
details: " ",
state: "Idle in Launcher...",
state: " ",
details: "Idle in Launcher...",
startTimestamp: new Date(),
largeImageKey: "ezppfarm",
largeImageText: `${appName} ${appVersion}`,