tins2021/settings.go

48 lines
756 B
Go
Raw Permalink Normal View History

package tins2021
import (
"os"
"opslag.de/schobers/geom"
)
2021-08-11 06:03:02 +00:00
const settingsFileName = "settings.json"
2021-08-17 16:22:22 +00:00
type AudioSettings struct {
SoundVolume float64
MusicVolume float64
}
type ControlsSettings struct {
Type string
MoveDownRight string
MoveDownLeft string
MoveUpLeft string
MoveUpRight string
Virtual bool
2021-08-17 16:22:22 +00:00
}
type Settings struct {
2021-08-17 16:22:22 +00:00
Audio AudioSettings
Controls ControlsSettings
Window WindowSettings
}
func (s *Settings) Init() error {
2021-08-11 06:03:02 +00:00
err := LoadUserFileJSON(settingsFileName, s)
if os.IsNotExist(err) {
return nil
}
2021-08-11 06:03:02 +00:00
return err
}
func (s *Settings) Store() error {
2021-08-11 06:03:02 +00:00
return SaveUserFileJSON(settingsFileName, s)
}
type WindowSettings struct {
Location *geom.Point
Size *geom.Point
VSync *bool
}