Files
inkwell/ui.cursor.go
T
mr.zeroandClaude Opus 5 92fc36bdf5
ci/woodpecker/push/woodpecker Pipeline was successful
Nine things a domain kept having to invent
Every change here started life as a workaround in a game and is really
the same finding: a fact about an entity had nowhere to live, so the
domain built machinery around the gap.

  Character.Label / Character.Voice — a tape is a character that speaks
  into the log, not a second spelling of Say. VoiceOf and CharacterLabel
  read them; Say obeys them.

  Game.Do — a real action queue, in order, so a widget can start an
  action. queueAction no longer drops what arrives while the runner is
  busy; it queues it.

  Widget.When + Gated + WidgetVisible — a widget declares when it is on
  screen. Nothing ticks, draws or blocks a click while its condition is
  false, so a HUD is hidden for a cutscene without a wrapper per widget.

  TopBar.NoteVar — the title was already discovered; the note beside it
  no longer needs a domain widget to push it in.

  Game.UseWithFail — the pair nobody authored is content, and belongs to
  the domain, exactly like ExitLook and ExitTake.

  Game.Player / Game.Walkboxes — a scene that names no cast and no floor
  means "the usual", instead of a defaults pass rewriting every scene.

  Game.WindowScale — Run's 4× is now a default, not a decision.

  SceneNav — the dev widget every game was writing.

  Colour text: DrawText paints in the colour it is handed, and GlyphW/H,
  TextWidth, WrapText and ClipText are the library's, not each game's.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-30 22:57:16 +02:00

41 lines
1.3 KiB
Go

package inkwell
import (
"github.com/hajimehoshi/ebiten/v2"
"github.com/hajimehoshi/ebiten/v2/vector"
)
// Cursor renders the mouse cursor. When the player has an inventory item
// selected, the item's sprite is drawn at the cursor instead of the
// default crosshair. Registered last so it draws on top.
type Cursor struct {
Name string
When Condition
}
func (c *Cursor) GetName() string { return c.Name }
func (c *Cursor) VisibleWhen() Condition { return c.When }
func (c *Cursor) Layer() Layer { return LayerCursor }
func (c *Cursor) Tick(ctx *UICtx) {}
func (c *Cursor) Draw(dst *ebiten.Image, ctx *UICtx) {
g := ctx.Game
x, y := g.Input.Pos()
if sel := g.Inventory.Selected(); sel != "" {
if it, ok := g.ItemManager.Get(sel); ok {
img := g.loaded.image(g.AssetManager, it.Sprite)
sw, sh := img.Bounds().Dx(), img.Bounds().Dy()
if sw > 0 && sh > 0 && !g.loaded.isPlaceholder(it.Sprite) {
op := &ebiten.DrawImageOptions{}
op.GeoM.Scale(16/float64(sw), 16/float64(sh))
op.GeoM.Translate(float64(x-8), float64(y-8))
dst.DrawImage(img, op)
return
}
}
}
col := g.Theme().CursorColor
vector.StrokeLine(dst, float32(x-3), float32(y), float32(x+4), float32(y), 1, col, false)
vector.StrokeLine(dst, float32(x), float32(y-3), float32(x), float32(y+4), 1, col, false)
}