-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.js
More file actions
87 lines (76 loc) · 2.6 KB
/
Copy pathmain.js
File metadata and controls
87 lines (76 loc) · 2.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
const { app, BrowserWindow, ipcMain, dialog, screen } = require('electron');
const path = require('path');
const remoteMain = require('@electron/remote/main');
remoteMain.initialize();
let startWindow;
let mainWindow;
function createStartWindow() {
const { width, height } = screen.getPrimaryDisplay().workAreaSize; // Maximale Bildschirmgröße ohne Taskleiste
startWindow = new BrowserWindow({
width: width,
height: height,
webPreferences: {
nodeIntegration: true,
contextIsolation: false
}
});
remoteMain.enable(startWindow.webContents);
startWindow.loadFile('start.html');
startWindow.maximize(); // Optional: Fenster sofort maximieren
}
function createMainWindow(config) {
const { width, height } = screen.getPrimaryDisplay().workAreaSize;
mainWindow = new BrowserWindow({
width: width,
height: height,
webPreferences: {
nodeIntegration: true,
contextIsolation: false
}
});
remoteMain.enable(mainWindow.webContents);
mainWindow.loadFile('index.html');
mainWindow.maximize(); // Optional: Fenster sofort maximieren
mainWindow.webContents.on('did-finish-load', () => {
mainWindow.webContents.send('load-workspace', config);
});
startWindow.close();
}
app.whenReady().then(() => {
createStartWindow();
});
app.on('window-all-closed', () => {
if (process.platform !== 'darwin') app.quit();
});
app.on('activate', () => {
if (BrowserWindow.getAllWindows().length === 0) createStartWindow();
});
ipcMain.on('select-texture', (event) => {
dialog.showOpenDialog({
title: "Textur auswählen",
filters: [{ name: 'Images', extensions: ['png'] }],
properties: ['openFile']
}).then(result => {
if (!result.canceled && result.filePaths.length > 0) {
event.reply('texture-selected', result.filePaths[0]);
}
}).catch(err => {
event.reply('texture-error', err.message);
});
});
ipcMain.on('select-workspace-file', (event) => {
dialog.showOpenDialog({
title: "Workspace-Datei laden",
filters: [{ name: 'JSON Files', extensions: ['json'] }],
properties: ['openFile']
}).then(result => {
if (!result.canceled && result.filePaths.length > 0) {
event.reply('workspace-file-selected', result.filePaths[0]);
}
}).catch(err => {
console.error(err);
});
});
ipcMain.on('open-main-window', (event, config) => {
createMainWindow(config);
});