tins2021/settings.go
Sander Schobers 19adf64c54 Added virtual controls.
Added missing mouse pointers where applicable.
2021-08-20 10:21:41 +02:00

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
}