add save-load GPU preference handler

This commit is contained in:
Fazri Gading
2026-01-19 00:08:40 +08:00
parent fffc730788
commit 8e9af9c768

24
main.js
View File

@@ -276,7 +276,7 @@ app.on('window-all-closed', () => {
}
});
ipcMain.handle('launch-game', async (event, playerName, javaPath, installPath) => {
ipcMain.handle('launch-game', async (event, playerName, javaPath, installPath, gpuPreference) => {
try {
const progressCallback = (message, percent, speed, downloaded, total) => {
if (mainWindow && !mainWindow.isDestroyed()) {
@@ -291,7 +291,7 @@ ipcMain.handle('launch-game', async (event, playerName, javaPath, installPath) =
}
};
const result = await launchGameWithVersionCheck(playerName, progressCallback, javaPath, installPath);
const result = await launchGameWithVersionCheck(playerName, progressCallback, javaPath, installPath, gpuPreference);
return result;
} catch (error) {
@@ -704,6 +704,26 @@ ipcMain.handle('get-update-info', async () => {
return updateManager.getUpdateInfo();
});
ipcMain.handle('get-gpu-info', () => {
try {
return app.getGPUInfo('complete');
} catch (error) {
console.error('Error getting GPU info:', error);
return {};
}
});
ipcMain.handle('save-gpu-preference', (event, gpuPreference) => {
const { saveGPUPreference } = require('./backend/launcher');
saveGPUPreference(gpuPreference);
return { success: true };
});
ipcMain.handle('load-gpu-preference', () => {
const { loadGPUPreference } = require('./backend/launcher');
return loadGPUPreference();
});
ipcMain.handle('window-close', () => {
if (mainWindow && !mainWindow.isDestroyed()) {
mainWindow.close();