From 78b0fa239ae335fbfaa4d3fc7915e234854427f5 Mon Sep 17 00:00:00 2001 From: azures04 Date: Thu, 1 May 2025 20:25:20 +0200 Subject: [PATCH] Sync --- app/assets/js/index.js | 19 ++++++++++++++----- app/logged.html | 5 +---- config.json | 4 ++-- main.js | 28 ++++++++++++++++++++++++++++ 4 files changed, 45 insertions(+), 11 deletions(-) diff --git a/app/assets/js/index.js b/app/assets/js/index.js index fed06ff..1a38160 100644 --- a/app/assets/js/index.js +++ b/app/assets/js/index.js @@ -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") diff --git a/app/logged.html b/app/logged.html index 18f3a48..90ecc01 100644 --- a/app/logged.html +++ b/app/logged.html @@ -27,9 +27,6 @@
- @@ -208,7 +205,7 @@

-
diff --git a/config.json b/config.json index 673e231..3cd6f5a 100644 --- a/config.json +++ b/config.json @@ -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" } } diff --git a/main.js b/main.js index 0c8ab64..fb681d6 100644 --- a/main.js +++ b/main.js @@ -268,6 +268,7 @@ ipcMain.on("call", async (event, data) => { launcherWindow.webContents.send("Response", $launcherSettings) break case "game::launch": + launcherWindow.webContents.send("Response", { 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", { 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()