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/popup.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/popup.lua')
-rw-r--r-- | indra/newview/scripts/lua/require/UI/popup.lua | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/indra/newview/scripts/lua/require/UI/popup.lua b/indra/newview/scripts/lua/require/UI/popup.lua new file mode 100644 index 0000000000..3aaadf85ba --- /dev/null +++ b/indra/newview/scripts/lua/require/UI/popup.lua @@ -0,0 +1,53 @@ +local leap = require 'leap' +local mapargs = require 'mapargs' + +-- notification is any name defined in notifications.xml as +-- <notification name=> +-- vars is a table providing values for [VAR] substitution keys in the +-- notification body +-- payload prepopulates the response table +-- wait=false means fire and forget, otherwise wait for user response +local popup_meta = { + -- setting this function as getmetatable(popup).__call() means this gets + -- called when a consumer calls popup(notification, vars, payload) + __call = function(self, ...) + local args = mapargs('notification,vars,payload,wait', ...) + -- we use convenience argument names different from 'LLNotifications' + -- listener + args.name = args.notification + args.notification = nil + args.substitutions = args.vars + args.vars = nil + local wait = args.wait + args.wait = nil + args.op = 'requestAdd' + -- Specifically test (wait == false), NOT (not wait), because we treat + -- nil (omitted, default true) differently than false (explicitly + -- DON'T wait). + if wait == false then + leap.send('LLNotifications', args) + else + return leap.request('LLNotifications', args).response + end + end +} + +local popup = setmetatable({}, popup_meta) + +function popup:alert(message) + return self('GenericAlert', {MESSAGE=message}) +end + +function popup:alertOK(message) + return self('GenericAlertOK', {MESSAGE=message}) +end + +function popup:alertYesCancel(message) + return self('GenericAlertYesCancel', {MESSAGE=message}) +end + +function popup:tip(message) + self{'SystemMessageTip', {MESSAGE=message}, wait=false} +end + +return popup |