@@ -42,14 +42,7 @@ local function OnSubmenuClassLoaded(class, path, name)
4242end
4343
4444-- load submenu base from specific folder
45- local submenuBase = classbuilder .BuildFromFolder (
46- " terrortown/menus/gamemode/base_gamemodemenu/" ,
47- CLIENT_FILE ,
48- " CLGAMEMODESUBMENU" , -- class scope
49- OnSubmenuClassLoaded , -- on class loaded
50- true , -- should inherit
51- ShouldInherit -- special inheritance check
52- )
45+ local submenuBase
5346
5447-- callback function that is called once the menu class is loaded;
5548-- also used to load submenus for this menu
@@ -103,30 +96,44 @@ local function LoadSubmenus(class, path, name)
10396 class :Initialize ()
10497end
10598
106- local menus = classbuilder .BuildFromFolder (
107- " terrortown/menus/gamemode/" ,
108- CLIENT_FILE ,
109- " CLGAMEMODEMENU" , -- class scope
110- OnMenuClassLoaded , -- on class loaded callback
111- true , -- should inherit
112- ShouldInherit , -- special inheritance check
113- nil , -- don't pass through additional classes
114- LoadSubmenus -- post inheritance callback
115- )
116-
117- -- transfer mnus into indexed table and sort by priority
118- -- local menusIndexed = {}
119- menusIndexed = {}
120-
121- for _ , menu in pairs (menus ) do
122- if menu .type == " base_gamemodemenu" then
123- continue
99+ local function LoadAllMenus ()
100+ submenuBase = classbuilder .BuildFromFolder (
101+ " terrortown/menus/gamemode/base_gamemodemenu/" ,
102+ CLIENT_FILE ,
103+ " CLGAMEMODESUBMENU" , -- class scope
104+ OnSubmenuClassLoaded , -- on class loaded
105+ true , -- should inherit
106+ ShouldInherit -- special inheritance check
107+ )
108+
109+ local menus = classbuilder .BuildFromFolder (
110+ " terrortown/menus/gamemode/" ,
111+ CLIENT_FILE ,
112+ " CLGAMEMODEMENU" , -- class scope
113+ OnMenuClassLoaded , -- on class loaded callback
114+ true , -- should inherit
115+ ShouldInherit , -- special inheritance check
116+ nil , -- don't pass through additional classes
117+ LoadSubmenus -- post inheritance callback
118+ )
119+
120+ -- transfer mnus into indexed table and sort by priority
121+ -- local menusIndexed = {}
122+ menusIndexed = {}
123+
124+ for _ , menu in pairs (menus ) do
125+ if menu .type == " base_gamemodemenu" then
126+ continue
127+ end
128+
129+ menusIndexed [# menusIndexed + 1 ] = menu
124130 end
125131
126- menusIndexed [ # menusIndexed + 1 ] = menu
132+ table . SortByMember ( menusIndexed , " priority " )
127133end
128134
129- table .SortByMember (menusIndexed , " priority" )
135+ LoadAllMenus ()
136+ hook .Add (" OnReloaded" , " TTT2HelpLoadMenus" , LoadAllMenus )
130137
131138-- END load help menu classes
132139
0 commit comments