diff options
author | Mnikolenko Productengine <mnikolenko@productengine.com> | 2024-01-30 15:44:08 +0200 |
---|---|---|
committer | Mnikolenko Productengine <mnikolenko@productengine.com> | 2024-01-31 15:03:09 +0200 |
commit | ab1f2c2f6f9b854b95db3733fd6ff6d02e677ebd (patch) | |
tree | b0f26efa5983c67a4c93920ea463fdcafb574dd5 /indra/newview | |
parent | 2acb8bdf937dda337a591caa227d604efec5ca4a (diff) |
strip lua testing functions
Diffstat (limited to 'indra/newview')
-rw-r--r-- | indra/newview/llluamanager.cpp | 443 |
1 files changed, 1 insertions, 442 deletions
diff --git a/indra/newview/llluamanager.cpp b/indra/newview/llluamanager.cpp index 09ca6e10a7..3e3ce45cb0 100644 --- a/indra/newview/llluamanager.cpp +++ b/indra/newview/llluamanager.cpp @@ -40,22 +40,8 @@ // skip all these link dependencies for integration testing #ifndef LL_TEST -#include "llagent.h" -#include "llappearancemgr.h" -#include "llcallbacklist.h" -#include "llfloaterreg.h" -#include "llfloaterimnearbychat.h" -#include "llfloatersidepanelcontainer.h" -#include "llnotificationsutil.h" -#include "llvoavatarself.h" -#include "llviewermenu.h" -#include "llviewermenufile.h" -#include "llviewerwindow.h" #include "lluilistener.h" -#include "llanimationstates.h" -#include "llinventoryfunctions.h" -#include "lltoolplacer.h" -#include "llviewerregion.h" +#include "llviewercontrol.h" // FIXME extremely hacky way to get to the UI Listener framework. There's // a cleaner way. @@ -369,433 +355,6 @@ lua_function(print_warning) } #ifndef LL_TEST -lua_function(avatar_sit) -{ - gAgent.sitDown(); - return 0; -} - -lua_function(avatar_stand) -{ - gAgent.standUp(); - return 0; -} - -lua_function(nearby_chat_send) -{ - std::string msg(lua_tostring(L, 1)); - LLFloaterIMNearbyChat *nearby_chat = LLFloaterReg::findTypedInstance<LLFloaterIMNearbyChat>("nearby_chat"); - nearby_chat->sendChatFromViewer(msg, CHAT_TYPE_NORMAL, gSavedSettings.getBOOL("PlayChatAnim")); - - lua_pop(L, 1); - return 0; -} - -lua_function(wear_by_name) -{ - std::string folder_name(lua_tostring(L, 1)); - LLAppearanceMgr::instance().wearOutfitByName(folder_name); - - lua_pop(L, 1); - return 0; -} - -lua_function(open_floater) -{ - std::string floater_name(lua_tostring(L, 1)); - - LLSD key; - if (floater_name == "profile") - { - key["id"] = gAgentID; - } - LLFloaterReg::showInstance(floater_name, key); - - lua_pop(L, 1); - return 0; -} - -lua_function(close_floater) -{ - std::string floater_name(lua_tostring(L, 1)); - - LLSD key; - if (floater_name == "profile") - { - key["id"] = gAgentID; - } - LLFloaterReg::hideInstance(floater_name, key); - - lua_pop(L, 1); - return 0; -} - -lua_function(close_all_floaters) -{ - close_all_windows(); - return 0; -} - -lua_function(click_child) -{ - std::string parent_name(lua_tostring(L, 1)); - std::string child_name(lua_tostring(L, 2)); - - LLFloater *floater = LLFloaterReg::findInstance(parent_name); - LLUICtrl *child = floater->getChild<LLUICtrl>(child_name, true); - child->onCommit(); - - lua_pop(L, 2); - return 0; -} - -lua_function(snapshot_to_file) -{ - std::string filename(lua_tostring(L, 1)); - - //don't take snapshot from coroutine - doOnIdleOneTime([filename]() - { - gViewerWindow->saveSnapshot(filename, - gViewerWindow->getWindowWidthRaw(), - gViewerWindow->getWindowHeightRaw(), - gSavedSettings.getBOOL("RenderUIInSnapshot"), - gSavedSettings.getBOOL("RenderHUDInSnapshot"), - FALSE, - LLSnapshotModel::SNAPSHOT_TYPE_COLOR, - LLSnapshotModel::SNAPSHOT_FORMAT_PNG); - }); - - lua_pop(L, 1); - return 0; -} - -lua_function(open_wearing_tab) -{ - LLFloaterSidePanelContainer::showPanel("appearance", LLSD().with("type", "now_wearing")); - return 0; -} - -lua_function(set_debug_setting_bool) -{ - std::string setting_name(lua_tostring(L, 1)); - bool value(lua_toboolean(L, 2)); - - gSavedSettings.setBOOL(setting_name, value); - lua_pop(L, 2); - return 0; -} - -lua_function(get_avatar_name) -{ - std::string name = gAgentAvatarp->getFullname(); - luaL_checkstack(L, 1, nullptr); - lua_pushstdstring(L, name); - return 1; -} - -lua_function(is_avatar_flying) -{ - luaL_checkstack(L, 1, nullptr); - lua_pushboolean(L, gAgent.getFlying()); - return 1; -} - -lua_function(play_animation) -{ - // on exit, pop all passed arguments, so always return 0 - LuaPopper popper(L, lua_gettop(L)); - - std::string anim_name = lua_tostring(L,1); - - EAnimRequest req = ANIM_REQUEST_START; - if (lua_gettop(L) > 1) - { - req = (EAnimRequest) (int) lua_tonumber(L, 2); - } - - LLInventoryModel::cat_array_t cat_array; - LLInventoryModel::item_array_t item_array; - LLNameItemCollector has_name(anim_name); - gInventory.collectDescendentsIf(gInventory.getRootFolderID(), - cat_array, - item_array, - LLInventoryModel::EXCLUDE_TRASH, - has_name); - for (auto& item: item_array) - { - if (item->getType() == LLAssetType::AT_ANIMATION) - { - LLUUID anim_id = item->getAssetUUID(); - LL_INFOS() << "Playing animation " << anim_id << LL_ENDL; - gAgent.sendAnimationRequest(anim_id, req); - return 0; - } - } - LL_WARNS() << "No animation found for name " << anim_name << LL_ENDL; - - return 0; -} - -lua_function(env_setting_event) -{ - handle_env_setting_event(lua_tostring(L, 1)); - lua_pop(L, 1); - return 0; -} - -void handle_notification_dialog(const LLSD ¬ification, const LLSD &response, lua_State *L, std::string response_cb) -{ - if (!response_cb.empty()) - { - S32 option = LLNotificationsUtil::getSelectedOption(notification, response); - - luaL_checkstack(L, 1, nullptr); - lua_pushinteger(L, option); - lua_setglobal(L, response_cb.c_str()); - } -} - -lua_function(show_notification) -{ - std::string notification(lua_tostring(L, 1)); - - if (lua_type(L, 2) == LUA_TTABLE) - { - LLSD args = lua_tollsd(L, 2); - - std::string response_cb; - if (lua_type(L, 3) == LUA_TSTRING) - { - response_cb = lua_tostring(L, 3); - } - - LLNotificationsUtil::add(notification, args, LLSD(), boost::bind(handle_notification_dialog, _1, _2, L, response_cb)); - } - else if (lua_type(L, 2) == LUA_TSTRING) - { - std::string response_cb = lua_tostring(L, 2); - LLNotificationsUtil::add(notification, LLSD(), LLSD(), boost::bind(handle_notification_dialog, _1, _2, L, response_cb)); - } - else - { - LLNotificationsUtil::add(notification); - } - - lua_settop(L, 0); - return 0; -} - -lua_function(add_menu_item) -{ - std::string menu(lua_tostring(L, 1)); - if (lua_type(L, 2) == LUA_TTABLE) - { - LLSD args = lua_tollsd(L, 2); - - LLMenuItemCallGL::Params item_params; - item_params.name = args["name"]; - item_params.label = args["label"]; - - LLUICtrl::CommitCallbackParam item_func; - item_func.function_name = args["function"]; - if (args.has("parameter")) - { - item_func.parameter = args["parameter"]; - } - item_params.on_click = item_func; - - LLMenuItemCallGL *menu_item = LLUICtrlFactory::create<LLMenuItemCallGL>(item_params); - gMenuBarView->findChildMenuByName(menu, true)->append(menu_item); - } - - lua_settop(L, 0); - return 0; -} - -lua_function(add_menu_separator) -{ - std::string menu(lua_tostring(L, 1)); - gMenuBarView->findChildMenuByName(menu, true)->addSeparator(); - - lua_pop(L, 1); - return 0; -} - -lua_function(add_menu) -{ - if (lua_type(L, 1) == LUA_TTABLE) - { - LLSD args = lua_tollsd(L, 1); - - LLMenuGL::Params item_params; - item_params.name = args["name"]; - item_params.label = args["label"]; - item_params.can_tear_off = args["tear_off"]; - - LLMenuGL *menu = LLUICtrlFactory::create<LLMenuGL>(item_params); - gMenuBarView->appendMenu(menu); - } - - lua_settop(L, 0); - return 0; -} - -lua_function(add_branch) -{ - std::string menu(lua_tostring(L, 1)); - if (lua_type(L, 2) == LUA_TTABLE) - { - LLSD args = lua_tollsd(L, 2); - - LLMenuGL::Params item_params; - item_params.name = args["name"]; - item_params.label = args["label"]; - item_params.can_tear_off = args["tear_off"]; - - LLMenuGL *branch = LLUICtrlFactory::create<LLMenuGL>(item_params); - gMenuBarView->findChildMenuByName(menu, true)->appendMenu(branch); - } - - lua_settop(L, 0); - return 0; -} - -// rez_prim({x, y}, prim_type) -// avatar is the reference point -lua_function(rez_prim) -{ - lua_rawgeti(L, 1, 1); - F32 x = lua_tonumber(L, -1); - lua_pop(L, 1); - lua_rawgeti(L, 1, 2); - F32 y = lua_tonumber(L, -1); - lua_pop(L, 1); - - S32 type(lua_tonumber(L, 2)); // primitive shapes 1-8 - - LLVector3 obj_pos = gAgent.getPositionAgent() + LLVector3(x, y, -0.5); - bool res = LLToolPlacer::rezNewObject(type, NULL, 0, TRUE, gAgent.getPositionAgent(), obj_pos, gAgent.getRegion(), 0); - - LL_INFOS() << "Rezing a prim: type " << LLPrimitive::pCodeToString(type) << ", coordinates: " << obj_pos << " Success: " << res << LL_ENDL; - - lua_pop(L, lua_gettop(L)); - return 0; -} - -// rez_prim2({x, y,z}, prim_type) -// avatar is the reference point -lua_function(rez_prim2) -{ - luaL_checktype(L, 1, LUA_TTABLE); - S32 type(lua_tonumber(L,2)); - lua_pop(L,1); - - lua_pushinteger(L, 1); - lua_gettable(L, -2); - F32 x = lua_tonumber(L,-1); - lua_pop(L,1); - - lua_pushinteger(L, 2); - lua_gettable(L, -2); - F32 y = lua_tonumber(L,-1); - lua_pop(L,1); - - lua_pushinteger(L, 3); - lua_gettable(L, -2); - F32 z = lua_tonumber(L,-1); - lua_pop(L,1); - - LL_INFOS() << "x " << x << " y " << y << " z " << z << " type " << type << LL_ENDL; - - LLVector3 obj_pos = gAgent.getPositionAgent() + LLVector3(x, y, z); - bool res = LLToolPlacer::rezNewObject(type, NULL, 0, TRUE, gAgent.getPositionAgent(), obj_pos, gAgent.getRegion(), 0); - - LL_INFOS() << "Rezing a prim: type " << LLPrimitive::pCodeToString(type) << ", coordinates: " << obj_pos << " Success: " << res << LL_ENDL; - - lua_settop(L, 0); - return 0; -} - - -void move_to_dest(const LLVector3d &target_global, lua_State *L, std::string response_cb) -{ - struct Data - { - lua_State *L; - std::string response_cb; - }; - - Data *data = new Data(); - data->L = L; - if (!response_cb.empty()) - { - data->response_cb = response_cb; - } - - auto handle_dest_reached = [](BOOL success, void *user_data) - { - Data *cb_data = static_cast<Data *>(user_data); - if (!cb_data->response_cb.empty()) - { - S32 result = success ? 1 : -1; - lua_pushinteger(cb_data->L, result); - lua_setglobal(cb_data->L, cb_data->response_cb.c_str()); - } - }; - - gAgent.startAutoPilotGlobal(target_global, std::string(), NULL, handle_dest_reached, data, 0.f, 0.03f, FALSE); -} - -// move_by({x,y}, "lua_cb_func") -// avatar is the reference point -lua_function(move_by) -{ - lua_rawgeti(L, 1, 1); - F32 x = lua_tonumber(L, -1); - lua_pop(L, 1); - lua_rawgeti(L, 1, 2); - F32 y = lua_tonumber(L, -1); - lua_pop(L, 1); - - LLVector3d dest = gAgent.getRegion()->getPosGlobalFromRegion(gAgent.getPositionAgent() + LLVector3(x, y, 0)); - - std::string response_cb; - if (lua_type(L, 2) == LUA_TSTRING) - { - response_cb = lua_tostring(L, 2); - } - move_to_dest(dest, L, response_cb); - - lua_settop(L, 0); - return 0; -} - -// move_to({x,y,z}, "lua_cb_func") -// region coordinates are used -lua_function(move_to) -{ - lua_rawgeti(L, 1, 1); - F32 x = lua_tonumber(L, -1); - lua_pop(L, 1); - lua_rawgeti(L, 1, 2); - F32 y = lua_tonumber(L, -1); - lua_rawgeti(L, 1, 3); - F32 z = lua_tonumber(L, -1); - lua_pop(L, 1); - - LLVector3d dest = gAgent.getRegion()->getPosGlobalFromRegion(LLVector3(x, y, z)); - - std::string response_cb; - if (lua_type(L, 2) == LUA_TSTRING) - { - response_cb = lua_tostring(L, 2); - } - move_to_dest(dest, L, response_cb); - - lua_settop(L, 0); - return 0; -} lua_function(run_ui_command) { |