Wire the sliders into the config file
Not yet the game itself. That's still TODO.
This commit is contained in:
@@ -68,3 +68,36 @@ func (c *Config) Save() error {
|
|||||||
func (c *Config) DataFile(path string) string {
|
func (c *Config) DataFile(path string) string {
|
||||||
return filepath.Join(c.DataDir, path)
|
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
|
||||||
|
}
|
||||||
|
@@ -47,7 +47,7 @@ func (o *Ordoor) optionsDriver(main *ui.Driver) (*ui.Driver, error) {
|
|||||||
return nil, err
|
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{
|
v10Slider := map[int]int{
|
||||||
0: 0,
|
0: 0,
|
||||||
10: 9, 20: 18, 30: 27, 40: 36, 50: 45,
|
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.5", cfg.ShowGrid), &err)
|
||||||
try(options.SetValueBool("2.6", cfg.ShowPaths), &err)
|
try(options.SetValueBool("2.6", cfg.ShowPaths), &err)
|
||||||
try(options.SetValueBool("2.7", cfg.PointSaving), &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.SetValueBool("2.25", cfg.AutoCutLevel), &err)
|
||||||
|
try(options.SetValueInt("2.26", cfg.UnitSpeed), &err)
|
||||||
|
try(options.SetValueInt("2.27", cfg.AnimSpeed), &err)
|
||||||
|
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (o *Ordoor) optionsIntoConfig(options *ui.Driver) error {
|
func (o *Ordoor) optionsIntoConfig(options *ui.Driver) error {
|
||||||
cfg := &o.config.Options
|
cfg := &o.config.Options
|
||||||
|
var resIdx int // needs handling manually
|
||||||
var err error
|
var err error
|
||||||
|
|
||||||
try(options.ValueBool("2.1", &cfg.PlayMovies), &err)
|
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.5", &cfg.ShowGrid), &err)
|
||||||
try(options.ValueBool("2.6", &cfg.ShowPaths), &err)
|
try(options.ValueBool("2.6", &cfg.ShowPaths), &err)
|
||||||
try(options.ValueBool("2.7", &cfg.PointSaving), &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.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 {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cfg.SetResolutionIndex(resIdx)
|
||||||
|
|
||||||
if err := o.config.Save(); err != nil {
|
if err := o.config.Save(); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@@ -180,6 +180,12 @@ func (d *Driver) ValueInt(id string, into *int) error {
|
|||||||
return nil
|
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 {
|
func (d *Driver) Update(screenX, screenY int) error {
|
||||||
// This will be updated while processing hovers
|
// This will be updated while processing hovers
|
||||||
d.tooltip = ""
|
d.tooltip = ""
|
||||||
|
Reference in New Issue
Block a user