Compare commits
2 Commits
1739618278
...
dev
Author | SHA1 | Date | |
---|---|---|---|
9c1e958715 | |||
084409a955 |
@@ -34,23 +34,22 @@ module.exports = {
|
|||||||
if (!richPresence) {
|
if (!richPresence) {
|
||||||
richPresence = new DiscordRPC.AutoClient({ transport: "ipc" });
|
richPresence = new DiscordRPC.AutoClient({ transport: "ipc" });
|
||||||
richPresence.endlessLogin({ clientId });
|
richPresence.endlessLogin({ clientId });
|
||||||
richPresence.once("ready", () => {
|
richPresence.once("ready", async () => {
|
||||||
console.log(
|
console.log(
|
||||||
"connected presence with user " + richPresence.user.username,
|
"connected presence with user " + richPresence.user.username,
|
||||||
);
|
);
|
||||||
richPresence.setActivity(currentStatus);
|
await richPresence.setActivity(currentStatus);
|
||||||
intervalId = setInterval(() => {
|
intervalId = setInterval(() => richPresence.setActivity(currentStatus), 2500);
|
||||||
richPresence.setActivity(currentStatus);
|
|
||||||
}, 2500);
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
disconnect: async () => {
|
disconnect: async () => {
|
||||||
if (richPresence) {
|
if (richPresence) {
|
||||||
clearInterval(intervalId);
|
const presence = richPresence;
|
||||||
await richPresence.clearActivity();
|
|
||||||
await richPresence.destroy();
|
|
||||||
richPresence = null;
|
richPresence = null;
|
||||||
|
clearInterval(intervalId);
|
||||||
|
await presence.clearActivity();
|
||||||
|
await presence.destroy();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
updateStatus: ({ state, details, largeImageKey }) => {
|
updateStatus: ({ state, details, largeImageKey }) => {
|
||||||
@@ -62,9 +61,9 @@ module.exports = {
|
|||||||
currentStatus.smallImageKey = id ? `https://a.ez-pp.farm/${id}` : " ";
|
currentStatus.smallImageKey = id ? `https://a.ez-pp.farm/${id}` : " ";
|
||||||
currentStatus.smallImageText = username ?? " ";
|
currentStatus.smallImageText = username ?? " ";
|
||||||
},
|
},
|
||||||
update: () => {
|
update: async () => {
|
||||||
if (richPresence && richPresence.user) {
|
if (richPresence && richPresence.user) {
|
||||||
richPresence.setActivity(currentStatus);
|
await richPresence.setActivity(currentStatus);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
hasPresence: () => richPresence != undefined,
|
hasPresence: () => richPresence != undefined,
|
||||||
|
49
main.js
49
main.js
@@ -1,5 +1,5 @@
|
|||||||
// Modules to control application life and create native browser window
|
// Modules to control application life and create native browser window
|
||||||
const { app, BrowserWindow, Menu, ipcMain, dialog, shell } = require(
|
const { app, BrowserWindow, Menu, ipcMain, dialog, shell, protocol, session } = require(
|
||||||
"electron",
|
"electron",
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -98,7 +98,7 @@ function startOsuStatus() {
|
|||||||
id,
|
id,
|
||||||
username,
|
username,
|
||||||
});
|
});
|
||||||
richPresence.update();
|
await richPresence.update();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch {
|
} catch {
|
||||||
@@ -123,7 +123,7 @@ function startOsuStatus() {
|
|||||||
lastOsuStatus = windowTitle;
|
lastOsuStatus = windowTitle;
|
||||||
const currentStatusRequest = await fetch(
|
const currentStatusRequest = await fetch(
|
||||||
"https://api.ez-pp.farm/v1/get_player_status?name=" +
|
"https://api.ez-pp.farm/v1/get_player_status?name=" +
|
||||||
currentUser.username,
|
currentUser.username,
|
||||||
{
|
{
|
||||||
headers: {
|
headers: {
|
||||||
"User-Agent":
|
"User-Agent":
|
||||||
@@ -141,7 +141,7 @@ function startOsuStatus() {
|
|||||||
|
|
||||||
const currentInfoRequest = await fetch(
|
const currentInfoRequest = await fetch(
|
||||||
"https://api.ez-pp.farm/v1/get_player_info?name=" +
|
"https://api.ez-pp.farm/v1/get_player_info?name=" +
|
||||||
currentUser.username + "&scope=all",
|
currentUser.username + "&scope=all",
|
||||||
{
|
{
|
||||||
headers: {
|
headers: {
|
||||||
"User-Agent":
|
"User-Agent":
|
||||||
@@ -235,7 +235,7 @@ function startOsuStatus() {
|
|||||||
largeImageKey,
|
largeImageKey,
|
||||||
});
|
});
|
||||||
|
|
||||||
richPresence.update();
|
await richPresence.update();
|
||||||
}
|
}
|
||||||
}, 2500);
|
}, 2500);
|
||||||
}
|
}
|
||||||
@@ -554,9 +554,8 @@ function registerIPCPipes() {
|
|||||||
progress: Math.ceil(data.progress),
|
progress: Math.ceil(data.progress),
|
||||||
});
|
});
|
||||||
mainWindow.webContents.send("ezpplauncher:launchstatus", {
|
mainWindow.webContents.send("ezpplauncher:launchstatus", {
|
||||||
status: `Downloading ${data.fileName}(${formatBytes(data.loaded)}/${
|
status: `Downloading ${data.fileName}(${formatBytes(data.loaded)}/${formatBytes(data.total)
|
||||||
formatBytes(data.total)
|
})...`,
|
||||||
})...`,
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
await updateDownloader.startDownload();
|
await updateDownloader.startDownload();
|
||||||
@@ -612,9 +611,8 @@ function registerIPCPipes() {
|
|||||||
progress: Math.ceil(data.progress),
|
progress: Math.ceil(data.progress),
|
||||||
});
|
});
|
||||||
mainWindow.webContents.send("ezpplauncher:launchstatus", {
|
mainWindow.webContents.send("ezpplauncher:launchstatus", {
|
||||||
status: `Downloading ${data.fileName}(${
|
status: `Downloading ${data.fileName}(${formatBytes(data.loaded)
|
||||||
formatBytes(data.loaded)
|
}/${formatBytes(data.total)})...`,
|
||||||
}/${formatBytes(data.total)})...`,
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
patcherDownloader.eventEmitter.on("delete", (data) => {
|
patcherDownloader.eventEmitter.on("delete", (data) => {
|
||||||
@@ -732,7 +730,7 @@ function registerIPCPipes() {
|
|||||||
|
|
||||||
logger.log("Launching osu!...");
|
logger.log("Launching osu!...");
|
||||||
|
|
||||||
const onExitHook = () => {
|
const onExitHook = async () => {
|
||||||
logger.log("osu! has exited.");
|
logger.log("osu! has exited.");
|
||||||
mainWindow.show();
|
mainWindow.show();
|
||||||
mainWindow.focus();
|
mainWindow.focus();
|
||||||
@@ -745,7 +743,7 @@ function registerIPCPipes() {
|
|||||||
state: "Idle in Launcher...",
|
state: "Idle in Launcher...",
|
||||||
details: undefined,
|
details: undefined,
|
||||||
});
|
});
|
||||||
richPresence.update();
|
await richPresence.update();
|
||||||
mainWindow.webContents.send("ezpplauncher:launchstatus", {
|
mainWindow.webContents.send("ezpplauncher:launchstatus", {
|
||||||
status: "Waiting for cleanup...",
|
status: "Waiting for cleanup...",
|
||||||
});
|
});
|
||||||
@@ -757,8 +755,7 @@ function registerIPCPipes() {
|
|||||||
const osuGameplayFile = path.join(osuPath, "osu!gameplay.dll");
|
const osuGameplayFile = path.join(osuPath, "osu!gameplay.dll");
|
||||||
if (isWritable(osuUIFile) && isWritable(osuGameplayFile)) {
|
if (isWritable(osuUIFile) && isWritable(osuGameplayFile)) {
|
||||||
logger.log(
|
logger.log(
|
||||||
`Cleanup complete, took ${
|
`Cleanup complete, took ${((performance.now() - timeStart) / 1000).toFixed(3)
|
||||||
((performance.now() - timeStart) / 1000).toFixed(3)
|
|
||||||
} seconds.`,
|
} seconds.`,
|
||||||
);
|
);
|
||||||
clearInterval(cleanup);
|
clearInterval(cleanup);
|
||||||
@@ -789,7 +786,18 @@ function createWindow() {
|
|||||||
app.quit();
|
app.quit();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
app.on('second-instance', (e, argv) => {
|
||||||
|
if (process.platform !== 'darwin') {
|
||||||
|
// Find the arg that is our custom protocol url and store it
|
||||||
|
const deeplinkingUrl = argv.find((arg) => arg.startsWith('ezpplauncher://'));
|
||||||
|
console.log(deeplinkingUrl);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mainWindow) {
|
||||||
|
if (mainWindow.isMinimized()) mainWindow.restore();
|
||||||
|
mainWindow.focus();
|
||||||
|
}
|
||||||
|
});
|
||||||
setupTitlebar();
|
setupTitlebar();
|
||||||
|
|
||||||
// Create the browser window.
|
// Create the browser window.
|
||||||
@@ -870,7 +878,16 @@ function createWindow() {
|
|||||||
// This method will be called when Electron has finished
|
// This method will be called when Electron has finished
|
||||||
// initialization and is ready to create browser windows.
|
// initialization and is ready to create browser windows.
|
||||||
// Some APIs can only be used after this event occurs.
|
// Some APIs can only be used after this event occurs.
|
||||||
app.whenReady().then(createWindow)
|
app.whenReady().then(() => {
|
||||||
|
createWindow();
|
||||||
|
if (isDev() && process.platform === 'win32') {
|
||||||
|
app.setAsDefaultProtocolClient('ezpplauncher', process.execPath, [
|
||||||
|
path.resolve(process.argv[1])
|
||||||
|
]);
|
||||||
|
} else {
|
||||||
|
app.setAsDefaultProtocolClient('ezpplauncher');
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
// Quit when all windows are closed.
|
// Quit when all windows are closed.
|
||||||
app.on("window-all-closed", async function () {
|
app.on("window-all-closed", async function () {
|
||||||
|
10
package.json
10
package.json
@@ -22,7 +22,15 @@
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
"linux": {},
|
"linux": {},
|
||||||
"mac": {}
|
"mac": {},
|
||||||
|
"protocols": [
|
||||||
|
{
|
||||||
|
"name": "ezpplauncher",
|
||||||
|
"schemes": [
|
||||||
|
"ezpplauncher"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "rollup -c --bundleConfigAsCjs",
|
"build": "rollup -c --bundleConfigAsCjs",
|
||||||
|
Reference in New Issue
Block a user