Compare commits

...

2 Commits

Author SHA1 Message Date
c2a75319dc add alerts dark theme 2022-10-16 22:21:02 +02:00
2de6cc11cf fix folder detection on launch 2022-10-16 22:20:50 +02:00
3 changed files with 24 additions and 10 deletions

22
app.js
View File

@ -22,6 +22,13 @@ const run = () => {
mainWindow = createWindow();
mainWindow.on('show', async () => {
const osuPath = await config.get("osuPath", "");
const isValid = await osuUtil.isValidOsuFolder(osuPath);
if (osuPath.trim == "" || !isValid) {
mainWindow.webContents.send('status_update', {
type: "missing-folder"
})
return;
}
if (fs.existsSync(osuPath)) {
tempOsuPath = osuPath;
const osuConfig = await osuUtil.getLatestConfig(tempOsuPath);
@ -34,14 +41,17 @@ const run = () => {
const releaseFiles = await osuUtil.getUpdateFiles(releaseStream);
const filesToDownload = await osuUtil.filesThatNeedUpdate(tempOsuPath, releaseFiles);
/* const downloadTask = await osuUtil.downloadUpdateFiles(osuPath, filesToDownload);
downloadTask.on('completed', () => {
console.log("done!");
}); */
// const downloadTask = await osuUtil.downloadUpdateFiles(osuPath, filesToDownload);
// downloadTask.on('completed', () => {
// console.log("done!");
// });
mainWindow.webContents.send('status_update', {
type: filesToDownload.length > 0 ? "update-available" : "up-to-date"
})
}
} else
mainWindow.webContents.send('status_update', {
type: "missing-folder"
})
})
app.on('activate', function () {
if (BrowserWindow.getAllWindows().length === 0) mainWindow = createWindow();
@ -56,7 +66,7 @@ const run = () => {
if (yes.filePaths.length <= 0)
return undefined;
const folderPath = yes.filePaths[0];
const validOsuDir = osuUtil.isValidOsuFolder(folderPath);
const validOsuDir = await osuUtil.isValidOsuFolder(folderPath);
if (validOsuDir) await config.set("osuPath", folderPath);

View File

@ -7,7 +7,6 @@
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link rel="icon" type="image/png" href="../assets/logo.png" />
<link href="../assets/mdb.min.css" rel="stylesheet" />
<link href="../assets/sweetalert2.dark.css" rel="stylesheet" />
<style>
* {
user-select: none;

View File

@ -22,16 +22,16 @@ window.addEventListener('DOMContentLoaded', () => {
if (success) {
Swal.fire({
title: 'Success!',
text: 'osu! folder set!',
text: 'osu! folder set.',
icon: 'success',
confirmButtonText: 'Cool'
})
} else {
Swal.fire({
title: 'Uh oh!',
text: 'failed to set osu! folder.',
text: 'The selected folder is not a osu! directory.',
icon: 'error',
confirmButtonText: 'Cool'
confirmButtonText: 'Oops.. my bad!'
})
}
});
@ -46,6 +46,11 @@ window.addEventListener('DOMContentLoaded', () => {
$("#launch-btn").attr('disabled', false);
$('#launch-btn').html('Update');
break;
case "missing-folder":
$('#launch-btn').html('Please set your osu folder!');
}
})
// workaround for the dark theme
$('head').append($('<link href="../assets/sweetalert2.dark.css" rel="stylesheet" />'));
})