Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,16 @@
"vite": "^8.0.3"
},
"dependencies": {
"@tailwindcss/forms": "^0.5.11",
"@tailwindcss/vite": "^4.2.2",
"decompress": "^4.2.1",
"electron-is-dev": "^3.0.1",
"electron-log": "^5.4.3",
"electron-squirrel-startup": "^1.0.1",
"minecraft-launcher-core": "^3.18.2",
"msmc": "^5.0.5",
"node-fetch": "^3.3.2",
"tailwindcss": "^4.2.2",
"vue": "^3.5.31",
"vue3-toastify": "^0.2.9"
},
Expand Down
20 changes: 4 additions & 16 deletions src/client/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import Updater from './Updater.vue'
import Login from './Login.vue'
import Main from './Main.vue'
import { toast } from 'vue3-toastify';
import './assets/css/menubar.css'
import './assets/css/fonts.css'
import 'vue3-toastify/dist/index.css';
import './assets/css/app.css'

const page = ref("updater")
const totalmem = ref(0)
Expand All @@ -27,49 +27,37 @@ function showInfo(title, body) {
toast.info({
title,
content: body,
// color: 'blue'
})
}

function showSuccess(title, body) {
toast.success({
title,
content: body,
// color: 'green'
})
}

function showWarning(title, body) {
toast.warning({
title,
content: body,
// color: 'yellow'
})
}

function showError(title, body) {
toast.error({
title,
content: body,
// color: 'red'
})
}

onMounted(() => {
// iziToast.settings({
// close: false,
// closeOnClick: true,
// timeout: 5000,
// position: 'topRight',
// resetOnHover: true
// })

window.electronAPI.ipc.on('pc-configuration', (e) => {
totalmem.value = e.totalMem
})
})

provide("setPage", setPage)
provide("showInfo", showInfo)
provide("showError", showError)
provide("showWarning", showWarning)
Expand All @@ -87,9 +75,9 @@ provide("showSuccess", showSuccess)
<li id="minimize-btn" @click="minimize"><i class="material-icons">minimize</i></li><!--<li id="max-unmax-btn"><i class="material-icons">crop_square</i></li>--><li id="close-btn" @click="close"><i class="material-icons">close</i></li>
</ul>
</div>
<Updater v-if="page === 'updater'"/>
<Login v-if="page === 'login'" />
<Main v-if="page === 'main'" totalmem="totalmem" />
<Updater @set-page="setPage" v-if="page === 'updater'"/>
<Login @set-page="setPage" v-if="page === 'login'" />
<Main @set-page="setPage" v-if="page === 'main'" totalmem="totalmem" />
</template>


5 changes: 3 additions & 2 deletions src/client/Login.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@
import { ref, inject, onMounted } from 'vue'
import './assets/css/login.css'

const emit = defineEmits(['setPage'])

const form_disabled = ref(false)
const microsoft_button = ref('Connexion avec un compte Microsoft')

const showWarning = inject("showWarning")
const setPage = inject("setPage")

function microsoftButton (e) {
e.preventDefault()
Expand All @@ -22,7 +23,7 @@ onMounted(() => {
showWarning(e.title, e.body)
})
window.electronAPI.ipc.on('loginSuccess', () => {
setPage("main")
emit('setPage', 'main')
})
})

Expand Down
177 changes: 78 additions & 99 deletions src/client/Main.vue
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
<script setup>
import { ref, onMounted, inject } from 'vue'
import './assets/css/index.css'
import Dividers from './components/Dividers.vue'
import QuantityInput from './components/QuantityInput.vue'
import Button from './components/Button.vue'
import Fullscreen from './components/Fullscreen.vue'

const setPage = inject("setPage")
const emit = defineEmits(['setPage'])

