summaryrefslogtreecommitdiff
path: root/indra/newview/llluamanager.cpp
diff options
context:
space:
mode:
authorBrad Payne (Vir Linden) <vir@lindenlab.com>2023-09-14 20:43:45 +0100
committerBrad Payne (Vir Linden) <vir@lindenlab.com>2023-09-14 20:43:45 +0100
commit1d5db5e5926954b9f22469cd736d6cfb396491f4 (patch)
tree59d327ff1098dd69ab992a002e3654ef2f1ed42d /indra/newview/llluamanager.cpp
parent5b09d6372ff0900f67714af61bea100ee9a6d87b (diff)
DRTVWR-589 - LUA support for UI commands, only if no parameters
Diffstat (limited to 'indra/newview/llluamanager.cpp')
-rw-r--r--indra/newview/llluamanager.cpp18
1 files changed, 18 insertions, 0 deletions
diff --git a/indra/newview/llluamanager.cpp b/indra/newview/llluamanager.cpp
index edfd5c3cad..b251ebb6d5 100644
--- a/indra/newview/llluamanager.cpp
+++ b/indra/newview/llluamanager.cpp
@@ -38,6 +38,7 @@
#include "llviewermenu.h"
#include "llviewermenufile.h"
#include "llviewerwindow.h"
+#include "lluilistener.h"
#include <boost/algorithm/string/replace.hpp>
@@ -52,6 +53,9 @@ extern "C"
#pragma comment(lib, "liblua54.a")
#endif
+// FIXME extremely hacky way to get to the UI Listener framework. There's almost certainly a cleaner way.
+extern LLUIListener sUIListener;
+
int lua_printWarning(lua_State *L)
{
std::string msg(lua_tostring(L, 1));
@@ -163,6 +167,18 @@ int lua_env_setting_event(lua_State *L)
return 1;
}
+int lua_run_ui_command(lua_State *L)
+{
+ std::string func_name = lua_tostring(L,1);
+ LL_WARNS("LUA") << "running ui func " << func_name << LL_ENDL;
+ LLSD event;
+ event["function"] = func_name;
+ event["parameter"] = LLSD();
+ sUIListener.call(event);
+
+ return 1;
+}
+
bool checkLua(lua_State *L, int r, std::string &error_msg)
{
if (r != LUA_OK)
@@ -194,6 +210,8 @@ void initLUA(lua_State *L)
lua_register(L, "env_setting_event", lua_env_setting_event);
lua_register(L, "set_debug_setting_bool", lua_set_debug_setting_bool);
+
+ lua_register(L, "run_ui_command", lua_run_ui_command);
}
void LLLUAmanager::runScriptFile(const std::string &filename, script_finished_fn cb)