Add Java path configuration and input handling

- Introduced a new input field for Java path in the launcher UI.
- Updated the main process to handle saving and loading of the Java path.
- Enhanced game launch functionality to accept a Java path parameter.
- Added Java detection logic to find the Java executable on the system.
- Created a .gitignore file to exclude build artifacts and dependencies.
This commit is contained in:
chasem-dev
2026-01-14 10:11:01 -05:00
parent b90eeb344b
commit 6873e2e4bf
6 changed files with 458 additions and 123 deletions

33
main.js
View File

@@ -1,6 +1,6 @@
const { app, BrowserWindow, ipcMain } = require('electron');
const path = require('path');
const { launchGame, saveUsername, loadUsername } = require('./backend/launcher');
const { launchGame, saveUsername, loadUsername, saveJavaPath, loadJavaPath } = require('./backend/launcher');
let mainWindow;
@@ -61,8 +61,8 @@ app.on('window-all-closed', () => {
}
});
ipcMain.handle('launch-game', async (event, playerName) => {
try {
ipcMain.handle('launch-game', async (event, playerName, javaPath) => {
try {
const progressCallback = (message, percent, speed, downloaded, total) => {
if (mainWindow && !mainWindow.isDestroyed()) {
const data = {
@@ -76,7 +76,7 @@ ipcMain.handle('launch-game', async (event, playerName) => {
}
};
await launchGame(playerName, progressCallback);
await launchGame(playerName, progressCallback, javaPath);
return { success: true };
} catch (error) {
@@ -94,11 +94,20 @@ ipcMain.handle('window-minimize', () => {
if (mainWindow) mainWindow.minimize();
});
ipcMain.handle('save-username', (event, username) => {
saveUsername(username);
return { success: true };
});
ipcMain.handle('load-username', () => {
return loadUsername();
});
ipcMain.handle('save-username', (event, username) => {
saveUsername(username);
return { success: true };
});
ipcMain.handle('load-username', () => {
return loadUsername();
});
ipcMain.handle('save-java-path', (event, javaPath) => {
saveJavaPath(javaPath);
return { success: true };
});
ipcMain.handle('load-java-path', () => {
return loadJavaPath();
});