48 lines
756 B
Go
48 lines
756 B
Go
package tins2021
|
|
|
|
import (
|
|
"os"
|
|
|
|
"opslag.de/schobers/geom"
|
|
)
|
|
|
|
const settingsFileName = "settings.json"
|
|
|
|
type AudioSettings struct {
|
|
SoundVolume float64
|
|
MusicVolume float64
|
|
}
|
|
|
|
type ControlsSettings struct {
|
|
Type string
|
|
MoveDownRight string
|
|
MoveDownLeft string
|
|
MoveUpLeft string
|
|
MoveUpRight string
|
|
Virtual bool
|
|
}
|
|
|
|
type Settings struct {
|
|
Audio AudioSettings
|
|
Controls ControlsSettings
|
|
Window WindowSettings
|
|
}
|
|
|
|
func (s *Settings) Init() error {
|
|
err := LoadUserFileJSON(settingsFileName, s)
|
|
if os.IsNotExist(err) {
|
|
return nil
|
|
}
|
|
return err
|
|
}
|
|
|
|
func (s *Settings) Store() error {
|
|
return SaveUserFileJSON(settingsFileName, s)
|
|
}
|
|
|
|
type WindowSettings struct {
|
|
Location *geom.Point
|
|
Size *geom.Point
|
|
VSync *bool
|
|
}
|