mirror of
https://github.com/AltarikMC/Launcher
synced 2024-11-24 06:39:50 +01:00
added progress bar
This commit is contained in:
parent
09ee3e175e
commit
c05f09d5e9
2
.gitignore
vendored
2
.gitignore
vendored
@ -1,3 +1,3 @@
|
||||
node_modules/
|
||||
|
||||
game
|
||||
out/
|
@ -67,3 +67,29 @@ h3 {
|
||||
border: 1px solid black;
|
||||
border-radius: 3px;
|
||||
}
|
||||
|
||||
.hidden{
|
||||
display:none;
|
||||
}
|
||||
|
||||
#fullprogressbar{
|
||||
position:relative;
|
||||
margin: 0 auto;
|
||||
width:80%;
|
||||
height:25px;
|
||||
background-color:gray;
|
||||
}
|
||||
|
||||
#progressbar{
|
||||
background-color: green;
|
||||
height:100%;
|
||||
width:0;
|
||||
}
|
||||
|
||||
#loading-message{
|
||||
width:80%;
|
||||
position:relative;
|
||||
margin: 0 auto;
|
||||
height:28px;
|
||||
color:white;
|
||||
}
|
@ -1,16 +1,37 @@
|
||||
minMem= "2G"
|
||||
maxMem = "4G"
|
||||
|
||||
let launchBtn = document.querySelector('#launch-btn');
|
||||
let fullProgressBar = document.querySelector('#fullprogressbar')
|
||||
let progressBar = document.querySelector('#progressbar')
|
||||
let loadingMessage = document.querySelector('#loading-message')
|
||||
|
||||
ipcRenderer.on("nick", (event, args) => {
|
||||
console.log(args)
|
||||
document.querySelector("#nick-span").innerHTML = args.name
|
||||
})
|
||||
|
||||
document.querySelector('#launch-btn').addEventListener("click", e => {
|
||||
launchBtn.addEventListener("click", e => {
|
||||
launchBtn.classList.add('hidden');
|
||||
fullProgressBar.classList.remove('hidden');
|
||||
loadingMessage.classList.remove('hidden');
|
||||
ipcRenderer.send('launch', {
|
||||
minMem: minMem,
|
||||
maxMem: maxMem
|
||||
})
|
||||
document.querySelector('#launch-btn').disabled = true
|
||||
launchBtn.disabled = true
|
||||
})
|
||||
|
||||
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');
|
||||
loadingMessage.innerHTML = "Téléchargement de Minecraft en cours..."
|
||||
progressBar.style.width = "0"
|
||||
launchBtn.disabled = false
|
||||
})
|
Before Width: | Height: | Size: 74 KiB After Width: | Height: | Size: 74 KiB |
10
index.html
10
index.html
@ -4,8 +4,8 @@
|
||||
<meta charset="UTF-8">
|
||||
<title>Launcher Projet Secret</title>
|
||||
<meta http-equiv="Content-Security-Policy" content="script-src 'self' 'unsafe-inline';" />
|
||||
<link href="index.css" rel="stylesheet" />
|
||||
<link href="menubar.css" rel="stylesheet" />
|
||||
<link href="include/index.css" rel="stylesheet" />
|
||||
<link href="include/menubar.css" rel="stylesheet" />
|
||||
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
|
||||
</head>
|
||||
<body>
|
||||
@ -27,14 +27,16 @@
|
||||
Contenu
|
||||
</div>
|
||||
<div id="main">
|
||||
<img id="main-img" src="./maxresdefault.jpg">
|
||||
<img id="main-img" src="include/maxresdefault.jpg">
|
||||
<div id="launch">
|
||||
<button id="launch-btn">Lancer le jeu</button>
|
||||
<div id="loading-message" class="hidden">Téléchargement de Minecraft en cours...</div>
|
||||
<div id="fullprogressbar" class="hidden"><div id="progressbar"></div></div>
|
||||
</div>
|
||||
</div>
|
||||
</p>
|
||||
</div>
|
||||
<script src="script.js"></script>
|
||||
<script src="include/script.js"></script>
|
||||
<script src="include/index.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
@ -4,8 +4,8 @@
|
||||
<meta charset="UTF-8">
|
||||
<title>Launcher Projet Secret</title>
|
||||
<meta http-equiv="Content-Security-Policy" content="script-src 'self' 'unsafe-inline';" />
|
||||
<link href="login.css" rel="stylesheet" />
|
||||
<link href="menubar.css" rel="stylesheet" />
|
||||
<link href="include/login.css" rel="stylesheet" />
|
||||
<link href="include/menubar.css" rel="stylesheet" />
|
||||
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
|
||||
</head>
|
||||
<body>
|
||||
@ -31,7 +31,7 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script src="script.js"></script>
|
||||
<script src="include/script.js"></script>
|
||||
<script src="include/login.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
20
main.js
20
main.js
@ -7,14 +7,17 @@ const iconPath = path.join(__dirname, "icon.png");
|
||||
let win = null
|
||||
let auth = null
|
||||
|
||||
let Minecraftpath = "projet-secret"
|
||||
let Minecraftpath = "game"
|
||||
let clientPackage = "https://www.dropbox.com/s/ww6a052nzzgojdm/modpack.zip?dl=1"
|
||||
let version = "fabric-loader-0.10.8-1.16.4"
|
||||
let version = "1.16.4"
|
||||
let versionFolder = "fabric-loader-0.10.8-1.16.4"
|
||||
|
||||
function createWindow () {
|
||||
win = new BrowserWindow({
|
||||
width: 1000,
|
||||
minWidth: 900,
|
||||
height: 600,
|
||||
minHeight: 600,
|
||||
icon: iconPath,
|
||||
webPreferences: {
|
||||
nodeIntegration: true,
|
||||
@ -75,11 +78,10 @@ ipcMain.on("launch", (event, args) => {
|
||||
clientPackage: clientPackage,
|
||||
authorization: auth,
|
||||
root: Minecraftpath,
|
||||
//forge: fabricmc,
|
||||
version: {
|
||||
number: "1.16.4",
|
||||
number: version,
|
||||
type: "release",
|
||||
custom: version
|
||||
custom: versionFolder
|
||||
},
|
||||
memory: {
|
||||
max: args.maxMem,
|
||||
@ -87,9 +89,9 @@ ipcMain.on("launch", (event, args) => {
|
||||
}
|
||||
}
|
||||
launcher.launch(opts)
|
||||
launcher.on('debug', (e) => console.log(e));
|
||||
launcher.on('data', (e) => console.log(e));
|
||||
launcher.on('progress', (e) => console.log(e));
|
||||
launcher.on('close', (e) => console.log(e));
|
||||
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('close', (e) => event.sender.send("close", e));
|
||||
|
||||
})
|
Loading…
Reference in New Issue
Block a user