Allow dialogues to be hidden or shown

To do this, MENU and SUBMENU are split into two types (at last), and
a Widget type is introduced. This should allow lots of code to be
removed at some point.
This commit is contained in:
2020-04-14 03:14:49 +01:00
parent dc131939f4
commit 786d261f98
18 changed files with 1034 additions and 847 deletions

View File

@@ -4,10 +4,6 @@ import (
"code.ur.gs/lupine/ordoor/internal/menus"
)
func init() {
registerBuilder(menus.TypeInventorySelect, ownedByMenu)
}
// An inventory select is a sort of radio button. If 2 share the same menu,
// selecting one deselects the other. Otherwise, they act like checkboxes.
//
@@ -20,33 +16,18 @@ type inventorySelect struct {
}
// Called from the menu, which fills "others" for us
func registerInventorySelect(d *Driver, r *menus.Record) (*inventorySelect, error) {
sprites, err := d.menu.Sprites(r.ObjectIdx, r.Share, 3) // unchecked, checked, disabled
func (d *Driver) buildInventorySelect(p *menus.Properties) (*inventorySelect, *Widget, error) {
c, widget, err := d.buildCheckbox(p)
if err != nil {
return nil, err
return nil, nil, err
}
element := &inventorySelect{
checkbox: checkbox{
button: button{
path: r.Path(),
baseSpr: sprites[0], // unchecked
clickSpr: sprites[1], // checked
frozenSpr: sprites[2], // disabled
hoverImpl: hoverImpl{text: r.Text},
},
// In an inventorySelect, the frozen and click sprites are reversed
c.clickSpr, c.frozenSpr = c.frozenSpr, c.clickSpr
valueImpl: valueImpl{str: "0"},
},
}
element := &inventorySelect{checkbox: *c}
d.clickables = append(d.clickables, element)
d.freezables = append(d.freezables, element)
d.hoverables = append(d.hoverables, element)
d.paintables = append(d.paintables, element)
d.valueables = append(d.valueables, element)
return element, nil
return element, widget, nil
}
func (i *inventorySelect) registerMouseClick() {