tins2021/settings.go

41 lines
639 B
Go
Raw Normal View History

package tins2021
import (
"os"
"opslag.de/schobers/geom"
)
2021-08-11 06:03:02 +00:00
const settingsFileName = "settings.json"
type Settings struct {
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 ControlsSettings struct {
Type string
MoveDownRight string
MoveDownLeft string
MoveUpLeft string
MoveUpRight string
}
type WindowSettings struct {
Location *geom.Point
Size *geom.Point
VSync *bool
}