From 1a3082a90fbf8f145f37de7ef940adcf206c8a56 Mon Sep 17 00:00:00 2001 From: Quentin Legot Date: Fri, 18 Feb 2022 21:10:54 +0100 Subject: [PATCH] Index.html now work --- src/client/assets/js/index.js | 58 +++++++++++++++++------------------ src/client/index.html | 2 +- src/server/main.js | 6 ++-- src/server/minecraft.js | 12 ++------ 4 files changed, 36 insertions(+), 42 deletions(-) diff --git a/src/client/assets/js/index.js b/src/client/assets/js/index.js index a9aafe0..8f40ee2 100644 --- a/src/client/assets/js/index.js +++ b/src/client/assets/js/index.js @@ -21,7 +21,9 @@ app = vue.createApp({ progressbarWidth: 0, sidebarContent: "

Chargement en cours

", modsInformations: [], - modsInformationsLoaded: true + modsInformationsLoaded: true, + selectedChapter: -1, + gameLaunching: false } }, @@ -33,16 +35,6 @@ app = vue.createApp({ position: 'topRight', resetOnHover: true, }) - ipcRenderer.on("modsInformations", (e, args) => { - console.log("loaded") - if(args === null) { - this.modsInformationsLoaded = false - } else { - this.modsInformationsLoaded = true - } - this.updateModsInformations(args) - }) - ipcRenderer.on("nick", (_, args) => root.nick = args.name) }, methods: { invalidateData () { @@ -61,21 +53,26 @@ app = vue.createApp({ ipcRenderer.send('launch', { minMem: this.minMemValue + "M", maxMem: this.maxMemValue + "M", - chapter: selectedChapter + chapter: this.selectedChapter }) this.launchBtnDisable = true localStorage.setItem("minMem", this.minMemValue) localStorage.setItem("maxMem", this.maxMemValue) - gameLaunching = true + this.gameLaunching = true } else { this.showError("Erreur de lancement", "La mémoire minimale doit être inférieure ou égale à la mémoire maximale.") } }, + changeSelectedChapter(index) { + this.selectedChapter = parseInt(index) + root.launchBtnText = "JOUER" + root.launchBtnDisable = false + }, disconnectBtn () { ipcRenderer.send('disconnect') }, options () { - if(!gameLaunching) + if(!this.gameLaunching) this.displayFullscreen = "block" }, discord() { @@ -89,7 +86,6 @@ app = vue.createApp({ }, updateModsInformations(content) { this.modsInformations = content - nextTick(() => {}) }, getModsInformations() { return this.modsInformations @@ -121,16 +117,15 @@ app = vue.createApp({ message: body, color: 'green' }) + }, + isSelected(index) { + return this.selectedChapter === index } } }) let root = app.mount("#vue") -let gameLaunching = false - -let selectedChapter = -1; - ipcRenderer.on("invalidated", () => { root.invalidateButtonDisabled = false root.invalidateButtonText = "Supprimer et retélécharger les bibliothèques" @@ -149,7 +144,7 @@ ipcRenderer.on("close", (_e, _args) => { root.loadingMessageText = "Chargement de Minecraft en cours..." root.progressbarWidth = 0 root.launchBtnDisable = false - gameLaunching = false + root.gameLaunching = false }) ipcRenderer.on('launch', (_e, _args) => { @@ -157,12 +152,17 @@ ipcRenderer.on('launch', (_e, _args) => { root.loadingMessageHidden = true }) -function changeSelectedChapter(element) { - selectedChapter = Number(element.dataset.chapter) - document.querySelectorAll("#sidebar-content > div").forEach((v) => { - v.classList.remove("selected") - }) - element.classList.add("selected") - root.launchBtnText = "JOUER" - root.launchBtnDisable = false -} +setInterval(() => { + ipcRenderer.send("pageReady") +}, 500) + +ipcRenderer.on("modsInformations", (_e, args) => { + if(args === null) { + root.modsInformationsLoaded = false + } else { + root.modsInformationsLoaded = true + } + root.updateModsInformations(args) +}) + +ipcRenderer.on("nick", (_e, args) => root.nick = args.name) \ No newline at end of file diff --git a/src/client/index.html b/src/client/index.html index 5a30849..f1aede7 100644 --- a/src/client/index.html +++ b/src/client/index.html @@ -40,7 +40,7 @@

Chapitres