This commit is contained in:
Gilles Lazures 2025-05-01 20:25:20 +02:00
parent 5657184b08
commit 78b0fa239a
4 changed files with 45 additions and 11 deletions

View File

@ -2,6 +2,7 @@ const navBar = document.querySelector("nav")
const uiButtons = document.querySelector("footer>section.left")
const footer = document.querySelector("footer")
const leftSection = document.querySelector("section.left")
const playButton = document.querySelector("button[name='play']")
const audioPourcentageLabel = document.querySelector("label[for='audioVolume']")
const audio = new Audio()
@ -79,11 +80,11 @@ function logout() {
document.location.href = './login.html'
}
system.result("server::ping", (pong) => {
system.result("server::ping", pong => {
playersStatus.innerText = `${pong.players.online}/${pong.players.max}`
})
system.result("player::profile", (playerProfile) => {
system.result("player::profile", playerProfile => {
if (!localStorage.getItem("user")) {
localStorage.setItem("user", JSON.stringify(playerProfile))
}
@ -97,7 +98,7 @@ function handleSettingsChanges(key, value) {
system.call("settings::set", { key, value })
}
system.result("game::parseOptions", (options) => {
system.result("game::parseOptions", options => {
gamma.checked = options.gamma == 1 ? true : false
renderClouds.checked = options.renderrenderClouds == false ? false : true
guiScale.value = options.guiScale
@ -105,15 +106,23 @@ system.result("game::parseOptions", (options) => {
renderDistance.value = options.renderDistance
})
system.result("settings::read", (settings) => {
system.result("settings::read", settings => {
ram.value = settings.ram.max
})
system.result("hardware::ramInformation", ($ram) => {
system.result("hardware::ramInformation", $ram => {
ram.setAttribute("max", $ram.avaibleRam)
maxRam.innerText = `${Math.floor($ram.avaibleRam / 1024)} G`
})
system.result("game::launch", info => {
if (info.disablePlayButton) {
playButton.removeAttribute("hidden")
} else {
playButton.setAttribute("hidden", "")
}
})
window.onload = () => {
system.call("hardware::ramInformation")
system.call("game::parseOptions")

View File

@ -27,9 +27,6 @@
</button>
</summary>
<article>
<button class="classic" style="width: 100%;" onclick="system.call('app::devtools')">
Déconnexion
</button>
<button class="classic" style="background-color: #aa3939; width: 100%;" onclick="logout()">
Déconnexion
</button>
@ -208,7 +205,7 @@
<section class="center">
<img class="logo" src="./assets/img/logo.png" alt="">
<br>
<button class="play">
<button class="play" name="play" onclick="system.call('game::launch')">
Jouer
</button>
</section>

View File

@ -1,6 +1,6 @@
{
"api": {
"base": "http://localhost:8535",
"base": "http://185.253.54.147:8535",
"endpoints": {
"fileHash": "/api/v1/file/hash/",
"checkBanStatus": "/api/v1/ban/iam",
@ -10,7 +10,7 @@
},
"websockets": {
"base": {
"host": "wss://localhost",
"host": "wss://185.253.54.147",
"port": "8535"
}
}

28
main.js
View File

@ -268,6 +268,7 @@ ipcMain.on("call", async (event, data) => {
launcherWindow.webContents.send("Response<settings::read>", $launcherSettings)
break
case "game::launch":
launcherWindow.webContents.send("Response<game::launch>", { disablePlayButton: false })
const downloadQueue = []
const remoteFiles = await fileManager.getRemoteFiles()
const localFiles = fs.readdirSync(path.join(app.getPath("appData"), ".catboat"), { recursive: true })
@ -320,6 +321,33 @@ ipcMain.on("call", async (event, data) => {
title: "Téléchargement des fichiers",
message: "Téléchargement fini."
})
gamePlayable = true
launcher.on("close", () => {
launcherSettings.webContents.send("Response<game::launch>", { disablePlayButton: true })
gamePlayable = true
})
launcher.on("debug", (log) => {
console.log(log)
})
launcher.on("data", (log) => {
console.log(log)
})
if (gamePlayable) {
launcher.launch({
root: path.join(app.getPath("appData"), ".catboat"),
authorization: auth,
version: {
number: "1.16.5",
type: "release"
},
forge: path.join(app.getPath("appData"), ".catboat", "forge-1.16.5.jar"),
memory: {
min: 512,
max: launcherSettings.get("ram").max
}
})
}
break
case "app::devtools":
launcherWindow.webContents.openDevTools()