Show tooltips when hovering
This commit is contained in:
@@ -6,6 +6,7 @@ import (
|
||||
"reflect" // For DeepEqual
|
||||
|
||||
"github.com/hajimehoshi/ebiten"
|
||||
"github.com/hajimehoshi/ebiten/ebitenutil"
|
||||
|
||||
"code.ur.gs/lupine/ordoor/internal/assetstore"
|
||||
"code.ur.gs/lupine/ordoor/internal/menus"
|
||||
@@ -93,6 +94,11 @@ func (i *Interface) Draw(screen *ebiten.Image) error {
|
||||
return err
|
||||
}
|
||||
do.GeoM = geo
|
||||
|
||||
if widget.hoverState && widget.Tooltip != "" {
|
||||
mouseX, mouseY := ebiten.CursorPosition()
|
||||
ebitenutil.DebugPrintAt(screen, widget.Tooltip, mouseX+16, mouseY-16)
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
@@ -167,10 +173,11 @@ func (i *Interface) widgetFromRecord(record *menus.Record) (*Widget, error) {
|
||||
}
|
||||
|
||||
widget := &Widget{
|
||||
Bounds: sprite.Rect,
|
||||
path: path,
|
||||
record: record,
|
||||
sprite: sprite,
|
||||
Bounds: sprite.Rect,
|
||||
Tooltip: record.Desc,
|
||||
path: path,
|
||||
record: record,
|
||||
sprite: sprite,
|
||||
}
|
||||
|
||||
switch record.Type {
|
||||
|
@@ -13,8 +13,8 @@ import (
|
||||
// non-interactive areas are not widgets.
|
||||
type Widget struct {
|
||||
// Position on the screen in original (i.e., unscaled) coordinates
|
||||
Bounds image.Rectangle
|
||||
// Tooltip string // TODO: show the tooltip when hovering?
|
||||
Bounds image.Rectangle
|
||||
Tooltip string
|
||||
|
||||
OnHoverEnter func()
|
||||
OnHoverLeave func()
|
||||
|
Reference in New Issue
Block a user