hadean-old/src/qt/index.ts

96 lines
1.9 KiB
TypeScript
Raw Normal View History

2021-07-23 00:12:02 -04:00
import {
QMainWindow, WidgetEventTypes
} from '@nodegui/nodegui';
import { APPLICATION_NAME } from '../Constants.js';
2021-07-25 13:57:47 -04:00
import { ProcessManager } from '../ProcessManager.js';
2021-07-23 00:12:02 -04:00
import { LoadingView } from './LoadingView.js';
2021-07-25 13:57:47 -04:00
import { RequestReloadPopup } from './RequestReloadPopup.js';
2021-07-23 00:12:02 -04:00
import { View } from './View.js';
export { GameView } from './GameView.js';
export { Popup } from './Popup.js';
export const win = new QMainWindow();
win.setFixedSize(800, 600);
win.setWindowTitle(APPLICATION_NAME);
2021-07-26 00:18:21 -04:00
// win.setStyleSheet(`
// #root {
// background-color: black;
// height: '100%';
// }
// QPushButton {
// background: #333333;
// }
// QPushButton:pressed {
// background: cyan;
// color: black;
// }
// * {
// font-family: 'MxPlus IBM VGA 8x16';
// font-size: 16px;
// }
// QTabWidget {
// border: 1px solid white;
// }
// QTabWidget::pane {
// background: black;
// border: none;
// border-radius: 0px;
// }
// QTabBar::tab {
// background: black;
// color: cyan;
// padding: 4px 12px;
// }
// QTabBar::tab:selected {
// background: cyan;
// color: black;
// }
// `);
2021-07-23 00:12:02 -04:00
win.show();
(global as any).win = win;
win.addEventListener(WidgetEventTypes.Paint, _ => _);
win.addEventListener('customContextMenuRequested', console.log)
win.addEventListener('objectNameChanged', console.log)
win.addEventListener('windowIconChanged', console.log)
win.addEventListener('windowTitleChanged', console.log)
setView(new LoadingView());
export function start() {
}
export function stop() {
win.close();
}
export function setView(view: View) {
view.addComponents();
}
export function setTitle(title: string) {
}
export function update() {
}
export function isStarted() {
2021-07-26 00:18:21 -04:00
return true;
2021-07-23 00:12:02 -04:00
return win.isVisible();
}
2021-07-25 13:57:47 -04:00
ProcessManager.on('reload', () => {
RequestReloadPopup.show();
//
2021-07-26 00:18:21 -04:00
});
2021-07-25 13:57:47 -04:00
2021-07-23 00:12:02 -04:00
// HACK this is bullshit, :)
function f() {
win.repaint();
win.update();
setTimeout(f, 100);
}
f();