From f5d524948c9894fb2ecafb5f9097eb5e05784bd9 Mon Sep 17 00:00:00 2001
From: Quentin Legot
Date: Tue, 8 Dec 2020 23:04:57 +0100
Subject: [PATCH] added progress bar
---
.gitignore | 4 +--
index.css => include/index.css | 26 ++++++++++++++++++
include/index.js | 25 +++++++++++++++--
login.css => include/login.css | 0
.../maxresdefault.jpg | Bin
menubar.css => include/menubar.css | 0
script.js => include/script.js | 0
index.html | 10 ++++---
login.html | 6 ++--
main.js | 20 ++++++++------
10 files changed, 71 insertions(+), 20 deletions(-)
rename index.css => include/index.css (75%)
rename login.css => include/login.css (100%)
rename maxresdefault.jpg => include/maxresdefault.jpg (100%)
rename menubar.css => include/menubar.css (100%)
rename script.js => include/script.js (100%)
diff --git a/.gitignore b/.gitignore
index 66b8fc9..de34272 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,3 +1,3 @@
node_modules/
-
-out/
\ No newline at end of file
+game
+out/
diff --git a/index.css b/include/index.css
similarity index 75%
rename from index.css
rename to include/index.css
index e64840d..8eac1bc 100644
--- a/index.css
+++ b/include/index.css
@@ -66,4 +66,30 @@ h3 {
background-color: green;
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;
}
\ No newline at end of file
diff --git a/include/index.js b/include/index.js
index cae95f5..88b5531 100644
--- a/include/index.js
+++ b/include/index.js
@@ -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
})
\ No newline at end of file
diff --git a/login.css b/include/login.css
similarity index 100%
rename from login.css
rename to include/login.css
diff --git a/maxresdefault.jpg b/include/maxresdefault.jpg
similarity index 100%
rename from maxresdefault.jpg
rename to include/maxresdefault.jpg
diff --git a/menubar.css b/include/menubar.css
similarity index 100%
rename from menubar.css
rename to include/menubar.css
diff --git a/script.js b/include/script.js
similarity index 100%
rename from script.js
rename to include/script.js
diff --git a/index.html b/index.html
index f3f2ab5..ee82946 100644
--- a/index.html
+++ b/index.html
@@ -4,8 +4,8 @@
Launcher Projet Secret
-
-
+
+
@@ -27,14 +27,16 @@
Contenu
-
+
+
Téléchargement de Minecraft en cours...
+
-
+