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; const windowTitle = firstInstance.processTitle;
if (lastOsuStatus == windowTitle) return;
lastOsuStatus = windowTitle; 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({ richPresence.updateStatus({
details: undefined, details,
state: "Idle..." state: infoText
}) })
} else { /* const components = windowTitle.split(" - ");
const components = windowTitle.split(" - ");
const splitTitle = [components.shift(), components.join(" - ")] const splitTitle = [components.shift(), components.join(" - ")]
const currentMap = splitTitle[1]; const currentMap = splitTitle[1];
if (!currentMap.endsWith(".osu")) { if (!currentMap.endsWith(".osu")) {
@ -64,10 +110,9 @@ function startOsuStatus() {
state: "Playing...", state: "Playing...",
details: currentMap details: currentMap
}) })
} */
} }
} }, 2500);
}
}, 1000);
} }
function stopOsuStatus() { function stopOsuStatus() {
@ -326,11 +371,12 @@ function registerIPCPipes() {
const onExitHook = () => { const onExitHook = () => {
mainWindow.show(); mainWindow.show();
mainWindow.focus();
stopOsuStatus(); stopOsuStatus();
richPresence.updateVersion(); richPresence.updateVersion();
richPresence.updateStatus({ richPresence.updateStatus({
state: "Idle in Launcher...", details: "Idle in Launcher...",
details: undefined state: undefined
}) })
mainWindow.webContents.send("ezpplauncher:launchstatus", { mainWindow.webContents.send("ezpplauncher:launchstatus", {
status: "Waiting for cleanup...", status: "Waiting for cleanup...",
@ -345,14 +391,6 @@ function registerIPCPipes() {
runOsuWithDevServer(osuPath, "ez-pp.farm", onExitHook); runOsuWithDevServer(osuPath, "ez-pp.farm", onExitHook);
mainWindow.hide(); mainWindow.hide();
startOsuStatus(); startOsuStatus();
/* mainWindow.webContents.send("ezpplauncher:launchprogress", {
progress: 0,
});
mainWindow.webContents.send("ezpplauncher:launchprogress", {
progress: 100,
}); */
return true; return true;
}); });
} }

View File

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