Clean up the options flow handlers a tiny bit

This commit is contained in:
2020-04-02 01:22:53 +01:00
parent aa43011e8d
commit df1f116b3d

View File

@@ -11,8 +11,8 @@ func (f *Flow) linkOptions() {
f.configureSlider(options, "2.10", v10Slider) // Music volume slider
f.configureSlider(options, "2.11", v10Slider) // SFX volume slider
f.onClick(options, "2.12", f.acceptOptions()) // OK button
f.onClick(options, "2.24", f.cancelOptions()) // Cancel button
f.onClick(options, "2.12", f.acceptOptions) // OK button
f.onClick(options, "2.24", f.cancelOptions) // Cancel button
f.configureSlider(options, "2.26", h9Slider) // Unit speed slider
f.configureSlider(options, "2.27", h9Slider) // Animation speed slider
@@ -21,31 +21,27 @@ func (f *Flow) linkOptions() {
// 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() {}) // Reset to defaults button
f.onClick(kbd, "3.4", func() {}) // TODO: Reset to defaults button
}
// FIXME: exiting is a bit OTT. Perhaps display "save failed"?
func (f *Flow) acceptOptions() func() {
return func() {
if err := f.optionsIntoConfig(); err != nil {
log.Printf("Saving options to config failed: %v", err)
f.exit = err
} else {
f.setDriverNow(main)
}
func (f *Flow) acceptOptions() {
if err := f.optionsIntoConfig(); err != nil {
log.Printf("Saving options to config failed: %v", err)
f.exit = err
} else {
f.setDriverNow(main)
}
}
// FIXME: again, exiting is OTT. We're just resetting the state of
// the interface to the values in config.
func (f *Flow) cancelOptions() func() {
return func() {
if err := f.configIntoOptions(); err != nil {
log.Printf("Saving options to config failed: %v", err)
f.exit = err
} else {
f.exit = f.returnToLastDriverNow(options)
}
func (f *Flow) cancelOptions() {
if err := f.configIntoOptions(); err != nil {
log.Printf("Saving options to config failed: %v", err)
f.exit = err
} else {
f.exit = f.returnToLastDriverNow(options)
}
}