Compare commits
No commits in common. "356ec5d7e0b0a8d03f8e0f00f6a767db2b2b63be" and "65b607fb31fa5790bcdfbca54e5f6cece6817c5d" have entirely different histories.
356ec5d7e0
...
65b607fb31
8
app.js
8
app.js
@ -1,7 +1,6 @@
|
|||||||
const { app, BrowserWindow, ipcMain, dialog } = require('electron');
|
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 run = () => {
|
const run = () => {
|
||||||
const gotTheLock = app.requestSingleInstanceLock()
|
const gotTheLock = app.requestSingleInstanceLock()
|
||||||
@ -21,14 +20,11 @@ const run = () => {
|
|||||||
app.on('window-all-closed', () => {
|
app.on('window-all-closed', () => {
|
||||||
app.quit()
|
app.quit()
|
||||||
})
|
})
|
||||||
ipcMain.handle('set-osu-dir', async (event) => {
|
ipcMain.handle('open-folder-dialog', async (event) => {
|
||||||
const yes = await dialog.showOpenDialog({
|
const yes = await dialog.showOpenDialog({
|
||||||
properties: ['openDirectory']
|
properties: ['openDirectory']
|
||||||
})
|
})
|
||||||
if (yes.filePaths.length <= 0)
|
return yes.filePaths;
|
||||||
return undefined;
|
|
||||||
const folderPath = yes.filePaths[0];
|
|
||||||
return osuUtil.isValidOsuFolder(folderPath);
|
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
42
osuUtil.js
42
osuUtil.js
@ -1,42 +0,0 @@
|
|||||||
const fs = require('fs');
|
|
||||||
const path = require('path');
|
|
||||||
|
|
||||||
const osuEntities = [
|
|
||||||
'avcodec-51.dll',
|
|
||||||
'avformat-52.dll',
|
|
||||||
'avutil-49.dll',
|
|
||||||
'bass.dll',
|
|
||||||
'bass_fx.dll',
|
|
||||||
'collection.db',
|
|
||||||
'd3dcompiler_47.dll',
|
|
||||||
'Data',
|
|
||||||
'Downloads',
|
|
||||||
'libEGL.dll',
|
|
||||||
'libGLESv2.dll',
|
|
||||||
'Logs',
|
|
||||||
'Microsoft.Ink.dll',
|
|
||||||
'OpenTK.dll',
|
|
||||||
'osu!.cfg',
|
|
||||||
'osu!.db',
|
|
||||||
'osu!.exe',
|
|
||||||
'osu!auth.dll',
|
|
||||||
'osu!gameplay.dll',
|
|
||||||
'osu!seasonal.dll',
|
|
||||||
'osu!ui.dll',
|
|
||||||
'presence.db',
|
|
||||||
'pthreadGC2.dll',
|
|
||||||
'scores.db',
|
|
||||||
'Skins',
|
|
||||||
'Songs'
|
|
||||||
]
|
|
||||||
|
|
||||||
async function isValidOsuFolder(path) {
|
|
||||||
const allFiles = await fs.promises.readdir(path);
|
|
||||||
let matches = 0;
|
|
||||||
for (const file of allFiles) {
|
|
||||||
if (osuEntities.includes(file)) matches = matches + 1;
|
|
||||||
}
|
|
||||||
return Math.round((matches / osuEntities.length) * 100) >= 60;
|
|
||||||
}
|
|
||||||
|
|
||||||
module.exports = { isValidOsuFolder }
|
|
@ -16,9 +16,7 @@ window.addEventListener('DOMContentLoaded', () => {
|
|||||||
const $ = require('jquery');
|
const $ = require('jquery');
|
||||||
|
|
||||||
$("#folder-btn").on('click', async () => {
|
$("#folder-btn").on('click', async () => {
|
||||||
const success = await ipcRenderer.invoke('set-osu-dir');
|
const folderLoc = await ipcRenderer.invoke('open-folder-dialog');
|
||||||
if (success == undefined)
|
alert(folderLoc);
|
||||||
return;
|
|
||||||
alert(success);
|
|
||||||
});
|
});
|
||||||
})
|
})
|
Loading…
x
Reference in New Issue
Block a user