mirror of
https://gitea.shironeko-all.duckdns.org/shironeko/Hytale-F2P-2.git
synced 2026-02-26 02:31:46 -03:00
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:
33
main.js
33
main.js
@@ -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();
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user