tins2021/settings.go
2021-08-11 08:03:02 +02:00

41 lines
639 B
Go

package tins2021
import (
"os"
"opslag.de/schobers/geom"
)
const settingsFileName = "settings.json"
type Settings struct {
Controls ControlsSettings
Window WindowSettings
}
func (s *Settings) Init() error {
err := LoadUserFileJSON(settingsFileName, s)
if os.IsNotExist(err) {
return nil
}
return err
}
func (s *Settings) Store() error {
return SaveUserFileJSON(settingsFileName, s)
}
type ControlsSettings struct {
Type string
MoveDownRight string
MoveDownLeft string
MoveUpLeft string
MoveUpRight string
}
type WindowSettings struct {
Location *geom.Point
Size *geom.Point
VSync *bool
}