65 lines
2.0 KiB
JavaScript
Executable File
65 lines
2.0 KiB
JavaScript
Executable File
const { app, BrowserWindow, ipcMain } = require("electron");
|
|
const path = require("path");
|
|
const { Instance } = require("../core/LauncherCore");
|
|
const ejse = require("ejs-electron");
|
|
global.launcherConfig = require("../launcherconfig.json");
|
|
|
|
class LauncherApp {
|
|
constructor() {
|
|
this.init();
|
|
}
|
|
|
|
async init() {
|
|
await app.whenReady();
|
|
|
|
const win = this.mainWindow = new BrowserWindow({
|
|
width: 1280,
|
|
height: 720,
|
|
frame: false,
|
|
titleBarOverlay: true,
|
|
minHeight: 720,
|
|
minWidth: 1280,
|
|
webPreferences: {
|
|
nodeIntegration: true,
|
|
contextIsolation: true,
|
|
preload: path.join(__dirname, "launcher-preload.js")
|
|
}
|
|
});
|
|
|
|
win.loadFile(path.join(__dirname, "app/launcher.ejs"));
|
|
|
|
ipcMain.on("close", (e) => {
|
|
app.quit();
|
|
});
|
|
|
|
ipcMain.on("start-minecraft", async (e, modpack, version) => {
|
|
const instance = new Instance();
|
|
await instance.loadVersionManifest();
|
|
instance.authData.playerName = "Cyanoure";
|
|
instance.setWorkDirAtDefaultLocation(".chronika-plasma");
|
|
//instance.startVersion("1.20.1");
|
|
instance.startVersion(version);
|
|
|
|
instance.events.on("download-started", () => {
|
|
win.webContents.send("minecraft-download-started");
|
|
});
|
|
|
|
instance.events.on("download-process", (data) => {
|
|
win.webContents.send("minecraft-download-process", data);
|
|
});
|
|
|
|
instance.events.on("starting", () => {
|
|
win.webContents.send("minecraft-starting");
|
|
});
|
|
|
|
instance.events.on("started", process => {
|
|
win.webContents.send("minecraft-started");
|
|
process.on("exit", (code) => {
|
|
win.webContents.send("minecraft-exited", code);
|
|
});
|
|
});
|
|
});
|
|
}
|
|
}
|
|
|
|
module.exports = { LauncherApp } |