usercfg

package
v0.0.0-...-79996cc Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 9, 2023 License: GPL-3.0 Imports: 11 Imported by: 0

Documentation

Overview

Package usercfg has functions around the user's Game Settings.

Other places in the codebase to look for its related functionality:

  • pkg/windows/settings.go: the Settings Window is the UI owner of this feature, it adjusts the usercfg.Current struct and Saves the changes to disk.

Index

Constants

This section is empty.

Variables

View Source
var Current = Defaults()

Current loaded settings, good defaults by default.

Functions

func Filepath

func Filepath() string

Filepath returns the path to the settings file.

func Load

func Load() error

Load the settings from disk. The loaded settings will be available at usercfg.Current.

func MakeEntropy

func MakeEntropy() ([]byte, error)

MakeEntropy creates a random string one time that saves into the settings.json, used for checksum calculations for the user's savegame.

func Save

func Save() error

Save the settings to disk.

Types

type Settings

type Settings struct {
	// Initialized is set true the first time the settings are saved to
	// disk, so the game may decide some default settings for first-time
	// user experience, e.g. set horizontal toolbars for mobile.
	Initialized bool
	Entropy     []byte `json:"entropy"`

	// Configurable settings (pkg/windows/settings.go)
	HorizontalToolbars bool `json:",omitempty"`
	EnableFeatures     bool `json:",omitempty"`
	CrosshairSize      int  `json:",omitempty"`
	CrosshairColor     render.Color
	HideTouchHints     bool `json:",omitempty"`
	DisableAutosave    bool `json:",omitempty"`
	ControllerStyle    int

	// Secret boolprops from balance/boolprops.go
	ShowHiddenDoodads bool `json:",omitempty"`
	WriteLockOverride bool `json:",omitempty"`
	JSONIndent        bool `json:",omitempty"`
	EnableCheatsMenu  bool `json:",omitempty"`

	// Bookkeeping.
	UpdatedAt time.Time
}

Settings are the available game settings.

func Defaults

func Defaults() *Settings

Defaults returns sensible default user settings.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL