From 50d60c2518710e92cff05b806624b11ac714369f Mon Sep 17 00:00:00 2001 From: Maxim Nikolenko Date: Wed, 17 Jul 2024 16:46:00 +0300 Subject: Lua api for adding new menu items to the Top menu --- indra/newview/scripts/lua/require/UI.lua | 28 ++++++++++++++++++++++++ indra/newview/scripts/lua/test_top_menu.lua | 34 +++++++++++++++++++++++++++++ 2 files changed, 62 insertions(+) create mode 100644 indra/newview/scripts/lua/test_top_menu.lua (limited to 'indra/newview/scripts') diff --git a/indra/newview/scripts/lua/require/UI.lua b/indra/newview/scripts/lua/require/UI.lua index 1eee4657f4..28488ff3e1 100644 --- a/indra/newview/scripts/lua/require/UI.lua +++ b/indra/newview/scripts/lua/require/UI.lua @@ -135,4 +135,32 @@ function UI.snapshot(...) args.op = 'saveSnapshot' return leap.request('LLViewerWindow', args).result end + +-- *************************************************************************** +-- Top menu +-- *************************************************************************** + +function UI.addMenu(...) + local args = mapargs('name,label', ...) + args.op = 'addMenu' + return leap.request('UI', args) +end + +function UI.addMenuBranch(...) + local args = mapargs('name,label,parent_menu', ...) + args.op = 'addMenuBranch' + return leap.request('UI', args) +end + +function UI.addMenuItem(...) + local args = mapargs('name,label,parent_menu,func,param', ...) + args.op = 'addMenuItem' + return leap.request('UI', args) +end + +function UI.addMenuSeparator(...) + local args = mapargs('parent_menu', ...) + args.op = 'addMenuSeparator' + return leap.request('UI', args) +end return UI diff --git a/indra/newview/scripts/lua/test_top_menu.lua b/indra/newview/scripts/lua/test_top_menu.lua new file mode 100644 index 0000000000..780a384c92 --- /dev/null +++ b/indra/newview/scripts/lua/test_top_menu.lua @@ -0,0 +1,34 @@ +UI = require 'UI' + +--Add new drop-down 'LUA Menu' to the Top menu. +local MENU_NAME = "lua_menu" +UI.addMenu{name=MENU_NAME,label="LUA Menu"} + +--Add two new menu items to the 'LUA Menu': 'Debug console' and 'Scripts' +UI.addMenuItem{name="lua_debug",label="Debug console", + param="lua_debug", + func="Floater.ToggleOrBringToFront", + parent_menu=MENU_NAME} + +UI.addMenuItem{name="lua_scripts",label="Scripts", + param="lua_scripts", + func="Floater.ToggleOrBringToFront", + parent_menu=MENU_NAME} + +--Add menu separator to the 'LUA Menu' under added menu items +UI.addMenuSeparator{parent_menu=MENU_NAME} + +--Add two new menu branch 'About...' to the 'LUA Menu' +local BRANCH_NAME = "about_branch" +UI.addMenuBranch{name="about_branch",label="About...",parent_menu=MENU_NAME} + +--Add two new menu items to the 'About...' branch +UI.addMenuItem{name="lua_info",label="Lua...", + param="https://www.lua.org/about.html", + func="Advanced.ShowURL", + parent_menu=BRANCH_NAME} + +UI.addMenuItem{name="lua_info",label="Luau...", + param="https://luau-lang.org/", + func="Advanced.ShowURL", + parent_menu=BRANCH_NAME} -- cgit v1.2.3 From decc2d3aa5ba8dc583dae5396a5ae8ca738412dd Mon Sep 17 00:00:00 2001 From: Mnikolenko Productengine Date: Thu, 25 Jul 2024 18:15:24 +0300 Subject: Lua api for Follow Camera control --- .../scripts/lua/luafloater_camera_control.xml | 244 +++++++++++++++++++++ indra/newview/scripts/lua/require/LLAgent.lua | 28 +++ indra/newview/scripts/lua/test_camera_control.lua | 52 +++++ 3 files changed, 324 insertions(+) create mode 100644 indra/newview/scripts/lua/luafloater_camera_control.xml create mode 100644 indra/newview/scripts/lua/require/LLAgent.lua create mode 100644 indra/newview/scripts/lua/test_camera_control.lua (limited to 'indra/newview/scripts') diff --git a/indra/newview/scripts/lua/luafloater_camera_control.xml b/indra/newview/scripts/lua/luafloater_camera_control.xml new file mode 100644 index 0000000000..0601a363e5 --- /dev/null +++ b/indra/newview/scripts/lua/luafloater_camera_control.xml @@ -0,0 +1,244 @@ + + + + Camera position: + + + + + + + + + + Focus position: + + + + + + + + + + Lock: + + + + + + + diff --git a/indra/newview/scripts/lua/require/LLAgent.lua b/indra/newview/scripts/lua/require/LLAgent.lua new file mode 100644 index 0000000000..7c6a842555 --- /dev/null +++ b/indra/newview/scripts/lua/require/LLAgent.lua @@ -0,0 +1,28 @@ +local leap = require 'leap' +local mapargs = require 'mapargs' + +local LLAgent = {} + +function LLAgent.getRegionPosition() + return leap.request('LLAgent', {op = 'getPosition'}).region +end + +function LLAgent.getGlobalPosition() + return leap.request('LLAgent', {op = 'getPosition'}).global +end + +function LLAgent.setCamera(...) + local args = mapargs('camera_pos,focus_pos,focus_offset,camera_locked,focus_locked', ...) + args.op = 'setCameraParams' + leap.send('LLAgent', args) +end + +function LLAgent.setFollowCamActive(active) + leap.send('LLAgent', {op = 'setFollowCamActive', active = active}) +end + +function LLAgent.removeCamParams() + leap.send('LLAgent', {op = 'removeCameraParams'}) +end + +return LLAgent diff --git a/indra/newview/scripts/lua/test_camera_control.lua b/indra/newview/scripts/lua/test_camera_control.lua new file mode 100644 index 0000000000..db76201932 --- /dev/null +++ b/indra/newview/scripts/lua/test_camera_control.lua @@ -0,0 +1,52 @@ +local Floater = require 'Floater' +local LLAgent = require 'LLAgent' +local leap = require 'leap' +local startup = require 'startup' +local inspect = require 'inspect' + +local flt = Floater('luafloater_camera_control.xml') + +function getValue(ctrl_name) + return flt:request({action="get_value", ctrl_name=ctrl_name}).value +end + +function setValue(ctrl_name, value) + flt:post({action="set_value", ctrl_name=ctrl_name, value=value}) +end + +function flt:commit_update_btn(event_data) + lock_focus = getValue('lock_focus_ctrl') + lock_camera = self:request({action="get_value", ctrl_name='lock_camera_ctrl'}).value + + local camera_pos = {getValue('cam_x'),getValue('cam_y'),getValue('cam_z')} + local focus_pos = {getValue('focus_x'),getValue('focus_y'),getValue('focus_z')} + + + LLAgent.setCamera{camera_pos=camera_pos,focus_pos=focus_pos, + focus_locked = lock_focus,camera_locked = lock_camera} + + self:post({action="add_text", ctrl_name="events_editor", + value = {'Updating FollowCam params', 'camera_pos:', camera_pos, 'focus_pos:', focus_pos, 'lock_focus:', lock_focus, 'lock_camera:', lock_camera}}) +end + +function flt:commit_agent_cam_btn(event_data) + agent_pos = LLAgent.getRegionPosition() + setValue('cam_x', math.floor(agent_pos[1])) + setValue('cam_y', math.floor(agent_pos[2])) + setValue('cam_z', math.floor(agent_pos[3])) +end + +function flt:commit_agent_focus_btn(event_data) + agent_pos = LLAgent.getRegionPosition() + setValue('focus_x', math.floor(agent_pos[1])) + setValue('focus_y', math.floor(agent_pos[2])) + setValue('focus_z', math.floor(agent_pos[3])) +end + +function flt:commit_reset_btn(event_data) + LLAgent.removeCamParams() + LLAgent.setFollowCamActive(false) +end + +startup.wait('STATE_LOGIN_WAIT') +flt:show() -- cgit v1.2.3 From 4edcebdb31b7d49faf94b60a66c9921e90e23899 Mon Sep 17 00:00:00 2001 From: Mnikolenko Productengine Date: Thu, 25 Jul 2024 18:29:06 +0300 Subject: Script clean up --- indra/newview/scripts/lua/test_camera_control.lua | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) (limited to 'indra/newview/scripts') diff --git a/indra/newview/scripts/lua/test_camera_control.lua b/indra/newview/scripts/lua/test_camera_control.lua index db76201932..e7ad69b473 100644 --- a/indra/newview/scripts/lua/test_camera_control.lua +++ b/indra/newview/scripts/lua/test_camera_control.lua @@ -1,8 +1,6 @@ local Floater = require 'Floater' local LLAgent = require 'LLAgent' -local leap = require 'leap' local startup = require 'startup' -local inspect = require 'inspect' local flt = Floater('luafloater_camera_control.xml') @@ -16,17 +14,16 @@ end function flt:commit_update_btn(event_data) lock_focus = getValue('lock_focus_ctrl') - lock_camera = self:request({action="get_value", ctrl_name='lock_camera_ctrl'}).value + lock_camera = getValue('lock_camera_ctrl') + local camera_pos = {getValue('cam_x'), getValue('cam_y'), getValue('cam_z')} + local focus_pos = {getValue('focus_x'), getValue('focus_y'), getValue('focus_z')} - local camera_pos = {getValue('cam_x'),getValue('cam_y'),getValue('cam_z')} - local focus_pos = {getValue('focus_x'),getValue('focus_y'),getValue('focus_z')} - - - LLAgent.setCamera{camera_pos=camera_pos,focus_pos=focus_pos, - focus_locked = lock_focus,camera_locked = lock_camera} + LLAgent.setCamera{camera_pos=camera_pos, focus_pos=focus_pos, + focus_locked=lock_focus, camera_locked=lock_camera} self:post({action="add_text", ctrl_name="events_editor", - value = {'Updating FollowCam params', 'camera_pos:', camera_pos, 'focus_pos:', focus_pos, 'lock_focus:', lock_focus, 'lock_camera:', lock_camera}}) + value = {'Updating FollowCam params', 'camera_pos:', camera_pos, 'focus_pos:', focus_pos, + 'lock_focus:', lock_focus, 'lock_camera:', lock_camera}}) end function flt:commit_agent_cam_btn(event_data) -- cgit v1.2.3 From 41ea8a61c247d915ebe53436e9cfc999a712b692 Mon Sep 17 00:00:00 2001 From: Mnikolenko Productengine Date: Fri, 26 Jul 2024 15:55:17 +0300 Subject: Add api for more script camera params --- indra/newview/scripts/lua/require/LLAgent.lua | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 'indra/newview/scripts') diff --git a/indra/newview/scripts/lua/require/LLAgent.lua b/indra/newview/scripts/lua/require/LLAgent.lua index 7c6a842555..bc9a6b23a0 100644 --- a/indra/newview/scripts/lua/require/LLAgent.lua +++ b/indra/newview/scripts/lua/require/LLAgent.lua @@ -11,8 +11,25 @@ function LLAgent.getGlobalPosition() return leap.request('LLAgent', {op = 'getPosition'}).global end +-- Use LL.leaphelp('LLAgent') and see 'setCameraParams' to get more info about params +-- -- TYPE -- DEFAULT -- RANGE +-- LLAgent.setCamera{ [, camera_pos] -- vector3 +-- [, focus_pos] -- vector3 +-- [, focus_offset] -- vector3 -- {1,0,0} -- {-10,-10,-10} to {10,10,10} +-- [, distance] -- float (meters) -- 3 -- 0.5 to 50 +-- [, focus_threshold] -- float (meters) -- 1 -- 0 to 4 +-- [, camera_threshold] -- float (meters) -- 1 -- 0 to 4 +-- [, focus_lag] -- float (seconds) -- 0.1 -- 0 to 3 +-- [, camera_lag] -- float (seconds) -- 0.1 -- 0 to 3 +-- [, camera_pitch] -- float (degrees) -- 0 -- -45 to 80 +-- [, behindness_angle] -- float (degrees) -- 10 -- 0 to 180 +-- [, behindness_lag] -- float (seconds) -- 0 -- 0 to 3 +-- [, camera_locked] -- bool -- false +-- [, focus_locked]} -- bool -- false function LLAgent.setCamera(...) - local args = mapargs('camera_pos,focus_pos,focus_offset,camera_locked,focus_locked', ...) + local args = mapargs('camera_pos,focus_pos,focus_offset,focus_lag,camera_lag,' .. + 'distance,focus_threshold,camera_threshold,camera_pitch,' .. + 'camera_locked,focus_locked,behindness_angle,behindness_lag', ...) args.op = 'setCameraParams' leap.send('LLAgent', args) end -- cgit v1.2.3 From ffeb738afda99fca98a9c1ba7704d7f6144da70c Mon Sep 17 00:00:00 2001 From: nat-goodspeed Date: Wed, 31 Jul 2024 06:30:19 -0400 Subject: Represent the many "LLAgent" "setCameraParams" args in an array. This encapsulates the boilerplate associated with passing each distinct parameter to its corresponding LLFollowCamMgr method. --- indra/newview/scripts/lua/test_camera_control.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/newview/scripts') diff --git a/indra/newview/scripts/lua/test_camera_control.lua b/indra/newview/scripts/lua/test_camera_control.lua index e7ad69b473..9b35cdf8cd 100644 --- a/indra/newview/scripts/lua/test_camera_control.lua +++ b/indra/newview/scripts/lua/test_camera_control.lua @@ -45,5 +45,5 @@ function flt:commit_reset_btn(event_data) LLAgent.setFollowCamActive(false) end -startup.wait('STATE_LOGIN_WAIT') +startup.wait('STATE_STARTED') flt:show() -- cgit v1.2.3 From fdb7207aa0d1f25ed3e14fbc4e8615e8383e508c Mon Sep 17 00:00:00 2001 From: Nat Goodspeed Date: Thu, 1 Aug 2024 16:52:44 -0400 Subject: Add UI.callables() and corresponding entry point. --- indra/newview/scripts/lua/require/UI.lua | 6 ++++++ indra/newview/scripts/lua/test_callables.lua | 6 ++++++ 2 files changed, 12 insertions(+) create mode 100644 indra/newview/scripts/lua/test_callables.lua (limited to 'indra/newview/scripts') diff --git a/indra/newview/scripts/lua/require/UI.lua b/indra/newview/scripts/lua/require/UI.lua index 28488ff3e1..06b49c6269 100644 --- a/indra/newview/scripts/lua/require/UI.lua +++ b/indra/newview/scripts/lua/require/UI.lua @@ -14,6 +14,10 @@ function UI.call(func, parameter) leap.request('UI', {op='call', ['function']=func, parameter=parameter}) end +function UI.callables() + return leap.request('UI', {op='callables'}).callables +end + function UI.getValue(path) return leap.request('UI', {op='getValue', path=path})['value'] end @@ -152,6 +156,7 @@ function UI.addMenuBranch(...) return leap.request('UI', args) end +-- see UI.callables() for valid values of 'func' function UI.addMenuItem(...) local args = mapargs('name,label,parent_menu,func,param', ...) args.op = 'addMenuItem' @@ -163,4 +168,5 @@ function UI.addMenuSeparator(...) args.op = 'addMenuSeparator' return leap.request('UI', args) end + return UI diff --git a/indra/newview/scripts/lua/test_callables.lua b/indra/newview/scripts/lua/test_callables.lua new file mode 100644 index 0000000000..1bee062db8 --- /dev/null +++ b/indra/newview/scripts/lua/test_callables.lua @@ -0,0 +1,6 @@ +startup=require 'startup' +UI=require 'UI' +startup.wait('STATE_LOGIN_WAIT') +for _, cbl in pairs(UI.callables()) do + print(`{cbl.name} ({cbl.access})`) +end -- cgit v1.2.3