Skip to content

Commit 5d9a353

Browse files
authored
DX: Small developer experience improvements (#1855)
- Reload F1 menu on GM:OnReloaded - Make editorconfig settings match stylua settings
1 parent c660721 commit 5d9a353

File tree

2 files changed

+39
-28
lines changed

2 files changed

+39
-28
lines changed

.editorconfig

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,7 @@ trim_trailing_whitespace = false
1414
[*.yml]
1515
indent_size = 2
1616
indent_style = space
17+
18+
[*.lua]
19+
indent_size = 4
20+
indent_style = space

gamemodes/terrortown/gamemode/client/cl_help.lua

Lines changed: 35 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -42,14 +42,7 @@ local function OnSubmenuClassLoaded(class, path, name)
4242
end
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()
10497
end
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")
127133
end
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

Comments
 (0)