diff --git a/internal/config/config.go b/internal/config/config.go index 69b3e69..5bd9dd7 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -68,3 +68,36 @@ func (c *Config) Save() error { func (c *Config) DataFile(path string) string { return filepath.Join(c.DataDir, path) } + +func (o *Options) ResolutionIndex() int { + if o.XRes == 640 && o.YRes == 480 { + return 1 + } + + if o.XRes == 800 && o.YRes == 600 { + return 2 + } + + if o.XRes == 1024 && o.YRes == 768 { + return 3 + } + + return 4 // Magic value +} + +func (o *Options) SetResolutionIndex(value int) { + switch value { + case 1: + o.XRes = 640 + o.YRes = 480 + case 2: + o.XRes = 800 + o.YRes = 600 + case 3: + o.XRes = 1024 + o.YRes = 768 + } + + // If the value isn't recognised, silently ignore the request to avoid + // overwriting options the resolution slider doesn't know about +} diff --git a/internal/ordoor/interfaces.go b/internal/ordoor/interfaces.go index c76b528..0182846 100644 --- a/internal/ordoor/interfaces.go +++ b/internal/ordoor/interfaces.go @@ -47,7 +47,7 @@ func (o *Ordoor) optionsDriver(main *ui.Driver) (*ui.Driver, error) { return nil, err } - h3Slider := map[int]int{1: 8, 2: 56, 3: 110} + h3Slider := map[int]int{1: 8, 2: 56, 3: 110, 4: 120} v10Slider := map[int]int{ 0: 0, 10: 9, 20: 18, 30: 27, 40: 36, 50: 45, @@ -112,13 +112,19 @@ func (o *Ordoor) configIntoOptions(options *ui.Driver) error { try(options.SetValueBool("2.5", cfg.ShowGrid), &err) try(options.SetValueBool("2.6", cfg.ShowPaths), &err) try(options.SetValueBool("2.7", cfg.PointSaving), &err) + try(options.SetValueInt("2.9", cfg.ResolutionIndex()), &err) + try(options.SetValueInt("2.10", cfg.MusicVolume), &err) + try(options.SetValueInt("2.11", cfg.SFXVolume), &err) try(options.SetValueBool("2.25", cfg.AutoCutLevel), &err) + try(options.SetValueInt("2.26", cfg.UnitSpeed), &err) + try(options.SetValueInt("2.27", cfg.AnimSpeed), &err) return err } func (o *Ordoor) optionsIntoConfig(options *ui.Driver) error { cfg := &o.config.Options + var resIdx int // needs handling manually var err error try(options.ValueBool("2.1", &cfg.PlayMovies), &err) @@ -128,12 +134,19 @@ func (o *Ordoor) optionsIntoConfig(options *ui.Driver) error { try(options.ValueBool("2.5", &cfg.ShowGrid), &err) try(options.ValueBool("2.6", &cfg.ShowPaths), &err) try(options.ValueBool("2.7", &cfg.PointSaving), &err) + try(options.ValueInt("2.9", &resIdx), &err) + try(options.ValueInt("2.10", &cfg.MusicVolume), &err) + try(options.ValueInt("2.11", &cfg.SFXVolume), &err) try(options.ValueBool("2.25", &cfg.AutoCutLevel), &err) + try(options.ValueInt("2.26", &cfg.UnitSpeed), &err) + try(options.ValueInt("2.27", &cfg.AnimSpeed), &err) if err != nil { return err } + cfg.SetResolutionIndex(resIdx) + if err := o.config.Save(); err != nil { return err } diff --git a/internal/ui/driver.go b/internal/ui/driver.go index f99adbc..cfce6d8 100644 --- a/internal/ui/driver.go +++ b/internal/ui/driver.go @@ -180,6 +180,12 @@ func (d *Driver) ValueInt(id string, into *int) error { return nil } +func (d *Driver) SetValueInt(id string, value int) error { + vStr := strconv.Itoa(value) + + return d.SetValue(id, vStr) +} + func (d *Driver) Update(screenX, screenY int) error { // This will be updated while processing hovers d.tooltip = ""