Skip to content

Draft: Some Lua interactions with menus

Skydusk requested to merge Acelite/srb-2-archivedmodifications:menuhookslua into next

It is pretty much half-baked support, at most visual. I want to tackle again the custom console variable menu later. This is more so for those wanting to overhaul visually the menus.

menuitem_t got exposed, partially -> only as read only int status; string patch; string text; int alphaKey; not the call function.

Due to status being also exposed, menu item flags were also exposed as constants -> at the end of the merge description.

Hooked in the M_Drawer ->

hud.add(function(v, *int* menu_id, *int* item_on, *table huditem_t* items), "menu") While menu_id is not actually specific, as it uses already exposed menu id constants https://wiki.srb2.org/wiki/Constants#Menu_types_(MN_*), at least it is something for orientation as exposing menu_t definitions is not a good idea to be precise for location in the tree. items is lua table with all menuitems_t in the current menu array. It is only active when the menu is active which should include an escape menu from ingame.

As well as menu item hud_menu internally, which can be disabled/enabled with the "menu" string. Making a game not draw the menu, would allow for modders to create visually their own menu.

Added MenuChange ordinary hook, into both M_SetupNextMenu and M_StartControlPanel to make sure. It does nothing really in both of these functions, it merely activates.

addHook("MenuChange", function(int currentmenu, int previousmenu)) Both integers derive from the same constants that were already exposed and were partially documented on the wiki. They return nothing. Mainly created it because disabling the menu hud item in the hud hook is tic late.

menu_test.lua

flags
IT_TYPE
IT_CALL
IT_SPACE
IT_ARROWS
IT_KEYHANDLER
IT_SUBMENU
IT_CVAR
IT_PAIR
IT_MSGHANDLER
IT_DISPLAY
IT_NOTHING
IT_PATCH
IT_STRING
IT_WHITESTRING
IT_DYBIGSPACE
IT_DYLITLSPACE
IT_STRING2
IT_GRAYPATCH
IT_BIGSLIDER
IT_TRANSTEXT
IT_TRANSTEXT2
IT_HEADERTEXT
IT_QUESTIONMARKS
IT_CENTER
IT_CVARTYPE
IT_CV_NORMAL
IT_CV_SLIDER
IT_CV_STRING
IT_CV_NOPRINT
IT_CV_NOMOD
IT_CV_INVISSLIDER
IT_CV_INTEGERSTEP
IT_CV_FLOATSLIDER
IT_CALLTYPE
IT_CALL_NORMAL
IT_CALL_NOTMODIFIED
IT_BIGSPACE
IT_LITLSPACE
IT_CONTROL
IT_CVARMAX
IT_DISABLED
IT_GRAYEDOUT
IT_GRAYEDOUT2
IT_HEADER
IT_SECRET
Edited by Skydusk

Merge request reports

Loading