Play around with menus some more
We now display the buttons in Main.mnu, but a lot remains unknown.
This commit is contained in:
37
internal/conv/font.go
Normal file
37
internal/conv/font.go
Normal file
@@ -0,0 +1,37 @@
|
||||
package conv
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/faiface/pixel"
|
||||
"github.com/faiface/pixel/text"
|
||||
"golang.org/x/image/colornames"
|
||||
"golang.org/x/image/font/basicfont"
|
||||
|
||||
"ur.gs/ordoor/internal/fonts"
|
||||
)
|
||||
|
||||
type Font struct {
|
||||
Name string
|
||||
Atlas *text.Atlas
|
||||
Text *text.Text
|
||||
}
|
||||
|
||||
func (f *Font) Output(to pixel.Target, m pixel.Matrix, format string, args ...interface{}) {
|
||||
text := text.New(pixel.V(0.0, 0.0), f.Atlas)
|
||||
text.Color = colornames.White
|
||||
|
||||
fmt.Fprintf(text, format, args...)
|
||||
|
||||
text.Draw(to, m)
|
||||
}
|
||||
|
||||
func ConvertFont(font *fonts.Font) *Font {
|
||||
// FIXME: actually use the pixel data in font
|
||||
atlas := text.NewAtlas(basicfont.Face7x13, text.ASCII)
|
||||
|
||||
return &Font{
|
||||
Name: font.Name,
|
||||
Atlas: atlas,
|
||||
}
|
||||
}
|
@@ -16,8 +16,9 @@ type Record struct {
|
||||
|
||||
Id int
|
||||
Type int
|
||||
FontType int
|
||||
Active bool
|
||||
SpriteId int
|
||||
SpriteId []int
|
||||
X int
|
||||
Y int
|
||||
Desc string
|
||||
@@ -161,7 +162,14 @@ func (r *Record) Toplevel() *Record {
|
||||
}
|
||||
|
||||
func setProperty(r *Record, k, v string) {
|
||||
vSplit := strings.Split(v, ",")
|
||||
vInt, _ := strconv.Atoi(v)
|
||||
vSplitInt := make([]int, len(vSplit))
|
||||
|
||||
for i, subV := range vSplit {
|
||||
vSplitInt[i], _ = strconv.Atoi(subV)
|
||||
}
|
||||
|
||||
switch k {
|
||||
case "MENUID", "SUBMENUID":
|
||||
r.Id = vInt
|
||||
@@ -170,13 +178,15 @@ func setProperty(r *Record, k, v string) {
|
||||
case "ACTIVE":
|
||||
r.Active = (vInt != 0)
|
||||
case "SPRITEID":
|
||||
r.SpriteId = vInt
|
||||
r.SpriteId = vSplitInt
|
||||
case "X-CORD":
|
||||
r.X = vInt
|
||||
case "Y-CORD":
|
||||
r.Y = vInt
|
||||
case "DESC":
|
||||
r.Desc = v
|
||||
case "FONTTYPE":
|
||||
r.FontType = vInt
|
||||
default:
|
||||
r.properties[k] = v
|
||||
}
|
||||
|
Reference in New Issue
Block a user