Add a partial listbox implementation
This commit is contained in:
@@ -11,11 +11,42 @@ func init() {
|
||||
}
|
||||
|
||||
func registerMenu(d *Driver, r *menus.Record) ([]*menus.Record, error) {
|
||||
// Group all inventory selects that share a menu together
|
||||
childrenLeft, err := listBoxFromMenu(d, r, r.Children)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
childrenLeft, err = inventorySelectFromMenu(d, r, childrenLeft)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// Return all the unhandled children to be processed further
|
||||
return childrenLeft, nil
|
||||
}
|
||||
|
||||
func listBoxFromMenu(d *Driver, menu *menus.Record, children []*menus.Record) ([]*menus.Record, error) {
|
||||
ok := false
|
||||
for _, rec := range children {
|
||||
if rec.Type == menus.TypeThumb { // FIXME: we're using this to indicate a listbox
|
||||
ok = true
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
if !ok {
|
||||
return children, nil
|
||||
}
|
||||
|
||||
return registerListBox(d, menu)
|
||||
}
|
||||
|
||||
// Group all inventory selects that share a menu together
|
||||
func inventorySelectFromMenu(d *Driver, menu *menus.Record, children []*menus.Record) ([]*menus.Record, error) {
|
||||
var childrenLeft []*menus.Record
|
||||
var inventorySelects []*inventorySelect
|
||||
|
||||
for _, child := range r.Children {
|
||||
for _, child := range children {
|
||||
switch child.Type {
|
||||
case menus.TypeInventorySelect:
|
||||
is, err := registerInventorySelect(d, child)
|
||||
@@ -37,6 +68,5 @@ func registerMenu(d *Driver, r *menus.Record) ([]*menus.Record, error) {
|
||||
}
|
||||
}
|
||||
|
||||
// Return all the unhandled children to be processed further
|
||||
return childrenLeft, nil
|
||||
}
|
||||
|
Reference in New Issue
Block a user