1local function build_list(group)
2	local res = {};
3	for i,v in ipairs(shader_list({group})) do
4		local key, dom = shader_getkey(v, {group});
5		local rv = shader_uform_menu(key, dom);
6		if (rv and #rv > 0) then
7			table.insert(res, {
8				name = key,
9				label = v,
10				submenu = true,
11				kind = "action",
12				handler = function()
13					return rv;
14				end
15			});
16		end
17	end
18	return res;
19end
20
21local rebuild_query = {
22{
23	name = "no",
24	label = "No",
25	kind = "action",
26	handler = function() end
27},
28{
29	name = "yes",
30	label = "Yes",
31	description = "Warning: This can put the UI in an unstable state, Proceed?",
32	kind = "action",
33	dangerous = true,
34		handler = function()
35			shdrmgmt_scan();
36		end
37	}
38};
39
40return function()
41	return
42	{
43		{
44		name = "ui",
45		label = "UI",
46		description = "Change variables for shaders that belong to the 'UI' category",
47		kind = "action",
48		submenu = true,
49		eval = function() return #build_list("ui") > 0; end,
50		handler = function()
51			return build_list("ui");
52		end
53		},
54		{
55		name = "effect",
56		label = "Effect",
57		description = "Change variables for shaders that belong to the 'Effect' category",
58		kind = "action",
59		submenu = true,
60		eval = function() return #build_list("effect") > 0; end,
61		handler = function()
62			return build_list("effect");
63		end
64		},
65		{
66		name = "rebuild",
67		description = "Recompile / Rescan the list of shaders",
68		label = "Reset",
69		kind = "action",
70		submenu = true,
71		handler = rebuild_query
72		}
73	};
74end
75