Allow menu records to be processed hierarchically by the UI driver

Nothing is actually processed in this way yet, but there is a new
assertion forbidding certain types of records from having children.

Because of this new assertion, our menutype tweaks must be moved up a
layer into internal/menus. They fit better there anyway.
This commit is contained in:
2020-03-31 23:29:43 +01:00
parent 7586b90f8a
commit 2ae3611d7f
5 changed files with 61 additions and 34 deletions

View File

@@ -23,7 +23,7 @@ const (
TypeDoorHotspot MenuType = 30 // Like a button I guess? "FONTTYPE is animation speed"
TypeDoorHotspot2 MenuType = 31 // Seems like a duplicate of the above? What's different?
TypeLineKbd MenuType = 40
TypeThumb MenuType = 45
TypeThumb MenuType = 45 // A "thumb" appears to be a vertical slider
TypeLineBriefing MenuType = 41
TypeInvokeButton MenuType = 50
TypeDoorHotspot3 MenuType = 60 // Maybe? Appears in Arrange.mnu
@@ -67,6 +67,20 @@ var TextOverrides = map[string]map[string]string{
},
}
// FIXME: The menu is specified as type 2 (button) in these cases, which is
// weird. Make it a menu for now.
var TypeOverrides = map[string]map[string]MenuType{
"levelply": {
"2": TypeMenu,
},
"savegame": {
"2": TypeMenu,
},
"loadgame": {
"2": TypeMenu,
},
}
type Record struct {
Menu *Menu
Parent *Record
@@ -262,6 +276,13 @@ func setProperty(r *Record, k, v string) {
r.Id = vInt
case "MENUTYPE", "SUBMENUTYPE":
r.Type = MenuType(vInt)
// FIXME: Type override. Note that MENUID is specified first, so this works
if overrides, ok := TypeOverrides[r.Menu.Name]; ok {
if newType, ok := overrides[r.Path()]; ok {
r.Type = newType
}
}
case "ACTIVE":
r.Active = (vInt != 0)
case "SPRITEID":