-
Notifications
You must be signed in to change notification settings - Fork 18
/
gallery.ts
76 lines (70 loc) · 2.38 KB
/
gallery.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
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
// screen for selecting from samples
namespace microcode {
export class SamplesGallery extends CursorScene {
sampleButtons: Button[]
/* override */ shutdown() {
super.shutdown()
}
/* override */ startup() {
super.startup()
let x = -72,
y = -55
this.sampleButtons = []
let rowButtons: Button[] = []
samples(true)
.filter(sample => !!sample.icon)
.forEach(sample => {
const btn = new Button({
parent: null,
style: ButtonStyles.Transparent,
icon: sample.icon,
ariaId: sample.ariaId,
x: x + 16,
y: y + 16,
onClick: () => {
reportEvent("samples.open", {
name: sample.label,
})
this.app.saveBuffer(SAVESLOT_AUTO, sample.source)
this.app.popScene()
this.app.pushScene(new Editor(this.app))
},
})
this.sampleButtons.push(btn)
rowButtons.push(btn)
x += 38
if (x + 32 > 75) {
this.navigator.addButtons(rowButtons)
rowButtons = []
y += 38
x = -72
}
})
if (rowButtons.length > 0) this.navigator.addButtons(rowButtons)
}
protected moveCursor(dir: CursorDir) {
if (dir == CursorDir.Back) {
// go back to home screen
this.app.popScene()
this.app.pushScene(new Home(this.app))
} else {
super.moveCursor(dir)
}
}
/* override */ activate() {
super.activate()
this.color = 15
}
/* override */ draw() {
Screen.fillRect(
Screen.LEFT_EDGE,
Screen.TOP_EDGE,
Screen.WIDTH,
Screen.HEIGHT,
0xc
)
this.sampleButtons.forEach(s => s.draw())
super.draw()
}
}
}