diff options
Diffstat (limited to 'indra')
-rw-r--r-- | indra/newview/llinventoryfunctions.cpp | 13 | ||||
-rw-r--r-- | indra/newview/llinventoryfunctions.h | 16 | ||||
-rw-r--r-- | indra/newview/llinventorymodel.cpp | 11 | ||||
-rw-r--r-- | indra/newview/llluamanager.cpp | 38 |
4 files changed, 77 insertions, 1 deletions
diff --git a/indra/newview/llinventoryfunctions.cpp b/indra/newview/llinventoryfunctions.cpp index 145814ab41..bf8b49e1e0 100644 --- a/indra/newview/llinventoryfunctions.cpp +++ b/indra/newview/llinventoryfunctions.cpp @@ -2155,6 +2155,19 @@ bool LLNameCategoryCollector::operator()( return false; } +bool LLNameItemCollector::operator()( + LLInventoryCategory* cat, LLInventoryItem* item) +{ + if(item) + { + if (!LLStringUtil::compareInsensitive(mName, item->getName())) + { + return true; + } + } + return false; +} + bool LLFindCOFValidItems::operator()(LLInventoryCategory* cat, LLInventoryItem* item) { diff --git a/indra/newview/llinventoryfunctions.h b/indra/newview/llinventoryfunctions.h index 8c8bd789c2..1bfd0f2b93 100644 --- a/indra/newview/llinventoryfunctions.h +++ b/indra/newview/llinventoryfunctions.h @@ -313,6 +313,22 @@ protected: }; //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// Class LLNameItemCollector +// +// Collects items based on case-insensitive match of prefix +//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +class LLNameItemCollector : public LLInventoryCollectFunctor +{ +public: + LLNameItemCollector(const std::string& name) : mName(name) {} + virtual ~LLNameItemCollector() {} + virtual bool operator()(LLInventoryCategory* cat, + LLInventoryItem* item); +protected: + std::string mName; +}; + +//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // Class LLFindCOFValidItems // // Collects items that can be legitimately linked to in the COF. diff --git a/indra/newview/llinventorymodel.cpp b/indra/newview/llinventorymodel.cpp index 9c4e122481..bbac9f4123 100644 --- a/indra/newview/llinventorymodel.cpp +++ b/indra/newview/llinventorymodel.cpp @@ -4421,6 +4421,17 @@ std::string LLInventoryModel::getFullPath(const LLInventoryObject *obj) const return result; } +/* +const LLInventoryObject* LLInventoryModel::findByFullPath(const std::string& path) +{ + vector<std::string> path_elts; + boost::algorithm::split(path_elts, path, boost::is_any_of("/")); + for(path_elts, auto e) + { + } +} +*/ + ///---------------------------------------------------------------------------- /// Local function definitions ///---------------------------------------------------------------------------- diff --git a/indra/newview/llluamanager.cpp b/indra/newview/llluamanager.cpp index a154daeeed..92a012c921 100644 --- a/indra/newview/llluamanager.cpp +++ b/indra/newview/llluamanager.cpp @@ -40,6 +40,8 @@ #include "llviewermenufile.h" #include "llviewerwindow.h" #include "lluilistener.h" +#include "llanimationstates.h" +#include "llinventoryfunctions.h" #include <boost/algorithm/string/replace.hpp> @@ -187,7 +189,7 @@ int lua_set_debug_setting_bool(lua_State *L) return 1; } - int lua_get_avatar_name(lua_State *L) +int lua_get_avatar_name(lua_State *L) { std::string name = gAgentAvatarp->getFullname(); lua_pushstring(L, name.c_str()); @@ -200,6 +202,39 @@ int lua_is_avatar_flying(lua_State *L) return 1; } +int lua_play_animation(lua_State *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 1; + } + } + LL_WARNS() << "No animation found for name " << anim_name << LL_ENDL; + + return 1; +} + int lua_env_setting_event(lua_State *L) { handle_env_setting_event(lua_tostring(L, 1)); @@ -302,6 +337,7 @@ void initLUA(lua_State *L) lua_register(L, "get_avatar_name", lua_get_avatar_name); lua_register(L, "is_avatar_flying", lua_is_avatar_flying); + lua_register(L, "play_animation", lua_play_animation); lua_register(L, "env_setting_event", lua_env_setting_event); lua_register(L, "set_debug_setting_bool", lua_set_debug_setting_bool); |