summaryrefslogtreecommitdiff
path: root/indra/newview/scripts
diff options
context:
space:
mode:
authorNat Goodspeed <nat@lindenlab.com>2024-08-07 10:14:50 -0400
committerNat Goodspeed <nat@lindenlab.com>2024-08-07 10:14:50 -0400
commitb213a07a77d7a0ab0d4a092a213d0e31b6611ace (patch)
tree4ee1d85365365c0e6b0007e1beb082875abc0669 /indra/newview/scripts
parentda30bd882dd8fbf33215726efd90e53209481f1c (diff)
parentf8c70f4855b4163c82aa7c2e0cc07a5cd81a206f (diff)
Merge branch 'release/luau-scripting' into viewer-lua-smoother
Diffstat (limited to 'indra/newview/scripts')
-rw-r--r--indra/newview/scripts/lua/require/UI.lua61
-rw-r--r--indra/newview/scripts/lua/test_LLChatListener.lua19
-rw-r--r--indra/newview/scripts/lua/test_luafloater_demo.lua (renamed from indra/newview/scripts/lua/test_luafloater_demo2.lua)0
-rw-r--r--indra/newview/scripts/lua/test_luafloater_gesture_list.lua (renamed from indra/newview/scripts/lua/test_luafloater_gesture_list2.lua)0
-rw-r--r--indra/newview/scripts/lua/test_toolbars.lua28
5 files changed, 104 insertions, 4 deletions
diff --git a/indra/newview/scripts/lua/require/UI.lua b/indra/newview/scripts/lua/require/UI.lua
index 06b49c6269..9bc9a3685d 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'
@@ -169,4 +173,61 @@ function UI.addMenuSeparator(...)
return leap.request('UI', args)
end
+-- ***************************************************************************
+-- Toolbar buttons
+-- ***************************************************************************
+-- Clears all buttons off the toolbars
+function UI.clearAllToolbars()
+ leap.send('UI', {op='clearAllToolbars'})
+end
+
+function UI.defaultToolbars()
+ leap.send('UI', {op='defaultToolbars'})
+end
+
+-- UI.addToolbarBtn{btn_name=btn_name
+-- [, toolbar= bottom] -- left, right, bottom -- default is bottom
+-- [, rank=1]} -- position on the toolbar, starts at 0 (0 - first position, 1 - second position etc.)
+function UI.addToolbarBtn(...)
+ local args = mapargs('btn_name,toolbar,rank', ...)
+ args.op = 'addToolbarBtn'
+ return leap.request('UI', args)
+end
+
+-- Returns the rank(position) of the command in the original list
+function UI.removeToolbarBtn(btn_name)
+ return leap.request('UI', {op = 'removeToolbarBtn', btn_name=btn_name}).rank
+end
+
+function UI.getToolbarBtnNames()
+ return leap.request('UI', {op = 'getToolbarBtnNames'}).cmd_names
+end
+
+-- ***************************************************************************
+-- Floaters
+-- ***************************************************************************
+function UI.showFloater(floater_name)
+ leap.send("LLFloaterReg", {op = "showInstance", name = floater_name})
+end
+
+function UI.hideFloater(floater_name)
+ leap.send("LLFloaterReg", {op = "hideInstance", name = floater_name})
+end
+
+function UI.toggleFloater(floater_name)
+ leap.send("LLFloaterReg", {op = "toggleInstance", name = floater_name})
+end
+
+function UI.isFloaterVisible(floater_name)
+ return leap.request("LLFloaterReg", {op = "instanceVisible", name = floater_name}).visible
+end
+
+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_luafloater_demo2.lua b/indra/newview/scripts/lua/test_luafloater_demo.lua
index 3903d01e65..3903d01e65 100644
--- a/indra/newview/scripts/lua/test_luafloater_demo2.lua
+++ b/indra/newview/scripts/lua/test_luafloater_demo.lua
diff --git a/indra/newview/scripts/lua/test_luafloater_gesture_list2.lua b/indra/newview/scripts/lua/test_luafloater_gesture_list.lua
index bd397ef2a6..bd397ef2a6 100644
--- a/indra/newview/scripts/lua/test_luafloater_gesture_list2.lua
+++ b/indra/newview/scripts/lua/test_luafloater_gesture_list.lua
diff --git a/indra/newview/scripts/lua/test_toolbars.lua b/indra/newview/scripts/lua/test_toolbars.lua
new file mode 100644
index 0000000000..9a832c5644
--- /dev/null
+++ b/indra/newview/scripts/lua/test_toolbars.lua
@@ -0,0 +1,28 @@
+popup = require 'popup'
+UI = require 'UI'
+
+local OK = 'OK_okcancelbuttons'
+local BUTTONS = UI.getToolbarBtnNames()
+local TOOLBARS = {'left','right','bottom'}
+
+-- 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.clearAllToolbars()
+ math.randomseed(os.time())
+
+ -- add the buttons to the random toolbar
+ for i = 1, #BUTTONS do
+ UI.addToolbarBtn(BUTTONS[i], TOOLBARS[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