Add installation effects and draggable progress bar

Introduces animated installation effects overlay and makes the progress bar draggable. Adds maximize window support, improves window controls styling, and enforces a single app instance. Removes the unused Skins page and related translations. Refines  various UI details for a more polished user experience.
This commit is contained in:
AMIAY
2026-01-22 07:41:35 +01:00
parent bb474fe233
commit 2a024b61dd
9 changed files with 341 additions and 92 deletions

View File

@@ -51,11 +51,7 @@
<i class="fas fa-cog"></i> <i class="fas fa-cog"></i>
<span class="nav-tooltip" data-i18n="nav.settings">Settings</span> <span class="nav-tooltip" data-i18n="nav.settings">Settings</span>
</div> </div>
<div class="nav-item" data-page="skins"> <div class="nav-item logs-nav-item" data-page="logs" id="openLogsBtn" onclick="openLogs()">
<i class="fas fa-user"></i>
<span class="nav-tooltip" data-i18n="nav.skins">Skins</span>
</div>
<div class="nav-item" data-page="logs" id="openLogsBtn" onclick="openLogs()">
<i class="fas fa-terminal"></i> <i class="fas fa-terminal"></i>
<span class="nav-tooltip">Logs</span> <span class="nav-tooltip">Logs</span>
</div> </div>
@@ -94,6 +90,9 @@
<button class="control-btn minimize" onclick="window.electronAPI?.minimizeWindow()"> <button class="control-btn minimize" onclick="window.electronAPI?.minimizeWindow()">
<i class="fas fa-minus"></i> <i class="fas fa-minus"></i>
</button> </button>
<button class="control-btn maximize" onclick="toggleMaximize()">
<i class="fas fa-square"></i>
</button>
<button class="control-btn close" onclick="window.electronAPI?.closeWindow()"> <button class="control-btn close" onclick="window.electronAPI?.closeWindow()">
<i class="fas fa-times"></i> <i class="fas fa-times"></i>
</button> </button>
@@ -104,9 +103,6 @@
<h1 class="game-title"> <h1 class="game-title">
HY<span class="title-accent">TALE</span> HY<span class="title-accent">TALE</span>
</h1> </h1>
<div class="game-tags">
<span class="tag" data-i18n="header.f2p">FREE TO PLAY</span>
</div>
</div> </div>
<div class="content-pages"> <div class="content-pages">
@@ -114,7 +110,7 @@
<div class="install-content"> <div class="install-content">
<div class="install-header"> <div class="install-header">
<h1 class="install-title"> <h1 class="install-title">
HYTA<span class="title-accent">LE</span> HY<span class="title-accent">TALE</span>
</h1> </h1>
<p class="install-subtitle" data-i18n="install.title">FREE TO PLAY LAUNCHER</p> <p class="install-subtitle" data-i18n="install.title">FREE TO PLAY LAUNCHER</p>
</div> </div>
@@ -462,14 +458,6 @@
</div> </div>
</div> </div>
<div id="skins-page" class="page">
<div class="placeholder-content">
<i class="fas fa-user text-6xl mb-4 text-purple-500"></i>
<h2 data-i18n="skins.title">Skins</h2>
<p data-i18n="skins.comingSoon">Skin customization coming soon...</p>
</div>
</div>
<div id="logs-page" class="page"> <div id="logs-page" class="page">
<div class="logs-container"> <div class="logs-container">
<div class="logs-header"> <div class="logs-header">
@@ -532,6 +520,20 @@
</div> </div>
</div> </div>
<!-- Installation effects overlay -->
<div id="installationEffects" class="installation-effects" style="display: none;">
<div class="space-effects">
<div class="warp-line"></div>
<div class="warp-line"></div>
<div class="warp-line"></div>
<div class="warp-line"></div>
<div class="warp-line"></div>
<div class="warp-line"></div>
<div class="warp-line"></div>
<div class="warp-line"></div>
</div>
</div>
<div id="chatUsernameModal" class="chat-username-modal" style="display: none;"> <div id="chatUsernameModal" class="chat-username-modal" style="display: none;">
<div class="chat-username-modal-content"> <div class="chat-username-modal-content">
<div class="chat-username-modal-header"> <div class="chat-username-modal-header">

View File

