switch details and state
This commit is contained in:
parent
6369c0e8af
commit
01905d695a
92
main.js
92
main.js
|
@ -48,26 +48,71 @@ 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);
|
||||||
richPresence.updateStatus({
|
const currentStatus = await currentStatusRequest.json();
|
||||||
details: undefined,
|
|
||||||
state: "Idle..."
|
if (!("player_status" in currentStatus)) return;
|
||||||
})
|
if (!("status" in currentStatus.player_status)) return;
|
||||||
} else {
|
|
||||||
const components = windowTitle.split(" - ");
|
let details = "Idle...";
|
||||||
const splitTitle = [components.shift(), components.join(" - ")]
|
let infoText = currentStatus.player_status.status.info_text.length > 0 ? currentStatus.player_status.status.info_text : " ";
|
||||||
const currentMap = splitTitle[1];
|
|
||||||
if (!currentMap.endsWith(".osu")) {
|
switch (currentStatus.player_status.status.action) {
|
||||||
richPresence.updateStatus({
|
case 1:
|
||||||
state: "Playing...",
|
details = "AFK..."
|
||||||
details: currentMap
|
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,
|
||||||
|
state: infoText
|
||||||
|
})
|
||||||
|
/* const components = windowTitle.split(" - ");
|
||||||
|
const splitTitle = [components.shift(), components.join(" - ")]
|
||||||
|
const currentMap = splitTitle[1];
|
||||||
|
if (!currentMap.endsWith(".osu")) {
|
||||||
|
richPresence.updateStatus({
|
||||||
|
state: "Playing...",
|
||||||
|
details: currentMap
|
||||||
|
})
|
||||||
|
} */
|
||||||
}
|
}
|
||||||
}, 1000);
|
}, 2500);
|
||||||
}
|
}
|
||||||
|
|
||||||
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;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -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}`,
|
||||||
|
|
Loading…
Reference in New Issue
Block a user