new theme fix

This commit is contained in:
2026-05-25 20:53:24 +02:00
parent 2eef22a76b
commit ca8df5bd72
3 changed files with 51 additions and 22 deletions

View File

@@ -25,11 +25,12 @@ func Build() *p.Game {
defineBedroom(g) defineBedroom(g)
defineKitchen(g) defineKitchen(g)
// Story-rich HUD: top bar + character panels + chat log + permanent // Story-rich HUD: top bar + NPC character panel + chat log + permanent
// verb wheel + small inventory. Swap for p.RegisterDefaultUI(g) to // verb wheel + small inventory. The player panel is skipped — the
// get the simpler SCUMM-style layout, or p.RegisterRadialVerbUI(g) // player avatar is always visible in the scene, so the floating card
// for a verb-coin (right-click) layout. // in the corner just gets in the way. Pass "player" as the second
p.RegisterRichUI(g, "player", "cat") // arg to put it back.
p.RegisterRichUI(g, "", "cat")
g.MaxLogLines = 64 g.MaxLogLines = 64
// initial HUD vars // initial HUD vars

View File

@@ -88,8 +88,14 @@ func RegisterRichUI(g *Game, playerName, npcName string) {
g.UIManager.Register(&RadialVerbs{ g.UIManager.Register(&RadialVerbs{
Name: "verbs", Name: "verbs",
AlwaysVisible: true, AlwaysVisible: true,
Center: Point{X: 290, Y: 90}, Center: Point{X: 282, Y: 90},
Radius: 28, Radius: 36,
Labels: map[string]string{
"look": "Néz",
"use": "Tedd",
"talk": "Szól",
"take": "Vedd",
},
}) })
g.UIManager.Register(&SpeechBubble{Name: "speech", MaxWidth: 200, Padding: 3, OffsetY: 4, FallbackY: 18}) g.UIManager.Register(&SpeechBubble{Name: "speech", MaxWidth: 200, Padding: 3, OffsetY: 4, FallbackY: 18})
g.UIManager.Register(&DialogBox{Name: "dialog", Bounds: Rect(0, 90, float64(g.Width), 56), LineHeight: 12, Padding: 6}) g.UIManager.Register(&DialogBox{Name: "dialog", Bounds: Rect(0, 90, float64(g.Width), 56), LineHeight: 12, Padding: 6})

View File

@@ -25,6 +25,11 @@ type RadialVerbs struct {
AlwaysVisible bool AlwaysVisible bool
Center Point Center Point
// Labels overrides the rendered verb label per verb Name. Useful when
// the regular Verb.Label is too long to fit inside the wheel — e.g.
// {"use": "Tedd", "take": "Vedd"}. Falls back to Verb.Label.
Labels map[string]string
// runtime // runtime
visible bool visible bool
center Point center Point
@@ -180,28 +185,45 @@ func (r *RadialVerbs) Draw(dst *ebiten.Image, ctx *UICtx) {
return return
} }
radius := r.Radius radius := r.Radius
// translucent backdrop disk
vector.DrawFilledCircle(dst, float32(r.center.X), float32(r.center.Y), float32(radius*1.15), color.RGBA{0, 0, 0, 140}, true) cx, cy := float32(r.center.X), float32(r.center.Y)
// translucent backdrop disk that defines the wheel area
vector.DrawFilledCircle(dst, cx, cy, float32(radius), color.RGBA{0, 0, 0, 170}, true)
hover := r.hitTest(g, g.Input.Point()) hover := r.hitTest(g, g.Input.Point())
slice := 2 * math.Pi / float64(n) slice := 2 * math.Pi / float64(n)
// Labels live INSIDE the disk, at 0.62×radius from the center, so a
// short (35 char) word stays comfortably within the rim.
labelDist := radius * 0.62
for i, name := range verbs { for i, name := range verbs {
a := slice*float64(i) + slice/2 a := slice*float64(i) + slice/2
x := r.center.X + math.Cos(a)*radius lx := r.center.X + math.Cos(a)*labelDist
y := r.center.Y + math.Sin(a)*radius ly := r.center.Y + math.Sin(a)*labelDist
bg := th.VerbButtonBG
label := r.labelFor(g, name)
tw := textWidth(label)
col := th.VerbButtonText
if i == hover { if i == hover {
bg = th.VerbButtonSelectedBG // hover halo behind the text
vector.DrawFilledCircle(dst, float32(lx), float32(ly+4), float32(radius*0.28), th.VerbButtonSelectedBG, true)
} }
bw, bh := 34, 14 g.DrawText(dst, label, int(lx)-tw/2, int(ly)-7, col)
bx := int(x) - bw/2
by := int(y) - bh/2
vector.DrawFilledRect(dst, float32(bx), float32(by), float32(bw), float32(bh), bg, false)
verb := g.VerbManager.MustGet(name)
// center label as best we can
tw := textWidth(verb.Label)
g.DrawText(dst, verb.Label, bx+(bw-tw)/2, by-1, th.VerbButtonText)
} }
// center dot // center dot
vector.DrawFilledCircle(dst, float32(r.center.X), float32(r.center.Y), 2, th.CursorColor, true) vector.DrawFilledCircle(dst, cx, cy, 2.5, th.CursorColor, true)
}
func (r *RadialVerbs) labelFor(g *Game, verbName string) string {
if r.Labels != nil {
if alt, ok := r.Labels[verbName]; ok {
return alt
}
}
if v, ok := g.VerbManager.Get(verbName); ok {
return v.Label
}
return verbName
} }