-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.mjs
94 lines (69 loc) · 1.8 KB
/
main.mjs
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
88
89
90
91
import Automaton from './src/automaton/Automaton.mjs';
import Modal from './src/modals/modal.mjs';
import BottomPanel from './src/ui-controls/bottom-panel.mjs';
import RightPanel from './src/ui-controls/right-panel.mjs';
import { CGOL2dPieceData } from './examples/CGOL/entityData.mjs';
// Begin UI setup
const bottomPanel = new BottomPanel();
const rightPanel = new RightPanel();
// End UI Setup
const automaton = new Automaton();
// const welcomeModal = new Modal({
// htmlPath: 'src/modals/welcome-modal/welcome-modal.html',
// jsPath: 'src/modals/welcome-modal/welcome-modal.mjs',
// });
// welcomeModal.render();
// welcomeModal.open();
const MIN_UNIT_SIZE = 20;
const createBoardEvent = new CustomEvent(
'createBoard',
{
detail: {
name: 'Board 1',
width: 800,
height: 800,
minUnitSize: MIN_UNIT_SIZE,
is2dInfinite: true,
},
},
);
document.dispatchEvent(createBoardEvent);
// hack to get board id
const boardId = automaton.boardController.listBoards()[0].id;;
const createEntityTypeEvent = new CustomEvent(
'createEntityType',
{
detail: CGOL2dPieceData({ minUnitSize: MIN_UNIT_SIZE }),
},
);
document.dispatchEvent(createEntityTypeEvent);
const fillBoardWithEntityTypeEvent = new CustomEvent(
'fillBoardWithEntityType',
{
detail: {
entityTypeName: 'CGOL2dPiece',
boardId,
},
},
);
document.dispatchEvent(fillBoardWithEntityTypeEvent);
const setEntityClickActionEvent = new CustomEvent(
'setEntityClickAction',
{
detail: {
entityTypeName: 'CGOL2dPiece',
clickActionName: 'toggle',
},
},
);
document.dispatchEvent(setEntityClickActionEvent);
const createClockEvent = new CustomEvent(
'createClock',
{
detail: {
boardIds: [ boardId ],
tickFunc: automaton.updateBoardEntities.bind(automaton)
},
},
);
document.dispatchEvent(createClockEvent);