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;
|
||||
if (lastOsuStatus == windowTitle) return;
|
||||
lastOsuStatus = windowTitle;
|
||||
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;
|
||||
}
|
||||
|
||||
if (!windowTitle.includes("-")) {
|
||||
richPresence.updateStatus({
|
||||
details,
|
||||
state: infoText
|
||||
})
|
||||
details: undefined,
|
||||
state: "Idle...",
|
||||
});
|
||||
} else {
|
||||
const components = windowTitle.split(" - ");
|
||||
const splitTitle = [components.shift(), components.join(" - ")];
|
||||
const currentMap = splitTitle[1];
|
||||
if (!currentMap.endsWith(".osu")) {
|
||||
richPresence.updateStatus({
|
||||
state: "Playing...",
|
||||
details: currentMap,
|
||||
});
|
||||
}
|
||||
}, 2500);
|
||||
}
|
||||
}
|
||||
}, 1000);
|
||||
}
|
||||
|
||||
function stopOsuStatus() {
|
||||
@ -457,13 +421,12 @@ function registerIPCPipes() {
|
||||
|
||||
const onExitHook = () => {
|
||||
mainWindow.show();
|
||||
mainWindow.focus();
|
||||
stopOsuStatus();
|
||||
richPresence.updateVersion();
|
||||
richPresence.updateStatus({
|
||||
state: "Idle in Launcher...",
|
||||
details: undefined
|
||||
})
|
||||
details: undefined,
|
||||
});
|
||||
mainWindow.webContents.send("ezpplauncher:launchstatus", {
|
||||
status: "Waiting for cleanup...",
|
||||
});
|
||||
@ -478,7 +441,6 @@ function registerIPCPipes() {
|
||||
mainWindow.hide();
|
||||
startOsuStatus();
|
||||
|
||||
|
||||
/* mainWindow.webContents.send("ezpplauncher:launchprogress", {
|
||||
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