mirror of
https://git.sanhost.net/sanasol/hytale-f2p
synced 2026-02-26 09:21:48 -03:00
Merge pull request #172 from Rahul-Sahani04/develop
feat: Add option to toggle hardware acceleration for launcher. Issue #170
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -20,3 +20,4 @@ backend/patcher/
|
||||
# macOS Specific
|
||||
.DS_Store
|
||||
*.zst.DS_Store
|
||||
bun.lock
|
||||
|
||||
@@ -127,17 +127,20 @@
|
||||
<label class="form-label" data-i18n="install.gameBranch">Game Version</label>
|
||||
<div class="radio-group">
|
||||
<label class="radio-label">
|
||||
<input type="radio" name="installBranch" value="release" class="custom-radio" checked>
|
||||
<input type="radio" name="installBranch" value="release" class="custom-radio"
|
||||
checked>
|
||||
<span class="radio-text">
|
||||
<i class="fas fa-check-circle mr-2"></i>
|
||||
<span data-i18n="install.releaseVersion">Release (Stable)</span>
|
||||
</span>
|
||||
</label>
|
||||
<label class="radio-label">
|
||||
<input type="radio" name="installBranch" value="pre-release" class="custom-radio">
|
||||
<input type="radio" name="installBranch" value="pre-release"
|
||||
class="custom-radio">
|
||||
<span class="radio-text">
|
||||
<i class="fas fa-flask mr-2"></i>
|
||||
<span data-i18n="install.preReleaseVersion">Pre-Release (Experimental)</span>
|
||||
<span data-i18n="install.preReleaseVersion">Pre-Release
|
||||
(Experimental)</span>
|
||||
</span>
|
||||
</label>
|
||||
</div>
|
||||
@@ -361,20 +364,27 @@
|
||||
|
||||
<div class="settings-option">
|
||||
<div class="settings-input-group">
|
||||
<label class="settings-input-label" data-i18n="settings.gameBranch">Game Branch</label>
|
||||
<label class="settings-input-label" data-i18n="settings.gameBranch">Game
|
||||
Branch</label>
|
||||
<div class="segmented-control">
|
||||
<input type="radio" id="branch-release" name="gameBranch" value="release" checked>
|
||||
<label for="branch-release" data-i18n="settings.branchRelease">Release</label>
|
||||
<input type="radio" id="branch-pre-release" name="gameBranch" value="pre-release">
|
||||
<label for="branch-pre-release" data-i18n="settings.branchPreRelease">Pre-Release</label>
|
||||
<input type="radio" id="branch-release" name="gameBranch"
|
||||
value="release" checked>
|
||||
<label for="branch-release"
|
||||
data-i18n="settings.branchRelease">Release</label>
|
||||
<input type="radio" id="branch-pre-release" name="gameBranch"
|
||||
value="pre-release">
|
||||
<label for="branch-pre-release"
|
||||
data-i18n="settings.branchPreRelease">Pre-Release</label>
|
||||
</div>
|
||||
<p class="settings-hint">
|
||||
<i class="fas fa-info-circle"></i>
|
||||
<span data-i18n="settings.branchHint">Switch between stable release and experimental pre-release versions</span>
|
||||
<span data-i18n="settings.branchHint">Switch between stable release and
|
||||
experimental pre-release versions</span>
|
||||
</p>
|
||||
<p class="settings-hint" style="color: #f39c12;">
|
||||
<i class="fas fa-exclamation-triangle"></i>
|
||||
<span data-i18n="settings.branchWarning">Changing branch will download and install a different game version</span>
|
||||
<span data-i18n="settings.branchWarning">Changing branch will download
|
||||
and install a different game version</span>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
@@ -383,8 +393,7 @@
|
||||
<label class="settings-input-label" data-i18n="settings.gpuPreference">GPU
|
||||
Preference</label>
|
||||
<div class="segmented-control">
|
||||
<input type="radio" id="gpu-auto" name="gpuPreference" value="auto"
|
||||
checked>
|
||||
<input type="radio" id="gpu-auto" name="gpuPreference" value="auto" checked>
|
||||
<label for="gpu-auto" data-i18n="settings.gpuAuto">Auto</label>
|
||||
<input type="radio" id="gpu-integrated" name="gpuPreference"
|
||||
value="integrated">
|
||||
@@ -462,8 +471,8 @@
|
||||
<div class="checkbox-content">
|
||||
<div class="checkbox-title" data-i18n="settings.enableRPC">Enable
|
||||
Discord Rich Presence</div>
|
||||
<div class="checkbox-description"
|
||||
data-i18n="settings.discordDescription">Show your launcher activity
|
||||
<div class="checkbox-description" data-i18n="settings.discordDescription">
|
||||
Show your launcher activity
|
||||
on Discord
|
||||
</div>
|
||||
</div>
|
||||
@@ -482,13 +491,28 @@
|
||||
<input type="checkbox" id="closeLauncherCheck" />
|
||||
<span class="checkmark"></span>
|
||||
<div class="checkbox-content">
|
||||
<div class="checkbox-title" data-i18n="settings.closeOnStart">Close Launcher on game start</div>
|
||||
<div class="checkbox-description" data-i18n="settings.closeOnStartDescription">
|
||||
<div class="checkbox-title" data-i18n="settings.closeOnStart">Close Launcher
|
||||
on game start</div>
|
||||
<div class="checkbox-description"
|
||||
data-i18n="settings.closeOnStartDescription">
|
||||
Automatically close the launcher after Hytale has launched
|
||||
</div>
|
||||
</div>
|
||||
</label>
|
||||
</div>
|
||||
<div class="settings-option">
|
||||
<label class="settings-checkbox">
|
||||
<input type="checkbox" id="launcherHwAccelCheck" />
|
||||
<span class="checkmark"></span>
|
||||
<div class="checkbox-content">
|
||||
<div class="checkbox-title" data-i18n="settings.hwAccel">Launcher Hardware
|
||||
Acceleration</div>
|
||||
<div class="checkbox-description" data-i18n="settings.hwAccelDescription">
|
||||
Enable hardware acceleration for the launcher UI (Requires restart)
|
||||
</div>
|
||||
</div>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -541,8 +565,8 @@
|
||||
|
||||
<div class="settings-option">
|
||||
<div class="settings-input-group">
|
||||
<label class="settings-input-label"
|
||||
data-i18n="settings.selectLanguage">Select Language</label>
|
||||
<label class="settings-input-label" data-i18n="settings.selectLanguage">Select
|
||||
Language</label>
|
||||
<select id="languageSelect" class="settings-input">
|
||||
<!-- Options populated by i18n.js -->
|
||||
</select>
|
||||
|
||||
@@ -6,6 +6,7 @@ let browseJavaBtn;
|
||||
let settingsPlayerName;
|
||||
let discordRPCCheck;
|
||||
let closeLauncherCheck;
|
||||
let launcherHwAccelCheck;
|
||||
let gpuPreferenceRadios;
|
||||
let gameBranchRadios;
|
||||
|
||||
@@ -165,6 +166,7 @@ function setupSettingsElements() {
|
||||
settingsPlayerName = document.getElementById('settingsPlayerName');
|
||||
discordRPCCheck = document.getElementById('discordRPCCheck');
|
||||
closeLauncherCheck = document.getElementById('closeLauncherCheck');
|
||||
launcherHwAccelCheck = document.getElementById('launcherHwAccelCheck');
|
||||
gpuPreferenceRadios = document.querySelectorAll('input[name="gpuPreference"]');
|
||||
gameBranchRadios = document.querySelectorAll('input[name="gameBranch"]');
|
||||
|
||||
@@ -206,6 +208,10 @@ function setupSettingsElements() {
|
||||
closeLauncherCheck.addEventListener('change', saveCloseLauncher);
|
||||
}
|
||||
|
||||
if (launcherHwAccelCheck) {
|
||||
launcherHwAccelCheck.addEventListener('change', saveLauncherHwAccel);
|
||||
}
|
||||
|
||||
|
||||
// UUID event listeners
|
||||
if (copyUuidBtn) {
|
||||
@@ -391,6 +397,35 @@ async function loadCloseLauncher() {
|
||||
}
|
||||
}
|
||||
|
||||
async function saveLauncherHwAccel() {
|
||||
try {
|
||||
if (window.electronAPI && window.electronAPI.saveLauncherHardwareAcceleration && launcherHwAccelCheck) {
|
||||
const enabled = launcherHwAccelCheck.checked;
|
||||
await window.electronAPI.saveLauncherHardwareAcceleration(enabled);
|
||||
|
||||
const msg = window.i18n ? window.i18n.t('notifications.hwAccelSaved') : 'Setting saved. Please restart the launcher to apply changes.';
|
||||
showNotification(msg, 'success');
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Error saving hardware acceleration setting:', error);
|
||||
const msg = window.i18n ? window.i18n.t('notifications.hwAccelSaveFailed') : 'Failed to save setting';
|
||||
showNotification(msg, 'error');
|
||||
}
|
||||
}
|
||||
|
||||
async function loadLauncherHwAccel() {
|
||||
try {
|
||||
if (window.electronAPI && window.electronAPI.loadLauncherHardwareAcceleration) {
|
||||
const enabled = await window.electronAPI.loadLauncherHardwareAcceleration();
|
||||
if (launcherHwAccelCheck) {
|
||||
launcherHwAccelCheck.checked = enabled;
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Error loading hardware acceleration setting:', error);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
async function savePlayerName() {
|
||||
try {
|
||||
@@ -507,6 +542,7 @@ async function loadAllSettings() {
|
||||
await loadCurrentUuid();
|
||||
await loadDiscordRPC();
|
||||
await loadCloseLauncher();
|
||||
await loadLauncherHwAccel();
|
||||
await loadGpuPreference();
|
||||
await loadVersionBranch();
|
||||
}
|
||||
|
||||
@@ -131,6 +131,8 @@
|
||||
"closeLauncher": "Launcher Behavior",
|
||||
"closeOnStart": "Close Launcher on game start",
|
||||
"closeOnStartDescription": "Automatically close the launcher after Hytale has launched",
|
||||
"hwAccel": "Hardware Acceleration",
|
||||
"hwAccelDescription": "Enable hardware acceleration for the launcher",
|
||||
"gameBranch": "Game Branch",
|
||||
"branchRelease": "Release",
|
||||
"branchPreRelease": "Pre-Release",
|
||||
@@ -207,7 +209,9 @@
|
||||
"modsDownloadFailed": "Failed to download mod: {error}",
|
||||
"modsToggleFailed": "Failed to toggle mod: {error}",
|
||||
"modsDeleteFailed": "Failed to delete mod: {error}",
|
||||
"modsModNotFound": "Mod information not found"
|
||||
"modsModNotFound": "Mod information not found",
|
||||
"hwAccelSaved": "Hardware acceleration setting saved",
|
||||
"hwAccelSaveFailed": "Failed to save hardware acceleration setting"
|
||||
},
|
||||
"confirm": {
|
||||
"defaultTitle": "Confirm action",
|
||||
|
||||
@@ -166,6 +166,15 @@ function loadCloseLauncherOnStart() {
|
||||
return config.closeLauncherOnStart !== undefined ? config.closeLauncherOnStart : false;
|
||||
}
|
||||
|
||||
function saveLauncherHardwareAcceleration(enabled) {
|
||||
saveConfig({ launcherHardwareAcceleration: !!enabled });
|
||||
}
|
||||
|
||||
function loadLauncherHardwareAcceleration() {
|
||||
const config = loadConfig();
|
||||
return config.launcherHardwareAcceleration !== undefined ? config.launcherHardwareAcceleration : true;
|
||||
}
|
||||
|
||||
function saveModsToConfig(mods) {
|
||||
try {
|
||||
const config = loadConfig();
|
||||
@@ -369,6 +378,11 @@ module.exports = {
|
||||
// Close Launcher export
|
||||
saveCloseLauncherOnStart,
|
||||
loadCloseLauncherOnStart,
|
||||
|
||||
// Hardware Acceleration functions
|
||||
saveLauncherHardwareAcceleration,
|
||||
loadLauncherHardwareAcceleration,
|
||||
|
||||
// Version Management exports
|
||||
saveVersionClient,
|
||||
loadVersionClient,
|
||||
|
||||
@@ -19,6 +19,12 @@ const {
|
||||
loadLanguage,
|
||||
saveCloseLauncherOnStart,
|
||||
loadCloseLauncherOnStart,
|
||||
|
||||
// Hardware Acceleration
|
||||
saveLauncherHardwareAcceleration,
|
||||
loadLauncherHardwareAcceleration,
|
||||
|
||||
|
||||
saveModsToConfig,
|
||||
loadModsFromConfig,
|
||||
getUuidForUser,
|
||||
@@ -134,6 +140,10 @@ module.exports = {
|
||||
saveCloseLauncherOnStart,
|
||||
loadCloseLauncherOnStart,
|
||||
|
||||
// Hardware Acceleration functions
|
||||
saveLauncherHardwareAcceleration,
|
||||
loadLauncherHardwareAcceleration,
|
||||
|
||||
// GPU Preference functions
|
||||
saveGpuPreference,
|
||||
loadGpuPreference,
|
||||
|
||||
22
main.js
22
main.js
@@ -3,9 +3,20 @@ require('dotenv').config({ path: path.join(__dirname, '.env') });
|
||||
const { app, BrowserWindow, ipcMain, dialog, shell } = require('electron');
|
||||
const { autoUpdater } = require('electron-updater');
|
||||
const fs = require('fs');
|
||||
const { launchGame, launchGameWithVersionCheck, installGame, saveUsername, loadUsername, saveChatUsername, loadChatUsername, saveChatColor, loadChatColor, saveJavaPath, loadJavaPath, saveInstallPath, loadInstallPath, saveDiscordRPC, loadDiscordRPC, saveLanguage, loadLanguage, saveCloseLauncherOnStart, loadCloseLauncherOnStart, isGameInstalled, uninstallGame, repairGame, getHytaleNews, handleFirstLaunchCheck, proposeGameUpdate, markAsLaunched } = require('./backend/launcher');
|
||||
const { launchGame, launchGameWithVersionCheck, installGame, saveUsername, loadUsername, saveChatUsername, loadChatUsername, saveChatColor, loadChatColor, saveJavaPath, loadJavaPath, saveInstallPath, loadInstallPath, saveDiscordRPC, loadDiscordRPC, saveLanguage, loadLanguage, saveCloseLauncherOnStart, loadCloseLauncherOnStart, saveLauncherHardwareAcceleration, loadLauncherHardwareAcceleration, isGameInstalled, uninstallGame, repairGame, getHytaleNews, handleFirstLaunchCheck, proposeGameUpdate, markAsLaunched } = require('./backend/launcher');
|
||||
const { retryPWRDownload } = require('./backend/managers/gameManager');
|
||||
|
||||
// Handle Hardware Acceleration
|
||||
try {
|
||||
const hwEnabled = loadLauncherHardwareAcceleration();
|
||||
if (!hwEnabled) {
|
||||
console.log('Hardware acceleration disabled by user setting');
|
||||
app.disableHardwareAcceleration();
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Failed to load hardware acceleration setting:', error);
|
||||
}
|
||||
|
||||
const logger = require('./backend/logger');
|
||||
const profileManager = require('./backend/managers/profileManager');
|
||||
|
||||
@@ -625,6 +636,15 @@ ipcMain.handle('load-close-launcher', () => {
|
||||
return loadCloseLauncherOnStart();
|
||||
});
|
||||
|
||||
ipcMain.handle('save-launcher-hw-accel', (event, enabled) => {
|
||||
saveLauncherHardwareAcceleration(enabled);
|
||||
return { success: true };
|
||||
});
|
||||
|
||||
ipcMain.handle('load-launcher-hw-accel', () => {
|
||||
return loadLauncherHardwareAcceleration();
|
||||
});
|
||||
|
||||
ipcMain.handle('select-install-path', async () => {
|
||||
|
||||
const result = await dialog.showOpenDialog(mainWindow, {
|
||||
|
||||
@@ -23,6 +23,11 @@ contextBridge.exposeInMainWorld('electronAPI', {
|
||||
loadLanguage: () => ipcRenderer.invoke('load-language'),
|
||||
saveCloseLauncher: (enabled) => ipcRenderer.invoke('save-close-launcher', enabled),
|
||||
loadCloseLauncher: () => ipcRenderer.invoke('load-close-launcher'),
|
||||
|
||||
// Harwadre Acceleration
|
||||
saveLauncherHardwareAcceleration: (enabled) => ipcRenderer.invoke('save-launcher-hw-accel', enabled),
|
||||
loadLauncherHardwareAcceleration: () => ipcRenderer.invoke('load-launcher-hw-accel'),
|
||||
|
||||
selectInstallPath: () => ipcRenderer.invoke('select-install-path'),
|
||||
browseJavaPath: () => ipcRenderer.invoke('browse-java-path'),
|
||||
isGameInstalled: () => ipcRenderer.invoke('is-game-installed'),
|
||||
|
||||
Reference in New Issue
Block a user