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

Index.html now work

This commit is contained in:
Quentin Legot 2022-02-18 21:10:54 +01:00
parent f856bd620e
commit 1a3082a90f
4 changed files with 36 additions and 42 deletions

View File

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

View File

@ -40,7 +40,7 @@
<h2>Chapitres</h2> <h2>Chapitres</h2>
<div id="sidebar-content" @change="modsInformations"> <div id="sidebar-content" @change="modsInformations">
<div v-if="modsInformationsLoaded === false">Une erreur est survenue lors de la récupération des informations, vérifiez votre connexion internet puis cliquez sur réessayez</div> <div v-if="modsInformationsLoaded === false">Une erreur est survenue lors de la récupération des informations, vérifiez votre connexion internet puis cliquez sur réessayez</div>
<div v-for="(item, index) in modsInformations" v-else-if="modsInformations.length !== 0" data-chapter="{{index}}" v-on:click="changeSelectedChapter(this)"> <div v-for="(item, index) in modsInformations" v-else-if="modsInformations.length !== 0" v-on:click="changeSelectedChapter(index)" :class="{ selected: isSelected(index) }">
<h3>{{ item.title }}</h3> <h3>{{ item.title }}</h3>
<p>{{ item.description}}</p> <p>{{ item.description}}</p>
</div> </div>

View File

@ -86,5 +86,7 @@ ipcMain.on("disconnect", () => {
}) })
ipcMain.on("pageReady", (event) => {
event.sender.send("nick", { name: minecraft.auth.name })
minecraft.getModsInformations(event)
})

View File

@ -30,13 +30,7 @@ class Minecraft {
if(isDev || password.trim() !== "") { if(isDev || password.trim() !== "") {
this.auth = Authenticator.getAuth(username, password) this.auth = Authenticator.getAuth(username, password)
this.auth.then(v => { this.auth.then(v => {
win.loadFile('src/client/index.html').then(() => { win.loadFile('src/client/index.html')
setInterval(() => {
event.sender.send("nick", { name: v.name })
this.getModsInformations(e)
}, 1000)
})
}).catch(() => { }).catch(() => {
event.sender.send("loginError") event.sender.send("loginError")
logger.error("[MJ login] User haven't purchase the game") logger.error("[MJ login] User haven't purchase the game")
@ -68,9 +62,7 @@ class Minecraft {
} else { } else {
if(!msmc.isDemoUser(result)) { if(!msmc.isDemoUser(result)) {
this.auth = msmc.getMCLC().getAuth(result) this.auth = msmc.getMCLC().getAuth(result)
win.loadFile('src/client/index.html').then(() => { win.loadFile('src/client/index.html')
event.sender.send("nick", { name: this.auth.name })
})
} else { } else {
event.sender.send("loginError") event.sender.send("loginError")
logger.error("[MS login] User haven't purchase the game") logger.error("[MS login] User haven't purchase the game")