mirror of
https://github.com/amiayweb/Hytale-F2P.git
synced 2026-02-26 07:41:45 -03:00
fix hardcoded branch + pre-release/release issue
This commit is contained in:
@@ -168,6 +168,8 @@ function setupSettingsElements() {
|
||||
gpuPreferenceRadios = document.querySelectorAll('input[name="gpuPreference"]');
|
||||
gameBranchRadios = document.querySelectorAll('input[name="gameBranch"]');
|
||||
|
||||
console.log('[Settings] gameBranchRadios found:', gameBranchRadios.length);
|
||||
|
||||
|
||||
// UUID Management elements
|
||||
currentUuidDisplay = document.getElementById('currentUuid');
|
||||
@@ -541,7 +543,8 @@ document.addEventListener('DOMContentLoaded', initSettings);
|
||||
|
||||
window.SettingsAPI = {
|
||||
getCurrentJavaPath,
|
||||
getCurrentPlayerName
|
||||
getCurrentPlayerName,
|
||||
reloadBranch: loadVersionBranch
|
||||
};
|
||||
|
||||
async function loadCurrentUuid() {
|
||||
@@ -1078,11 +1081,13 @@ async function loadVersionBranch() {
|
||||
console.log('[Settings] Selected branch:', selectedBranch);
|
||||
|
||||
// Update radio buttons
|
||||
if (gameBranchRadios) {
|
||||
if (gameBranchRadios && gameBranchRadios.length > 0) {
|
||||
gameBranchRadios.forEach(radio => {
|
||||
radio.checked = radio.value === selectedBranch;
|
||||
console.log(`[Settings] Radio ${radio.value}: ${radio.checked ? 'checked' : 'unchecked'}`);
|
||||
});
|
||||
} else {
|
||||
console.warn('[Settings] gameBranchRadios not found or empty');
|
||||
}
|
||||
|
||||
return selectedBranch;
|
||||
|
||||
@@ -29,6 +29,15 @@ function showPage(pageId) {
|
||||
if (page.id === pageId) {
|
||||
page.classList.add('active');
|
||||
page.style.display = '';
|
||||
|
||||
// Reload settings when settings page becomes visible
|
||||
if (pageId === 'settings-page') {
|
||||
console.log('[UI] Settings page activated, reloading branch...');
|
||||
// Dynamically import and call loadVersionBranch from settings
|
||||
if (window.SettingsAPI && window.SettingsAPI.reloadBranch) {
|
||||
window.SettingsAPI.reloadBranch();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
page.classList.remove('active');
|
||||
page.style.display = 'none';
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const os = require('os');
|
||||
const { loadVersionBranch } = require('./config');
|
||||
|
||||
function getAppDir() {
|
||||
const home = os.homedir();
|
||||
@@ -48,8 +49,20 @@ function expandHome(inputPath) {
|
||||
const APP_DIR = DEFAULT_APP_DIR;
|
||||
const CACHE_DIR = path.join(APP_DIR, 'cache');
|
||||
const TOOLS_DIR = path.join(APP_DIR, 'butler');
|
||||
const GAME_DIR = path.join(APP_DIR, 'release', 'package', 'game', 'latest');
|
||||
const JRE_DIR = path.join(APP_DIR, 'release', 'package', 'jre', 'latest');
|
||||
|
||||
// Dynamic GAME_DIR and JRE_DIR based on version_branch from config
|
||||
function getGameDir() {
|
||||
const branch = loadVersionBranch();
|
||||
return path.join(APP_DIR, branch, 'package', 'game', 'latest');
|
||||
}
|
||||
|
||||
function getJreDir() {
|
||||
const branch = loadVersionBranch();
|
||||
return path.join(APP_DIR, branch, 'package', 'jre', 'latest');
|
||||
}
|
||||
|
||||
const GAME_DIR = getGameDir();
|
||||
const JRE_DIR = getJreDir();
|
||||
const PLAYER_ID_FILE = path.join(APP_DIR, 'player_id.json');
|
||||
|
||||
function getClientCandidates(gameLatest) {
|
||||
@@ -156,7 +169,8 @@ async function getModsPath(customInstallPath = null) {
|
||||
installPath = getAppDir();
|
||||
}
|
||||
|
||||
const gameLatest = path.join(installPath, 'release', 'package', 'game', 'latest');
|
||||
const branch = loadVersionBranch();
|
||||
const gameLatest = path.join(installPath, branch, 'package', 'game', 'latest');
|
||||
|
||||
const userDataPath = findUserDataPath(gameLatest);
|
||||
|
||||
@@ -195,7 +209,8 @@ function getProfilesDir(customInstallPath = null) {
|
||||
}
|
||||
if (!installPath) installPath = getAppDir();
|
||||
|
||||
const gameLatest = path.join(installPath, 'release', 'package', 'game', 'latest');
|
||||
const branch = loadVersionBranch();
|
||||
const gameLatest = path.join(installPath, branch, 'package', 'game', 'latest');
|
||||
const userDataPath = findUserDataPath(gameLatest);
|
||||
const profilesDir = path.join(userDataPath, 'Profiles');
|
||||
|
||||
@@ -219,6 +234,8 @@ module.exports = {
|
||||
TOOLS_DIR,
|
||||
GAME_DIR,
|
||||
JRE_DIR,
|
||||
getGameDir,
|
||||
getJreDir,
|
||||
PLAYER_ID_FILE,
|
||||
getClientCandidates,
|
||||
findClientPath,
|
||||
|
||||
@@ -446,7 +446,11 @@ function isGameInstalled(branchOverride = null) {
|
||||
}
|
||||
|
||||
async function installGame(playerName = 'Player', progressCallback, javaPathOverride, installPathOverride, branchOverride = null) {
|
||||
const branch = branchOverride || loadVersionBranch();
|
||||
console.log(`[InstallGame] branchOverride parameter received: ${branchOverride}`);
|
||||
const loadedBranch = loadVersionBranch();
|
||||
console.log(`[InstallGame] loadVersionBranch() returned: ${loadedBranch}`);
|
||||
const branch = branchOverride || loadedBranch;
|
||||
console.log(`[InstallGame] Final branch selected: ${branch}`);
|
||||
const customAppDir = getResolvedAppDir(installPathOverride);
|
||||
const customCacheDir = path.join(customAppDir, 'cache');
|
||||
const customToolsDir = path.join(customAppDir, 'butler');
|
||||
|
||||
12
main.js
12
main.js
@@ -392,7 +392,12 @@ ipcMain.handle('launch-game', async (event, playerName, javaPath, installPath, g
|
||||
|
||||
ipcMain.handle('install-game', async (event, playerName, javaPath, installPath, branch) => {
|
||||
try {
|
||||
console.log(`[IPC] install-game called with branch: ${branch || 'default'}`);
|
||||
console.log(`[IPC] install-game called with parameters:`);
|
||||
console.log(` - playerName: ${playerName}`);
|
||||
console.log(` - javaPath: ${javaPath}`);
|
||||
console.log(` - installPath: ${installPath}`);
|
||||
console.log(` - branch: ${branch}`);
|
||||
console.log(`[IPC] branch type: ${typeof branch}, value: ${JSON.stringify(branch)}`);
|
||||
|
||||
// Signal installation start
|
||||
if (mainWindow && !mainWindow.isDestroyed()) {
|
||||
@@ -747,8 +752,9 @@ ipcMain.handle('open-external', async (event, url) => {
|
||||
|
||||
ipcMain.handle('open-game-location', async () => {
|
||||
try {
|
||||
const { getResolvedAppDir } = require('./backend/launcher');
|
||||
const gameDir = path.join(getResolvedAppDir(), 'release', 'package', 'game');
|
||||
const { getResolvedAppDir, loadVersionBranch } = require('./backend/launcher');
|
||||
const branch = loadVersionBranch();
|
||||
const gameDir = path.join(getResolvedAppDir(), branch, 'package', 'game');
|
||||
|
||||
if (fs.existsSync(gameDir)) {
|
||||
await shell.openPath(gameDir);
|
||||
|
||||
@@ -2,7 +2,7 @@ const { contextBridge, ipcRenderer } = require('electron');
|
||||
|
||||
contextBridge.exposeInMainWorld('electronAPI', {
|
||||
launchGame: (playerName, javaPath, installPath, gpuPreference) => ipcRenderer.invoke('launch-game', playerName, javaPath, installPath, gpuPreference),
|
||||
installGame: (playerName, javaPath, installPath) => ipcRenderer.invoke('install-game', playerName, javaPath, installPath),
|
||||
installGame: (playerName, javaPath, installPath, branch) => ipcRenderer.invoke('install-game', playerName, javaPath, installPath, branch),
|
||||
closeWindow: () => ipcRenderer.invoke('window-close'),
|
||||
minimizeWindow: () => ipcRenderer.invoke('window-minimize'),
|
||||
maximizeWindow: () => ipcRenderer.invoke('window-maximize'),
|
||||
|
||||
Reference in New Issue
Block a user