3 Commits

Author SHA1 Message Date
37567b5767 bump version 2022-10-21 00:59:19 +02:00
0a780b84e4 forgor to remove debug log 2022-10-21 00:59:11 +02:00
c8a07fbb0d add basic discord rpc, showing osu status 2022-10-21 00:57:42 +02:00
5 changed files with 114 additions and 3 deletions

3
.gitignore vendored
View File

@@ -1,3 +1,4 @@
node_modules/
release/
yarn.lock
yarn.lock
pnpm-lock.yaml

38
app.js
View File

@@ -5,8 +5,11 @@ const osuUtil = require('./osuUtil');
const ezppUtil = require('./ezppUtil');
const config = require('./config');
const fs = require('fs');
const rpc = require('./discordPresence');
const windowName = require('get-window-by-name');
let tempOsuPath;
let osuWindowInfo;
const run = () => {
const gotTheLock = app.requestSingleInstanceLock()
@@ -15,8 +18,42 @@ const run = () => {
return;
}
setInterval(() => {
osuWindowInfo = windowName.getWindowText("osu!.exe");
const firstInstance = osuWindowInfo[0];
if (firstInstance) {
if (firstInstance.processTitle && firstInstance.processTitle.length > 0) {
const windowTitle = firstInstance.processTitle;
let rpcOsuVersion = "";
let currentMap = undefined;
if (!windowTitle.includes("-")) {
rpcOsuVersion = windowTitle;
rpc.updateState("Idle...");
} else {
var string = windowTitle;
var components = string.split(' - ');
const splitArray = [components.shift(), components.join(' - ')];
rpcOsuVersion = splitArray[0];
currentMap = splitArray[1];
rpc.updateState("Playing...");
}
rpc.updateStatus(currentMap, rpcOsuVersion);
} else {
rpc.updateState("Idle in Launcher...");
rpc.updateStatus(undefined, undefined);
}
} else {
rpc.updateState("Idle in Launcher...");
rpc.updateStatus(undefined, undefined);
}
}, 2000);
setupTitlebar();
rpc.connect();
let mainWindow;
app.whenReady().then(() => {
@@ -46,6 +83,7 @@ const run = () => {
await osuUtil.setConfigValue(osuConfig.path, "Username", "");
await osuUtil.setConfigValue(osuConfig.path, "Password", "");
}
rpc.updateState("Launching osu!...");
const result = await osuUtil.startOsuWithDevServer(tempOsuPath, "ez-pp.farm", async () => {
await doUpdateCheck(mainWindow);
});

View File

@@ -1,4 +1,4 @@
const appName = "EZPPLauncher"
const appVersion = "1.1.0";
const appVersion = "1.1.1";
module.exports = { appName, appVersion };

69
discordPresence.js Normal file
View File

@@ -0,0 +1,69 @@
const appInfo = require('./appInfo.js');
const DiscordAutoRPC = require("discord-auto-rpc");
const { app } = require('electron');
const DiscordRPC = require("discord-rpc").default;
const clientId = "1032772293220384808";
let client = undefined;
let lastState = "Idle in Launcher...";
let presenceEnabled = true;
let startDate = new Date();
let lastActivity = {
details: " ",
state: lastState,
startTimestamp: startDate,
largeImageKey: "ezppfarm",
largeImageText: appInfo.appName + " " + appInfo.appVersion,
buttons: [
{
label: "Download the Launcher",
url: "https://ez-pp.farm/download"
},
{
label: "Join EZPPFarm",
url: "https://discord.com/invite/g8Bh7RaKPg"
}
],
instance: false,
};
module.exports = {
connect: () => {
if (client === undefined) {
client = new DiscordAutoRPC.AutoClient({ transport: "ipc" });
client.endlessLogin({ clientId: clientId });
client.once("ready", () => {
setInterval(() => {
if (lastActivity !== undefined)
lastActivity.state = lastState;
client.setActivity(presenceEnabled ? lastActivity : undefined);
}, 2500);
});
}
},
enablePresence: () => presenceEnabled = true,
disablePresence: () => presenceEnabled = false,
updateStartDate: () => startDate = new Date(),
updateState: (state) => lastState = state,
updateStatus: (details, osuVersion) => {
lastActivity = {
details: details ? details : " ",
state: lastState,
startTimestamp: startDate,
smallImageKey: osuVersion ? "osu" : " ",
smallImageText: osuVersion ? osuVersion : " ",
largeImageKey: "ezppfarm",
largeImageText: appInfo.appName + " " + appInfo.appVersion,
buttons: [
{
label: "Download the Launcher",
url: "https://ez-pp.farm/download"
},
{
label: "Join EZPPFarm",
url: "https://discord.com/invite/g8Bh7RaKPg"
}
],
instance: false,
}
}
}

View File

@@ -1,6 +1,6 @@
{
"name": "ezpplauncher",
"version": "1.1.0",
"version": "1.1.1",
"main": "app.js",
"license": "MIT",
"author": "HorizonCode",
@@ -50,6 +50,9 @@
"dependencies": {
"axios": "^0.27.2",
"custom-electron-titlebar": "^4.1.1",
"discord-auto-rpc": "^1.0.17",
"discord-rpc": "^4.0.1",
"get-window-by-name": "^2.0.0",
"jquery": "^3.6.0",
"node-downloader-helper": "^2.1.4",
"sweetalert2": "^11.5.2",