-
Notifications
You must be signed in to change notification settings - Fork 68
/
Copy pathscene_dialog.go
112 lines (93 loc) · 2.72 KB
/
scene_dialog.go
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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
package menu
import (
"github.com/libretro/ludo/audio"
"github.com/libretro/ludo/input"
"github.com/libretro/ludo/libretro"
)
type sceneDialog struct {
entry
title, line1, line2 string
}
func buildYesNoDialog(title, line1, line2 string, callbackOK func()) Scene {
var list sceneDialog
list.label = "Confirm Dialog"
list.callbackOK = callbackOK
list.title = title
list.line1 = line1
list.line2 = line2
audio.PlayEffect(audio.Effects["notice"])
return &list
}
func (s *sceneDialog) Entry() *entry {
return &s.entry
}
func (s *sceneDialog) segueMount() {
}
func (s *sceneDialog) segueNext() {
}
func (s *sceneDialog) segueBack() {
}
func (s *sceneDialog) update(dt float32) {
// OK
if input.Released[0][libretro.DeviceIDJoypadA] == 1 {
audio.PlayEffect(audio.Effects["ok"])
menu.stack[len(menu.stack)-2].segueBack()
menu.stack = menu.stack[:len(menu.stack)-1]
s.callbackOK()
}
// Cancel
if input.Released[0][libretro.DeviceIDJoypadB] == 1 {
audio.PlayEffect(audio.Effects["cancel"])
menu.stack[len(menu.stack)-2].segueBack()
menu.stack = menu.stack[:len(menu.stack)-1]
}
}
func (s *sceneDialog) render() {
w, h := menu.GetFramebufferSize()
fw := float32(w)
fh := float32(h)
menu.DrawRect(0, 0, fw, fh, 0, black.Alpha(0.85))
var width float32 = 1000
var height float32 = 400
menu.DrawRect(
fw/2-width/2*menu.ratio,
fh/2-height/2*menu.ratio,
width*menu.ratio,
height*menu.ratio,
0.05,
white,
)
menu.Font.SetColor(orange)
lw1 := menu.Font.Width(0.7*menu.ratio, s.title)
menu.Font.Printf(fw/2-lw1/2, fh/2-120*menu.ratio+20*menu.ratio, 0.7*menu.ratio, s.title)
menu.Font.SetColor(black)
lw2 := menu.Font.Width(0.5*menu.ratio, s.line1)
menu.Font.Printf(fw/2-lw2/2, fh/2-30*menu.ratio+20*menu.ratio, 0.5*menu.ratio, s.line1)
lw3 := menu.Font.Width(0.5*menu.ratio, s.line2)
menu.Font.Printf(fw/2-lw3/2, fh/2+30*menu.ratio+20*menu.ratio, 0.5*menu.ratio, s.line2)
menu.Font.SetColor(darkGrey)
var margin float32 = 15
_, _, _, a, b, _, _, _, _, _ := hintIcons()
menu.DrawImage(
b,
fw/2-width/2*menu.ratio+margin*menu.ratio,
fh/2+height/2*menu.ratio-70*menu.ratio-margin*menu.ratio,
70*menu.ratio, 70*menu.ratio, 1.0, darkGrey)
menu.Font.Printf(
fw/2-width/2*menu.ratio+margin*menu.ratio+70*menu.ratio,
fh/2+height/2*menu.ratio-23*menu.ratio-margin*menu.ratio,
0.4*menu.ratio,
"NO")
menu.DrawImage(
a,
fw/2+width/2*menu.ratio-150*menu.ratio-margin*menu.ratio,
fh/2+height/2*menu.ratio-70*menu.ratio-margin*menu.ratio,
70*menu.ratio, 70*menu.ratio, 1.0, darkGrey)
menu.Font.Printf(
fw/2+width/2*menu.ratio-150*menu.ratio-margin*menu.ratio+70*menu.ratio,
fh/2+height/2*menu.ratio-23*menu.ratio-margin*menu.ratio,
0.4*menu.ratio,
"YES")
}
func (s *sceneDialog) drawHintBar() {
}