Compare commits
No commits in common. "830b1099ac67287c38c28bf4afdba8aebd6c9ef1" and "356ec5d7e0b0a8d03f8e0f00f6a767db2b2b63be" have entirely different histories.
830b1099ac
...
356ec5d7e0
26
app.js
26
app.js
@ -2,10 +2,6 @@ const { app, BrowserWindow, ipcMain, dialog } = require('electron');
|
|||||||
const { setupTitlebar, attachTitlebarToWindow } = require('custom-electron-titlebar/main');
|
const { setupTitlebar, attachTitlebarToWindow } = require('custom-electron-titlebar/main');
|
||||||
const windowManager = require('./ui/windowManager');
|
const windowManager = require('./ui/windowManager');
|
||||||
const osuUtil = require('./osuUtil');
|
const osuUtil = require('./osuUtil');
|
||||||
const config = require('./config');
|
|
||||||
const fs = require('fs');
|
|
||||||
|
|
||||||
let tempOsuPath;
|
|
||||||
|
|
||||||
const run = () => {
|
const run = () => {
|
||||||
const gotTheLock = app.requestSingleInstanceLock()
|
const gotTheLock = app.requestSingleInstanceLock()
|
||||||
@ -13,24 +9,12 @@ const run = () => {
|
|||||||
app.quit();
|
app.quit();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
setupTitlebar();
|
setupTitlebar();
|
||||||
|
|
||||||
let mainWindow;
|
let mainWindow;
|
||||||
app.whenReady().then(() => {
|
app.whenReady().then(() => {
|
||||||
|
|
||||||
mainWindow = createWindow();
|
mainWindow = createWindow()
|
||||||
mainWindow.on('show', async () => {
|
|
||||||
const osuPath = await config.get("osuPath", "");
|
|
||||||
if(fs.existsSync(osuPath)){
|
|
||||||
tempOsuPath = osuPath;
|
|
||||||
const osuConfig = await osuUtil.getLatestConfig(tempOsuPath);
|
|
||||||
console.log(osuConfig);
|
|
||||||
const lastVersion = await osuConfig.get("LastVersion");
|
|
||||||
console.log(lastVersion);
|
|
||||||
//Do update check
|
|
||||||
}
|
|
||||||
})
|
|
||||||
app.on('activate', function () {
|
app.on('activate', function () {
|
||||||
if (BrowserWindow.getAllWindows().length === 0) mainWindow = createWindow();
|
if (BrowserWindow.getAllWindows().length === 0) mainWindow = createWindow();
|
||||||
})
|
})
|
||||||
@ -44,18 +28,14 @@ const run = () => {
|
|||||||
if (yes.filePaths.length <= 0)
|
if (yes.filePaths.length <= 0)
|
||||||
return undefined;
|
return undefined;
|
||||||
const folderPath = yes.filePaths[0];
|
const folderPath = yes.filePaths[0];
|
||||||
const validOsuDir = osuUtil.isValidOsuFolder(folderPath);
|
return osuUtil.isValidOsuFolder(folderPath);
|
||||||
|
|
||||||
if (validOsuDir) await config.set("osuPath", folderPath);
|
|
||||||
|
|
||||||
return validOsuDir;
|
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
function createWindow() {
|
function createWindow() {
|
||||||
// Create the browser window.
|
// Create the browser window.
|
||||||
const win = windowManager.createWindow(480, 350);
|
const win = windowManager.createWindow(480, 420);
|
||||||
|
|
||||||
win.loadFile('./html/index.html');
|
win.loadFile('./html/index.html');
|
||||||
|
|
||||||
|
51
config.js
51
config.js
@ -1,51 +0,0 @@
|
|||||||
const path = require('path');
|
|
||||||
const fs = require('fs');
|
|
||||||
|
|
||||||
const configFolder = path.join(process.env['LOCALAPPDATA'], 'EZPPLauncher');
|
|
||||||
if (!fs.existsSync(configFolder)) fs.mkdirSync(configFolder);
|
|
||||||
|
|
||||||
const configLocation = path.join(configFolder, `ezpplauncher.${path.basename(process.env['HOME'])}.cfg`);
|
|
||||||
if (!fs.existsSync(configLocation)) fs.writeFileSync(configLocation, "");
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
async function get(key, defaultValue) {
|
|
||||||
const fileStream = await fs.promises.readFile(configLocation, "utf-8");
|
|
||||||
const lines = fileStream.split(/\r?\n/)
|
|
||||||
for (const line of lines) {
|
|
||||||
if (line.includes('=')) {
|
|
||||||
const argsPair = line.split('=', 2);
|
|
||||||
const keyname = argsPair[0]
|
|
||||||
const value = argsPair[1];
|
|
||||||
if (keyname == key) {
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return defaultValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
async function set(key, value) {
|
|
||||||
console.log("setting " + key + " to " + value);
|
|
||||||
const configValues = new Map();
|
|
||||||
const fileStream = await fs.promises.readFile(configLocation, "utf-8");
|
|
||||||
const lines = fileStream.split(/\r?\n/)
|
|
||||||
for (const line of lines) {
|
|
||||||
if (line.includes('=')) {
|
|
||||||
const argsPair = line.split('=', 2);
|
|
||||||
const keyname = argsPair[0]
|
|
||||||
const value = argsPair[1];
|
|
||||||
configValues.set(keyname, value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
configValues.set(key, value);
|
|
||||||
|
|
||||||
const arr = [];
|
|
||||||
for (var [storkey, storvalue] of configValues.entries())
|
|
||||||
arr.push(`${storkey}=${storvalue}`);
|
|
||||||
|
|
||||||
await fs.promises.writeFile(configLocation, arr.join('\n'));
|
|
||||||
}
|
|
||||||
|
|
||||||
module.exports = { get, set }
|
|
@ -17,7 +17,7 @@
|
|||||||
|
|
||||||
<body class="fixed-sn mdb-skin-custom" data-spy="scroll" data-target="#scrollspy" data-offset="15"
|
<body class="fixed-sn mdb-skin-custom" data-spy="scroll" data-target="#scrollspy" data-offset="15"
|
||||||
oncontextmenu="return false;">
|
oncontextmenu="return false;">
|
||||||
<main style="">
|
<main style="margin-top: 2rem;">
|
||||||
<div class="noselect">
|
<div class="noselect">
|
||||||
<div class="position-relative overflow-hidden p-3 p-md-5 m-md-3 text-center text-lg-end d-flex align-items-center justify-content-center"
|
<div class="position-relative overflow-hidden p-3 p-md-5 m-md-3 text-center text-lg-end d-flex align-items-center justify-content-center"
|
||||||
style="border-radius: 0.5em;">
|
style="border-radius: 0.5em;">
|
||||||
@ -28,19 +28,18 @@
|
|||||||
<div class="card" style="border-radius: 1rem;">
|
<div class="card" style="border-radius: 1rem;">
|
||||||
<div class="row g-0">
|
<div class="row g-0">
|
||||||
<div class="card-body p-4 p-lg-5 text-black">
|
<div class="card-body p-4 p-lg-5 text-black">
|
||||||
<div class="d-flex align-items-center mb-2 pb-1 text-white">
|
<div class="d-flex align-items-center mb-3 pb-1 text-white">
|
||||||
<span class="h1 fw-bold mb-0">EZPPLauncher</span>
|
<span class="h1 fw-bold mb-0">EZPPLauncher</span>
|
||||||
</div>
|
</div>
|
||||||
<h5 class="fw-lighter fs-5 mb-3 pb-3 text-white text-start"
|
<h5 class="fw-normal mb-3 pb-3 text-white text-start"
|
||||||
style="letter-spacing: 1px;">
|
style="letter-spacing: 1px;">
|
||||||
Launch osu! with connection to the EZPPFarm server
|
Launch osu! with connection to the EZPPFarm server
|
||||||
</h5>
|
</h5>
|
||||||
<div class="pt-1 mb-4">
|
<div class="pt-1 mb-4">
|
||||||
<button id="launch-btn" class="btn btn-primary btn-lg btn-block"
|
<button id="launch-btn" class="btn btn-primary btn-lg btn-block"
|
||||||
type="button" style="background-color:#d6016f"
|
type="button" style="background-color:#d6016f" disabled>Launch</button>
|
||||||
disabled>Launch</button>
|
|
||||||
</div>
|
</div>
|
||||||
<button class="btn btn-dark btn-sm float-end" id="folder-btn">
|
<button class="btn btn-dark btn-sm float-start" id="folder-btn">
|
||||||
set osu! directory
|
set osu! directory
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
42
osuUtil.js
42
osuUtil.js
@ -39,44 +39,4 @@ async function isValidOsuFolder(path) {
|
|||||||
return Math.round((matches / osuEntities.length) * 100) >= 60;
|
return Math.round((matches / osuEntities.length) * 100) >= 60;
|
||||||
}
|
}
|
||||||
|
|
||||||
async function getLatestConfig(osuPath) {
|
module.exports = { isValidOsuFolder }
|
||||||
const allFiles = await fs.promises.readdir(osuPath);
|
|
||||||
const configFileInfo = {
|
|
||||||
name: "",
|
|
||||||
path: "",
|
|
||||||
lastModified: 0,
|
|
||||||
get: async (key) => {
|
|
||||||
const fileStream = await fs.promises.readFile(configFileInfo.path, "utf-8");
|
|
||||||
const lines = fileStream.split(/\r?\n/)
|
|
||||||
for (const line of lines) {
|
|
||||||
if (line.includes(' = ')) {
|
|
||||||
const argsPair = line.split(' = ', 2);
|
|
||||||
const keyname = argsPair[0]
|
|
||||||
const value = argsPair[1];
|
|
||||||
if (keyname == key) {
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for (const file of allFiles) {
|
|
||||||
if (file.startsWith('osu!.') && file.endsWith('.cfg') && file !== "osu!.cfg") {
|
|
||||||
const fullFilePath = path.join(osuPath, file);
|
|
||||||
const fileStats = await fs.promises.stat(fullFilePath);
|
|
||||||
const lastModified = fileStats.mtimeMs;
|
|
||||||
if (lastModified > configFileInfo.lastModified) {
|
|
||||||
configFileInfo.name = file;
|
|
||||||
configFileInfo.path = fullFilePath;
|
|
||||||
configFileInfo.lastModified = lastModified;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return configFileInfo;
|
|
||||||
}
|
|
||||||
|
|
||||||
async function checkForUpdate(path) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
module.exports = { isValidOsuFolder, getLatestConfig }
|
|
@ -19,10 +19,6 @@ window.addEventListener('DOMContentLoaded', () => {
|
|||||||
const success = await ipcRenderer.invoke('set-osu-dir');
|
const success = await ipcRenderer.invoke('set-osu-dir');
|
||||||
if (success == undefined)
|
if (success == undefined)
|
||||||
return;
|
return;
|
||||||
if (success) {
|
alert(success);
|
||||||
|
|
||||||
} else {
|
|
||||||
//TODO: Alert User, invalid osu folder selected
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
})
|
})
|
@ -33,9 +33,9 @@ module.exports = {
|
|||||||
|
|
||||||
window.webContents.setUserAgent("EZPPLauncher");
|
window.webContents.setUserAgent("EZPPLauncher");
|
||||||
attachTitlebarToWindow(window);
|
attachTitlebarToWindow(window);
|
||||||
/* window.webContents.openDevTools({
|
window.webContents.openDevTools({
|
||||||
mode: "detach"
|
mode: "detach"
|
||||||
}); */
|
});
|
||||||
|
|
||||||
return window;
|
return window;
|
||||||
},
|
},
|
||||||
|
Loading…
x
Reference in New Issue
Block a user