Get character stats (kind of) displaying in-scenario
This commit is contained in:
@@ -32,12 +32,13 @@ type noninteractive struct {
|
||||
hoverImpl
|
||||
}
|
||||
|
||||
// Paint some text to screen
|
||||
// Paint some text to screen, possibly settable
|
||||
type label struct {
|
||||
align AlignMode
|
||||
rect image.Rectangle
|
||||
text string
|
||||
font *assetstore.Font
|
||||
locator string
|
||||
align AlignMode
|
||||
rect image.Rectangle
|
||||
font *assetstore.Font
|
||||
valueImpl
|
||||
}
|
||||
|
||||
// This particular animation has entry and exit sequences, which are invoked
|
||||
@@ -109,6 +110,33 @@ func (d *Driver) buildHypertext(p *menus.Properties) (*noninteractive, *Widget,
|
||||
return ni, widget, nil
|
||||
}
|
||||
|
||||
func (d *Driver) buildClickText(p *menus.Properties) (*noninteractive, *Widget, error) {
|
||||
ni, err := d.buildNoninteractive(p)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
fnt := d.menu.Font(p.FontType/10 - 1)
|
||||
|
||||
// FIXME: is this always right? Seems to make sense for Main.mnu
|
||||
ni.label = &label{
|
||||
locator: ni.locator,
|
||||
font: fnt,
|
||||
rect: ni.rect, // We will be centered by default
|
||||
// Starts with no text. The text specified in the menu is hovertext
|
||||
}
|
||||
|
||||
widget := &Widget{
|
||||
Locator: ni.locator,
|
||||
Active: p.Active,
|
||||
ownClickables: []clickable{ni},
|
||||
ownPaintables: []paintable{ni},
|
||||
ownValueables: []valueable{ni.label},
|
||||
}
|
||||
|
||||
return ni, widget, nil
|
||||
}
|
||||
|
||||
// An overlay is a static image + some text that needs to be rendered
|
||||
func (d *Driver) buildOverlay(p *menus.Properties) (*noninteractive, *Widget, error) {
|
||||
ni, err := d.buildNoninteractive(p)
|
||||
@@ -127,9 +155,9 @@ func (d *Driver) buildOverlay(p *menus.Properties) (*noninteractive, *Widget, er
|
||||
fnt := d.menu.Font(p.FontType/10 - 1)
|
||||
|
||||
ni.label = &label{
|
||||
font: fnt,
|
||||
rect: ni.rect, // We will be centered by default
|
||||
text: p.Text,
|
||||
font: fnt,
|
||||
rect: ni.rect, // We will be centered by default
|
||||
valueImpl: valueImpl{str: p.Text},
|
||||
}
|
||||
} else {
|
||||
log.Printf("Overlay without text detected in %v", p.Locator)
|
||||
@@ -253,6 +281,10 @@ func (a *animationHover) setHoverState(value bool) {
|
||||
a.hoverImpl.setHoverState(value)
|
||||
}
|
||||
|
||||
func (l *label) id() string {
|
||||
return l.locator
|
||||
}
|
||||
|
||||
// Top-left of where to start drawing the text. We want it to appear to be in
|
||||
// the centre of the rect.
|
||||
//
|
||||
@@ -260,7 +292,7 @@ func (a *animationHover) setHoverState(value bool) {
|
||||
func (l *label) pos() image.Point {
|
||||
pos := l.rect.Min
|
||||
|
||||
textRect := l.font.CalculateBounds(l.text)
|
||||
textRect := l.font.CalculateBounds(l.str)
|
||||
|
||||
// Centre the text horizontally
|
||||
if l.align == AlignModeCentre {
|
||||
@@ -287,7 +319,7 @@ func (l *label) regions(tick int) []region {
|
||||
|
||||
pt := l.pos()
|
||||
|
||||
for _, r := range l.text {
|
||||
for _, r := range l.str {
|
||||
glyph, err := l.font.Glyph(r)
|
||||
if err != nil {
|
||||
log.Printf("FIXME: ignoring misssing glyph %v", r)
|
||||
|
Reference in New Issue
Block a user