tins2020/settings.go

36 lines
541 B
Go
Raw Normal View History

2020-05-08 16:38:26 +00:00
package tins2020
import "os"
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 DecodeJSON(path, s)
}
func (s *Settings) Store() error {
path, err := SettingsPath()
if err != nil {
return err
}
return EncodeJSON(path, s)
}
type WindowSettings struct {
Location *Point
2020-05-09 12:02:00 +00:00
Size *Point
2020-05-08 16:38:26 +00:00
}