Implement the main menu for the ordoor binary

In this commit, we also remove code that doesn't properly belong in
view-menu
This commit is contained in:
2020-03-22 19:12:44 +00:00
parent d4d8a50ce4
commit cfa56a0e12
6 changed files with 225 additions and 78 deletions

View File

@@ -25,6 +25,9 @@ type Widget struct {
OnMouseClick func()
OnMouseUp func()
disabled bool
disabledImage *ebiten.Image
// These are expected to have the same dimensions as the Bounds
hoverAnimation []*ebiten.Image
hoverState bool
@@ -39,6 +42,13 @@ type Widget struct {
sprite *assetstore.Sprite
}
func (w *Widget) Disable() {
w.hovering(false)
w.mouseButton(false)
w.disabled = true
}
func (w *Widget) hovering(value bool) {
if w.OnHoverEnter != nil && !w.hoverState && value {
w.OnHoverEnter()
@@ -72,6 +82,10 @@ func (w *Widget) mouseButton(value bool) {
}
func (w *Widget) Image(aniStep int) (*ebiten.Image, error) {
if w.disabled {
return w.disabledImage, nil
}
if w.hoverState && w.mouseButtonState {
return w.mouseButtonDownImage, nil
}