From 911f70875fd6e0264834da7561ae57d117e2b45a Mon Sep 17 00:00:00 2001 From: gardenGnostic Date: Fri, 6 Mar 2026 15:55:54 +0100 Subject: [PATCH] v1.1.2 --- README.md | 1 - package.json | 6 ++-- renderer.js | 98 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 102 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index c381297..eaa37da 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,6 @@ # LegacyLauncher A custom launcher for Minecraft Legacy Console Edition. -image ## Features diff --git a/package.json b/package.json index de14bd2..c0a5c07 100644 --- a/package.json +++ b/package.json @@ -1,12 +1,13 @@ { "name": "legacylauncher", - "version": "1.1.0", + "version": "1.1.1", "description": "", "main": "main.js", "scripts": { "test": "echo \"Error: no test specified\" && exit 1", "start": "electron .", "dist": "electron-builder --linux AppImage", + "dist:flatpak": "electron-builder --linux flatpak", "dist:win": "electron-builder --win nsis", "dist:mac": "electron-builder --mac dmg" }, @@ -25,7 +26,8 @@ }, "linux": { "target": [ - "AppImage" + "AppImage", + "flatpak" ], "category": "Game", "icon": "512x512.png" diff --git a/renderer.js b/renderer.js index fb75cdf..c4fa115 100644 --- a/renderer.js +++ b/renderer.js @@ -8,6 +8,7 @@ const childProcess = require('child_process'); const DEFAULT_REPO = "smartcmd/MinecraftConsoles"; const DEFAULT_EXEC = "Minecraft.Client.exe"; const TARGET_FILE = "LCEWindows64.zip"; +const LAUNCHER_REPO = "gradenGnostic/LegacyLauncher"; let releasesData = []; let commitsData = []; @@ -47,9 +48,106 @@ window.onload = async () => { }); fetchGitHubData(); + checkForLauncherUpdates(); GamepadManager.init(); }; +async function checkForLauncherUpdates() { + try { + const currentVersion = require('./package.json').version; + const res = await fetch(`https://api.github.com/repos/${LAUNCHER_REPO}/releases/latest`); + if (!res.ok) return; + + const latestRelease = await res.json(); + const latestVersion = latestRelease.tag_name.replace('v', ''); + + if (latestVersion !== currentVersion) { + const updateConfirmed = await promptLauncherUpdate(latestRelease.tag_name); + if (updateConfirmed) { + downloadAndInstallLauncherUpdate(latestRelease); + } + } + } catch (e) { + console.error("Launcher update check failed:", e); + } +} + +async function promptLauncherUpdate(version) { + return new Promise((resolve) => { + const modal = document.getElementById('update-modal'); + const confirmBtn = document.getElementById('btn-confirm-update'); + const skipBtn = document.getElementById('btn-skip-update'); + const closeBtn = document.getElementById('btn-close-update'); + + document.getElementById('update-modal-text').innerHTML = + `A new Launcher version ${version} is available.

` + + `Would you like to download and install it now?`; + + modal.style.display = 'flex'; + modal.style.opacity = '1'; + + const cleanup = (result) => { + modal.style.opacity = '0'; + setTimeout(() => modal.style.display = 'none', 300); + confirmBtn.onclick = null; + skipBtn.onclick = null; + closeBtn.onclick = null; + resolve(result); + }; + + confirmBtn.onclick = () => cleanup(true); + skipBtn.onclick = () => cleanup(false); + closeBtn.onclick = () => cleanup(false); + }); +} + +async function downloadAndInstallLauncherUpdate(release) { + setProcessingState(true); + updateProgress(0, "Preparing Launcher Update..."); + + let assetPattern = ""; + if (process.platform === 'win32') assetPattern = ".exe"; + else if (process.platform === 'linux') assetPattern = ".AppImage"; + else if (process.platform === 'darwin') assetPattern = ".dmg"; + + const asset = release.assets.find(a => a.name.toLowerCase().endsWith(assetPattern)); + + if (!asset) { + showToast("No compatible update found for your OS."); + setProcessingState(false); + return; + } + + try { + const homeDir = require('os').homedir(); + const downloadPath = path.join(homeDir, 'Downloads', asset.name); + + updateProgress(10, `Downloading Launcher Update...`); + await downloadFile(asset.browser_download_url, downloadPath); + + updateProgress(100, "Download Complete. Launching Installer..."); + + // Give time for UI update + await new Promise(r => setTimeout(r, 1000)); + + if (process.platform === 'win32') { + childProcess.exec(`start "" "${downloadPath}"`); + } else if (process.platform === 'linux') { + fs.chmodSync(downloadPath, 0o755); + childProcess.exec(`"${downloadPath}"`); + } else if (process.platform === 'darwin') { + childProcess.exec(`open "${downloadPath}"`); + } + + // Close the app to allow installation + setTimeout(() => ipcRenderer.send('window-close'), 2000); + + } catch (e) { + showToast("Launcher Update Error: " + e.message); + setProcessingState(false); + } +} + async function scanCompatibilityLayers() { const select = document.getElementById('compat-select'); const savedValue = await Store.get('legacy_compat_layer', 'direct');