diff --git a/.editorconfig b/.editorconfig index bcaf6b26b..08683166f 100644 --- a/.editorconfig +++ b/.editorconfig @@ -14,3 +14,7 @@ trim_trailing_whitespace = false [*.yml] indent_size = 2 indent_style = space + +[*.lua] +indent_size = 4 +indent_style = space diff --git a/gamemodes/terrortown/gamemode/client/cl_help.lua b/gamemodes/terrortown/gamemode/client/cl_help.lua index 22001b57f..2c42adfa3 100644 --- a/gamemodes/terrortown/gamemode/client/cl_help.lua +++ b/gamemodes/terrortown/gamemode/client/cl_help.lua @@ -42,14 +42,7 @@ local function OnSubmenuClassLoaded(class, path, name) end -- load submenu base from specific folder -local submenuBase = classbuilder.BuildFromFolder( - "terrortown/menus/gamemode/base_gamemodemenu/", - CLIENT_FILE, - "CLGAMEMODESUBMENU", -- class scope - OnSubmenuClassLoaded, -- on class loaded - true, -- should inherit - ShouldInherit -- special inheritance check -) +local submenuBase -- callback function that is called once the menu class is loaded; -- also used to load submenus for this menu @@ -103,30 +96,44 @@ local function LoadSubmenus(class, path, name) class:Initialize() end -local menus = classbuilder.BuildFromFolder( - "terrortown/menus/gamemode/", - CLIENT_FILE, - "CLGAMEMODEMENU", -- class scope - OnMenuClassLoaded, -- on class loaded callback - true, -- should inherit - ShouldInherit, -- special inheritance check - nil, -- don't pass through additional classes - LoadSubmenus -- post inheritance callback -) - --- transfer mnus into indexed table and sort by priority ---local menusIndexed = {} -menusIndexed = {} - -for _, menu in pairs(menus) do - if menu.type == "base_gamemodemenu" then - continue +local function LoadAllMenus() + submenuBase = classbuilder.BuildFromFolder( + "terrortown/menus/gamemode/base_gamemodemenu/", + CLIENT_FILE, + "CLGAMEMODESUBMENU", -- class scope + OnSubmenuClassLoaded, -- on class loaded + true, -- should inherit + ShouldInherit -- special inheritance check + ) + + local menus = classbuilder.BuildFromFolder( + "terrortown/menus/gamemode/", + CLIENT_FILE, + "CLGAMEMODEMENU", -- class scope + OnMenuClassLoaded, -- on class loaded callback + true, -- should inherit + ShouldInherit, -- special inheritance check + nil, -- don't pass through additional classes + LoadSubmenus -- post inheritance callback + ) + + -- transfer mnus into indexed table and sort by priority + --local menusIndexed = {} + menusIndexed = {} + + for _, menu in pairs(menus) do + if menu.type == "base_gamemodemenu" then + continue + end + + menusIndexed[#menusIndexed + 1] = menu end - menusIndexed[#menusIndexed + 1] = menu + table.SortByMember(menusIndexed, "priority") end -table.SortByMember(menusIndexed, "priority") +LoadAllMenus() +hook.Add("OnReloaded", "TTT2HelpLoadMenus", LoadAllMenus) -- END load help menu classes