@@ -39,6 +39,19 @@ export function setupInstallation() {
} }
}); });
} }
// Setup installation effects listeners
if (window.electronAPI && window.electronAPI.onInstallationStart) {
window.electronAPI.onInstallationStart(() => {
showInstallationEffects();
});
}
if (window.electronAPI && window.electronAPI.onInstallationEnd) {
window.electronAPI.onInstallationEnd(() => {
hideInstallationEffects();
});
}
} }
export async function installGame() { export async function installGame() {
@@ -78,12 +91,19 @@ export async function installGame() {
} }
} catch (error) { } catch (error) {
const errorMsg = window.i18n ? window.i18n.t('progress.installationFailed').replace('{error}', error.message) : `Installation failed: ${error.message}`; const errorMsg = window.i18n ? window.i18n.t('progress.installationFailed').replace('{error}', error.message) : `Installation failed: ${error.message}`;
// Hide installation effects on error
if (window.hideInstallationEffects) {
window.hideInstallationEffects();
}
// Reset button state on error
resetInstallButton();
if (window.LauncherUI) { if (window.LauncherUI) {
window.LauncherUI.updateProgress({ message: errorMsg }); window.LauncherUI.updateProgress({ message: errorMsg });
setTimeout(() => { // Don't hide progress bar, just update the message
window.LauncherUI.hideProgress(); // User can see the error and close it manually
resetInstallButton();
}, 3000);
} }
} }
} }

View File

