Documentation
¶
Index ¶
- Constants
- func NewButton(bt *theme.ButtonTheme, font *font.Face, text string, c *Controller, s UISignal) *widget.Button
- func NewButtonCluster() *widget.Container
- func NewLabel(lt *theme.LabelTheme, font *font.Face, text string) *widget.Label
- func NewLabeledDisplay(lt *theme.LabelTheme, font *font.Face, labelText string) (*widget.Container, *widget.Label)
- func NewTextInput(tit *theme.TextInputTheme, font *font.Face, placeholder, text string, ...) *widget.TextInput
- type Controller
- func (c *Controller) ClearLMBPointer()
- func (c *Controller) Emit() *UIResponse
- func (c *Controller) GetRules() string
- func (c *Controller) GetSignal() UISignal
- func (c *Controller) IsLMBDownOn(w *widget.Widget) bool
- func (c *Controller) SetLMBDownOn(w *widget.Widget)
- func (c *Controller) SetRules(rules string)
- func (c *Controller) SetSignal(s UISignal)
- type UI
- type UIResponse
- type UISignal
Constants ¶
Variables ¶
This section is empty.
Functions ¶
func NewButton ¶
func NewButton(bt *theme.ButtonTheme, font *font.Face, text string, c *Controller, s UISignal) *widget.Button
Returns the new widget.Button given font, text to display, Controller and signal corresponding with the Button.
func NewButtonCluster ¶
Returns a pointer to the container designed to hold buttons that serve similar functions.
func NewLabeledDisplay ¶
func NewLabeledDisplay(lt *theme.LabelTheme, font *font.Face, labelText string) (*widget.Container, *widget.Label)
Creates a special kind of label. It consists of 2 widget.Label instances. One of them serves as a title, denoting a type of information displayed and another is holding value that can be changed. It is used to provide insight to game variables such as current generation number, current speed or zoom level. This function returns a container holding both labels and the label serving as a value holder. Accepts the title text.
func NewTextInput ¶
func NewTextInput(tit *theme.TextInputTheme, font *font.Face, placeholder, text string, c *Controller, s UISignal) *widget.TextInput
Returns new widget.TextInput. Accepts font, placeholder (text displayed when empty), text to display, Controller and UISignal associated with the TextInput.
Types ¶
type Controller ¶
type Controller struct {
// contains filtered or unexported fields
}
Controller for the UI.
func NewController ¶
func NewController(rules string) *Controller
Creates a new Controller structure.
func (*Controller) ClearLMBPointer ¶
func (c *Controller) ClearLMBPointer()
Sets c.lmbDownOn to nil.
func (*Controller) Emit ¶
func (c *Controller) Emit() *UIResponse
Emits the current UI state outwards in form of UIResponse.
func (*Controller) GetRules ¶
func (c *Controller) GetRules() string
func (*Controller) GetSignal ¶
func (c *Controller) GetSignal() UISignal
func (*Controller) IsLMBDownOn ¶
func (c *Controller) IsLMBDownOn(w *widget.Widget) bool
Returns true if w and c.lmbDownOn point to the same widget.
func (*Controller) SetLMBDownOn ¶
func (c *Controller) SetLMBDownOn(w *widget.Widget)
Stores the pointer to w in c.lmbDownOn.
func (*Controller) SetRules ¶
func (c *Controller) SetRules(rules string)
func (*Controller) SetSignal ¶
func (c *Controller) SetSignal(s UISignal)
type UI ¶
type UI struct {
// contains filtered or unexported fields
}
Top structure of User Interface.
func (*UI) SetRules ¶
Sets the contents of the ui.rules. If user specifies incorrect rules, this method is called to revert to the previous ones.
func (*UI) Update ¶
func (ui *UI) Update() *UIResponse
Updates the UI. Returns UIResponse if widget was interacted with.
func (*UI) UpdateGenValue ¶
Sets the generation label text to new value.
func (*UI) UpdateSpeedValue ¶
Sets the current speed label text to new value.
func (*UI) UpdateZoomValue ¶
Sets the current zoom label text to new value.
type UIResponse ¶
type UIResponse struct {
// Current rules read from the TextInput
Rules string
// Signal passed since last Controller.Emit call
Signal UISignal
}
Represents the state of the Controller. It is emitted outwards on Controller.Emit call.
type UISignal ¶
type UISignal uint8
Signal received by Controller. Each signal corresponds with specific widget and allows the Game to determine in what way its state should be modified.
const ( // No signal is currently stored (UI was not interacted with) NONE UISignal = iota // Toggle Play / Pause PLAY_TOGGLE // Decrease speed SLOW_DOWN // Increase speed SPEED_UP // Reset the world (set the state of all cells to DEAD) RESET_STATE // Set random state RANDOM_STATE // Fast forward 1 generation FF_I // Fast forward 10 generations FF_X // Fast forward 50 generations FF_L // Fast forward 100 generations FF_C // Fast forward 1000 generations FF_M // Indicates that new rules were requested NEW_RULES )