tins2020/settings.go

42 lines
637 B
Go
Raw Permalink Normal View History

2020-05-08 16:38:26 +00:00
package tins2020
import (
"os"
"opslag.de/schobers/geom"
"opslag.de/schobers/zntg"
)
2020-05-08 16:38:26 +00:00
type Settings struct {
Window WindowSettings
}
func SettingsPath() (string, error) {
return UserFile("settings.json")
}
func (s *Settings) Init() error {
path, err := SettingsPath()
if err != nil {
return err
}
if _, err := os.Stat(path); os.IsNotExist(err) {
return nil
}
return zntg.DecodeJSON(path, s)
2020-05-08 16:38:26 +00:00
}
func (s *Settings) Store() error {
path, err := SettingsPath()
if err != nil {
return err
}
return zntg.EncodeJSON(path, s)
2020-05-08 16:38:26 +00:00
}
type WindowSettings struct {
Location *geom.Point
Size *geom.Point
2020-05-10 23:20:23 +00:00
VSync *bool
2020-05-08 16:38:26 +00:00
}