4
0
mirror of https://github.com/AltarikMC/Launcher synced 2024-11-22 06:19:50 +01:00

Improved ram selection + improved UX + added CI (may not work)

This commit is contained in:
Quentin Legot 2020-12-19 13:38:59 +01:00 committed by Quentin Legot
parent bc5c5e0292
commit 48502d4e64
3 changed files with 68 additions and 14 deletions

27
.github/workflows/electron.yml vendored Normal file
View File

@ -0,0 +1,27 @@
name: CI
on: [ push ]
jobs:
build:
strategy:
matrix:
os: [ ubuntu-latest, windows-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v2
- name: Use Node.js 14
uses: actions/setup-node@v1
with:
node-version: 14.x
- name: Get npm cache directory
id: npm-cache
run: |
echo "::set-output name=dir::$(npm config get cache)"
- uses: actions/cache@v2
with:
path: ${{ steps.npm-cache.outputs.dir }}
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- name: Intall dependencies
run: npm ci
- run: npm run make --if-present

View File

@ -1,8 +1,14 @@
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))
ipcRenderer.on("nick", (event, args) => {
console.log(args)
@ -13,15 +19,23 @@ launchBtn.addEventListener("click", e => {
launchBtn.classList.add('hidden');
fullProgressBar.classList.remove('hidden');
loadingMessage.classList.remove('hidden');
if(Number(minMem.value) <= Number(maxMem.value)){
ipcRenderer.send('launch', {
minMem: document.querySelector('#minMem').value,
maxMem: document.querySelector('#maxMem').value
minMem: minMem.value + "M",
maxMem: maxMem.value + "M"
})
launchBtn.disabled = true
if(document.querySelector('#minMem').value.trim() && document.querySelector('#maxMem').value.trim()){
localStorage.setItem("minMem", document.querySelector('#minMem').value.trim())
localStorage.setItem("maxMem", document.querySelector('#maxMem').value.trim())
if(minMem.value && maxMem.value){
localStorage.setItem("minMem", minMem.value)
localStorage.setItem("maxMem", maxMem.value)
}
} else{
ipcRenderer.send('notification', {
title: "Erreur de lancement",
body: "La mémoire minimale doit être inférieure ou égale à la mémoire maximale"
})
}
})
ipcRenderer.on("progress", (e, args) => {
@ -43,6 +57,19 @@ disconnectBtn.addEventListener('click', e => {
})
window.addEventListener("DOMContentLoaded", () => {
document.querySelector('#minMem').value = localStorage.getItem("minMem") != null ? localStorage.getItem("minMem") : "2G"
document.querySelector('#maxMem').value = localStorage.getItem("maxMem") != null ? localStorage.getItem("maxMem") : "4G"
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
})
minMem.addEventListener("input", (e) => {
outputMinMem.innerHTML = e.target.value
})
maxMem.addEventListener("input", (e) => {
outputMaxMem.innerHTML = e.target.value
})

View File

@ -26,10 +26,10 @@
<h3>Modifier la configuration</h3>
<hr>
<h4>Allocation mémoire</h4>
<label for="minMem">mémoire minimale</label>
<input type="text" id="minMem" value="2G">
<label for="minMem">mémoire maximale</label>
<input type="text" id="maxMem" value="4G">
<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>
<input type="range" min="1024" max="2048" step="128" value="1" class="slider" id="maxMem">
</div>
<div id="main">
<img id="main-img" src="include/maxresdefault.jpg">