35 lines
524 B
Go
35 lines
524 B
Go
|
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
|
||
|
}
|