ui

package
v0.0.0-...-77e5ff9 Latest Latest
Warning

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

Go to latest
Published: Mar 31, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Button

type Button struct {
	*UI
	// contains filtered or unexported fields
}

func NewButton

func NewButton(img, hover, press, disable *ebiten.Image, posX, posY int) *Button

NewButton create a new button with 4 images of 4 states, normal, hover and press, disable to be drawn at posX posY on screen

func (*Button) Draw

func (b *Button) Draw(screen *ebiten.Image)

func (*Button) SetImage

func (b *Button) SetImage(img *ebiten.Image)

SetText place img on top of the button, img cannot be remove once set.

func (*Button) SetText

func (b *Button) SetText(txt string, face font.Face, color color.Color)

SetText create text on button, text cannot be remove once set.

type Digit

type Digit struct {
	*UI
	// contains filtered or unexported fields
}

func NewDigit

func NewDigit(f font.Face, posX, posY int, c color.Color) *Digit

func (*Digit) Draw

func (d *Digit) Draw(screen *ebiten.Image)

func (*Digit) GetNumber

func (d *Digit) GetNumber() int

func (*Digit) SetNumber

func (d *Digit) SetNumber(x int)

func (*Digit) Update

func (d *Digit) Update()

type Digits

type Digits struct {
	// contains filtered or unexported fields
}

func NewDigits

func NewDigits(f font.Face, posX, posY int, num int, c color.Color) *Digits

NewDigits creates a new number with `num` of digits

func (*Digits) Draw

func (d *Digits) Draw(screen *ebiten.Image)

func (*Digits) GetNumber

func (d *Digits) GetNumber() int

func (*Digits) SetNumber

func (d *Digits) SetNumber(n int)

func (*Digits) Update

func (d *Digits) Update()

type Drawable

type Drawable interface {
	Draw(*ebiten.Image)
	SetPos(int, int)
	GetPos() (int, int)
	GetSize() (int, int)
	SetActive(bool)
	IsActive() bool
	IsHover() bool
	IsDown() bool
	IsJustPressed() bool
	IsJustReleased() bool
}

type List

type List struct {
	PosX int
	PosY int
	// contains filtered or unexported fields
}

Draw a list of UI

func NewList

func NewList(x, y int, dir UIDirection) *List

func (*List) AddUI

func (s *List) AddUI(ui Drawable)

func (*List) Draw

func (s *List) Draw(screen *ebiten.Image)

func (*List) IsDown

func (s *List) IsDown() int

return index of mouse down UI, -1 if none

func (*List) IsHover

func (s *List) IsHover() int

return index of hover UI, return -1 when not hovering

func (*List) IsJustPressed

func (s *List) IsJustPressed() int

return index of mouse just pressed UI, -1 if none

func (*List) IsJustReleased

func (s *List) IsJustReleased() int

return index of mouse just released UI, -1 if none

type TextButton

type TextButton struct {
	*UI
	// contains filtered or unexported fields
}

Use text as a button

func NewTextButton

func NewTextButton(txt string, c color.Color, face font.Face,
	posX, posY int, interactive bool) *TextButton

NewButton create a new button with 4 states, normal, hover and press, disable to be drawn at posX posY on screen

func (*TextButton) Draw

func (b *TextButton) Draw(screen *ebiten.Image)

type UI

type UI struct {
	Active bool
	PosX   int
	PosY   int
	ImgW   int
	ImgH   int
	Op     *ebiten.DrawImageOptions
}

Common UI variables and functions

func NewUI

func NewUI(posX, posY, imgW, imgH int) *UI

func (*UI) GetPos

func (b *UI) GetPos() (int, int)

func (*UI) GetSize

func (b *UI) GetSize() (int, int)

func (*UI) IsActive

func (b *UI) IsActive() bool

func (*UI) IsDown

func (b *UI) IsDown() bool

func (*UI) IsHover

func (b *UI) IsHover() bool

func (*UI) IsJustPressed

func (b *UI) IsJustPressed() bool

func (*UI) IsJustReleased

func (b *UI) IsJustReleased() bool

func (*UI) IsMouseOnButton

func (b *UI) IsMouseOnButton() bool

func (*UI) ResetOptions

func (b *UI) ResetOptions()

func (*UI) SetActive

func (b *UI) SetActive(x bool)

func (*UI) SetPos

func (b *UI) SetPos(x, y int)

SetPos put button in new position x, y

type UIDirection

type UIDirection int
const (
	Horizontal UIDirection = iota
	Vertical
)

Jump to

Keyboard shortcuts

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