Make a start on font rendering
I was hopeful I could use ebiten/text, but font.Face doesn't seem set up for fixed-colour fonts.
This commit is contained in:
@@ -2,11 +2,14 @@ package menus
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"image/color"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"path/filepath"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"code.ur.gs/lupine/ordoor/internal/data"
|
||||
"code.ur.gs/lupine/ordoor/internal/util/asciiscan"
|
||||
)
|
||||
|
||||
@@ -93,6 +96,9 @@ type Menu struct {
|
||||
ObjectFiles []string
|
||||
FontNames []string
|
||||
|
||||
BackgroundColor color.Color
|
||||
HypertextColor color.Color
|
||||
|
||||
// FIXME: turn these into first-class data
|
||||
Properties map[string]string
|
||||
|
||||
@@ -146,7 +152,23 @@ func LoadMenu(filename string) (*Menu, error) {
|
||||
out.ObjectFiles = append(out.ObjectFiles, str)
|
||||
case 1: // List of properties
|
||||
k, v := asciiscan.ConsumeProperty(str)
|
||||
out.Properties[k] = v
|
||||
vInt, err := strconv.Atoi(v) // FIXME:
|
||||
switch k {
|
||||
case "BACKGROUND COLOR 0..255..-1 trans":
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
out.BackgroundColor = data.ColorPalette[vInt]
|
||||
case "HYPERTEXT COLOR 0..255":
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
out.HypertextColor = data.ColorPalette[vInt]
|
||||
default:
|
||||
out.Properties[k] = v
|
||||
}
|
||||
case 2: // list of fonts
|
||||
// FIXME: do we need to do something cleverer here?
|
||||
if str == "NULL" {
|
||||
@@ -170,6 +192,8 @@ func LoadMenu(filename string) (*Menu, error) {
|
||||
}
|
||||
}
|
||||
|
||||
log.Printf("Menu properties: %#+v", out.Properties)
|
||||
|
||||
return out, nil
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user