Skip to content

Commit

Permalink
Merge pull request #436 from AltarikMC/dev
Browse files Browse the repository at this point in the history
2.2.0
  • Loading branch information
quentinlegot authored Aug 31, 2024
2 parents 59cbcb8 + 3c5c58e commit 9f49596
Show file tree
Hide file tree
Showing 5 changed files with 4,770 additions and 6,281 deletions.
10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "altarik-launcher",
"author": "Altarik",
"version": "2.1.8",
"version": "2.2.0",
"description": "Altarik Launcher",
"main": "src/server/main.js",
"type": "module",
Expand Down Expand Up @@ -35,17 +35,17 @@
"@electron-forge/maker-zip": "^7.4.0",
"@electron-forge/plugin-auto-unpack-natives": "^7.4.0",
"@electron-forge/publisher-github": "^7.4.0",
"electron": "31.1.0",
"eslint": "^9.6.0",
"electron": "32.0.1",
"eslint": "^9.9.1",
"eslint-config-standard": "^17.1.0",
"eslint-plugin-import": "^2.29.1",
"eslint-plugin-n": "^17.9.0",
"eslint-plugin-promise": "^6.2.0"
"eslint-plugin-promise": "^6.6.0"
},
"dependencies": {
"decompress": "^4.2.1",
"electron-is-dev": "^3.0.1",
"electron-log": "^5.1.5",
"electron-log": "^5.1.7",
"electron-squirrel-startup": "^1.0.1",
"extract-zip": "^2.0.1",
"hasha": "^6.0.0",
Expand Down
13 changes: 11 additions & 2 deletions src/client/assets/js/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ app = vue.createApp({
position: 'topRight',
resetOnHover: true
})
setInterval(() => {
setTimeout(() => {
ipcRenderer.send('pageReady')
}, 500)
},
Expand Down Expand Up @@ -98,11 +98,20 @@ app = vue.createApp({
this.displayCredits = 'block'
},
updateModsInformations (content) {
this.modsInformations = content
if(content === null) {
this.modsInformations = []
} else {
this.modsInformations = content
}
},
getModsInformations () {
return this.modsInformations
},
reloadChapters() {
this.updateModsInformations(null)
this.modsInformationsLoaded = true
ipcRenderer.send('pageReady')
},
showInfo (title, body) {
iziToast.info({
title,
Expand Down
2 changes: 1 addition & 1 deletion src/client/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ <h4>Au secours, mon jeu ne démarre pas</h4>
</div>
<div id="content">
<div id="sidebar">
<h2>Chapitres</h2>
<h2>Chapitres <i v-if="modsInformations.length !== 0 || modsInformationsLoaded === false" v-on:click="reloadChapters()" class="reload-chapter material-icons">sync</i></h2>
<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-for="(item, index) in modsInformations" v-else-if="modsInformations.length !== 0" v-on:click="changeSelectedChapter(index)" :class="{ selected: isSelected(index) }">
Expand Down
26 changes: 5 additions & 21 deletions src/server/minecraft.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export default class Minecraft {
auth = null
modsList = undefined
showNotification = undefined
modsInformationsEndpoint = 'https://launcher.altarik.fr'
modsInformationsEndpoint = 'https://launcher.altarik.fr/launcher.json'

setShowNotification (showNotification) {
this.showNotification = showNotification
Expand Down Expand Up @@ -145,39 +145,23 @@ export default class Minecraft {
fs.writeFileSync(file, JSON.stringify(data))
event.sender.send('modsInformations', this.extractModsInformations(data))
}).catch(err => {
event.sender.send('modsInformations', this.extractModsFromFileSystem())
event.sender.send('modsInformations', null)
logger.warn(err)
logger.warn('An error occured while trying to connect to server')
})
} else {
logger.warn('Unable to connect to server')
logger.warn(response.status)
event.sender.send('modsInformations', this.extractModsFromFileSystem())
logger.warn(this.modsInformationsEndpoint)
event.sender.send('modsInformations', null)
}
}).catch(err => {
logger.warn('Unable to connect to server')
logger.warn(err)
event.sender.send('modsInformations', this.extractModsFromFileSystem())
event.sender.send('modsInformations', null)
})
}

extractModsFromFileSystem () {
const filepath = join(this.localappdata, 'altarik-launcher/data/launcher.json')
if (fs.existsSync(filepath)) {
const content = fs.readFileSync(filepath)
if (content !== null) {
this.showNotification('Impossible de récupérer certaines informations en ligne', 'utilisation des dernières données récupérées', 'warning')
return this.extractModsInformations(JSON.parse(content))
} else {
this.showNotification('Impossible de récupérer certaines informations en ligne', 'Veuillez réessayez en cliquant sur le bouton', 'warning')
logger.error('Unable to get chapters informations from server or filesystem')
return null
}
} else {
return null
}
}

extractModsInformations (json) {
this.modsList = json.chapters
return this.modsList
Expand Down
Loading

0 comments on commit 9f49596

Please sign in to comment.