2021-01-12 16:48:33 +01:00
|
|
|
const os = require('os');
|
|
|
|
const launchBtn = document.querySelector('#launch-btn');
|
|
|
|
const fullProgressBar = document.querySelector('#fullprogressbar')
|
|
|
|
const progressBar = document.querySelector('#progressbar')
|
|
|
|
const loadingMessage = document.querySelector('#loading-message')
|
|
|
|
const disconnectBtn = document.querySelector('#disconnect-btn')
|
|
|
|
const minMem = document.querySelector('#minMem')
|
|
|
|
const maxMem = document.querySelector('#maxMem')
|
|
|
|
const outputMinMem = document.querySelector('#outputMinMem')
|
|
|
|
const outputMaxMem = document.querySelector('#outputMaxMem')
|
|
|
|
const totalMem = os.totalmem() / (1.049 * Math.pow(10, 6))
|
|
|
|
|
|
|
|
document.body.onload = (e) => {
|
|
|
|
minMem.max = totalMem
|
|
|
|
maxMem.max = totalMem
|
|
|
|
minMem.value = localStorage.getItem("minMem")
|
|
|
|
outputMinMem.innerHTML = minMem.value
|
|
|
|
maxMem.value = localStorage.getItem("maxMem")
|
|
|
|
outputMaxMem.innerHTML = maxMem.value
|
|
|
|
}
|
2020-12-08 19:59:56 +01:00
|
|
|
|
|
|
|
ipcRenderer.on("nick", (event, args) => {
|
|
|
|
console.log(args)
|
|
|
|
document.querySelector("#nick-span").innerHTML = args.name
|
|
|
|
})
|
|
|
|
|
2020-12-08 23:04:57 +01:00
|
|
|
launchBtn.addEventListener("click", e => {
|
|
|
|
launchBtn.classList.add('hidden');
|
|
|
|
fullProgressBar.classList.remove('hidden');
|
|
|
|
loadingMessage.classList.remove('hidden');
|
2020-12-19 13:38:59 +01:00
|
|
|
if(Number(minMem.value) <= Number(maxMem.value)){
|
|
|
|
ipcRenderer.send('launch', {
|
|
|
|
minMem: minMem.value + "M",
|
|
|
|
maxMem: maxMem.value + "M"
|
|
|
|
})
|
|
|
|
launchBtn.disabled = true
|
2021-01-12 16:48:33 +01:00
|
|
|
localStorage.setItem("minMem", minMem.value)
|
|
|
|
localStorage.setItem("maxMem", maxMem.value)
|
2020-12-19 13:38:59 +01:00
|
|
|
} else{
|
|
|
|
ipcRenderer.send('notification', {
|
|
|
|
title: "Erreur de lancement",
|
|
|
|
body: "La mémoire minimale doit être inférieure ou égale à la mémoire maximale"
|
|
|
|
})
|
2020-12-09 11:46:11 +01:00
|
|
|
}
|
2020-12-19 13:38:59 +01:00
|
|
|
|
2020-12-08 23:04:57 +01:00
|
|
|
})
|
|
|
|
|
|
|
|
ipcRenderer.on("progress", (e, args) => {
|
|
|
|
progressBar.style.width = (args.task / args.total) * 100 + "%"
|
|
|
|
loadingMessage.innerHTML = "Téléchargement de " + args.type + ": " + args.task + " sur " + args.total;
|
|
|
|
})
|
|
|
|
|
|
|
|
ipcRenderer.on("close", (e, args) => {
|
|
|
|
launchBtn.classList.remove('hidden');
|
|
|
|
fullProgressBar.classList.add('hidden');
|
|
|
|
loadingMessage.classList.add('hidden');
|
2021-01-12 16:48:33 +01:00
|
|
|
loadingMessage.innerHTML = "Chargement de Minecraft en cours..."
|
2020-12-08 23:04:57 +01:00
|
|
|
progressBar.style.width = "0"
|
|
|
|
launchBtn.disabled = false
|
2020-12-08 23:19:42 +01:00
|
|
|
})
|
|
|
|
|
2021-01-12 16:48:33 +01:00
|
|
|
ipcRenderer.on('launch', (e, args) => {
|
|
|
|
fullProgressBar.classList.add('hidden');
|
|
|
|
loadingMessage.classList.add('hidden');
|
2020-12-09 11:46:11 +01:00
|
|
|
})
|
|
|
|
|
2021-01-12 16:48:33 +01:00
|
|
|
disconnectBtn.addEventListener('click', e => {
|
|
|
|
ipcRenderer.send('disconnect')
|
2020-12-19 13:38:59 +01:00
|
|
|
})
|
|
|
|
|
|
|
|
minMem.addEventListener("input", (e) => {
|
|
|
|
outputMinMem.innerHTML = e.target.value
|
|
|
|
})
|
|
|
|
|
|
|
|
maxMem.addEventListener("input", (e) => {
|
|
|
|
outputMaxMem.innerHTML = e.target.value
|
2020-12-08 19:59:56 +01:00
|
|
|
})
|