Make the menu buttons work
This commit is contained in:
@@ -10,15 +10,24 @@ import (
|
||||
"code.ur.gs/lupine/ordoor/internal/util/asciiscan"
|
||||
)
|
||||
|
||||
const (
|
||||
TypeStatic = 0
|
||||
TypeMenu = 1
|
||||
TypeOverlay = 61
|
||||
TypeMainButton = 228
|
||||
)
|
||||
|
||||
type Record struct {
|
||||
Parent *Record
|
||||
Children []*Record
|
||||
|
||||
Id int
|
||||
Type int
|
||||
DrawType int
|
||||
FontType int
|
||||
Active bool
|
||||
SpriteId []int
|
||||
Share int
|
||||
X int
|
||||
Y int
|
||||
Desc string
|
||||
@@ -161,6 +170,29 @@ func (r *Record) Toplevel() *Record {
|
||||
return r
|
||||
}
|
||||
|
||||
func (r *Record) SelectSprite(step int, pressed, focused bool) int {
|
||||
switch r.Type {
|
||||
case TypeStatic:
|
||||
return r.SpriteId[0]
|
||||
case TypeMenu:
|
||||
return r.SpriteId[0] // Probably -1
|
||||
case TypeOverlay:
|
||||
return r.Share
|
||||
case TypeMainButton:
|
||||
// A main button has 4 states: unfocused, focused (animated), mousedown, disabled
|
||||
if focused && pressed {
|
||||
return r.Share + 1
|
||||
} else if focused {
|
||||
return r.SpriteId[0] + (step % r.DrawType)
|
||||
}
|
||||
|
||||
// TODO: disabled
|
||||
return r.Share
|
||||
}
|
||||
|
||||
return -1
|
||||
}
|
||||
|
||||
func setProperty(r *Record, k, v string) {
|
||||
vSplit := strings.Split(v, ",")
|
||||
vInt, _ := strconv.Atoi(v)
|
||||
@@ -187,6 +219,10 @@ func setProperty(r *Record, k, v string) {
|
||||
r.Desc = v
|
||||
case "FONTTYPE":
|
||||
r.FontType = vInt
|
||||
case "DRAW TYPE":
|
||||
r.DrawType = vInt
|
||||
case "SHARE":
|
||||
r.Share = vInt
|
||||
default:
|
||||
r.properties[k] = v
|
||||
}
|
||||
|
Reference in New Issue
Block a user