options

package
v0.0.0-...-9adee62 Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2024 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Map

type Map interface {
	Values() map[string]string  // Values returns all map values.
	SetValue(key, value string) // SetValue sets the map value for the given key.
	GetValue(key string) string // GetValue returns the map value for the given key.
}

type MemStore

type MemStore struct {
	Options      []string
	Descriptions []string
	// contains filtered or unexported fields
}

MemStore implements options.Options using slices and a map. MemStore is fully concurrency-safe and returns copies of all value when using any of the getters methods.

func NewMemStore

func NewMemStore(names []string, descs []string) *MemStore

func (*MemStore) Changed

func (s *MemStore) Changed() <-chan bool

Changed returns the stores changed channel.

func (*MemStore) Dec

func (s *MemStore) Dec()

func (*MemStore) Descs

func (s *MemStore) Descs() (descs []string)

func (*MemStore) Get

func (s *MemStore) Get() int

func (*MemStore) GetName

func (s *MemStore) GetName() string

func (*MemStore) GetValue

func (s *MemStore) GetValue(key string) string

func (*MemStore) Inc

func (s *MemStore) Inc()

func (*MemStore) Len

func (s *MemStore) Len() int

func (*MemStore) List

func (s *MemStore) List() (options []string)

func (*MemStore) Set

func (s *MemStore) Set(idx int)

func (*MemStore) SetValue

func (s *MemStore) SetValue(key, value string)

func (*MemStore) Values

func (s *MemStore) Values() map[string]string

type Options

type Options interface {
	Select
	Map

	Changed() <-chan bool
}

Options defines a map-slice interface for managing a single list of selectable options in combination with a key-value map for storing additional config values.

The game package uses this to access game options in a platform-independent way. A target platform can use this to implement platform specific options.

type Select

type Select interface {
	Set(idx int)     // Set sets the selected option according to the given options index.
	Get() int        // Get returns the current index of the selected option.
	Inc()            // Increase selected options index by 1
	Dec()            // Increase selected options index by 1
	Len() int        // Len returns the number of options.
	GetName() string // GetName returns the name/title of the current option.
	List() []string  // List returns all names/titles for all possible options.
	Descs() []string // Descs returns descriptions for all possible options.
}

Jump to

Keyboard shortcuts

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