v2.4.5: Add multi-instance setting for mod developers

Allow running multiple game clients simultaneously via a new
"Allow multiple game instances" toggle in Settings. When enabled,
skips the Electron single-instance lock and the pre-launch process
kill, so existing game instances stay alive.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
sanasol
2026-02-27 21:52:13 +01:00
parent e1a3f919a2
commit 3abdd10cab
19 changed files with 103 additions and 6 deletions

View File

@@ -592,6 +592,18 @@
</div> </div>
</label> </label>
</div> </div>
<div class="settings-option">
<label class="settings-checkbox">
<input type="checkbox" id="allowMultiInstanceCheck" />
<span class="checkmark"></span>
<div class="checkbox-content">
<div class="checkbox-title" data-i18n="settings.allowMultiInstance">Allow multiple game instances</div>
<div class="checkbox-description" data-i18n="settings.allowMultiInstanceDescription">
Allow running multiple game clients at the same time (useful for mod development)
</div>
</div>
</label>
</div>
<div class="settings-option"> <div class="settings-option">
<label class="settings-checkbox"> <label class="settings-checkbox">
<input type="checkbox" id="launcherHwAccelCheck" /> <input type="checkbox" id="launcherHwAccelCheck" />

View File

@@ -6,6 +6,7 @@ let browseJavaBtn;
let settingsPlayerName; let settingsPlayerName;
let discordRPCCheck; let discordRPCCheck;
let closeLauncherCheck; let closeLauncherCheck;
let allowMultiInstanceCheck;
let launcherHwAccelCheck; let launcherHwAccelCheck;
let gpuPreferenceRadios; let gpuPreferenceRadios;
let gameBranchRadios; let gameBranchRadios;
@@ -171,6 +172,7 @@ function setupSettingsElements() {
settingsPlayerName = document.getElementById('settingsPlayerName'); settingsPlayerName = document.getElementById('settingsPlayerName');
discordRPCCheck = document.getElementById('discordRPCCheck'); discordRPCCheck = document.getElementById('discordRPCCheck');
closeLauncherCheck = document.getElementById('closeLauncherCheck'); closeLauncherCheck = document.getElementById('closeLauncherCheck');
allowMultiInstanceCheck = document.getElementById('allowMultiInstanceCheck');
launcherHwAccelCheck = document.getElementById('launcherHwAccelCheck'); launcherHwAccelCheck = document.getElementById('launcherHwAccelCheck');
gpuPreferenceRadios = document.querySelectorAll('input[name="gpuPreference"]'); gpuPreferenceRadios = document.querySelectorAll('input[name="gpuPreference"]');
gameBranchRadios = document.querySelectorAll('input[name="gameBranch"]'); gameBranchRadios = document.querySelectorAll('input[name="gameBranch"]');
@@ -218,6 +220,10 @@ function setupSettingsElements() {
closeLauncherCheck.addEventListener('change', saveCloseLauncher); closeLauncherCheck.addEventListener('change', saveCloseLauncher);
} }
if (allowMultiInstanceCheck) {
allowMultiInstanceCheck.addEventListener('change', saveAllowMultiInstance);
}
if (launcherHwAccelCheck) { if (launcherHwAccelCheck) {
launcherHwAccelCheck.addEventListener('change', saveLauncherHwAccel); launcherHwAccelCheck.addEventListener('change', saveLauncherHwAccel);
} }
@@ -415,6 +421,30 @@ async function loadCloseLauncher() {
} }
} }
async function saveAllowMultiInstance() {
try {
if (window.electronAPI && window.electronAPI.saveAllowMultiInstance && allowMultiInstanceCheck) {
const enabled = allowMultiInstanceCheck.checked;
await window.electronAPI.saveAllowMultiInstance(enabled);
}
} catch (error) {
console.error('Error saving multi-instance setting:', error);
}
}
async function loadAllowMultiInstance() {
try {
if (window.electronAPI && window.electronAPI.loadAllowMultiInstance) {
const enabled = await window.electronAPI.loadAllowMultiInstance();
if (allowMultiInstanceCheck) {
allowMultiInstanceCheck.checked = enabled;
}
}
} catch (error) {
console.error('Error loading multi-instance setting:', error);
}
}
async function saveLauncherHwAccel() { async function saveLauncherHwAccel() {
try { try {
if (window.electronAPI && window.electronAPI.saveLauncherHardwareAcceleration && launcherHwAccelCheck) { if (window.electronAPI && window.electronAPI.saveLauncherHardwareAcceleration && launcherHwAccelCheck) {
@@ -587,6 +617,7 @@ async function loadAllSettings() {
await loadCurrentUuid(); await loadCurrentUuid();
await loadDiscordRPC(); await loadDiscordRPC();
await loadCloseLauncher(); await loadCloseLauncher();
await loadAllowMultiInstance();
await loadLauncherHwAccel(); await loadLauncherHwAccel();
await loadGpuPreference(); await loadGpuPreference();
await loadVersionBranch(); await loadVersionBranch();

View File

@@ -140,6 +140,8 @@
"closeLauncher": "سلوك المشغل", "closeLauncher": "سلوك المشغل",
"closeOnStart": "إغلاق المشغل عند بدء اللعبة", "closeOnStart": "إغلاق المشغل عند بدء اللعبة",
"closeOnStartDescription": "إغلاق المشغل تلقائياً بعد تشغيل Hytale", "closeOnStartDescription": "إغلاق المشغل تلقائياً بعد تشغيل Hytale",
"allowMultiInstance": "Allow multiple game instances",
"allowMultiInstanceDescription": "Allow running multiple game clients at the same time (useful for mod development)",
"hwAccel": "تسريع الأجهزة (Hardware Acceleration)", "hwAccel": "تسريع الأجهزة (Hardware Acceleration)",
"hwAccelDescription": "تفعيل تسريع الأجهزة للمشغل", "hwAccelDescription": "تفعيل تسريع الأجهزة للمشغل",
"gameBranch": "فرع اللعبة", "gameBranch": "فرع اللعبة",

View File

@@ -140,6 +140,8 @@
"closeLauncher": "Launcher-Verhalten", "closeLauncher": "Launcher-Verhalten",
"closeOnStart": "Launcher beim Spielstart schließen", "closeOnStart": "Launcher beim Spielstart schließen",
"closeOnStartDescription": "Schließe den Launcher automatisch, nachdem Hytale gestartet wurde", "closeOnStartDescription": "Schließe den Launcher automatisch, nachdem Hytale gestartet wurde",
"allowMultiInstance": "Allow multiple game instances",
"allowMultiInstanceDescription": "Allow running multiple game clients at the same time (useful for mod development)",
"hwAccel": "Hardware-Beschleunigung", "hwAccel": "Hardware-Beschleunigung",
"hwAccelDescription": "Hardware-Beschleunigung für den Launcher aktivieren", "hwAccelDescription": "Hardware-Beschleunigung für den Launcher aktivieren",
"gameBranch": "Spiel-Branch", "gameBranch": "Spiel-Branch",

View File

@@ -140,6 +140,8 @@
"closeLauncher": "Launcher Behavior", "closeLauncher": "Launcher Behavior",
"closeOnStart": "Close Launcher on game start", "closeOnStart": "Close Launcher on game start",
"closeOnStartDescription": "Automatically close the launcher after Hytale has launched", "closeOnStartDescription": "Automatically close the launcher after Hytale has launched",
"allowMultiInstance": "Allow multiple game instances",
"allowMultiInstanceDescription": "Allow running multiple game clients at the same time (useful for mod development)",
"hwAccel": "Hardware Acceleration", "hwAccel": "Hardware Acceleration",
"hwAccelDescription": "Enable hardware acceleration for the launcher", "hwAccelDescription": "Enable hardware acceleration for the launcher",
"gameBranch": "Game Branch", "gameBranch": "Game Branch",

View File

@@ -140,6 +140,8 @@
"closeLauncher": "Comportamiento del Launcher", "closeLauncher": "Comportamiento del Launcher",
"closeOnStart": "Cerrar Launcher al iniciar el juego", "closeOnStart": "Cerrar Launcher al iniciar el juego",
"closeOnStartDescription": "Cierra automáticamente el launcher después de que Hytale se haya iniciado", "closeOnStartDescription": "Cierra automáticamente el launcher después de que Hytale se haya iniciado",
"allowMultiInstance": "Allow multiple game instances",
"allowMultiInstanceDescription": "Allow running multiple game clients at the same time (useful for mod development)",
"hwAccel": "Aceleración por Hardware", "hwAccel": "Aceleración por Hardware",
"hwAccelDescription": "Habilitar aceleración por hardware para el launcher", "hwAccelDescription": "Habilitar aceleración por hardware para el launcher",
"gameBranch": "Rama del Juego", "gameBranch": "Rama del Juego",

View File

@@ -140,6 +140,8 @@
"closeLauncher": "Comportement du Launcher", "closeLauncher": "Comportement du Launcher",
"closeOnStart": "Fermer le Launcher au démarrage du jeu", "closeOnStart": "Fermer le Launcher au démarrage du jeu",
"closeOnStartDescription": "Fermer automatiquement le launcher après le lancement d'Hytale", "closeOnStartDescription": "Fermer automatiquement le launcher après le lancement d'Hytale",
"allowMultiInstance": "Allow multiple game instances",
"allowMultiInstanceDescription": "Allow running multiple game clients at the same time (useful for mod development)",
"hwAccel": "Accélération Matérielle", "hwAccel": "Accélération Matérielle",
"hwAccelDescription": "Activer l'accélération matérielle pour le launcher", "hwAccelDescription": "Activer l'accélération matérielle pour le launcher",
"gameBranch": "Branche du Jeu", "gameBranch": "Branche du Jeu",

View File

@@ -140,6 +140,8 @@
"closeLauncher": "Perilaku Launcher", "closeLauncher": "Perilaku Launcher",
"closeOnStart": "Tutup launcher saat game dimulai", "closeOnStart": "Tutup launcher saat game dimulai",
"closeOnStartDescription": "Tutup launcher secara otomatis setelah Hytale diluncurkan", "closeOnStartDescription": "Tutup launcher secara otomatis setelah Hytale diluncurkan",
"allowMultiInstance": "Allow multiple game instances",
"allowMultiInstanceDescription": "Allow running multiple game clients at the same time (useful for mod development)",
"hwAccel": "Akselerasi Perangkat Keras", "hwAccel": "Akselerasi Perangkat Keras",
"hwAccelDescription": "Aktifkan akselerasi perangkat keras untuk launcher`", "hwAccelDescription": "Aktifkan akselerasi perangkat keras untuk launcher`",
"gameBranch": "Cabang Game", "gameBranch": "Cabang Game",

View File

@@ -140,6 +140,8 @@
"closeLauncher": "Zachowanie Launchera", "closeLauncher": "Zachowanie Launchera",
"closeOnStart": "Zamknij Launcher przy starcie gry", "closeOnStart": "Zamknij Launcher przy starcie gry",
"closeOnStartDescription": "Automatycznie zamknij launcher po uruchomieniu Hytale", "closeOnStartDescription": "Automatycznie zamknij launcher po uruchomieniu Hytale",
"allowMultiInstance": "Allow multiple game instances",
"allowMultiInstanceDescription": "Allow running multiple game clients at the same time (useful for mod development)",
"hwAccel": "Przyspieszenie Sprzętowe", "hwAccel": "Przyspieszenie Sprzętowe",
"hwAccelDescription": "Włącz przyspieszenie sprzętowe dla launchera", "hwAccelDescription": "Włącz przyspieszenie sprzętowe dla launchera",
"gameBranch": "Gałąź Gry", "gameBranch": "Gałąź Gry",

View File

@@ -140,6 +140,8 @@
"closeLauncher": "Comportamento do Lançador", "closeLauncher": "Comportamento do Lançador",
"closeOnStart": "Fechar Lançador ao iniciar o jogo", "closeOnStart": "Fechar Lançador ao iniciar o jogo",
"closeOnStartDescription": "Fechar automaticamente o lançador após o Hytale ter sido iniciado", "closeOnStartDescription": "Fechar automaticamente o lançador após o Hytale ter sido iniciado",
"allowMultiInstance": "Allow multiple game instances",
"allowMultiInstanceDescription": "Allow running multiple game clients at the same time (useful for mod development)",
"hwAccel": "Aceleração de Hardware", "hwAccel": "Aceleração de Hardware",
"hwAccelDescription": "Ativar aceleração de hardware para o lançador", "hwAccelDescription": "Ativar aceleração de hardware para o lançador",
"gameBranch": "Versão do Jogo", "gameBranch": "Versão do Jogo",

View File

@@ -140,6 +140,8 @@
"closeLauncher": "Поведение лаунчера", "closeLauncher": "Поведение лаунчера",
"closeOnStart": "Закрыть лаунчер при старте игры", "closeOnStart": "Закрыть лаунчер при старте игры",
"closeOnStartDescription": "Автоматически закрыть лаунчер после запуска Hytale", "closeOnStartDescription": "Автоматически закрыть лаунчер после запуска Hytale",
"allowMultiInstance": "Несколько копий игры",
"allowMultiInstanceDescription": "Разрешить запуск нескольких клиентов одновременно (полезно для разработки модов)",
"hwAccel": "Аппаратное ускорение", "hwAccel": "Аппаратное ускорение",
"hwAccelDescription": "Включить аппаратное ускорение для лаунчера", "hwAccelDescription": "Включить аппаратное ускорение для лаунчера",
"gameBranch": "Ветка игры", "gameBranch": "Ветка игры",

View File

@@ -140,6 +140,8 @@
"closeLauncher": "Launcher-beteende", "closeLauncher": "Launcher-beteende",
"closeOnStart": "Stäng launcher vid spelstart", "closeOnStart": "Stäng launcher vid spelstart",
"closeOnStartDescription": "Stäng automatiskt launcher efter att Hytale har startats", "closeOnStartDescription": "Stäng automatiskt launcher efter att Hytale har startats",
"allowMultiInstance": "Allow multiple game instances",
"allowMultiInstanceDescription": "Allow running multiple game clients at the same time (useful for mod development)",
"hwAccel": "Hårdvaruacceleration", "hwAccel": "Hårdvaruacceleration",
"hwAccelDescription": "Aktivera hårdvaruacceleration för launchern", "hwAccelDescription": "Aktivera hårdvaruacceleration för launchern",
"gameBranch": "Spelgren", "gameBranch": "Spelgren",

View File

@@ -140,6 +140,8 @@
"closeLauncher": "Başlatıcı Davranışı", "closeLauncher": "Başlatıcı Davranışı",
"closeOnStart": "Oyun başlatıldığında Başlatıcıyı Kapat", "closeOnStart": "Oyun başlatıldığında Başlatıcıyı Kapat",
"closeOnStartDescription": "Hytale başlatıldıktan sonra başlatıcıyı otomatik olarak kapatın", "closeOnStartDescription": "Hytale başlatıldıktan sonra başlatıcıyı otomatik olarak kapatın",
"allowMultiInstance": "Allow multiple game instances",
"allowMultiInstanceDescription": "Allow running multiple game clients at the same time (useful for mod development)",
"hwAccel": "Donanım Hızlandırma", "hwAccel": "Donanım Hızlandırma",
"hwAccelDescription": "Başlatıcı için donanım hızlandırmasını etkinleştir", "hwAccelDescription": "Başlatıcı için donanım hızlandırmasını etkinleştir",
"gameBranch": "Oyun Dalı", "gameBranch": "Oyun Dalı",

View File

@@ -708,6 +708,15 @@ function loadLauncherHardwareAcceleration() {
return config.launcherHardwareAcceleration !== undefined ? config.launcherHardwareAcceleration : true; return config.launcherHardwareAcceleration !== undefined ? config.launcherHardwareAcceleration : true;
} }
function saveAllowMultiInstance(enabled) {
saveConfig({ allowMultiInstance: !!enabled });
}
function loadAllowMultiInstance() {
const config = loadConfig();
return config.allowMultiInstance !== undefined ? config.allowMultiInstance : false;
}
// ============================================================================= // =============================================================================
// MODS MANAGEMENT // MODS MANAGEMENT
// ============================================================================= // =============================================================================
@@ -1105,6 +1114,8 @@ module.exports = {
loadCloseLauncherOnStart, loadCloseLauncherOnStart,
saveLauncherHardwareAcceleration, saveLauncherHardwareAcceleration,
loadLauncherHardwareAcceleration, loadLauncherHardwareAcceleration,
saveAllowMultiInstance,
loadAllowMultiInstance,
// Mods // Mods
saveModsToConfig, saveModsToConfig,

View File

@@ -20,6 +20,8 @@ const {
saveLauncherHardwareAcceleration, saveLauncherHardwareAcceleration,
loadLauncherHardwareAcceleration, loadLauncherHardwareAcceleration,
saveAllowMultiInstance,
loadAllowMultiInstance,
loadConfig, loadConfig,
saveConfig, saveConfig,
@@ -151,6 +153,10 @@ module.exports = {
saveLauncherHardwareAcceleration, saveLauncherHardwareAcceleration,
loadLauncherHardwareAcceleration, loadLauncherHardwareAcceleration,
// Multi-instance functions
saveAllowMultiInstance,
loadAllowMultiInstance,
// Config functions // Config functions
loadConfig, loadConfig,
saveConfig, saveConfig,

View File

@@ -30,6 +30,7 @@ const { syncModsForCurrentProfile } = require('./modManager');
const { getUserDataPath } = require('../utils/userDataMigration'); const { getUserDataPath } = require('../utils/userDataMigration');
const { syncServerList } = require('../utils/serverListSync'); const { syncServerList } = require('../utils/serverListSync');
const { killGameProcesses } = require('./gameManager'); const { killGameProcesses } = require('./gameManager');
const { loadAllowMultiInstance } = require('../core/config');
// Client patcher for custom auth server (sanasol.ws) // Client patcher for custom auth server (sanasol.ws)
let clientPatcher = null; let clientPatcher = null;
@@ -464,8 +465,10 @@ async function launchGame(playerNameOverride = null, progressCallback, javaPathO
} }
// Kill any stalled game processes from a previous launch to prevent file locks // Kill any stalled game processes from a previous launch to prevent file locks
// and "game already running" issues // and "game already running" issues (skip if multi-instance mode is enabled)
if (!loadAllowMultiInstance()) {
await killGameProcesses(); await killGameProcesses();
}
// Remove AOT cache: generated by official Hytale JRE, incompatible with F2P JRE. // Remove AOT cache: generated by official Hytale JRE, incompatible with F2P JRE.
// Client adds -XX:AOTCache when this file exists, causing classloading failures. // Client adds -XX:AOTCache when this file exists, causing classloading failures.

16
main.js
View File

@@ -3,7 +3,7 @@ require('dotenv').config({ path: path.join(__dirname, '.env') });
const { app, BrowserWindow, ipcMain, dialog, shell } = require('electron'); const { app, BrowserWindow, ipcMain, dialog, shell } = require('electron');
const { autoUpdater } = require('electron-updater'); const { autoUpdater } = require('electron-updater');
const fs = require('fs'); const fs = require('fs');
const { launchGame, launchGameWithVersionCheck, installGame, saveUsername, loadUsername, saveJavaPath, loadJavaPath, saveInstallPath, loadInstallPath, saveDiscordRPC, loadDiscordRPC, saveLanguage, loadLanguage, saveCloseLauncherOnStart, loadCloseLauncherOnStart, saveLauncherHardwareAcceleration, loadLauncherHardwareAcceleration, isGameInstalled, uninstallGame, repairGame, getHytaleNews, handleFirstLaunchCheck, proposeGameUpdate, markAsLaunched, loadConfig, saveConfig, checkLaunchReady } = require('./backend/launcher'); const { launchGame, launchGameWithVersionCheck, installGame, saveUsername, loadUsername, saveJavaPath, loadJavaPath, saveInstallPath, loadInstallPath, saveDiscordRPC, loadDiscordRPC, saveLanguage, loadLanguage, saveCloseLauncherOnStart, loadCloseLauncherOnStart, saveLauncherHardwareAcceleration, loadLauncherHardwareAcceleration, saveAllowMultiInstance, loadAllowMultiInstance, isGameInstalled, uninstallGame, repairGame, getHytaleNews, handleFirstLaunchCheck, proposeGameUpdate, markAsLaunched, loadConfig, saveConfig, checkLaunchReady } = require('./backend/launcher');
const { retryPWRDownload } = require('./backend/managers/gameManager'); const { retryPWRDownload } = require('./backend/managers/gameManager');
const { migrateUserDataToCentralized } = require('./backend/utils/userDataMigration'); const { migrateUserDataToCentralized } = require('./backend/utils/userDataMigration');
@@ -23,8 +23,9 @@ const profileManager = require('./backend/managers/profileManager');
logger.interceptConsole(); logger.interceptConsole();
// Single instance lock // Single instance lock (skip if multi-instance mode is enabled)
const gotTheLock = app.requestSingleInstanceLock(); const multiInstanceEnabled = loadAllowMultiInstance();
const gotTheLock = multiInstanceEnabled || app.requestSingleInstanceLock();
if (!gotTheLock) { if (!gotTheLock) {
console.log('Another instance is already running. Quitting...'); console.log('Another instance is already running. Quitting...');
@@ -740,6 +741,15 @@ ipcMain.handle('load-close-launcher', () => {
return loadCloseLauncherOnStart(); return loadCloseLauncherOnStart();
}); });
ipcMain.handle('save-allow-multi-instance', (event, enabled) => {
saveAllowMultiInstance(enabled);
return { success: true };
});
ipcMain.handle('load-allow-multi-instance', () => {
return loadAllowMultiInstance();
});
ipcMain.handle('save-launcher-hw-accel', (event, enabled) => { ipcMain.handle('save-launcher-hw-accel', (event, enabled) => {
saveLauncherHardwareAcceleration(enabled); saveLauncherHardwareAcceleration(enabled);
return { success: true }; return { success: true };

View File

@@ -1,6 +1,6 @@
{ {
"name": "hytale-f2p-launcher", "name": "hytale-f2p-launcher",
"version": "2.4.4", "version": "2.4.5",
"description": "A modern, cross-platform launcher for Hytale with automatic updates and multi-client support", "description": "A modern, cross-platform launcher for Hytale with automatic updates and multi-client support",
"homepage": "https://git.sanhost.net/sanasol/hytale-f2p", "homepage": "https://git.sanhost.net/sanasol/hytale-f2p",
"main": "main.js", "main": "main.js",

View File

@@ -20,6 +20,8 @@ contextBridge.exposeInMainWorld('electronAPI', {
loadLanguage: () => ipcRenderer.invoke('load-language'), loadLanguage: () => ipcRenderer.invoke('load-language'),
saveCloseLauncher: (enabled) => ipcRenderer.invoke('save-close-launcher', enabled), saveCloseLauncher: (enabled) => ipcRenderer.invoke('save-close-launcher', enabled),
loadCloseLauncher: () => ipcRenderer.invoke('load-close-launcher'), loadCloseLauncher: () => ipcRenderer.invoke('load-close-launcher'),
saveAllowMultiInstance: (enabled) => ipcRenderer.invoke('save-allow-multi-instance', enabled),
loadAllowMultiInstance: () => ipcRenderer.invoke('load-allow-multi-instance'),
loadConfig: () => ipcRenderer.invoke('load-config'), loadConfig: () => ipcRenderer.invoke('load-config'),
saveConfig: (configUpdate) => ipcRenderer.invoke('save-config', configUpdate), saveConfig: (configUpdate) => ipcRenderer.invoke('save-config', configUpdate),