-
Notifications
You must be signed in to change notification settings - Fork 130
/
AppWindow.ts
48 lines (37 loc) · 1.3 KB
/
AppWindow.ts
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
import { OWWindow } from "@overwolf/overwolf-api-ts";
// A base class for the app's foreground windows.
// Sets the modal and drag behaviors, which are shared accross the desktop and in-game windows.
export class AppWindow {
protected currWindow: OWWindow;
protected mainWindow: OWWindow;
protected maximized: boolean = false;
constructor(windowName) {
this.mainWindow = new OWWindow('background');
this.currWindow = new OWWindow(windowName);
const closeButton = document.getElementById('closeButton');
const maximizeButton = document.getElementById('maximizeButton');
const minimizeButton = document.getElementById('minimizeButton');
const header = document.getElementById('header');
this.setDrag(header);
closeButton.addEventListener('click', () => {
this.mainWindow.close();
});
minimizeButton.addEventListener('click', () => {
this.currWindow.minimize();
});
maximizeButton.addEventListener('click', () => {
if (!this.maximized) {
this.currWindow.maximize();
} else {
this.currWindow.restore();
}
this.maximized = !this.maximized;
});
}
public async getWindowState() {
return await this.currWindow.getWindowState();
}
private async setDrag(elem) {
this.currWindow.dragMove(elem);
}
}