Wire the sliders into the config file

Not yet the game itself. That's still TODO.
This commit is contained in:
2020-03-24 23:11:37 +00:00
parent 20ad9ae6f8
commit d376d9850c
3 changed files with 53 additions and 1 deletions

View File

@@ -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
}