mirror of
https://git.sanhost.net/sanasol/hytale-f2p
synced 2026-02-26 09:11:49 -03:00
pre-release & release game version [to check]
This commit is contained in:
@@ -60,6 +60,18 @@ export async function installGame() {
|
||||
const playerName = (installPlayerName ? installPlayerName.value.trim() : '') || 'Player';
|
||||
const installPath = installPathInput ? installPathInput.value.trim() : '';
|
||||
|
||||
// Récupérer la branche sélectionnée
|
||||
const selectedBranchRadio = document.querySelector('input[name="installBranch"]:checked');
|
||||
const selectedBranch = selectedBranchRadio ? selectedBranchRadio.value : 'release';
|
||||
|
||||
console.log(`[Install] Installing game with branch: ${selectedBranch}`);
|
||||
|
||||
// Sauvegarder la branche sélectionnée dans le config
|
||||
if (window.electronAPI && window.electronAPI.saveVersionBranch) {
|
||||
await window.electronAPI.saveVersionBranch(selectedBranch);
|
||||
console.log(`[Install] Branch saved to config: ${selectedBranch}`);
|
||||
}
|
||||
|
||||
if (window.LauncherUI) window.LauncherUI.showProgress();
|
||||
isDownloading = true;
|
||||
if (installBtn) {
|
||||
@@ -69,7 +81,7 @@ export async function installGame() {
|
||||
|
||||
try {
|
||||
if (window.electronAPI && window.electronAPI.installGame) {
|
||||
const result = await window.electronAPI.installGame(playerName, '', installPath);
|
||||
const result = await window.electronAPI.installGame(playerName, '', installPath, selectedBranch);
|
||||
|
||||
if (result.success) {
|
||||
const successMsg = window.i18n ? window.i18n.t('progress.installationComplete') : 'Installation completed successfully!';
|
||||
|
||||
@@ -3,11 +3,12 @@ let customJavaCheck;
|
||||
let customJavaOptions;
|
||||
let customJavaPath;
|
||||
let browseJavaBtn;
|
||||
let settingsPlayerName;
|
||||
let discordRPCCheck;
|
||||
let closeLauncherCheck;
|
||||
let gpuPreferenceRadios;
|
||||
|
||||
let settingsPlayerName;
|
||||
let discordRPCCheck;
|
||||
let closeLauncherCheck;
|
||||
let gpuPreferenceRadios;
|
||||
let gameBranchRadios;
|
||||
|
||||
|
||||
// UUID Management elements
|
||||
let currentUuidDisplay;
|
||||
@@ -161,11 +162,12 @@ function setupSettingsElements() {
|
||||
customJavaOptions = document.getElementById('customJavaOptions');
|
||||
customJavaPath = document.getElementById('customJavaPath');
|
||||
browseJavaBtn = document.getElementById('browseJavaBtn');
|
||||
settingsPlayerName = document.getElementById('settingsPlayerName');
|
||||
discordRPCCheck = document.getElementById('discordRPCCheck');
|
||||
closeLauncherCheck = document.getElementById('closeLauncherCheck');
|
||||
gpuPreferenceRadios = document.querySelectorAll('input[name="gpuPreference"]');
|
||||
|
||||
settingsPlayerName = document.getElementById('settingsPlayerName');
|
||||
discordRPCCheck = document.getElementById('discordRPCCheck');
|
||||
closeLauncherCheck = document.getElementById('closeLauncherCheck');
|
||||
gpuPreferenceRadios = document.querySelectorAll('input[name="gpuPreference"]');
|
||||
gameBranchRadios = document.querySelectorAll('input[name="gameBranch"]');
|
||||
|
||||
|
||||
// UUID Management elements
|
||||
currentUuidDisplay = document.getElementById('currentUuid');
|
||||
@@ -194,14 +196,14 @@ function setupSettingsElements() {
|
||||
settingsPlayerName.addEventListener('change', savePlayerName);
|
||||
}
|
||||
|
||||
if (discordRPCCheck) {
|
||||
discordRPCCheck.addEventListener('change', saveDiscordRPC);
|
||||
}
|
||||
|
||||
if (closeLauncherCheck) {
|
||||
closeLauncherCheck.addEventListener('change', saveCloseLauncher);
|
||||
}
|
||||
|
||||
if (discordRPCCheck) {
|
||||
discordRPCCheck.addEventListener('change', saveDiscordRPC);
|
||||
}
|
||||
|
||||
if (closeLauncherCheck) {
|
||||
closeLauncherCheck.addEventListener('change', saveCloseLauncher);
|
||||
}
|
||||
|
||||
|
||||
// UUID event listeners
|
||||
if (copyUuidBtn) {
|
||||
@@ -252,6 +254,12 @@ function setupSettingsElements() {
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
if (gameBranchRadios) {
|
||||
gameBranchRadios.forEach(radio => {
|
||||
radio.addEventListener('change', handleBranchChange);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function toggleCustomJava() {
|
||||
@@ -344,43 +352,43 @@ async function saveDiscordRPC() {
|
||||
}
|
||||
}
|
||||
|
||||
async function loadDiscordRPC() {
|
||||
try {
|
||||
if (window.electronAPI && window.electronAPI.loadDiscordRPC) {
|
||||
const enabled = await window.electronAPI.loadDiscordRPC();
|
||||
if (discordRPCCheck) {
|
||||
discordRPCCheck.checked = enabled;
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Error loading Discord RPC setting:', error);
|
||||
}
|
||||
}
|
||||
|
||||
async function saveCloseLauncher() {
|
||||
try {
|
||||
if (window.electronAPI && window.electronAPI.saveCloseLauncher && closeLauncherCheck) {
|
||||
const enabled = closeLauncherCheck.checked;
|
||||
await window.electronAPI.saveCloseLauncher(enabled);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Error saving close launcher setting:', error);
|
||||
}
|
||||
}
|
||||
|
||||
async function loadCloseLauncher() {
|
||||
try {
|
||||
if (window.electronAPI && window.electronAPI.loadCloseLauncher) {
|
||||
const enabled = await window.electronAPI.loadCloseLauncher();
|
||||
if (closeLauncherCheck) {
|
||||
closeLauncherCheck.checked = enabled;
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Error loading close launcher setting:', error);
|
||||
}
|
||||
}
|
||||
|
||||
async function loadDiscordRPC() {
|
||||
try {
|
||||
if (window.electronAPI && window.electronAPI.loadDiscordRPC) {
|
||||
const enabled = await window.electronAPI.loadDiscordRPC();
|
||||
if (discordRPCCheck) {
|
||||
discordRPCCheck.checked = enabled;
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Error loading Discord RPC setting:', error);
|
||||
}
|
||||
}
|
||||
|
||||
async function saveCloseLauncher() {
|
||||
try {
|
||||
if (window.electronAPI && window.electronAPI.saveCloseLauncher && closeLauncherCheck) {
|
||||
const enabled = closeLauncherCheck.checked;
|
||||
await window.electronAPI.saveCloseLauncher(enabled);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Error saving close launcher setting:', error);
|
||||
}
|
||||
}
|
||||
|
||||
async function loadCloseLauncher() {
|
||||
try {
|
||||
if (window.electronAPI && window.electronAPI.loadCloseLauncher) {
|
||||
const enabled = await window.electronAPI.loadCloseLauncher();
|
||||
if (closeLauncherCheck) {
|
||||
closeLauncherCheck.checked = enabled;
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Error loading close launcher setting:', error);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
async function savePlayerName() {
|
||||
try {
|
||||
@@ -491,15 +499,16 @@ async function loadGpuPreference() {
|
||||
}
|
||||
}
|
||||
|
||||
async function loadAllSettings() {
|
||||
await loadCustomJavaPath();
|
||||
await loadPlayerName();
|
||||
await loadCurrentUuid();
|
||||
await loadDiscordRPC();
|
||||
await loadCloseLauncher();
|
||||
await loadGpuPreference();
|
||||
}
|
||||
|
||||
async function loadAllSettings() {
|
||||
await loadCustomJavaPath();
|
||||
await loadPlayerName();
|
||||
await loadCurrentUuid();
|
||||
await loadDiscordRPC();
|
||||
await loadCloseLauncher();
|
||||
await loadGpuPreference();
|
||||
await loadVersionBranch();
|
||||
}
|
||||
|
||||
|
||||
async function openGameLocation() {
|
||||
try {
|
||||
@@ -891,4 +900,177 @@ function showNotification(message, type = 'info') {
|
||||
}
|
||||
}, 300);
|
||||
}, 3000);
|
||||
}
|
||||
}// Append this to settings.js for branch management
|
||||
|
||||
// === Game Branch Management ===
|
||||
async function handleBranchChange(event) {
|
||||
const newBranch = event.target.value;
|
||||
const currentBranch = await loadVersionBranch();
|
||||
|
||||
if (newBranch === currentBranch) {
|
||||
return; // No change
|
||||
}
|
||||
|
||||
// Confirm branch change
|
||||
const branchName = window.i18n ?
|
||||
window.i18n.t(`settings.branch${newBranch === 'pre-release' ? 'PreRelease' : 'Release'}`) :
|
||||
newBranch;
|
||||
|
||||
const message = window.i18n ?
|
||||
window.i18n.t('settings.branchWarning') :
|
||||
'Changing branch will download and install a different game version';
|
||||
|
||||
showCustomConfirm(
|
||||
message,
|
||||
window.i18n ? window.i18n.t('settings.gameBranch') : 'Game Branch',
|
||||
async () => {
|
||||
await switchBranch(newBranch);
|
||||
},
|
||||
() => {
|
||||
// Cancel: revert radio selection
|
||||
loadVersionBranch().then(branch => {
|
||||
const radioToCheck = document.querySelector(`input[name="gameBranch"][value="${branch}"]`);
|
||||
if (radioToCheck) {
|
||||
radioToCheck.checked = true;
|
||||
}
|
||||
});
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
async function switchBranch(newBranch) {
|
||||
try {
|
||||
const switchingMsg = window.i18n ?
|
||||
window.i18n.t('settings.branchSwitching').replace('{branch}', newBranch) :
|
||||
`Switching to ${newBranch}...`;
|
||||
|
||||
showNotification(switchingMsg, 'info');
|
||||
|
||||
// Lock play button
|
||||
const playButton = document.getElementById('playButton');
|
||||
if (playButton) {
|
||||
playButton.disabled = true;
|
||||
playButton.classList.add('disabled');
|
||||
}
|
||||
|
||||
// Save new branch
|
||||
await window.electronAPI.saveVersionBranch(newBranch);
|
||||
|
||||
const switchedMsg = window.i18n ?
|
||||
window.i18n.t('settings.branchSwitched').replace('{branch}', newBranch) :
|
||||
`Switched to ${newBranch} successfully!`;
|
||||
|
||||
showNotification(switchedMsg, 'success');
|
||||
|
||||
// Suggest reinstalling
|
||||
setTimeout(() => {
|
||||
const branchLabel = newBranch === 'release' ?
|
||||
(window.i18n ? window.i18n.t('install.releaseVersion') : 'Release') :
|
||||
(window.i18n ? window.i18n.t('install.preReleaseVersion') : 'Pre-Release');
|
||||
|
||||
const confirmMsg = window.i18n ?
|
||||
window.i18n.t('settings.branchInstallConfirm').replace('{branch}', branchLabel) :
|
||||
`The game will be installed for the ${branchLabel} branch. Continue?`;
|
||||
|
||||
showCustomConfirm(
|
||||
confirmMsg,
|
||||
window.i18n ? window.i18n.t('settings.installRequired') : 'Installation Required',
|
||||
async () => {
|
||||
// Show progress and trigger game installation
|
||||
if (window.LauncherUI) {
|
||||
window.LauncherUI.showProgress();
|
||||
}
|
||||
|
||||
try {
|
||||
const playerName = await window.electronAPI.loadUsername();
|
||||
const result = await window.electronAPI.installGame(playerName || 'Player', '', '', newBranch);
|
||||
|
||||
if (result.success) {
|
||||
const successMsg = window.i18n ?
|
||||
window.i18n.t('progress.installationComplete') :
|
||||
'Installation completed successfully!';
|
||||
|
||||
showNotification(successMsg, 'success');
|
||||
|
||||
setTimeout(() => {
|
||||
if (window.LauncherUI) {
|
||||
window.LauncherUI.hideProgress();
|
||||
}
|
||||
|
||||
// Unlock play button
|
||||
const playButton = document.getElementById('playButton');
|
||||
if (playButton) {
|
||||
playButton.disabled = false;
|
||||
playButton.classList.remove('disabled');
|
||||
}
|
||||
}, 2000);
|
||||
} else {
|
||||
throw new Error(result.error || 'Installation failed');
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Installation error:', error);
|
||||
const errorMsg = window.i18n ?
|
||||
window.i18n.t('progress.installationFailed').replace('{error}', error.message) :
|
||||
`Installation failed: ${error.message}`;
|
||||
|
||||
showNotification(errorMsg, 'error');
|
||||
|
||||
if (window.LauncherUI) {
|
||||
window.LauncherUI.hideProgress();
|
||||
}
|
||||
|
||||
// Unlock play button
|
||||
const playButton = document.getElementById('playButton');
|
||||
if (playButton) {
|
||||
playButton.disabled = false;
|
||||
playButton.classList.remove('disabled');
|
||||
}
|
||||
}
|
||||
},
|
||||
() => {
|
||||
// Cancel - unlock play button
|
||||
const playButton = document.getElementById('playButton');
|
||||
if (playButton) {
|
||||
playButton.disabled = false;
|
||||
playButton.classList.remove('disabled');
|
||||
}
|
||||
},
|
||||
window.i18n ? window.i18n.t('common.install') : 'Install',
|
||||
window.i18n ? window.i18n.t('common.cancel') : 'Cancel'
|
||||
);
|
||||
}, 500);
|
||||
|
||||
} catch (error) {
|
||||
console.error('Error switching branch:', error);
|
||||
showNotification(`Failed to switch branch: ${error.message}`, 'error');
|
||||
|
||||
// Revert radio selection
|
||||
loadVersionBranch().then(branch => {
|
||||
const radioToCheck = document.querySelector(`input[name="gameBranch"][value="${branch}"]`);
|
||||
if (radioToCheck) {
|
||||
radioToCheck.checked = true;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
async function loadVersionBranch() {
|
||||
try {
|
||||
if (window.electronAPI && window.electronAPI.loadVersionBranch) {
|
||||
const branch = await window.electronAPI.loadVersionBranch();
|
||||
|
||||
// Update radio buttons
|
||||
if (gameBranchRadios) {
|
||||
gameBranchRadios.forEach(radio => {
|
||||
radio.checked = radio.value === branch;
|
||||
});
|
||||
}
|
||||
|
||||
return branch;
|
||||
}
|
||||
return 'release'; // Default
|
||||
} catch (error) {
|
||||
console.error('Error loading version branch:', error);
|
||||
return 'release';
|
||||
}
|
||||
}
|
||||
|
||||
45
GUI/js/ui.js
45
GUI/js/ui.js
@@ -501,6 +501,7 @@ function setupUI() {
|
||||
setupAnimations();
|
||||
setupFirstLaunchHandlers();
|
||||
loadLauncherVersion();
|
||||
checkGameInstallation();
|
||||
|
||||
document.body.focus();
|
||||
}
|
||||
@@ -520,6 +521,50 @@ async function loadLauncherVersion() {
|
||||
}
|
||||
}
|
||||
|
||||
// Check game installation status on startup
|
||||
async function checkGameInstallation() {
|
||||
try {
|
||||
console.log('Checking game installation status...');
|
||||
|
||||
// Check if game is installed
|
||||
const isInstalled = await window.electronAPI.isGameInstalled();
|
||||
|
||||
// Load version_client from config
|
||||
let versionClient = null;
|
||||
if (window.electronAPI.loadVersionClient) {
|
||||
versionClient = await window.electronAPI.loadVersionClient();
|
||||
}
|
||||
|
||||
console.log(`Game installed: ${isInstalled}, version_client: ${versionClient}`);
|
||||
|
||||
// If version_client is null and game is not installed, trigger installation
|
||||
if (versionClient === null && !isInstalled) {
|
||||
console.log('Game not installed and version_client is null, showing install page...');
|
||||
|
||||
// Show installation page
|
||||
const installPage = document.getElementById('install-page');
|
||||
const launcher = document.getElementById('launcher-container');
|
||||
const sidebar = document.querySelector('.sidebar');
|
||||
|
||||
if (installPage) {
|
||||
installPage.style.display = 'block';
|
||||
if (launcher) launcher.style.display = 'none';
|
||||
if (sidebar) sidebar.style.pointerEvents = 'none';
|
||||
|
||||
// Unlock play button since we're in install mode
|
||||
lockPlayButton(false);
|
||||
}
|
||||
} else {
|
||||
// Game is installed or version is set, unlock play button
|
||||
lockPlayButton(false);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Error checking game installation:', error);
|
||||
// Unlock on error to prevent permanent lock
|
||||
lockPlayButton(false);
|
||||
}
|
||||
}
|
||||
|
||||
window.LauncherUI = {
|
||||
showPage,
|
||||
setActiveNav,
|
||||
|
||||
Reference in New Issue
Block a user