diff options
-rw-r--r-- | indra/llui/llcommandmanager.cpp | 8 | ||||
-rw-r--r-- | indra/llui/llfloaterreg.cpp | 7 | ||||
-rw-r--r-- | indra/newview/lluilistener.cpp | 26 | ||||
-rw-r--r-- | indra/newview/scripts/lua/require/UI.lua | 8 | ||||
-rw-r--r-- | indra/newview/scripts/lua/test_toolbars.lua | 5 |
5 files changed, 29 insertions, 25 deletions
diff --git a/indra/llui/llcommandmanager.cpp b/indra/llui/llcommandmanager.cpp index 0c27e519dd..6c3e676c9b 100644 --- a/indra/llui/llcommandmanager.cpp +++ b/indra/llui/llcommandmanager.cpp @@ -32,6 +32,7 @@ #include "llcommandmanager.h" #include "lldir.h" #include "llerror.h" +#include "llsdutil.h" #include "llxuiparser.h" @@ -192,10 +193,5 @@ bool LLCommandManager::load() LLSD LLCommandManager::getCommandNames() { - LLSD cmd_names; - for (auto &it : mCommands) - { - cmd_names.append(it->name()); - } - return cmd_names; + return llsd::toArray(mCommands, [](const auto &cmd) { return cmd->name(); }); } diff --git a/indra/llui/llfloaterreg.cpp b/indra/llui/llfloaterreg.cpp index a9ed678973..8f9268ffcb 100644 --- a/indra/llui/llfloaterreg.cpp +++ b/indra/llui/llfloaterreg.cpp @@ -610,10 +610,5 @@ U32 LLFloaterReg::getVisibleFloaterInstanceCount() LLSD LLFloaterReg::getFloaterNames() { - LLSD names; - for (auto &it : sGroupMap) - { - names.append(it.first); - } - return names; + return llsd::toArray(sGroupMap, [](const auto &pair) { return pair.first; }); } diff --git a/indra/newview/lluilistener.cpp b/indra/newview/lluilistener.cpp index bcc13c5fe9..3e67531388 100644 --- a/indra/newview/lluilistener.cpp +++ b/indra/newview/lluilistener.cpp @@ -106,23 +106,24 @@ LLUIListener::LLUIListener(): llsd::map("name", LLSD(), "visible", LLSD(), "reply", LLSD())); add("defaultToolbars", - "todo: defaultToolbars desc", + "Restore default toolbar buttons", &LLUIListener::restoreDefaultToolbars); - add("clearToolbars", + add("clearAllToolbars", "Clear all buttons off the toolbars", &LLUIListener::clearAllToolbars); add("addToolbarBtn", - "Add [\"btn_name\"] toolbar button to the [\"toolbar\"]\n" - "[1 (left toolbar), 2 (right toolbar), 3 (bottom toolbar)]\n" + "Add [\"btn_name\"] toolbar button to the [\"toolbar\"]:\n" + "\"left\", \"right\", \"bottom\" (default is \"bottom\")\n" "Position of the command in the original list can be specified as [\"rank\"]", &LLUIListener::addToolbarBtn, llsd::map("btn_name", LLSD(), "reply", LLSD())); add("removeToolbarBtn", "Remove [\"btn_name\"] toolbar button off the toolbar,\n" - "return [\"rank\"] (old position) of the command in the original list", + "return [\"rank\"] (old position) of the command in the original list,\n" + "rank -1 means that [\"btn_name\"] was not found", &LLUIListener::removeToolbarBtn, llsd::map("btn_name", LLSD(), "reply", LLSD())); @@ -347,9 +348,20 @@ void LLUIListener::addToolbarBtn(const LLSD &event) const ToolBarLocation toolbar = ToolBarLocation::TOOLBAR_BOTTOM; if (event.has("toolbar")) { - toolbar = llclamp((ToolBarLocation)event["toolbar"].asInteger(), ToolBarLocation::TOOLBAR_NONE, ToolBarLocation::TOOLBAR_BOTTOM); + if (event["toolbar"] == "left") + { + toolbar = ToolBarLocation::TOOLBAR_LEFT; + } + else if (event["toolbar"] == "right") + { + toolbar = ToolBarLocation::TOOLBAR_RIGHT; + } + else if (event["toolbar"] != "bottom") + { + return response.error(stringize("Toolbar name ", std::quoted(event["toolbar"].asString()), " is not correct. Toolbar names are: left, right, bottom")); + } } - S32 rank = event.has("rank") ? event["rank"].asInteger() : - 1; + S32 rank = event.has("rank") ? event["rank"].asInteger() : LLToolBar::RANK_NONE; if(!gToolBarView->addCommand(event["btn_name"].asString(), toolbar, rank)) { response.error(stringize("Toolbar button ", std::quoted(event["btn_name"].asString()), " was not found")); diff --git a/indra/newview/scripts/lua/require/UI.lua b/indra/newview/scripts/lua/require/UI.lua index df76b1501c..9bc9a3685d 100644 --- a/indra/newview/scripts/lua/require/UI.lua +++ b/indra/newview/scripts/lua/require/UI.lua @@ -177,8 +177,8 @@ end -- Toolbar buttons -- *************************************************************************** -- Clears all buttons off the toolbars -function UI.clearToolbars() - leap.send('UI', {op='clearToolbars'}) +function UI.clearAllToolbars() + leap.send('UI', {op='clearAllToolbars'}) end function UI.defaultToolbars() @@ -186,8 +186,8 @@ function UI.defaultToolbars() end -- UI.addToolbarBtn{btn_name=btn_name --- [, toolbar= 3] -- 1 [TOOLBAR_LEFT], 2 [TOOLBAR_RIGHT], 3 [TOOLBAR_BOTTOM] --- [, rank=1]} -- position on the toolbar +-- [, 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' diff --git a/indra/newview/scripts/lua/test_toolbars.lua b/indra/newview/scripts/lua/test_toolbars.lua index 70035db775..9a832c5644 100644 --- a/indra/newview/scripts/lua/test_toolbars.lua +++ b/indra/newview/scripts/lua/test_toolbars.lua @@ -3,16 +3,17 @@ 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.clearToolbars() + UI.clearAllToolbars() math.randomseed(os.time()) -- add the buttons to the random toolbar for i = 1, #BUTTONS do - UI.addToolbarBtn(BUTTONS[i], math.random(3)) + UI.addToolbarBtn(BUTTONS[i], TOOLBARS[math.random(3)]) end -- remove some of the added buttons from the toolbars |