-
Notifications
You must be signed in to change notification settings - Fork 0
/
TitleScreen.js
51 lines (47 loc) · 1.45 KB
/
TitleScreen.js
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
class TitleScreen {
constructor({progress}) {
this.progress = progress
}
getOptions(resolve) {
const saveFile = this.progress.getSaveFile()
return[
{
label: "New Game",
description: "Start a new pizza adventure!",
handler: () => {
this.close()
resolve()
}
},
//Maybe continue
saveFile ? {
label: "Continue Game",
description: "Resume your adventure",
handler: () => {
this.close()
resolve(saveFile)
}
} : null
].filter(v => v)
}
createElement() {
this.element = document.createElement("div")
this.element.classList.add("TitleScreen")
this.element.innerHTML = (`
<img class="TitleScreen_logo" src="./images/logo.png" alt="Pizza Legends" />
`)
}
close() {
this.keyboardMenu.end()
this.element.remove()
}
async init(container) {
return new Promise(resolve => {
this.createElement()
container.appendChild(this.element)
this.keyboardMenu = new KeyboardMenu()
this.keyboardMenu.init(this.element)
this.keyboardMenu.setOptions(this.getOptions(resolve))
})
}
}