summaryrefslogtreecommitdiff
path: root/indra/newview/scripts
diff options
context:
space:
mode:
Diffstat (limited to 'indra/newview/scripts')
-rw-r--r--indra/newview/scripts/lua/require/UI.lua8
-rw-r--r--indra/newview/scripts/lua/test_LLChatListener.lua19
-rw-r--r--indra/newview/scripts/lua/test_toolbars.lua27
3 files changed, 50 insertions, 4 deletions
diff --git a/indra/newview/scripts/lua/require/UI.lua b/indra/newview/scripts/lua/require/UI.lua
index df77eb2b56..df76b1501c 100644
--- a/indra/newview/scripts/lua/require/UI.lua
+++ b/indra/newview/scripts/lua/require/UI.lua
@@ -150,6 +150,10 @@ function UI.addMenu(...)
return leap.request('UI', args)
end
+function UI.setMenuVisible(name, visible)
+ return leap.request('UI', {op='setMenuVisible', name=name, visible=visible})
+end
+
function UI.addMenuBranch(...)
local args = mapargs('name,label,parent_menu', ...)
args.op = 'addMenuBranch'
@@ -222,4 +226,8 @@ function UI.closeAllFloaters()
return leap.send("UI", {op = "closeAllFloaters"})
end
+function UI.getFloaterNames()
+ return leap.request("LLFloaterReg", {op = "getFloaterNames"}).floaters
+end
+
return UI
diff --git a/indra/newview/scripts/lua/test_LLChatListener.lua b/indra/newview/scripts/lua/test_LLChatListener.lua
index 18363ed43b..4a4d40bee5 100644
--- a/indra/newview/scripts/lua/test_LLChatListener.lua
+++ b/indra/newview/scripts/lua/test_LLChatListener.lua
@@ -1,11 +1,22 @@
local LLChatListener = require 'LLChatListener'
local LLChat = require 'LLChat'
-local leap = require 'leap'
+local UI = require 'UI'
+-- Chat listener script allows to use the following commands in Nearby chat:
+-- open inventory -- open defined floater by name
+-- close inventory -- close defined floater by name
+-- closeall -- close all floaters
+-- stop -- close the script
+-- any other messages will be echoed.
function openOrEcho(message)
- local floater_name = string.match(message, "^open%s+(%w+)")
- if floater_name then
- leap.send("LLFloaterReg", {name = floater_name, op = "showInstance"})
+ local open_floater_name = string.match(message, "^open%s+(%w+)")
+ local close_floater_name = string.match(message, "^close%s+(%w+)")
+ if open_floater_name then
+ UI.showFloater(open_floater_name)
+ elseif close_floater_name then
+ UI.hideFloater(close_floater_name)
+ elseif message == 'closeall' then
+ UI.closeAllFloaters()
else
LLChat.sendNearby('Echo: ' .. message)
end
diff --git a/indra/newview/scripts/lua/test_toolbars.lua b/indra/newview/scripts/lua/test_toolbars.lua
new file mode 100644
index 0000000000..70035db775
--- /dev/null
+++ b/indra/newview/scripts/lua/test_toolbars.lua
@@ -0,0 +1,27 @@
+popup = require 'popup'
+UI = require 'UI'
+
+local OK = 'OK_okcancelbuttons'
+local BUTTONS = UI.getToolbarBtnNames()
+
+-- Clear the toolbars and then add the toolbar buttons to the random toolbar
+response = popup:alertYesCancel('Toolbars will be randomly reshuffled. Proceed?')
+if next(response) == OK then
+ UI.clearToolbars()
+ math.randomseed(os.time())
+
+ -- add the buttons to the random toolbar
+ for i = 1, #BUTTONS do
+ UI.addToolbarBtn(BUTTONS[i], math.random(3))
+ end
+
+ -- remove some of the added buttons from the toolbars
+ for i = 1, #BUTTONS do
+ if math.random(100) < 30 then
+ UI.removeToolbarBtn(BUTTONS[i])
+ end
+ end
+ popup:tip('Toolbars were reshuffled')
+else
+ popup:tip('Canceled')
+end