diff options
author | Nat Goodspeed <nat@lindenlab.com> | 2024-08-23 20:55:22 -0400 |
---|---|---|
committer | Nat Goodspeed <nat@lindenlab.com> | 2024-08-23 20:55:22 -0400 |
commit | e4a710296943674573be800f5233b24214440929 (patch) | |
tree | 26440adfa5822be86d6d217b2796d532fda20e1f /indra/newview/scripts/lua/require/UI.lua | |
parent | a80b9487dc7c893f5e96f48f15140a5f82b99e30 (diff) |
Look for lazy UI submodules in a require/UI subdirectory.
This way encourages "UI = require 'UI'; UI.Floater"
instead of just "Floater = require 'Floater'".
Moreover, now we don't need UI to maintain a list of allowed submodules;
that's effected by membership in the subdirectory.
Diffstat (limited to 'indra/newview/scripts/lua/require/UI.lua')
-rw-r--r-- | indra/newview/scripts/lua/require/UI.lua | 12 |
1 files changed, 3 insertions, 9 deletions
diff --git a/indra/newview/scripts/lua/require/UI.lua b/indra/newview/scripts/lua/require/UI.lua index 969a2cbded..2df70fd453 100644 --- a/indra/newview/scripts/lua/require/UI.lua +++ b/indra/newview/scripts/lua/require/UI.lua @@ -5,17 +5,11 @@ local mapargs = require 'mapargs' local Timer = (require 'timers').Timer local util = require 'util' --- Allow lazily accessing certain other modules on demand, e.g. a reference to --- UI.Floater lazily loads the Floater module. Use of UI's __index metamethod --- theoretically permits any other module you can require() to appear as a --- submodule of UI, but it doesn't make sense to support (e.g.) UI.Queue. -local submods = { 'Floater', 'popup' } +-- Allow lazily accessing UI submodules on demand, e.g. a reference to +-- UI.Floater lazily loads the UI/Floater module. local UI = util.setmetamethods{ __index=function(t, key) - if not table.find(submods, key) then - error(`Invalid UI submodule {key}`, 2) - end - local mod = require(key) + local mod = require('UI/' .. key) -- cache the submodule t[key] = mod return mod |