Make animations work in the options screen
This commit is contained in:
@@ -4,7 +4,6 @@ import (
|
||||
"fmt"
|
||||
"image"
|
||||
"log"
|
||||
"reflect" // For DeepEqual
|
||||
|
||||
"github.com/hajimehoshi/ebiten"
|
||||
"github.com/hajimehoshi/ebiten/ebitenutil"
|
||||
@@ -23,7 +22,7 @@ import (
|
||||
type Interface struct {
|
||||
Name string
|
||||
menu *assetstore.Menu
|
||||
static []*staticElement
|
||||
static []*noninteractive
|
||||
ticks int
|
||||
widgets []*Widget
|
||||
}
|
||||
@@ -44,14 +43,14 @@ func NewInterface(menu *assetstore.Menu) (*Interface, error) {
|
||||
}
|
||||
|
||||
// Find a widget by its hierarchical ID path
|
||||
func (i *Interface) Widget(path ...int) (*Widget, error) {
|
||||
func (i *Interface) Widget(path string) (*Widget, error) {
|
||||
for _, widget := range i.widgets {
|
||||
if reflect.DeepEqual(path, widget.path) {
|
||||
if path == widget.path {
|
||||
return widget, nil
|
||||
}
|
||||
}
|
||||
|
||||
return nil, fmt.Errorf("Couldn't find widget %#+v", path)
|
||||
return nil, fmt.Errorf("Couldn't find widget %v", path)
|
||||
}
|
||||
|
||||
func (i *Interface) Update(screenX, screenY int) error {
|
||||
@@ -82,9 +81,9 @@ func (i *Interface) Draw(screen *ebiten.Image) error {
|
||||
do := &ebiten.DrawImageOptions{GeoM: geo}
|
||||
|
||||
for _, s := range i.static {
|
||||
if s.image != nil {
|
||||
do.GeoM.Translate(geo.Apply(float64(s.bounds.Min.X), float64(s.bounds.Min.X)))
|
||||
if err := screen.DrawImage(s.image, do); err != nil {
|
||||
if image := s.image(i.ticks); image != nil {
|
||||
do.GeoM.Translate(geo.Apply(float64(s.bounds.Min.X), float64(s.bounds.Min.Y)))
|
||||
if err := screen.DrawImage(image, do); err != nil {
|
||||
return err
|
||||
}
|
||||
do.GeoM = geo
|
||||
|
Reference in New Issue
Block a user