ui

package
v0.0.0-...-16767da Latest Latest
Warning

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

Go to latest
Published: Jul 16, 2023 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	OriginalX = 640.0
	OriginalY = 480.0
)

Variables

View Source
var (
	SpeedDivisor = 2
)

Functions

This section is empty.

Types

type AlignMode

type AlignMode int
const (
	AlignModeCentre AlignMode = 0
	AlignModeLeft   AlignMode = 1
)

type CustomCursor

type CustomCursor interface {
	// The cursor draw operation
	Cursor() (*ebiten.Image, *ebiten.DrawImageOptions, error)
}

type Driver

type Driver struct {
	Name string
	// contains filtered or unexported fields
}

Driver acts as an interface between the main loop and the widgets specified in a menu.

Menu assets assume a 640x480 screen; Driver is responsible for scaling to the actual screen size when drawing.

TODO: move scaling responsibilities to Window?

func NewDriver

func NewDriver(assets *assetstore.AssetStore, menu *assetstore.Menu) (*Driver, error)

func (*Driver) ConfigureSlider

func (d *Driver) ConfigureSlider(id string, steps map[int]int) error

FIXME: HURK. Surely I'm missing something? steps is value:offset

func (*Driver) Cursor

func (d *Driver) Cursor() (*ebiten.Image, *ebiten.DrawImageOptions, error)

func (*Driver) Dialogues

func (d *Driver) Dialogues() []string

func (*Driver) Draw

func (d *Driver) Draw(screen *ebiten.Image) error

func (*Driver) HideDialogue

func (d *Driver) HideDialogue()

func (*Driver) IsInDialogue

func (d *Driver) IsInDialogue() bool

func (*Driver) OnClick

func (d *Driver) OnClick(id string, f func()) error

func (*Driver) SetActive

func (d *Driver) SetActive(locator string, value bool) error

func (*Driver) SetFreeze

func (d *Driver) SetFreeze(id string, value bool) error

func (*Driver) SetValue

func (d *Driver) SetValue(id, value string) error

func (*Driver) SetValueBool

func (d *Driver) SetValueBool(id string, value bool) error

func (*Driver) SetValueInt

func (d *Driver) SetValueInt(id string, value int) error

func (*Driver) ShowDialogue

func (d *Driver) ShowDialogue(locator string) error

func (*Driver) ToggleActive

func (d *Driver) ToggleActive(locator string) error

func (*Driver) Update

func (d *Driver) Update(screenX, screenY int) error

func (*Driver) Value

func (d *Driver) Value(id string, into *string) error

func (*Driver) ValueBool

func (d *Driver) ValueBool(id string, into *bool) error

func (*Driver) ValueInt

func (d *Driver) ValueInt(id string, into *int) error

type Game

type Game interface {
	Update(screenX, screenY int) error
	Draw(*ebiten.Image) error
}

type Widget

type Widget struct {
	Locator  string
	Children []*Widget
	Active   bool
	// contains filtered or unexported fields
}

type Window

type Window struct {
	Title             string
	KeyUpHandlers     map[ebiten.Key]func()
	MouseWheelHandler func(float64, float64)
	MouseClickHandler func()

	WhileKeyDownHandlers map[ebiten.Key]func()
	// contains filtered or unexported fields
}

TODO: move all scaling into Window, so drivers only need to cope with one coordinate space. This will allow us to draw custom mouse cursors in the window, rather than in the driver.

func NewWindow

func NewWindow(game Game, title string, xRes int, yRes int) (*Window, error)

0,0 is the *top left* of the window

ebiten assumes a single window, so only call this once...

func (*Window) Draw

func (w *Window) Draw(screen *ebiten.Image)

func (*Window) Layout

func (w *Window) Layout(_, _ int) (int, int)

func (*Window) OnKeyUp

func (w *Window) OnKeyUp(key ebiten.Key, f func())

TODO: multiple handlers for the same key?

func (*Window) OnMouseClick

func (w *Window) OnMouseClick(f func())

func (*Window) OnMouseWheel

func (w *Window) OnMouseWheel(f func(x, y float64))

func (*Window) Run

func (w *Window) Run() error

TODO: a stop or other cancellation mechanism

Note that this must be called on the main OS thread

func (*Window) Update

func (w *Window) Update() (outErr error)

func (*Window) WhileKeyDown

func (w *Window) WhileKeyDown(key ebiten.Key, f func())

Jump to

Keyboard shortcuts

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