preperations for the patch method

This commit is contained in:
HorizonCode 2022-10-27 13:58:15 +02:00
parent 67a53fdd2d
commit 89cdc8f316

19
app.js
View File

@ -14,6 +14,7 @@ let osuWindowInfo;
let isIngame; let isIngame;
const platform = process.platform; const platform = process.platform;
let linuxWMCtrlFound = false; let linuxWMCtrlFound = false;
let osuLoaded = false;
const run = () => { const run = () => {
const gotTheLock = app.requestSingleInstanceLock() const gotTheLock = app.requestSingleInstanceLock()
@ -28,6 +29,10 @@ const run = () => {
const firstInstance = osuWindowInfo[0]; const firstInstance = osuWindowInfo[0];
if (firstInstance) { if (firstInstance) {
if (firstInstance.processTitle && firstInstance.processTitle.length > 0) { if (firstInstance.processTitle && firstInstance.processTitle.length > 0) {
if (!osuLoaded) {
osuLoaded = true;
//TODO: do patch
}
const windowTitle = firstInstance.processTitle; const windowTitle = firstInstance.processTitle;
let rpcOsuVersion = ""; let rpcOsuVersion = "";
let currentMap = undefined; let currentMap = undefined;
@ -40,7 +45,7 @@ const run = () => {
const splitArray = [components.shift(), components.join(' - ')]; const splitArray = [components.shift(), components.join(' - ')];
rpcOsuVersion = splitArray[0]; rpcOsuVersion = splitArray[0];
currentMap = splitArray[1]; currentMap = splitArray[1];
if(currentMap.endsWith(".osu")){ if (currentMap.endsWith(".osu")) {
rpc.updateState("Editing..."); rpc.updateState("Editing...");
currentMap = currentMap.substring(0, currentMap.length - 4); currentMap = currentMap.substring(0, currentMap.length - 4);
} else rpc.updateState("Playing..."); } else rpc.updateState("Playing...");
@ -48,10 +53,12 @@ const run = () => {
rpc.updateStatus(currentMap, rpcOsuVersion); rpc.updateStatus(currentMap, rpcOsuVersion);
} else { } else {
if (osuLoaded) osuLoaded = false;
rpc.updateState("Idle in Launcher..."); rpc.updateState("Idle in Launcher...");
rpc.updateStatus(undefined, undefined); rpc.updateStatus(undefined, undefined);
} }
} else { } else {
if (osuLoaded) osuLoaded = false;
rpc.updateState("Idle in Launcher..."); rpc.updateState("Idle in Launcher...");
rpc.updateStatus(undefined, undefined); rpc.updateStatus(undefined, undefined);
} }
@ -82,10 +89,10 @@ const run = () => {
const splitArray = [components.shift(), components.join(' - ')]; const splitArray = [components.shift(), components.join(' - ')];
rpcOsuVersion = splitArray[0]; rpcOsuVersion = splitArray[0];
currentMap = splitArray[1]; currentMap = splitArray[1];
if(currentMap.endsWith(".osu")){ if (currentMap.endsWith(".osu")) {
rpc.updateState("Editing..."); rpc.updateState("Editing...");
currentMap = currentMap.substring(0, currentMap.length - 4); currentMap = currentMap.substring(0, currentMap.length - 4);
} }
else rpc.updateState("Playing..."); else rpc.updateState("Playing...");
} }
@ -119,9 +126,9 @@ const run = () => {
await tryLogin(mainWindow); await tryLogin(mainWindow);
await doUpdateCheck(mainWindow); await doUpdateCheck(mainWindow);
if (platform === "linux") { if (platform === "linux") {
try{ try {
await terminalUtil.execCommand(`osu-stable -h`); await terminalUtil.execCommand(`osu-stable -h`);
}catch(err){ } catch (err) {
mainWindow.webContents.send('status_update', { mainWindow.webContents.send('status_update', {
type: "package-issue", type: "package-issue",
message: "Seems like you dont have the osu AUR Package installed, please install it." message: "Seems like you dont have the osu AUR Package installed, please install it."