Start loading .fnt files. No display yet

This commit is contained in:
2019-01-02 06:16:15 +00:00
parent 568365be3a
commit 997e2076d1
6 changed files with 340 additions and 19 deletions

View File

@@ -20,6 +20,7 @@ type Record struct {
SpriteId int
X int
Y int
Desc string
// FIXME: turn these into first-class data
properties map[string]string
@@ -174,7 +175,30 @@ func setProperty(r *Record, k, v string) {
r.X = vInt
case "Y-CORD":
r.Y = vInt
case "DESC":
r.Desc = v
default:
r.properties[k] = v
}
}
type Replacer interface {
Replace(int, *string)
}
func (r *Record) Internationalize(replacer Replacer) {
id, err := strconv.Atoi(r.Desc)
if err == nil {
replacer.Replace(id, &r.Desc)
}
for _, child := range r.Children {
child.Internationalize(replacer)
}
}
func (m *Menu) Internationalize(replacer Replacer) {
for _, record := range m.Records {
record.Internationalize(replacer)
}
}