mirror of
https://github.com/AltarikMC/Launcher
synced 2024-11-22 06:19:50 +01:00
Fixed a bug with allocation + deleted progress bar when game load
This commit is contained in:
parent
4695e2c187
commit
1d3d7d0feb
@ -57,9 +57,9 @@ h3 {
|
||||
|
||||
#launch-btn {
|
||||
position: relative;
|
||||
top: -25px;
|
||||
top: 50%;
|
||||
left:50%;
|
||||
transform: translateX(-50%);
|
||||
transform: translate(-50%, -50%);
|
||||
width: 20%;
|
||||
max-width:200px;
|
||||
height:50px;
|
||||
|
@ -1,14 +1,23 @@
|
||||
var os = require('os');
|
||||
let launchBtn = document.querySelector('#launch-btn');
|
||||
let fullProgressBar = document.querySelector('#fullprogressbar')
|
||||
let progressBar = document.querySelector('#progressbar')
|
||||
let loadingMessage = document.querySelector('#loading-message')
|
||||
let disconnectBtn = document.querySelector('#disconnect-btn')
|
||||
let minMem = document.querySelector('#minMem')
|
||||
let maxMem = document.querySelector('#maxMem')
|
||||
let outputMinMem = document.querySelector('#outputMinMem')
|
||||
let outputMaxMem = document.querySelector('#outputMaxMem')
|
||||
let totalMem = os.totalmem() / (1.049 * Math.pow(10, 6))
|
||||
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
|
||||
}
|
||||
|
||||
ipcRenderer.on("nick", (event, args) => {
|
||||
console.log(args)
|
||||
@ -25,10 +34,8 @@ launchBtn.addEventListener("click", e => {
|
||||
maxMem: maxMem.value + "M"
|
||||
})
|
||||
launchBtn.disabled = true
|
||||
if(minMem.value && maxMem.value){
|
||||
localStorage.setItem("minMem", minMem.value)
|
||||
localStorage.setItem("maxMem", maxMem.value)
|
||||
}
|
||||
localStorage.setItem("minMem", minMem.value)
|
||||
localStorage.setItem("maxMem", maxMem.value)
|
||||
} else{
|
||||
ipcRenderer.send('notification', {
|
||||
title: "Erreur de lancement",
|
||||
@ -47,23 +54,18 @@ ipcRenderer.on("close", (e, args) => {
|
||||
launchBtn.classList.remove('hidden');
|
||||
fullProgressBar.classList.add('hidden');
|
||||
loadingMessage.classList.add('hidden');
|
||||
loadingMessage.innerHTML = "Téléchargement de Minecraft en cours..."
|
||||
loadingMessage.innerHTML = "Chargement de Minecraft en cours..."
|
||||
progressBar.style.width = "0"
|
||||
launchBtn.disabled = false
|
||||
})
|
||||
|
||||
disconnectBtn.addEventListener('click', e => {
|
||||
ipcRenderer.send('disconnect')
|
||||
ipcRenderer.on('launch', (e, args) => {
|
||||
fullProgressBar.classList.add('hidden');
|
||||
loadingMessage.classList.add('hidden');
|
||||
})
|
||||
|
||||
window.addEventListener("DOMContentLoaded", () => {
|
||||
minMem.value = localStorage.getItem("minMem") != null ? Number(localStorage.getItem("minMem")) : 1024
|
||||
minMem.max = totalMem
|
||||
outputMinMem.innerHTML = minMem.value
|
||||
maxMem.value = localStorage.getItem("maxMem") != null ? Number(localStorage.getItem("maxMem")) : 2048
|
||||
maxMem.max = totalMem
|
||||
outputMaxMem.innerHTML = maxMem.value
|
||||
|
||||
disconnectBtn.addEventListener('click', e => {
|
||||
ipcRenderer.send('disconnect')
|
||||
})
|
||||
|
||||
minMem.addEventListener("input", (e) => {
|
||||
|
@ -20,26 +20,9 @@ window.addEventListener("DOMContentLoaded", () => {
|
||||
const maxUnmaxButton = document.getElementById("max-unmax-btn")
|
||||
const closeButton = document.getElementById("close-btn")
|
||||
|
||||
minimizeButton.addEventListener("click", e => {
|
||||
window.minimizeWindow()
|
||||
})
|
||||
minimizeButton.addEventListener("click", e => window.minimizeWindow())
|
||||
|
||||
maxUnmaxButton.addEventListener("click", e => {
|
||||
const icon = maxUnmaxButton.querySelector("#icon-maxUnmax")
|
||||
maxUnmaxButton.addEventListener("click", e => window.maxUnmaxWindow())
|
||||
|
||||
window.maxUnmaxWindow()
|
||||
|
||||
// Change the middle maximize-unmaximize icons.
|
||||
if (window.isWindowMaximized()) {
|
||||
icon.classList.remove("icon-square")
|
||||
icon.classList.add("icon-clone")
|
||||
} else {
|
||||
icon.classList.add("icon-square")
|
||||
icon.classList.remove("icon-clone")
|
||||
}
|
||||
})
|
||||
|
||||
closeButton.addEventListener("click", e => {
|
||||
window.closeWindow()
|
||||
})
|
||||
closeButton.addEventListener("click", e => window.closeWindow())
|
||||
})
|
||||
|
@ -29,7 +29,7 @@
|
||||
<h4>Allocation mémoire</h4>
|
||||
<label for="minMem">mémoire minimale : <div id="outputMinMem"></div></label>
|
||||
<input type="range" min="1024" max="2048" step="128" value="1" class="slider" id="minMem">
|
||||
<label for="minMem">mémoire maximale : <div id="outputMaxMem"></div></label>
|
||||
<label for="maxMem">mémoire maximale : <div id="outputMaxMem"></div></label>
|
||||
<input type="range" min="1024" max="2048" step="128" value="1" class="slider" id="maxMem">
|
||||
</div>
|
||||
<div id="main">
|
||||
|
18
main.js
18
main.js
@ -1,10 +1,9 @@
|
||||
const { app, BrowserWindow, Menu, ipcMain, Notification } = require('electron')
|
||||
const path = require('path')
|
||||
if (handleSquirrelEvent()) return;
|
||||
const { Client, Authenticator } = require('minecraft-launcher-core')
|
||||
const appdata = process.env.APPDATA || (process.platform == 'darwin' ? process.env.HOME + '/Library/Preferences' : process.env.HOME + "/.local/share")
|
||||
|
||||
if (handleSquirrelEvent()) {
|
||||
return;
|
||||
}
|
||||
|
||||
function handleSquirrelEvent() {
|
||||
if (process.argv.length === 1) {
|
||||
@ -52,14 +51,14 @@ function handleSquirrelEvent() {
|
||||
app.quit();
|
||||
return true;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
const launcher = new Client();
|
||||
const iconPath = path.join(__dirname, "icon.ico");
|
||||
let win = null
|
||||
let auth = null
|
||||
|
||||
let Minecraftpath = "game"
|
||||
let Minecraftpath = path.join(appdata, ".ps")
|
||||
let clientPackage = "https://www.dropbox.com/s/ww6a052nzzgojdm/modpack.zip?dl=1"
|
||||
let version = "1.16.4"
|
||||
let versionFolder = "fabric-loader-0.10.8-1.16.4"
|
||||
@ -113,7 +112,7 @@ ipcMain.on("login", (event, args) => {
|
||||
})
|
||||
})
|
||||
|
||||
function showNotification(title="", body="") {
|
||||
function showNotification(title, body="") {
|
||||
const notification = {
|
||||
title: title,
|
||||
body: body
|
||||
@ -142,14 +141,15 @@ ipcMain.on("launch", (event, args) => {
|
||||
}
|
||||
launcher.launch(opts)
|
||||
// launcher.on('debug', (e) => console.log("debug", e));
|
||||
launcher.on('data', (e) => console.log("data", e));
|
||||
launcher.on('progress', (e) => event.sender.send("progress", e));
|
||||
// launcher.on('data', (e) => console.log("data", e));
|
||||
launcher.on('progress', (e) => event.sender.send("progress", e))
|
||||
launcher.on('arguments', (e) => event.sender.send("launch", e))
|
||||
launcher.on('close', (e) => {
|
||||
event.sender.send("close", e)
|
||||
if(e !== 0){
|
||||
showNotification("Une erreur est suvenue", "Minecraft ne s'est pas fermé correctement")
|
||||
}
|
||||
});
|
||||
})
|
||||
|
||||
})
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user