Increase dialogue modality, display keyboard dialogue
This commit is contained in:
@@ -38,6 +38,20 @@ var (
|
||||
}
|
||||
)
|
||||
|
||||
func (f *Flow) returnToLastDriver(from driverName) func() {
|
||||
return func() {
|
||||
to, ok := f.returns[from]
|
||||
if !ok {
|
||||
f.exit = fmt.Errorf("Couldn't work out where to return to from %v", from)
|
||||
return
|
||||
}
|
||||
|
||||
delete(f.returns, from)
|
||||
|
||||
f.setDriverNow(to)
|
||||
}
|
||||
}
|
||||
|
||||
// from is the child menu, to is the parent
|
||||
func (f *Flow) returnToLastDriverNow(from driverName) error {
|
||||
to, ok := f.returns[from]
|
||||
|
@@ -4,6 +4,7 @@ import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"log"
|
||||
"strings"
|
||||
|
||||
"github.com/hajimehoshi/ebiten"
|
||||
|
||||
@@ -233,6 +234,21 @@ func (f *Flow) playNextScenario(from driverName) func() {
|
||||
}
|
||||
}
|
||||
|
||||
func (f *Flow) showDialogue(driver driverName, id string) func() {
|
||||
return func() {
|
||||
f.drivers[driver].ShowDialogue(locator(driver, id))
|
||||
}
|
||||
}
|
||||
|
||||
func (f *Flow) hideDialogue(driver driverName) func() {
|
||||
return f.drivers[driver].HideDialogue
|
||||
}
|
||||
|
||||
func (f *Flow) setExit() {
|
||||
f.exit = ErrExit
|
||||
}
|
||||
|
||||
// TODO: convert all to locators
|
||||
func locator(d driverName, id string) string {
|
||||
return fmt.Sprintf("%v:%v", strings.ToLower(string(d)), id)
|
||||
}
|
||||
|
25
internal/flow/keyboard.go
Normal file
25
internal/flow/keyboard.go
Normal file
@@ -0,0 +1,25 @@
|
||||
package flow
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"log"
|
||||
)
|
||||
|
||||
func (f *Flow) linkKeyboard() {
|
||||
// Keyboard settings
|
||||
// TODO: implement keybindings save/load behaviour
|
||||
f.onClick(kbd, "3.1", f.returnToLastDriver(kbd)) // Done button
|
||||
f.onClick(kbd, "3.2", f.returnToLastDriver(kbd)) // Cancel button
|
||||
f.onClick(kbd, "3.4", func() {}) // TODO: Reset to defaults button
|
||||
|
||||
for i := 1; i <= 13; i++ {
|
||||
f.onClick(kbd, fmt.Sprintf("2.%v", i), f.captureKeybinding(i))
|
||||
}
|
||||
}
|
||||
|
||||
func (f *Flow) captureKeybinding(forLine int) func() {
|
||||
return func() {
|
||||
log.Printf("HELLO %v", forLine)
|
||||
f.showDialogue(kbd, "4")()
|
||||
}
|
||||
}
|
@@ -5,7 +5,7 @@ import (
|
||||
)
|
||||
|
||||
func (f *Flow) linkOptions() {
|
||||
f.onClick(options, "2.8", f.setDriver(kbd)) // Keyboard settings button
|
||||
f.onClick(options, "2.8", f.setReturningDriver(options, kbd)) // Keyboard settings button
|
||||
|
||||
f.configureSlider(options, "2.9", h3Slider) // Resolution slider
|
||||
f.configureSlider(options, "2.10", v10Slider) // Music volume slider
|
||||
@@ -17,11 +17,7 @@ func (f *Flow) linkOptions() {
|
||||
f.configureSlider(options, "2.26", h9Slider) // Unit speed slider
|
||||
f.configureSlider(options, "2.27", h9Slider) // Animation speed slider
|
||||
|
||||
// Keyboard settings
|
||||
// TODO: implement keybindings save/load behaviour
|
||||
f.onClick(kbd, "3.1", f.setDriver(options)) // Done button
|
||||
f.onClick(kbd, "3.2", f.setDriver(options)) // Cancel button
|
||||
f.onClick(kbd, "3.4", func() {}) // TODO: Reset to defaults button
|
||||
f.linkKeyboard()
|
||||
}
|
||||
|
||||
// FIXME: exiting is a bit OTT. Perhaps display "save failed"?
|
||||
|
Reference in New Issue
Block a user