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:
@@ -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
|
||||
}
|
||||
|
Reference in New Issue
Block a user