Add parsing of AD1 files. Memorize window size and location.
This commit is contained in:
@@ -4,13 +4,23 @@ import log from "electron-log/main";
|
||||
import { join } from "path";
|
||||
import icon from "../../resources/icon.png?asset";
|
||||
import ErrorTypeCheck from "../util/errorTypeCheck";
|
||||
import "./store/store";
|
||||
import store from "./store/store";
|
||||
|
||||
log.initialize();
|
||||
function createWindow(): void {
|
||||
// Create the browser window.
|
||||
const { width, height, x, y } = store.get("app.windowBounds") as {
|
||||
width: number;
|
||||
height: number;
|
||||
x: number | undefined;
|
||||
y: number | undefined;
|
||||
};
|
||||
|
||||
const mainWindow = new BrowserWindow({
|
||||
width: 900,
|
||||
height: 670,
|
||||
width,
|
||||
height,
|
||||
x,
|
||||
y,
|
||||
show: false,
|
||||
autoHideMenuBar: true,
|
||||
...(process.platform === "linux" ? { icon } : {}),
|
||||
@@ -21,6 +31,17 @@ function createWindow(): void {
|
||||
},
|
||||
});
|
||||
|
||||
// Store window properties for later
|
||||
const storeWindowState = (): void => {
|
||||
const [width, height] = mainWindow.getSize();
|
||||
const [x, y] = mainWindow.getPosition();
|
||||
store.set("app.windowBounds", { width, height, x, y });
|
||||
};
|
||||
mainWindow.on("resized", storeWindowState);
|
||||
mainWindow.on("maximize", storeWindowState);
|
||||
mainWindow.on("unmaximize", storeWindowState);
|
||||
mainWindow.on("moved", storeWindowState);
|
||||
|
||||
mainWindow.on("ready-to-show", () => {
|
||||
mainWindow.show();
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user