EZPPLauncher/preload/preload.js

51 lines
1.5 KiB
JavaScript
Raw Normal View History

2022-10-16 13:54:29 +00:00
const { ipcRenderer } = require('electron');
const { Titlebar, Color } = require('custom-electron-titlebar');
let titlebar;
window.addEventListener('DOMContentLoaded', () => {
titlebar = new Titlebar({
backgroundColor: Color.fromHex("#303030"),
itemBackgroundColor: Color.fromHex("#121212"),
menu: null,
maximizable: false
});
titlebar.updateTitle("EZPPLauncher");
const $ = require('jquery');
2022-10-16 19:31:05 +00:00
const Swal = require('sweetalert2');
2022-10-16 13:54:29 +00:00
$("#folder-btn").on('click', async () => {
2022-10-16 14:47:43 +00:00
const success = await ipcRenderer.invoke('set-osu-dir');
if (success == undefined)
return;
2022-10-16 16:42:04 +00:00
if (success) {
2022-10-16 19:31:05 +00:00
Swal.fire({
title: 'Success!',
text: 'osu! folder set!',
icon: 'success',
confirmButtonText: 'Cool'
})
2022-10-16 16:42:04 +00:00
} else {
2022-10-16 19:31:05 +00:00
Swal.fire({
title: 'Uh oh!',
text: 'failed to set osu! folder.',
icon: 'error',
confirmButtonText: 'Cool'
})
2022-10-16 16:42:04 +00:00
}
2022-10-16 13:54:29 +00:00
});
2022-10-16 19:13:30 +00:00
ipcRenderer.on('status_update', (event, status) => {
switch (status.type) {
case "up-to-date":
$("#launch-btn").attr('disabled', false);
$('#launch-btn').html('Launch');
break;
case "update-available":
$("#launch-btn").attr('disabled', false);
$('#launch-btn').html('Update');
break;
}
})
2022-10-16 13:54:29 +00:00
})