ui

package
v0.0.0-...-f5e6668 Latest Latest
Warning

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

Go to latest
Published: Feb 24, 2025 License: BSD-3-Clause Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const DoubleClickThreshold = 20

Variables

This section is empty.

Functions

This section is empty.

Types

type Selection

type Selection struct {
	Name   string
	Action func()
	Hotkey string
}

type UI

type UI struct {
	// track the layer number of the elements
	Elements map[UILayer][]*UIElement
	Groups   []*UIElementGroup

	Draw       func(*UI, *ebiten.Image)
	HandleKeys UIKeyFunc
	Counter    uint64

	// fires when the left mouse button is clicked, even if no element is clicked
	LeftClick func()

	LeftClickedElements []*UIElement

	Delays []UIDelay

	// disabled so that the zero value is enabled
	Disabled bool

	// lazily initialized in the sync.Once
	StandardSoundMaker audio.MakePlayerFunc
	StandardSoundSetup sync.Once
	Cache              *lbx.LbxCache
	// contains filtered or unexported fields
}

func (*UI) AddDelay

func (ui *UI) AddDelay(time uint64, f func())

func (*UI) AddElement

func (ui *UI) AddElement(element *UIElement)

func (*UI) AddElements

func (ui *UI) AddElements(elements []*UIElement)

func (*UI) AddGroup

func (ui *UI) AddGroup(group *UIElementGroup)

func (*UI) Disable

func (ui *UI) Disable()

func (*UI) Enable

func (ui *UI) Enable()

func (*UI) FocusElement

func (ui *UI) FocusElement(element *UIElement, text string)

func (*UI) GetHighestLayer

func (ui *UI) GetHighestLayer() []*UIElement

func (*UI) GetHighestLayerValue

func (ui *UI) GetHighestLayerValue() UILayer

func (*UI) IsDisabled

func (ui *UI) IsDisabled() bool

func (*UI) IterateElementsByLayer

func (ui *UI) IterateElementsByLayer(f func(*UIElement))

func (*UI) MakeFadeIn

func (ui *UI) MakeFadeIn(time uint64) util.AlphaFadeFunc

func (*UI) MakeFadeOut

func (ui *UI) MakeFadeOut(time uint64) util.AlphaFadeFunc

func (*UI) PlayStandardSound

func (ui *UI) PlayStandardSound()

func (*UI) RemoveElement

func (ui *UI) RemoveElement(toRemove *UIElement)

func (*UI) RemoveElements

func (ui *UI) RemoveElements(toRemove []*UIElement)

func (*UI) RemoveGroup

func (ui *UI) RemoveGroup(group *UIElementGroup)

func (*UI) SetElementsFromArray

func (ui *UI) SetElementsFromArray(elements []*UIElement)

func (*UI) StandardUpdate

func (ui *UI) StandardUpdate()

func (*UI) UnfocusElement

func (ui *UI) UnfocusElement()

type UIClickElementFunc

type UIClickElementFunc func(element *UIElement)

type UIContainer

type UIContainer interface {
	MakeFadeIn(time uint64) util.AlphaFadeFunc
	MakeFadeOut(time uint64) util.AlphaFadeFunc
	AddDelay(time uint64, f func())
	AddElement(*UIElement)
	AddElements([]*UIElement)
	RemoveElement(*UIElement)
	RemoveElements([]*UIElement)
}

type UIDelay

type UIDelay struct {
	Time uint64
	Func func()
}

type UIDrawFunc

type UIDrawFunc func(element *UIElement, window *ebiten.Image)

type UIElement

type UIElement struct {
	Rect image.Rectangle
	// fires if the mouse is not inside this element
	NotInside UINotInsideElementFunc
	// fires if the mouse is inside this element
	Inside UIInsideElementFunc
	// fires if a left click occurred but no other element was clicked on
	NotLeftClicked UIClickElementFunc
	// fires when a left click occurs on this element
	LeftClick UIClickElementFunc
	// fires when the left click button is released on this element
	LeftClickRelease UIClickElementFunc
	// fires when this element is double clicked
	DoubleLeftClick UIClickElementFunc
	// fires when this element is right clicked
	RightClick UIClickElementFunc

	// fires when this element is left clicked
	GainFocus UIGainFocusFunc
	// fires when some other element is left clicked
	LoseFocus UILoseFocusFunc
	// fires when the user types some keys and this element is focused
	TextEntry UITextEntry
	// fires when a key is pressed and this element is focused
	HandleKeys UIKeyFunc

	// fires when the mouse wheel/pad is scrolled
	Scroll UIScrollFunc

	Draw  UIDrawFunc
	Layer UILayer

	// for specifying which element is drawn first
	Order int

	// if true, the standard ui sound will play when this element is left clicked
	PlaySoundLeftClick bool
}

