diff --git a/indra/llcommon/llstl.h b/indra/llcommon/llstl.h index 5730ce6ff2..9f5173613e 100644 --- a/indra/llcommon/llstl.h +++ b/indra/llcommon/llstl.h @@ -201,11 +201,11 @@ void delete_and_clear_array(T*& ptr) // foo[2] = "hello"; // const char* bar = get_ptr_in_map(foo, 2); // bar -> "hello" // const char* baz = get_ptr_in_map(foo, 3); // baz == NULL -template -inline T* get_ptr_in_map(const std::map& inmap, const K& key) +template +inline typename T::mapped_type get_ptr_in_map(const T& inmap, typename T::key_type const& key) { // Typedef here avoids warnings because of new c++ naming rules. - typedef typename std::map::const_iterator map_iter; + typedef typename T::const_iterator map_iter; map_iter iter = inmap.find(key); if(iter == inmap.end()) { diff --git a/indra/llui/llbadge.cpp b/indra/llui/llbadge.cpp index 7732a96b85..838356505d 100644 --- a/indra/llui/llbadge.cpp +++ b/indra/llui/llbadge.cpp @@ -36,7 +36,7 @@ static LLDefaultChildRegistry::Register r("badge"); static const S32 BADGE_OFFSET_NOT_SPECIFIED = 0x7FFFFFFF; // Compiler optimization, generate extern template -template class LLBadge* LLView::getChild(const std::string& name, bool recurse) const; +template class LLBadge* LLView::getChild(std::string_view name, bool recurse) const; LLBadge::Params::Params() diff --git a/indra/llui/llbadge.h b/indra/llui/llbadge.h index a6d584c6d7..77fe76f0da 100644 --- a/indra/llui/llbadge.h +++ b/indra/llui/llbadge.h @@ -171,7 +171,7 @@ private: // Build time optimization, generate once in .cpp file #ifndef LLBADGE_CPP -extern template class LLBadge* LLView::getChild(const std::string& name, bool recurse) const; +extern template class LLBadge* LLView::getChild(std::string_view name, bool recurse) const; #endif #endif // LL_LLBADGE_H diff --git a/indra/llui/llbutton.cpp b/indra/llui/llbutton.cpp index 9285982edd..b16ca9c0d9 100644 --- a/indra/llui/llbutton.cpp +++ b/indra/llui/llbutton.cpp @@ -58,7 +58,7 @@ static LLDefaultChildRegistry::Register r("button"); // Compiler optimization, generate extern template template class LLButton* LLView::getChild( - const std::string& name, bool recurse) const; + std::string_view name, bool recurse) const; // globals S32 LLBUTTON_H_PAD = 4; @@ -1348,7 +1348,7 @@ void LLButton::setFloaterToggle(LLUICtrl* ctrl, const LLSD& sdname) // Set the button control value (toggle state) to the floater visibility control (Sets the value as well) button->setControlVariable(LLFloater::getControlGroup()->getControl(vis_control_name)); // Set the clicked callback to toggle the floater - button->setClickedCallback(boost::bind(&LLFloaterReg::toggleInstance, sdname, LLSD())); + button->setClickedCallback([=](LLUICtrl* ctrl, const LLSD& param) -> void { LLFloaterReg::toggleInstance(sdname.asString(), LLSD()); }); } // static diff --git a/indra/llui/llbutton.h b/indra/llui/llbutton.h index 250c6f53b3..95e1e6c1f6 100644 --- a/indra/llui/llbutton.h +++ b/indra/llui/llbutton.h @@ -422,7 +422,7 @@ protected: // Build time optimization, generate once in .cpp file #ifndef LLBUTTON_CPP extern template class LLButton* LLView::getChild( - const std::string& name, bool recurse) const; + std::string_view name, bool recurse) const; #endif #endif // LL_LLBUTTON_H diff --git a/indra/llui/llcheckboxctrl.cpp b/indra/llui/llcheckboxctrl.cpp index 1b803ac896..efebacbcfc 100644 --- a/indra/llui/llcheckboxctrl.cpp +++ b/indra/llui/llcheckboxctrl.cpp @@ -45,7 +45,7 @@ static LLDefaultChildRegistry::Register r("check_box"); // Compiler optimization, generate extern template template class LLCheckBoxCtrl* LLView::getChild( - const std::string& name, bool recurse) const; + std::string_view name, bool recurse) const; void LLCheckBoxCtrl::WordWrap::declareValues() { diff --git a/indra/llui/llcheckboxctrl.h b/indra/llui/llcheckboxctrl.h index bfff0ed25b..5003828ad2 100644 --- a/indra/llui/llcheckboxctrl.h +++ b/indra/llui/llcheckboxctrl.h @@ -167,7 +167,7 @@ protected: // Build time optimization, generate once in .cpp file #ifndef LLCHECKBOXCTRL_CPP extern template class LLCheckBoxCtrl* LLView::getChild( - const std::string& name, bool recurse) const; + std::string_view name, bool recurse) const; #endif #endif // LL_LLCHECKBOXCTRL_H diff --git a/indra/llui/llfloaterreg.cpp b/indra/llui/llfloaterreg.cpp index 372e1e2559..2baf03e57b 100644 --- a/indra/llui/llfloaterreg.cpp +++ b/indra/llui/llfloaterreg.cpp @@ -41,9 +41,9 @@ LLFloaterReg::instance_list_t LLFloaterReg::sNullInstanceList; LLFloaterReg::instance_map_t LLFloaterReg::sInstanceMap; LLFloaterReg::build_map_t LLFloaterReg::sBuildMap; -std::map LLFloaterReg::sGroupMap; +std::map> LLFloaterReg::sGroupMap; bool LLFloaterReg::sBlockShowFloaters = false; -std::set LLFloaterReg::sAlwaysShowableList; +std::set> LLFloaterReg::sAlwaysShowableList; static LLFloaterRegListener sFloaterRegListener; @@ -62,40 +62,32 @@ void LLFloaterReg::add(const std::string& name, const std::string& filename, con sGroupMap[groupname] = groupname; // for referencing directly by group name } -// [SL:KB] - Patch: UI-Base | Checked: 2010-12-01 (Catznip-3.0.0a) | Added: Catznip-2.4.0g //static -void LLFloaterReg::addWithFileCallback(const std::string& name, const LLFloaterFileFunc& fileFunc, - const LLFloaterBuildFunc& func, const std::string& groupname) -{ - sBuildMap[name].mFunc = func; - sBuildMap[name].mFileFunc = fileFunc; - sGroupMap[name] = groupname.empty() ? name : groupname; - sGroupMap[groupname] = groupname; // for referencing directly by group name -} -// [/SL:KB] - -//static -bool LLFloaterReg::isRegistered(const std::string& name) +bool LLFloaterReg::isRegistered(std::string_view name) { return sBuildMap.find(name) != sBuildMap.end(); } //static -LLFloater* LLFloaterReg::getLastFloaterInGroup(const std::string& name) +LLFloater* LLFloaterReg::getLastFloaterInGroup(std::string_view name) { - const std::string& groupname = sGroupMap[name]; - if (!groupname.empty()) + auto it = sGroupMap.find(name); + if (it != sGroupMap.end()) { - instance_list_t& list = sInstanceMap[groupname]; - if (!list.empty()) + const std::string& groupname = it->second; + if (!groupname.empty()) { - for (instance_list_t::reverse_iterator iter = list.rbegin(); iter != list.rend(); ++iter) + instance_list_t& list = sInstanceMap[groupname]; + if (!list.empty()) { - LLFloater* inst = *iter; - - if (inst->getVisible() && !inst->isMinimized()) + for (instance_list_t::reverse_iterator iter = list.rbegin(), end = list.rend(); iter != end; ++iter) { - return inst; + LLFloater* inst = *iter; + + if (inst->getVisible() && !inst->isMinimized()) + { + return inst; + } } } } @@ -147,10 +139,8 @@ LLFloater* LLFloaterReg::getLastFloaterCascading() instance_list_t& instances = sInstanceMap[group_name]; - for (instance_list_t::const_iterator iter = instances.begin(); iter != instances.end(); ++iter) + for (LLFloater* inst : instances) { - LLFloater* inst = *iter; - if (inst->getVisible() && (inst->isPositioning(LLFloaterEnums::POSITIONING_CASCADING) || inst->isPositioning(LLFloaterEnums::POSITIONING_CASCADE_GROUP))) @@ -168,20 +158,23 @@ LLFloater* LLFloaterReg::getLastFloaterCascading() } //static -LLFloater* LLFloaterReg::findInstance(const std::string& name, const LLSD& key) +LLFloater* LLFloaterReg::findInstance(std::string_view name, const LLSD& key) { LLFloater* res = NULL; - const std::string& groupname = sGroupMap[name]; - if (!groupname.empty()) + auto it = sGroupMap.find(name); + if (it != sGroupMap.end()) { - instance_list_t& list = sInstanceMap[groupname]; - for (instance_list_t::iterator iter = list.begin(); iter != list.end(); ++iter) + const std::string& groupname = it->second; + if (!groupname.empty()) { - LLFloater* inst = *iter; - if (inst->matchesKey(key)) + instance_list_t& list = sInstanceMap[groupname]; + for (LLFloater* inst : list) { - res = inst; - break; + if (inst->matchesKey(key)) + { + res = inst; + break; + } } } } @@ -189,50 +182,55 @@ LLFloater* LLFloaterReg::findInstance(const std::string& name, const LLSD& key) } //static -LLFloater* LLFloaterReg::getInstance(const std::string& name, const LLSD& key) +LLFloater* LLFloaterReg::getInstance(std::string_view name, const LLSD& key) { LLFloater* res = findInstance(name, key); if (!res) { - const LLFloaterBuildFunc& build_func = sBuildMap[name].mFunc; -// const std::string& xui_file = sBuildMap[name].mFile; -// [SL:KB] - Patch: UI-Base | Checked: 2010-12-01 (Catznip-3.0.0a) | Added: Catznip-2.5.0a - const std::string& xui_file = (!sBuildMap[name].mFileFunc) ? sBuildMap[name].mFile : sBuildMap[name].mFileFunc(); -// [/SL:KB] - if (build_func) + auto it = sBuildMap.find(name); + if (it != sBuildMap.end()) { - const std::string& groupname = sGroupMap[name]; - if (!groupname.empty()) + const LLFloaterBuildFunc& build_func = it->second.mFunc; + const std::string& xui_file = it->second.mFile; + if (build_func) { - instance_list_t& list = sInstanceMap[groupname]; - - res = build_func(key); - if (!res) + auto it = sGroupMap.find(name); + if (it != sGroupMap.end()) { - LL_WARNS() << "Failed to build floater type: '" << name << "'." << LL_ENDL; - return NULL; + const std::string& groupname = it->second; + if (!groupname.empty()) + { + instance_list_t& list = sInstanceMap[groupname]; + + res = build_func(key); + if (!res) + { + LL_WARNS() << "Failed to build floater type: '" << name << "'." << LL_ENDL; + return NULL; + } + bool success = res->buildFromFile(xui_file); + if (!success) + { + LL_WARNS() << "Failed to build floater type: '" << name << "'." << LL_ENDL; + return NULL; + } + + // Note: key should eventually be a non optional LLFloater arg; for now, set mKey to be safe + if (res->mKey.isUndefined()) + { + res->mKey = key; + } + res->setInstanceName(std::string(name)); + + LLFloater* last_floater = (list.empty() ? NULL : list.back()); + + res->applyControlsAndPosition(last_floater); + + gFloaterView->adjustToFitScreen(res, false); + + list.push_back(res); + } } - bool success = res->buildFromFile(xui_file); - if (!success) - { - LL_WARNS() << "Failed to build floater type: '" << name << "'." << LL_ENDL; - return NULL; - } - - // Note: key should eventually be a non optional LLFloater arg; for now, set mKey to be safe - if (res->mKey.isUndefined()) - { - res->mKey = key; - } - res->setInstanceName(name); - - LLFloater *last_floater = (list.empty() ? NULL : list.back()); - - res->applyControlsAndPosition(last_floater); - - gFloaterView->adjustToFitScreen(res, false); - - list.push_back(res); } } if (!res) @@ -244,21 +242,25 @@ LLFloater* LLFloaterReg::getInstance(const std::string& name, const LLSD& key) } //static -LLFloater* LLFloaterReg::removeInstance(const std::string& name, const LLSD& key) +LLFloater* LLFloaterReg::removeInstance(std::string_view name, const LLSD& key) { LLFloater* res = NULL; - const std::string& groupname = sGroupMap[name]; - if (!groupname.empty()) + auto it = sGroupMap.find(name); + if (it != sGroupMap.end()) { - instance_list_t& list = sInstanceMap[groupname]; - for (instance_list_t::iterator iter = list.begin(); iter != list.end(); ++iter) + const std::string& groupname = it->second; + if (!groupname.empty()) { - LLFloater* inst = *iter; - if (inst->matchesKey(key)) + instance_list_t& list = sInstanceMap[groupname]; + for (instance_list_t::iterator iter = list.begin(); iter != list.end(); ++iter) { - res = inst; - list.erase(iter); - break; + LLFloater* inst = *iter; + if (inst->matchesKey(key)) + { + res = inst; + list.erase(iter); + break; + } } } } @@ -267,7 +269,7 @@ LLFloater* LLFloaterReg::removeInstance(const std::string& name, const LLSD& key //static // returns true if the instance existed -bool LLFloaterReg::destroyInstance(const std::string& name, const LLSD& key) +bool LLFloaterReg::destroyInstance(std::string_view name, const LLSD& key) { LLFloater* inst = removeInstance(name, key); if (inst) @@ -283,7 +285,7 @@ bool LLFloaterReg::destroyInstance(const std::string& name, const LLSD& key) // Iterators //static -LLFloaterReg::const_instance_list_t& LLFloaterReg::getFloaterList(const std::string& name) +LLFloaterReg::const_instance_list_t& LLFloaterReg::getFloaterList(std::string_view name) { instance_map_t::iterator iter = sInstanceMap.find(name); if (iter != sInstanceMap.end()) @@ -300,14 +302,14 @@ LLFloaterReg::const_instance_list_t& LLFloaterReg::getFloaterList(const std::str // [RLVa:KB] - Checked: 2012-02-07 (RLVa-1.4.5) | Added: RLVa-1.4.5 //static -bool LLFloaterReg::canShowInstance(const std::string& name, const LLSD& key) +bool LLFloaterReg::canShowInstance(std::string_view name, const LLSD& key) { return mValidateSignal(name, key); } // [/RLVa:KB] //static -LLFloater* LLFloaterReg::showInstance(const std::string& name, const LLSD& key, bool focus) +LLFloater* LLFloaterReg::showInstance(std::string_view name, const LLSD& key, bool focus) { // if( sBlockShowFloaters // // see EXT-7090 @@ -329,7 +331,7 @@ LLFloater* LLFloaterReg::showInstance(const std::string& name, const LLSD& key, //static // returns true if the instance exists -bool LLFloaterReg::hideInstance(const std::string& name, const LLSD& key) +bool LLFloaterReg::hideInstance(std::string_view name, const LLSD& key) { LLFloater* instance = findInstance(name, key); if (instance) @@ -341,7 +343,7 @@ bool LLFloaterReg::hideInstance(const std::string& name, const LLSD& key) //static // returns true if the instance is visible when completed -bool LLFloaterReg::toggleInstance(const std::string& name, const LLSD& key) +bool LLFloaterReg::toggleInstance(std::string_view name, const LLSD& key) { LLFloater* instance = findInstance(name, key); if (instance && instance->isShown()) @@ -357,7 +359,7 @@ bool LLFloaterReg::toggleInstance(const std::string& name, const LLSD& key) //static // returns true if the instance exists and is visible (doesnt matter minimized or not) -bool LLFloaterReg::instanceVisible(const std::string& name, const LLSD& key) +bool LLFloaterReg::instanceVisible(std::string_view name, const LLSD& key) { LLFloater* instance = findInstance(name, key); return LLFloater::isVisible(instance); diff --git a/indra/llui/llfloaterreg.h b/indra/llui/llfloaterreg.h index f943cfc81d..500297946a 100644 --- a/indra/llui/llfloaterreg.h +++ b/indra/llui/llfloaterreg.h @@ -58,7 +58,7 @@ public: // 2) We can change the key of a floater without altering the list. typedef std::list instance_list_t; typedef const instance_list_t const_instance_list_t; - typedef std::map instance_map_t; + typedef std::map> instance_map_t; struct BuildData { @@ -68,24 +68,24 @@ public: // [/SL:KB] std::string mFile; }; - typedef std::map build_map_t; + typedef std::map> build_map_t; private: friend class LLFloaterRegListener; static instance_list_t sNullInstanceList; static instance_map_t sInstanceMap; static build_map_t sBuildMap; - static std::map sGroupMap; + static std::map> sGroupMap; static bool sBlockShowFloaters; /** * Defines list of floater names that can be shown despite state of sBlockShowFloaters. */ - static std::set sAlwaysShowableList; + static std::set> sAlwaysShowableList; // [RLVa:KB] - Checked: 2010-02-28 (RLVa-1.4.0a) | Modified: RLVa-1.2.0a // Used to determine whether a floater can be shown public: - typedef boost::signals2::signal validate_signal_t; + typedef boost::signals2::signal validate_signal_t; static boost::signals2::connection setValidateCallback(const validate_signal_t::slot_type& cb) { return mValidateSignal.connect(cb); } private: static validate_signal_t mValidateSignal; @@ -104,40 +104,35 @@ public: static void add(const std::string& name, const std::string& file, const LLFloaterBuildFunc& func, const std::string& groupname = LLStringUtil::null); - static bool isRegistered(const std::string& name); - -// [SL:KB] - Patch: UI-Base | Checked: 2010-12-01 (Catznip-3.0.0a) | Added: Catznip-2.4.0g - static void addWithFileCallback(const std::string& name, const LLFloaterFileFunc& fileFunc, const LLFloaterBuildFunc& func, - const std::string& groupname = LLStringUtil::null); -// [/SL:KB] + static bool isRegistered(std::string_view name); // Helpers - static LLFloater* getLastFloaterInGroup(const std::string& name); + static LLFloater* getLastFloaterInGroup(std::string_view name); static LLFloater* getLastFloaterCascading(); static instance_list_t getAllFloatersInGroup(LLFloater* floater); // FIRE-24125: Add option to close all floaters of a group // Find / get (create) / remove / destroy - static LLFloater* findInstance(const std::string& name, const LLSD& key = LLSD()); - static LLFloater* getInstance(const std::string& name, const LLSD& key = LLSD()); - static LLFloater* removeInstance(const std::string& name, const LLSD& key = LLSD()); - static bool destroyInstance(const std::string& name, const LLSD& key = LLSD()); + static LLFloater* findInstance(std::string_view name, const LLSD& key = LLSD()); + static LLFloater* getInstance(std::string_view name, const LLSD& key = LLSD()); + static LLFloater* removeInstance(std::string_view name, const LLSD& key = LLSD()); + static bool destroyInstance(std::string_view name, const LLSD& key = LLSD()); // Iterators - static const_instance_list_t& getFloaterList(const std::string& name); + static const_instance_list_t& getFloaterList(std::string_view name); // Visibility Management // [RLVa:KB] - Checked: 2012-02-07 (RLVa-1.4.5) | Added: RLVa-1.4.5 // return false if floater can not be shown (=doesn't pass the validation filter) - static bool canShowInstance(const std::string& name, const LLSD& key = LLSD()); + static bool canShowInstance(std::string_view name, const LLSD& key = LLSD()); // [/RLVa:KB] // return NULL if instance not found or can't create instance (no builder) - static LLFloater* showInstance(const std::string& name, const LLSD& key = LLSD(), bool focus = false); + static LLFloater* showInstance(std::string_view name, const LLSD& key = LLSD(), bool focus = false); // Close a floater (may destroy or set invisible) // return false if can't find instance - static bool hideInstance(const std::string& name, const LLSD& key = LLSD()); + static bool hideInstance(std::string_view name, const LLSD& key = LLSD()); // return true if instance is visible: - static bool toggleInstance(const std::string& name, const LLSD& key = LLSD()); - static bool instanceVisible(const std::string& name, const LLSD& key = LLSD()); + static bool toggleInstance(std::string_view name, const LLSD& key = LLSD()); + static bool instanceVisible(std::string_view name, const LLSD& key = LLSD()); static void showInitialVisibleInstances(); static void hideVisibleInstances(const std::set& exceptions = std::set()); @@ -162,19 +157,19 @@ public: // Typed find / get / show template - static T* findTypedInstance(const std::string& name, const LLSD& key = LLSD()) + static T* findTypedInstance(std::string_view name, const LLSD& key = LLSD()) { return dynamic_cast(findInstance(name, key)); } template - static T* getTypedInstance(const std::string& name, const LLSD& key = LLSD()) + static T* getTypedInstance(std::string_view name, const LLSD& key = LLSD()) { return dynamic_cast(getInstance(name, key)); } template - static T* showTypedInstance(const std::string& name, const LLSD& key = LLSD(), bool focus = false) + static T* showTypedInstance(std::string_view name, const LLSD& key = LLSD(), bool focus = false) { return dynamic_cast(showInstance(name, key, focus)); } diff --git a/indra/llui/llfloaterreglistener.cpp b/indra/llui/llfloaterreglistener.cpp index aa3d1a1171..17641b8375 100644 --- a/indra/llui/llfloaterreglistener.cpp +++ b/indra/llui/llfloaterreglistener.cpp @@ -94,22 +94,22 @@ void LLFloaterRegListener::getBuildMap(const LLSD& event) const void LLFloaterRegListener::showInstance(const LLSD& event) const { - LLFloaterReg::showInstance(event["name"], event["key"], event["focus"]); + LLFloaterReg::showInstance(event["name"].asString(), event["key"], event["focus"]); } void LLFloaterRegListener::hideInstance(const LLSD& event) const { - LLFloaterReg::hideInstance(event["name"], event["key"]); + LLFloaterReg::hideInstance(event["name"].asString(), event["key"]); } void LLFloaterRegListener::toggleInstance(const LLSD& event) const { - LLFloaterReg::toggleInstance(event["name"], event["key"]); + LLFloaterReg::toggleInstance(event["name"].asString(), event["key"]); } void LLFloaterRegListener::instanceVisible(const LLSD& event) const { - sendReply(LLSDMap("visible", LLFloaterReg::instanceVisible(event["name"], event["key"])), + sendReply(LLSDMap("visible", LLFloaterReg::instanceVisible(event["name"].asString(), event["key"])), event); } @@ -119,7 +119,7 @@ void LLFloaterRegListener::clickButton(const LLSD& event) const LLReqID reqID(event); LLSD reply(reqID.makeResponse()); - LLFloater* floater = LLFloaterReg::findInstance(event["name"], event["key"]); + LLFloater* floater = LLFloaterReg::findInstance(event["name"].asString(), event["key"]); if (! LLFloater::isShown(floater)) { reply["type"] = "LLFloater"; @@ -131,7 +131,7 @@ void LLFloaterRegListener::clickButton(const LLSD& event) const { // Here 'floater' points to an LLFloater instance with the specified // name and key which isShown(). - LLButton* button = floater->findChild(event["button"]); + LLButton* button = floater->findChild(event["button"].asString()); if (! LLButton::isAvailable(button)) { reply["type"] = "LLButton"; diff --git a/indra/llui/llkeywords.cpp b/indra/llui/llkeywords.cpp index bd08f54f3a..4512aadc5b 100644 --- a/indra/llui/llkeywords.cpp +++ b/indra/llui/llkeywords.cpp @@ -164,13 +164,13 @@ std::string LLKeywords::getArguments(LLSD& arguments) return argString; } -std::string LLKeywords::getAttribute(const std::string& key) +std::string LLKeywords::getAttribute(std::string_view key) { attribute_iterator_t it = mAttributes.find(key); return (it != mAttributes.end()) ? it->second : ""; } -LLColor4 LLKeywords::getColorGroup(const std::string& key_in) +LLColor4 LLKeywords::getColorGroup(std::string_view key_in) { std::string color_group = "ScriptText"; if (key_in == "functions") @@ -284,7 +284,7 @@ void LLKeywords::processTokens() LL_INFOS("SyntaxLSL") << "Finished processing tokens." << LL_ENDL; } -void LLKeywords::processTokensGroup(const LLSD& tokens, const std::string& group) +void LLKeywords::processTokensGroup(const LLSD& tokens, std::string_view group) { LLColor4 color; LLColor4 color_group; @@ -356,7 +356,7 @@ void LLKeywords::processTokensGroup(const LLSD& tokens, const std::string& group case LLKeywordToken::TT_CONSTANT: if (getAttribute("type").length() > 0) { - color_group = getColorGroup(group + "-" + getAttribute("type")); + color_group = getColorGroup(std::string(group) + "-" + getAttribute("type")); } else { diff --git a/indra/llui/llkeywords.h b/indra/llui/llkeywords.h index 36620425b5..06e91597e4 100644 --- a/indra/llui/llkeywords.h +++ b/indra/llui/llkeywords.h @@ -115,7 +115,7 @@ public: ~LLKeywords(); void clearLoaded() { mLoaded = false; } - LLColor4 getColorGroup(const std::string& key_in); + LLColor4 getColorGroup(std::string_view key_in); bool isLoaded() const { return mLoaded; } // Re-add support for Cinder's legacy file format bool loadFromLegacyFile(const std::string& filename); @@ -176,7 +176,7 @@ public: #endif protected: - void processTokensGroup(const LLSD& Tokens, const std::string& Group); + void processTokensGroup(const LLSD& Tokens, std::string_view Group); void insertSegment(std::vector& seg_list, LLTextSegmentPtr new_segment, S32 text_len, @@ -200,10 +200,10 @@ protected: token_list_t mLineTokenList; token_list_t mDelimiterTokenList; - typedef std::map element_attributes_t; + typedef std::map> element_attributes_t; typedef element_attributes_t::const_iterator attribute_iterator_t; element_attributes_t mAttributes; - std::string getAttribute(const std::string& key); + std::string getAttribute(std::string_view key); std::string getArguments(LLSD& arguments); diff --git a/indra/llui/lllayoutstack.cpp b/indra/llui/lllayoutstack.cpp index 86ed281809..e7b5616f6f 100644 --- a/indra/llui/lllayoutstack.cpp +++ b/indra/llui/lllayoutstack.cpp @@ -616,7 +616,7 @@ LLLayoutPanel* LLLayoutStack::findEmbeddedPanel(LLPanel* panelp) const return NULL; } -LLLayoutPanel* LLLayoutStack::findEmbeddedPanelByName(const std::string& name) const +LLLayoutPanel* LLLayoutStack::findEmbeddedPanelByName(std::string_view name) const { LLLayoutPanel* result = NULL; diff --git a/indra/llui/lllayoutstack.h b/indra/llui/lllayoutstack.h index 754ac6d9c6..d75d734bce 100644 --- a/indra/llui/lllayoutstack.h +++ b/indra/llui/lllayoutstack.h @@ -119,7 +119,7 @@ private: e_panel_list_t mPanels; LLLayoutPanel* findEmbeddedPanel(LLPanel* panelp) const; - LLLayoutPanel* findEmbeddedPanelByName(const std::string& name) const; + LLLayoutPanel* findEmbeddedPanelByName(std::string_view name) const; void updateFractionalSizes(); void normalizeFractionalSizes(); void updatePanelRect( LLLayoutPanel* param1, const LLRect& new_rect ); diff --git a/indra/llui/lllineeditor.cpp b/indra/llui/lllineeditor.cpp index d23644fa6e..5b24468649 100644 --- a/indra/llui/lllineeditor.cpp +++ b/indra/llui/lllineeditor.cpp @@ -74,7 +74,7 @@ static LLDefaultChildRegistry::Register r1("line_editor"); // Compiler optimization, generate extern template template class LLLineEditor* LLView::getChild( - const std::string& name, bool recurse) const; + std::string_view name, bool recurse) const; // // Member functions diff --git a/indra/llui/lllineeditor.h b/indra/llui/lllineeditor.h index db6f1bfefc..0ded4b3483 100644 --- a/indra/llui/lllineeditor.h +++ b/indra/llui/lllineeditor.h @@ -483,7 +483,7 @@ private: // Build time optimization, generate once in .cpp file #ifndef LLLINEEDITOR_CPP extern template class LLLineEditor* LLView::getChild( - const std::string& name, bool recurse) const; + std::string_view name, bool recurse) const; #endif #endif // LL_LINEEDITOR_ diff --git a/indra/llui/llmenugl.cpp b/indra/llui/llmenugl.cpp index d21c7127cc..d691a3e417 100644 --- a/indra/llui/llmenugl.cpp +++ b/indra/llui/llmenugl.cpp @@ -1009,7 +1009,7 @@ LLMenuItemBranchGL::~LLMenuItemBranchGL() // virtual -LLView* LLMenuItemBranchGL::getChildView(const std::string& name, bool recurse) const +LLView* LLMenuItemBranchGL::getChildView(std::string_view name, bool recurse) const { LLMenuGL* branch = getBranch(); if (branch) @@ -1026,7 +1026,7 @@ LLView* LLMenuItemBranchGL::getChildView(const std::string& name, bool recurse) return LLView::getChildView(name, recurse); } -LLView* LLMenuItemBranchGL::findChildView(const std::string& name, bool recurse) const +LLView* LLMenuItemBranchGL::findChildView(std::string_view name, bool recurse) const { LLMenuGL* branch = getBranch(); if (branch) @@ -2781,7 +2781,7 @@ void LLMenuGL::setEnabledSubMenus(bool enable) // setItemEnabled() - pass the label and the enable flag for a menu // item. true will make sure it's enabled, false will disable it. -void LLMenuGL::setItemEnabled( const std::string& name, bool enable ) +void LLMenuGL::setItemEnabled(std::string_view name, bool enable ) { item_list_t::iterator item_iter; for (item_iter = mItems.begin(); item_iter != mItems.end(); ++item_iter) @@ -2795,7 +2795,7 @@ void LLMenuGL::setItemEnabled( const std::string& name, bool enable ) } } -void LLMenuGL::setItemVisible( const std::string& name, bool visible ) +void LLMenuGL::setItemVisible(std::string_view name, bool visible ) { item_list_t::iterator item_iter; for (item_iter = mItems.begin(); item_iter != mItems.end(); ++item_iter) @@ -3306,7 +3306,7 @@ void LLMenuGL::setVisible(bool visible) } } -LLMenuGL* LLMenuGL::findChildMenuByName(const std::string& name, bool recurse) const +LLMenuGL* LLMenuGL::findChildMenuByName(std::string_view name, bool recurse) const { LLView* view = findChildView(name, recurse); if (view) diff --git a/indra/llui/llmenugl.h b/indra/llui/llmenugl.h index fc71391f23..e5eada41c5 100644 --- a/indra/llui/llmenugl.h +++ b/indra/llui/llmenugl.h @@ -457,7 +457,7 @@ public: virtual bool hasAccelerator(const KEY &key, const MASK &mask) const; virtual bool handleAcceleratorKey(KEY key, MASK mask); - LLMenuGL* findChildMenuByName(const std::string& name, bool recurse) const; + LLMenuGL* findChildMenuByName(std::string_view name, bool recurse) const; bool clearHoverItem(); @@ -480,12 +480,12 @@ public: // setItemEnabled() - pass the name and the enable flag for a // menu item. true will make sure it's enabled, false will disable // it. - void setItemEnabled( const std::string& name, bool enable ); + void setItemEnabled(std::string_view name, bool enable ); // propagate message to submenus void setEnabledSubMenus(bool enable); - void setItemVisible( const std::string& name, bool visible); + void setItemVisible(std::string_view name, bool visible); void setItemLabel(const std::string &name, const std::string &label); @@ -692,8 +692,8 @@ public: virtual void openMenu(); - virtual LLView* getChildView(const std::string& name, bool recurse = true) const; - virtual LLView* findChildView(const std::string& name, bool recurse = true) const; + virtual LLView* getChildView(std::string_view name, bool recurse = true) const; + virtual LLView* findChildView(std::string_view name, bool recurse = true) const; private: LLHandle mBranchHandle; diff --git a/indra/llui/llnotifications.cpp b/indra/llui/llnotifications.cpp index 204a6a178f..a64f69a9e8 100644 --- a/indra/llui/llnotifications.cpp +++ b/indra/llui/llnotifications.cpp @@ -267,7 +267,7 @@ LLSD LLNotificationForm::asLLSD() const return mFormData; } -LLSD LLNotificationForm::getElement(const std::string& element_name) +LLSD LLNotificationForm::getElement(std::string_view element_name) { for (LLSD::array_const_iterator it = mFormData.beginArray(); it != mFormData.endArray(); @@ -279,7 +279,7 @@ LLSD LLNotificationForm::getElement(const std::string& element_name) } -bool LLNotificationForm::hasElement(const std::string& element_name) const +bool LLNotificationForm::hasElement(std::string_view element_name) const { for (LLSD::array_const_iterator it = mFormData.beginArray(); it != mFormData.endArray(); @@ -302,7 +302,7 @@ void LLNotificationForm::getElements(LLSD& elements, S32 offset) } } -bool LLNotificationForm::getElementEnabled(const std::string& element_name) const +bool LLNotificationForm::getElementEnabled(std::string_view element_name) const { for (LLSD::array_const_iterator it = mFormData.beginArray(); it != mFormData.endArray(); @@ -317,7 +317,7 @@ bool LLNotificationForm::getElementEnabled(const std::string& element_name) cons return false; } -void LLNotificationForm::setElementEnabled(const std::string& element_name, bool enabled) +void LLNotificationForm::setElementEnabled(std::string_view element_name, bool enabled) { for (LLSD::array_iterator it = mFormData.beginArray(); it != mFormData.endArray(); @@ -440,7 +440,7 @@ LLNotificationTemplate::LLNotificationTemplate(const LLNotificationTemplate::Par mSoundName("") { if (p.sound.isProvided() && LLUI::getInstance()->mSettingGroups["config"] - && LLUI::getInstance()->mSettingGroups["config"]->controlExists(p.sound)) + && LLUI::getInstance()->mSettingGroups["config"]->controlExists(p.sound())) { mSoundName = p.sound; } @@ -770,7 +770,7 @@ bool LLNotification::hasUniquenessConstraints() const return (mTemplatep ? mTemplatep->mUnique : false); } -bool LLNotification::matchesTag(const std::string& tag) +bool LLNotification::matchesTag(std::string_view tag) { bool result = false; @@ -1464,11 +1464,12 @@ void LLNotifications::createDefaultChannels() } -LLNotificationTemplatePtr LLNotifications::getTemplate(const std::string& name) +LLNotificationTemplatePtr LLNotifications::getTemplate(std::string_view name) { - if (mTemplates.count(name)) + auto it = mTemplates.find(name); + if (it != mTemplates.end()) { - return mTemplates[name]; + return it->second; } else { @@ -1476,7 +1477,7 @@ LLNotificationTemplatePtr LLNotifications::getTemplate(const std::string& name) } } -bool LLNotifications::templateExists(const std::string& name) +bool LLNotifications::templateExists(std::string_view name) { return (mTemplates.count(name) != 0); } @@ -1762,7 +1763,7 @@ void LLNotifications::cancel(LLNotificationPtr pNotif) } } -void LLNotifications::cancelByName(const std::string& name) +void LLNotifications::cancelByName(std::string_view name) { LLMutexLock lock(&mItemsMutex); std::vector notifs_to_cancel; @@ -1837,7 +1838,7 @@ LLNotificationPtr LLNotifications::find(LLUUID uuid) } } -std::string LLNotifications::getGlobalString(const std::string& key) const +std::string LLNotifications::getGlobalString(std::string_view key) const { GlobalStringMap::const_iterator it = mGlobalStrings.find(key); if (it != mGlobalStrings.end()) @@ -1848,7 +1849,7 @@ std::string LLNotifications::getGlobalString(const std::string& key) const { // if we don't have the key as a global, return the key itself so that the error // is self-diagnosing. - return key; + return std::string(key); } } @@ -1861,13 +1862,13 @@ bool LLNotifications::getIgnoreAllNotifications() return mIgnoreAllNotifications; } -void LLNotifications::setIgnored(const std::string& name, bool ignored) +void LLNotifications::setIgnored(std::string_view name, bool ignored) { LLNotificationTemplatePtr templatep = getTemplate(name); templatep->mForm->setIgnored(ignored); } -bool LLNotifications::getIgnored(const std::string& name) +bool LLNotifications::getIgnored(std::string_view name) { LLNotificationTemplatePtr templatep = getTemplate(name); return (mIgnoreAllNotifications) || ( (templatep->mForm->getIgnoreType() != LLNotificationForm::IGNORE_NO) && (templatep->mForm->getIgnored()) ); diff --git a/indra/llui/llnotifications.h b/indra/llui/llnotifications.h index 5d46e48cf3..286e3a779b 100644 --- a/indra/llui/llnotifications.h +++ b/indra/llui/llnotifications.h @@ -252,11 +252,11 @@ public: S32 getNumElements() { return static_cast(mFormData.size()); } LLSD getElement(S32 index) { return mFormData.get(index); } - LLSD getElement(const std::string& element_name); + LLSD getElement(std::string_view element_name); void getElements(LLSD& elements, S32 offset = 0); - bool hasElement(const std::string& element_name) const; - bool getElementEnabled(const std::string& element_name) const; - void setElementEnabled(const std::string& element_name, bool enabled); + bool hasElement(std::string_view element_name) const; + bool getElementEnabled(std::string_view element_name) const; + void setElementEnabled(std::string_view element_name, bool enabled); void addElement(const std::string& type, const std::string& name, const LLSD& value = LLSD(), bool enabled = true); void formatElements(const LLSD& substitutions); // appends form elements from another form serialized as LLSD @@ -646,7 +646,7 @@ public: bool hasUniquenessConstraints() const; - bool matchesTag(const std::string& tag); + bool matchesTag(std::string_view tag); virtual ~LLNotification() {} }; @@ -931,7 +931,7 @@ public: void add(const LLNotificationPtr pNotif); void load(const LLNotificationPtr pNotif); void cancel(LLNotificationPtr pNotif); - void cancelByName(const std::string& name); + void cancelByName(std::string_view name); void cancelByOwner(const LLUUID ownerId); void update(const LLNotificationPtr pNotif); @@ -939,19 +939,19 @@ public: // This is all stuff for managing the templates // take your template out - LLNotificationTemplatePtr getTemplate(const std::string& name); + LLNotificationTemplatePtr getTemplate(std::string_view name); // get the whole collection typedef std::vector TemplateNames; TemplateNames getTemplateNames() const; // returns a list of notification names - typedef std::map TemplateMap; + typedef std::map> TemplateMap; TemplateMap::const_iterator templatesBegin() { return mTemplates.begin(); } TemplateMap::const_iterator templatesEnd() { return mTemplates.end(); } // test for existence - bool templateExists(const std::string& name); + bool templateExists(std::string_view name); typedef std::list VisibilityRuleList; @@ -961,13 +961,13 @@ public: LLNotificationChannelPtr getChannel(const std::string& channelName); - std::string getGlobalString(const std::string& key) const; + std::string getGlobalString(std::string_view key) const; void setIgnoreAllNotifications(bool ignore); bool getIgnoreAllNotifications(); - void setIgnored(const std::string& name, bool ignored); - bool getIgnored(const std::string& name); + void setIgnored(std::string_view name, bool ignored); + bool getIgnored(std::string_view name); bool isVisibleByRules(LLNotificationPtr pNotification); @@ -993,7 +993,7 @@ private: LLNotificationMap mUniqueNotifications; - typedef std::map GlobalStringMap; + typedef std::map> GlobalStringMap; GlobalStringMap mGlobalStrings; bool mIgnoreAllNotifications; diff --git a/indra/llui/llnotificationslistener.cpp b/indra/llui/llnotificationslistener.cpp index ace9e37e25..9c1fc27c51 100644 --- a/indra/llui/llnotificationslistener.cpp +++ b/indra/llui/llnotificationslistener.cpp @@ -191,7 +191,7 @@ void LLNotificationsListener::ignore(const LLSD& params) const if (params["name"].isDefined()) { // ["name"] was passed: ignore just that notification - LLNotificationTemplatePtr templatep = mNotifications.getTemplate(params["name"]); + LLNotificationTemplatePtr templatep = mNotifications.getTemplate(params["name"].asStringRef()); if (templatep) { templatep->mForm->setIgnored(ignore); diff --git a/indra/llui/llpanel.cpp b/indra/llui/llpanel.cpp index f6f32d82d0..aeeeea7af7 100644 --- a/indra/llui/llpanel.cpp +++ b/indra/llui/llpanel.cpp @@ -55,7 +55,7 @@ LLPanel::factory_stack_t LLPanel::sFactoryStack; // Compiler optimization, generate extern template template class LLPanel* LLView::getChild( - const std::string& name, bool recurse) const; + std::string_view name, bool recurse) const; LLPanel::LocalizedString::LocalizedString() : name("name"), @@ -277,7 +277,7 @@ void LLPanel::setDefaultBtn(LLButton* btn) } } -void LLPanel::setDefaultBtn(const std::string& id) +void LLPanel::setDefaultBtn(std::string_view id) { LLButton *button = getChild(id); if (button) @@ -593,12 +593,12 @@ bool LLPanel::initPanelXML(LLXMLNodePtr node, LLView *parent, LLXMLNodePtr outpu return true; } -bool LLPanel::hasString(const std::string& name) +bool LLPanel::hasString(std::string_view name) { return mUIStrings.find(name) != mUIStrings.end(); } -std::string LLPanel::getString(const std::string& name, const LLStringUtil::format_map_t& args) const +std::string LLPanel::getString(std::string_view name, const LLStringUtil::format_map_t& args) const { ui_string_map_t::const_iterator found_it = mUIStrings.find(name); if (found_it != mUIStrings.end()) @@ -608,7 +608,7 @@ std::string LLPanel::getString(const std::string& name, const LLStringUtil::form formatted_string.setArgList(args); return formatted_string.getString(); } - std::string err_str("Failed to find string " + name + " in panel " + getName() + " loaded from file " + mXMLFilename); //*TODO: Translate + std::string err_str("Failed to find string " + std::string(name) + " in panel " + getName() + " loaded from file " + mXMLFilename); //*TODO: Translate if(LLUI::getInstance()->mSettingGroups["config"]->getBOOL("QAMode")) { LL_ERRS() << err_str << LL_ENDL; @@ -620,14 +620,14 @@ std::string LLPanel::getString(const std::string& name, const LLStringUtil::form return LLStringUtil::null; } -std::string LLPanel::getString(const std::string& name) const +std::string LLPanel::getString(std::string_view name) const { ui_string_map_t::const_iterator found_it = mUIStrings.find(name); if (found_it != mUIStrings.end()) { return found_it->second; } - std::string err_str("Failed to find string " + name + " in panel " + getName() + " loaded from file " + mXMLFilename); //*TODO: Translate + std::string err_str("Failed to find string " + std::string(name) + " in panel " + getName() + " loaded from file " + mXMLFilename); //*TODO: Translate if(LLUI::getInstance()->mSettingGroups["config"]->getBOOL("QAMode")) { LL_ERRS() << err_str << LL_ENDL; @@ -640,7 +640,7 @@ std::string LLPanel::getString(const std::string& name) const } -void LLPanel::childSetVisible(const std::string& id, bool visible) +void LLPanel::childSetVisible(std::string_view id, bool visible) { LLView* child = findChild(id); if (child) @@ -649,7 +649,7 @@ void LLPanel::childSetVisible(const std::string& id, bool visible) } } -void LLPanel::childSetEnabled(const std::string& id, bool enabled) +void LLPanel::childSetEnabled(std::string_view id, bool enabled) { LLView* child = findChild(id); if (child) @@ -658,7 +658,7 @@ void LLPanel::childSetEnabled(const std::string& id, bool enabled) } } -void LLPanel::childSetFocus(const std::string& id, bool focus) +void LLPanel::childSetFocus(std::string_view id, bool focus) { LLUICtrl* child = findChild(id); if (child) @@ -667,7 +667,7 @@ void LLPanel::childSetFocus(const std::string& id, bool focus) } } -bool LLPanel::childHasFocus(const std::string& id) +bool LLPanel::childHasFocus(std::string_view id) { LLUICtrl* child = findChild(id); if (child) @@ -684,7 +684,7 @@ bool LLPanel::childHasFocus(const std::string& id) // Prefer getChild("foo")->setCommitCallback(boost:bind(...)), // which takes a generic slot. Or use mCommitCallbackRegistrar.add() with // a named callback and reference it in XML. -void LLPanel::childSetCommitCallback(const std::string& id, boost::function cb, void* data) +void LLPanel::childSetCommitCallback(std::string_view id, boost::function cb, void* data) { LLUICtrl* child = findChild(id); if (child) @@ -693,7 +693,7 @@ void LLPanel::childSetCommitCallback(const std::string& id, boost::function(id); if (child) @@ -702,7 +702,7 @@ void LLPanel::childSetColor(const std::string& id, const LLColor4& color) } } -LLCtrlSelectionInterface* LLPanel::childGetSelectionInterface(const std::string& id) const +LLCtrlSelectionInterface* LLPanel::childGetSelectionInterface(std::string_view id) const { LLUICtrl* child = findChild(id); if (child) @@ -712,7 +712,7 @@ LLCtrlSelectionInterface* LLPanel::childGetSelectionInterface(const std::string& return NULL; } -LLCtrlListInterface* LLPanel::childGetListInterface(const std::string& id) const +LLCtrlListInterface* LLPanel::childGetListInterface(std::string_view id) const { LLUICtrl* child = findChild(id); if (child) @@ -722,7 +722,7 @@ LLCtrlListInterface* LLPanel::childGetListInterface(const std::string& id) const return NULL; } -LLCtrlScrollInterface* LLPanel::childGetScrollInterface(const std::string& id) const +LLCtrlScrollInterface* LLPanel::childGetScrollInterface(std::string_view id) const { LLUICtrl* child = findChild(id); if (child) @@ -732,7 +732,7 @@ LLCtrlScrollInterface* LLPanel::childGetScrollInterface(const std::string& id) c return NULL; } -void LLPanel::childSetValue(const std::string& id, LLSD value) +void LLPanel::childSetValue(std::string_view id, LLSD value) { LLUICtrl* child = findChild(id); if (child) @@ -741,7 +741,7 @@ void LLPanel::childSetValue(const std::string& id, LLSD value) } } -LLSD LLPanel::childGetValue(const std::string& id) const +LLSD LLPanel::childGetValue(std::string_view id) const { LLUICtrl* child = findChild(id); if (child) @@ -752,7 +752,7 @@ LLSD LLPanel::childGetValue(const std::string& id) const return LLSD(); } -bool LLPanel::childSetTextArg(const std::string& id, const std::string& key, const LLStringExplicit& text) +bool LLPanel::childSetTextArg(std::string_view id, const std::string& key, const LLStringExplicit& text) { LLUICtrl* child = findChild(id); if (child) @@ -762,7 +762,7 @@ bool LLPanel::childSetTextArg(const std::string& id, const std::string& key, con return false; } -bool LLPanel::childSetLabelArg(const std::string& id, const std::string& key, const LLStringExplicit& text) +bool LLPanel::childSetLabelArg(std::string_view id, const std::string& key, const LLStringExplicit& text) { LLView* child = findChild(id); if (child) @@ -772,7 +772,7 @@ bool LLPanel::childSetLabelArg(const std::string& id, const std::string& key, co return false; } -void LLPanel::childSetAction(const std::string& id, const commit_signal_t::slot_type& function) +void LLPanel::childSetAction(std::string_view id, const commit_signal_t::slot_type& function) { LLButton* button = findChild(id); if (button) @@ -781,7 +781,7 @@ void LLPanel::childSetAction(const std::string& id, const commit_signal_t::slot_ } } -void LLPanel::childSetAction(const std::string& id, boost::function function, void* value) +void LLPanel::childSetAction(std::string_view id, boost::function function, void* value) { LLButton* button = findChild(id); if (button) diff --git a/indra/llui/llpanel.h b/indra/llui/llpanel.h index 1236c09891..26ee9e6c8b 100644 --- a/indra/llui/llpanel.h +++ b/indra/llui/llpanel.h @@ -149,7 +149,7 @@ public: void setBackgroundOpaque(bool b) { mBgOpaque = b; } bool isBackgroundOpaque() const { return mBgOpaque; } void setDefaultBtn(LLButton* btn = NULL); - void setDefaultBtn(const std::string& id); + void setDefaultBtn(std::string_view id); void updateDefaultBtn(); void setLabel(const LLStringExplicit& label) { mLabel = label; } std::string getLabel() const { return mLabel; } @@ -169,47 +169,47 @@ public: void initFromParams(const Params& p); bool initPanelXML( LLXMLNodePtr node, LLView *parent, LLXMLNodePtr output_node, const LLPanel::Params& default_params); - bool hasString(const std::string& name); - std::string getString(const std::string& name, const LLStringUtil::format_map_t& args) const; - std::string getString(const std::string& name) const; + bool hasString(std::string_view name); + std::string getString(std::string_view name, const LLStringUtil::format_map_t& args) const; + std::string getString(std::string_view name) const; // ** Wrappers for setting child properties by name ** -TomY // WARNING: These are deprecated, please use getChild("name")->doStuff() idiom instead // LLView - void childSetVisible(const std::string& name, bool visible); + void childSetVisible(std::string_view name, bool visible); - void childSetEnabled(const std::string& name, bool enabled); - void childEnable(const std::string& name) { childSetEnabled(name, true); } - void childDisable(const std::string& name) { childSetEnabled(name, false); }; + void childSetEnabled(std::string_view name, bool enabled); + void childEnable(std::string_view name) { childSetEnabled(name, true); } + void childDisable(std::string_view name) { childSetEnabled(name, false); }; // LLUICtrl - void childSetFocus(const std::string& id, bool focus = true); - bool childHasFocus(const std::string& id); + void childSetFocus(std::string_view id, bool focus = true); + bool childHasFocus(std::string_view id); // *TODO: Deprecate; for backwards compatability only: // Prefer getChild("foo")->setCommitCallback(boost:bind(...)), // which takes a generic slot. Or use mCommitCallbackRegistrar.add() with // a named callback and reference it in XML. - void childSetCommitCallback(const std::string& id, boost::function cb, void* data); - void childSetColor(const std::string& id, const LLColor4& color); + void childSetCommitCallback(std::string_view id, boost::function cb, void* data); + void childSetColor(std::string_view id, const LLColor4& color); - LLCtrlSelectionInterface* childGetSelectionInterface(const std::string& id) const; - LLCtrlListInterface* childGetListInterface(const std::string& id) const; - LLCtrlScrollInterface* childGetScrollInterface(const std::string& id) const; + LLCtrlSelectionInterface* childGetSelectionInterface(std::string_view id) const; + LLCtrlListInterface* childGetListInterface(std::string_view id) const; + LLCtrlScrollInterface* childGetScrollInterface(std::string_view id) const; // This is the magic bullet for data-driven UI - void childSetValue(const std::string& id, LLSD value); - LLSD childGetValue(const std::string& id) const; + void childSetValue(std::string_view id, LLSD value); + LLSD childGetValue(std::string_view id) const; // For setting text / label replacement params, e.g. "Hello [NAME]" // Not implemented for all types, defaults to noop, returns false if not applicaple - bool childSetTextArg(const std::string& id, const std::string& key, const LLStringExplicit& text); - bool childSetLabelArg(const std::string& id, const std::string& key, const LLStringExplicit& text); + bool childSetTextArg(std::string_view id, const std::string& key, const LLStringExplicit& text); + bool childSetLabelArg(std::string_view id, const std::string& key, const LLStringExplicit& text); // LLButton - void childSetAction(const std::string& id, boost::function function, void* value); - void childSetAction(const std::string& id, const commit_signal_t::slot_type& function); + void childSetAction(std::string_view id, boost::function function, void* value); + void childSetAction(std::string_view id, const commit_signal_t::slot_type& function); static LLView* fromXML(LLXMLNodePtr node, LLView *parent, LLXMLNodePtr output_node = NULL); @@ -250,7 +250,7 @@ private: LLButton* mDefaultBtn; LLUIString mLabel; - typedef std::map ui_string_map_t; + typedef std::map> ui_string_map_t; ui_string_map_t mUIStrings; @@ -259,7 +259,7 @@ private: // Build time optimization, generate once in .cpp file #ifndef LLPANEL_CPP extern template class LLPanel* LLView::getChild( - const std::string& name, bool recurse) const; + std::string_view name, bool recurse) const; #endif typedef boost::function LLPanelClassCreatorFunc; @@ -277,7 +277,7 @@ public: mPanelClassesNames[tag] = func; } - LLPanel* createPanelClass(const std::string& tag) + LLPanel* createPanelClass(std::string_view tag) { param_name_map_t::iterator iT = mPanelClassesNames.find(tag); if(iT == mPanelClassesNames.end()) @@ -292,7 +292,7 @@ public: } private: - typedef std::map< std::string, LLPanelClassCreatorFunc> param_name_map_t; + typedef std::map< std::string, LLPanelClassCreatorFunc, std::less<>> param_name_map_t; param_name_map_t mPanelClassesNames; }; diff --git a/indra/llui/lltabcontainer.cpp b/indra/llui/lltabcontainer.cpp index 4dcb0456e3..3cecf95cb7 100644 --- a/indra/llui/lltabcontainer.cpp +++ b/indra/llui/lltabcontainer.cpp @@ -344,7 +344,7 @@ void LLTabContainer::reshape(S32 width, S32 height, bool called_from_parent) } //virtual -LLView* LLTabContainer::getChildView(const std::string& name, bool recurse) const +LLView* LLTabContainer::getChildView(std::string_view name, bool recurse) const { tuple_list_t::const_iterator itor; for (itor = mTabList.begin(); itor != mTabList.end(); ++itor) @@ -372,7 +372,7 @@ LLView* LLTabContainer::getChildView(const std::string& name, bool recurse) cons } //virtual -LLView* LLTabContainer::findChildView(const std::string& name, bool recurse) const +LLView* LLTabContainer::findChildView(std::string_view name, bool recurse) const { tuple_list_t::const_iterator itor; for (itor = mTabList.begin(); itor != mTabList.end(); ++itor) @@ -1542,7 +1542,7 @@ S32 LLTabContainer::getIndexForPanel(LLPanel* panel) return -1; } -S32 LLTabContainer::getPanelIndexByTitle(const std::string& title) +S32 LLTabContainer::getPanelIndexByTitle(std::string_view title) { for (S32 index = 0 ; index < (S32)mTabList.size(); index++) { @@ -1554,7 +1554,7 @@ S32 LLTabContainer::getPanelIndexByTitle(const std::string& title) return -1; } -LLPanel* LLTabContainer::getPanelByName(const std::string& name) +LLPanel* LLTabContainer::getPanelByName(std::string_view name) { for (S32 index = 0 ; index < (S32)mTabList.size(); index++) { @@ -1783,7 +1783,7 @@ bool LLTabContainer::setTab(S32 which) return is_visible; } -bool LLTabContainer::selectTabByName(const std::string& name) +bool LLTabContainer::selectTabByName(std::string_view name) { LLPanel* panel = getPanelByName(name); if (!panel) diff --git a/indra/llui/lltabcontainer.h b/indra/llui/lltabcontainer.h index 069002a9ad..e97f458c9d 100644 --- a/indra/llui/lltabcontainer.h +++ b/indra/llui/lltabcontainer.h @@ -166,8 +166,8 @@ public: /*virtual*/ bool handleDragAndDrop(S32 x, S32 y, MASK mask, bool drop, EDragAndDropType type, void* cargo_data, EAcceptance* accept, std::string& tooltip); - /*virtual*/ LLView* getChildView(const std::string& name, bool recurse = true) const; - /*virtual*/ LLView* findChildView(const std::string& name, bool recurse = true) const; + /*virtual*/ LLView* getChildView(std::string_view name, bool recurse = true) const; + /*virtual*/ LLView* findChildView(std::string_view name, bool recurse = true) const; /*virtual*/ void initFromParams(const LLPanel::Params& p); /*virtual*/ bool addChild(LLView* view, S32 tab_group = 0); /*virtual*/ bool postBuild(); @@ -207,8 +207,8 @@ public: S32 getTabCount(); LLPanel* getPanelByIndex(S32 index); S32 getIndexForPanel(LLPanel* panel); - S32 getPanelIndexByTitle(const std::string& title); - LLPanel* getPanelByName(const std::string& name); + S32 getPanelIndexByTitle(std::string_view title); + LLPanel* getPanelByName(std::string_view name); S32 getTotalTabWidth() const; void setCurrentTabName(const std::string& name); @@ -218,7 +218,7 @@ public: void selectPrevTab(); bool selectTabPanel( LLPanel* child ); bool selectTab(S32 which); - bool selectTabByName(const std::string& title); + bool selectTabByName(std::string_view title); void setCurrentPanelIndex(S32 index) { mCurrentTabIdx = index; } bool getTabPanelFlashing(LLPanel* child); diff --git a/indra/llui/lltextbox.cpp b/indra/llui/lltextbox.cpp index 3b8fea8a62..877f9ac6b8 100644 --- a/indra/llui/lltextbox.cpp +++ b/indra/llui/lltextbox.cpp @@ -41,7 +41,7 @@ static LLDefaultChildRegistry::Register r("text"); // Compiler optimization, generate extern template template class LLTextBox* LLView::getChild( - const std::string& name, bool recurse) const; + std::string_view name, bool recurse) const; LLTextBox::LLTextBox(const LLTextBox::Params& p) : LLTextBase(p), diff --git a/indra/llui/lltextbox.h b/indra/llui/lltextbox.h index 2625368edc..6fa8f28d4f 100644 --- a/indra/llui/lltextbox.h +++ b/indra/llui/lltextbox.h @@ -93,7 +93,7 @@ protected: // Build time optimization, generate once in .cpp file #ifndef LLTEXTBOX_CPP extern template class LLTextBox* LLView::getChild( - const std::string& name, bool recurse) const; + std::string_view name, bool recurse) const; #endif #endif diff --git a/indra/llui/lltexteditor.cpp b/indra/llui/lltexteditor.cpp index 2dcc57c0ed..b0979a9518 100644 --- a/indra/llui/lltexteditor.cpp +++ b/indra/llui/lltexteditor.cpp @@ -71,7 +71,7 @@ static LLDefaultChildRegistry::Register r("simple_text_editor"); // Compiler optimization, generate extern template template class LLTextEditor* LLView::getChild( - const std::string& name, bool recurse) const; + std::string_view name, bool recurse) const; // // Constants diff --git a/indra/llui/lltexteditor.h b/indra/llui/lltexteditor.h index 8dea44ad14..fade04097d 100644 --- a/indra/llui/lltexteditor.h +++ b/indra/llui/lltexteditor.h @@ -361,7 +361,7 @@ private: // Build time optimization, generate once in .cpp file #ifndef LLTEXTEDITOR_CPP extern template class LLTextEditor* LLView::getChild( - const std::string& name, bool recurse) const; + std::string_view name, bool recurse) const; #endif #endif // LL_TEXTEDITOR_H diff --git a/indra/llui/lltrans.cpp b/indra/llui/lltrans.cpp index 6c7e472a87..8410031653 100644 --- a/indra/llui/lltrans.cpp +++ b/indra/llui/lltrans.cpp @@ -65,7 +65,7 @@ bool LLTrans::parseStrings(LLXMLNodePtr &root, const std::set& defa if (!root->hasName("strings")) { LL_ERRS() << "Invalid root node name in " << xml_filename - << ": was " << root->getName() << ", expected \"strings\"" << LL_ENDL; + << ": was " << root->getName()->mString << ", expected \"strings\"" << LL_ENDL; } StringTable string_table; @@ -113,7 +113,7 @@ bool LLTrans::parseLanguageStrings(LLXMLNodePtr &root) if (!root->hasName("strings")) { LL_ERRS() << "Invalid root node name in " << xml_filename - << ": was " << root->getName() << ", expected \"strings\"" << LL_ENDL; + << ": was " << root->getName()->mString << ", expected \"strings\"" << LL_ENDL; } StringTable string_table; @@ -143,7 +143,7 @@ bool LLTrans::parseLanguageStrings(LLXMLNodePtr &root) static LLTrace::BlockTimerStatHandle FTM_GET_TRANS("Translate string"); //static -std::string LLTrans::getString(const std::string &xml_desc, const LLStringUtil::format_map_t& msg_args, bool def_string) +std::string LLTrans::getString(std::string_view xml_desc, const LLStringUtil::format_map_t& msg_args, bool def_string) { // Don't care about time as much as call count. Make sure we're not // calling LLTrans::getString() in an inner loop. JC @@ -167,12 +167,12 @@ std::string LLTrans::getString(const std::string &xml_desc, const LLStringUtil:: else { LL_WARNS_ONCE("configuration") << "Missing String in strings.xml: [" << xml_desc << "]" << LL_ENDL; - return "MissingString("+xml_desc+")"; + return "MissingString(" + std::string(xml_desc) + ")"; } } //static -std::string LLTrans::getDefString(const std::string &xml_desc, const LLStringUtil::format_map_t& msg_args) +std::string LLTrans::getDefString(std::string_view xml_desc, const LLStringUtil::format_map_t& msg_args) { template_map_t::iterator iter = sDefaultStringTemplates.find(xml_desc); if (iter != sDefaultStringTemplates.end()) @@ -187,12 +187,12 @@ std::string LLTrans::getDefString(const std::string &xml_desc, const LLStringUti else { LL_WARNS_ONCE("configuration") << "Missing String in strings.xml: [" << xml_desc << "]" << LL_ENDL; - return "MissingString(" + xml_desc + ")"; + return "MissingString(" + std::string(xml_desc) + ")"; } } //static -std::string LLTrans::getString(const std::string &xml_desc, const LLSD& msg_args, bool def_string) +std::string LLTrans::getString(std::string_view xml_desc, const LLSD& msg_args, bool def_string) { // Don't care about time as much as call count. Make sure we're not // calling LLTrans::getString() in an inner loop. JC @@ -213,12 +213,12 @@ std::string LLTrans::getString(const std::string &xml_desc, const LLSD& msg_args else { LL_WARNS_ONCE("configuration") << "Missing String in strings.xml: [" << xml_desc << "]" << LL_ENDL; - return "MissingString("+xml_desc+")"; + return "MissingString(" + std::string(xml_desc) + ")"; } } //static -std::string LLTrans::getDefString(const std::string &xml_desc, const LLSD& msg_args) +std::string LLTrans::getDefString(std::string_view xml_desc, const LLSD& msg_args) { template_map_t::iterator iter = sDefaultStringTemplates.find(xml_desc); if (iter != sDefaultStringTemplates.end()) @@ -230,12 +230,12 @@ std::string LLTrans::getDefString(const std::string &xml_desc, const LLSD& msg_a else { LL_WARNS_ONCE("configuration") << "Missing String in strings.xml: [" << xml_desc << "]" << LL_ENDL; - return "MissingString(" + xml_desc + ")"; + return "MissingString(" + std::string(xml_desc) + ")"; } } //static -bool LLTrans::findString(std::string &result, const std::string &xml_desc, const LLStringUtil::format_map_t& msg_args) +bool LLTrans::findString(std::string &result, std::string_view xml_desc, const LLStringUtil::format_map_t& msg_args) { LL_PROFILE_ZONE_SCOPED_CATEGORY_UI; @@ -257,7 +257,7 @@ bool LLTrans::findString(std::string &result, const std::string &xml_desc, const } //static -bool LLTrans::findString(std::string &result, const std::string &xml_desc, const LLSD& msg_args) +bool LLTrans::findString(std::string &result, std::string_view xml_desc, const LLSD& msg_args) { LL_PROFILE_ZONE_SCOPED_CATEGORY_UI; diff --git a/indra/llui/lltrans.h b/indra/llui/lltrans.h index 4f38ef9067..3492ed0169 100644 --- a/indra/llui/lltrans.h +++ b/indra/llui/lltrans.h @@ -76,12 +76,12 @@ public: * @param args A list of substrings to replace in the string * @returns Translated string */ - static std::string getString(const std::string &xml_desc, const LLStringUtil::format_map_t& args, bool def_string = false); - static std::string getDefString(const std::string &xml_desc, const LLStringUtil::format_map_t& args); - static std::string getString(const std::string &xml_desc, const LLSD& args, bool def_string = false); - static std::string getDefString(const std::string &xml_desc, const LLSD& args); - static bool findString(std::string &result, const std::string &xml_desc, const LLStringUtil::format_map_t& args); - static bool findString(std::string &result, const std::string &xml_desc, const LLSD& args); + static std::string getString(std::string_view xml_desc, const LLStringUtil::format_map_t& args, bool def_string = false); + static std::string getDefString(std::string_view xml_desc, const LLStringUtil::format_map_t& args); + static std::string getString(std::string_view xml_desc, const LLSD& args, bool def_string = false); + static std::string getDefString(std::string_view xml_desc, const LLSD& args); + static bool findString(std::string &result, std::string_view xml_desc, const LLStringUtil::format_map_t& args); + static bool findString(std::string &result, std::string_view xml_desc, const LLSD& args); // Returns translated string with [COUNT] replaced with a number, following // special per-language logic for plural nouns. For example, some languages @@ -94,23 +94,22 @@ public: * @param xml_desc String's description * @returns Translated string */ - static std::string getString(const std::string &xml_desc, bool def_string = false) + static std::string getString(std::string_view xml_desc, bool def_string = false) { LLStringUtil::format_map_t empty; return getString(xml_desc, empty); } - static bool findString(std::string &result, const std::string &xml_desc) + static bool findString(std::string &result, std::string_view xml_desc) { LLStringUtil::format_map_t empty; return findString(result, xml_desc, empty); } - static std::string getKeyboardString(const char* keystring) + static std::string getKeyboardString(const std::string_view keystring) { - std::string key_str(keystring); std::string trans_str; - return findString(trans_str, key_str) ? trans_str : key_str; + return findString(trans_str, keystring) ? trans_str : std::string(keystring); } // get the default args @@ -128,7 +127,7 @@ public: } private: - typedef std::map template_map_t; + typedef std::map> template_map_t; static template_map_t sStringTemplates; static template_map_t sDefaultStringTemplates; static LLStringUtil::format_map_t sDefaultArgs; diff --git a/indra/llui/llui.cpp b/indra/llui/llui.cpp index 5555157eca..0a4e3a59fa 100644 --- a/indra/llui/llui.cpp +++ b/indra/llui/llui.cpp @@ -194,11 +194,11 @@ mHelpImpl(NULL) LLUICtrl::CommitCallbackRegistry::Registrar& reg = LLUICtrl::CommitCallbackRegistry::defaultRegistrar(); // Callbacks for associating controls with floater visibility: - reg.add("Floater.Toggle", boost::bind(&LLFloaterReg::toggleInstance, _2, LLSD())); - reg.add("Floater.ToggleOrBringToFront", boost::bind(&LLFloaterReg::toggleInstanceOrBringToFront, _2, LLSD())); - reg.add("Floater.Show", boost::bind(&LLFloaterReg::showInstance, _2, LLSD(), false)); - reg.add("Floater.ShowOrBringToFront", boost::bind(&LLFloaterReg::showInstanceOrBringToFront, _2, LLSD())); - reg.add("Floater.Hide", boost::bind(&LLFloaterReg::hideInstance, _2, LLSD())); + reg.add("Floater.Toggle", [](LLUICtrl* ctrl, const LLSD& param) -> void { LLFloaterReg::toggleInstance(param.asStringRef()); }); + reg.add("Floater.ToggleOrBringToFront", [](LLUICtrl* ctrl, const LLSD& param) -> void { LLFloaterReg::toggleInstanceOrBringToFront(param.asStringRef()); }); + reg.add("Floater.Show", [](LLUICtrl* ctrl, const LLSD& param) -> void { LLFloaterReg::showInstance(param.asStringRef(), LLSD(), false); }); + reg.add("Floater.ShowOrBringToFront", [](LLUICtrl* ctrl, const LLSD& param) -> void { LLFloaterReg::showInstanceOrBringToFront(param.asStringRef(), LLSD()); }); + reg.add("Floater.Hide", [](LLUICtrl* ctrl, const LLSD& param) -> void { LLFloaterReg::hideInstance(param.asStringRef()); }); // Button initialization callback for toggle buttons reg.add("Button.SetFloaterToggle", boost::bind(&LLButton::setFloaterToggle, _1, _2)); @@ -213,11 +213,11 @@ mHelpImpl(NULL) reg.add("Button.ToggleFloater", boost::bind(&LLButton::toggleFloaterAndSetToggleState, _1, _2)); // Used by menus along with Floater.Toggle to display visibility as a check-mark - LLUICtrl::EnableCallbackRegistry::defaultRegistrar().add("Floater.Visible", boost::bind(&LLFloaterReg::instanceVisible, _2, LLSD())); - LLUICtrl::EnableCallbackRegistry::defaultRegistrar().add("Floater.IsOpen", boost::bind(&LLFloaterReg::instanceVisible, _2, LLSD())); + LLUICtrl::EnableCallbackRegistry::defaultRegistrar().add("Floater.Visible", [](LLUICtrl* ctrl, const LLSD& param) -> bool { return LLFloaterReg::instanceVisible(param.asStringRef(), LLSD()); }); + LLUICtrl::EnableCallbackRegistry::defaultRegistrar().add("Floater.IsOpen", [](LLUICtrl* ctrl, const LLSD& param) -> bool { return LLFloaterReg::instanceVisible(param.asStringRef(), LLSD()); }); // [RLVa:KB] - Checked: 2012-02-07 (RLVa-1.4.5) | Added: RLVa-1.4.5 - LLUICtrl::EnableCallbackRegistry::defaultRegistrar().add("Floater.CanShow", boost::bind(&LLFloaterReg::canShowInstance, _2, LLSD())); -// [/RLVa:KB] + LLUICtrl::EnableCallbackRegistry::defaultRegistrar().add("Floater.CanShow", [](LLUICtrl* ctrl, const LLSD& param) -> bool { return LLFloaterReg::canShowInstance(param.asStringRef(), LLSD()); }); + // [/RLVa:KB] // Parse the master list of commands LLCommandManager::load(); @@ -421,7 +421,7 @@ void LLUI::glRectToScreen(const LLRect& gl, LLRect *screen) } -LLControlGroup& LLUI::getControlControlGroup (const std::string& controlname) +LLControlGroup& LLUI::getControlControlGroup (std::string_view controlname) { for (settings_map_t::iterator itor = mSettingGroups.begin(); itor != mSettingGroups.end(); ++itor) @@ -596,7 +596,7 @@ namespace LLInitParam { if (control.isProvided() && !control().empty()) { - updateValue(LLUIColorTable::instance().getColor(control)); + updateValue(LLUIColorTable::instance().getColor(control())); } else { diff --git a/indra/llui/llui.h b/indra/llui/llui.h index e13800d658..7440ce10a1 100644 --- a/indra/llui/llui.h +++ b/indra/llui/llui.h @@ -121,7 +121,7 @@ typedef void (*LLUIAudioCallback)(const LLUUID& uuid); class LLUI : public LLParamSingleton { public: - typedef std::map settings_map_t; + typedef std::map > settings_map_t; private: LLSINGLETON(LLUI , const settings_map_t &settings, @@ -304,7 +304,7 @@ public: void screenRectToGL(const LLRect& screen, LLRect *gl); void glRectToScreen(const LLRect& gl, LLRect *screen); // Returns the control group containing the control name, or the default group - LLControlGroup& getControlControlGroup (const std::string& controlname); + LLControlGroup& getControlControlGroup (std::string_view controlname); F32 getMouseIdleTime() { return mMouseIdleTimer.getElapsedTimeF32(); } void resetMouseIdleTimer() { mMouseIdleTimer.reset(); } LLWindow* getWindow() { return mWindow; } diff --git a/indra/llui/lluicolortable.cpp b/indra/llui/lluicolortable.cpp index f7cdd4a251..a3ade58acd 100644 --- a/indra/llui/lluicolortable.cpp +++ b/indra/llui/lluicolortable.cpp @@ -63,7 +63,7 @@ void LLUIColorTable::insertFromParams(const Params& p, string_color_map_t& table ColorEntryParams color_entry = *it; if(color_entry.color.value.isChosen()) { - setColor(color_entry.name, color_entry.color.value, table); + setColor(color_entry.name(), color_entry.color.value, table); } else { @@ -131,14 +131,7 @@ void LLUIColorTable::insertFromParams(const Params& p, string_color_map_t& table { // since this reference does not refer to another reference it must refer to an // actual color, lets find it... - - // string_color_map_t::iterator color_value = mLoadedColors.find(previous->second); - - ColorName oName{}; - oName.nLen = previous->second.size(); - oName.pName = const_cast(previous->second.c_str()); // That's ok, I won't hurt you. - - string_color_map_t::iterator color_value = mLoadedColors.find(oName); + string_color_map_t::iterator color_value = mLoadedColors.find(previous->second); if(color_value != mLoadedColors.end()) { @@ -183,31 +176,16 @@ void LLUIColorTable::clear() clearTable(mUserSetColors); } -LLUIColor LLUIColorTable::getColor(const std::string& name, const LLColor4& default_color) const +LLUIColor LLUIColorTable::getColor(std::string_view name, const LLColor4& default_color) const { - return getColor( name.c_str(), default_color ); -} - -LLUIColor LLUIColorTable::getColor( char const *name, const LLColor4& default_color) const // Change from std::string to char*, avoind lots of unecessary string constructions -{ - // Change from std::string to char*, avoind lots of unecessary string constructions - // string_color_map_t::const_iterator iter = mUserSetColors.find(name); - - ColorName oName{}; - oName.nLen = strlen(name); - oName.pName = const_cast(name); - string_color_map_t::const_iterator iter = mUserSetColors.find(oName); - // + string_color_map_t::const_iterator iter = mUserSetColors.find(name); if(iter != mUserSetColors.end()) { return LLUIColor(&iter->second); } - // Change from std::string to char*, avoind lots of unecessary string constructions - // iter = mLoadedColors.find(name); - iter = mLoadedColors.find(oName); - // + iter = mLoadedColors.find(name); if(iter != mLoadedColors.end()) { @@ -218,7 +196,7 @@ LLUIColor LLUIColorTable::getColor( char const *name, const LLColor4& default_co } // update user color, loaded colors are parsed on initialization -void LLUIColorTable::setColor(const std::string& name, const LLColor4& color) +void LLUIColorTable::setColor(std::string_view name, const LLColor4& color) { setColor(name, color, mUserSetColors); } @@ -255,10 +233,7 @@ void LLUIColorTable::saveUserSettings() const continue; ColorEntryParams color_entry; - - // color_entry.name = it->first; - color_entry.name = it->first.pName; - + color_entry.name = it->first; color_entry.color.value = it->second; params.color_entries.add(color_entry); @@ -287,20 +262,13 @@ void LLUIColorTable::saveUserSettingsPaletteOnly() const { Params params; - for(string_color_map_t::const_iterator it = mUserSetColors.begin(); - it != mUserSetColors.end(); - ++it) + for (const auto& [name, value] : mUserSetColors) { ColorEntryParams color_entry; + color_entry.name = name; + color_entry.color.value = value; - // color_entry.name = it->first; - color_entry.name = it->first.pName; - - color_entry.color.value = it->second; - - - - if (((std::string)color_entry.name).compare(0,17,"ColorPaletteEntry") == 0) + if (color_entry.name().compare(0, 17, "ColorPaletteEntry") == 0) params.color_entries.add(color_entry); } @@ -308,12 +276,12 @@ void LLUIColorTable::saveUserSettingsPaletteOnly() const LLXUIParser parser; parser.writeXUI(output_node, params); - if(!output_node->isNull()) + if (!output_node->isNull()) { const std::string& filename = gDirUtilp->getExpandedFilename(LL_PATH_USER_SETTINGS, "colors.xml"); - LLFILE *fp = LLFile::fopen(filename, "w"); + LLFILE* fp = LLFile::fopen(filename, "w"); - if(fp != NULL) + if (fp) { LLXMLNode::writeHeaderToFile(fp); output_node->writeToFile(fp); @@ -323,19 +291,10 @@ void LLUIColorTable::saveUserSettingsPaletteOnly() const } } -// bool LLUIColorTable::colorExists(const std::string& color_name) const -bool LLUIColorTable::colorExists( char const *name ) const +bool LLUIColorTable::colorExists(std::string_view color_name) const { - // Change from std::string to char*, avoind lots of unecessary string constructions - // return ((mLoadedColors.find(color_name) != mLoadedColors.end()) - // || (mUserSetColors.find(color_name) != mUserSetColors.end())); - - ColorName oName{}; - oName.nLen = strlen(name); - oName.pName = const_cast(name); - return ((mLoadedColors.find(oName) != mLoadedColors.end()) - || (mUserSetColors.find(oName) != mUserSetColors.end())); - // + return ((mLoadedColors.find(color_name) != mLoadedColors.end()) + || (mUserSetColors.find(color_name) != mUserSetColors.end())); } void LLUIColorTable::clearTable(string_color_map_t& table) @@ -350,27 +309,17 @@ void LLUIColorTable::clearTable(string_color_map_t& table) // this method inserts a color into the table if it does not exist // if the color already exists it changes the color -void LLUIColorTable::setColor(const std::string& name, const LLColor4& color, string_color_map_t& table) +void LLUIColorTable::setColor(std::string_view name, const LLColor4& color, string_color_map_t& table) { - - // Change from std::string to char*, avoind lots of unecessary string constructions - // string_color_map_t::iterator it = table.lower_bound(name); - - ColorName oName{}; - oName.nLen = name.size(); - oName.pName = const_cast(name.c_str()); - string_color_map_t::iterator it = table.find(oName); - - // if(it != table.end() && !(table.key_comp()(name, it->first))) - if (it != table.end()) - // + string_color_map_t::iterator it = table.lower_bound(name); + if(it != table.end() + && !(table.key_comp()(name, it->first))) { it->second = color; } else { - oName.pName = strdup(oName.pName); - table.insert(string_color_map_t::value_type(oName, color)); + table.insert(it, string_color_map_t::value_type(name, color)); } } diff --git a/indra/llui/lluicolortable.h b/indra/llui/lluicolortable.h index 459f2fb034..ffc792e513 100644 --- a/indra/llui/lluicolortable.h +++ b/indra/llui/lluicolortable.h @@ -42,27 +42,7 @@ class LLUIColorTable : public LLSingleton LOG_CLASS(LLUIColorTable); // consider using sorted vector, can be much faster - - // Change from std::string to char*, avoind lots of unecessary string constructions - - // typedef std::map string_color_map_t; - - struct ColorName - { - char* pName; - size_t nLen; - - bool operator<(ColorName const &aRHS) const - { - if (nLen == aRHS.nLen) - return strcmp(pName, aRHS.pName) < 0; - - return nLen < aRHS.nLen; - } - }; - - typedef std::map string_color_map_t; - // + typedef std::map> string_color_map_t; public: struct ColorParams : LLInitParam::ChoiceBlock @@ -95,24 +75,13 @@ public: void clear(); // color lookup - - LLUIColor getColor(const std::string& name, const LLColor4& default_color = LLColor4::magenta) const; - - // Change from std::string to char*, avoind lots of unecessary string constructions - LLUIColor getColor(char const *name, const LLColor4& default_color = LLColor4::magenta) const; - // + LLUIColor getColor(std::string_view name, const LLColor4& default_color = LLColor4::magenta) const; // if the color is in the table, it's value is changed, otherwise it is added - void setColor(const std::string& name, const LLColor4& color); + void setColor(std::string_view name, const LLColor4& color); // returns true if color_name exists in the table - - // Change from std::string to char*, avoind lots of unecessary string constructions - - // bool colorExists(const std::string& color_name) const; - bool colorExists(char const *name) const; - - // + bool colorExists(std::string_view color_name) const; // loads colors from settings files bool loadFromSettings(); @@ -127,7 +96,7 @@ private: void insertFromParams(const Params& p, string_color_map_t& table); void clearTable(string_color_map_t& table); - void setColor(const std::string& name, const LLColor4& color, string_color_map_t& table); + void setColor(std::string_view name, const LLColor4& color, string_color_map_t& table); string_color_map_t mLoadedColors; string_color_map_t mUserSetColors; diff --git a/indra/llui/lluictrl.cpp b/indra/llui/lluictrl.cpp index 8857ba6f87..281ffb98a8 100644 --- a/indra/llui/lluictrl.cpp +++ b/indra/llui/lluictrl.cpp @@ -44,7 +44,7 @@ F32 LLUICtrl::sInactiveControlTransparency = 1.0f; // Compiler optimization, generate extern template template class LLUICtrl* LLView::getChild( - const std::string& name, bool recurse) const; + std::string_view name, bool recurse) const; LLUICtrl::CallbackParam::CallbackParam() : name("name"), @@ -135,7 +135,7 @@ void LLUICtrl::initFromParams(const Params& p) { if (p.enabled_controls.enabled.isChosen()) { - LLControlVariable* control = findControl(p.enabled_controls.enabled); + LLControlVariable* control = findControl(p.enabled_controls.enabled()); if (control) { setEnabledControlVariable(control); @@ -149,7 +149,7 @@ void LLUICtrl::initFromParams(const Params& p) } else if(p.enabled_controls.disabled.isChosen()) { - LLControlVariable* control = findControl(p.enabled_controls.disabled); + LLControlVariable* control = findControl(p.enabled_controls.disabled()); if (control) { setDisabledControlVariable(control); @@ -169,7 +169,7 @@ void LLUICtrl::initFromParams(const Params& p) if (p.controls_visibility.visible.isProvided()) // { - LLControlVariable* control = findControl(p.controls_visibility.visible); + LLControlVariable* control = findControl(p.controls_visibility.visible()); if (control) { setMakeVisibleControlVariable(control); @@ -186,7 +186,7 @@ void LLUICtrl::initFromParams(const Params& p) if (p.controls_visibility.invisible.isProvided()) // { - LLControlVariable* control = findControl(p.controls_visibility.invisible); + LLControlVariable* control = findControl(p.controls_visibility.invisible()); if (control) { setMakeInvisibleControlVariable(control); diff --git a/indra/llui/lluictrl.h b/indra/llui/lluictrl.h index 6c5210e71a..aa50ec0d84 100644 --- a/indra/llui/lluictrl.h +++ b/indra/llui/lluictrl.h @@ -354,7 +354,7 @@ private: // Build time optimization, generate once in .cpp file #ifndef LLUICTRL_CPP extern template class LLUICtrl* LLView::getChild( - const std::string& name, bool recurse) const; + std::string_view name, bool recurse) const; #endif #endif // LL_LLUICTRL_H diff --git a/indra/llui/lluictrlfactory.h b/indra/llui/lluictrlfactory.h index a07f9b7dae..75e7e396bc 100644 --- a/indra/llui/lluictrlfactory.h +++ b/indra/llui/lluictrlfactory.h @@ -182,10 +182,10 @@ fail: } template - static T* getDefaultWidget(const std::string& name) + static T* getDefaultWidget(std::string_view name) { typename T::Params widget_params; - widget_params.name = name; + widget_params.name = std::string(name); return create(widget_params); } diff --git a/indra/llui/llview.cpp b/indra/llui/llview.cpp index 44f877157e..cd1dfe45ef 100644 --- a/indra/llui/llview.cpp +++ b/indra/llui/llview.cpp @@ -85,7 +85,7 @@ bool LLView::sIsDrawing = false; // Compiler optimization, generate extern template template class LLView* LLView::getChild( - const std::string& name, bool recurse) const; + std::string_view name, bool recurse) const; static LLDefaultChildRegistry::Register r("view"); @@ -774,7 +774,7 @@ void LLView::logMouseEvent() } template -LLView* LLView::childrenHandleCharEvent(const std::string& desc, const METHOD& method, +LLView* LLView::childrenHandleCharEvent(std::string_view desc, const METHOD& method, CHARTYPE c, MASK mask) { if ( getVisible() && getEnabled() ) @@ -1681,7 +1681,7 @@ bool LLView::hasAncestor(const LLView* parentp) const //----------------------------------------------------------------------------- -bool LLView::childHasKeyboardFocus( const std::string& childname ) const +bool LLView::childHasKeyboardFocus(std::string_view childname) const { LLView *focus = dynamic_cast(gFocusMgr.getKeyboardFocus()); @@ -1700,7 +1700,7 @@ bool LLView::childHasKeyboardFocus( const std::string& childname ) const //----------------------------------------------------------------------------- -bool LLView::hasChild(const std::string& childname, bool recurse) const +bool LLView::hasChild(std::string_view childname, bool recurse) const { return findChildView(childname, recurse) != NULL; } @@ -1708,12 +1708,12 @@ bool LLView::hasChild(const std::string& childname, bool recurse) const //----------------------------------------------------------------------------- // getChildView() //----------------------------------------------------------------------------- -LLView* LLView::getChildView(const std::string& name, bool recurse) const +LLView* LLView::getChildView(std::string_view name, bool recurse) const { return getChild(name, recurse); } -LLView* LLView::findChildView(const std::string& name, bool recurse) const +LLView* LLView::findChildView(std::string_view name, bool recurse) const { LL_PROFILE_ZONE_SCOPED_CATEGORY_UI; @@ -2380,18 +2380,20 @@ LLView* LLView::findSnapEdge(S32& new_edge_val, const LLCoordGL& mouse_dir, ESna //----------------------------------------------------------------------------- -LLControlVariable *LLView::findControl(const std::string& name) +LLControlVariable *LLView::findControl(std::string_view name) { + auto uiInst = LLUI::getInstance(); // parse the name to locate which group it belongs to std::size_t key_pos= name.find("."); - if(key_pos!= std::string::npos ) + if(key_pos != std::string_view::npos ) { - std::string control_group_key = name.substr(0, key_pos); + std::string_view control_group_key = name.substr(0, key_pos); LLControlVariable* control; // check if it's in the control group that name indicated - if(LLUI::getInstance()->mSettingGroups[control_group_key]) + auto it = uiInst->mSettingGroups.find(control_group_key); + if(it != uiInst->mSettingGroups.end() && it->second) { - control = LLUI::getInstance()->mSettingGroups[control_group_key]->getControl(name); + control = it->second->getControl(name); if (control) { return control; @@ -2399,7 +2401,7 @@ LLControlVariable *LLView::findControl(const std::string& name) } } - LLControlGroup& control_group = LLUI::getInstance()->getControlControlGroup(name); + LLControlGroup& control_group = uiInst->getControlControlGroup(name); return control_group.getControl(name); } diff --git a/indra/llui/llview.h b/indra/llui/llview.h index 0a03aac6f1..b1681d00ea 100644 --- a/indra/llui/llview.h +++ b/indra/llui/llview.h @@ -341,8 +341,8 @@ public: S32 getChildCount() const { return (S32)mChildList.size(); } template void sortChildren(_Pr3 _Pred) { mChildList.sort(_Pred); } bool hasAncestor(const LLView* parentp) const; - bool hasChild(const std::string& childname, bool recurse = false) const; - bool childHasKeyboardFocus( const std::string& childname ) const; + bool hasChild(std::string_view childname, bool recurse = false) const; + bool childHasKeyboardFocus( std::string_view childname ) const; // these iterators are used for collapsing various tree traversals into for loops typedef LLTreeDFSIter tree_iterator_t; @@ -416,7 +416,7 @@ public: void screenRectToLocal( const LLRect& screen, LLRect* local ) const; void localRectToScreen( const LLRect& local, LLRect* screen ) const; - LLControlVariable *findControl(const std::string& name); + LLControlVariable *findControl(std::string_view name); const child_list_t* getChildList() const { return &mChildList; } child_list_const_iter_t beginChild() const { return mChildList.begin(); } @@ -452,24 +452,24 @@ public: // static method handles NULL pointer too static std::string getPathname(const LLView*); - template T* findChild(const std::string& name, bool recurse = true) const + template T* findChild(std::string_view name, bool recurse = true) const { LLView* child = findChildView(name, recurse); T* result = dynamic_cast(child); return result; } - template T* getChild(const std::string& name, bool recurse = true) const; + template T* getChild(std::string_view name, bool recurse = true) const; - template T& getChildRef(const std::string& name, bool recurse = true) const + template T& getChildRef(std::string_view name, bool recurse = true) const { return *getChild(name, recurse); } - virtual LLView* getChildView(const std::string& name, bool recurse = true) const; - virtual LLView* findChildView(const std::string& name, bool recurse = true) const; + virtual LLView* getChildView(std::string_view name, bool recurse = true) const; + virtual LLView* findChildView(std::string_view name, bool recurse = true) const; - template T* getDefaultWidget(const std::string& name) const + template T* getDefaultWidget(std::string_view name) const { LLView* widgetp = getDefaultWidgetContainer().findChildView(name); return dynamic_cast(widgetp); @@ -576,7 +576,7 @@ private: LLView* childrenHandleMouseEvent(const METHOD& method, S32 x, S32 y, XDATA extra, bool allow_mouse_block = true); template - LLView* childrenHandleCharEvent(const std::string& desc, const METHOD& method, + LLView* childrenHandleCharEvent(std::string_view desc, const METHOD& method, CHARTYPE c, MASK mask); // adapter to blur distinction between handleKey() and handleUnicodeChar() @@ -704,7 +704,7 @@ struct TypeValues : public LLInitParam::TypeValuesHelper T* LLView::getChild(const std::string& name, bool recurse) const +template T* LLView::getChild(std::string_view name, bool recurse) const { LLView* child = findChildView(name, recurse); T* result = dynamic_cast(child); @@ -739,7 +739,7 @@ template T* LLView::getChild(const std::string& name, bool recurse) co // require explicit specialization. See llbutton.cpp for an example. #ifndef LLVIEW_CPP extern template class LLView* LLView::getChild( - const std::string& name, bool recurse) const; + std::string_view name, bool recurse) const; #endif #endif //LL_LLVIEW_H diff --git a/indra/llwindow/llkeyboard.cpp b/indra/llwindow/llkeyboard.cpp index 3fcd5abb06..93e255a829 100644 --- a/indra/llwindow/llkeyboard.cpp +++ b/indra/llwindow/llkeyboard.cpp @@ -360,7 +360,7 @@ std::string LLKeyboard::stringFromKey(KEY key, bool translate) LLKeyStringTranslatorFunc *trans = gKeyboard->mStringTranslator; if (trans != NULL) { - res = trans(res.c_str()); + res = trans(res); } } @@ -400,7 +400,7 @@ std::string LLKeyboard::stringFromMouse(EMouseClickType click, bool translate) LLKeyStringTranslatorFunc* trans = gKeyboard->mStringTranslator; if (trans != NULL) { - res = trans(res.c_str()); + res = trans(res); } } return res; diff --git a/indra/llwindow/llkeyboard.h b/indra/llwindow/llkeyboard.h index 2ece690489..caf379ce1a 100644 --- a/indra/llwindow/llkeyboard.h +++ b/indra/llwindow/llkeyboard.h @@ -42,7 +42,7 @@ enum EKeystate }; typedef boost::function LLKeyFunc; -typedef std::string (LLKeyStringTranslatorFunc)(const char *label); +typedef std::string (LLKeyStringTranslatorFunc)(std::string_view); enum EKeyboardInsertMode { diff --git a/indra/llxml/llcontrol.cpp b/indra/llxml/llcontrol.cpp index d2ebdd82de..f11593850e 100644 --- a/indra/llxml/llcontrol.cpp +++ b/indra/llxml/llcontrol.cpp @@ -419,7 +419,7 @@ LLPointer LLControlGroup::getControl(std::string_view name) incrCount(name); } - ctrl_name_table_t::iterator iter = mNameTable.find(name.data()); + ctrl_name_table_t::iterator iter = mNameTable.find(name); return iter == mNameTable.end() ? LLPointer() : iter->second; } @@ -759,7 +759,7 @@ LLSD LLControlGroup::asLLSD(bool diffs_only) return result; } -bool LLControlGroup::controlExists(const std::string& name) +bool LLControlGroup::controlExists(std::string_view name) { ctrl_name_table_t::iterator iter = mNameTable.find(name); return iter != mNameTable.end(); diff --git a/indra/llxml/llcontrol.h b/indra/llxml/llcontrol.h index 829c14f340..1ddcef94e2 100644 --- a/indra/llxml/llcontrol.h +++ b/indra/llxml/llcontrol.h @@ -226,7 +226,7 @@ class LLControlGroup : public LLInstanceTracker LOG_CLASS(LLControlGroup); protected: - typedef std::map ctrl_name_table_t; + typedef std::map > ctrl_name_table_t; ctrl_name_table_t mNameTable; static const std::string mTypeString[TYPE_COUNT]; static const std::string mSanityTypeString[SANITY_TYPE_COUNT]; @@ -339,7 +339,7 @@ public: } } - bool controlExists(const std::string& name); + bool controlExists(std::string_view name); // Returns number of controls loaded, 0 if failed // If require_declaration is false, will auto-declare controls it finds diff --git a/indra/newview/CMakeLists.txt b/indra/newview/CMakeLists.txt index 56819614a7..d9b6f86a4b 100644 --- a/indra/newview/CMakeLists.txt +++ b/indra/newview/CMakeLists.txt @@ -301,6 +301,7 @@ set(viewer_SOURCE_FILES llfloaterbigpreview.cpp llfloaterbuildoptions.cpp llfloaterbulkpermission.cpp + llfloaterbulkupload.cpp llfloaterbump.cpp llfloaterbuy.cpp llfloaterbuycontents.cpp @@ -1106,6 +1107,7 @@ set(viewer_HEADER_FILES llfloaterbigpreview.h llfloaterbuildoptions.h llfloaterbulkpermission.h + llfloaterbulkupload.h llfloaterbump.h llfloaterbuy.h llfloaterbuycontents.h diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml index f960f6100c..1233ecdabc 100644 --- a/indra/newview/app_settings/settings.xml +++ b/indra/newview/app_settings/settings.xml @@ -2711,6 +2711,17 @@ Value 0 + BulkUpload2KTextures + + Comment + Bulk upload scales textures to 2K if true, to 1K if false + Persist + 1 + Type + Boolean + Value + 1 + EnableButtonFlashing Comment @@ -15027,6 +15038,19 @@ Change of this parameter will affect the layout of buttons in notification toast Backup 0 + TextureBiasUnimportantFactor + + Comment + When biasing textures to lower resolution due to lack of vram, the importance threshold below which is considered unimportant and getting an extra bias. + Persist + 1 + Type + F32 + Value + 0.25 + Backup + 0 + TextureDecodeDisabled Comment diff --git a/indra/newview/app_settings/shaders/class1/deferred/normgenF.glsl b/indra/newview/app_settings/shaders/class1/deferred/normgenF.glsl index 6d05d983f3..607a8c6ef6 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/normgenF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/normgenF.glsl @@ -64,14 +64,14 @@ float getBumpValue(vec2 texcoord) void main() { - float c = getBumpValue(vary_texcoord0).r; + float c = getBumpValue(vary_texcoord0); float scaler = 512.0; - vec3 right = vec3(norm_scale, 0, (getBumpValue(vary_texcoord0+vec2(stepX, 0)).r-c)*scaler); - vec3 left = vec3(-norm_scale, 0, (getBumpValue(vary_texcoord0-vec2(stepX, 0)).r-c)*scaler); - vec3 up = vec3(0, -norm_scale, (getBumpValue(vary_texcoord0-vec2(0, stepY)).r-c)*scaler); - vec3 down = vec3(0, norm_scale, (getBumpValue(vary_texcoord0+vec2(0, stepY)).r-c)*scaler); + vec3 right = vec3(norm_scale, 0, (getBumpValue(vary_texcoord0+vec2(stepX, 0))-c)*scaler); + vec3 left = vec3(-norm_scale, 0, (getBumpValue(vary_texcoord0-vec2(stepX, 0))-c)*scaler); + vec3 up = vec3(0, -norm_scale, (getBumpValue(vary_texcoord0-vec2(0, stepY))-c)*scaler); + vec3 down = vec3(0, norm_scale, (getBumpValue(vary_texcoord0+vec2(0, stepY))-c)*scaler); vec3 norm = cross(right, down) + cross(down, left) + cross(left,up) + cross(up, right); diff --git a/indra/newview/fsfloaterposestand.cpp b/indra/newview/fsfloaterposestand.cpp index 9eb1730d36..babb250310 100644 --- a/indra/newview/fsfloaterposestand.cpp +++ b/indra/newview/fsfloaterposestand.cpp @@ -111,7 +111,7 @@ void FSFloaterPoseStand::loadPoses() LLUUID anim_id(p_itr->first); if (anim_id.notNull()) { - mComboPose->add(LLTrans::getString(p_itr->second["name"]), anim_id); + mComboPose->add(LLTrans::getString(p_itr->second["name"].asStringRef()), anim_id); } } } diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp index 5e78459d3a..c9c8dad434 100644 --- a/indra/newview/llappviewer.cpp +++ b/indra/newview/llappviewer.cpp @@ -2818,7 +2818,7 @@ bool LLAppViewer::loadSettingsFromDirectory(const std::string& location_key, std::string full_settings_path; if (file.file_name_setting.isProvided() - && gSavedSettings.controlExists(file.file_name_setting)) + && gSavedSettings.controlExists(file.file_name_setting())) { // try to find filename stored in file_name_setting control full_settings_path = gSavedSettings.getString(file.file_name_setting()); diff --git a/indra/newview/llappviewer.h b/indra/newview/llappviewer.h index 153addef1f..80b9d9a6c7 100644 --- a/indra/newview/llappviewer.h +++ b/indra/newview/llappviewer.h @@ -372,7 +372,7 @@ private: }; // consts from viewer.h -const S32 AGENT_UPDATES_PER_SECOND = 125; // FIRE-34171 - Directional Input Delays with latest PBR-Capable Viewers +const S32 AGENT_UPDATES_PER_SECOND = 125; // Value derived experimentally to avoid Input Delays with latest PBR-Capable Viewers when viewer FPS is highly volatile. const S32 AGENT_FORCE_UPDATES_PER_SECOND = 1; // Globals with external linkage. From viewer.h diff --git a/indra/newview/llfloaterbulkupload.cpp b/indra/newview/llfloaterbulkupload.cpp new file mode 100644 index 0000000000..b898cb28b6 --- /dev/null +++ b/indra/newview/llfloaterbulkupload.cpp @@ -0,0 +1,136 @@ +/** + * @file llfloaterbulkupload.cpp + * @author Andrey Kleshchev + * @brief LLFloaterBulkUpload class implementation + * + * $LicenseInfo:firstyear=2024&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2024, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + +#include "llviewerprecompiledheaders.h" + +#include "llfloaterbulkupload.h" + +#include "lltextbox.h" +#include "llviewercontrol.h" +#include "llviewermenufile.h" + +constexpr S32 MAX_HEIGH = 211; + +LLFloaterBulkUpload::LLFloaterBulkUpload(const LLSD& key) +: LLModalDialog(key, true) +{ + mUploadCost = key["upload_cost"].asInteger(); + mUploadCount = key["upload_count"].asInteger(); + mHas2kTextures = key["has_2k_textures"].asBoolean(); + if (key["files"].isArray()) + { + const LLSD& files = key["files"]; + for (LLSD::array_const_iterator it = files.beginArray(); + it != files.endArray(); + ++it) + { + mFiles.push_back(it->asString()); + } + } +} + +LLFloaterBulkUpload::~LLFloaterBulkUpload() +{ +} + +bool LLFloaterBulkUpload::postBuild() +{ + childSetAction("upload_btn", [this](void*) { onClickUpload(); }, this); + childSetAction("cancel_btn", [this](void*) { onClickCancel(); }, this); + + mCountLabel = getChild("number_of_items", true); + mCostLabel = getChild("upload_cost", true); + + mCheckboxPanel = getChild("checkbox_panel", true); + mLinkPanel = getChild("link_panel", true); + mWarningPanel = getChild("warning_panel", true); + + mCheckboxUpload2K = getChild("upload_2k"); + mCheckboxUpload2K->setCommitCallback([this](LLUICtrl* ctrl, const LLSD& data) { onUpload2KCheckBox(); }); + + mAllow2kTextures = gSavedSettings.getBOOL("BulkUpload2KTextures"); + mCheckboxUpload2K->setValue(!mAllow2kTextures); + + if (!mAllow2kTextures && mHas2kTextures) + { + // provided cost is for 2K textures, recalculate cost + S32 bvh_count; + S32 textures_2k_count; + get_bulk_upload_expected_cost(mFiles, mAllow2kTextures, mUploadCost, mUploadCount, bvh_count, textures_2k_count); + + update(); + } + + + update(); + + return LLModalDialog::postBuild(); +} + +void LLFloaterBulkUpload::update() +{ + mCountLabel->setTextArg("[COUNT]", llformat("%d", mUploadCount)); + mCostLabel->setTextArg("[COST]", llformat("%d", mUploadCost)); + + mCheckboxPanel->setVisible(mHas2kTextures); + mLinkPanel->setVisible(mHas2kTextures); + mWarningPanel->setVisible(mHas2kTextures); + + S32 new_height = MAX_HEIGH; + if (!mHas2kTextures) + { + new_height -= mCheckboxPanel->getRect().getHeight(); + new_height -= mLinkPanel->getRect().getHeight(); + new_height -= mWarningPanel->getRect().getHeight(); + } + reshape(getRect().getWidth(), new_height, false); +} + +void LLFloaterBulkUpload::onUpload2KCheckBox() +{ + mAllow2kTextures = !mCheckboxUpload2K->getValue().asBoolean(); + gSavedSettings.setBOOL("BulkUpload2KTextures", mAllow2kTextures); + + S32 bvh_count; + S32 textures_2k_count; + get_bulk_upload_expected_cost(mFiles, mAllow2kTextures, mUploadCost, mUploadCount, bvh_count, textures_2k_count); + // keep old value of mHas2kTextures to show checkbox + + update(); +} + +void LLFloaterBulkUpload::onClickUpload() +{ + do_bulk_upload(mFiles, mAllow2kTextures); + closeFloater(); +} + + +void LLFloaterBulkUpload::onClickCancel() +{ + closeFloater(); +} diff --git a/indra/newview/llfloaterbulkupload.h b/indra/newview/llfloaterbulkupload.h new file mode 100644 index 0000000000..d07dc8eabe --- /dev/null +++ b/indra/newview/llfloaterbulkupload.h @@ -0,0 +1,66 @@ +/** + * @file llfloaterbulkupload.h + * @author Andrey Kleshchev + * @brief LLFloaterBulkUpload class definition + * + * $LicenseInfo:firstyear=2024&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2024, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + +#ifndef LL_LLFLOATERBULKUPLOAD_H +#define LL_LLFLOATERBULKUPLOAD_H + +#include "llmodaldialog.h" + +class LLTextBox; + +class LLFloaterBulkUpload : public LLModalDialog +{ +public: + LLFloaterBulkUpload(const LLSD& key); + ~LLFloaterBulkUpload(); + + bool postBuild() override; + + void update(); + +protected: + void onUpload2KCheckBox(); + + void onClickUpload(); + void onClickCancel(); + +private: + LLUICtrl* mCheckboxUpload2K = nullptr; + LLTextBox* mCountLabel = nullptr; + LLTextBox* mCostLabel = nullptr; + LLPanel* mCheckboxPanel = nullptr; + LLPanel* mLinkPanel = nullptr; + LLPanel* mWarningPanel = nullptr; + + std::vector mFiles; + bool mAllow2kTextures = true; + bool mHas2kTextures = false; + S32 mUploadCost = 0; + S32 mUploadCount = 0; +}; + +#endif diff --git a/indra/newview/llfloaterpreference.cpp b/indra/newview/llfloaterpreference.cpp index 79dc6db47c..1fdb47e7e4 100644 --- a/indra/newview/llfloaterpreference.cpp +++ b/indra/newview/llfloaterpreference.cpp @@ -3160,7 +3160,7 @@ void LLFloaterPreference::setSoundCacheLocation(const LLStringExplicit& location void LLFloaterPreference::selectPanel(const LLSD& name) { LLTabContainer * tab_containerp = getChild("pref core"); - LLPanel * panel = tab_containerp->getPanelByName(name); + LLPanel * panel = tab_containerp->getPanelByName(name.asStringRef()); if (NULL != panel) { tab_containerp->selectTabPanel(panel); diff --git a/indra/newview/llfloaterregioninfo.cpp b/indra/newview/llfloaterregioninfo.cpp index 1b4a28ee35..4816d9365f 100644 --- a/indra/newview/llfloaterregioninfo.cpp +++ b/indra/newview/llfloaterregioninfo.cpp @@ -1747,7 +1747,7 @@ bool LLPanelRegionTerrainInfo::postBuild() { mTextureDetailCtrl[i]->setBakeTextureEnabled(false); } - initAndSetCtrl(mMaterialDetailCtrl[i], llformat("material_detail_%d", i)); + initMaterialCtrl(mMaterialDetailCtrl[i], llformat("material_detail_%d", i), i); initAndSetCtrl(mMaterialScaleUCtrl[i], llformat("terrain%dScaleU", i)); initAndSetCtrl(mMaterialScaleVCtrl[i], llformat("terrain%dScaleV", i)); @@ -2153,6 +2153,31 @@ bool LLPanelRegionTerrainInfo::sendUpdate() return true; } +void LLPanelRegionTerrainInfo::initMaterialCtrl(LLTextureCtrl*& ctrl, const std::string& name, S32 index) +{ + ctrl = findChild(name, true); + if (!ctrl) return; + + // consume cancel events, otherwise they will trigger commit callbacks + ctrl->setOnCancelCallback([](LLUICtrl* ctrl, const LLSD& param) {}); + ctrl->setCommitCallback( + [this, index](LLUICtrl* ctrl, const LLSD& param) + { + if (!mMaterialScaleUCtrl[index] + || !mMaterialScaleVCtrl[index] + || !mMaterialRotationCtrl[index] + || !mMaterialOffsetUCtrl[index] + || !mMaterialOffsetVCtrl[index]) return; + + mMaterialScaleUCtrl[index]->setValue(1.f); + mMaterialScaleVCtrl[index]->setValue(1.f); + mMaterialRotationCtrl[index]->setValue(0.f); + mMaterialOffsetUCtrl[index]->setValue(0.f); + mMaterialOffsetVCtrl[index]->setValue(0.f); + onChangeAnything(); + }); +} + bool LLPanelRegionTerrainInfo::callbackTextureHeights(const LLSD& notification, const LLSD& response) { S32 option = LLNotificationsUtil::getSelectedOption(notification, response); diff --git a/indra/newview/llfloaterregioninfo.h b/indra/newview/llfloaterregioninfo.h index d3b9fea4c9..cce1adbb4c 100644 --- a/indra/newview/llfloaterregioninfo.h +++ b/indra/newview/llfloaterregioninfo.h @@ -303,6 +303,8 @@ public: protected: bool sendUpdate() override; + void initMaterialCtrl(LLTextureCtrl*& ctrl, const std::string& name, S32 index); + private: bool mConfirmedTextureHeights; bool mAskedTextureHeights; diff --git a/indra/newview/llfloatersidepanelcontainer.cpp b/indra/newview/llfloatersidepanelcontainer.cpp index f2a3862663..8efed3314a 100644 --- a/indra/newview/llfloatersidepanelcontainer.cpp +++ b/indra/newview/llfloatersidepanelcontainer.cpp @@ -130,7 +130,7 @@ LLFloater* LLFloaterSidePanelContainer::getTopmostInventoryFloater() return topmost_floater; } -LLPanel* LLFloaterSidePanelContainer::openChildPanel(const std::string& panel_name, const LLSD& params) +LLPanel* LLFloaterSidePanelContainer::openChildPanel(std::string_view panel_name, const LLSD& params) { LLView* view = findChildView(panel_name, true); if (!view) @@ -162,18 +162,18 @@ LLPanel* LLFloaterSidePanelContainer::openChildPanel(const std::string& panel_na } // [RLVa:KB] - Checked: 2012-02-07 (RLVa-1.4.5) | Added: RLVa-1.4.5 -bool LLFloaterSidePanelContainer::canShowPanel(const std::string& floater_name, const LLSD& key) +bool LLFloaterSidePanelContainer::canShowPanel(std::string_view floater_name, const LLSD& key) { return mValidateSignal(floater_name, sMainPanelName, key); } -bool LLFloaterSidePanelContainer::canShowPanel(const std::string& floater_name, const std::string& panel_name, const LLSD& key) +bool LLFloaterSidePanelContainer::canShowPanel(std::string_view floater_name, std::string_view panel_name, const LLSD& key) { return mValidateSignal(floater_name, panel_name, key); } // [/RLVa:KB] -void LLFloaterSidePanelContainer::showPanel(const std::string& floater_name, const LLSD& key) +void LLFloaterSidePanelContainer::showPanel(std::string_view floater_name, const LLSD& key) { LLFloaterSidePanelContainer* floaterp = LLFloaterReg::getTypedInstance(floater_name); // if (floaterp) @@ -185,7 +185,7 @@ void LLFloaterSidePanelContainer::showPanel(const std::string& floater_name, con } } -void LLFloaterSidePanelContainer::showPanel(const std::string& floater_name, const std::string& panel_name, const LLSD& key) +void LLFloaterSidePanelContainer::showPanel(std::string_view floater_name, std::string_view panel_name, const LLSD& key) { LLFloaterSidePanelContainer* floaterp = LLFloaterReg::getTypedInstance(floater_name); // if (floaterp) @@ -197,7 +197,7 @@ void LLFloaterSidePanelContainer::showPanel(const std::string& floater_name, con } } -LLPanel* LLFloaterSidePanelContainer::getPanel(const std::string& floater_name, const std::string& panel_name) +LLPanel* LLFloaterSidePanelContainer::getPanel(std::string_view floater_name, std::string_view panel_name) { LLFloaterSidePanelContainer* floaterp = LLFloaterReg::getTypedInstance(floater_name); @@ -209,7 +209,7 @@ LLPanel* LLFloaterSidePanelContainer::getPanel(const std::string& floater_name, return NULL; } -LLPanel* LLFloaterSidePanelContainer::findPanel(const std::string& floater_name, const std::string& panel_name) +LLPanel* LLFloaterSidePanelContainer::findPanel(std::string_view floater_name, std::string_view panel_name) { LLFloaterSidePanelContainer* floaterp = LLFloaterReg::findTypedInstance(floater_name); diff --git a/indra/newview/llfloatersidepanelcontainer.h b/indra/newview/llfloatersidepanelcontainer.h index 7f30b6ba4c..4be2962f47 100644 --- a/indra/newview/llfloatersidepanelcontainer.h +++ b/indra/newview/llfloatersidepanelcontainer.h @@ -55,22 +55,22 @@ public: void cleanup() { destroy(); } - LLPanel* openChildPanel(const std::string& panel_name, const LLSD& params); + LLPanel* openChildPanel(std::string_view panel_name, const LLSD& params); static LLFloater* getTopmostInventoryFloater(); // [RLVa:KB] - Checked: 2012-02-07 (RLVa-1.4.5) | Added: RLVa-1.4.5 - static bool canShowPanel(const std::string& floater_name, const LLSD& key); - static bool canShowPanel(const std::string& floater_name, const std::string& panel_name, const LLSD& key); + static bool canShowPanel(std::string_view floater_name, const LLSD& key); + static bool canShowPanel(std::string_view floater_name, std::string_view panel_name, const LLSD& key); // [/RLVa:KB] - static void showPanel(const std::string& floater_name, const LLSD& key); + static void showPanel(std::string_view floater_name, const LLSD& key); - static void showPanel(const std::string& floater_name, const std::string& panel_name, const LLSD& key); + static void showPanel(std::string_view floater_name, std::string_view panel_name, const LLSD& key); - static LLPanel* getPanel(const std::string& floater_name, const std::string& panel_name = sMainPanelName); + static LLPanel* getPanel(std::string_view floater_name, std::string_view panel_name = sMainPanelName); - static LLPanel* findPanel(const std::string& floater_name, const std::string& panel_name = sMainPanelName); + static LLPanel* findPanel(std::string_view floater_name, std::string_view panel_name = sMainPanelName); /** * Gets the panel of given type T (doesn't show it or do anything else with it). @@ -80,7 +80,7 @@ public: * @returns a pointer to the panel of given type T. */ template - static T* getPanel(const std::string& floater_name, const std::string& panel_name = sMainPanelName) + static T* getPanel(std::string_view floater_name, std::string_view panel_name = sMainPanelName) { T* panel = dynamic_cast(getPanel(floater_name, panel_name)); if (!panel) @@ -111,7 +111,7 @@ public: // [RLVa:KB] - Checked: 2012-02-07 (RLVa-1.4.5) | Added: RLVa-1.4.5 // Used to determine whether a sidepanel can be shown public: - typedef boost::signals2::signal validate_signal_t; + typedef boost::signals2::signal validate_signal_t; static boost::signals2::connection setValidateCallback(const validate_signal_t::slot_type& cb) { return mValidateSignal.connect(cb); } private: static validate_signal_t mValidateSignal; diff --git a/indra/newview/llfloaterwebcontent.cpp b/indra/newview/llfloaterwebcontent.cpp index b0a6be27b2..258bba5df0 100644 --- a/indra/newview/llfloaterwebcontent.cpp +++ b/indra/newview/llfloaterwebcontent.cpp @@ -226,7 +226,7 @@ void LLFloaterWebContent::preCreate(LLFloaterWebContent::Params& p) // showInstance will open a new window. Figure out how many web browsers are already open, // and close the least recently opened one if this will put us over the limit. - LLFloaterReg::const_instance_list_t &instances = LLFloaterReg::getFloaterList(p.window_class); + LLFloaterReg::const_instance_list_t &instances = LLFloaterReg::getFloaterList(p.window_class()); if(instances.size() >= (size_t)browser_window_limit) { diff --git a/indra/newview/lllogininstance.cpp b/indra/newview/lllogininstance.cpp index 0ebfcca5c4..d66d4e7eba 100644 --- a/indra/newview/lllogininstance.cpp +++ b/indra/newview/lllogininstance.cpp @@ -463,7 +463,7 @@ void LLLoginInstance::handleLoginFailure(const LLSD& event) gViewerWindow->setShowProgress(false, false); } - showMFAChallange(LLTrans::getString(response["message_id"])); + showMFAChallange(LLTrans::getString(response["message_id"].asString())); } else if( reason_response == "key" || reason_response == "presence" diff --git a/indra/newview/llmaterialeditor.cpp b/indra/newview/llmaterialeditor.cpp index 0f91dc5eb7..157c2d0fee 100644 --- a/indra/newview/llmaterialeditor.cpp +++ b/indra/newview/llmaterialeditor.cpp @@ -2433,14 +2433,14 @@ void LLMaterialEditor::onSaveObjectsMaterialAsMsgCallback(const LLSD& notificati createInventoryItem(str.str(), new_name, std::string(), permissions); } -const void upload_bulk(const std::vector& filenames, LLFilePicker::ELoadFilter type); +const void upload_bulk(const std::vector& filenames, LLFilePicker::ELoadFilter type, bool allow_2k); void LLMaterialEditor::loadMaterial(const tinygltf::Model &model_in, const std::string &filename, S32 index, bool open_floater) { if (index == model_in.materials.size()) { // bulk upload all the things - upload_bulk({ filename }, LLFilePicker::FFLOAD_MATERIAL); + upload_bulk({ filename }, LLFilePicker::FFLOAD_MATERIAL, true); return; } diff --git a/indra/newview/llpanelpeoplemenus.cpp b/indra/newview/llpanelpeoplemenus.cpp index dfdd74120e..5feb605073 100644 --- a/indra/newview/llpanelpeoplemenus.cpp +++ b/indra/newview/llpanelpeoplemenus.cpp @@ -296,11 +296,14 @@ bool PeopleContextMenu::enableContextMenuItem(const LLSD& userdata) return RlvActions::canPayAvatar(mUUIDs.front()); } // [/RLVa:KB] - else if (item == std::string("can_im") || item == std::string("can_invite") || - item == std::string("can_share") || item == std::string("can_pay")) + else if (item == std::string("can_im") || item == std::string("can_invite")) { return true; } + else if (item == std::string("can_share") || item == std::string("can_pay")) + { + return mUUIDs.size() == 1; + } return false; } diff --git a/indra/newview/llsidetraypanelcontainer.cpp b/indra/newview/llsidetraypanelcontainer.cpp index eb8e05ec27..44e0c3b05c 100644 --- a/indra/newview/llsidetraypanelcontainer.cpp +++ b/indra/newview/llsidetraypanelcontainer.cpp @@ -62,10 +62,10 @@ void LLSideTrayPanelContainer::onOpen(const LLSD& key) getCurrentPanel()->onOpen(key); } -void LLSideTrayPanelContainer::openPanel(const std::string& panel_name, const LLSD& key) +void LLSideTrayPanelContainer::openPanel(std::string_view panel_name, const LLSD& key) { LLSD combined_key = key; - combined_key[PARAM_SUB_PANEL_NAME] = panel_name; + combined_key[PARAM_SUB_PANEL_NAME] = std::string(panel_name); onOpen(combined_key); } diff --git a/indra/newview/llsidetraypanelcontainer.h b/indra/newview/llsidetraypanelcontainer.h index 5dfd7f2d83..0017d7743f 100644 --- a/indra/newview/llsidetraypanelcontainer.h +++ b/indra/newview/llsidetraypanelcontainer.h @@ -59,7 +59,7 @@ public: /** * Opens given subpanel. */ - void openPanel(const std::string& panel_name, const LLSD& key = LLSD::emptyMap()); + void openPanel(std::string_view panel_name, const LLSD& key = LLSD::emptyMap()); /** * Opens previous panel from panel navigation history. diff --git a/indra/newview/llviewerassetupload.cpp b/indra/newview/llviewerassetupload.cpp index e0783a619d..f226e8f191 100644 --- a/indra/newview/llviewerassetupload.cpp +++ b/indra/newview/llviewerassetupload.cpp @@ -385,7 +385,8 @@ LLNewFileResourceUploadInfo::LLNewFileResourceUploadInfo( LLResourceUploadInfo(name, description, compressionInfo, destinationType, inventoryType, nextOWnerPerms, groupPerms, everyonePerms, expectedCost, show_inventory), - mFileName(fileName) + mFileName(fileName), + mMaxImageSize(LLViewerFetchedTexture::MAX_IMAGE_SIZE_DEFAULT) { } @@ -439,7 +440,7 @@ LLSD LLNewFileResourceUploadInfo::exportTempFile() else if (assetType == LLAssetType::AT_TEXTURE) { // It's an image file, the upload procedure is the same for all - if (!LLViewerTextureList::createUploadFile(getFileName(), filename, codec)) + if (!LLViewerTextureList::createUploadFile(getFileName(), filename, codec, mMaxImageSize)) { // Duplicate error message output //errorMessage = llformat("Problem with file %s:\n\n%s\n", diff --git a/indra/newview/llviewerassetupload.h b/indra/newview/llviewerassetupload.h index 5a07fbf802..365436ede0 100644 --- a/indra/newview/llviewerassetupload.h +++ b/indra/newview/llviewerassetupload.h @@ -161,13 +161,15 @@ public: std::string getFileName() const { return mFileName; }; + void setMaxImageSize(U32 maxUploadSize) { mMaxImageSize = maxUploadSize; } + protected: virtual LLSD exportTempFile(); private: std::string mFileName; - + S32 mMaxImageSize; }; //------------------------------------------------------------------------- diff --git a/indra/newview/llviewerfloaterreg.cpp b/indra/newview/llviewerfloaterreg.cpp index 924e5a56b4..2812429887 100644 --- a/indra/newview/llviewerfloaterreg.cpp +++ b/indra/newview/llviewerfloaterreg.cpp @@ -47,6 +47,7 @@ #include "llfloaterbeacons.h" #include "llfloaterbuildoptions.h" #include "llfloaterbulkpermission.h" +#include "llfloaterbulkupload.h" #include "llfloaterbump.h" #include "llfloaterbuy.h" #include "llfloaterbuycontents.h" @@ -264,6 +265,7 @@ public: "camera_presets", "delete_pref_preset", "forget_username", + "gltf_asset_editor", "god_tools", "group_picker", "hud", @@ -280,7 +282,8 @@ public: "upload_image", "upload_model", "upload_script", - "upload_sound" + "upload_sound", + "bulk_upload" }; return std::find(blacklist_clicked.begin(), blacklist_clicked.end(), fl_name) == blacklist_clicked.end(); } @@ -304,6 +307,7 @@ public: "env_edit_extdaycycle", "font_test", "forget_username", + "gltf_asset_editor", "god_tools", "group_picker", "hud", @@ -329,7 +333,8 @@ public: "upload_image", "upload_model", "upload_script", - "upload_sound" + "upload_sound", + "bulk_upload" }; return std::find(blacklist_untrusted.begin(), blacklist_untrusted.end(), fl_name) == blacklist_untrusted.end(); } @@ -404,6 +409,7 @@ void LLViewerFloaterReg::registerFloaters() LLFloaterReg::add("buy_object_contents", "floater_buy_contents.xml", (LLFloaterBuildFunc)&LLFloaterReg::build); LLFloaterReg::add("build", "floater_tools.xml", (LLFloaterBuildFunc)&LLFloaterReg::build); LLFloaterReg::add("build_options", "floater_build_options.xml", (LLFloaterBuildFunc)&LLFloaterReg::build); + LLFloaterReg::add("bulk_upload", "floater_bulk_upload.xml", (LLFloaterBuildFunc)&LLFloaterReg::build); LLFloaterReg::add("bumps", "floater_bumps.xml", (LLFloaterBuildFunc)&LLFloaterReg::build); LLFloaterReg::add("camera", "floater_camera.xml", (LLFloaterBuildFunc)&LLFloaterReg::build); diff --git a/indra/newview/llviewermenufile.cpp b/indra/newview/llviewermenufile.cpp index 67e5ab7053..5b498f9b80 100644 --- a/indra/newview/llviewermenufile.cpp +++ b/indra/newview/llviewermenufile.cpp @@ -538,15 +538,8 @@ const void upload_single_file(const std::vector& filenames, LLFileP return; } -void do_bulk_upload(std::vector filenames, const LLSD& notification, const LLSD& response) +void do_bulk_upload(std::vector filenames, bool allow_2k) { - S32 option = LLNotificationsUtil::getSelectedOption(notification, response); - if (option != 0) - { - // Cancel upload - return; - } - for (std::vector::const_iterator in_iter = filenames.begin(); in_iter != filenames.end(); ++in_iter) { std::string filename = (*in_iter); @@ -566,7 +559,7 @@ void do_bulk_upload(std::vector filenames, const LLSD& notification if (LLResourceUploadInfo::findAssetTypeAndCodecOfExtension(ext, asset_type, codec)) { bool resource_upload = false; - if (asset_type == LLAssetType::AT_TEXTURE) + if (asset_type == LLAssetType::AT_TEXTURE && allow_2k) { LLPointer image_frmted = LLImageFormatted::createFromType(codec); if (gDirUtilp->fileExists(filename) && image_frmted->load(filename)) @@ -582,7 +575,7 @@ void do_bulk_upload(std::vector filenames, const LLSD& notification if (resource_upload) { - LLResourceUploadInfo::ptr_t uploadInfo(new LLNewFileResourceUploadInfo( + LLNewFileResourceUploadInfo* info_p = new LLNewFileResourceUploadInfo( filename, asset_name, asset_name, 0, @@ -590,7 +583,13 @@ void do_bulk_upload(std::vector filenames, const LLSD& notification LLFloaterPerms::getNextOwnerPerms("Uploads"), LLFloaterPerms::getGroupPerms("Uploads"), LLFloaterPerms::getEveryonePerms("Uploads"), - expected_upload_cost)); + expected_upload_cost); + + if (!allow_2k) + { + info_p->setMaxImageSize(1024); + } + LLResourceUploadInfo::ptr_t uploadInfo(info_p); upload_new_resource(uploadInfo); } @@ -616,11 +615,30 @@ void do_bulk_upload(std::vector filenames, const LLSD& notification } } -bool get_bulk_upload_expected_cost(const std::vector& filenames, S32& total_cost, S32& file_count, S32& bvh_count) +void do_bulk_upload(std::vector filenames, bool allow_2k, const LLSD& notification, const LLSD& response) +{ + S32 option = LLNotificationsUtil::getSelectedOption(notification, response); + if (option != 0) + { + // Cancel upload + return; + } + + do_bulk_upload(filenames, allow_2k); +} + +bool get_bulk_upload_expected_cost( + const std::vector& filenames, + bool allow_2k, + S32& total_cost, + S32& file_count, + S32& bvh_count, + S32& textures_2k_count) { total_cost = 0; file_count = 0; bvh_count = 0; + textures_2k_count = 0; for (std::vector::const_iterator in_iter = filenames.begin(); in_iter != filenames.end(); ++in_iter) { std::string filename = (*in_iter); @@ -637,12 +655,20 @@ bool get_bulk_upload_expected_cost(const std::vector& filenames, S3 if (LLResourceUploadInfo::findAssetTypeAndCodecOfExtension(ext, asset_type, codec)) { - if (asset_type == LLAssetType::AT_TEXTURE) + if (asset_type == LLAssetType::AT_TEXTURE && allow_2k) { LLPointer image_frmted = LLImageFormatted::createFromType(codec); if (gDirUtilp->fileExists(filename) && image_frmted->load(filename)) { total_cost += LLAgentBenefitsMgr::current().getTextureUploadCost(image_frmted); + if (image_frmted) + { + S32 area = image_frmted->getHeight() * image_frmted->getWidth(); + if (area >= LLAgentBenefits::MIN_2K_TEXTURE_AREA) + { + textures_2k_count++; + } + } file_count++; } } @@ -697,47 +723,40 @@ bool get_bulk_upload_expected_cost(const std::vector& filenames, S3 return file_count > 0; } -const void upload_bulk(const std::vector& filenames, LLFilePicker::ELoadFilter type) +const void upload_bulk(const std::vector& filtered_filenames, bool allow_2k) { - // TODO: - // Check user balance for entire cost - // Charge user entire cost - // Loop, uploading - // If an upload fails, refund the user for that one - // - // Also fix single upload to charge first, then refund - - // FIXME PREMIUM what about known types that can't be bulk uploaded - // (bvh)? These will fail in the item by item upload but won't be - // mentioned in the notification. - std::vector filtered_filenames; - for (std::vector::const_iterator in_iter = filenames.begin(); in_iter != filenames.end(); ++in_iter) - { - const std::string& filename = *in_iter; - if (check_file_extension(filename, type)) - { - filtered_filenames.push_back(filename); - } - } - S32 expected_upload_cost; S32 expected_upload_count; S32 bvh_count; - if (get_bulk_upload_expected_cost(filtered_filenames, expected_upload_cost, expected_upload_count, bvh_count)) + S32 textures_2k_count; + if (get_bulk_upload_expected_cost(filtered_filenames, allow_2k, expected_upload_cost, expected_upload_count, bvh_count, textures_2k_count)) { - LLSD args; - args["COST"] = expected_upload_cost; - args["COUNT"] = expected_upload_count; + LLSD key; + key["upload_cost"] = expected_upload_cost; + key["upload_count"] = expected_upload_count; + key["has_2k_textures"] = (textures_2k_count > 0); + // Check balance before trying to upload S32 current_balance = gStatusBar->getBalance(); if (expected_upload_cost > current_balance) { + LLSD args; + args["COST"] = expected_upload_cost; + args["COUNT"] = expected_upload_count; args["BALANCE"] = current_balance; LLNotificationsUtil::add("NotEnoughMoneyForBulkUpload", args); return; } // - LLNotificationsUtil::add("BulkUploadCostConfirmation", args, LLSD(), boost::bind(do_bulk_upload, filtered_filenames, _1, _2)); + + LLSD array; + for (const std::string& str : filtered_filenames) + { + array.append(str); + } + key["files"] = array; + + LLFloaterReg::showInstance("bulk_upload", key); if (filtered_filenames.size() > expected_upload_count) { @@ -762,6 +781,31 @@ const void upload_bulk(const std::vector& filenames, LLFilePicker:: } +const void upload_bulk(const std::vector& filenames, LLFilePicker::ELoadFilter type, bool allow_2k) +{ + // TODO: + // Check user balance for entire cost + // Charge user entire cost + // Loop, uploading + // If an upload fails, refund the user for that one + // + // Also fix single upload to charge first, then refund + + // FIXME PREMIUM what about known types that can't be bulk uploaded + // (bvh)? These will fail in the item by item upload but won't be + // mentioned in the notification. + std::vector filtered_filenames; + for (std::vector::const_iterator in_iter = filenames.begin(); in_iter != filenames.end(); ++in_iter) + { + const std::string& filename = *in_iter; + if (check_file_extension(filename, type)) + { + filtered_filenames.push_back(filename); + } + } + upload_bulk(filtered_filenames, allow_2k); +} + class LLFileUploadImage : public view_listener_t { bool handleEvent(const LLSD& userdata) @@ -827,7 +871,7 @@ class LLFileUploadBulk : public view_listener_t { gAgentCamera.changeCameraToDefault(); } - LLFilePickerReplyThread::startPicker(boost::bind(&upload_bulk, _1, _2), LLFilePicker::FFLOAD_ALL, true); + LLFilePickerReplyThread::startPicker(boost::bind(&upload_bulk, _1, _2, true), LLFilePicker::FFLOAD_ALL, true); return true; } }; diff --git a/indra/newview/llviewermenufile.h b/indra/newview/llviewermenufile.h index b0d2717c36..62a2bf779b 100644 --- a/indra/newview/llviewermenufile.h +++ b/indra/newview/llviewermenufile.h @@ -65,13 +65,15 @@ void upload_new_resource( LLAssetStorage::LLStoreAssetCallback callback = LLAssetStorage::LLStoreAssetCallback(), void *userdata = NULL); +bool get_bulk_upload_expected_cost( + const std::vector& filenames, + bool allow_2k, + S32& total_cost, + S32& file_count, + S32& bvh_count, + S32& textures_2k_count); -void assign_defaults_and_show_upload_message( - LLAssetType::EType asset_type, - LLInventoryType::EType& inventory_type, - std::string& name, - const std::string& display_name, - std::string& description); +void do_bulk_upload(std::vector filenames, bool allow_2k); //consider moving all file pickers below to more suitable place class LLFilePickerThread : public LLThread diff --git a/indra/newview/llviewertexturelist.cpp b/indra/newview/llviewertexturelist.cpp index 0509714bb4..3ad6cc868f 100644 --- a/indra/newview/llviewertexturelist.cpp +++ b/indra/newview/llviewertexturelist.cpp @@ -944,12 +944,10 @@ void LLViewerTextureList::updateImageDecodePriority(LLViewerFetchedTexture* imag if (face && face->getViewerObject() && face->getTextureEntry()) { -// Fix Blurry textures and use importance weight F32 radius; F32 cos_angle_to_view_dir; bool in_frustum = face->calcPixelArea(cos_angle_to_view_dir, radius); static LLCachedControl bias_unimportant_threshold(gSavedSettings, "TextureBiasUnimportantFactor", 0.25f); -// F32 vsize = face->getPixelArea(); // Scale desired texture resolution higher or lower depending on texture scale @@ -963,15 +961,6 @@ void LLViewerTextureList::updateImageDecodePriority(LLViewerFetchedTexture* imag min_scale = llclamp(min_scale*min_scale, texture_scale_min(), texture_scale_max()); vsize /= min_scale; -// Fix Blurry textures and use importance weight -// vsize /= LLViewerTexture::sDesiredDiscardBias; -// vsize /= llmax(1.f, (LLViewerTexture::sDesiredDiscardBias-1.f) * (1.f + face->getDrawable()->mDistanceWRTCamera * bias_distance_scale)); - -// F32 radius; -// F32 cos_angle_to_view_dir; -// bool in_frustum = face->calcPixelArea(cos_angle_to_view_dir, radius); -// if (!in_frustum || !face->getDrawable()->isVisible()) -// if (!in_frustum || !face->getDrawable()->isVisible() || face->getImportanceToCamera() < bias_unimportant_threshold) { // further reduce by discard bias when off screen or occluded vsize /= LLViewerTexture::sDesiredDiscardBias; diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index 83f564c6e3..b3986eb965 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -844,9 +844,11 @@ bool LLPipeline::allocateScreenBuffer(U32 resX, U32 resY, U32 samples) LL_PROFILE_ZONE_SCOPED_CATEGORY_DISPLAY; if (mRT == &mMainRT) { // hacky -- allocate auxillary buffer + + gCubeSnapshot = TRUE; + if (sReflectionProbesEnabled) { - gCubeSnapshot = true; mReflectionMapManager.initReflectionMaps(); } diff --git a/indra/newview/quickprefs.cpp b/indra/newview/quickprefs.cpp index 4a039c710b..07326cfa92 100644 --- a/indra/newview/quickprefs.cpp +++ b/indra/newview/quickprefs.cpp @@ -744,7 +744,7 @@ void FloaterQuickPrefs::loadSavedSettingsFromFile(const std::string& settings_pa if (xml_entry.translation_id.isProvided()) { // replace label with translated version, if available - LLTrans::findString(label, xml_entry.translation_id); + LLTrans::findString(label, xml_entry.translation_id()); } // Convert old RenderAvatarMaxVisible setting to IndirectMaxNonImpostors diff --git a/indra/newview/rlvui.cpp b/indra/newview/rlvui.cpp index f26334dcc0..a566490bf2 100644 --- a/indra/newview/rlvui.cpp +++ b/indra/newview/rlvui.cpp @@ -336,7 +336,7 @@ bool RlvUIEnabler::removeGenericFloaterFilter(const std::string& strFloaterName) return true; } -bool RlvUIEnabler::filterFloaterGeneric(const std::string& strFloaterName, const LLSD&) +bool RlvUIEnabler::filterFloaterGeneric(std::string_view strFloaterName, const LLSD&) { auto itFloater = m_FilteredFloaterMap.find(strFloaterName); if (m_FilteredFloaterMap.end() != itFloater) @@ -350,7 +350,7 @@ bool RlvUIEnabler::filterFloaterGeneric(const std::string& strFloaterName, const } // Checked: 2010-04-22 (RLVa-1.4.5) | Added: RLVa-1.2.0 -bool RlvUIEnabler::filterFloaterShowLoc(const std::string& strName, const LLSD&) +bool RlvUIEnabler::filterFloaterShowLoc(std::string_view strName, const LLSD&) { if ("about_land" == strName) return canViewParcelProperties(); @@ -362,7 +362,7 @@ bool RlvUIEnabler::filterFloaterShowLoc(const std::string& strName, const LLSD&) } // Checked: 2012-02-07 (RLVa-1.4.5) | Added: RLVa-1.4.5 -bool RlvUIEnabler::filterPanelShowLoc(const std::string& strFloater, const std::string&, const LLSD& sdKey) +bool RlvUIEnabler::filterPanelShowLoc(std::string_view strFloater, std::string_view, const LLSD& sdKey) { if ("places" == strFloater) { @@ -376,7 +376,7 @@ bool RlvUIEnabler::filterPanelShowLoc(const std::string& strFloater, const std:: } // Checked: 2010-03-01 (RLVa-1.2.0b) | Added: RLVa-1.2.0a -bool RlvUIEnabler::filterFloaterViewXXX(const std::string& strName, const LLSD&) +bool RlvUIEnabler::filterFloaterViewXXX(std::string_view strName, const LLSD&) { if ( (gRlvHandler.hasBehaviour(RLV_BHVR_VIEWNOTE)) && ("preview_notecard" == strName) ) { diff --git a/indra/newview/rlvui.h b/indra/newview/rlvui.h index b33ca0683f..6df15694a4 100644 --- a/indra/newview/rlvui.h +++ b/indra/newview/rlvui.h @@ -66,14 +66,14 @@ public: bool removeGenericFloaterFilter(const std::string& strFloaterName); protected: - bool filterFloaterGeneric(const std::string&, const LLSD&); + bool filterFloaterGeneric(std::string_view, const LLSD&); boost::signals2::connection m_ConnFloaterGeneric; - bool filterFloaterShowLoc(const std::string&, const LLSD& ); + bool filterFloaterShowLoc(std::string_view, const LLSD& ); boost::signals2::connection m_ConnFloaterShowLoc; // showloc - bool filterFloaterViewXXX(const std::string&, const LLSD&); + bool filterFloaterViewXXX(std::string_view, const LLSD&); boost::signals2::connection m_ConnFloaterViewXXX; // viewnote, viewscript, viewtexture - bool filterPanelShowLoc(const std::string&, const std::string&, const LLSD& ); + bool filterPanelShowLoc(std::string_view, std::string_view, const LLSD& ); boost::signals2::connection m_ConnPanelShowLoc; // showloc /* @@ -93,7 +93,7 @@ protected: typedef std::multimap behaviour_handler_map_t; behaviour_handler_map_t m_Handlers; - std::map> m_FilteredFloaterMap; + std::map, std::less<>> m_FilteredFloaterMap; }; // ============================================================================ diff --git a/indra/newview/skins/default/xui/az/notifications.xml b/indra/newview/skins/default/xui/az/notifications.xml index 326552c1a1..633b889ea9 100644 --- a/indra/newview/skins/default/xui/az/notifications.xml +++ b/indra/newview/skins/default/xui/az/notifications.xml @@ -3575,10 +3575,6 @@ Təhlükəsizliyiniz üçün onlar bir neçə saniyə bloklanacaqlar. Təəssüf ki, bu sessiya üçün hesab faydaları haqqında məlumat əldə edə bilmədik. Bu normal iş mühitində baş verməməlidir. Zəhmət olmasa dəstək ilə əlaqə saxlayın. Bu seans normal işləməyəcək və biz sizə proqramın yenidən başlamağınızı tövsiyə edirik. - - - Bu, ümumi dəyəri L$[COST] olan [COUNT] elementi yükləyəcək. Yükləməyə davam etmək istədiyinizə əminsiniz? - Cari L$[BALANCE] balansınız ümumi dəyəri L$[COST] olan [COUNT] element yükləmək üçün kifayət deyil. diff --git a/indra/newview/skins/default/xui/de/floater_bulk_upload.xml b/indra/newview/skins/default/xui/de/floater_bulk_upload.xml new file mode 100644 index 0000000000..2a23acd851 --- /dev/null +++ b/indra/newview/skins/default/xui/de/floater_bulk_upload.xml @@ -0,0 +1,33 @@ + + + + + + Anzahl an hochzuladenden Objekten: [COUNT] + + + + + Standardmäßig werden eine oder mehrere ausgewählte Texturen auf 2048px skaliert. + + + + + + + + Kosten fürs Hochladen: L$[COST] + + + +