Health, mana and experience bars, quarter hearts, lives, a spinning coin counter, score board, stage timer, minimap with fog, compass, hotbar, paper-doll equipment, skill tree, skill buttons with cooldown wipes, status effects, a boss bar, damage numbers, quest log and tracker, party frames, character sheet, level-up screen and shop. data exports DrawSlot so every slot looks alike; pixel adds TextVeil for dissolving text. Messages the font cannot draw are fixed and TestMessagesHaveGlyphs holds every message to the font.
43 lines
1.3 KiB
Go
43 lines
1.3 KiB
Go
package game
|
|
|
|
import (
|
|
"strings"
|
|
|
|
"github.com/egoist/mygo/ui"
|
|
|
|
"git.zacharyzhang.com/ZacharyZhang-NY/8bitMyGoUI/icon"
|
|
"git.zacharyzhang.com/ZacharyZhang-NY/8bitMyGoUI/pixel"
|
|
)
|
|
|
|
type QuestTrackerOptions struct{}
|
|
|
|
// QuestTracker lists a quest's objectives with counts, met ones ticked.
|
|
func QuestTracker(c *ui.Context, q Quest, o QuestTrackerOptions) *ui.Element {
|
|
k := pixel.K(c)
|
|
q.check()
|
|
w := icon.Star.W + 2 + pixel.Measure(q.Title)
|
|
parts := make([]string, len(q.Objectives))
|
|
for i, ob := range q.Objectives {
|
|
parts[i] = ob.Text + " " + ratio(ob.Have, ob.Need)
|
|
w = max(w, 11+pixel.Measure(ob.Text)+6+pixel.MicroWidth(ratio(ob.Have, ob.Need)))
|
|
}
|
|
return ui.Box(c).Role(ui.RoleGroup).Label(q.Title).Description(strings.Join(parts, "; ")).Size(k.D(w), k.D((1+len(q.Objectives))*pixel.LineHeight)).Draw(func(p *ui.Painter, r ui.Rect) {
|
|
g := k.Canvas(p, r)
|
|
g.Sprite(0, 2, icon.Star, 0, pixel.Warn, 1)
|
|
g.Text(icon.Star.W+2, 0, q.Title, pixel.Warn, 1)
|
|
for i, ob := range q.Objectives {
|
|
y, met := (i+1)*pixel.LineHeight, ob.Have == ob.Need
|
|
tick(g, 1, y+5, met)
|
|
ink := pixel.Ink
|
|
if met {
|
|
ink = pixel.Faint
|
|
}
|
|
g.Text(11, y, ob.Text, ink, 1)
|
|
if ob.Need > 1 {
|
|
n := ratio(ob.Have, ob.Need)
|
|
g.Micro(w-pixel.MicroWidth(n), y+6, n, ink, 1)
|
|
}
|
|
}
|
|
})
|
|
}
|