From 7ede6c2f278e36b840bed93ee061df79e64ad4fa Mon Sep 17 00:00:00 2001 From: AMIAY Date: Sun, 18 Jan 2026 15:42:24 +0100 Subject: [PATCH] Add files via upload --- GUI/js/install.js | 18 ++++++++++++++++ GUI/js/launcher.js | 9 ++++++++ GUI/js/script.js | 51 ++++++++++++++++++++++++++++++++++++++-------- GUI/js/settings.js | 12 +++++++++++ GUI/js/ui.js | 29 ++++++++++++++++++++++++++ 5 files changed, 110 insertions(+), 9 deletions(-) diff --git a/GUI/js/install.js b/GUI/js/install.js index 0fa5a78..c6f728e 100644 --- a/GUI/js/install.js +++ b/GUI/js/install.js @@ -30,6 +30,24 @@ export function setupInstallation() { if (installPlayerName) { installPlayerName.addEventListener('change', savePlayerName); } + + if (window.electronAPI && window.electronAPI.onProgressUpdate) { + window.electronAPI.onProgressUpdate((data) => { + if (window.LauncherUI) { + window.LauncherUI.showProgress(); + window.LauncherUI.updateProgress(data); + } + }); + } + + if (window.electronAPI && window.electronAPI.onProgressComplete) { + window.electronAPI.onProgressComplete(() => { + if (window.LauncherUI) { + window.LauncherUI.hideProgress(); + } + resetInstallButton(); + }); + } } export async function installGame() { diff --git a/GUI/js/launcher.js b/GUI/js/launcher.js index 977f4ea..5795770 100644 --- a/GUI/js/launcher.js +++ b/GUI/js/launcher.js @@ -31,6 +31,15 @@ export function setupLauncher() { } }); } + + if (window.electronAPI && window.electronAPI.onProgressComplete) { + window.electronAPI.onProgressComplete(() => { + if (window.LauncherUI) { + window.LauncherUI.hideProgress(); + } + resetPlayButton(); + }); + } } export async function launch() { diff --git a/GUI/js/script.js b/GUI/js/script.js index 825a6cd..b7d485d 100644 --- a/GUI/js/script.js +++ b/GUI/js/script.js @@ -1,9 +1,42 @@ -import './ui.js'; -import './install.js'; -import './launcher.js'; -import './news.js'; -import './mods.js'; -import './players.js'; -import './chat.js'; -import './settings.js'; - +import './ui.js'; +import './install.js'; +import './launcher.js'; +import './news.js'; +import './mods.js'; +import './players.js'; +import './chat.js'; +import './settings.js'; + +// Discord notification functions +window.closeDiscordNotification = function() { + const notification = document.getElementById('discordNotification'); + if (notification) { + notification.classList.add('hidden'); + setTimeout(() => { + notification.style.display = 'none'; + }, 300); + } +}; + +// Show notification after a delay +document.addEventListener('DOMContentLoaded', () => { + const notification = document.getElementById('discordNotification'); + if (notification) { + // Check if user has previously dismissed the notification + const dismissed = localStorage.getItem('discordNotificationDismissed'); + if (!dismissed) { + setTimeout(() => { + notification.style.display = 'flex'; + }, 3000); // Show after 3 seconds + } else { + notification.style.display = 'none'; + } + } +}); + +// Remember when user closes notification +const originalClose = window.closeDiscordNotification; +window.closeDiscordNotification = function() { + localStorage.setItem('discordNotificationDismissed', 'true'); + originalClose(); +}; \ No newline at end of file diff --git a/GUI/js/settings.js b/GUI/js/settings.js index e987871..701b252 100644 --- a/GUI/js/settings.js +++ b/GUI/js/settings.js @@ -119,6 +119,15 @@ async function loadAllSettings() { await loadPlayerName(); } +async function openGameLocation() { + try { + if (window.electronAPI && window.electronAPI.openGameLocation) { + await window.electronAPI.openGameLocation(); + } + } catch (error) { + console.error('Error opening game location:', error); + } +} export function getCurrentJavaPath() { if (customJavaCheck && customJavaCheck.checked && customJavaPath) { @@ -135,6 +144,9 @@ export function getCurrentPlayerName() { return 'Player'; } +// Make openGameLocation globally available +window.openGameLocation = openGameLocation; + document.addEventListener('DOMContentLoaded', initSettings); window.SettingsAPI = { diff --git a/GUI/js/ui.js b/GUI/js/ui.js index 9f12233..1b85369 100644 --- a/GUI/js/ui.js +++ b/GUI/js/ui.js @@ -196,8 +196,26 @@ function setupFirstLaunchHandlers() { updateProgress(data); }); + let lockButtonTimeout = null; + window.electronAPI.onLockPlayButton((locked) => { lockPlayButton(locked); + + if (locked) { + if (lockButtonTimeout) { + clearTimeout(lockButtonTimeout); + } + lockButtonTimeout = setTimeout(() => { + console.warn('Play button has been locked for too long, forcing unlock'); + lockPlayButton(false); + lockButtonTimeout = null; + }, 20000); + } else { + if (lockButtonTimeout) { + clearTimeout(lockButtonTimeout); + lockButtonTimeout = null; + } + } }); } @@ -448,6 +466,17 @@ function setupUI() { lockPlayButton(true); + setTimeout(() => { + const playButton = document.getElementById('homePlayBtn'); + if (playButton && playButton.getAttribute('data-locked') === 'true') { + const spanElement = playButton.querySelector('span'); + if (spanElement && spanElement.textContent === 'CHECKING...') { + console.warn('Play button still locked after startup timeout, forcing unlock'); + lockPlayButton(false); + } + } + }, 25000); + handleNavigation(); setupWindowControls(); setupSidebarLogo();