func MakeConfirmDialog

func MakeConfirmDialog(container UIContainer, cache *lbx.LbxCache, imageCache *util.ImageCache, message string, center bool, confirm func(), cancel func()) []*UIElement

func MakeConfirmDialogWithLayer

func MakeConfirmDialogWithLayer(container UIContainer, cache *lbx.LbxCache, imageCache *util.ImageCache, layer UILayer, message string, center bool, confirm func(), cancel func()) []*UIElement

func MakeConfirmDialogWithLayerFull

func MakeConfirmDialogWithLayerFull(container UIContainer, cache *lbx.LbxCache, imageCache *util.ImageCache, layer UILayer, message string, center bool, confirm func(), cancel func(), yesButtons []*ebiten.Image, noButtons []*ebiten.Image) []*UIElement

func MakeErrorElement

func MakeErrorElement(ui UIContainer, cache *lbx.LbxCache, imageCache *util.ImageCache, message string, clicked func()) *UIElement

func MakeHelpElement

func MakeHelpElement(container UIContainer, cache *lbx.LbxCache, imageCache *util.ImageCache, help help.HelpEntry, helpEntries ...help.HelpEntry) *UIElement

func MakeHelpElementWithLayer

func MakeHelpElementWithLayer(container UIContainer, cache *lbx.LbxCache, imageCache *util.ImageCache, layer UILayer, help help.HelpEntry, helpEntries ...help.HelpEntry) *UIElement

func MakeLairConfirmDialog

func MakeLairConfirmDialog(ui UIContainer, cache *lbx.LbxCache, imageCache *util.ImageCache, lairPicture *util.Animation, message string, confirm func(), cancel func()) []*UIElement

func MakeLairConfirmDialogWithLayer

func MakeLairConfirmDialogWithLayer(ui UIContainer, cache *lbx.LbxCache, imageCache *util.ImageCache, lairPicture *util.Animation, layer UILayer, message string, confirm func(), cancel func()) []*UIElement

func MakeLairShowDialogWithLayer

func MakeLairShowDialogWithLayer(ui UIContainer, cache *lbx.LbxCache, imageCache *util.ImageCache, lairPicture *util.Animation, layer UILayer, message string, dismiss func()) []*UIElement

func MakeSelectionUI

func MakeSelectionUI(ui UIContainer, lbxCache *lbx.LbxCache, imageCache *util.ImageCache, cornerX int, cornerY int, selectionTitle string, choices []Selection) []*UIElement

type UIElementGroup

type UIElementGroup struct {
	Elements map[UILayer][]*UIElement

	Counter uint64
	Delays  []UIDelay
	// contains filtered or unexported fields
}

a collection of ui elements that can be removed all at once

func MakeGroup

func MakeGroup() *UIElementGroup

func (*UIElementGroup) AddDelay

func (group *UIElementGroup) AddDelay(time uint64, f func())

func (*UIElementGroup) AddElement

func (group *UIElementGroup) AddElement(element *UIElement)

func (*UIElementGroup) AddElements

func (group *UIElementGroup) AddElements(elements []*UIElement)

func (*UIElementGroup) MakeFadeIn

func (group *UIElementGroup) MakeFadeIn(time uint64) util.AlphaFadeFunc

func (*UIElementGroup) MakeFadeOut

func (group *UIElementGroup) MakeFadeOut(time uint64) util.AlphaFadeFunc

func (*UIElementGroup) RemoveElement

func (group *UIElementGroup) RemoveElement(element *UIElement)

func (*UIElementGroup) RemoveElements

func (group *UIElementGroup) RemoveElements(elements []*UIElement)

type UIGainFocusFunc

type UIGainFocusFunc func(*UIElement)

type UIInsideElementFunc

type UIInsideElementFunc func(element *UIElement, x int, y int)

type UIKeyFunc

type UIKeyFunc func(key []ebiten.Key)

type UILayer

type UILayer int

type UILoseFocusFunc

type UILoseFocusFunc func(*UIElement)

type UINotInsideElementFunc

type UINotInsideElementFunc func(element *UIElement)

type UIScrollFunc

type UIScrollFunc func(*UIElement, float64, float64)

type UITextEntry

type UITextEntry func(*UIElement, string) string

Jump to

Keyboard shortcuts

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