some experimental stuff 👀
This commit is contained in:
parent
769a88521e
commit
42777c9e0c
17
.vscode/launch.json
vendored
Normal file
17
.vscode/launch.json
vendored
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
{
|
||||||
|
"version": "0.2.0",
|
||||||
|
"configurations": [
|
||||||
|
{
|
||||||
|
"name": "Debug Main Process",
|
||||||
|
"type": "node",
|
||||||
|
"request": "launch",
|
||||||
|
"cwd": "${workspaceFolder}",
|
||||||
|
"runtimeExecutable": "${workspaceFolder}/node_modules/.bin/electron",
|
||||||
|
"windows": {
|
||||||
|
"runtimeExecutable": "${workspaceFolder}/node_modules/.bin/electron.cmd"
|
||||||
|
},
|
||||||
|
"args" : ["."],
|
||||||
|
"outputCapture": "std"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
17
app.js
17
app.js
|
@ -195,11 +195,19 @@ const run = () => {
|
||||||
} else linuxWMCtrlFound = true;
|
} else linuxWMCtrlFound = true;
|
||||||
} else {
|
} else {
|
||||||
const osuFolder = await config.get("osuPath");
|
const osuFolder = await config.get("osuPath");
|
||||||
|
console.log(osuFolder, !osuFolder || osuFolder == "");
|
||||||
if (!osuFolder || osuFolder == "") {
|
if (!osuFolder || osuFolder == "") {
|
||||||
const foundFolder = await osuUtil.findOsuInstallation();
|
const foundFolder = await osuUtil.findOsuInstallation();
|
||||||
|
if (foundFolder && osuUtil.isValidOsuFolder(foundFolder)) {
|
||||||
|
mainWindow.webContents.send('alert_message', foundFolder);
|
||||||
|
}
|
||||||
console.log("osu! Installation located at: ", foundFolder);
|
console.log("osu! Installation located at: ", foundFolder);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
});
|
||||||
|
ipcMain.on("alert_response", async (event, path) => {
|
||||||
|
console.log("yes");
|
||||||
|
await config.set("osuPath", path);
|
||||||
})
|
})
|
||||||
app.on('activate', function () {
|
app.on('activate', function () {
|
||||||
if (BrowserWindow.getAllWindows().length === 0) mainWindow = createWindow();
|
if (BrowserWindow.getAllWindows().length === 0) mainWindow = createWindow();
|
||||||
|
@ -208,6 +216,8 @@ const run = () => {
|
||||||
app.quit()
|
app.quit()
|
||||||
})
|
})
|
||||||
ipcMain.handle('launch', async () => {
|
ipcMain.handle('launch', async () => {
|
||||||
|
const osuFolder = await config.get("osuPath");
|
||||||
|
await osuUtil.updateOsuCfg(path.join(osuFolder, "osu!.cfg"));
|
||||||
const osuConfig = await osuUtil.getLatestConfig(tempOsuPath);
|
const osuConfig = await osuUtil.getLatestConfig(tempOsuPath);
|
||||||
const username = await config.get('username');
|
const username = await config.get('username');
|
||||||
const password = await config.get('password');
|
const password = await config.get('password');
|
||||||
|
@ -221,13 +231,17 @@ const run = () => {
|
||||||
await osuUtil.setConfigValue(osuConfig.path, "Username", "");
|
await osuUtil.setConfigValue(osuConfig.path, "Username", "");
|
||||||
await osuUtil.setConfigValue(osuConfig.path, "Password", "");
|
await osuUtil.setConfigValue(osuConfig.path, "Password", "");
|
||||||
}
|
}
|
||||||
|
await osuUtil.replaceUI(osuFolder, true);
|
||||||
rpc.updateState("Launching osu!...");
|
rpc.updateState("Launching osu!...");
|
||||||
isIngame = true;
|
isIngame = true;
|
||||||
if (mainWindow.isVisible()) mainWindow.hide();
|
if (mainWindow.isVisible()) mainWindow.hide();
|
||||||
const result = await osuUtil.startOsuWithDevServer(tempOsuPath, "ez-pp.farm", async () => {
|
const result = await osuUtil.startOsuWithDevServer(tempOsuPath, "ez-pp.farm", async () => {
|
||||||
isIngame = false;
|
|
||||||
if (!mainWindow.isVisible()) mainWindow.show();
|
if (!mainWindow.isVisible()) mainWindow.show();
|
||||||
|
setTimeout(async () => {
|
||||||
|
isIngame = false;
|
||||||
|
await osuUtil.replaceUI(osuFolder, false);
|
||||||
await doUpdateCheck(mainWindow);
|
await doUpdateCheck(mainWindow);
|
||||||
|
}, 2000);
|
||||||
});
|
});
|
||||||
return result;
|
return result;
|
||||||
})
|
})
|
||||||
|
@ -344,6 +358,7 @@ async function tryLogin(window) {
|
||||||
|
|
||||||
async function doUpdateCheck(window) {
|
async function doUpdateCheck(window) {
|
||||||
const osuPath = await config.get("osuPath");
|
const osuPath = await config.get("osuPath");
|
||||||
|
console.log("osuPath:", osuPath);
|
||||||
if (!osuPath || osuPath.trim == "") {
|
if (!osuPath || osuPath.trim == "") {
|
||||||
window.webContents.send('status_update', {
|
window.webContents.send('status_update', {
|
||||||
type: "missing-folder"
|
type: "missing-folder"
|
||||||
|
|
|
@ -13,6 +13,19 @@ body {
|
||||||
background-color: hsl(var(--main-bg), 24%, 19%);
|
background-color: hsl(var(--main-bg), 24%, 19%);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
p.text-white {
|
||||||
|
margin: .5rem 0;
|
||||||
|
color: white;
|
||||||
|
}
|
||||||
|
|
||||||
|
.quotetext {
|
||||||
|
color: white;
|
||||||
|
background-color: #727272;
|
||||||
|
border-radius: .35rem;
|
||||||
|
font-size: .95rem;
|
||||||
|
padding: .25rem .5rem;
|
||||||
|
}
|
||||||
|
|
||||||
.sections {
|
.sections {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-flow: column;
|
flex-flow: column;
|
||||||
|
|
54
osuUtil.js
54
osuUtil.js
|
@ -8,8 +8,10 @@ const { EventEmitter } = require('events');
|
||||||
const { DownloaderHelper } = require('node-downloader-helper');
|
const { DownloaderHelper } = require('node-downloader-helper');
|
||||||
|
|
||||||
const checkUpdateURL = "https://osu.ppy.sh/web/check-updates.php?action=check&stream=";
|
const checkUpdateURL = "https://osu.ppy.sh/web/check-updates.php?action=check&stream=";
|
||||||
|
const customUIDLLPath = "";
|
||||||
|
const customUIDLLName = "ezpp!ui.dll";
|
||||||
const ignoredOsuEntities = [
|
const ignoredOsuEntities = [
|
||||||
'osu!auth.dll'
|
'osu!auth.dll',
|
||||||
]
|
]
|
||||||
const osuEntities = [
|
const osuEntities = [
|
||||||
'avcodec-51.dll',
|
'avcodec-51.dll',
|
||||||
|
@ -174,6 +176,34 @@ async function setConfigValue(configPath, key, value) {
|
||||||
}
|
}
|
||||||
await fs.promises.writeFile(configPath, configLines.join("\n"), 'utf-8');
|
await fs.promises.writeFile(configPath, configLines.join("\n"), 'utf-8');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function updateOsuCfg(cfgPath) {
|
||||||
|
const osuFolder = path.dirname(cfgPath);
|
||||||
|
const fileStream = await fs.promises.readFile(cfgPath, "utf-8");
|
||||||
|
const lines = fileStream.split(/\r?\n/);
|
||||||
|
const newLines = [];
|
||||||
|
for (const line of lines) {
|
||||||
|
if (line.includes(' = ')) {
|
||||||
|
const argsPair = line.split(' = ', 2);
|
||||||
|
const keyname = argsPair[0]
|
||||||
|
const value = argsPair[1];
|
||||||
|
|
||||||
|
if (keyname.startsWith("h_")) {
|
||||||
|
const filename = keyname.substring(2, keyname.length);
|
||||||
|
const filepath = path.join(osuFolder, filename);
|
||||||
|
if (!fs.existsSync(filepath)) continue;
|
||||||
|
const binaryFileContents = await fs.promises.readFile(filepath);
|
||||||
|
const existingFileMD5 = crypto.createHash("md5").update(binaryFileContents).digest("hex");
|
||||||
|
if (value == existingFileMD5) newLines.push(line)
|
||||||
|
else newLines.push(`${keyname} = ${existingFileMD5}`);
|
||||||
|
} else {
|
||||||
|
newLines.push(line);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
await fs.promises.writeFile(cfgPath, newLines.join("\n"), 'utf-8');
|
||||||
|
}
|
||||||
|
|
||||||
async function findOsuInstallation() {
|
async function findOsuInstallation() {
|
||||||
const regedit = require('qiao-regedit');
|
const regedit = require('qiao-regedit');
|
||||||
|
|
||||||
|
@ -183,14 +213,32 @@ async function findOsuInstallation() {
|
||||||
if (line.includes("REG_SZ")) {
|
if (line.includes("REG_SZ")) {
|
||||||
let value = (line.trim().split(" ")[2]);
|
let value = (line.trim().split(" ")[2]);
|
||||||
value = value.substring(1, value.length - 3);
|
value = value.substring(1, value.length - 3);
|
||||||
return value.trim();
|
return path.dirname(value.trim());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function replaceUI(folder, isStart) {
|
||||||
|
const ezppUIFile = path.join(folder, customUIDLLName);
|
||||||
|
const osuUIFile = path.join(folder, "osu!ui.dll");
|
||||||
|
const osuUIFileBackup = path.join(folder, "osu!ui.dll.bak");
|
||||||
|
if (isStart) {
|
||||||
|
if (fs.existsSync(osuUIFileBackup)) await fs.promises.unlink(osuUIFileBackup);
|
||||||
|
await fs.promises.rename(osuUIFile, osuUIFileBackup);
|
||||||
|
await new Promise((res) => setTimeout(res, 1000));
|
||||||
|
await fs.promises.rename(ezppUIFile, osuUIFile);
|
||||||
|
} else {
|
||||||
|
if (!fs.existsSync(osuUIFileBackup)) return;
|
||||||
|
await fs.promises.rename(osuUIFile, ezppUIFile);
|
||||||
|
await new Promise((res) => setTimeout(res, 1000));
|
||||||
|
await fs.promises.rename(osuUIFileBackup, osuUIFile);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
isValidOsuFolder, getLatestConfig, getUpdateFiles, filesThatNeedUpdate,
|
isValidOsuFolder, getLatestConfig, getUpdateFiles, filesThatNeedUpdate,
|
||||||
downloadUpdateFiles, startOsuWithDevServer: startWithDevServer, setConfigValue,
|
downloadUpdateFiles, startOsuWithDevServer: startWithDevServer, setConfigValue,
|
||||||
findOsuInstallation
|
findOsuInstallation, replaceUI, updateOsuCfg
|
||||||
}
|
}
|
|
@ -188,6 +188,28 @@ window.addEventListener('DOMContentLoaded', () => {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
ipcRenderer.on('alert_message', async (event, path) => {
|
||||||
|
const res = await Swal.fire({
|
||||||
|
title: 'Hey!',
|
||||||
|
html: `<p class="text-white">Detected a osu! installation at</p><span class="quotetext">${path}</span><p class="text-white">Is this correct?</p>`,
|
||||||
|
icon: 'info',
|
||||||
|
showCancelButton: true,
|
||||||
|
confirmButtonText: 'Yes',
|
||||||
|
cancelButtonText: 'No',
|
||||||
|
});
|
||||||
|
if (res.isConfirmed) {
|
||||||
|
$('#currentOsuPath').text(path);
|
||||||
|
ipcRenderer.send('alert_response', path);
|
||||||
|
Swal.fire({
|
||||||
|
title: 'Success!',
|
||||||
|
text: 'osu! folder set.',
|
||||||
|
icon: 'success',
|
||||||
|
confirmButtonText: 'Cool'
|
||||||
|
})
|
||||||
|
ipcRenderer.send("do-update-check");
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
ipcRenderer.on('status_update', (event, status) => {
|
ipcRenderer.on('status_update', (event, status) => {
|
||||||
switch (status.type) {
|
switch (status.type) {
|
||||||
case "up-to-date":
|
case "up-to-date":
|
||||||
|
|
Loading…
Reference in New Issue
Block a user