tins2021/settings.go

42 lines
637 B
Go

package tins2021
import (
"os"
"opslag.de/schobers/geom"
"opslag.de/schobers/zntg"
)
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)
}
func (s *Settings) Store() error {
path, err := SettingsPath()
if err != nil {
return err
}
return zntg.EncodeJSON(path, s)
}
type WindowSettings struct {
Location *geom.Point
Size *geom.Point
VSync *bool
}