Compare commits
No commits in common. "ae566f09a0fc88be3120b327e071f791c4a153e1" and "94fa7e7bd82e5699053c2ab7e2b0cc27e114ce72" have entirely different histories.
ae566f09a0
...
94fa7e7bd8
76
main.js
76
main.js
@ -68,62 +68,26 @@ function startOsuStatus() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const windowTitle = firstInstance.processTitle;
|
const windowTitle = firstInstance.processTitle;
|
||||||
|
if (lastOsuStatus == windowTitle) return;
|
||||||
lastOsuStatus = windowTitle;
|
lastOsuStatus = windowTitle;
|
||||||
const currentStatusRequest = await fetch("https://api.ez-pp.farm/get_player_status?name=" + currentUser.username);
|
if (!windowTitle.includes("-")) {
|
||||||
const currentStatus = await currentStatusRequest.json();
|
richPresence.updateStatus({
|
||||||
|
details: undefined,
|
||||||
if (!("player_status" in currentStatus)) return;
|
state: "Idle...",
|
||||||
if (!("status" in currentStatus.player_status)) return;
|
});
|
||||||
|
} else {
|
||||||
let details = "Idle...";
|
const components = windowTitle.split(" - ");
|
||||||
let infoText = currentStatus.player_status.status.info_text.length > 0 ? currentStatus.player_status.status.info_text : " ";
|
const splitTitle = [components.shift(), components.join(" - ")];
|
||||||
|
const currentMap = splitTitle[1];
|
||||||
switch (currentStatus.player_status.status.action) {
|
if (!currentMap.endsWith(".osu")) {
|
||||||
case 1:
|
richPresence.updateStatus({
|
||||||
details = "AFK..."
|
state: "Playing...",
|
||||||
infoText = " ";
|
details: currentMap,
|
||||||
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
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
}, 2500);
|
}, 1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
function stopOsuStatus() {
|
function stopOsuStatus() {
|
||||||
@ -457,13 +421,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...",
|
state: "Idle in Launcher...",
|
||||||
details: undefined
|
details: undefined,
|
||||||
})
|
});
|
||||||
mainWindow.webContents.send("ezpplauncher:launchstatus", {
|
mainWindow.webContents.send("ezpplauncher:launchstatus", {
|
||||||
status: "Waiting for cleanup...",
|
status: "Waiting for cleanup...",
|
||||||
});
|
});
|
||||||
@ -478,7 +441,6 @@ function registerIPCPipes() {
|
|||||||
mainWindow.hide();
|
mainWindow.hide();
|
||||||
startOsuStatus();
|
startOsuStatus();
|
||||||
|
|
||||||
|
|
||||||
/* mainWindow.webContents.send("ezpplauncher:launchprogress", {
|
/* mainWindow.webContents.send("ezpplauncher:launchprogress", {
|
||||||
progress: 0,
|
progress: 0,
|
||||||
});
|
});
|
||||||
|
@ -1,56 +0,0 @@
|
|||||||
const DiscordRPC = require("discord-auto-rpc");
|
|
||||||
const { appName, appVersion } = require("../../appInfo");
|
|
||||||
|
|
||||||
const clientId = "1032772293220384808";
|
|
||||||
let richPresence;
|
|
||||||
|
|
||||||
let currentStatus = {
|
|
||||||
state: " ",
|
|
||||||
details: "Idle in Launcher...",
|
|
||||||
startTimestamp: new Date(),
|
|
||||||
largeImageKey: "ezppfarm",
|
|
||||||
largeImageText: `${appName} ${appVersion}`,
|
|
||||||
smallImageKey: " ",
|
|
||||||
smallImageText: " ",
|
|
||||||
buttons: [
|
|
||||||
{
|
|
||||||
label: "Download the Launcher",
|
|
||||||
url: "https://git.ez-pp.farm/EZPPFarm/EZPPLauncher/releases/latest"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: "Join EZPPFarm",
|
|
||||||
url: "https://ez-pp.farm/discord"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
instance: false
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
module.exports = {
|
|
||||||
connect: () => {
|
|
||||||
if (!richPresence) {
|
|
||||||
richPresence = new DiscordRPC.AutoClient({ transport: "ipc" });
|
|
||||||
richPresence.endlessLogin({ clientId });
|
|
||||||
richPresence.once("ready", () => {
|
|
||||||
setInterval(() => {
|
|
||||||
richPresence.setActivity(currentStatus);
|
|
||||||
}, 2500)
|
|
||||||
});
|
|
||||||
}
|
|
||||||
},
|
|
||||||
disconnect: async () => {
|
|
||||||
if (richPresence) {
|
|
||||||
await richPresence.clearActivity();
|
|
||||||
await richPresence.destroy();
|
|
||||||
richPresence = null;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
updateStatus: ({ state, details }) => {
|
|
||||||
currentStatus.state = state ?? " ";
|
|
||||||
currentStatus.details = details ?? " ";
|
|
||||||
},
|
|
||||||
updateVersion: (osuVersion) => {
|
|
||||||
currentStatus.smallImageKey = osuVersion ? "osu" : " ";
|
|
||||||
currentStatus.smallImageText = osuVersion ? `osu! ${osuVersion}` : " ";
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
x
Reference in New Issue
Block a user