Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,7 @@ trim_trailing_whitespace = false
[*.yml]
indent_size = 2
indent_style = space

[*.lua]
indent_size = 4
indent_style = space
66 changes: 38 additions & 28 deletions gamemodes/terrortown/gamemode/client/cl_help.lua
Original file line number Diff line number Diff line change
Expand Up @@ -39,17 +39,11 @@ local function OnSubmenuClassLoaded(class, path, name)
class.base = class.base or "base_gamemodesubmenu"

Dev(1, "Added TTT2 gamemode submenu file: ", 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
Expand Down Expand Up @@ -103,30 +97,46 @@ 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

Expand Down
Loading