const showSuccess = inject("showSuccess")
const showInfo = inject("showInfo")
Expand All @@ -14,9 +18,9 @@ const minMemValue = ref(localStorage.getItem('minMem') != null ? localStorage.ge
const maxMemValue = ref(localStorage.getItem('maxMem') != null ? localStorage.getItem('maxMem') : 2048)
const memStep = ref(128)
const memMax = ref(props.totalmem / (1.049 * Math.pow(10, 6)))
const invalidateButtonText = ref('Supprimer et retélécharger les bibliothèques')
const invalidateButtonText = ref('Nettoyer l\'installation')
const invalidateButtonDisabled = ref(false)
const displayFullscreen = ref('none')
const displayFullscreen = ref(false)
const displaySettings = ref('none')
const displayCredits = ref('none')
const nick = ref('Chargement')
Expand All @@ -27,7 +31,6 @@ const loadingMessageHidden = ref(true)
const loadingMessageText = ref('Téléchargement de Minecraft en cours...')
const fullprogressbarHidden = ref(true)
const progressbarWidth = ref(0)
const sidebarContent = ref('<hr><p>Chargement en cours</p>')
const modsInformations = ref([])
const modsInformationsLoaded = ref(true)
const selectedChapter = ref(-1)
Expand All @@ -42,58 +45,60 @@ function updateModsInformations (content) {
}

onMounted(() => {
setTimeout(() => {
window.electronAPI.ipc.send('pageReady')
}, 500)
window.electronAPI.ipc.send('pageReady')
})

function isSelected (index) {
return selectedChapter.value === index
}

function reloadChapters () {
changeSelectedChapter(-1)
updateModsInformations(null)
modsInformationsLoaded.value = true
window.electronAPI.ipc.send('pageReady')
}

function changeSelectedChapter (index) {
if(!gameLaunching.value) {
selectedChapter.value = parseInt(index)
launchBtnText.value = 'JOUER'
launchBtnDisable.value = false
selectedChapter.value = index
if (index !== -1) {
launchBtnText.value = 'JOUER'
launchBtnDisable.value = false
} else {
launchBtnText.value = 'Selectionnez un chapitre'
launchBtnDisable.value = true
}
}

}

function launchBtnClick () {
launchBtnHidden.value = true
fullprogressbarHidden.value = false
loadingMessageHidden.value = false
if (Number(minMemValue.value) <= Number(maxMemValue.value)) {
window.electronAPI.ipc.send('launch', {
minMem: minMemValue.value + 'M',
maxMem: maxMemValue.value + 'M',
chapter: selectedChapter.value
})
launchBtnDisable.value = true
localStorage.setItem('minMem', minMemValue.value)
localStorage.setItem('maxMem', maxMemValue.value)
gameLaunching.value = true
window.electronAPI.ipc.send('launch', {
minMem: minMemValue.value + 'M',
maxMem: maxMemValue.value + 'M',
chapter: selectedChapter.value
})
launchBtnDisable.value = true
localStorage.setItem('minMem', minMemValue.value)
localStorage.setItem('maxMem', maxMemValue.value)
gameLaunching.value = true
} else {
showError('Erreur de lancement', 'La mémoire minimale doit être inférieure ou égale à la mémoire maximale.')
showError('Erreur de lancement', 'La mémoire minimale doit être inférieure ou égale à la mémoire maximale.')
}
}

function disconnectBtn () {
setPage('login')
emit('setPage', 'login')
showSuccess('Déconnecté', 'Vous avez été déconnecté de votre compte')
// window.electronAPI.ipc.send('disconnect')
}

function options () {
if (!gameLaunching.value) {
displayFullscreen.value = 'block'
displayFullscreen.value = true
displaySettings.value = 'block'
displayCredits.value = 'none'
}
Expand All @@ -107,16 +112,14 @@ function web () {
window.electronAPI.shell.openExternal('https://altarik.fr')
}

function closeFullscreen () {
displayFullscreen.value = 'none'
displaySettings.value = 'none'
displayCredits.value = 'none'
function sourceCode() {
window.electronAPI.shell.openExternal('https://github.com/AltarikMC/Launcher')
}

function credits () {
displayFullscreen.value = 'block'
function closeFullscreen () {
displayFullscreen.value = false
displaySettings.value = 'none'
displayCredits.value = 'block'
displayCredits.value = 'none'
}

function invalidateData () {
Expand All @@ -126,7 +129,6 @@ function invalidateData () {
window.electronAPI.ipc.send('invalidateData')
}


window.electronAPI.ipc.on('nick', (e) => (nick.value = e.name))

window.electronAPI.ipc.on('modsInformations', (e) => {
Expand All @@ -140,7 +142,7 @@ window.electronAPI.ipc.on('modsInformations', (e) => {

window.electronAPI.ipc.on('invalidated', () => {
invalidateButtonDisabled.value = false
invalidateButtonText.value = 'Supprimer et retélécharger les bibliothèques'
invalidateButtonText.value = 'Nettoyer l\'installation'
showSuccess('Opération terminée', 'Les données du jeu ont été supprimé avec succès')
})

Expand Down Expand Up @@ -169,87 +171,64 @@ window.electronAPI.ipc.on('launchError', (e) => {
})
</script>
<template>
<div id="fullscreen" :style="{ display: displayFullscreen }">
<div @click="closeFullscreen" id="close"><i class="material-icons">close</i></div>
<div id="settings" :style="{ display: displaySettings }">
<h2>Paramètres</h2>
<span href="" id="disconnect-btn" @click="disconnectBtn">Se déconnecter</span>
<h4>Allocation mémoire</h4>
<label for="minMem">mémoire minimale : <span id="outputMinMem">{{ minMemValue }}</span></label><br />
<input type="number" min="1024" :max="memMax" :step="memStep" v-model="minMemValue" class="slider" id="minMem"><br />
<label for="maxMem">mémoire maximale : <span id="outputMaxMem">{{ maxMemValue }}</span></label><br />
<input type="number" min="1024" :max="memMax" :step="memStep" v-model="maxMemValue" class="slider" id="maxMem"><br />
<h4>Au secours, mon jeu ne démarre pas</h4>
<button @click="invalidateData" :disabled="invalidateButtonDisabled">{{ invalidateButtonText }}</button><br />
<span @click="credits">Voir crédits</span>
</div>
<div id="credits" :style="{ display: displayCredits }">
<div class="content">
<p>BSD 3-Clause License</p>

<p>Copyright (c) 2021, Altarik<br />
All rights reserved.</p>

<p>Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:</p>

<ol>
<li>Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.</li>
<li>Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.</li>
<li>Neither the name of the copyright holder nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.</li>
</ol>

<p>THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.</p>
</div>
<Fullscreen v-if="displayFullscreen" @close="closeFullscreen">
<div id="settings" class="py-8" :style="{ display: displaySettings }">
<h1 class="text-center m-5 text-2xl">Paramètres</h1>
<Dividers title="Connectivité" />
<p class="justify-center flex">
<Button :callback="disconnectBtn" text="Se déconnecter" />
</p>
<Dividers title="Allocation mémoire" />
<p>
<label for="minMem">Mémoire minimale : <span>{{ minMemValue }} Mo</span></label>
<QuantityInput v-model="minMemValue" id="minMem" min="1024" :max="memMax" :step="memStep" />
<label for="maxMem">Mémoire maximale : <span>{{ maxMemValue }} Mo</span></label>
<QuantityInput v-model="maxMemValue" id="minMem" min="1024" :max="memMax" :step="memStep" />
</p>
<Dividers title="Dépannage" />
<p class="justify-center flex">
<Button :callback="invalidateData" :text="invalidateButtonText" :disabled="invalidateButtonDisabled" />
</p>
<Dividers title="Autre" />
<p class="justify-center flex">
<Button :callback="sourceCode" text="Code source" />
</p>

</div>
</div>
</Fullscreen>
<div id="content" class="main">
<div id="sidebar">
<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) }">
<h3>{{ item.title }}</h3>
<p>{{ item.description}}</p>
<h1 class="text-4xl mb-3 font-black">Chapitres <i v-if="modsInformations.length !== 0 || modsInformationsLoaded === false" @click="reloadChapters()" class="reload-chapter material-icons">sync</i></h1>
<div id="sidebar-content" @change="modsInformations" class="overflow-auto">
<div v-if="modsInformationsLoaded === false">Une erreur est survenue lors de la récupération des informations, vérifiez votre connexion internet ou réessayez plus tard</div>
<div v-for="(item, index) in modsInformations" v-else-if="modsInformations.length !== 0" @click="changeSelectedChapter(index)" :class="[{ 'text-black': isSelected(index) },{'text-neutral-900/60': !isSelected(index)}]">
<h2 class="text-3xl font-semibold">{{ item.title }}</h2>
<div class="text-2xl">{{ item.description}}</div>
</div>
<div v-else>Chargement en cours</div>
</div>
</div>
<div id="media">
<div id="media" class="absolute bottom-4 left-6 w-xs flex">
<div @click="options" title="Paramètres">
<img src="./assets/images/settings.png">
<img src="./assets/images/settings.png" class="w-24 h-23">
</div>
<div @click="discord" title="Rejoingnez notre Discord">
<img src="./assets/images/discord.png">
<img src="./assets/images/discord.png" class="w-24 h-23">
</div>
<div @click="web"title="Visitez notre site web">
<img src="./assets/images/web.png">
<div @click="web"title="Visitez notre site web" >
<img src="./assets/images/web.png" class="w-24 h-23">
</div>

</div>
<div id="main">
<div id="account">
<div id="nick">{{ nick }}</div><!-- <img src=""> Head du joueur -->
<div class="w-full h-full">
<div id="account" class="w-xs h-24 bg-[url('../images/nickname_scroll.png')] bg-no-repeat bg-cover absolute right-6 top-12 px-8">
<div id="nick" class="relative top-45/100 -translate-y-45/100 text-3xl font-['French-Press',sans-serif]">{{ nick }}</div><!-- <img src=""> Head du joueur -->
</div>
<button @click="launchBtnClick" id="launch-btn" :disabled="launchBtnDisable">
<div id="launch-text" :class="[{hidden: launchBtnHidden}]">{{ launchBtnText }}</div>
<div id="loading-message" :class="[{hidden: loadingMessageHidden}]">{{ loadingMessageText }}</div>
<div id="fullprogressbar" :class="[{hidden: fullprogressbarHidden}]"><div id="progressbar" :style="{ width: progressbarWidth + '%' }"></div></div>
<button @click="launchBtnClick" id="launch-btn" :disabled="launchBtnDisable" class="bg-transparent absolute text-center border-0 p-2.5 h-28 w-78 bottom-5 right-6 font-['French-Press',sans-serif]">
<div class="font-bold" :class="[{hidden: launchBtnHidden},{'text-2xl': launchBtnDisable},{'text-5xl': !launchBtnDisable}]">{{ launchBtnText }}</div>
<div class="w-full h-7 text-white text-2xl relative mx-auto mb-1" :class="[{hidden: loadingMessageHidden}]">{{ loadingMessageText }}</div>
<div id="fullprogressbar" class="rounded-sm" :class="[{hidden: fullprogressbarHidden}]"><div class="w-0 h-full bg-green-700 rounded-sm" :style="{ width: progressbarWidth + '%' }"></div></div>
</button>
</div>
</div>
</template>
</template>
Loading
Loading