@@ -479,6 +479,9 @@ function setupUI() {
progressSpeed = document.getElementById('progressSpeed'); progressSpeed = document.getElementById('progressSpeed');
progressSize = document.getElementById('progressSize'); progressSize = document.getElementById('progressSize');
// Setup draggable progress bar
setupProgressDrag();
lockPlayButton(true); lockPlayButton(true);
setTimeout(() => { setTimeout(() => {
@@ -510,4 +513,91 @@ window.LauncherUI = {
updateProgress updateProgress
}; };
// Make installation effects globally available
window.showInstallationEffects = showInstallationEffects;
window.hideInstallationEffects = hideInstallationEffects;
// Draggable progress bar functionality
function setupProgressDrag() {
if (!progressOverlay) return;
let isDragging = false;
let offsetX;
let offsetY;
progressOverlay.addEventListener('mousedown', dragStart);
document.addEventListener('mousemove', drag);
document.addEventListener('mouseup', dragEnd);
function dragStart(e) {
// Only drag if clicking on the overlay itself, not on buttons or inputs
if (e.target.closest('.progress-bar-fill')) return;
if (e.target === progressOverlay || e.target.closest('.progress-content')) {
isDragging = true;
progressOverlay.classList.add('dragging');
// Get the current position of the progress overlay
const rect = progressOverlay.getBoundingClientRect();
offsetX = e.clientX - rect.left - progressOverlay.offsetWidth / 2;
offsetY = e.clientY - rect.top;
}
}
function drag(e) {
if (isDragging) {
e.preventDefault();
// Calculate new position
const newX = e.clientX - offsetX - progressOverlay.offsetWidth / 2;
const newY = e.clientY - offsetY;
// Get window bounds
const maxX = window.innerWidth - progressOverlay.offsetWidth;
const maxY = window.innerHeight - progressOverlay.offsetHeight;
const minX = 0;
const minY = 0;
// Constrain to window bounds
const constrainedX = Math.max(minX, Math.min(newX, maxX));
const constrainedY = Math.max(minY, Math.min(newY, maxY));
progressOverlay.style.left = constrainedX + 'px';
progressOverlay.style.bottom = 'auto';
progressOverlay.style.top = constrainedY + 'px';
progressOverlay.style.transform = 'none';
}
}
function dragEnd() {
isDragging = false;
progressOverlay.classList.remove('dragging');
}
}
// Show/hide installation effects
function showInstallationEffects() {
const installationEffects = document.getElementById('installationEffects');
if (installationEffects) {
installationEffects.style.display = 'block';
}
}
function hideInstallationEffects() {
const installationEffects = document.getElementById('installationEffects');
if (installationEffects) {
installationEffects.style.display = 'none';
}
}
// Toggle maximize/restore window function
function toggleMaximize() {
if (window.electronAPI && window.electronAPI.maximizeWindow) {
window.electronAPI.maximizeWindow();
}
}
// Make toggleMaximize globally available
window.toggleMaximize = toggleMaximize;
document.addEventListener('DOMContentLoaded', setupUI); document.addEventListener('DOMContentLoaded', setupUI);

View File

@@ -4,14 +4,12 @@
"mods": "Mods", "mods": "Mods",
"news": "News", "news": "News",
"chat": "Players Chat", "chat": "Players Chat",
"settings": "Settings", "settings": "Settings"
"skins": "Skins"
}, },
"header": { "header": {
"playersLabel": "Players:", "playersLabel": "Players:",
"manageProfiles": "Manage Profiles", "manageProfiles": "Manage Profiles",
"defaultProfile": "Default", "defaultProfile": "Default"
"f2p": "FREE TO PLAY"
}, },
"install": { "install": {
"title": "FREE TO PLAY LAUNCHER", "title": "FREE TO PLAY LAUNCHER",
@@ -148,10 +146,6 @@
"notificationText": "Join our Discord community!", "notificationText": "Join our Discord community!",
"joinButton": "Join Discord" "joinButton": "Join Discord"
}, },
"skins": {
"title": "Skins",
"comingSoon": "Skin customization coming soon..."
},
"common": { "common": {
"confirm": "Confirm", "confirm": "Confirm",
"cancel": "Cancel", "cancel": "Cancel",

View File

@@ -4,14 +4,12 @@
"mods": "Mods", "mods": "Mods",
"news": "Noticias", "news": "Noticias",
"chat": "Chat de Jugadores", "chat": "Chat de Jugadores",
"settings": "Configuración", "settings": "Configuración"
"skins": "Aspectos"
}, },
"header": { "header": {
"playersLabel": "Jugadores:", "playersLabel": "Jugadores:",
"manageProfiles": "Gestionar Perfiles", "manageProfiles": "Gestionar Perfiles",
"defaultProfile": "Predeterminado", "defaultProfile": "Predeterminado"
"f2p": "FREE TO PLAY"
}, },
"install": { "install": {
"title": "LAUNCHER GRATUITO", "title": "LAUNCHER GRATUITO",
@@ -148,10 +146,6 @@
"notificationText": "¡Únete a nuestra comunidad de Discord!", "notificationText": "¡Únete a nuestra comunidad de Discord!",
"joinButton": "Unirse a Discord" "joinButton": "Unirse a Discord"
}, },
"skins": {
"title": "Aspectos",
"comingSoon": "Personalización de aspectos próximamente..."
},
"common": { "common": {
"confirm": "Confirmar", "confirm": "Confirmar",
"cancel": "Cancelar", "cancel": "Cancelar",

View File

@@ -4,14 +4,12 @@
"mods": "Mods", "mods": "Mods",
"news": "Notícias", "news": "Notícias",
"chat": "Chat de Jogadores", "chat": "Chat de Jogadores",
"settings": "Configurações", "settings": "Configurações"
"skins": "Aparências"
}, },
"header": { "header": {
"playersLabel": "Jogadores:", "playersLabel": "Jogadores:",
"manageProfiles": "Gerenciar Perfis", "manageProfiles": "Gerenciar Perfis",
"defaultProfile": "Padrão", "defaultProfile": "Padrão"
"f2p": "FREE TO PLAY"
}, },
"install": { "install": {
"title": "LANÇADOR JOGO GRATUITO", "title": "LANÇADOR JOGO GRATUITO",
@@ -148,10 +146,7 @@
"notificationText": "Junte-se à nossa comunidade do Discord!", "notificationText": "Junte-se à nossa comunidade do Discord!",
"joinButton": "Entrar no Discord" "joinButton": "Entrar no Discord"
}, },
"skins": {
"title": "Aparências",
"comingSoon": "Personalização de aparências em breve..."
},
"common": { "common": {
"confirm": "Confirmar", "confirm": "Confirmar",
"cancel": "Cancelar", "cancel": "Cancelar",

View File

@@ -26,7 +26,7 @@ body {
backdrop-filter: blur(20px); backdrop-filter: blur(20px);
border-right: 1px solid rgba(255, 255, 255, 0.1); border-right: 1px solid rgba(255, 255, 255, 0.1);
position: relative; position: relative;
z-index: 20; z-index: 45;
} }
.sidebar-logo { .sidebar-logo {
@@ -109,6 +109,12 @@ body {
transform: scale(1.1); transform: scale(1.1);
} }
/* Allow logs navigation during installation */
.logs-nav-item {
z-index: 100;
position: relative;
}
.nav-tooltip { .nav-tooltip {
position: absolute; position: absolute;
left: 100%; left: 100%;
@@ -374,10 +380,10 @@ body {
} }
.control-btn { .control-btn {
width: 20px; width: 28px;
height: 20px; height: 28px;
border-radius: 50%; border-radius: 6px;
border: none; border: 1px solid rgba(255, 255, 255, 0.1);
cursor: pointer !important; cursor: pointer !important;
transition: all 0.3s ease; transition: all 0.3s ease;
display: flex !important; display: flex !important;
@@ -386,24 +392,36 @@ body {
position: relative; position: relative;
z-index: 100000 !important; z-index: 100000 !important;
pointer-events: auto !important; pointer-events: auto !important;
backdrop-filter: blur(10px);
} }
.control-btn i { .control-btn i {
font-size: 0.5rem; font-size: 0.75rem;
opacity: 0; opacity: 0.7;
transition: opacity 0.3s ease; transition: opacity 0.3s ease;
color: white;
} }
.control-btn:hover i { .control-btn:hover i {
opacity: 1; opacity: 1;
} }
.maximize {
background: rgba(34, 197, 94, 0.2);
}
.maximize:hover {
background: rgba(34, 197, 94, 0.4);
border-color: rgba(34, 197, 94, 0.5);
}
.minimize { .minimize {
background: rgba(251, 191, 36, 0.2); background: rgba(251, 191, 36, 0.2);
} }
.minimize:hover { .minimize:hover {
background: #fbbf24; background: rgba(251, 191, 36, 0.4);
border-color: rgba(251, 191, 36, 0.5);
} }
.close { .close {
@@ -411,7 +429,8 @@ body {
} }
.close:hover { .close:hover {
background: #ef4444; background: rgba(239, 68, 68, 0.4);
border-color: rgba(239, 68, 68, 0.5);
} }
@@ -429,7 +448,7 @@ body {
} }
.title-accent { .title-accent {
color: #9333ea; color: #bf84f7;
text-shadow: 0 0 20px rgba(147, 51, 234, 0.5); text-shadow: 0 0 20px rgba(147, 51, 234, 0.5);
} }
@@ -928,15 +947,22 @@ body {
.news-grid-horizontal { .news-grid-horizontal {
display: flex; display: grid;
grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
grid-auto-rows: minmax(200px, 1fr);
gap: 1rem; gap: 1rem;
overflow-x: auto; overflow-y: auto;
overflow-x: hidden;
padding-bottom: 1rem; padding-bottom: 1rem;
scrollbar-width: thin; scrollbar-width: thin;
scrollbar-color: rgba(147, 51, 234, 0.3) transparent; scrollbar-color: rgba(147, 51, 234, 0.3) transparent;
flex: 1;
min-height: 0;
align-content: start;
} }
.news-grid-horizontal::-webkit-scrollbar { .news-grid-horizontal::-webkit-scrollbar {
width: 6px;
height: 6px; height: 6px;
} }
@@ -954,9 +980,11 @@ body {
} }
.news-grid-horizontal .news-item { .news-grid-horizontal .news-item {
min-width: 300px; width: 100%;
max-width: 300px; min-width: 0;
height: 200px; max-width: none;
height: auto;
aspect-ratio: 16 / 9;
flex-shrink: 0; flex-shrink: 0;
} }
@@ -988,7 +1016,7 @@ body {
.news-card { .news-card {
position: relative; position: relative;
aspect-ratio: 16/10; height: 100%;
border-radius: 8px; border-radius: 8px;
overflow: hidden; overflow: hidden;
cursor: pointer; cursor: pointer;
@@ -1500,44 +1528,55 @@ body {
.progress-overlay { .progress-overlay {
position: fixed; position: fixed;
bottom: 1rem; bottom: 1.5rem;
left: 1rem; left: 50%;
right: 1rem; transform: translateX(-50%);
background: rgba(0, 0, 0, 0.85); width: 400px;
backdrop-filter: blur(30px); background: rgba(15, 23, 42, 0.95);
border: 2px solid rgba(147, 51, 234, 0.3); backdrop-filter: blur(20px);
border-radius: 16px; border: 1px solid rgba(147, 51, 234, 0.3);
padding: 2rem; border-radius: 12px;
z-index: 50; padding: 1.25rem;
z-index: 60;
box-shadow: box-shadow:
0 8px 32px rgba(0, 0, 0, 0.6), 0 4px 16px rgba(0, 0, 0, 0.5),
0 0 40px rgba(147, 51, 234, 0.1), 0 0 30px rgba(147, 51, 234, 0.15),
inset 0 1px 0 rgba(255, 255, 255, 0.1); inset 0 1px 0 rgba(255, 255, 255, 0.05);
animation: progressGlow 3s ease-in-out infinite alternate; animation: progressGlow 3s ease-in-out infinite alternate;
cursor: move;
user-select: none;
}
.progress-overlay.dragging {
cursor: grabbing;
box-shadow:
0 8px 24px rgba(0, 0, 0, 0.7),
0 0 50px rgba(147, 51, 234, 0.3),
inset 0 1px 0 rgba(255, 255, 255, 0.05);
} }
@keyframes progressGlow { @keyframes progressGlow {
0% { 0% {
box-shadow: box-shadow:
0 8px 32px rgba(0, 0, 0, 0.6), 0 4px 16px rgba(0, 0, 0, 0.5),
0 0 40px rgba(147, 51, 234, 0.1), 0 0 30px rgba(147, 51, 234, 0.15),
inset 0 1px 0 rgba(255, 255, 255, 0.1); inset 0 1px 0 rgba(255, 255, 255, 0.05);
border-color: rgba(147, 51, 234, 0.3); border-color: rgba(147, 51, 234, 0.3);
} }
100% { 100% {
box-shadow: box-shadow:
0 8px 32px rgba(0, 0, 0, 0.6), 0 4px 16px rgba(0, 0, 0, 0.5),
0 0 60px rgba(147, 51, 234, 0.3), 0 0 40px rgba(147, 51, 234, 0.25),
inset 0 1px 0 rgba(255, 255, 255, 0.1); inset 0 1px 0 rgba(255, 255, 255, 0.05);
border-color: rgba(147, 51, 234, 0.5); border-color: rgba(147, 51, 234, 0.4);
} }
} }
.progress-content { .progress-content {
display: flex; display: flex;
flex-direction: column; flex-direction: column;
gap: 1.5rem; gap: 0.75rem;
} }
.progress-info { .progress-info {
@@ -1548,7 +1587,7 @@ body {
.progress-info span { .progress-info span {
font-family: 'JetBrains Mono', monospace; font-family: 'JetBrains Mono', monospace;
font-size: 0.875rem; font-size: 0.8rem;
} }
#progressText { #progressText {
@@ -1572,8 +1611,8 @@ body {
#progressPercent { #progressPercent {
color: #9333ea; color: #9333ea;
font-weight: 700; font-weight: 700;
font-size: 2rem; font-size: 1.25rem;
text-shadow: 0 0 20px rgba(147, 51, 234, 0.8); text-shadow: 0 0 15px rgba(147, 51, 234, 0.6);
animation: percentGlow 1.5s ease-in-out infinite; animation: percentGlow 1.5s ease-in-out infinite;
} }
@@ -1592,15 +1631,15 @@ body {
} }
.progress-bar-container { .progress-bar-container {
height: 16px; height: 10px;
background: linear-gradient(90deg, #1f2937, #374151); background: linear-gradient(90deg, #1f2937, #374151);
border: 2px solid rgba(147, 51, 234, 0.2); border: 1px solid rgba(147, 51, 234, 0.2);
border-radius: 12px; border-radius: 8px;
overflow: hidden; overflow: hidden;
position: relative; position: relative;
box-shadow: box-shadow:
inset 0 2px 4px rgba(0, 0, 0, 0.5), inset 0 2px 4px rgba(0, 0, 0, 0.5),
0 0 20px rgba(147, 51, 234, 0.1); 0 0 15px rgba(147, 51, 234, 0.1);
} }
.progress-bar-container::before { .progress-bar-container::before {
@@ -1636,15 +1675,15 @@ body {
#06b6d4 75%, #06b6d4 75%,
#10b981 100%); #10b981 100%);
background-size: 200% 100%; background-size: 200% 100%;
border-radius: 10px; border-radius: 6px;
width: 0%; width: 0%;
transition: width 0.5s cubic-bezier(0.4, 0, 0.2, 1); transition: width 0.5s cubic-bezier(0.4, 0, 0.2, 1);
position: relative; position: relative;
overflow: hidden; overflow: hidden;
animation: progressFlow 3s linear infinite; animation: progressFlow 3s linear infinite;
box-shadow: box-shadow:
0 0 30px rgba(147, 51, 234, 0.6), 0 0 20px rgba(147, 51, 234, 0.5),
inset 0 1px 0 rgba(255, 255, 255, 0.3); inset 0 1px 0 rgba(255, 255, 255, 0.2);
} }
@keyframes progressFlow { @keyframes progressFlow {
@@ -1692,6 +1731,71 @@ body {
text-shadow: 0 0 5px rgba(156, 163, 175, 0.3); text-shadow: 0 0 5px rgba(156, 163, 175, 0.3);
} }
/* Installation effects */
.installation-effects {
position: fixed;
top: 0;
left: 80px;
width: calc(100% - 80px);
height: 100%;
background: rgba(0, 0, 0, 0.5);
backdrop-filter: blur(10px);
z-index: 40;
pointer-events: auto;
overflow: hidden;
}
.space-effects {
position: absolute;
width: 100%;
height: 100%;
perspective: 1000px;
}
.warp-line {
position: absolute;
width: 2px;
height: 100%;
background: linear-gradient(180deg,
transparent 0%,
rgba(147, 51, 234, 0.8) 50%,
transparent 100%);
box-shadow: 0 0 10px rgba(147, 51, 234, 0.8),
0 0 20px rgba(147, 51, 234, 0.4);
animation: warpSpeed 1.5s linear infinite;
opacity: 0;
}
.warp-line:nth-child(1) { left: 10%; animation-delay: 0s; }
.warp-line:nth-child(2) { left: 25%; animation-delay: 0.2s; }
.warp-line:nth-child(3) { left: 40%; animation-delay: 0.4s; }
.warp-line:nth-child(4) { left: 55%; animation-delay: 0.6s; }
.warp-line:nth-child(5) { left: 70%; animation-delay: 0.8s; }
.warp-line:nth-child(6) { left: 85%; animation-delay: 1s; }
.warp-line:nth-child(7) { left: 15%; animation-delay: 0.3s; }
.warp-line:nth-child(8) { left: 60%; animation-delay: 0.7s; }
@keyframes warpSpeed {
0% {
transform: translateY(-100%) scaleY(0);
opacity: 0;
}
10% {
opacity: 1;
}
50% {
opacity: 1;
transform: translateY(0%) scaleY(1);
}
90% {
opacity: 1;
}
100% {
transform: translateY(100%) scaleY(2);
opacity: 0;
}
}
.mods-manager { .mods-manager {
display: flex; display: flex;

45
main.js
View File

@@ -8,6 +8,22 @@ const profileManager = require('./backend/managers/profileManager');
logger.interceptConsole(); logger.interceptConsole();
// Single instance lock - prevent multiple launcher instances
const gotTheLock = app.requestSingleInstanceLock();
if (!gotTheLock) {
console.log('Another instance is already running. Quitting...');
app.quit();
} else {
app.on('second-instance', (event, commandLine, workingDirectory) => {
// Someone tried to run a second instance, focus our window instead
if (mainWindow) {
if (mainWindow.isMinimized()) mainWindow.restore();
mainWindow.focus();
}
});
}
let mainWindow; let mainWindow;
let updateManager; let updateManager;
let discordRPC = null; let discordRPC = null;
@@ -89,8 +105,10 @@ function createWindow() {
mainWindow = new BrowserWindow({ mainWindow = new BrowserWindow({
width: 1280, width: 1280,
height: 720, height: 720,
minWidth: 900,
minHeight: 600,
frame: false, frame: false,
resizable: false, resizable: true,
alwaysOnTop: false, alwaysOnTop: false,
backgroundColor: '#090909', backgroundColor: '#090909',
webPreferences: { webPreferences: {
@@ -327,6 +345,11 @@ ipcMain.handle('launch-game', async (event, playerName, javaPath, installPath, g
ipcMain.handle('install-game', async (event, playerName, javaPath, installPath) => { ipcMain.handle('install-game', async (event, playerName, javaPath, installPath) => {
try { try {
// Signal installation start
if (mainWindow && !mainWindow.isDestroyed()) {
mainWindow.webContents.send('installation-start');
}
const progressCallback = (message, percent, speed, downloaded, total) => { const progressCallback = (message, percent, speed, downloaded, total) => {
if (mainWindow && !mainWindow.isDestroyed()) { if (mainWindow && !mainWindow.isDestroyed()) {
const data = { const data = {
@@ -342,11 +365,21 @@ ipcMain.handle('install-game', async (event, playerName, javaPath, installPath)
const result = await installGame(playerName, progressCallback, javaPath, installPath); const result = await installGame(playerName, progressCallback, javaPath, installPath);
// Signal installation end
if (mainWindow && !mainWindow.isDestroyed()) {
mainWindow.webContents.send('installation-end');
}
return result; return result;
} catch (error) { } catch (error) {
console.error('Install error:', error); console.error('Install error:', error);
const errorMessage = error.message || error.toString(); const errorMessage = error.message || error.toString();
// Signal installation end on error too
if (mainWindow && !mainWindow.isDestroyed()) {
mainWindow.webContents.send('installation-end');
}
return { success: false, error: errorMessage }; return { success: false, error: errorMessage };
} }
}); });
@@ -793,6 +826,16 @@ ipcMain.handle('window-minimize', () => {
} }
}); });
ipcMain.handle('window-maximize', () => {
if (mainWindow && !mainWindow.isDestroyed()) {
if (mainWindow.isMaximized()) {
mainWindow.unmaximize();
} else {
mainWindow.maximize();
}
}
});
ipcMain.handle('get-log-directory', () => { ipcMain.handle('get-log-directory', () => {
return logger.getLogDirectory(); return logger.getLogDirectory();
}); });

View File

@@ -5,6 +5,7 @@ contextBridge.exposeInMainWorld('electronAPI', {
installGame: (playerName, javaPath, installPath) => ipcRenderer.invoke('install-game', playerName, javaPath, installPath), installGame: (playerName, javaPath, installPath) => ipcRenderer.invoke('install-game', playerName, javaPath, installPath),
closeWindow: () => ipcRenderer.invoke('window-close'), closeWindow: () => ipcRenderer.invoke('window-close'),
minimizeWindow: () => ipcRenderer.invoke('window-minimize'), minimizeWindow: () => ipcRenderer.invoke('window-minimize'),
maximizeWindow: () => ipcRenderer.invoke('window-maximize'),
saveUsername: (username) => ipcRenderer.invoke('save-username', username), saveUsername: (username) => ipcRenderer.invoke('save-username', username),
loadUsername: () => ipcRenderer.invoke('load-username'), loadUsername: () => ipcRenderer.invoke('load-username'),
saveChatUsername: (chatUsername) => ipcRenderer.invoke('save-chat-username', chatUsername), saveChatUsername: (chatUsername) => ipcRenderer.invoke('save-chat-username', chatUsername),
@@ -44,6 +45,12 @@ contextBridge.exposeInMainWorld('electronAPI', {
onProgressComplete: (callback) => { onProgressComplete: (callback) => {
ipcRenderer.on('progress-complete', () => callback()); ipcRenderer.on('progress-complete', () => callback());
}, },
onInstallationStart: (callback) => {
ipcRenderer.on('installation-start', () => callback());
},
onInstallationEnd: (callback) => {
ipcRenderer.on('installation-end', () => callback());
},
getUserId: () => ipcRenderer.invoke('get-user-id'), getUserId: () => ipcRenderer.invoke('get-user-id'),
checkForUpdates: () => ipcRenderer.invoke('check-for-updates'), checkForUpdates: () => ipcRenderer.invoke('check-for-updates'),
openDownloadPage: () => ipcRenderer.invoke('open-download-page'), openDownloadPage: () => ipcRenderer.invoke('open-download-page'),