summaryrefslogtreecommitdiff
path: root/indra
diff options
context:
space:
mode:
Diffstat (limited to 'indra')
-rw-r--r--indra/llui/llfloaterreg.cpp10
-rw-r--r--indra/llui/llfloaterreg.h2
-rw-r--r--indra/llui/llfloaterreglistener.cpp11
-rw-r--r--indra/llui/llfloaterreglistener.h1
-rw-r--r--indra/newview/lluilistener.cpp16
-rw-r--r--indra/newview/lluilistener.h1
-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
9 files changed, 91 insertions, 4 deletions
diff --git a/indra/llui/llfloaterreg.cpp b/indra/llui/llfloaterreg.cpp
index 989ce12d09..a9ed678973 100644
--- a/indra/llui/llfloaterreg.cpp
+++ b/indra/llui/llfloaterreg.cpp
@@ -607,3 +607,13 @@ U32 LLFloaterReg::getVisibleFloaterInstanceCount()
return count;
}
+
+LLSD LLFloaterReg::getFloaterNames()
+{
+ LLSD names;
+ for (auto &it : sGroupMap)
+ {
+ names.append(it.first);
+ }
+ return names;
+}
diff --git a/indra/llui/llfloaterreg.h b/indra/llui/llfloaterreg.h
index 43f3f7b170..31a334b89c 100644
--- a/indra/llui/llfloaterreg.h
+++ b/indra/llui/llfloaterreg.h
@@ -153,6 +153,8 @@ public:
static void blockShowFloaters(bool value) { sBlockShowFloaters = value;}
static U32 getVisibleFloaterInstanceCount();
+
+ static LLSD getFloaterNames();
};
#endif
diff --git a/indra/llui/llfloaterreglistener.cpp b/indra/llui/llfloaterreglistener.cpp
index 8316101264..e17f9f4dd6 100644
--- a/indra/llui/llfloaterreglistener.cpp
+++ b/indra/llui/llfloaterreglistener.cpp
@@ -80,6 +80,11 @@ LLFloaterRegListener::LLFloaterRegListener():
add("getFloaterEvents",
"Return the table of Lua Floater events which are send to the script",
&LLFloaterRegListener::getLuaFloaterEvents);
+
+ add("getFloaterNames",
+ "Return the table of all registered floaters",
+ &LLFloaterRegListener::getFloaterNames,
+ llsd::map("reply", LLSD()));
}
void LLFloaterRegListener::getBuildMap(const LLSD& event) const
@@ -121,6 +126,12 @@ void LLFloaterRegListener::instanceVisible(const LLSD& event) const
event);
}
+
+void LLFloaterRegListener::getFloaterNames(const LLSD &event) const
+{
+ Response response(llsd::map("floaters", LLFloaterReg::getFloaterNames()), event);
+}
+
void LLFloaterRegListener::clickButton(const LLSD& event) const
{
// If the caller requests a reply, build the reply.
diff --git a/indra/llui/llfloaterreglistener.h b/indra/llui/llfloaterreglistener.h
index 9cb0af2de5..2165b1b62f 100644
--- a/indra/llui/llfloaterreglistener.h
+++ b/indra/llui/llfloaterreglistener.h
@@ -49,6 +49,7 @@ private:
void toggleInstance(const LLSD& event) const;
void instanceVisible(const LLSD& event) const;
void clickButton(const LLSD& event) const;
+ void getFloaterNames(const LLSD &event) const;
void getLuaFloaterEvents(const LLSD &event) const;
};
diff --git a/indra/newview/lluilistener.cpp b/indra/newview/lluilistener.cpp
index 07a8b45f89..bcc13c5fe9 100644
--- a/indra/newview/lluilistener.cpp
+++ b/indra/newview/lluilistener.cpp
@@ -100,6 +100,11 @@ LLUIListener::LLUIListener():
&LLUIListener::addMenuSeparator,
llsd::map("parent_menu", LLSD(), "reply", LLSD()));
+ add("setMenuVisible",
+ "Set menu [\"name\"] visibility to [\"visible\"]",
+ &LLUIListener::setMenuVisible,
+ llsd::map("name", LLSD(), "visible", LLSD(), "reply", LLSD()));
+
add("defaultToolbars",
"todo: defaultToolbars desc",
&LLUIListener::restoreDefaultToolbars);
@@ -313,6 +318,17 @@ void LLUIListener::addMenuSeparator(const LLSD&event) const
}
}
+void LLUIListener::setMenuVisible(const LLSD &event) const
+{
+ Response response(LLSD(), event);
+ std::string menu_name(event["name"]);
+ if (!gMenuBarView->getItem(menu_name))
+ {
+ return response.error(stringize("Menu ", std::quoted(menu_name), " was not found"));
+ }
+ gMenuBarView->setItemVisible(menu_name, event["visible"].asBoolean());
+}
+
void LLUIListener::restoreDefaultToolbars(const LLSD &event) const
{
LLToolBarView::loadDefaultToolbars();
diff --git a/indra/newview/lluilistener.h b/indra/newview/lluilistener.h
index bae6724b3d..98e4754306 100644
--- a/indra/newview/lluilistener.h
+++ b/indra/newview/lluilistener.h
@@ -49,6 +49,7 @@ private:
void addMenuBranch(const LLSD&event) const;
void addMenuItem(const LLSD&event) const;
void addMenuSeparator(const LLSD&event) const;
+ void setMenuVisible(const LLSD &event) const;
void restoreDefaultToolbars(const LLSD &event) const;
void clearAllToolbars(const LLSD &event) const;
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