diff options
Diffstat (limited to 'indra')
157 files changed, 5238 insertions, 1935 deletions
diff --git a/indra/llcommon/CMakeLists.txt b/indra/llcommon/CMakeLists.txt index 3c689930b8..60e88a1cfb 100644 --- a/indra/llcommon/CMakeLists.txt +++ b/indra/llcommon/CMakeLists.txt @@ -32,6 +32,7 @@ set(llcommon_SOURCE_FILES llapp.cpp llapr.cpp llassettype.cpp + llavatarname.cpp llbase32.cpp llbase64.cpp llcommon.cpp @@ -114,6 +115,7 @@ set(llcommon_HEADER_FILES llallocator.h llallocator_heap_profile.h llagentconstants.h + llavatarname.h llapp.h llapr.h llassettype.h diff --git a/indra/llcommon/llavatarname.cpp b/indra/llcommon/llavatarname.cpp new file mode 100644 index 0000000000..4eeb6e706d --- /dev/null +++ b/indra/llcommon/llavatarname.cpp @@ -0,0 +1,81 @@ +/** + * @file llavatarname.cpp + * @brief Represents name-related data for an avatar, such as the + * username/SLID ("bobsmith123" or "james.linden") and the display + * name ("James Cook") + * + * $LicenseInfo:firstyear=2010&license=viewergpl$ + * + * Copyright (c) 2010, Linden Research, Inc. + * + * Second Life Viewer Source Code + * The source code in this file ("Source Code") is provided by Linden Lab + * to you under the terms of the GNU General Public License, version 2.0 + * ("GPL"), unless you have obtained a separate licensing agreement + * ("Other License"), formally executed by you and Linden Lab. Terms of + * the GPL can be found in doc/GPL-license.txt in this distribution, or + * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2 + * + * There are special exceptions to the terms and conditions of the GPL as + * it is applied to this Source Code. View the full text of the exception + * in the file doc/FLOSS-exception.txt in this software distribution, or + * online at + * http://secondlifegrid.net/programs/open_source/licensing/flossexception + * + * By copying, modifying or distributing this software, you acknowledge + * that you have read and understood your obligations described above, + * and agree to abide by those obligations. + * + * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO + * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, + * COMPLETENESS OR PERFORMANCE. + * $/LicenseInfo$ + */ +#include "linden_common.h" + +#include "llavatarname.h" + +#include "lldate.h" +#include "llsd.h" + +// Store these in pre-built std::strings to avoid memory allocations in +// LLSD map lookups +static const std::string SL_ID("sl_id"); +static const std::string DISPLAY_NAME("display_name"); +static const std::string IS_DISPLAY_NAME_DEFAULT("is_display_name_default"); +static const std::string DISPLAY_NAME_EXPIRES("display_name_expires"); + +LLAvatarName::LLAvatarName() +: mSLID(), + mDisplayName(), + mIsDisplayNameDefault(false), + mIsDummy(false), + mExpires(F64_MAX) +{ } + +bool LLAvatarName::operator<(const LLAvatarName& rhs) const +{ + if (mSLID == rhs.mSLID) + return mDisplayName < rhs.mDisplayName; + else + return mSLID < rhs.mSLID; +} + +LLSD LLAvatarName::asLLSD() const +{ + LLSD sd; + sd[SL_ID] = mSLID; + sd[DISPLAY_NAME] = mDisplayName; + sd[IS_DISPLAY_NAME_DEFAULT] = mIsDisplayNameDefault; + sd[DISPLAY_NAME_EXPIRES] = LLDate(mExpires); + return sd; +} + +void LLAvatarName::fromLLSD(const LLSD& sd) +{ + mSLID = sd[SL_ID].asString(); + mDisplayName = sd[DISPLAY_NAME].asString(); + mIsDisplayNameDefault = sd[IS_DISPLAY_NAME_DEFAULT].asBoolean(); + LLDate expires = sd[DISPLAY_NAME_EXPIRES]; + mExpires = expires.secondsSinceEpoch(); +} diff --git a/indra/llcommon/llavatarname.h b/indra/llcommon/llavatarname.h new file mode 100644 index 0000000000..d7d91e1c7a --- /dev/null +++ b/indra/llcommon/llavatarname.h @@ -0,0 +1,75 @@ +/** + * @file llavatarname.h + * @brief Represents name-related data for an avatar, such as the + * username/SLID ("bobsmith123" or "james.linden") and the display + * name ("James Cook") + * + * $LicenseInfo:firstyear=2010&license=viewergpl$ + * + * Copyright (c) 2010, Linden Research, Inc. + * + * Second Life Viewer Source Code + * The source code in this file ("Source Code") is provided by Linden Lab + * to you under the terms of the GNU General Public License, version 2.0 + * ("GPL"), unless you have obtained a separate licensing agreement + * ("Other License"), formally executed by you and Linden Lab. Terms of + * the GPL can be found in doc/GPL-license.txt in this distribution, or + * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2 + * + * There are special exceptions to the terms and conditions of the GPL as + * it is applied to this Source Code. View the full text of the exception + * in the file doc/FLOSS-exception.txt in this software distribution, or + * online at + * http://secondlifegrid.net/programs/open_source/licensing/flossexception + * + * By copying, modifying or distributing this software, you acknowledge + * that you have read and understood your obligations described above, + * and agree to abide by those obligations. + * + * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO + * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, + * COMPLETENESS OR PERFORMANCE. + * $/LicenseInfo$ + */ +#ifndef LLAVATARNAME_H +#define LLAVATARNAME_H + +#include <string> + +class LLSD; + +class LL_COMMON_API LLAvatarName +{ +public: + LLAvatarName(); + + bool operator<(const LLAvatarName& rhs) const; + + LLSD asLLSD() const; + + void fromLLSD(const LLSD& sd); + + // "bobsmith123" or "james.linden", US-ASCII only + std::string mSLID; + + // "Jose' Sanchez" or "James Linden", UTF-8 encoded Unicode + // Contains data whether or not user has explicitly set + // a display name; may duplicate their SLID. + std::string mDisplayName; + + // If true, both display name and SLID were generated from + // a legacy first and last name, like "James Linden (james.linden)" + bool mIsDisplayNameDefault; + + // Under error conditions, we may insert "dummy" records with + // names like "???" into caches as placeholders. These can be + // shown in UI, but are not serialized. + bool mIsDummy; + + // Names can change, so need to keep track of when name was + // last checked. + // Unix time-from-epoch seconds for efficiency + F64 mExpires; +}; + +#endif diff --git a/indra/llcommon/llchat.h b/indra/llcommon/llchat.h index f1b9091298..91302618e9 100644 --- a/indra/llcommon/llchat.h +++ b/indra/llcommon/llchat.h @@ -34,7 +34,6 @@ #ifndef LL_LLCHAT_H #define LL_LLCHAT_H -#include "llstring.h" #include "lluuid.h" #include "v3math.h" @@ -77,7 +76,7 @@ typedef enum e_chat_style class LLChat { public: - LLChat(const std::string& text = LLStringUtil::null) + LLChat(const std::string& text = std::string()) : mText(text), mFromName(), mFromID(), diff --git a/indra/llinventory/lltransactionflags.cpp b/indra/llinventory/lltransactionflags.cpp index e0f87aa7db..79f8589bb1 100644 --- a/indra/llinventory/lltransactionflags.cpp +++ b/indra/llinventory/lltransactionflags.cpp @@ -114,6 +114,9 @@ std::string build_transfer_message_to_source( std::ostringstream ostr; if(dest_id.isNull()) { + // *NOTE: Do not change these strings! The viewer matches + // them in llviewermessage.cpp to perform localization. + // If you need to make changes, add a new, localizable message. JC ostr << "You paid L$" << amount; switch(transaction_type) { @@ -160,6 +163,9 @@ std::string build_transfer_message_to_destination( return description; } std::ostringstream ostr; + // *NOTE: Do not change these strings! The viewer matches + // them in llviewermessage.cpp to perform localization. + // If you need to make changes, add a new, localizable message. JC ostr << source_name << " paid you L$" << amount; append_reason(ostr, transaction_type, description); ostr << "."; diff --git a/indra/llmessage/CMakeLists.txt b/indra/llmessage/CMakeLists.txt index 1f8ee26716..1cad0f6d22 100644 --- a/indra/llmessage/CMakeLists.txt +++ b/indra/llmessage/CMakeLists.txt @@ -25,6 +25,7 @@ set(llmessage_SOURCE_FILES llares.cpp llareslistener.cpp llassetstorage.cpp + llavatarnamecache.cpp llblowfishcipher.cpp llbuffer.cpp llbufferstream.cpp @@ -110,6 +111,7 @@ set(llmessage_HEADER_FILES llares.h llareslistener.h llassetstorage.h + llavatarnamecache.h llblowfishcipher.h llbuffer.h llbufferstream.h @@ -248,6 +250,7 @@ if (LL_TESTS) "${CMAKE_CURRENT_SOURCE_DIR}/tests/test_llsdmessage_peer.py" ) + LL_ADD_INTEGRATION_TEST(llavatarnamecache "" "${test_libs}") LL_ADD_INTEGRATION_TEST(llhost "" "${test_libs}") LL_ADD_INTEGRATION_TEST(llpartdata "" "${test_libs}") LL_ADD_INTEGRATION_TEST(llxfer_file "" "${test_libs}") diff --git a/indra/llmessage/llavatarnamecache.cpp b/indra/llmessage/llavatarnamecache.cpp new file mode 100644 index 0000000000..fdbc28656e --- /dev/null +++ b/indra/llmessage/llavatarnamecache.cpp @@ -0,0 +1,773 @@ +/** + * @file llavatarnamecache.cpp + * @brief Provides lookup of avatar SLIDs ("bobsmith123") and display names + * ("James Cook") from avatar UUIDs. + * + * $LicenseInfo:firstyear=2010&license=viewergpl$ + * + * Copyright (c) 2010, Linden Research, Inc. + * + * Second Life Viewer Source Code + * The source code in this file ("Source Code") is provided by Linden Lab + * to you under the terms of the GNU General Public License, version 2.0 + * ("GPL"), unless you have obtained a separate licensing agreement + * ("Other License"), formally executed by you and Linden Lab. Terms of + * the GPL can be found in doc/GPL-license.txt in this distribution, or + * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2 + * + * There are special exceptions to the terms and conditions of the GPL as + * it is applied to this Source Code. View the full text of the exception + * in the file doc/FLOSS-exception.txt in this software distribution, or + * online at + * http://secondlifegrid.net/programs/open_source/licensing/flossexception + * + * By copying, modifying or distributing this software, you acknowledge + * that you have read and understood your obligations described above, + * and agree to abide by those obligations. + * + * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO + * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, + * COMPLETENESS OR PERFORMANCE. + * $/LicenseInfo$ + */ +#include "linden_common.h" + +#include "llavatarnamecache.h" + +#include "llcachename.h" // we wrap this system +#include "llframetimer.h" +#include "llhttpclient.h" +#include "llsd.h" +#include "llsdserialize.h" + +#include <boost/tokenizer.hpp> + +#include <map> +#include <set> + +namespace LLAvatarNameCache +{ + // Manual override for display names - can disable even if the region + // supports it. + bool sUseDisplayNames = true; + + // Cache starts in a paused state until we can determine if the + // current region supports display names. + bool sRunning = false; + + // Base lookup URL for name service. + // On simulator, loaded from indra.xml + // On viewer, usually a simulator capability (at People API team's request) + // Includes the trailing slash, like "http://pdp60.lindenlab.com:8000/agents/" + std::string sNameLookupURL; + + // accumulated agent IDs for next query against service + typedef std::set<LLUUID> ask_queue_t; + ask_queue_t sAskQueue; + + // agent IDs that have been requested, but with no reply + // maps agent ID to frame time request was made + typedef std::map<LLUUID, F64> pending_queue_t; + pending_queue_t sPendingQueue; + + // Callbacks to fire when we received a name. + // May have multiple callbacks for a single ID, which are + // represented as multiple slots bound to the signal. + // Avoid copying signals via pointers. + typedef std::map<LLUUID, callback_signal_t*> signal_map_t; + signal_map_t sSignalMap; + + // names we know about + typedef std::map<LLUUID, LLAvatarName> cache_t; + cache_t sCache; + + // Send bulk lookup requests a few times a second at most + // only need per-frame timing resolution + LLFrameTimer sRequestTimer; + + // Periodically clean out expired entries from the cache + LLFrameTimer sEraseExpiredTimer; + + //----------------------------------------------------------------------- + // Internal methods + //----------------------------------------------------------------------- + + // Handle name response off network. + // Optionally skip adding to cache, used when this is a fallback to the + // legacy name system. + void processName(const LLUUID& agent_id, + const LLAvatarName& av_name, + bool add_to_cache); + + void requestNamesViaCapability(); + + // Legacy name system callback + void legacyNameCallback(const LLUUID& agent_id, + const std::string& full_name, + bool is_group); + + void requestNamesViaLegacy(); + + // Fill in an LLAvatarName with the legacy name data + void buildLegacyName(const std::string& full_name, + LLAvatarName* av_name); + + // Do a single callback to a given slot + void fireSignal(const LLUUID& agent_id, + const callback_slot_t& slot, + const LLAvatarName& av_name); + + // Is a request in-flight over the network? + bool isRequestPending(const LLUUID& agent_id); + + // Erase expired names from cache + void eraseExpired(); + + bool expirationFromCacheControl(LLSD headers, F64 *expires); +} + +/* Sample response: +<?xml version="1.0"?> +<llsd> + <map> + <key>agents</key> + <array> + <map> + <key>display_name_next_update</key> + <date>2010-04-16T21:34:02+00:00Z</date> + <key>display_name_expires</key> + <date>2010-04-16T21:32:26.142178+00:00Z</date> + <key>display_name</key> + <string>MickBot390 LLQABot</string> + <key>sl_id</key> + <string>mickbot390.llqabot</string> + <key>id</key> + <string>0012809d-7d2d-4c24-9609-af1230a37715</string> + <key>is_display_name_default</key> + <boolean>false</boolean> + </map> + <map> + <key>display_name_next_update</key> + <date>2010-04-16T21:34:02+00:00Z</date> + <key>display_name_expires</key> + <date>2010-04-16T21:32:26.142178+00:00Z</date> + <key>display_name</key> + <string>Bjork Gudmundsdottir</string> + <key>sl_id</key> + <string>sardonyx.linden</string> + <key>id</key> + <string>3941037e-78ab-45f0-b421-bd6e77c1804d</string> + <key>is_display_name_default</key> + <boolean>true</boolean> + </map> + </array> + </map> +</llsd> +*/ + +class LLAvatarNameResponder : public LLHTTPClient::Responder +{ +private: + // need to store agent ids that are part of this request in case of + // an error, so we can flag them as unavailable + std::vector<LLUUID> mAgentIDs; + + // Need the headers to look up Expires: and Retry-After: + LLSD mHeaders; + +public: + LLAvatarNameResponder(const std::vector<LLUUID>& agent_ids) + : mAgentIDs(agent_ids), + mHeaders() + { } + + /*virtual*/ void completedHeader(U32 status, const std::string& reason, + const LLSD& headers) + { + mHeaders = headers; + } + + /*virtual*/ void result(const LLSD& content) + { + // Pull expiration out of headers if available + F64 expires = LLAvatarNameCache::nameExpirationFromHeaders(mHeaders); + + LLSD agents = content["agents"]; + LLSD::array_const_iterator it = agents.beginArray(); + for ( ; it != agents.endArray(); ++it) + { + const LLSD& row = *it; + LLUUID agent_id = row["id"].asUUID(); + + LLAvatarName av_name; + av_name.fromLLSD(row); + + // Use expiration time from header + av_name.mExpires = expires; + + // Some avatars don't have explicit display names set + if (av_name.mDisplayName.empty()) + { + av_name.mDisplayName = av_name.mSLID; + } + + // cache it and fire signals + LLAvatarNameCache::processName(agent_id, av_name, true); + } + } + + /*virtual*/ void error(U32 status, const std::string& reason) + { + // We're going to construct a dummy record and cache it for a while, + // either briefly for a 503 Service Unavailable, or longer for other + // errors. + F64 retry_timestamp = errorRetryTimestamp(status); + + // *NOTE: "??" starts trigraphs in C/C++, escape the question marks. + const std::string DUMMY_NAME("\?\?\?"); + LLAvatarName av_name; + av_name.mSLID = DUMMY_NAME; + av_name.mDisplayName = DUMMY_NAME; + av_name.mIsDisplayNameDefault = false; + av_name.mIsDummy = true; + av_name.mExpires = retry_timestamp; + + // Add dummy records for all agent IDs in this request + std::vector<LLUUID>::const_iterator it = mAgentIDs.begin(); + for ( ; it != mAgentIDs.end(); ++it) + { + const LLUUID& agent_id = *it; + // cache it and fire signals + LLAvatarNameCache::processName(agent_id, av_name, true); + } + } + + // Return time to retry a request that generated an error, based on + // error type and headers. Return value is seconds-since-epoch. + F64 errorRetryTimestamp(S32 status) + { + F64 now = LLFrameTimer::getTotalSeconds(); + + // Retry-After takes priority + LLSD retry_after = mHeaders["retry-after"]; + if (retry_after.isDefined()) + { + // We only support the delta-seconds type + S32 delta_seconds = retry_after.asInteger(); + if (delta_seconds > 0) + { + // ...valid delta-seconds + return now + F64(delta_seconds); + } + } + + // If no Retry-After, look for Cache-Control max-age + F64 expires = 0.0; + if (LLAvatarNameCache::expirationFromCacheControl(mHeaders, &expires)) + { + return expires; + } + + // No information in header, make a guess + if (status == 503) + { + // ...service unavailable, retry soon + const F64 SERVICE_UNAVAILABLE_DELAY = 600.0; // 10 min + return now + SERVICE_UNAVAILABLE_DELAY; + } + else + { + // ...other unexpected error + const F64 DEFAULT_DELAY = 3600.0; // 1 hour + return now + DEFAULT_DELAY; + } + } +}; + +void LLAvatarNameCache::processName(const LLUUID& agent_id, + const LLAvatarName& av_name, + bool add_to_cache) +{ + if (add_to_cache) + { + sCache[agent_id] = av_name; + } + + sPendingQueue.erase(agent_id); + + // signal everyone waiting on this name + signal_map_t::iterator sig_it = sSignalMap.find(agent_id); + if (sig_it != sSignalMap.end()) + { + callback_signal_t* signal = sig_it->second; + (*signal)(agent_id, av_name); + + sSignalMap.erase(agent_id); + + delete signal; + signal = NULL; + } +} + +void LLAvatarNameCache::requestNamesViaCapability() +{ + F64 now = LLFrameTimer::getTotalSeconds(); + + // URL format is like: + // http://pdp60.lindenlab.com:8000/agents/?ids=3941037e-78ab-45f0-b421-bd6e77c1804d&ids=0012809d-7d2d-4c24-9609-af1230a37715&ids=0019aaba-24af-4f0a-aa72-6457953cf7f0 + // + // Apache can handle URLs of 4096 chars, but let's be conservative + const U32 NAME_URL_MAX = 4096; + const U32 NAME_URL_SEND_THRESHOLD = 3000; + std::string url; + url.reserve(NAME_URL_MAX); + + std::vector<LLUUID> agent_ids; + agent_ids.reserve(128); + + ask_queue_t::const_iterator it = sAskQueue.begin(); + for ( ; it != sAskQueue.end(); ++it) + { + const LLUUID& agent_id = *it; + + if (url.empty()) + { + // ...starting new request + url += sNameLookupURL; + url += "?ids="; + } + else + { + // ...continuing existing request + url += "&ids="; + } + url += agent_id.asString(); + agent_ids.push_back(agent_id); + + // mark request as pending + sPendingQueue[agent_id] = now; + + if (url.size() > NAME_URL_SEND_THRESHOLD) + { + //llinfos << "requestNames " << url << llendl; + LLHTTPClient::get(url, new LLAvatarNameResponder(agent_ids)); + url.clear(); + agent_ids.clear(); + } + } + + if (!url.empty()) + { + //llinfos << "requestNames " << url << llendl; + LLHTTPClient::get(url, new LLAvatarNameResponder(agent_ids)); + url.clear(); + agent_ids.clear(); + } + + // We've moved all asks to the pending request queue + sAskQueue.clear(); +} + +void LLAvatarNameCache::legacyNameCallback(const LLUUID& agent_id, + const std::string& full_name, + bool is_group) +{ + // Construct a dummy record for this name. By convention, SLID is blank + // Never expires, but not written to disk, so lasts until end of session. + LLAvatarName av_name; + buildLegacyName(full_name, &av_name); + + // Don't add to cache, the data already exists in the legacy name system + // cache and we don't want or need duplicate storage, because keeping the + // two copies in sync is complex. + processName(agent_id, av_name, false); +} + +void LLAvatarNameCache::requestNamesViaLegacy() +{ + F64 now = LLFrameTimer::getTotalSeconds(); + std::string full_name; + ask_queue_t::const_iterator it = sAskQueue.begin(); + for (; it != sAskQueue.end(); ++it) + { + const LLUUID& agent_id = *it; + + // Mark as pending first, just in case the callback is immediately + // invoked below. This should never happen in practice. + sPendingQueue[agent_id] = now; + + gCacheName->get(agent_id, false, + boost::bind(&LLAvatarNameCache::legacyNameCallback, + _1, _2, _3)); + } + + // We've either answered immediately or moved all asks to the + // pending queue + sAskQueue.clear(); +} + +void LLAvatarNameCache::initClass(bool running) +{ + sRunning = running; +} + +void LLAvatarNameCache::cleanupClass() +{ +} + +void LLAvatarNameCache::importFile(std::istream& istr) +{ + LLSD data; + S32 parse_count = LLSDSerialize::fromXMLDocument(data, istr); + if (parse_count < 1) return; + + // by convention LLSD storage is a map + // we only store one entry in the map + LLSD agents = data["agents"]; + + LLUUID agent_id; + LLAvatarName av_name; + LLSD::map_const_iterator it = agents.beginMap(); + for ( ; it != agents.endMap(); ++it) + { + agent_id.set(it->first); + av_name.fromLLSD( it->second ); + sCache[agent_id] = av_name; + } + // entries may have expired since we last ran the viewer, just + // clean them out now + eraseExpired(); + llinfos << "loaded " << sCache.size() << llendl; +} + +void LLAvatarNameCache::exportFile(std::ostream& ostr) +{ + LLSD agents; + cache_t::const_iterator it = sCache.begin(); + for ( ; it != sCache.end(); ++it) + { + const LLUUID& agent_id = it->first; + const LLAvatarName& av_name = it->second; + if (!av_name.mIsDummy) + { + // key must be a string + agents[agent_id.asString()] = av_name.asLLSD(); + } + } + LLSD data; + data["agents"] = agents; + LLSDSerialize::toPrettyXML(data, ostr); +} + +void LLAvatarNameCache::setNameLookupURL(const std::string& name_lookup_url) +{ + sNameLookupURL = name_lookup_url; +} + +bool LLAvatarNameCache::hasNameLookupURL() +{ + return !sNameLookupURL.empty(); +} + +void LLAvatarNameCache::idle() +{ + // By convention, start running at first idle() call + sRunning = true; + + // 100 ms is the threshold for "user speed" operations, so we can + // stall for about that long to batch up requests. + const F32 SECS_BETWEEN_REQUESTS = 0.1f; + if (!sRequestTimer.checkExpirationAndReset(SECS_BETWEEN_REQUESTS)) + { + return; + } + + // Must be large relative to above + const F32 ERASE_EXPIRED_TIMEOUT = 60.f; // seconds + if (sEraseExpiredTimer.checkExpirationAndReset(ERASE_EXPIRED_TIMEOUT)) + { + eraseExpired(); + } + + if (sAskQueue.empty()) + { + return; + } + + if (useDisplayNames()) + { + requestNamesViaCapability(); + } + else + { + // ...fall back to legacy name cache system + requestNamesViaLegacy(); + } +} + +bool LLAvatarNameCache::isRequestPending(const LLUUID& agent_id) +{ + const F64 PENDING_TIMEOUT_SECS = 5.0 * 60.0; + F64 now = LLFrameTimer::getTotalSeconds(); + F64 expire_time = now - PENDING_TIMEOUT_SECS; + + pending_queue_t::const_iterator it = sPendingQueue.find(agent_id); + if (it != sPendingQueue.end()) + { + bool request_expired = (it->second < expire_time); + return !request_expired; + } + return false; +} + +void LLAvatarNameCache::eraseExpired() +{ + F64 now = LLFrameTimer::getTotalSeconds(); + cache_t::iterator it = sCache.begin(); + while (it != sCache.end()) + { + cache_t::iterator cur = it; + ++it; + const LLAvatarName& av_name = cur->second; + if (av_name.mExpires < now) + { + sCache.erase(cur); + } + } +} + +void LLAvatarNameCache::buildLegacyName(const std::string& full_name, + LLAvatarName* av_name) +{ + llassert(av_name); + av_name->mSLID = ""; + av_name->mDisplayName = full_name; + av_name->mIsDisplayNameDefault = true; + av_name->mIsDummy = true; + av_name->mExpires = F64_MAX; +} + +bool LLAvatarNameCache::get(const LLUUID& agent_id, LLAvatarName *av_name) +{ + if (sRunning) + { + // ...only do immediate lookups when cache is running + if (useDisplayNames()) + { + // ...use display names cache + std::map<LLUUID,LLAvatarName>::iterator it = sCache.find(agent_id); + if (it != sCache.end()) + { + *av_name = it->second; + return true; + } + } + else + { + // ...use legacy names cache + std::string full_name; + if (gCacheName->getFullName(agent_id, full_name)) + { + buildLegacyName(full_name, av_name); + return true; + } + } + } + + if (!isRequestPending(agent_id)) + { + sAskQueue.insert(agent_id); + } + + return false; +} + +void LLAvatarNameCache::fireSignal(const LLUUID& agent_id, + const callback_slot_t& slot, + const LLAvatarName& av_name) +{ + callback_signal_t signal; + signal.connect(slot); + signal(agent_id, av_name); +} + +void LLAvatarNameCache::get(const LLUUID& agent_id, callback_slot_t slot) +{ + if (sRunning) + { + // ...only do immediate lookups when cache is running + if (useDisplayNames()) + { + // ...use new cache + std::map<LLUUID,LLAvatarName>::iterator it = sCache.find(agent_id); + if (it != sCache.end()) + { + // ...name already exists in cache, fire callback now + fireSignal(agent_id, slot, it->second); + return; + } + } + else + { + // ...use old name system + std::string full_name; + if (gCacheName->getFullName(agent_id, full_name)) + { + LLAvatarName av_name; + buildLegacyName(full_name, &av_name); + fireSignal(agent_id, slot, av_name); + return; + } + } + } + + // schedule a request + if (!isRequestPending(agent_id)) + { + sAskQueue.insert(agent_id); + } + + // always store additional callback, even if request is pending + signal_map_t::iterator sig_it = sSignalMap.find(agent_id); + if (sig_it == sSignalMap.end()) + { + // ...new callback for this id + callback_signal_t* signal = new callback_signal_t(); + signal->connect(slot); + sSignalMap[agent_id] = signal; + } + else + { + // ...existing callback, bind additional slot + callback_signal_t* signal = sig_it->second; + signal->connect(slot); + } +} + + +void LLAvatarNameCache::setUseDisplayNames(bool use) +{ + if (use != sUseDisplayNames) + { + sUseDisplayNames = use; + // flush our cache + sCache.clear(); + } +} + +bool LLAvatarNameCache::useDisplayNames() +{ + // Must be both manually set on and able to look up names. + return sUseDisplayNames && !sNameLookupURL.empty(); +} + +void LLAvatarNameCache::erase(const LLUUID& agent_id) +{ + sCache.erase(agent_id); +} + +void LLAvatarNameCache::fetch(const LLUUID& agent_id) +{ + // re-request, even if request is already pending + sAskQueue.insert(agent_id); +} + +void LLAvatarNameCache::insert(const LLUUID& agent_id, const LLAvatarName& av_name) +{ + // *TODO: update timestamp if zero? + sCache[agent_id] = av_name; +} + +F64 LLAvatarNameCache::nameExpirationFromHeaders(LLSD headers) +{ + F64 expires = 0.0; + if (expirationFromCacheControl(headers, &expires)) + { + return expires; + } + else + { + // With no expiration info, default to a day + const F64 DEFAULT_EXPIRES = 24.0 * 60.0 * 60.0; + F64 now = LLFrameTimer::getTotalSeconds(); + return now + DEFAULT_EXPIRES; + } +} + +bool LLAvatarNameCache::expirationFromCacheControl(LLSD headers, F64 *expires) +{ + // Allow the header to override the default + LLSD cache_control_header = headers["cache-control"]; + if (cache_control_header.isDefined()) + { + S32 max_age = 0; + std::string cache_control = cache_control_header.asString(); + if (max_age_from_cache_control(cache_control, &max_age)) + { + F64 now = LLFrameTimer::getTotalSeconds(); + *expires = now + (F64)max_age; + return true; + } + } + return false; +} + +static const std::string MAX_AGE("max-age"); +static const boost::char_separator<char> EQUALS_SEPARATOR("="); +static const boost::char_separator<char> COMMA_SEPARATOR(","); + +bool max_age_from_cache_control(const std::string& cache_control, S32 *max_age) +{ + // Split the string on "," to get a list of directives + typedef boost::tokenizer<boost::char_separator<char> > tokenizer; + tokenizer directives(cache_control, COMMA_SEPARATOR); + + tokenizer::iterator token_it = directives.begin(); + for ( ; token_it != directives.end(); ++token_it) + { + // Tokens may have leading or trailing whitespace + std::string token = *token_it; + LLStringUtil::trim(token); + + if (token.compare(0, MAX_AGE.size(), MAX_AGE) == 0) + { + // ...this token starts with max-age, so let's chop it up by "=" + tokenizer subtokens(token, EQUALS_SEPARATOR); + tokenizer::iterator subtoken_it = subtokens.begin(); + + // Must have a token + if (subtoken_it == subtokens.end()) return false; + std::string subtoken = *subtoken_it; + + // Must exactly equal "max-age" + LLStringUtil::trim(subtoken); + if (subtoken != MAX_AGE) return false; + + // Must have another token + ++subtoken_it; + if (subtoken_it == subtokens.end()) return false; + subtoken = *subtoken_it; + + // Must be a valid integer + // *NOTE: atoi() returns 0 for invalid values, so we have to + // check the string first. + // *TODO: Do servers ever send "0000" for zero? We don't handle it + LLStringUtil::trim(subtoken); + if (subtoken == "0") + { + *max_age = 0; + return true; + } + S32 val = atoi( subtoken.c_str() ); + if (val > 0 && val < S32_MAX) + { + *max_age = val; + return true; + } + return false; + } + } + return false; +} + + diff --git a/indra/llmessage/llavatarnamecache.h b/indra/llmessage/llavatarnamecache.h new file mode 100644 index 0000000000..0a8b987b05 --- /dev/null +++ b/indra/llmessage/llavatarnamecache.h @@ -0,0 +1,103 @@ +/** + * @file llavatarnamecache.h + * @brief Provides lookup of avatar SLIDs ("bobsmith123") and display names + * ("James Cook") from avatar UUIDs. + * + * $LicenseInfo:firstyear=2010&license=viewergpl$ + * + * Copyright (c) 2010, Linden Research, Inc. + * + * Second Life Viewer Source Code + * The source code in this file ("Source Code") is provided by Linden Lab + * to you under the terms of the GNU General Public License, version 2.0 + * ("GPL"), unless you have obtained a separate licensing agreement + * ("Other License"), formally executed by you and Linden Lab. Terms of + * the GPL can be found in doc/GPL-license.txt in this distribution, or + * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2 + * + * There are special exceptions to the terms and conditions of the GPL as + * it is applied to this Source Code. View the full text of the exception + * in the file doc/FLOSS-exception.txt in this software distribution, or + * online at + * http://secondlifegrid.net/programs/open_source/licensing/flossexception + * + * By copying, modifying or distributing this software, you acknowledge + * that you have read and understood your obligations described above, + * and agree to abide by those obligations. + * + * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO + * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, + * COMPLETENESS OR PERFORMANCE. + * $/LicenseInfo$ + */ +#ifndef LLAVATARNAMECACHE_H +#define LLAVATARNAMECACHE_H + +#include "llavatarname.h" // for convenience + +#include <boost/signals2.hpp> + +class LLSD; +class LLUUID; + +namespace LLAvatarNameCache +{ + // Until the cache is set running, immediate lookups will fail and + // async lookups will be queued. This allows us to block requests + // until we know if the first region supports display names. + void initClass(bool running); + void cleanupClass(); + + void importFile(std::istream& istr); + void exportFile(std::ostream& ostr); + + // On the viewer, usually a simulator capabilitity + // If empty, name cache will fall back to using legacy name + // lookup system + void setNameLookupURL(const std::string& name_lookup_url); + + // Do we have a valid lookup URL, hence are we trying to use the + // new display name lookup system? + bool hasNameLookupURL(); + + // Periodically makes a batch request for display names not already in + // cache. Call once per frame. + void idle(); + + // If name is in cache, returns true and fills in provided LLAvatarName + // otherwise returns false + bool get(const LLUUID& agent_id, LLAvatarName *av_name); + + // Callback types for get() below + typedef boost::signals2::signal< + void (const LLUUID& agent_id, const LLAvatarName& av_name)> + callback_signal_t; + typedef callback_signal_t::slot_type callback_slot_t; + + // Fetches name information and calls callback. + // If name information is in cache, callback will be called immediately. + void get(const LLUUID& agent_id, callback_slot_t slot); + + // Allow display names to be explicitly disabled for testing. + void setUseDisplayNames(bool use); + bool useDisplayNames(); + + void erase(const LLUUID& agent_id); + + // Force a re-fetch of the most recent data, but keep the current + // data in cache + void fetch(const LLUUID& agent_id); + + void insert(const LLUUID& agent_id, const LLAvatarName& av_name); + + // Compute name expiration time from HTTP Cache-Control header, + // or return default value, in seconds from epoch. + F64 nameExpirationFromHeaders(LLSD headers); +} + +// Parse a cache-control header to get the max-age delta-seconds. +// Returns true if header has max-age param and it parses correctly. +// Exported here to ease unit testing. +bool max_age_from_cache_control(const std::string& cache_control, S32 *max_age); + +#endif diff --git a/indra/llmessage/llcachename.cpp b/indra/llmessage/llcachename.cpp index 9871c922f1..8e87b6f9b9 100644 --- a/indra/llmessage/llcachename.cpp +++ b/indra/llmessage/llcachename.cpp @@ -75,6 +75,8 @@ public: public: bool mIsGroup; U32 mCreateTime; // unix time_t + // IDEVO TODO collapse names to one field, which will eliminate + // many string compares on "Resident" std::string mFirstName; std::string mLastName; std::string mGroupName; @@ -220,7 +222,9 @@ public: Impl(LLMessageSystem* msg); ~Impl(); - + + BOOL getName(const LLUUID& id, std::string& first, std::string& last); + boost::signals2::connection addPending(const LLUUID& id, const LLCacheNameCallback& callback); void addPending(const LLUUID& id, const LLHost& host); @@ -306,89 +310,10 @@ boost::signals2::connection LLCacheName::addObserver(const LLCacheNameCallback& return impl.mSignal.connect(callback); } -void LLCacheName::importFile(LLFILE* fp) -{ - S32 count = 0; - - const S32 BUFFER_SIZE = 1024; - char buffer[BUFFER_SIZE]; /*Flawfinder: ignore*/ - - // *NOTE: These buffer sizes are hardcoded into sscanf() below - char id_string[MAX_STRING]; /*Flawfinder: ignore*/ - char firstname[MAX_STRING]; /*Flawfinder: ignore*/ - char lastname[MAX_STRING]; /*Flawfinder: ignore*/ - U32 create_time; - - // This is OK if the first line is actually a name. We just don't load it. - char* valid = fgets(buffer, BUFFER_SIZE, fp); - if (!valid) return; - - // *NOTE: This buffer size is hardcoded into sscanf() below - char version_string[BUFFER_SIZE]; /*Flawfinder: ignore*/ - S32 version = 0; - S32 match = sscanf( /* Flawfinder: ignore */ - buffer, - "%1023s %d", - version_string, &version); - if ( match != 2 - || strcmp(version_string, "version") - || version != CN_FILE_VERSION) - { - llwarns << "Ignoring old cache name file format" << llendl; - return; - } - - // We'll expire entries more than a week old - U32 now = (U32)time(NULL); - const U32 SECS_PER_DAY = 60 * 60 * 24; - U32 delete_before_time = now - (7 * SECS_PER_DAY); - - while(!feof(fp)) - { - valid = fgets(buffer, BUFFER_SIZE, fp); - if (!valid) break; - - match = sscanf( /* Flawfinder: ignore */ - buffer, - "%254s %u %254s %254s", - id_string, - &create_time, - firstname, - lastname); - if (4 != match) continue; - - LLUUID id(id_string); - if (id.isNull()) continue; - - // undo trivial XOR - S32 i; - for (i = 0; i < UUID_BYTES; i++) - { - id.mData[i] ^= 0x33; - } - - // Don't load entries that are more than a week old - if (create_time < delete_before_time) continue; - - LLCacheNameEntry* entry = new LLCacheNameEntry(); - entry->mIsGroup = false; - entry->mCreateTime = create_time; - entry->mFirstName = firstname; - entry->mLastName = lastname; - impl.mCache[id] = entry; - std::string fullname = entry->mFirstName + " " + entry->mLastName; - impl.mReverseCache[fullname] = id; - - count++; - } - - llinfos << "LLCacheName loaded " << count << " names" << llendl; -} - bool LLCacheName::importFile(std::istream& istr) { LLSD data; - if(LLSDSerialize::fromXML(data, istr) < 1) + if(LLSDSerialize::fromXMLDocument(data, istr) < 1) return false; // We'll expire entries more than a week old @@ -414,7 +339,7 @@ bool LLCacheName::importFile(std::istream& istr) entry->mFirstName = agent[FIRST].asString(); entry->mLastName = agent[LAST].asString(); impl.mCache[id] = entry; - std::string fullname = entry->mFirstName + " " + entry->mLastName; + std::string fullname = buildFullName(entry->mFirstName, entry->mLastName); impl.mReverseCache[fullname] = id; ++count; @@ -463,6 +388,7 @@ void LLCacheName::exportFile(std::ostream& ostr) // store it LLUUID id = iter->first; std::string id_str = id.asString(); + // IDEVO TODO: Should we store SLIDs with last name "Resident" or not? if(!entry->mFirstName.empty() && !entry->mLastName.empty()) { data[AGENTS][id_str][FIRST] = entry->mFirstName; @@ -480,7 +406,7 @@ void LLCacheName::exportFile(std::ostream& ostr) } -BOOL LLCacheName::getName(const LLUUID& id, std::string& first, std::string& last) +BOOL LLCacheName::Impl::getName(const LLUUID& id, std::string& first, std::string& last) { if(id.isNull()) { @@ -489,7 +415,7 @@ BOOL LLCacheName::getName(const LLUUID& id, std::string& first, std::string& las return TRUE; } - LLCacheNameEntry* entry = get_ptr_in_map(impl.mCache, id ); + LLCacheNameEntry* entry = get_ptr_in_map(mCache, id ); if (entry) { first = entry->mFirstName; @@ -500,16 +426,17 @@ BOOL LLCacheName::getName(const LLUUID& id, std::string& first, std::string& las { first = sCacheName["waiting"]; last.clear(); - if (!impl.isRequestPending(id)) + if (!isRequestPending(id)) { - impl.mAskNameQueue.insert(id); + mAskNameQueue.insert(id); } return FALSE; } } + // static -void LLCacheName::LocalizeCacheName(std::string key, std::string value) +void LLCacheName::localizeCacheName(std::string key, std::string value) { if (key!="" && value!= "" ) sCacheName[key]=value; @@ -520,11 +447,13 @@ void LLCacheName::LocalizeCacheName(std::string key, std::string value) BOOL LLCacheName::getFullName(const LLUUID& id, std::string& fullname) { std::string first_name, last_name; - BOOL res = getName(id, first_name, last_name); - fullname = first_name + " " + last_name; + BOOL res = impl.getName(id, first_name, last_name); + fullname = buildFullName(first_name, last_name); return res; } + + BOOL LLCacheName::getGroupName(const LLUUID& id, std::string& group) { if(id.isNull()) @@ -561,13 +490,13 @@ BOOL LLCacheName::getGroupName(const LLUUID& id, std::string& group) BOOL LLCacheName::getUUID(const std::string& first, const std::string& last, LLUUID& id) { - std::string fullname = first + " " + last; - return getUUID(fullname, id); + std::string full_name = buildFullName(first, last); + return getUUID(full_name, id); } -BOOL LLCacheName::getUUID(const std::string& fullname, LLUUID& id) +BOOL LLCacheName::getUUID(const std::string& full_name, LLUUID& id) { - ReverseCache::iterator iter = impl.mReverseCache.find(fullname); + ReverseCache::iterator iter = impl.mReverseCache.find(full_name); if (iter != impl.mReverseCache.end()) { id = iter->second; @@ -579,6 +508,25 @@ BOOL LLCacheName::getUUID(const std::string& fullname, LLUUID& id) } } +//static +std::string LLCacheName::buildFullName(const std::string& first, const std::string& last) +{ + std::string fullname = first; + if (!last.empty() + && last != "Resident") + { + fullname += ' '; + fullname += last; + } + return fullname; +} + +//static +std::string LLCacheName::cleanFullName(const std::string& full_name) +{ + return full_name.substr(0, full_name.find(" Resident")); +} + // This is a little bit kludgy. LLCacheNameCallback is a slot instead of a function pointer. // The reason it is a slot is so that the legacy get() function below can bind an old callback // and pass it as a slot. The reason it isn't a boost::function is so that trackable behavior @@ -586,7 +534,7 @@ BOOL LLCacheName::getUUID(const std::string& fullname, LLUUID& id) // we call it immediately. -Steve // NOTE: Even though passing first and last name is a bit of extra overhead, it eliminates the // potential need for any parsing should any code need to handle first and last name independently. -boost::signals2::connection LLCacheName::get(const LLUUID& id, BOOL is_group, const LLCacheNameCallback& callback) +boost::signals2::connection LLCacheName::get(const LLUUID& id, bool is_group, const LLCacheNameCallback& callback) { boost::signals2::connection res; @@ -594,7 +542,7 @@ boost::signals2::connection LLCacheName::get(const LLUUID& id, BOOL is_group, co { LLCacheNameSignal signal; signal.connect(callback); - signal(id, sCacheName["nobody"], "", is_group); + signal(id, sCacheName["nobody"], is_group); return res; } @@ -606,11 +554,13 @@ boost::signals2::connection LLCacheName::get(const LLUUID& id, BOOL is_group, co // id found in map therefore we can call the callback immediately. if (entry->mIsGroup) { - signal(id, entry->mGroupName, "", entry->mIsGroup); + signal(id, entry->mGroupName, entry->mIsGroup); } else { - signal(id, entry->mFirstName, entry->mLastName, entry->mIsGroup); + std::string fullname = + buildFullName(entry->mFirstName, entry->mLastName); + signal(id, fullname, entry->mIsGroup); } } else @@ -632,9 +582,9 @@ boost::signals2::connection LLCacheName::get(const LLUUID& id, BOOL is_group, co return res; } -boost::signals2::connection LLCacheName::get(const LLUUID& id, BOOL is_group, old_callback_t callback, void* user_data) +boost::signals2::connection LLCacheName::get(const LLUUID& id, bool is_group, old_callback_t callback, void* user_data) { - return get(id, is_group, boost::bind(callback, _1, _2, _3, _4, user_data)); + return get(id, is_group, boost::bind(callback, _1, _2, _3, user_data)); } void LLCacheName::processPending() @@ -706,7 +656,7 @@ void LLCacheName::dump() { llinfos << iter->first << " = " - << entry->mFirstName << " " << entry->mLastName + << buildFullName(entry->mFirstName, entry->mLastName) << " @ " << entry->mCreateTime << llendl; } @@ -725,12 +675,24 @@ void LLCacheName::dumpStats() << llendl; } +void LLCacheName::clear() +{ + for_each(impl.mCache.begin(), impl.mCache.end(), DeletePairedPointer()); + impl.mCache.clear(); +} + //static std::string LLCacheName::getDefaultName() { return sCacheName["waiting"]; } +//static +std::string LLCacheName::getDefaultLastName() +{ + return "Resident"; +} + void LLCacheName::Impl::processPendingAsks() { LLMemType mt_ppa(LLMemType::MTYPE_CACHE_PROCESS_PENDING_ASKS); @@ -752,11 +714,13 @@ void LLCacheName::Impl::processPendingReplies() if (!entry->mIsGroup) { - (reply->mSignal)(reply->mID, entry->mFirstName, entry->mLastName, FALSE); + std::string fullname = + LLCacheName::buildFullName(entry->mFirstName, entry->mLastName); + (reply->mSignal)(reply->mID, fullname, false); } else { - (reply->mSignal)(reply->mID, entry->mGroupName, "", TRUE); + (reply->mSignal)(reply->mID, entry->mGroupName, true); } } @@ -927,13 +891,27 @@ void LLCacheName::Impl::processUUIDReply(LLMessageSystem* msg, bool isGroup) if (!isGroup) { - mSignal(id, entry->mFirstName, entry->mLastName, FALSE); - std::string fullname = entry->mFirstName + " " + entry->mLastName; - mReverseCache[fullname] = id; + // NOTE: Very occasionally the server sends down a full name + // in the first name field with an empty last name, for example, + // first = "Ladanie1 Resident", last = "". + // I cannot reproduce this, nor can I find a bug in the server code. + // Ensure "Resident" does not appear via cleanFullName, because + // buildFullName only checks last name. JC + std::string full_name; + if (entry->mLastName.empty()) + { + full_name = cleanFullName(entry->mFirstName); + } + else + { + full_name = LLCacheName::buildFullName(entry->mFirstName, entry->mLastName); + } + mSignal(id, full_name, false); + mReverseCache[full_name] = id; } else { - mSignal(id, entry->mGroupName, "", TRUE); + mSignal(id, entry->mGroupName, true); mReverseCache[entry->mGroupName] = id; } } @@ -962,4 +940,3 @@ void LLCacheName::Impl::handleUUIDGroupNameReply(LLMessageSystem* msg, void** us { ((LLCacheName::Impl*)userData)->processUUIDReply(msg, true); } - diff --git a/indra/llmessage/llcachename.h b/indra/llmessage/llcachename.h index 111cc8b650..6b6bbde6ab 100644 --- a/indra/llmessage/llcachename.h +++ b/indra/llmessage/llcachename.h @@ -42,13 +42,12 @@ class LLUUID; typedef boost::signals2::signal<void (const LLUUID& id, - const std::string& first_name, - const std::string& last_name, - BOOL is_group)> LLCacheNameSignal; + const std::string& name, + bool is_group)> LLCacheNameSignal; typedef LLCacheNameSignal::slot_type LLCacheNameCallback; // Old callback with user data for compatability -typedef void (*old_callback_t)(const LLUUID&, const std::string&, const std::string&, BOOL, void*); +typedef void (*old_callback_t)(const LLUUID&, const std::string&, bool, void*); // Here's the theory: // If you request a name that isn't in the cache, it returns "waiting" @@ -71,24 +70,26 @@ public: boost::signals2::connection addObserver(const LLCacheNameCallback& callback); - // janky old format. Remove after a while. Phoenix. 2008-01-30 - void importFile(LLFILE* fp); - // storing cache on disk; for viewer, in name.cache bool importFile(std::istream& istr); void exportFile(std::ostream& ostr); - // If available, copies the first and last name into the strings provided. - // first must be at least DB_FIRST_NAME_BUF_SIZE characters. - // last must be at least DB_LAST_NAME_BUF_SIZE characters. + // If available, copies name ("bobsmith123" or "James Linden") into string // If not available, copies the string "waiting". // Returns TRUE iff available. - BOOL getName(const LLUUID& id, std::string& first, std::string& last); - BOOL getFullName(const LLUUID& id, std::string& fullname); - + BOOL getFullName(const LLUUID& id, std::string& full_name); + // Reverse lookup of UUID from name BOOL getUUID(const std::string& first, const std::string& last, LLUUID& id); BOOL getUUID(const std::string& fullname, LLUUID& id); + + // IDEVO Temporary code + // Clean up new-style "bobsmith123 Resident" names to "bobsmith123" for display + static std::string buildFullName(const std::string& first, const std::string& last); + + // Clean up legacy "bobsmith123 Resident" to "bobsmith123" + // If name does not contain "Resident" returns it unchanged. + static std::string cleanFullName(const std::string& full_name); // If available, this method copies the group name into the string // provided. The caller must allocate at least @@ -100,10 +101,10 @@ public: // If the data is currently available, may call the callback immediatly // otherwise, will request the data, and will call the callback when // available. There is no garuntee the callback will ever be called. - boost::signals2::connection get(const LLUUID& id, BOOL is_group, const LLCacheNameCallback& callback); + boost::signals2::connection get(const LLUUID& id, bool is_group, const LLCacheNameCallback& callback); // LEGACY - boost::signals2::connection get(const LLUUID& id, BOOL is_group, old_callback_t callback, void* user_data); + boost::signals2::connection get(const LLUUID& id, bool is_group, old_callback_t callback, void* user_data); // This method needs to be called from time to time to send out // requests. void processPending(); @@ -114,9 +115,15 @@ public: // Debugging void dump(); // Dumps the contents of the cache void dumpStats(); // Dumps the sizes of the cache and associated queues. + void clear(); // Deletes all entries from the cache static std::string getDefaultName(); - static void LocalizeCacheName(std::string key, std::string value); + + // Returns "Resident", the default last name for SLID-based accounts + // that have no last name. + static std::string getDefaultLastName(); + + static void localizeCacheName(std::string key, std::string value); static std::map<std::string, std::string> sCacheName; private: diff --git a/indra/llmessage/mean_collision_data.h b/indra/llmessage/mean_collision_data.h index 03b96f9f90..a6c635e81e 100644 --- a/indra/llmessage/mean_collision_data.h +++ b/indra/llmessage/mean_collision_data.h @@ -61,7 +61,7 @@ public: LLMeanCollisionData(LLMeanCollisionData *mcd) : mVictim(mcd->mVictim), mPerp(mcd->mPerp), mTime(mcd->mTime), mType(mcd->mType), mMag(mcd->mMag), - mFirstName(mcd->mFirstName), mLastName(mcd->mLastName) + mFullName(mcd->mFullName) { } @@ -95,8 +95,7 @@ public: time_t mTime; EMeanCollisionType mType; F32 mMag; - std::string mFirstName; - std::string mLastName; + std::string mFullName; }; diff --git a/indra/llmessage/tests/llavatarnamecache_test.cpp b/indra/llmessage/tests/llavatarnamecache_test.cpp new file mode 100644 index 0000000000..eeadb703d1 --- /dev/null +++ b/indra/llmessage/tests/llavatarnamecache_test.cpp @@ -0,0 +1,109 @@ +/** + * @file llhost_test.cpp + * @author Adroit + * @date 2007-02 + * @brief llhost test cases. + * + * $LicenseInfo:firstyear=2007&license=viewergpl$ + * + * Copyright (c) 2007-2009, Linden Research, Inc. + * + * Second Life Viewer Source Code + * The source code in this file ("Source Code") is provided by Linden Lab + * to you under the terms of the GNU General Public License, version 2.0 + * ("GPL"), unless you have obtained a separate licensing agreement + * ("Other License"), formally executed by you and Linden Lab. Terms of + * the GPL can be found in doc/GPL-license.txt in this distribution, or + * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2 + * + * There are special exceptions to the terms and conditions of the GPL as + * it is applied to this Source Code. View the full text of the exception + * in the file doc/FLOSS-exception.txt in this software distribution, or + * online at + * http://secondlifegrid.net/programs/open_source/licensing/flossexception + * + * By copying, modifying or distributing this software, you acknowledge + * that you have read and understood your obligations described above, + * and agree to abide by those obligations. + * + * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO + * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, + * COMPLETENESS OR PERFORMANCE. + * $/LicenseInfo$ + */ + +#include "linden_common.h" + +#include "../llavatarnamecache.h" + +#include "../test/lltut.h" + +namespace tut +{ + struct avatarnamecache_data + { + }; + typedef test_group<avatarnamecache_data> avatarnamecache_test; + typedef avatarnamecache_test::object avatarnamecache_object; + tut::avatarnamecache_test avatarnamecache_testcase("llavatarnamecache"); + + template<> template<> + void avatarnamecache_object::test<1>() + { + bool valid = false; + S32 max_age = 0; + + valid = max_age_from_cache_control("max-age=3600", &max_age); + ensure("typical input valid", valid); + ensure_equals("typical input parsed", max_age, 3600); + + valid = max_age_from_cache_control( + " max-age=600 , no-cache,private=\"stuff\" ", &max_age); + ensure("complex input valid", valid); + ensure_equals("complex input parsed", max_age, 600); + + valid = max_age_from_cache_control( + "no-cache, max-age = 123 ", &max_age); + ensure("complex input 2 valid", valid); + ensure_equals("complex input 2 parsed", max_age, 123); + } + + template<> template<> + void avatarnamecache_object::test<2>() + { + bool valid = false; + S32 max_age = -1; + + valid = max_age_from_cache_control("", &max_age); + ensure("empty input returns invalid", !valid); + ensure_equals("empty input doesn't change val", max_age, -1); + + valid = max_age_from_cache_control("no-cache", &max_age); + ensure("no max-age field returns invalid", !valid); + + valid = max_age_from_cache_control("max", &max_age); + ensure("just 'max' returns invalid", !valid); + + valid = max_age_from_cache_control("max-age", &max_age); + ensure("partial max-age is invalid", !valid); + + valid = max_age_from_cache_control("max-age=", &max_age); + ensure("longer partial max-age is invalid", !valid); + + valid = max_age_from_cache_control("max-age=FOO", &max_age); + ensure("invalid integer max-age is invalid", !valid); + + valid = max_age_from_cache_control("max-age 234", &max_age); + ensure("space separated max-age is invalid", !valid); + + valid = max_age_from_cache_control("max-age=0", &max_age); + ensure("zero max-age is valid", valid); + + // *TODO: Handle "0000" as zero + //valid = max_age_from_cache_control("max-age=0000", &max_age); + //ensure("multi-zero max-age is valid", valid); + + valid = max_age_from_cache_control("max-age=-123", &max_age); + ensure("less than zero max-age is invalid", !valid); + } +} diff --git a/indra/llui/llcombobox.cpp b/indra/llui/llcombobox.cpp index cc107c972d..f49069f065 100644 --- a/indra/llui/llcombobox.cpp +++ b/indra/llui/llcombobox.cpp @@ -58,8 +58,6 @@ #include "lltooltip.h" // Globals -S32 LLCOMBOBOX_HEIGHT = 0; -S32 LLCOMBOBOX_WIDTH = 0; S32 MAX_COMBO_WIDTH = 500; static LLDefaultChildRegistry::Register<LLComboBox> register_combo_box("combo_box"); @@ -711,10 +709,10 @@ void LLComboBox::onItemSelected(const LLSD& data) setLabel(getSelectedItemLabel()); if (mAllowTextEntry) - { - gFocusMgr.setKeyboardFocus(mTextEntry); - mTextEntry->selectAll(); - } + { + gFocusMgr.setKeyboardFocus(mTextEntry); + mTextEntry->selectAll(); + } } // hiding the list reasserts the old value stored in the text editor/dropdown button hideList(); diff --git a/indra/llui/llcombobox.h b/indra/llui/llcombobox.h index f0bd432f3a..7f93cd1477 100644 --- a/indra/llui/llcombobox.h +++ b/indra/llui/llcombobox.h @@ -49,9 +49,6 @@ class LLFontGL; class LLViewBorder; -extern S32 LLCOMBOBOX_HEIGHT; -extern S32 LLCOMBOBOX_WIDTH; - class LLComboBox : public LLUICtrl, public LLCtrlListInterface { @@ -230,8 +227,8 @@ private: commit_callback_t mPrearrangeCallback; commit_callback_t mTextEntryCallback; commit_callback_t mSelectionCallback; - boost::signals2::connection mTopLostSignalConnection; - S32 mLastSelectedIndex; + boost::signals2::connection mTopLostSignalConnection; + S32 mLastSelectedIndex; }; // A combo box with icons for the list of items. diff --git a/indra/llui/lltextbase.cpp b/indra/llui/lltextbase.cpp index 390ec234d3..78312eba73 100644 --- a/indra/llui/lltextbase.cpp +++ b/indra/llui/lltextbase.cpp @@ -401,11 +401,11 @@ void LLTextBase::drawSelectionBackground() ++rect_it) { LLRect selection_rect = *rect_it; - selection_rect.translate(mVisibleTextRect.mLeft - content_display_rect.mLeft, mVisibleTextRect.mBottom - content_display_rect.mBottom); - gl_rect_2d(selection_rect, selection_color); + selection_rect.translate(mVisibleTextRect.mLeft - content_display_rect.mLeft, mVisibleTextRect.mBottom - content_display_rect.mBottom); + gl_rect_2d(selection_rect, selection_color); + } } } -} void LLTextBase::drawCursor() { @@ -1551,6 +1551,20 @@ std::string LLTextBase::getText() const return getViewModel()->getValue().asString(); } +// IDEVO - icons can be UI image names or UUID sent from +// server with avatar display name +static LLUIImagePtr image_from_icon_name(const std::string& icon_name) +{ + if (LLUUID::validate(icon_name)) + { + return LLUI::getUIImageByID( LLUUID(icon_name) ); + } + else + { + return LLUI::getUIImage(icon_name); + } +} + void LLTextBase::appendText(const std::string &new_text, bool prepend_newline, const LLStyle::Params& input_params) { LLStyle::Params style_params(input_params); @@ -1563,7 +1577,7 @@ void LLTextBase::appendText(const std::string &new_text, bool prepend_newline, c LLUrlMatch match; std::string text = new_text; while ( LLUrlRegistry::instance().findUrl(text, match, - boost::bind(&LLTextBase::replaceUrlLabel, this, _1, _2)) ) + boost::bind(&LLTextBase::replaceUrl, this, _1, _2, _3)) ) { start = match.getStart(); end = match.getEnd()+1; @@ -1594,15 +1608,18 @@ void LLTextBase::appendText(const std::string &new_text, bool prepend_newline, c // output an optional icon before the Url if (! match.getIcon().empty()) { - LLUIImagePtr image = LLUI::getUIImage(match.getIcon()); + LLUIImagePtr image = image_from_icon_name( match.getIcon() ); if (image) { - LLStyle::Params icon; - icon.image = image; + LLStyle::Params icon_params; + icon_params.image = image; + // must refer to our link so we can update the icon later + // after name/group data is looked up + icon_params.link_href = match.getUrl(); // Text will be replaced during rendering with the icon, // but string cannot be empty or the segment won't be // added (or drawn). - appendAndHighlightText(" ", prepend_newline, part, icon); + appendAndHighlightText(" ", prepend_newline, part, icon_params); prepend_newline = false; } } @@ -1752,8 +1769,9 @@ void LLTextBase::appendAndHighlightText(const std::string &new_text, bool prepen } -void LLTextBase::replaceUrlLabel(const std::string &url, - const std::string &label) +void LLTextBase::replaceUrl(const std::string &url, + const std::string &label, + const std::string &icon) { // get the full (wide) text for the editor so we can change it LLWString text = getWText(); @@ -1783,6 +1801,21 @@ void LLTextBase::replaceUrlLabel(const std::string &url, modified = true; } + // Icon might be updated when more avatar or group info + // becomes available + if (style->isImage() && style->getLinkHREF() == url) + { + LLUIImagePtr image = image_from_icon_name( icon ); + if (image) + { + LLStyle::Params icon_params; + icon_params.image = image; + LLStyleConstSP new_style(new LLStyle(icon_params)); + seg->setStyle(new_style); + modified = true; + } + } + // work out the character offset for the next segment seg_start = seg->getEnd(); } @@ -1847,7 +1880,7 @@ S32 LLTextBase::getDocIndexFromLocalCoord( S32 local_x, S32 local_y, BOOL round, pos = segment_line_start; break; } - if (local_x < start_x + text_width // cursor to left of right edge of text + if (local_x < start_x + text_width // cursor to left of right edge of text || newline) // or this line ends with a newline, set doc pos to newline char { // Figure out which character we're nearest to. diff --git a/indra/llui/lltextbase.h b/indra/llui/lltextbase.h index 8ed0680df9..3a3a5d0e20 100644 --- a/indra/llui/lltextbase.h +++ b/indra/llui/lltextbase.h @@ -314,7 +314,10 @@ protected: // misc void updateRects(); void needsScroll() { mScrollNeeded = TRUE; } - void replaceUrlLabel(const std::string &url, const std::string &label); + + // Replace a URL with a new icon and label, for example, when + // avatar names are looked up. + void replaceUrl(const std::string &url, const std::string &label, const std::string& icon); protected: // text segmentation and flow diff --git a/indra/llui/llurlentry.cpp b/indra/llui/llurlentry.cpp index 3375c13c94..f3e1a07fbc 100644 --- a/indra/llui/llurlentry.cpp +++ b/indra/llui/llurlentry.cpp @@ -37,10 +37,15 @@ #include "llurlmatch.h" #include "llurlregistry.h" +#include "llavatarnamecache.h" #include "llcachename.h" #include "lltrans.h" #include "lluicolortable.h" +// Utility functions +std::string localize_slapp_label(const std::string& url, const std::string& full_name); + + LLUrlEntryBase::LLUrlEntryBase() : mColor(LLUIColorTable::instance().getColor("HTMLLinkColor")), mDisabledLink(false) @@ -56,6 +61,12 @@ std::string LLUrlEntryBase::getUrl(const std::string &string) const return escapeUrl(string); } +//virtual +std::string LLUrlEntryBase::getIcon(const std::string &url) const +{ + return mIcon; +} + std::string LLUrlEntryBase::getIDStringFromUrl(const std::string &url) const { // return the id from a SLURL in the format /app/{cmd}/{id}/about @@ -133,8 +144,11 @@ void LLUrlEntryBase::addObserver(const std::string &id, mObservers.insert(std::pair<std::string, LLUrlEntryObserver>(id, observer)); } } - -void LLUrlEntryBase::callObservers(const std::string &id, const std::string &label) + +// *NOTE: See also LLUrlEntryAgent::callObservers() +void LLUrlEntryBase::callObservers(const std::string &id, + const std::string &label, + const std::string &icon) { // notify all callbacks waiting on the given uuid std::multimap<std::string, LLUrlEntryObserver>::iterator it; @@ -142,7 +156,7 @@ void LLUrlEntryBase::callObservers(const std::string &id, const std::string &lab { // call the callback - give it the new label LLUrlEntryObserver &observer = it->second; - (*observer.signal)(it->second.url, label); + (*observer.signal)(it->second.url, label, icon); // then remove the signal - we only need to call it once delete observer.signal; mObservers.erase(it++); @@ -313,13 +327,35 @@ LLUrlEntryAgent::LLUrlEntryAgent() mColor = LLUIColorTable::instance().getColor("AgentLinkColor"); } -void LLUrlEntryAgent::onAgentNameReceived(const LLUUID& id, - const std::string& first, - const std::string& last, - BOOL is_group) +// virtual +void LLUrlEntryAgent::callObservers(const std::string &id, + const std::string &label, + const std::string &icon) +{ + // notify all callbacks waiting on the given uuid + std::multimap<std::string, LLUrlEntryObserver>::iterator it; + for (it = mObservers.find(id); it != mObservers.end();) + { + // call the callback - give it the new label + LLUrlEntryObserver &observer = it->second; + std::string final_label = localize_slapp_label(observer.url, label); + (*observer.signal)(observer.url, final_label, icon); + // then remove the signal - we only need to call it once + delete observer.signal; + mObservers.erase(it++); + } +} + +void LLUrlEntryAgent::onAvatarNameCache(const LLUUID& id, + const LLAvatarName& av_name) { + std::string label = av_name.mDisplayName; + if (!av_name.mSLID.empty()) + { + label += " (" + av_name.mSLID + ")"; + } // received the agent name from the server - tell our observers - callObservers(id.asString(), first + " " + last); + callObservers(id.asString(), label, mIcon); } std::string LLUrlEntryAgent::getTooltip(const std::string &string) const @@ -370,50 +406,71 @@ std::string LLUrlEntryAgent::getLabel(const std::string &url, const LLUrlLabelCa } LLUUID agent_id(agent_id_string); - std::string full_name; if (agent_id.isNull()) { return LLTrans::getString("AvatarNameNobody"); } - else if (gCacheName->getFullName(agent_id, full_name)) + + LLAvatarName av_name; + if (LLAvatarNameCache::get(agent_id, &av_name)) { - // customize label string based on agent SLapp suffix - if (LLStringUtil::endsWith(url, "/mute")) + std::string label = av_name.mDisplayName; + if (!av_name.mSLID.empty()) { - return LLTrans::getString("SLappAgentMute") + " " + full_name; + label += " (" + av_name.mSLID + ")"; } - if (LLStringUtil::endsWith(url, "/unmute")) - { - return LLTrans::getString("SLappAgentUnmute") + " " + full_name; - } - if (LLStringUtil::endsWith(url, "/im")) - { - return LLTrans::getString("SLappAgentIM") + " " + full_name; - } - if (LLStringUtil::endsWith(url, "/pay")) - { - return LLTrans::getString("SLappAgentPay") + " " + full_name; - } - if (LLStringUtil::endsWith(url, "/offerteleport")) - { - return LLTrans::getString("SLappAgentOfferTeleport") + " " + full_name; - } - if (LLStringUtil::endsWith(url, "/requestfriend")) - { - return LLTrans::getString("SLappAgentRequestFriend") + " " + full_name; - } - return full_name; + // handle suffixes like /mute or /offerteleport + label = localize_slapp_label(url, label); + return label; } else { - gCacheName->get(agent_id, FALSE, - boost::bind(&LLUrlEntryAgent::onAgentNameReceived, - this, _1, _2, _3, _4)); + LLAvatarNameCache::get(agent_id, + boost::bind(&LLUrlEntryAgent::onAvatarNameCache, + this, _1, _2)); addObserver(agent_id_string, url, cb); return LLTrans::getString("LoadingData"); } } +std::string localize_slapp_label(const std::string& url, const std::string& full_name) +{ + // customize label string based on agent SLapp suffix + if (LLStringUtil::endsWith(url, "/mute")) + { + return LLTrans::getString("SLappAgentMute") + " " + full_name; + } + if (LLStringUtil::endsWith(url, "/unmute")) + { + return LLTrans::getString("SLappAgentUnmute") + " " + full_name; + } + if (LLStringUtil::endsWith(url, "/im")) + { + return LLTrans::getString("SLappAgentIM") + " " + full_name; + } + if (LLStringUtil::endsWith(url, "/pay")) + { + return LLTrans::getString("SLappAgentPay") + " " + full_name; + } + if (LLStringUtil::endsWith(url, "/offerteleport")) + { + return LLTrans::getString("SLappAgentOfferTeleport") + " " + full_name; + } + if (LLStringUtil::endsWith(url, "/requestfriend")) + { + return LLTrans::getString("SLappAgentRequestFriend") + " " + full_name; + } + return full_name; +} + + +std::string LLUrlEntryAgent::getIcon(const std::string &url) const +{ + // *NOTE: Could look up a badge here by calling getIDStringFromUrl() + // and looking up the badge for the agent. + return mIcon; +} + // // LLUrlEntryGroup Describes a Second Life group Url, e.g., // secondlife:///app/group/00005ff3-4044-c79f-9de8-fb28ae0df991/about @@ -430,12 +487,11 @@ LLUrlEntryGroup::LLUrlEntryGroup() } void LLUrlEntryGroup::onGroupNameReceived(const LLUUID& id, - const std::string& first, - const std::string& last, - BOOL is_group) + const std::string& name, + bool is_group) { // received the group name from the server - tell our observers - callObservers(id.asString(), first); + callObservers(id.asString(), name, mIcon); } std::string LLUrlEntryGroup::getLabel(const std::string &url, const LLUrlLabelCallback &cb) @@ -465,9 +521,9 @@ std::string LLUrlEntryGroup::getLabel(const std::string &url, const LLUrlLabelCa } else { - gCacheName->get(group_id, TRUE, + gCacheName->get(group_id, true, boost::bind(&LLUrlEntryGroup::onGroupNameReceived, - this, _1, _2, _3, _4)); + this, _1, _2, _3)); addObserver(group_id_string, url, cb); return LLTrans::getString("LoadingData"); } diff --git a/indra/llui/llurlentry.h b/indra/llui/llurlentry.h index 71f030677a..d89f647a55 100644 --- a/indra/llui/llurlentry.h +++ b/indra/llui/llurlentry.h @@ -41,8 +41,11 @@ #include <string> #include <map> +class LLAvatarName; + typedef boost::signals2::signal<void (const std::string& url, - const std::string& label)> LLUrlLabelSignal; + const std::string& label, + const std::string& icon)> LLUrlLabelSignal; typedef LLUrlLabelSignal::slot_type LLUrlLabelCallback; /// @@ -77,7 +80,7 @@ public: virtual std::string getLabel(const std::string &url, const LLUrlLabelCallback &cb) { return url; } /// Return an icon that can be displayed next to Urls of this type - virtual std::string getIcon(const std::string &url) { return mIcon; } + virtual std::string getIcon(const std::string &url) const; /// Return the color to render the displayed text LLUIColor getColor() const { return mColor; } @@ -101,7 +104,7 @@ protected: std::string getLabelFromWikiLink(const std::string &url) const; std::string getUrlFromWikiLink(const std::string &string) const; void addObserver(const std::string &id, const std::string &url, const LLUrlLabelCallback &cb); - void callObservers(const std::string &id, const std::string &label); + virtual void callObservers(const std::string &id, const std::string &label, const std::string& icon); typedef struct { std::string url; @@ -163,16 +166,17 @@ public: /// /// LLUrlEntryAgent Describes a Second Life agent Url, e.g., /// secondlife:///app/agent/0e346d8b-4433-4d66-a6b0-fd37083abc4c/about -/// class LLUrlEntryAgent : public LLUrlEntryBase { public: LLUrlEntryAgent(); /*virtual*/ std::string getLabel(const std::string &url, const LLUrlLabelCallback &cb); + /*virtual*/ std::string getIcon(const std::string &url) const; /*virtual*/ std::string getTooltip(const std::string &string) const; +protected: + /*virtual*/ void callObservers(const std::string &id, const std::string &label, const std::string& icon); private: - void onAgentNameReceived(const LLUUID& id, const std::string& first, - const std::string& last, BOOL is_group); + void onAvatarNameCache(const LLUUID& id, const LLAvatarName& av_name); }; /// @@ -185,8 +189,7 @@ public: LLUrlEntryGroup(); /*virtual*/ std::string getLabel(const std::string &url, const LLUrlLabelCallback &cb); private: - void onGroupNameReceived(const LLUUID& id, const std::string& first, - const std::string& last, BOOL is_group); + void onGroupNameReceived(const LLUUID& id, const std::string& name, bool is_group); }; /// @@ -305,7 +308,7 @@ public: LLUrlEntryIcon(); /*virtual*/ std::string getUrl(const std::string &string) const; /*virtual*/ std::string getLabel(const std::string &url, const LLUrlLabelCallback &cb); - /*virtual*/ std::string getIcon(const std::string &url); + /*virtual*/ std::string getIcon(const std::string &url) const; }; diff --git a/indra/llui/llurlregistry.cpp b/indra/llui/llurlregistry.cpp index 4341286eb4..7a866f44c2 100644 --- a/indra/llui/llurlregistry.cpp +++ b/indra/llui/llurlregistry.cpp @@ -37,12 +37,14 @@ #include <boost/regex.hpp> // default dummy callback that ignores any label updates from the server -void LLUrlRegistryNullCallback(const std::string &url, const std::string &label) +void LLUrlRegistryNullCallback(const std::string &url, const std::string &label, const std::string& icon) { } LLUrlRegistry::LLUrlRegistry() { + mUrlEntry.reserve(16); + // Urls are matched in the order that they were registered registerUrl(new LLUrlEntryNoLink()); registerUrl(new LLUrlEntryIcon()); @@ -77,10 +79,13 @@ LLUrlRegistry::~LLUrlRegistry() } } -void LLUrlRegistry::registerUrl(LLUrlEntryBase *url) +void LLUrlRegistry::registerUrl(LLUrlEntryBase *url, bool force_front) { if (url) { + if (force_front) // IDEVO + mUrlEntry.insert(mUrlEntry.begin(), url); + else mUrlEntry.push_back(url); } } diff --git a/indra/llui/llurlregistry.h b/indra/llui/llurlregistry.h index 399ee0a988..dffbd9d4bf 100644 --- a/indra/llui/llurlregistry.h +++ b/indra/llui/llurlregistry.h @@ -43,7 +43,9 @@ #include <vector> /// This default callback for findUrl() simply ignores any label updates -void LLUrlRegistryNullCallback(const std::string &url, const std::string &label); +void LLUrlRegistryNullCallback(const std::string &url, + const std::string &label, + const std::string &icon); /// /// LLUrlRegistry is a singleton that contains a set of Url types that @@ -70,7 +72,9 @@ public: ~LLUrlRegistry(); /// add a new Url handler to the registry (will be freed on destruction) - void registerUrl(LLUrlEntryBase *url); + /// optionally force it to the front of the list, making it take + /// priority over other regular expression matches for URLs + void registerUrl(LLUrlEntryBase *url, bool force_front = false); /// get the next Url in an input string, starting at a given character offset /// your callback is invoked if the matched Url's label changes in the future diff --git a/indra/llui/tests/llurlentry_stub.cpp b/indra/llui/tests/llurlentry_stub.cpp index 26d1f2e067..e984f5cf81 100644 --- a/indra/llui/tests/llurlentry_stub.cpp +++ b/indra/llui/tests/llurlentry_stub.cpp @@ -22,11 +22,28 @@ #include "llstring.h" #include "llfile.h" +#include "llavatarnamecache.h" #include "llcachename.h" #include "lluuid.h" #include <string> +// Stub for LLAvatarNameCache +bool LLAvatarNameCache::get(const LLUUID& agent_id, LLAvatarName *av_name) +{ + return false; +} + +void LLAvatarNameCache::get(const LLUUID& agent_id, callback_slot_t slot) +{ + return; +} + +bool LLAvatarNameCache::useDisplayNames() +{ + return false; +} + // // Stub implementation for LLCacheName // @@ -42,7 +59,7 @@ BOOL LLCacheName::getGroupName(const LLUUID& id, std::string& group) return TRUE; } -boost::signals2::connection LLCacheName::get(const LLUUID& id, BOOL is_group, const LLCacheNameCallback& callback) +boost::signals2::connection LLCacheName::get(const LLUUID& id, bool is_group, const LLCacheNameCallback& callback) { return boost::signals2::connection(); } diff --git a/indra/llui/tests/llurlentry_test.cpp b/indra/llui/tests/llurlentry_test.cpp index cbb303a059..bcb1e65092 100644 --- a/indra/llui/tests/llurlentry_test.cpp +++ b/indra/llui/tests/llurlentry_test.cpp @@ -285,7 +285,6 @@ namespace tut testRegex("Agent Url alternate command", url, "XXX secondlife:///App/AGENT/0E346D8B-4433-4d66-a6b0-fd37083abc4c/foobar", "secondlife:///App/AGENT/0E346D8B-4433-4d66-a6b0-fd37083abc4c/foobar"); - } template<> template<> diff --git a/indra/newview/CMakeLists.txt b/indra/newview/CMakeLists.txt index 2459165398..1c9b72968a 100644 --- a/indra/newview/CMakeLists.txt +++ b/indra/newview/CMakeLists.txt @@ -236,6 +236,7 @@ set(viewer_SOURCE_FILES llhudeffecttrail.cpp llhudicon.cpp llhudmanager.cpp + llhudnametag.cpp llhudobject.cpp llhudrender.cpp llhudtext.cpp @@ -465,6 +466,7 @@ set(viewer_SOURCE_FILES llviewercontrol.cpp llviewercontrollistener.cpp llviewerdisplay.cpp + llviewerdisplayname.cpp llviewerfloaterreg.cpp llviewerfoldertype.cpp llviewergenericmessage.cpp @@ -749,6 +751,7 @@ set(viewer_HEADER_FILES llhudeffecttrail.h llhudicon.h llhudmanager.h + llhudnametag.h llhudobject.h llhudrender.h llhudtext.h @@ -977,6 +980,7 @@ set(viewer_HEADER_FILES llviewercontrol.h llviewercontrollistener.h llviewerdisplay.h + llviewerdisplayname.h llviewerfloaterreg.h llviewerfoldertype.h llviewergenericmessage.h diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml index 35b5d0c0f5..aeba46a92d 100644 --- a/indra/newview/app_settings/settings.xml +++ b/indra/newview/app_settings/settings.xml @@ -7259,7 +7259,7 @@ <key>Value</key> <integer>0</integer> </map> - <key>RenderShowGroupTitleAll</key> + <key>NameTagShowGroupTitles</key> <map> <key>Comment</key> <string>Show group titles in name labels</string> @@ -7268,6 +7268,28 @@ <key>Type</key> <string>Boolean</string> <key>Value</key> + <integer>0</integer> + </map> + <key>NameTagShowDisplayNames</key> + <map> + <key>Comment</key> + <string>Show display names in name labels</string> + <key>Persist</key> + <integer>1</integer> + <key>Type</key> + <string>Boolean</string> + <key>Value</key> + <integer>1</integer> + </map> + <key>NameTagShowSLIDs</key> + <map> + <key>Comment</key> + <string>Show Second Life IDs in name labels</string> + <key>Persist</key> + <integer>1</integer> + <key>Type</key> + <string>Boolean</string> + <key>Value</key> <integer>1</integer> </map> <key>RenderInitError</key> diff --git a/indra/newview/llagentui.cpp b/indra/newview/llagentui.cpp index c4597ad6f8..cd9dab4e7d 100644 --- a/indra/newview/llagentui.cpp +++ b/indra/newview/llagentui.cpp @@ -46,29 +46,6 @@ #include "llslurl.h" //static -void LLAgentUI::buildName(std::string& name) -{ - name.clear(); - if (isAgentAvatarValid()) - { - LLNameValue *first_nv = gAgentAvatarp->getNVPair("FirstName"); - LLNameValue *last_nv = gAgentAvatarp->getNVPair("LastName"); - if (first_nv && last_nv) - { - name = first_nv->printData() + " " + last_nv->printData(); - } - else - { - llwarns << "Agent is missing FirstName and/or LastName nv pair." << llendl; - } - } - else - { - name = gSavedSettings.getString("FirstName") + " " + gSavedSettings.getString("LastName"); - } -} - -//static void LLAgentUI::buildFullname(std::string& name) { if (isAgentAvatarValid()) diff --git a/indra/newview/llagentui.h b/indra/newview/llagentui.h index 3478793e38..c682d3c951 100644 --- a/indra/newview/llagentui.h +++ b/indra/newview/llagentui.h @@ -45,7 +45,6 @@ public: LOCATION_FORMAT_FULL, // Parcel, Region (x, y, z) - Maturity }; - static void buildName(std::string& name); static void buildFullname(std::string &name); static std::string buildSLURL(const bool escaped = true); diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp index 8db0388c64..3d63bc6b78 100644 --- a/indra/newview/llappviewer.cpp +++ b/indra/newview/llappviewer.cpp @@ -87,6 +87,7 @@ #include "llsecondlifeurls.h" // Linden library includes +#include "llavatarnamecache.h" #include "llimagej2c.h" #include "llmemory.h" #include "llprimitive.h" @@ -159,7 +160,6 @@ // Included so that constants/settings might be initialized // in save_settings_to_globals() #include "llbutton.h" -#include "llcombobox.h" #include "llstatusbar.h" #include "llsurface.h" #include "llvosky.h" @@ -401,9 +401,6 @@ static void settings_to_globals() MENU_BAR_HEIGHT = gSavedSettings.getS32("MenuBarHeight"); MENU_BAR_WIDTH = gSavedSettings.getS32("MenuBarWidth"); - LLCOMBOBOX_HEIGHT = BTN_HEIGHT - 2; - LLCOMBOBOX_WIDTH = 128; - LLSurface::setTextureSize(gSavedSettings.getU32("RegionTextureSize")); LLImageGL::sGlobalUseAnisotropic = gSavedSettings.getBOOL("RenderAnisotropic"); @@ -1312,8 +1309,7 @@ bool LLAppViewer::cleanup() LLPolyMesh::freeAllMeshes(); - delete gCacheName; - gCacheName = NULL; + LLStartUp::cleanupNameCache(); // Note: this is where gLocalSpeakerMgr and gActiveSpeakerMgr used to be deleted. @@ -3382,6 +3378,15 @@ void LLAppViewer::saveFinalSnapshot() void LLAppViewer::loadNameCache() { + // display names cache + std::string filename = + gDirUtilp->getExpandedFilename(LL_PATH_CACHE, "avatar_name_cache.xml"); + llifstream name_cache_stream(filename); + if(name_cache_stream.is_open()) + { + LLAvatarNameCache::importFile(name_cache_stream); + } + if (!gCacheName) return; std::string name_cache; @@ -3391,19 +3396,19 @@ void LLAppViewer::loadNameCache() { if(gCacheName->importFile(cache_file)) return; } - - // Try to load from the legacy format. This should go away after a - // while. Phoenix 2008-01-30 - LLFILE* name_cache_fp = LLFile::fopen(name_cache, "r"); // Flawfinder: ignore - if (name_cache_fp) - { - gCacheName->importFile(name_cache_fp); - fclose(name_cache_fp); - } } void LLAppViewer::saveNameCache() { + // display names cache + std::string filename = + gDirUtilp->getExpandedFilename(LL_PATH_CACHE, "avatar_name_cache.xml"); + llofstream name_cache_stream(filename); + if(name_cache_stream.is_open()) + { + LLAvatarNameCache::exportFile(name_cache_stream); + } + if (!gCacheName) return; std::string name_cache; @@ -3599,9 +3604,10 @@ void LLAppViewer::idle() // NOTE: Starting at this point, we may still have pointers to "dead" objects // floating throughout the various object lists. // + idleNameCache(); idleNetwork(); - + // Check for away from keyboard, kick idle agents. idle_afk_check(); @@ -3936,6 +3942,60 @@ void LLAppViewer::sendLogoutRequest() } } +void LLAppViewer::idleNameCache() +{ + // Neither old nor new name cache can function before agent has a region + LLViewerRegion* region = gAgent.getRegion(); + if (!region) return; + + // deal with any queued name requests and replies. + gCacheName->processPending(); + + // Can't run the new cache until we have the list of capabilities + // for the agent region, and can therefore decide whether to use + // display names or fall back to the old name system. + if (!region->capabilitiesReceived()) return; + + // Agent may have moved to a different region, so need to update cap URL + // for name lookups. Can't do this in the cap grant code, as caps are + // granted to neighbor regions before the main agent gets there. Can't + // do it in the move-into-region code because cap not guaranteed to be + // granted yet, for example on teleport. + bool had_capability = LLAvatarNameCache::hasNameLookupURL(); + std::string name_lookup_url; + name_lookup_url.reserve(128); // avoid a memory allocation below + name_lookup_url = region->getCapability("GetDisplayNames"); + bool have_capability = !name_lookup_url.empty(); + if (have_capability) + { + // we have support for display names, use it + U32 url_size = name_lookup_url.size(); + // capabilities require URLs with slashes before query params: + // https://<host>:<port>/cap/<uuid>/?ids=<blah> + // but the caps are granted like: + // https://<host>:<port>/cap/<uuid> + if (url_size > 0 && name_lookup_url[url_size-1] != '/') + { + name_lookup_url += '/'; + } + LLAvatarNameCache::setNameLookupURL(name_lookup_url); + } + else + { + // Display names not available on this region + LLAvatarNameCache::setNameLookupURL( std::string() ); + } + + // Error recovery - did we change state? + if (had_capability != have_capability) + { + // name tags are persistant on screen, so make sure they refresh + LLVOAvatar::invalidateNameTags(); + } + + LLAvatarNameCache::idle(); +} + // // Handle messages, and all message related stuff // @@ -3961,8 +4021,6 @@ void LLAppViewer::idleNetwork() { LLFastTimer t(FTM_IDLE_NETWORK); // decode - // deal with any queued name requests and replies. - gCacheName->processPending(); LLTimer check_message_timer; // Read all available packets from network const S64 frame_count = gFrameCount; // U32->S64 diff --git a/indra/newview/llappviewer.h b/indra/newview/llappviewer.h index 60645c46d4..d43c140da2 100644 --- a/indra/newview/llappviewer.h +++ b/indra/newview/llappviewer.h @@ -212,6 +212,8 @@ private: void idle(); void idleShutdown(); + // update avatar SLID and display name caches + void idleNameCache(); void idleNetwork(); void sendLogoutRequest(); diff --git a/indra/newview/llavataractions.cpp b/indra/newview/llavataractions.cpp index 764d54a987..85a087d6f6 100644 --- a/indra/newview/llavataractions.cpp +++ b/indra/newview/llavataractions.cpp @@ -37,11 +37,11 @@ #include "boost/lambda/lambda.hpp" // for lambda::constant +#include "llavatarnamecache.h" // IDEVO #include "llsd.h" #include "lldarray.h" #include "llnotifications.h" #include "llnotificationsutil.h" - #include "roles_constants.h" // for GP_MEMBER_INVITE #include "llagent.h" @@ -67,6 +67,7 @@ #include "llimfloater.h" #include "lltrans.h" #include "llcallingcard.h" +#include "llslurl.h" // IDEVO // static void LLAvatarActions::requestFriendshipDialog(const LLUUID& id, const std::string& name) @@ -78,7 +79,7 @@ void LLAvatarActions::requestFriendshipDialog(const LLUUID& id, const std::strin } LLSD args; - args["NAME"] = name; + args["NAME"] = LLSLURL::buildCommand("agent", id, "inspect"); LLSD payload; payload["id"] = id; payload["name"] = name; @@ -133,11 +134,10 @@ void LLAvatarActions::removeFriendsDialog(const uuid_vec_t& ids) if(ids.size() == 1) { LLUUID agent_id = ids[0]; - std::string first, last; - if(gCacheName->getName(agent_id, first, last)) + std::string full_name; + if(gCacheName->getFullName(agent_id, full_name)) { - args["FIRST_NAME"] = first; - args["LAST_NAME"] = last; + args["NAME"] = full_name; } msgType = "RemoveFromFriends"; @@ -200,6 +200,14 @@ void LLAvatarActions::startIM(const LLUUID& id) return; } + // IDEVO + LLAvatarName av_name; + if (LLAvatarNameCache::useDisplayNames() + && LLAvatarNameCache::get(id, &av_name)) + { + name = av_name.mDisplayName + " (" + av_name.mSLID + ")"; + } + LLUUID session_id = gIMMgr->addSession(name, IM_NOTHING_SPECIAL, id); if (session_id != LLUUID::null) { @@ -231,6 +239,13 @@ void LLAvatarActions::startCall(const LLUUID& id) std::string name; gCacheName->getFullName(id, name); + // IDEVO + LLAvatarName av_name; + if (LLAvatarNameCache::useDisplayNames() + && LLAvatarNameCache::get(id, &av_name)) + { + name = av_name.mDisplayName + " (" + av_name.mSLID + ")"; + } LLUUID session_id = gIMMgr->addSession(name, IM_NOTHING_SPECIAL, id, true); if (session_id != LLUUID::null) { @@ -672,9 +687,9 @@ bool LLAvatarActions::isBlocked(const LLUUID& id) // static bool LLAvatarActions::canBlock(const LLUUID& id) { - std::string firstname, lastname; - gCacheName->getName(id, firstname, lastname); - bool is_linden = !LLStringUtil::compareStrings(lastname, "Linden"); + std::string full_name; + gCacheName->getFullName(id, full_name); + bool is_linden = (full_name.find("Linden") != std::string::npos); bool is_self = id == gAgentID; return !is_self && !is_linden; } diff --git a/indra/newview/llavatariconctrl.cpp b/indra/newview/llavatariconctrl.cpp index 87b8d807c4..11cc456695 100644 --- a/indra/newview/llavatariconctrl.cpp +++ b/indra/newview/llavatariconctrl.cpp @@ -244,7 +244,8 @@ void LLAvatarIconCtrl::setValue(const LLSD& value) LLIconCtrl::setValue(value); } - gCacheName->get(mAvatarId, FALSE, boost::bind(&LLAvatarIconCtrl::nameUpdatedCallback, this, _1, _2, _3, _4)); + gCacheName->get(mAvatarId, false, + boost::bind(&LLAvatarIconCtrl::nameUpdatedCallback, this, _1, _2, _3)); } bool LLAvatarIconCtrl::updateFromCache() @@ -289,22 +290,20 @@ void LLAvatarIconCtrl::processProperties(void* data, EAvatarProcessorType type) void LLAvatarIconCtrl::nameUpdatedCallback( const LLUUID& id, - const std::string& first, - const std::string& last, - BOOL is_group) + const std::string& name, + bool is_group) { if (id == mAvatarId) { - mFirstName = first; - mLastName = last; + mFullName = name; if (mDrawTooltip) { - setToolTip(mFirstName + " " + mLastName); + setToolTip(name); } else { - setToolTip(std::string("")); + setToolTip(std::string()); } } } diff --git a/indra/newview/llavatariconctrl.h b/indra/newview/llavatariconctrl.h index 38616b7852..a5452ee1d3 100644 --- a/indra/newview/llavatariconctrl.h +++ b/indra/newview/llavatariconctrl.h @@ -92,20 +92,17 @@ public: void nameUpdatedCallback( const LLUUID& id, - const std::string& first, - const std::string& last, - BOOL is_group); + const std::string& name, + bool is_group); const LLUUID& getAvatarId() const { return mAvatarId; } - const std::string& getFirstName() const { return mFirstName; } - const std::string& getLastName() const { return mLastName; } + const std::string& getFullName() const { return mFullName; } void setDrawTooltip(bool value) { mDrawTooltip = value;} protected: LLUUID mAvatarId; - std::string mFirstName; - std::string mLastName; + std::string mFullName; bool mDrawTooltip; std::string mDefaultIconName; diff --git a/indra/newview/llavatarlistitem.cpp b/indra/newview/llavatarlistitem.cpp index 2a51eeacfc..fc5453c2dd 100644 --- a/indra/newview/llavatarlistitem.cpp +++ b/indra/newview/llavatarlistitem.cpp @@ -229,7 +229,7 @@ void LLAvatarListItem::setAvatarId(const LLUUID& id, const LLUUID& session_id, b mAvatarIcon->setValue(id); // Set avatar name. - gCacheName->get(id, FALSE, boost::bind(&LLAvatarListItem::onNameCache, this, _2, _3)); + gCacheName->get(id, FALSE, boost::bind(&LLAvatarListItem::onNameCache, this, _2)); } } @@ -335,10 +335,9 @@ void LLAvatarListItem::setNameInternal(const std::string& name, const std::strin mAvatarName->setToolTip(name); } -void LLAvatarListItem::onNameCache(const std::string& first_name, const std::string& last_name) +void LLAvatarListItem::onNameCache(const std::string& fullname) { - std::string name = first_name + " " + last_name; - setName(name); + setName(fullname); //requesting the list to resort notifyParent(LLSD().with("sort", LLSD())); diff --git a/indra/newview/llavatarlistitem.h b/indra/newview/llavatarlistitem.h index 3ba2c7a3e3..1e3b67b094 100644 --- a/indra/newview/llavatarlistitem.h +++ b/indra/newview/llavatarlistitem.h @@ -151,7 +151,7 @@ private: } EAvatarListItemChildIndex; void setNameInternal(const std::string& name, const std::string& highlight); - void onNameCache(const std::string& first_name, const std::string& last_name); + void onNameCache(const std::string& fullname); std::string formatSeconds(U32 secs); diff --git a/indra/newview/llcallingcard.cpp b/indra/newview/llcallingcard.cpp index 79a2631c31..b4c4ddcbf4 100644 --- a/indra/newview/llcallingcard.cpp +++ b/indra/newview/llcallingcard.cpp @@ -250,7 +250,7 @@ S32 LLAvatarTracker::addBuddyList(const LLAvatarTracker::buddy_map_t& buds) using namespace std; U32 new_buddy_count = 0; - std::string first,last; + std::string full_name; LLUUID agent_id; for(buddy_map_t::const_iterator itr = buds.begin(); itr != buds.end(); ++itr) { @@ -260,7 +260,8 @@ S32 LLAvatarTracker::addBuddyList(const LLAvatarTracker::buddy_map_t& buds) { ++new_buddy_count; mBuddyInfo[agent_id] = (*itr).second; - gCacheName->getName(agent_id, first, last); + // IDEVO JAMESDEBUG is this necessary? name is unused? + gCacheName->getFullName(agent_id, full_name); addChangedMask(LLFriendObserver::ADD, agent_id); lldebugs << "Added buddy " << agent_id << ", " << (mBuddyInfo[agent_id]->isOnline() ? "Online" : "Offline") @@ -693,12 +694,11 @@ void LLAvatarTracker::processNotify(LLMessageSystem* msg, bool online) setBuddyOnline(agent_id,online); if(chat_notify) { - std::string first, last; - if(gCacheName->getName(agent_id, first, last)) + std::string full_name; + if(gCacheName->getFullName(agent_id, full_name)) { notify = TRUE; - args["FIRST"] = first; - args["LAST"] = last; + args["NAME"] = full_name; } } } @@ -867,10 +867,8 @@ bool LLCollectProxyBuddies::operator()(const LLUUID& buddy_id, LLRelationship* b bool LLCollectMappableBuddies::operator()(const LLUUID& buddy_id, LLRelationship* buddy) { - gCacheName->getName(buddy_id, mFirst, mLast); - std::ostringstream fullname; - fullname << mFirst << " " << mLast; - buddy_map_t::value_type value(fullname.str(), buddy_id); + gCacheName->getFullName(buddy_id, mFullName); + buddy_map_t::value_type value(mFullName, buddy_id); if(buddy->isOnline() && buddy->isRightGrantedFrom(LLRelationship::GRANT_MAP_LOCATION)) { mMappable.insert(value); @@ -880,10 +878,8 @@ bool LLCollectMappableBuddies::operator()(const LLUUID& buddy_id, LLRelationship bool LLCollectOnlineBuddies::operator()(const LLUUID& buddy_id, LLRelationship* buddy) { - gCacheName->getName(buddy_id, mFirst, mLast); - std::ostringstream fullname; - fullname << mFirst << " " << mLast; - buddy_map_t::value_type value(fullname.str(), buddy_id); + gCacheName->getFullName(buddy_id, mFullName); + buddy_map_t::value_type value(mFullName, buddy_id); if(buddy->isOnline()) { mOnline.insert(value); @@ -893,10 +889,8 @@ bool LLCollectOnlineBuddies::operator()(const LLUUID& buddy_id, LLRelationship* bool LLCollectAllBuddies::operator()(const LLUUID& buddy_id, LLRelationship* buddy) { - gCacheName->getName(buddy_id, mFirst, mLast); - std::ostringstream fullname; - fullname << mFirst << " " << mLast; - buddy_map_t::value_type value(fullname.str(), buddy_id); + gCacheName->getFullName(buddy_id, mFullName); + buddy_map_t::value_type value(mFullName, buddy_id); if(buddy->isOnline()) { mOnline.insert(value); @@ -907,5 +901,3 @@ bool LLCollectAllBuddies::operator()(const LLUUID& buddy_id, LLRelationship* bud } return true; } - - diff --git a/indra/newview/llcallingcard.h b/indra/newview/llcallingcard.h index 47b0dcb903..5bd1f05687 100644 --- a/indra/newview/llcallingcard.h +++ b/indra/newview/llcallingcard.h @@ -241,8 +241,7 @@ public: virtual bool operator()(const LLUUID& buddy_id, LLRelationship* buddy); typedef std::map<std::string, LLUUID, LLDictionaryLess> buddy_map_t; buddy_map_t mMappable; - std::string mFirst; - std::string mLast; + std::string mFullName; }; // collect dictionary sorted map of name -> agent_id for every online buddy @@ -254,8 +253,7 @@ public: virtual bool operator()(const LLUUID& buddy_id, LLRelationship* buddy); typedef std::map<std::string, LLUUID, LLDictionaryLess> buddy_map_t; buddy_map_t mOnline; - std::string mFirst; - std::string mLast; + std::string mFullName; }; // collect dictionary sorted map of name -> agent_id for every buddy, @@ -269,8 +267,7 @@ public: typedef std::map<std::string, LLUUID, LLDictionaryLess> buddy_map_t; buddy_map_t mOnline; buddy_map_t mOffline; - std::string mFirst; - std::string mLast; + std::string mFullName; }; #endif // LL_LLCALLINGCARD_H diff --git a/indra/newview/llchathistory.cpp b/indra/newview/llchathistory.cpp index 68c31d87fa..0fc5e92324 100644 --- a/indra/newview/llchathistory.cpp +++ b/indra/newview/llchathistory.cpp @@ -32,10 +32,12 @@ #include "llviewerprecompiledheaders.h" +#include "llchathistory.h" + +#include "llavatarnamecache.h" #include "llinstantmessage.h" #include "llimview.h" -#include "llchathistory.h" #include "llcommandhandler.h" #include "llpanel.h" #include "lluictrlfactory.h" @@ -240,7 +242,12 @@ public: mAvatarID = chat.mFromID; mSessionID = chat.mSessionID; mSourceType = chat.mSourceType; - gCacheName->get(mAvatarID, FALSE, boost::bind(&LLChatHistoryHeader::nameUpdatedCallback, this, _1, _2, _3, _4)); + //gCacheName->get(mAvatarID, false, boost::bind(&LLChatHistoryHeader::nameUpdatedCallback, this, _1, _2, _3)); + if (mAvatarID.notNull()) + { + LLAvatarNameCache::get(mAvatarID, + boost::bind(&LLChatHistoryHeader::onAvatarNameCache, this, _1, _2)); + } //*TODO overly defensive thing, source type should be maintained out there if((chat.mFromID.isNull() && chat.mFromName.empty()) || chat.mFromName == SYSTEM_FROM) @@ -317,12 +324,23 @@ public: LLPanel::draw(); } - void nameUpdatedCallback(const LLUUID& id,const std::string& first,const std::string& last,BOOL is_group) + void nameUpdatedCallback(const LLUUID& id,const std::string& full_name, bool is_group) { if (id != mAvatarID) return; - mFrom = first + " " + last; + mFrom = full_name; } + + void onAvatarNameCache(const LLUUID& agent_id, const LLAvatarName& av_name) + { + if (agent_id != mAvatarID) return; + + // HACK: just update tooltip + setToolTip( av_name.mSLID ); + LLTextBox* user_name = getChild<LLTextBox>("user_name"); + user_name->setToolTip( av_name.mSLID ); + } + protected: static const S32 PADDING = 20; diff --git a/indra/newview/lldateutil.cpp b/indra/newview/lldateutil.cpp index 3e71ecdfba..32b8b9662a 100644 --- a/indra/newview/lldateutil.cpp +++ b/indra/newview/lldateutil.cpp @@ -59,22 +59,18 @@ static S32 days_from_month(S32 year, S32 month) } } -bool LLDateUtil::dateFromPDTString(LLDate& date, const std::string& str) +std::string LLDateUtil::ageFromDate(S32 born_year, + S32 born_month, + S32 born_day, + const LLDate& now) { - S32 month, day, year; - S32 matched = sscanf(str.c_str(), "%d/%d/%d", &month, &day, &year); - if (matched != 3) return false; - date.fromYMDHMS(year, month, day); - F64 secs_since_epoch = date.secondsSinceEpoch(); - // Correct for the fact that specified date is in Pacific time, == UTC - 8 - secs_since_epoch += 8.0 * 60.0 * 60.0; - date.secondsSinceEpoch(secs_since_epoch); - return true; -} - -std::string LLDateUtil::ageFromDate(const LLDate& born_date, const LLDate& now) -{ - S32 born_month, born_day, born_year; + LLDate born_date; + born_date.fromYMDHMS(born_year, born_month, born_day); + F64 born_date_secs_since_epoch = born_date.secondsSinceEpoch(); + // Correct for the fact that account creation dates are in Pacific time, + // == UTC - 8 + born_date_secs_since_epoch += 8.0 * 60.0 * 60.0; + born_date.secondsSinceEpoch(born_date_secs_since_epoch); // explode out to month/day/year again born_date.split(&born_year, &born_month, &born_day); @@ -158,17 +154,31 @@ std::string LLDateUtil::ageFromDate(const LLDate& born_date, const LLDate& now) return LLTrans::getString("TodayOld"); } -std::string LLDateUtil::ageFromDate(const std::string& date_string, const LLDate& now) +std::string LLDateUtil::ageFromDate(const std::string& date_string, + const LLDate& now) { - LLDate born_date; - - if (!dateFromPDTString(born_date, date_string)) - return "???"; - - return ageFromDate(born_date, now); + S32 born_month, born_day, born_year; + S32 matched = sscanf(date_string.c_str(), "%d/%d/%d", &born_month, &born_day, &born_year); + if (matched != 3) return "???"; + return ageFromDate(born_year, born_month, born_day, now); } std::string LLDateUtil::ageFromDate(const std::string& date_string) { return ageFromDate(date_string, LLDate::now()); } + +std::string LLDateUtil::ageFromDateISO(const std::string& date_string, + const LLDate& now) +{ + S32 born_month, born_day, born_year; + S32 matched = sscanf(date_string.c_str(), "%d-%d-%d", + &born_year, &born_month, &born_day); + if (matched != 3) return "???"; + return ageFromDate(born_year, born_month, born_day, now); +} + +std::string LLDateUtil::ageFromDateISO(const std::string& date_string) +{ + return ageFromDateISO(date_string, LLDate::now()); +} diff --git a/indra/newview/lldateutil.h b/indra/newview/lldateutil.h index a0df21022e..a2bfa11ce7 100644 --- a/indra/newview/lldateutil.h +++ b/indra/newview/lldateutil.h @@ -67,6 +67,14 @@ namespace LLDateUtil // Calls the above with LLDate::now() std::string ageFromDate(const std::string& date_string); + + // As above, for YYYY-MM-DD dates + std::string ageFromDateISO(const std::string& date_string, const LLDate& now); + + // Calls the above with LLDate::now() + std::string ageFromDateISO(const std::string& date_string); + + std::string ageFromDate(S32 born_year, S32 born_month, S32 born_day, const LLDate& now); } #endif diff --git a/indra/newview/lldrawable.h b/indra/newview/lldrawable.h index 651dabff9e..b8b09b89f1 100644 --- a/indra/newview/lldrawable.h +++ b/indra/newview/lldrawable.h @@ -53,6 +53,7 @@ class LLCamera; class LLDrawPool; class LLDrawable; class LLFace; +class LLFacePool; class LLSpatialGroup; class LLSpatialBridge; class LLSpatialPartition; diff --git a/indra/newview/llfloateravatarpicker.cpp b/indra/newview/llfloateravatarpicker.cpp index d1e99fbd61..bca9282cec 100644 --- a/indra/newview/llfloateravatarpicker.cpp +++ b/indra/newview/llfloateravatarpicker.cpp @@ -36,15 +36,21 @@ // Viewer includes #include "llagent.h" #include "llcallingcard.h" +#include "lldate.h" // split() +#include "lldateutil.h" // ageFromDate() #include "llfocusmgr.h" #include "llfloaterreg.h" #include "llimview.h" // for gIMMgr #include "lltooldraganddrop.h" // for LLToolDragAndDrop #include "llviewercontrol.h" +#include "llviewerregion.h" // getCapability() #include "llworld.h" // Linden libraries +#include "llavatarnamecache.h" // IDEVO #include "llbutton.h" +#include "llcachename.h" +#include "llhttpclient.h" // IDEVO #include "lllineeditor.h" #include "llscrolllistctrl.h" #include "llscrolllistitem.h" @@ -53,6 +59,8 @@ #include "lluictrlfactory.h" #include "message.h" +//#include "llsdserialize.h" + LLFloaterAvatarPicker* LLFloaterAvatarPicker::show(select_callback_t callback, BOOL allow_multiple, BOOL closeOnSelect) @@ -340,23 +348,75 @@ BOOL LLFloaterAvatarPicker::visibleItemsSelected() const return FALSE; } +class LLAvatarPickerResponder : public LLHTTPClient::Responder +{ +public: + LLUUID mQueryID; + + LLAvatarPickerResponder(const LLUUID& id) : mQueryID(id) { } + + /*virtual*/ void completed(U32 status, const std::string& reason, const LLSD& content) + { + //std::ostringstream ss; + //LLSDSerialize::toPrettyXML(content, ss); + //llinfos << ss.str() << llendl; + + if (isGoodStatus(status)) + { + LLFloaterAvatarPicker* floater = + LLFloaterReg::findTypedInstance<LLFloaterAvatarPicker>("avatar_picker"); + if (floater) + { + floater->processResponse(mQueryID, content); + } + } + else + { + llinfos << "avatar picker failed " << status + << " reason " << reason << llendl; + } + } +}; + void LLFloaterAvatarPicker::find() { std::string text = childGetValue("Edit").asString(); mQueryID.generate(); - LLMessageSystem* msg = gMessageSystem; + std::string url; + url.reserve(128); // avoid a memory allocation or two - msg->newMessage("AvatarPickerRequest"); - msg->nextBlock("AgentData"); - msg->addUUID("AgentID", gAgent.getID()); - msg->addUUID("SessionID", gAgent.getSessionID()); - msg->addUUID("QueryID", mQueryID); // not used right now - msg->nextBlock("Data"); - msg->addString("Name", text); - - gAgent.sendReliableMessage(); + LLViewerRegion* region = gAgent.getRegion(); + url = region->getCapability("AvatarPickerSearch"); + // Prefer use of capabilities to search on both SLID and display name + // but allow display name search to be manually turned off for test + if (!url.empty() + && LLAvatarNameCache::useDisplayNames()) + { + // capability urls don't end in '/', but we need one to parse + // query parameters correctly + if (url.size() > 0 && url[url.size()-1] != '/') + { + url += "/"; + } + url += "?names="; + url += LLURI::escape(text); + llinfos << "avatar picker " << url << llendl; + LLHTTPClient::get(url, new LLAvatarPickerResponder(mQueryID)); + } + else + { + LLMessageSystem* msg = gMessageSystem; + msg->newMessage("AvatarPickerRequest"); + msg->nextBlock("AgentData"); + msg->addUUID("AgentID", gAgent.getID()); + msg->addUUID("SessionID", gAgent.getSessionID()); + msg->addUUID("QueryID", mQueryID); // not used right now + msg->nextBlock("Data"); + msg->addString("Name", text); + gAgent.sendReliableMessage(); + } getChild<LLScrollListCtrl>("SearchResults")->deleteAllItems(); getChild<LLScrollListCtrl>("SearchResults")->setCommentText(getString("searching")); @@ -484,12 +544,13 @@ void LLFloaterAvatarPicker::processAvatarPickerReply(LLMessageSystem* msg, void* } else { - avatar_name = first_name + " " + last_name; + avatar_name = LLCacheName::buildFullName(first_name, last_name); search_results->setEnabled(TRUE); found_one = TRUE; } LLSD element; element["id"] = avatar_id; // value + element["columns"][0]["column"] = "name"; element["columns"][0]["value"] = avatar_name; search_results->addElement(element); } @@ -503,10 +564,63 @@ void LLFloaterAvatarPicker::processAvatarPickerReply(LLMessageSystem* msg, void* } } +void LLFloaterAvatarPicker::processResponse(const LLUUID& query_id, const LLSD& content) +{ + // Check for out-of-date query + if (query_id != mQueryID) return; + + LLScrollListCtrl* search_results = getChild<LLScrollListCtrl>("SearchResults"); + + LLSD agents = content["agents"]; + if (agents.size() == 0) + { + LLStringUtil::format_map_t map; + map["[TEXT]"] = childGetText("Edit"); + LLSD item; + item["id"] = LLUUID::null; + item["columns"][0]["column"] = "name"; + item["columns"][0]["value"] = getString("not_found", map); + search_results->addElement(item); + search_results->setEnabled(FALSE); + childDisable("ok_btn"); + return; + } + + // clear "Searching" label on first results + search_results->deleteAllItems(); + + LLSD item; + LLSD::array_const_iterator it = agents.beginArray(); + for ( ; it != agents.endArray(); ++it) + { + const LLSD& row = *it; + item["id"] = row["agent_id"]; + LLSD& columns = item["columns"]; + columns[0]["column"] = "name"; + columns[0]["value"] = row["display_name"]; + columns[1]["column"] = "slid"; + columns[1]["value"] = row["sl_id"]; + LLDate account_created = row["account_created"].asDate(); + S32 year, month, day; + account_created.split(&year, &month, &day); + std::string age = + LLDateUtil::ageFromDate(year, month, day, LLDate::now()); + columns[2]["column"] = "age"; + columns[2]["value"] = age; + search_results->addElement(item); + } + + childEnable("ok_btn"); + search_results->setEnabled(true); + search_results->selectFirstItem(); + onList(); + search_results->setFocus(TRUE); +} + //static void LLFloaterAvatarPicker::editKeystroke(LLLineEditor* caller, void* user_data) { - childSetEnabled("Find", caller->getText().size() >= 3); + childSetEnabled("Find", caller->getText().size() > 0); } // virtual diff --git a/indra/newview/llfloateravatarpicker.h b/indra/newview/llfloateravatarpicker.h index e69b814f9f..e355b38457 100644 --- a/indra/newview/llfloateravatarpicker.h +++ b/indra/newview/llfloateravatarpicker.h @@ -60,6 +60,7 @@ public: void setOkBtnEnableCb(validate_callback_t cb); static void processAvatarPickerReply(class LLMessageSystem* msg, void**); + void processResponse(const LLUUID& query_id, const LLSD& content); BOOL handleDragAndDrop(S32 x, S32 y, MASK mask, BOOL drop, EDragAndDropType cargo_type, diff --git a/indra/newview/llfloaterbump.cpp b/indra/newview/llfloaterbump.cpp index e925796526..9ccae43a92 100644 --- a/indra/newview/llfloaterbump.cpp +++ b/indra/newview/llfloaterbump.cpp @@ -89,7 +89,7 @@ void LLFloaterBump::onOpen(const LLSD& key) void LLFloaterBump::add(LLScrollListCtrl* list, LLMeanCollisionData* mcd) { - if (mcd->mFirstName.empty() || list->getItemCount() >= 20) + if (mcd->mFullName.empty() || list->getItemCount() >= 20) { return; } @@ -127,8 +127,7 @@ void LLFloaterBump::add(LLScrollListCtrl* list, LLMeanCollisionData* mcd) // All above action strings are in XML file LLUIString text = getString(action); text.setArg("[TIME]", timeStr); - text.setArg("[FIRST]", mcd->mFirstName); - text.setArg("[LAST]", mcd->mLastName); + text.setArg("[NAME]", mcd->mFullName); LLSD row; row["id"] = mcd->mPerp; diff --git a/indra/newview/llfloaterbuyland.cpp b/indra/newview/llfloaterbuyland.cpp index 76a61db5fd..50c95aea68 100644 --- a/indra/newview/llfloaterbuyland.cpp +++ b/indra/newview/llfloaterbuyland.cpp @@ -186,9 +186,8 @@ public: void updateNames(); // Name cache callback void updateGroupName(const LLUUID& id, - const std::string& first_name, - const std::string& last_name, - BOOL is_group); + const std::string& name, + bool is_group); void refreshUI(); @@ -824,9 +823,9 @@ void LLFloaterBuyLandUI::updateNames() } else if (parcelp->getIsGroupOwned()) { - gCacheName->get(parcelp->getGroupID(), TRUE, + gCacheName->get(parcelp->getGroupID(), true, boost::bind(&LLFloaterBuyLandUI::updateGroupName, this, - _1, _2, _3, _4)); + _1, _2, _3)); } else { @@ -836,16 +835,15 @@ void LLFloaterBuyLandUI::updateNames() } void LLFloaterBuyLandUI::updateGroupName(const LLUUID& id, - const std::string& first_name, - const std::string& last_name, - BOOL is_group) + const std::string& name, + bool is_group) { LLParcel* parcelp = mParcel->getParcel(); if (parcelp && parcelp->getGroupID() == id) { // request is current - mParcelSellerName = first_name; + mParcelSellerName = name; } } diff --git a/indra/newview/llfloaterland.cpp b/indra/newview/llfloaterland.cpp index 2ff483cd34..928d5c3a31 100644 --- a/indra/newview/llfloaterland.cpp +++ b/indra/newview/llfloaterland.cpp @@ -823,19 +823,19 @@ void LLPanelLandGeneral::refreshNames() if (parcel->getForSale()) { - const LLUUID& auth_buyer_id = parcel->getAuthorizedBuyerID(); - if(auth_buyer_id.notNull()) - { - std::string name; - name = LLSLURL::buildCommand("agent", auth_buyer_id, "inspect"); - mSaleInfoForSale2->setTextArg("[BUYER]", name); - } - else - { - mSaleInfoForSale2->setTextArg("[BUYER]", getString("anyone")); - } + const LLUUID& auth_buyer_id = parcel->getAuthorizedBuyerID(); + if(auth_buyer_id.notNull()) + { + std::string name; + name = LLSLURL::buildCommand("agent", auth_buyer_id, "inspect"); + mSaleInfoForSale2->setTextArg("[BUYER]", name); + } + else + { + mSaleInfoForSale2->setTextArg("[BUYER]", getString("anyone")); } } +} // virtual @@ -1388,10 +1388,9 @@ bool LLPanelLandObjects::callbackReturnOwnerObjects(const LLSD& notification, co } else { - std::string first, last; - gCacheName->getName(owner_id, first, last); - args["FIRST"] = first; - args["LAST"] = last; + std::string full_name; + gCacheName->getFullName(owner_id, full_name); + args["NAME"] = full_name; LLNotificationsUtil::add("OtherObjectsReturned", args); } send_return_objects_message(parcel->getLocalID(), RT_OWNER); @@ -2507,7 +2506,7 @@ void LLPanelLandAccess::refresh() if (maturity_pos != std::string::npos) { maturity_string.replace(maturity_pos, MATURITY.length(), std::string("")); - } + } maturity_checkbox->setLabel(maturity_string); } diff --git a/indra/newview/llfloaterpay.cpp b/indra/newview/llfloaterpay.cpp index 51364594e4..7dbcc9555c 100644 --- a/indra/newview/llfloaterpay.cpp +++ b/indra/newview/llfloaterpay.cpp @@ -47,6 +47,7 @@ #include "lllineeditor.h" #include "llmutelist.h" #include "llfloaterreporter.h" +#include "llslurl.h" #include "llviewerobject.h" #include "llviewerobjectlist.h" #include "llviewerregion.h" @@ -102,10 +103,6 @@ private: static void onGive(void* data); void give(S32 amount); static void processPayPriceReply(LLMessageSystem* msg, void **userdata); - void onCacheOwnerName(const LLUUID& owner_id, - const std::string& firstname, - const std::string& lastname, - BOOL is_group); void finishPayUI(const LLUUID& target_id, BOOL is_group); protected: @@ -427,33 +424,28 @@ void LLFloaterPay::payDirectly(money_callback callback, void LLFloaterPay::finishPayUI(const LLUUID& target_id, BOOL is_group) { - gCacheName->get(target_id, is_group, boost::bind(&LLFloaterPay::onCacheOwnerName, this, _1, _2, _3, _4)); - - // Make sure the amount field has focus - - childSetFocus("amount", TRUE); - - LLLineEditor* amount = getChild<LLLineEditor>("amount"); - amount->selectAll(); - mTargetIsGroup = is_group; -} - -void LLFloaterPay::onCacheOwnerName(const LLUUID& owner_id, - const std::string& firstname, - const std::string& lastname, - BOOL is_group) -{ + // IDEVO + //gCacheName->get(target_id, is_group, boost::bind(&LLFloaterPay::onCacheOwnerName, this, _1, _2, _3, _4)); + std::string slurl; if (is_group) { setTitle(getString("payee_group")); + slurl = LLSLURL::buildCommand("group", target_id, "inspect"); } else { setTitle(getString("payee_resident")); + slurl = LLSLURL::buildCommand("agent", target_id, "inspect"); } + childSetText("payee_name", slurl); - childSetTextArg("payee_name", "[FIRST]", firstname); - childSetTextArg("payee_name", "[LAST]", lastname); + // Make sure the amount field has focus + + childSetFocus("amount", TRUE); + + LLLineEditor* amount = getChild<LLLineEditor>("amount"); + amount->selectAll(); + mTargetIsGroup = is_group; } // static diff --git a/indra/newview/llfloaterpreference.cpp b/indra/newview/llfloaterpreference.cpp index 2ab83eab79..45ff38421f 100644 --- a/indra/newview/llfloaterpreference.cpp +++ b/indra/newview/llfloaterpreference.cpp @@ -81,6 +81,7 @@ #include "llvosky.h" // linden library includes +#include "llavatarnamecache.h" #include "llerror.h" #include "llfontgl.h" #include "llrect.h" @@ -184,6 +185,7 @@ void LLVoiceSetKeyDialog::onCancel(void* user_data) // if creating/destroying these is too slow, we'll need to create // a static member and update all our static callbacks +void handleNameTagOptionChanged(const LLSD& newvalue); bool callback_clear_browser_cache(const LLSD& notification, const LLSD& response); //bool callback_skip_dialogs(const LLSD& notification, const LLSD& response, LLFloaterPreference* floater); @@ -219,6 +221,11 @@ bool callback_clear_browser_cache(const LLSD& notification, const LLSD& response return false; } +void handleNameTagOptionChanged(const LLSD& newvalue) +{ + LLVOAvatar::invalidateNameTags(); +} + /*bool callback_skip_dialogs(const LLSD& notification, const LLSD& response, LLFloaterPreference* floater) { S32 option = LLNotificationsUtil::getSelectedOption(notification, response); @@ -311,6 +318,8 @@ LLFloaterPreference::LLFloaterPreference(const LLSD& key) mCommitCallbackRegistrar.add("Pref.MaturitySettings", boost::bind(&LLFloaterPreference::onChangeMaturity, this)); sSkin = gSavedSettings.getString("SkinCurrent"); + + gSavedSettings.getControl("NameTagShowSLIDs")->getCommitSignal()->connect(boost::bind(&handleNameTagOptionChanged, _2)); } BOOL LLFloaterPreference::postBuild() @@ -447,6 +456,10 @@ void LLFloaterPreference::apply() } } + LLUICtrl* display_names_check = getChild<LLUICtrl>("display_names_check"); + bool use_display_names = display_names_check->getValue().asBoolean(); + LLAvatarNameCache::setUseDisplayNames(use_display_names); + applyResolution(); } @@ -529,6 +542,10 @@ void LLFloaterPreference::onOpen(const LLSD& key) LLPanelLogin::setAlwaysRefresh(true); refresh(); + bool use_display_names = LLAvatarNameCache::useDisplayNames(); + LLUICtrl* display_names_check = getChild<LLUICtrl>("display_names_check"); + display_names_check->setValue( LLSD(use_display_names) ); + // Make sure the current state of prefs are saved away when // when the floater is opened. That will make cancel do its // job diff --git a/indra/newview/llfloaterregioninfo.cpp b/indra/newview/llfloaterregioninfo.cpp index 3758cbe74f..e085b8f7c9 100644 --- a/indra/newview/llfloaterregioninfo.cpp +++ b/indra/newview/llfloaterregioninfo.cpp @@ -1971,8 +1971,15 @@ void LLPanelEstateInfo::updateControls(LLViewerRegion* region) childSetEnabled("remove_allowed_avatar_btn", god || owner || manager); childSetEnabled("add_allowed_group_btn", god || owner || manager); childSetEnabled("remove_allowed_group_btn", god || owner || manager); - childSetEnabled("add_banned_avatar_btn", god || owner || manager); - childSetEnabled("remove_banned_avatar_btn", god || owner || manager); + + // Can't ban people from mainland, orientation islands, etc. because this + // creates much network traffic and server load. + // Disable their accounts in CSR tool instead. + bool linden_estate = (getEstateID() <= ESTATE_LAST_LINDEN); + bool enable_ban = (god || owner || manager) && !linden_estate; + childSetEnabled("add_banned_avatar_btn", enable_ban); + childSetEnabled("remove_banned_avatar_btn", enable_ban); + childSetEnabled("message_estate_btn", god || owner || manager); childSetEnabled("kick_user_from_estate_btn", god || owner || manager); diff --git a/indra/newview/llfloaterreporter.cpp b/indra/newview/llfloaterreporter.cpp index b42b34835d..9476b8b1aa 100644 --- a/indra/newview/llfloaterreporter.cpp +++ b/indra/newview/llfloaterreporter.cpp @@ -39,6 +39,7 @@ // linden library includes #include "llassetstorage.h" +#include "llcachename.h" #include "llfontgl.h" #include "llimagej2c.h" #include "llinventory.h" @@ -272,9 +273,8 @@ void LLFloaterReporter::getObjectInfo(const LLUUID& object_id) LLNameValue* lastname = objectp->getNVPair("LastName"); if (firstname && lastname) { - object_owner.append(firstname->getString()); - object_owner.append(1, ' '); - object_owner.append(lastname->getString()); + object_owner = LLCacheName::buildFullName( + firstname->getString(), lastname->getString()); } else { diff --git a/indra/newview/llfloaterscriptlimits.cpp b/indra/newview/llfloaterscriptlimits.cpp index 4792d761d8..bd31181e5a 100644 --- a/indra/newview/llfloaterscriptlimits.cpp +++ b/indra/newview/llfloaterscriptlimits.cpp @@ -295,7 +295,7 @@ void fetchScriptLimitsRegionSummaryResponder::result(const LLSD& content_ref) LLTabContainer* tab = instance->getChild<LLTabContainer>("scriptlimits_panels"); if(tab) { - LLPanelScriptLimitsRegionMemory* panel_memory = (LLPanelScriptLimitsRegionMemory*)tab->getChild<LLPanel>("script_limits_region_memory_panel"); + LLPanelScriptLimitsRegionMemory* panel_memory = (LLPanelScriptLimitsRegionMemory*)tab->getChild<LLPanel>("script_limits_region_memory_panel"); if(panel_memory) { panel_memory->childSetValue("loading_text", LLSD(std::string(""))); @@ -306,9 +306,9 @@ void fetchScriptLimitsRegionSummaryResponder::result(const LLSD& content_ref) btn->setEnabled(true); } - panel_memory->setRegionSummary(content); - } - } + panel_memory->setRegionSummary(content); + } +} } } @@ -599,11 +599,8 @@ void LLPanelScriptLimitsRegionMemory::setErrorStatus(U32 status, const std::stri // callback from the name cache with an owner name to add to the list void LLPanelScriptLimitsRegionMemory::onNameCache( const LLUUID& id, - const std::string& first_name, - const std::string& last_name) + const std::string& name) { - std::string name = first_name + " " + last_name; - LLScrollListCtrl *list = getChild<LLScrollListCtrl>("scripts_list"); if(!list) { @@ -675,6 +672,9 @@ void LLPanelScriptLimitsRegionMemory::setRegionDetails(LLSD content) std::string name_buf = content["parcels"][i]["objects"][j]["name"].asString(); LLUUID task_id = content["parcels"][i]["objects"][j]["id"].asUUID(); LLUUID owner_id = content["parcels"][i]["objects"][j]["owner_id"].asUUID(); + // This field may not be sent by all server versions, but it's OK if + // it uses the LLSD default of false + bool is_group_owned = content["parcels"][i]["objects"][j]["is_group_owned"].asBoolean(); F32 location_x = 0.0f; F32 location_y = 0.0f; @@ -700,15 +700,23 @@ void LLPanelScriptLimitsRegionMemory::setRegionDetails(LLSD content) // ...and if not use the slightly more painful method of disovery: else { - BOOL name_is_cached = gCacheName->getFullName(owner_id, owner_buf); + BOOL name_is_cached; + if (is_group_owned) + { + name_is_cached = gCacheName->getGroupName(owner_id, owner_buf); + } + else + { + name_is_cached = gCacheName->getFullName(owner_id, owner_buf); + } if(!name_is_cached) { if(std::find(names_requested.begin(), names_requested.end(), owner_id) == names_requested.end()) { names_requested.push_back(owner_id); - gCacheName->get(owner_id, TRUE, + gCacheName->get(owner_id, is_group_owned, boost::bind(&LLPanelScriptLimitsRegionMemory::onNameCache, - this, _1, _2, _3)); + this, _1, _2)); } } } @@ -1310,7 +1318,7 @@ void LLPanelScriptLimitsAttachment::setAttachmentSummary(LLSD content) // static void LLPanelScriptLimitsAttachment::onClickRefresh(void* userdata) -{ +{ LLFloaterScriptLimits* instance = LLFloaterReg::getTypedInstance<LLFloaterScriptLimits>("script_limits"); if(instance) { diff --git a/indra/newview/llfloaterscriptlimits.h b/indra/newview/llfloaterscriptlimits.h index 3c32b9f701..ba6f930bee 100644 --- a/indra/newview/llfloaterscriptlimits.h +++ b/indra/newview/llfloaterscriptlimits.h @@ -170,10 +170,8 @@ public: void returnObjects(); private: - void onNameCache(const LLUUID& id, - const std::string& first_name, - const std::string& last_name); + const std::string& name); LLSD mContent; LLUUID mParcelId; diff --git a/indra/newview/llfloatertopobjects.cpp b/indra/newview/llfloatertopobjects.cpp index 84ea353dab..04eb5f5d86 100644 --- a/indra/newview/llfloatertopobjects.cpp +++ b/indra/newview/llfloatertopobjects.cpp @@ -196,8 +196,9 @@ void LLFloaterTopObjects::handleReply(LLMessageSystem *msg, void** data) LLSD element; element["id"] = task_id; - element["object_name"] = name_buf; - element["owner_name"] = owner_buf; + // These cause parse warnings. JC + //element["object_name"] = name_buf; + //element["owner_name"] = owner_buf; element["columns"][0]["column"] = "score"; element["columns"][0]["value"] = llformat("%0.3f", score); element["columns"][0]["font"] = "SANSSERIF"; @@ -206,7 +207,7 @@ void LLFloaterTopObjects::handleReply(LLMessageSystem *msg, void** data) element["columns"][1]["value"] = name_buf; element["columns"][1]["font"] = "SANSSERIF"; element["columns"][2]["column"] = "owner"; - element["columns"][2]["value"] = owner_buf; + element["columns"][2]["value"] = LLCacheName::cleanFullName(owner_buf); element["columns"][2]["font"] = "SANSSERIF"; element["columns"][3]["column"] = "location"; element["columns"][3]["value"] = llformat("<%0.1f,%0.1f,%0.1f>", location_x, location_y, location_z); diff --git a/indra/newview/llglsandbox.cpp b/indra/newview/llglsandbox.cpp index 2aba0b5c09..eec08301a8 100644 --- a/indra/newview/llglsandbox.cpp +++ b/indra/newview/llglsandbox.cpp @@ -54,6 +54,7 @@ #include "lltoolmgr.h" #include "llselectmgr.h" #include "llhudmanager.h" +#include "llhudtext.h" #include "llrendersphere.h" #include "llviewerobjectlist.h" #include "lltoolselectrect.h" @@ -894,7 +895,7 @@ void LLViewerObjectList::renderObjectBeacons() color = debug_beacon.mTextColor; color.mV[3] *= 1.f; - hud_textp->setString(utf8str_to_wstring(debug_beacon.mString)); + hud_textp->setString(debug_beacon.mString); hud_textp->setColor(color); hud_textp->setPositionAgent(debug_beacon.mPositionAgent); debug_beacon.mHUDObject = hud_textp; diff --git a/indra/newview/llhudicon.h b/indra/newview/llhudicon.h index 770e3bbcd0..91b3a64250 100644 --- a/indra/newview/llhudicon.h +++ b/indra/newview/llhudicon.h @@ -50,6 +50,7 @@ // Renders a 2D icon billboard floating at the location specified. class LLDrawable; class LLViewerObject; +class LLViewerTexture; class LLHUDIcon : public LLHUDObject { diff --git a/indra/newview/llhudnametag.cpp b/indra/newview/llhudnametag.cpp new file mode 100644 index 0000000000..e444fc88eb --- /dev/null +++ b/indra/newview/llhudnametag.cpp @@ -0,0 +1,1066 @@ +/** + * @file llhudnametag.cpp + * @brief Name tags for avatars + * @author James Cook + * + * $LicenseInfo:firstyear=2010&license=viewergpl$ + * + * Copyright (c) 2002-2009, Linden Research, Inc. + * + * Second Life Viewer Source Code + * The source code in this file ("Source Code") is provided by Linden Lab + * to you under the terms of the GNU General Public License, version 2.0 + * ("GPL"), unless you have obtained a separate licensing agreement + * ("Other License"), formally executed by you and Linden Lab. Terms of + * the GPL can be found in doc/GPL-license.txt in this distribution, or + * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2 + * + * There are special exceptions to the terms and conditions of the GPL as + * it is applied to this Source Code. View the full text of the exception + * in the file doc/FLOSS-exception.txt in this software distribution, or + * online at + * http://secondlifegrid.net/programs/open_source/licensing/flossexception + * + * By copying, modifying or distributing this software, you acknowledge + * that you have read and understood your obligations described above, + * and agree to abide by those obligations. + * + * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO + * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, + * COMPLETENESS OR PERFORMANCE. + * $/LicenseInfo$ + */ + +#include "llviewerprecompiledheaders.h" + +#include "llhudnametag.h" + +#include "llrender.h" + +#include "llagent.h" +#include "llviewercontrol.h" +#include "llcriticaldamp.h" +#include "lldrawable.h" +#include "llfontgl.h" +#include "llglheaders.h" +#include "llhudrender.h" +#include "llui.h" +#include "llviewercamera.h" +#include "llviewertexturelist.h" +#include "llviewerobject.h" +#include "llvovolume.h" +#include "llviewerwindow.h" +#include "llstatusbar.h" +#include "llmenugl.h" +#include "pipeline.h" +#include <boost/tokenizer.hpp> + + +const F32 SPRING_STRENGTH = 0.7f; +const F32 RESTORATION_SPRING_TIME_CONSTANT = 0.1f; +const F32 HORIZONTAL_PADDING = 16.f; +const F32 VERTICAL_PADDING = 12.f; +const F32 LINE_PADDING = 1; // aka "leading" +const F32 BUFFER_SIZE = 2.f; +const F32 MIN_EDGE_OVERLAP = 3.f; +const F32 HUD_TEXT_MAX_WIDTH = 190.f; +const F32 HUD_TEXT_MAX_WIDTH_NO_BUBBLE = 1000.f; +const F32 RESIZE_TIME = 0.f; +const S32 NUM_OVERLAP_ITERATIONS = 10; +const F32 NEIGHBOR_FORCE_FRACTION = 1.f; +const F32 POSITION_DAMPING_TC = 0.2f; +const F32 MAX_STABLE_CAMERA_VELOCITY = 0.1f; +const F32 LOD_0_SCREEN_COVERAGE = 0.15f; +const F32 LOD_1_SCREEN_COVERAGE = 0.30f; +const F32 LOD_2_SCREEN_COVERAGE = 0.40f; + +std::set<LLPointer<LLHUDNameTag> > LLHUDNameTag::sTextObjects; +std::vector<LLPointer<LLHUDNameTag> > LLHUDNameTag::sVisibleTextObjects; +BOOL LLHUDNameTag::sDisplayText = TRUE ; + +bool llhudnametag_further_away::operator()(const LLPointer<LLHUDNameTag>& lhs, const LLPointer<LLHUDNameTag>& rhs) const +{ + return lhs->getDistance() > rhs->getDistance(); +} + + +LLHUDNameTag::LLHUDNameTag(const U8 type) +: LLHUDObject(type), + mDoFade(TRUE), + mFadeDistance(8.f), + mFadeRange(4.f), + mLastDistance(0.f), + mZCompare(TRUE), + mVisibleOffScreen(FALSE), + mOffscreen(FALSE), + mColor(1.f, 1.f, 1.f, 1.f), +// mScale(), + mWidth(0.f), + mHeight(0.f), + mFontp(LLFontGL::getFontSansSerifSmall()), + mBoldFontp(LLFontGL::getFontSansSerifBold()), + mSoftScreenRect(), + mPositionAgent(), + mPositionOffset(), + mMass(10.f), + mMaxLines(10), + mOffsetY(0), + mRadius(0.1f), + mTextSegments(), + mLabelSegments(), + mTextAlignment(ALIGN_TEXT_CENTER), + mVertAlignment(ALIGN_VERT_CENTER), + mLOD(0), + mHidden(FALSE) +{ + LLPointer<LLHUDNameTag> ptr(this); + sTextObjects.insert(ptr); +} + +LLHUDNameTag::~LLHUDNameTag() +{ +} + + +BOOL LLHUDNameTag::lineSegmentIntersect(const LLVector3& start, const LLVector3& end, LLVector3& intersection, BOOL debug_render) +{ + if (!mVisible || mHidden) + { + return FALSE; + } + + // don't pick text that isn't bound to a viewerobject + if (!mSourceObject || mSourceObject->mDrawable.isNull()) + { + return FALSE; + } + + F32 alpha_factor = 1.f; + LLColor4 text_color = mColor; + if (mDoFade) + { + if (mLastDistance > mFadeDistance) + { + alpha_factor = llmax(0.f, 1.f - (mLastDistance - mFadeDistance)/mFadeRange); + text_color.mV[3] = text_color.mV[3]*alpha_factor; + } + } + if (text_color.mV[3] < 0.01f) + { + return FALSE; + } + + mOffsetY = lltrunc(mHeight * ((mVertAlignment == ALIGN_VERT_CENTER) ? 0.5f : 1.f)); + + // scale screen size of borders down + //RN: for now, text on hud objects is never occluded + + LLVector3 x_pixel_vec; + LLVector3 y_pixel_vec; + + LLViewerCamera::getInstance()->getPixelVectors(mPositionAgent, y_pixel_vec, x_pixel_vec); + + LLVector3 width_vec = mWidth * x_pixel_vec; + LLVector3 height_vec = mHeight * y_pixel_vec; + + LLCoordGL screen_pos; + LLViewerCamera::getInstance()->projectPosAgentToScreen(mPositionAgent, screen_pos, FALSE); + + LLVector2 screen_offset; + screen_offset = updateScreenPos(mPositionOffset); + + LLVector3 render_position = mPositionAgent + + (x_pixel_vec * screen_offset.mV[VX]) + + (y_pixel_vec * screen_offset.mV[VY]); + + + //if (mUseBubble) + { + LLVector3 bg_pos = render_position + + (F32)mOffsetY * y_pixel_vec + - (width_vec / 2.f) + - (height_vec); + //LLUI::translate(bg_pos.mV[VX], bg_pos.mV[VY], bg_pos.mV[VZ]); + + LLVector3 v[] = + { + bg_pos, + bg_pos + width_vec, + bg_pos + width_vec + height_vec, + bg_pos + height_vec, + }; + + if (debug_render) + { + gGL.begin(LLRender::LINE_STRIP); + gGL.vertex3fv(v[0].mV); + gGL.vertex3fv(v[1].mV); + gGL.vertex3fv(v[2].mV); + gGL.vertex3fv(v[3].mV); + gGL.vertex3fv(v[0].mV); + gGL.vertex3fv(v[2].mV); + gGL.end(); + } + + LLVector3 dir = end-start; + F32 t = 0.f; + + if (LLTriangleRayIntersect(v[0], v[1], v[2], start, dir, NULL, NULL, &t, FALSE) || + LLTriangleRayIntersect(v[2], v[3], v[0], start, dir, NULL, NULL, &t, FALSE) ) + { + if (t <= 1.f) + { + intersection = start + dir*t; + return TRUE; + } + } + } + + return FALSE; +} + +void LLHUDNameTag::render() +{ + if (sDisplayText) + { + LLGLDepthTest gls_depth(GL_TRUE, GL_FALSE); + renderText(FALSE); + } +} + +void LLHUDNameTag::renderForSelect() +{ + LLGLDepthTest gls_depth(GL_TRUE, GL_FALSE); + renderText(TRUE); +} + +void LLHUDNameTag::renderText(BOOL for_select) +{ + if (!mVisible || mHidden) + { + return; + } + + // don't pick text that isn't bound to a viewerobject + if (for_select && + (!mSourceObject || mSourceObject->mDrawable.isNull())) + { + return; + } + + if (for_select) + { + gGL.getTexUnit(0)->disable(); + } + else + { + gGL.getTexUnit(0)->enable(LLTexUnit::TT_TEXTURE); + } + + LLGLState gls_blend(GL_BLEND, for_select ? FALSE : TRUE); + LLGLState gls_alpha(GL_ALPHA_TEST, for_select ? FALSE : TRUE); + + LLColor4 shadow_color(0.f, 0.f, 0.f, 1.f); + F32 alpha_factor = 1.f; + LLColor4 text_color = mColor; + if (mDoFade) + { + if (mLastDistance > mFadeDistance) + { + alpha_factor = llmax(0.f, 1.f - (mLastDistance - mFadeDistance)/mFadeRange); + text_color.mV[3] = text_color.mV[3]*alpha_factor; + } + } + if (text_color.mV[3] < 0.01f) + { + return; + } + shadow_color.mV[3] = text_color.mV[3]; + + mOffsetY = lltrunc(mHeight * ((mVertAlignment == ALIGN_VERT_CENTER) ? 0.5f : 1.f)); + + // *TODO: cache this image + LLUIImagePtr imagep = LLUI::getUIImage("Rounded_Rect"); + + // *TODO: make this a per-text setting + LLColor4 bg_color = LLUIColorTable::instance().getColor("NameTagBackground"); + bg_color.setAlpha(gSavedSettings.getF32("ChatBubbleOpacity") * alpha_factor); + + // JAMESDEBUG - maybe a no-op + //const S32 border_height = 16; + //const S32 border_width = 16; + const S32 border_height = 8; + const S32 border_width = 8; + + // *TODO move this into helper function + F32 border_scale = 1.f; + + if (border_height * 2 > mHeight) + { + border_scale = (F32)mHeight / ((F32)border_height * 2.f); + } + if (border_width * 2 > mWidth) + { + border_scale = llmin(border_scale, (F32)mWidth / ((F32)border_width * 2.f)); + } + + // scale screen size of borders down + //RN: for now, text on hud objects is never occluded + + LLVector3 x_pixel_vec; + LLVector3 y_pixel_vec; + + LLViewerCamera::getInstance()->getPixelVectors(mPositionAgent, y_pixel_vec, x_pixel_vec); + + LLVector2 border_scale_vec((F32)border_width / (F32)imagep->getTextureWidth(), (F32)border_height / (F32)imagep->getTextureHeight()); + LLVector3 width_vec = mWidth * x_pixel_vec; + LLVector3 height_vec = mHeight * y_pixel_vec; + LLVector3 scaled_border_width = (F32)llfloor(border_scale * (F32)border_width) * x_pixel_vec; + LLVector3 scaled_border_height = (F32)llfloor(border_scale * (F32)border_height) * y_pixel_vec; + + mRadius = (width_vec + height_vec).magVec() * 0.5f; + + LLCoordGL screen_pos; + LLViewerCamera::getInstance()->projectPosAgentToScreen(mPositionAgent, screen_pos, FALSE); + + LLVector2 screen_offset; +// if (!mUseBubble) +// { +// screen_offset = mPositionOffset; +// } +// else +// { + screen_offset = updateScreenPos(mPositionOffset); +// } + + LLVector3 render_position = mPositionAgent + + (x_pixel_vec * screen_offset.mV[VX]) + + (y_pixel_vec * screen_offset.mV[VY]); + +// if (mUseBubble) + { + LLGLDepthTest gls_depth(GL_TRUE, GL_FALSE); + LLUI::pushMatrix(); + { + LLVector3 bg_pos = render_position + + (F32)mOffsetY * y_pixel_vec + - (width_vec / 2.f) + - (height_vec); + LLUI::translate(bg_pos.mV[VX], bg_pos.mV[VY], bg_pos.mV[VZ]); + + if (for_select) + { + gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); + S32 name = mSourceObject->mGLName; + LLColor4U coloru((U8)(name >> 16), (U8)(name >> 8), (U8)name); + gGL.color4ubv(coloru.mV); + gl_segmented_rect_3d_tex(border_scale_vec, scaled_border_width, scaled_border_height, width_vec, height_vec); + LLUI::popMatrix(); + return; + } + else + { + gGL.getTexUnit(0)->bind(imagep->getImage()); + + gGL.color4fv(bg_color.mV); + gl_segmented_rect_3d_tex(border_scale_vec, scaled_border_width, scaled_border_height, width_vec, height_vec); + + if ( mLabelSegments.size()) + { + LLUI::pushMatrix(); + { + gGL.color4f(text_color.mV[VX], text_color.mV[VY], text_color.mV[VZ], gSavedSettings.getF32("ChatBubbleOpacity") * alpha_factor); + LLVector3 label_height = (mFontp->getLineHeight() * mLabelSegments.size() + (VERTICAL_PADDING / 3.f)) * y_pixel_vec; + LLVector3 label_offset = height_vec - label_height; + LLUI::translate(label_offset.mV[VX], label_offset.mV[VY], label_offset.mV[VZ]); + gl_segmented_rect_3d_tex_top(border_scale_vec, scaled_border_width, scaled_border_height, width_vec, label_height); + } + LLUI::popMatrix(); + } + } + + BOOL outside_width = llabs(mPositionOffset.mV[VX]) > mWidth * 0.5f; + BOOL outside_height = llabs(mPositionOffset.mV[VY] + (mVertAlignment == ALIGN_VERT_TOP ? mHeight * 0.5f : 0.f)) > mHeight * (mVertAlignment == ALIGN_VERT_TOP ? mHeight * 0.75f : 0.5f); + + // draw line segments pointing to parent object + if (!mOffscreen && (outside_width || outside_height)) + { + LLUI::pushMatrix(); + { + gGL.color4fv(bg_color.mV); + LLVector3 target_pos = -1.f * (mPositionOffset.mV[VX] * x_pixel_vec + mPositionOffset.mV[VY] * y_pixel_vec); + target_pos += (width_vec / 2.f); + target_pos += mVertAlignment == ALIGN_VERT_CENTER ? (height_vec * 0.5f) : LLVector3::zero; + target_pos -= 3.f * x_pixel_vec; + target_pos -= 6.f * y_pixel_vec; + LLUI::translate(target_pos.mV[VX], target_pos.mV[VY], target_pos.mV[VZ]); + gl_segmented_rect_3d_tex(border_scale_vec, 3.f * x_pixel_vec, 3.f * y_pixel_vec, 6.f * x_pixel_vec, 6.f * y_pixel_vec); + } + LLUI::popMatrix(); + + gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); + LLGLDepthTest gls_depth(mZCompare ? GL_TRUE : GL_FALSE, GL_FALSE); + + LLVector3 box_center_offset; + box_center_offset = (width_vec * 0.5f) + (height_vec * 0.5f); + LLUI::translate(box_center_offset.mV[VX], box_center_offset.mV[VY], box_center_offset.mV[VZ]); + gGL.color4fv(bg_color.mV); + LLUI::setLineWidth(2.0); + gGL.begin(LLRender::LINES); + { + if (outside_width) + { + LLVector3 vert; + // draw line in x then y + if (mPositionOffset.mV[VX] < 0.f) + { + // start at right edge + vert = width_vec * 0.5f; + gGL.vertex3fv(vert.mV); + } + else + { + // start at left edge + vert = width_vec * -0.5f; + gGL.vertex3fv(vert.mV); + } + vert = -mPositionOffset.mV[VX] * x_pixel_vec; + gGL.vertex3fv(vert.mV); + gGL.vertex3fv(vert.mV); + vert -= mPositionOffset.mV[VY] * y_pixel_vec; + vert -= ((mVertAlignment == ALIGN_VERT_TOP) ? (height_vec * 0.5f) : LLVector3::zero); + gGL.vertex3fv(vert.mV); + } + else + { + LLVector3 vert; + // draw line in y then x + if (mPositionOffset.mV[VY] < 0.f) + { + // start at top edge + vert = (height_vec * 0.5f) - (mPositionOffset.mV[VX] * x_pixel_vec); + gGL.vertex3fv(vert.mV); + } + else + { + // start at bottom edge + vert = (height_vec * -0.5f) - (mPositionOffset.mV[VX] * x_pixel_vec); + gGL.vertex3fv(vert.mV); + } + vert = -mPositionOffset.mV[VY] * y_pixel_vec - mPositionOffset.mV[VX] * x_pixel_vec; + vert -= ((mVertAlignment == ALIGN_VERT_TOP) ? (height_vec * 0.5f) : LLVector3::zero); + gGL.vertex3fv(vert.mV); + } + } + gGL.end(); + LLUI::setLineWidth(1.0); + + } + } + LLUI::popMatrix(); + } + + F32 y_offset = (F32)mOffsetY - 2; // JAMESDEBUG + + // Render label + { + gGL.getTexUnit(0)->setTextureBlendType(LLTexUnit::TB_MULT); + + for(std::vector<LLHUDTextSegment>::iterator segment_iter = mLabelSegments.begin(); + segment_iter != mLabelSegments.end(); ++segment_iter ) + { + // Label segments use default font + const LLFontGL* fontp = (segment_iter->mStyle == LLFontGL::BOLD) ? mBoldFontp : mFontp; + y_offset -= fontp->getLineHeight(); + + F32 x_offset; + if (mTextAlignment == ALIGN_TEXT_CENTER) + { + x_offset = -0.5f*segment_iter->getWidth(fontp); + } + else // ALIGN_LEFT + { + x_offset = -0.5f * mWidth + (HORIZONTAL_PADDING / 2.f); + } + + LLColor4 label_color(0.f, 0.f, 0.f, 1.f); + label_color.mV[VALPHA] = alpha_factor; + hud_render_text(segment_iter->getText(), render_position, *fontp, segment_iter->mStyle, LLFontGL::NO_SHADOW, x_offset, y_offset, label_color, FALSE); + } + } + + // Render text + { + // -1 mMaxLines means unlimited lines. + S32 start_segment; + S32 max_lines = getMaxLines(); + + if (max_lines < 0) + { + start_segment = 0; + } + else + { + start_segment = llmax((S32)0, (S32)mTextSegments.size() - max_lines); + } + + for (std::vector<LLHUDTextSegment>::iterator segment_iter = mTextSegments.begin() + start_segment; + segment_iter != mTextSegments.end(); ++segment_iter ) + { + const LLFontGL* fontp = segment_iter->mFont; + y_offset -= fontp->getLineHeight(); + y_offset -= LINE_PADDING; + + U8 style = segment_iter->mStyle; + LLFontGL::ShadowType shadow = LLFontGL::DROP_SHADOW; + + F32 x_offset; + if (mTextAlignment== ALIGN_TEXT_CENTER) + { + x_offset = -0.5f*segment_iter->getWidth(fontp); + } + else // ALIGN_LEFT + { + x_offset = -0.5f * mWidth + (HORIZONTAL_PADDING / 2.f); + + // JAMESDEBUG HACK + x_offset += 1; + } + + text_color = segment_iter->mColor; + text_color.mV[VALPHA] *= alpha_factor; + + hud_render_text(segment_iter->getText(), render_position, *fontp, style, shadow, x_offset, y_offset, text_color, FALSE); + } + } + /// Reset the default color to white. The renderer expects this to be the default. + gGL.color4f(1.0f, 1.0f, 1.0f, 1.0f); + if (for_select) + { + gGL.getTexUnit(0)->enable(LLTexUnit::TT_TEXTURE); + } +} + +void LLHUDNameTag::setString(const std::string &text_utf8) +{ + mTextSegments.clear(); + addLine(text_utf8, mColor); +} + +void LLHUDNameTag::clearString() +{ + mTextSegments.clear(); +} + + +void LLHUDNameTag::addLine(const std::string &text_utf8, + const LLColor4& color, + const LLFontGL::StyleFlags style, + const LLFontGL* font) +{ + LLWString wline = utf8str_to_wstring(text_utf8); + if (!wline.empty()) + { + // use default font for segment if custom font not specified + if (!font) + { + font = mFontp; + } + typedef boost::tokenizer<boost::char_separator<llwchar>, LLWString::const_iterator, LLWString > tokenizer; + LLWString seps(utf8str_to_wstring("\r\n")); + boost::char_separator<llwchar> sep(seps.c_str()); + + tokenizer tokens(wline, sep); + tokenizer::iterator iter = tokens.begin(); + + while (iter != tokens.end()) + { + U32 line_length = 0; + do + { + F32 max_pixels = HUD_TEXT_MAX_WIDTH; + S32 segment_length = font->maxDrawableChars(iter->substr(line_length).c_str(), max_pixels, wline.length(), LLFontGL::WORD_BOUNDARY_IF_POSSIBLE); + LLHUDTextSegment segment(iter->substr(line_length, segment_length), style, color, font); + mTextSegments.push_back(segment); + line_length += segment_length; + } + while (line_length != iter->size()); + ++iter; + } + } +} + +void LLHUDNameTag::setLabel(const std::string &label_utf8) +{ + mLabelSegments.clear(); + addLabel(label_utf8); +} + +void LLHUDNameTag::addLabel(const std::string& label_utf8) +{ + LLWString wstr = utf8string_to_wstring(label_utf8); + if (!wstr.empty()) + { + LLWString seps(utf8str_to_wstring("\r\n")); + LLWString empty; + + typedef boost::tokenizer<boost::char_separator<llwchar>, LLWString::const_iterator, LLWString > tokenizer; + boost::char_separator<llwchar> sep(seps.c_str(), empty.c_str(), boost::keep_empty_tokens); + + tokenizer tokens(wstr, sep); + tokenizer::iterator iter = tokens.begin(); + + while (iter != tokens.end()) + { + U32 line_length = 0; + do + { + S32 segment_length = mFontp->maxDrawableChars(iter->substr(line_length).c_str(), + HUD_TEXT_MAX_WIDTH, wstr.length(), LLFontGL::WORD_BOUNDARY_IF_POSSIBLE); + LLHUDTextSegment segment(iter->substr(line_length, segment_length), LLFontGL::NORMAL, mColor, mFontp); + mLabelSegments.push_back(segment); + line_length += segment_length; + } + while (line_length != iter->size()); + ++iter; + } + } +} + +void LLHUDNameTag::setZCompare(const BOOL zcompare) +{ + mZCompare = zcompare; +} + +void LLHUDNameTag::setFont(const LLFontGL* font) +{ + mFontp = font; +} + + +void LLHUDNameTag::setColor(const LLColor4 &color) +{ + mColor = color; + for (std::vector<LLHUDTextSegment>::iterator segment_iter = mTextSegments.begin(); + segment_iter != mTextSegments.end(); ++segment_iter ) + { + segment_iter->mColor = color; + } +} + +void LLHUDNameTag::setAlpha(F32 alpha) +{ + mColor.mV[VALPHA] = alpha; + for (std::vector<LLHUDTextSegment>::iterator segment_iter = mTextSegments.begin(); + segment_iter != mTextSegments.end(); ++segment_iter ) + { + segment_iter->mColor.mV[VALPHA] = alpha; + } +} + + +void LLHUDNameTag::setDoFade(const BOOL do_fade) +{ + mDoFade = do_fade; +} + +void LLHUDNameTag::updateVisibility() +{ + if (mSourceObject) + { + mSourceObject->updateText(); + } + + mPositionAgent = gAgent.getPosAgentFromGlobal(mPositionGlobal); + + if (!mSourceObject) + { + //llwarns << "LLHUDNameTag::updateScreenPos -- mSourceObject is NULL!" << llendl; + mVisible = TRUE; + sVisibleTextObjects.push_back(LLPointer<LLHUDNameTag> (this)); + return; + } + + // Not visible if parent object is dead + if (mSourceObject->isDead()) + { + mVisible = FALSE; + return; + } + + // push text towards camera by radius of object, but not past camera + LLVector3 vec_from_camera = mPositionAgent - LLViewerCamera::getInstance()->getOrigin(); + LLVector3 dir_from_camera = vec_from_camera; + dir_from_camera.normVec(); + + if (dir_from_camera * LLViewerCamera::getInstance()->getAtAxis() <= 0.f) + { //text is behind camera, don't render + mVisible = FALSE; + return; + } + + if (vec_from_camera * LLViewerCamera::getInstance()->getAtAxis() <= LLViewerCamera::getInstance()->getNear() + 0.1f + mSourceObject->getVObjRadius()) + { + mPositionAgent = LLViewerCamera::getInstance()->getOrigin() + vec_from_camera * ((LLViewerCamera::getInstance()->getNear() + 0.1f) / (vec_from_camera * LLViewerCamera::getInstance()->getAtAxis())); + } + else + { + mPositionAgent -= dir_from_camera * mSourceObject->getVObjRadius(); + } + + mLastDistance = (mPositionAgent - LLViewerCamera::getInstance()->getOrigin()).magVec(); + + if (mLOD >= 3 || !mTextSegments.size() || (mDoFade && (mLastDistance > mFadeDistance + mFadeRange))) + { + mVisible = FALSE; + return; + } + + LLVector3 x_pixel_vec; + LLVector3 y_pixel_vec; + + LLViewerCamera::getInstance()->getPixelVectors(mPositionAgent, y_pixel_vec, x_pixel_vec); + + LLVector3 render_position = mPositionAgent + + (x_pixel_vec * mPositionOffset.mV[VX]) + + (y_pixel_vec * mPositionOffset.mV[VY]); + + mOffscreen = FALSE; + if (!LLViewerCamera::getInstance()->sphereInFrustum(render_position, mRadius)) + { + if (!mVisibleOffScreen) + { + mVisible = FALSE; + return; + } + else + { + mOffscreen = TRUE; + } + } + + mVisible = TRUE; + sVisibleTextObjects.push_back(LLPointer<LLHUDNameTag> (this)); +} + +LLVector2 LLHUDNameTag::updateScreenPos(LLVector2 &offset) +{ + LLCoordGL screen_pos; + LLVector2 screen_pos_vec; + LLVector3 x_pixel_vec; + LLVector3 y_pixel_vec; + LLViewerCamera::getInstance()->getPixelVectors(mPositionAgent, y_pixel_vec, x_pixel_vec); + LLVector3 world_pos = mPositionAgent + (offset.mV[VX] * x_pixel_vec) + (offset.mV[VY] * y_pixel_vec); + if (!LLViewerCamera::getInstance()->projectPosAgentToScreen(world_pos, screen_pos, FALSE) && mVisibleOffScreen) + { + // bubble off-screen, so find a spot for it along screen edge + LLViewerCamera::getInstance()->projectPosAgentToScreenEdge(world_pos, screen_pos); + } + + screen_pos_vec.setVec((F32)screen_pos.mX, (F32)screen_pos.mY); + + LLRect world_rect = gViewerWindow->getWorldViewRectScaled(); + S32 bottom = world_rect.mBottom + STATUS_BAR_HEIGHT; + + LLVector2 screen_center; + screen_center.mV[VX] = llclamp((F32)screen_pos_vec.mV[VX], (F32)world_rect.mLeft + mWidth * 0.5f, (F32)world_rect.mRight - mWidth * 0.5f); + + if(mVertAlignment == ALIGN_VERT_TOP) + { + screen_center.mV[VY] = llclamp((F32)screen_pos_vec.mV[VY], + (F32)bottom, + (F32)world_rect.mTop - mHeight - (F32)MENU_BAR_HEIGHT); + mSoftScreenRect.setLeftTopAndSize(screen_center.mV[VX] - (mWidth + BUFFER_SIZE) * 0.5f, + screen_center.mV[VY] + (mHeight + BUFFER_SIZE), mWidth + BUFFER_SIZE, mHeight + BUFFER_SIZE); + } + else + { + screen_center.mV[VY] = llclamp((F32)screen_pos_vec.mV[VY], + (F32)bottom + mHeight * 0.5f, + (F32)world_rect.mTop - mHeight * 0.5f - (F32)MENU_BAR_HEIGHT); + mSoftScreenRect.setCenterAndSize(screen_center.mV[VX], screen_center.mV[VY], mWidth + BUFFER_SIZE, mHeight + BUFFER_SIZE); + } + + return offset + (screen_center - LLVector2((F32)screen_pos.mX, (F32)screen_pos.mY)); +} + +void LLHUDNameTag::updateSize() +{ + F32 height = 0.f; + F32 width = 0.f; + + S32 max_lines = getMaxLines(); + //S32 lines = (max_lines < 0) ? (S32)mTextSegments.size() : llmin((S32)mTextSegments.size(), max_lines); + //F32 height = (F32)mFontp->getLineHeight() * (lines + mLabelSegments.size()); + + S32 start_segment; + if (max_lines < 0) start_segment = 0; + else start_segment = llmax((S32)0, (S32)mTextSegments.size() - max_lines); + + std::vector<LLHUDTextSegment>::iterator iter = mTextSegments.begin() + start_segment; + while (iter != mTextSegments.end()) + { + const LLFontGL* fontp = iter->mFont; + height += fontp->getLineHeight(); + height += LINE_PADDING; + width = llmax(width, llmin(iter->getWidth(fontp), HUD_TEXT_MAX_WIDTH)); + ++iter; + } + + iter = mLabelSegments.begin(); + while (iter != mLabelSegments.end()) + { + height += mFontp->getLineHeight(); + width = llmax(width, llmin(iter->getWidth(mFontp), HUD_TEXT_MAX_WIDTH)); + ++iter; + } + + if (width == 0.f) + { + return; + } + + width += HORIZONTAL_PADDING; + height += VERTICAL_PADDING; + + // *TODO: Could do a timer-based resize here + //mWidth = llmax(width, lerp(mWidth, (F32)width, u)); + //mHeight = llmax(height, lerp(mHeight, (F32)height, u)); + mWidth = width; + mHeight = height; +} + +void LLHUDNameTag::updateAll() +{ + // iterate over all text objects, calculate their restoration forces, + // and add them to the visible set if they are on screen and close enough + sVisibleTextObjects.clear(); + + TextObjectIterator text_it; + for (text_it = sTextObjects.begin(); text_it != sTextObjects.end(); ++text_it) + { + LLHUDNameTag* textp = (*text_it); + textp->mTargetPositionOffset.clearVec(); + textp->updateSize(); + textp->updateVisibility(); + } + + // sort back to front for rendering purposes + std::sort(sVisibleTextObjects.begin(), sVisibleTextObjects.end(), llhudnametag_further_away()); + + // iterate from front to back, and set LOD based on current screen coverage + F32 screen_area = (F32)(gViewerWindow->getWindowWidthScaled() * gViewerWindow->getWindowHeightScaled()); + F32 current_screen_area = 0.f; + std::vector<LLPointer<LLHUDNameTag> >::reverse_iterator r_it; + for (r_it = sVisibleTextObjects.rbegin(); r_it != sVisibleTextObjects.rend(); ++r_it) + { + LLHUDNameTag* textp = (*r_it); +// if (textp->mUseBubble) +// { + if (current_screen_area / screen_area > LOD_2_SCREEN_COVERAGE) + { + textp->setLOD(3); + } + else if (current_screen_area / screen_area > LOD_1_SCREEN_COVERAGE) + { + textp->setLOD(2); + } + else if (current_screen_area / screen_area > LOD_0_SCREEN_COVERAGE) + { + textp->setLOD(1); + } + else + { + textp->setLOD(0); + } + textp->updateSize(); + // find on-screen position and initialize collision rectangle + textp->mTargetPositionOffset = textp->updateScreenPos(LLVector2::zero); + current_screen_area += (F32)(textp->mSoftScreenRect.getWidth() * textp->mSoftScreenRect.getHeight()); +// } + } + + LLStat* camera_vel_stat = LLViewerCamera::getInstance()->getVelocityStat(); + F32 camera_vel = camera_vel_stat->getCurrent(); + if (camera_vel > MAX_STABLE_CAMERA_VELOCITY) + { + return; + } + + VisibleTextObjectIterator src_it; + + for (S32 i = 0; i < NUM_OVERLAP_ITERATIONS; i++) + { + for (src_it = sVisibleTextObjects.begin(); src_it != sVisibleTextObjects.end(); ++src_it) + { + LLHUDNameTag* src_textp = (*src_it); + +// if (!src_textp->mUseBubble) +// { +// continue; +// } + VisibleTextObjectIterator dst_it = src_it; + ++dst_it; + for (; dst_it != sVisibleTextObjects.end(); ++dst_it) + { + LLHUDNameTag* dst_textp = (*dst_it); + +// if (!dst_textp->mUseBubble) +// { +// continue; +// } + if (src_textp->mSoftScreenRect.overlaps(dst_textp->mSoftScreenRect)) + { + LLRectf intersect_rect = src_textp->mSoftScreenRect; + intersect_rect.intersectWith(dst_textp->mSoftScreenRect); + intersect_rect.stretch(-BUFFER_SIZE * 0.5f); + + F32 src_center_x = src_textp->mSoftScreenRect.getCenterX(); + F32 src_center_y = src_textp->mSoftScreenRect.getCenterY(); + F32 dst_center_x = dst_textp->mSoftScreenRect.getCenterX(); + F32 dst_center_y = dst_textp->mSoftScreenRect.getCenterY(); + F32 intersect_center_x = intersect_rect.getCenterX(); + F32 intersect_center_y = intersect_rect.getCenterY(); + LLVector2 force = lerp(LLVector2(dst_center_x - intersect_center_x, dst_center_y - intersect_center_y), + LLVector2(intersect_center_x - src_center_x, intersect_center_y - src_center_y), + 0.5f); + force.setVec(dst_center_x - src_center_x, dst_center_y - src_center_y); + force.normVec(); + + LLVector2 src_force = -1.f * force; + LLVector2 dst_force = force; + + LLVector2 force_strength; + F32 src_mult = dst_textp->mMass / (dst_textp->mMass + src_textp->mMass); + F32 dst_mult = 1.f - src_mult; + F32 src_aspect_ratio = src_textp->mSoftScreenRect.getWidth() / src_textp->mSoftScreenRect.getHeight(); + F32 dst_aspect_ratio = dst_textp->mSoftScreenRect.getWidth() / dst_textp->mSoftScreenRect.getHeight(); + src_force.mV[VY] *= src_aspect_ratio; + src_force.normVec(); + dst_force.mV[VY] *= dst_aspect_ratio; + dst_force.normVec(); + + src_force.mV[VX] *= llmin(intersect_rect.getWidth() * src_mult, intersect_rect.getHeight() * SPRING_STRENGTH); + src_force.mV[VY] *= llmin(intersect_rect.getHeight() * src_mult, intersect_rect.getWidth() * SPRING_STRENGTH); + dst_force.mV[VX] *= llmin(intersect_rect.getWidth() * dst_mult, intersect_rect.getHeight() * SPRING_STRENGTH); + dst_force.mV[VY] *= llmin(intersect_rect.getHeight() * dst_mult, intersect_rect.getWidth() * SPRING_STRENGTH); + + src_textp->mTargetPositionOffset += src_force; + dst_textp->mTargetPositionOffset += dst_force; + src_textp->mTargetPositionOffset = src_textp->updateScreenPos(src_textp->mTargetPositionOffset); + dst_textp->mTargetPositionOffset = dst_textp->updateScreenPos(dst_textp->mTargetPositionOffset); + } + } + } + } + + VisibleTextObjectIterator this_object_it; + for (this_object_it = sVisibleTextObjects.begin(); this_object_it != sVisibleTextObjects.end(); ++this_object_it) + { +// if (!(*this_object_it)->mUseBubble) +// { +// continue; +// } + (*this_object_it)->mPositionOffset = lerp((*this_object_it)->mPositionOffset, (*this_object_it)->mTargetPositionOffset, LLCriticalDamp::getInterpolant(POSITION_DAMPING_TC)); + } +} + +void LLHUDNameTag::setLOD(S32 lod) +{ + mLOD = lod; + //RN: uncomment this to visualize LOD levels + //std::string label = llformat("%d", lod); + //setLabel(label); +} + +S32 LLHUDNameTag::getMaxLines() +{ + switch(mLOD) + { + case 0: + return mMaxLines; + case 1: + return mMaxLines > 0 ? mMaxLines / 2 : 5; + case 2: + return mMaxLines > 0 ? mMaxLines / 3 : 2; + default: + // label only + return 0; + } +} + +void LLHUDNameTag::markDead() +{ + sTextObjects.erase(LLPointer<LLHUDNameTag>(this)); + LLHUDObject::markDead(); +} + +void LLHUDNameTag::shiftAll(const LLVector3& offset) +{ + TextObjectIterator text_it; + for (text_it = sTextObjects.begin(); text_it != sTextObjects.end(); ++text_it) + { + LLHUDNameTag *textp = text_it->get(); + textp->shift(offset); + } +} + +void LLHUDNameTag::shift(const LLVector3& offset) +{ + mPositionAgent += offset; +} + +//static +void LLHUDNameTag::addPickable(std::set<LLViewerObject*> &pick_list) +{ + //this might put an object on the pick list a second time, overriding it's mGLName, which is ok + // *FIX: we should probably cull against pick frustum + VisibleTextObjectIterator text_it; + for (text_it = sVisibleTextObjects.begin(); text_it != sVisibleTextObjects.end(); ++text_it) + { +// if (!(*text_it)->mUseBubble) +// { +// continue; +// } + pick_list.insert((*text_it)->mSourceObject); + } +} + +//static +// called when UI scale changes, to flush font width caches +void LLHUDNameTag::reshape() +{ + TextObjectIterator text_it; + for (text_it = sTextObjects.begin(); text_it != sTextObjects.end(); ++text_it) + { + LLHUDNameTag* textp = (*text_it); + std::vector<LLHUDTextSegment>::iterator segment_iter; + for (segment_iter = textp->mTextSegments.begin(); + segment_iter != textp->mTextSegments.end(); ++segment_iter ) + { + segment_iter->clearFontWidthMap(); + } + for(segment_iter = textp->mLabelSegments.begin(); + segment_iter != textp->mLabelSegments.end(); ++segment_iter ) + { + segment_iter->clearFontWidthMap(); + } + } +} + +//============================================================================ + +F32 LLHUDNameTag::LLHUDTextSegment::getWidth(const LLFontGL* font) +{ + std::map<const LLFontGL*, F32>::iterator iter = mFontWidthMap.find(font); + if (iter != mFontWidthMap.end()) + { + return iter->second; + } + else + { + F32 width = font->getWidthF32(mText.c_str()); + mFontWidthMap[font] = width; + return width; + } +} diff --git a/indra/newview/llhudnametag.h b/indra/newview/llhudnametag.h new file mode 100644 index 0000000000..9a92307009 --- /dev/null +++ b/indra/newview/llhudnametag.h @@ -0,0 +1,191 @@ +/** + * @file llhudnametag.h + * @brief Name tags for avatars + * @author James Cook + * + * $LicenseInfo:firstyear=2010&license=viewergpl$ + * + * Copyright (c) 2002-2009, Linden Research, Inc. + * + * Second Life Viewer Source Code + * The source code in this file ("Source Code") is provided by Linden Lab + * to you under the terms of the GNU General Public License, version 2.0 + * ("GPL"), unless you have obtained a separate licensing agreement + * ("Other License"), formally executed by you and Linden Lab. Terms of + * the GPL can be found in doc/GPL-license.txt in this distribution, or + * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2 + * + * There are special exceptions to the terms and conditions of the GPL as + * it is applied to this Source Code. View the full text of the exception + * in the file doc/FLOSS-exception.txt in this software distribution, or + * online at + * http://secondlifegrid.net/programs/open_source/licensing/flossexception + * + * By copying, modifying or distributing this software, you acknowledge + * that you have read and understood your obligations described above, + * and agree to abide by those obligations. + * + * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO + * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, + * COMPLETENESS OR PERFORMANCE. + * $/LicenseInfo$ + */ + +#ifndef LLHUDNAMETAG_H +#define LLHUDNAMETAG_H + +#include "llpointer.h" + +#include "llhudobject.h" +#include "v4color.h" +//#include "v4coloru.h" +#include "v2math.h" +#include "llrect.h" +//#include "llframetimer.h" +#include "llfontgl.h" +#include <set> +#include <vector> + +class LLDrawable; +class LLHUDNameTag; + +struct llhudnametag_further_away +{ + bool operator()(const LLPointer<LLHUDNameTag>& lhs, const LLPointer<LLHUDNameTag>& rhs) const; +}; + +class LLHUDNameTag : public LLHUDObject +{ +protected: + class LLHUDTextSegment + { + public: + LLHUDTextSegment(const LLWString& text, const LLFontGL::StyleFlags style, const LLColor4& color, const LLFontGL* font) + : mColor(color), + mStyle(style), + mText(text), + mFont(font) + {} + F32 getWidth(const LLFontGL* font); + const LLWString& getText() const { return mText; } + void clearFontWidthMap() { mFontWidthMap.clear(); } + + LLColor4 mColor; + LLFontGL::StyleFlags mStyle; + const LLFontGL* mFont; + private: + LLWString mText; + std::map<const LLFontGL*, F32> mFontWidthMap; + }; + +public: + typedef enum e_text_alignment + { + ALIGN_TEXT_LEFT, + ALIGN_TEXT_CENTER + } ETextAlignment; + + typedef enum e_vert_alignment + { + ALIGN_VERT_TOP, + ALIGN_VERT_CENTER + } EVertAlignment; + +public: + // Set entire string, eliminating existing lines + void setString(const std::string& text_utf8); + + void clearString(); + + // Add text a line at a time, allowing custom formatting + void addLine(const std::string &text_utf8, const LLColor4& color, const LLFontGL::StyleFlags style = LLFontGL::NORMAL, const LLFontGL* font = NULL); + + // For bubble chat, set the part above the chat text + void setLabel(const std::string& label_utf8); + void addLabel(const std::string& label_utf8); + + // Sets the default font for lines with no font specified + void setFont(const LLFontGL* font); + void setColor(const LLColor4 &color); + void setAlpha(F32 alpha); + void setZCompare(const BOOL zcompare); + void setDoFade(const BOOL do_fade); + void setVisibleOffScreen(BOOL visible) { mVisibleOffScreen = visible; } + + // mMaxLines of -1 means unlimited lines. + void setMaxLines(S32 max_lines) { mMaxLines = max_lines; } + void setFadeDistance(F32 fade_distance, F32 fade_range) { mFadeDistance = fade_distance; mFadeRange = fade_range; } + void updateVisibility(); + LLVector2 updateScreenPos(LLVector2 &offset_target); + void updateSize(); +// void setMass(F32 mass) { mMass = llmax(0.1f, mass); } + void setTextAlignment(ETextAlignment alignment) { mTextAlignment = alignment; } + void setVertAlignment(EVertAlignment alignment) { mVertAlignment = alignment; } + /*virtual*/ void markDead(); + friend class LLHUDObject; + /*virtual*/ F32 getDistance() const { return mLastDistance; } + //void setUseBubble(BOOL use_bubble) { mUseBubble = use_bubble; } + S32 getLOD() { return mLOD; } + BOOL getVisible() { return mVisible; } + BOOL getHidden() const { return mHidden; } + void setHidden( BOOL hide ) { mHidden = hide; } + void shift(const LLVector3& offset); + + BOOL lineSegmentIntersect(const LLVector3& start, const LLVector3& end, LLVector3& intersection, BOOL debug_render = FALSE); + + static void shiftAll(const LLVector3& offset); + static void addPickable(std::set<LLViewerObject*> &pick_list); + static void reshape(); + static void setDisplayText(BOOL flag) { sDisplayText = flag ; } + +protected: + LLHUDNameTag(const U8 type); + + /*virtual*/ void render(); + /*virtual*/ void renderForSelect(); + void renderText(BOOL for_select); + static void updateAll(); + void setLOD(S32 lod); + S32 getMaxLines(); + +private: + ~LLHUDNameTag(); + BOOL mDoFade; + F32 mFadeRange; + F32 mFadeDistance; + F32 mLastDistance; + BOOL mZCompare; + BOOL mVisibleOffScreen; + BOOL mOffscreen; + LLColor4 mColor; +// LLVector3 mScale; + F32 mWidth; + F32 mHeight; +// LLColor4U mPickColor; + const LLFontGL* mFontp; + const LLFontGL* mBoldFontp; + LLRectf mSoftScreenRect; + LLVector3 mPositionAgent; + LLVector2 mPositionOffset; + LLVector2 mTargetPositionOffset; + F32 mMass; + S32 mMaxLines; + S32 mOffsetY; + F32 mRadius; + std::vector<LLHUDTextSegment> mTextSegments; + std::vector<LLHUDTextSegment> mLabelSegments; +// LLFrameTimer mResizeTimer; + ETextAlignment mTextAlignment; + EVertAlignment mVertAlignment; + S32 mLOD; + BOOL mHidden; + + static BOOL sDisplayText ; + static std::set<LLPointer<LLHUDNameTag> > sTextObjects; + static std::vector<LLPointer<LLHUDNameTag> > sVisibleTextObjects; +// static std::vector<LLPointer<LLHUDNameTag> > sVisibleHUDTextObjects; + typedef std::set<LLPointer<LLHUDNameTag> >::iterator TextObjectIterator; + typedef std::vector<LLPointer<LLHUDNameTag> >::iterator VisibleTextObjectIterator; +}; + +#endif diff --git a/indra/newview/llhudobject.cpp b/indra/newview/llhudobject.cpp index 2b73ed1dcd..d66ac6c5b2 100644 --- a/indra/newview/llhudobject.cpp +++ b/indra/newview/llhudobject.cpp @@ -30,9 +30,6 @@ * $/LicenseInfo$ */ -// llhudobject.cpp -// Copyright 2002, Linden Research, Inc. - #include "llviewerprecompiledheaders.h" #include "llhudobject.h" @@ -44,7 +41,7 @@ #include "llhudeffecttrail.h" #include "llhudeffectlookat.h" #include "llhudeffectpointat.h" - +#include "llhudnametag.h" #include "llvoicevisualizer.h" #include "llagent.h" @@ -72,7 +69,6 @@ LLHUDObject::LLHUDObject(const U8 type) : mVisible = TRUE; mType = type; mDead = FALSE; - mOnHUDAttachment = FALSE; } LLHUDObject::~LLHUDObject() @@ -151,6 +147,9 @@ LLHUDObject *LLHUDObject::addHUDObject(const U8 type) case LL_HUD_ICON: hud_objectp = new LLHUDIcon(type); break; + case LL_HUD_NAME_TAG: + hud_objectp = new LLHUDNameTag(type); + break; default: llwarns << "Unknown type of hud object:" << (U32) type << llendl; } @@ -263,6 +262,7 @@ void LLHUDObject::updateAll() LLFastTimer ftm(FTM_HUD_UPDATE); LLHUDText::updateAll(); LLHUDIcon::updateAll(); + LLHUDNameTag::updateAll(); sortObjects(); } @@ -311,6 +311,14 @@ void LLHUDObject::renderAllForSelect() } // static +void LLHUDObject::reshapeAll() +{ + // only hud objects that use fonts care about window size/scale changes + LLHUDText::reshape(); + LLHUDNameTag::reshape(); +} + +// static void LLHUDObject::sortObjects() { sHUDObjects.sort(hud_object_further_away()); diff --git a/indra/newview/llhudobject.h b/indra/newview/llhudobject.h index d304ac41af..a370b31a20 100644 --- a/indra/newview/llhudobject.h +++ b/indra/newview/llhudobject.h @@ -42,7 +42,7 @@ #include "v4color.h" #include "v3math.h" #include "v3dmath.h" -#include "lldrawpool.h" +#include "lldrawpool.h" // TODO: eliminate, unused below #include <list> class LLViewerCamera; @@ -76,6 +76,9 @@ public: static void renderAll(); static void renderAllForSelect(); + // Some objects may need to update when window shape changes + static void reshapeAll(); + static void cleanupHUDObjects(); enum @@ -96,7 +99,8 @@ public: LL_HUD_EFFECT_EDIT, LL_HUD_EFFECT_LOOKAT, LL_HUD_EFFECT_POINTAT, - LL_HUD_EFFECT_VOICE_VISUALIZER // Ventrella + LL_HUD_EFFECT_VOICE_VISUALIZER, // Ventrella + LL_HUD_NAME_TAG }; protected: static void sortObjects(); @@ -112,7 +116,6 @@ protected: BOOL mDead; BOOL mVisible; LLVector3d mPositionGlobal; - BOOL mOnHUDAttachment; LLPointer<LLViewerObject> mSourceObject; LLPointer<LLViewerObject> mTargetObject; diff --git a/indra/newview/llhudtext.cpp b/indra/newview/llhudtext.cpp index 8d1d27444b..31522f6efb 100644 --- a/indra/newview/llhudtext.cpp +++ b/indra/newview/llhudtext.cpp @@ -1,7 +1,6 @@ - /** * @file llhudtext.cpp - * @brief LLHUDText class implementation + * @brief Floating text above objects, set via script with llSetText() * * $LicenseInfo:firstyear=2002&license=viewergpl$ * @@ -62,16 +61,16 @@ const F32 HORIZONTAL_PADDING = 15.f; const F32 VERTICAL_PADDING = 12.f; const F32 BUFFER_SIZE = 2.f; const F32 MIN_EDGE_OVERLAP = 3.f; -F32 HUD_TEXT_MAX_WIDTH = 190.f; +const F32 HUD_TEXT_MAX_WIDTH = 190.f; const F32 HUD_TEXT_MAX_WIDTH_NO_BUBBLE = 1000.f; const F32 RESIZE_TIME = 0.f; const S32 NUM_OVERLAP_ITERATIONS = 10; const F32 NEIGHBOR_FORCE_FRACTION = 1.f; const F32 POSITION_DAMPING_TC = 0.2f; const F32 MAX_STABLE_CAMERA_VELOCITY = 0.1f; -const F32 LOD_0_SCREEN_COVERAGE = 0.15f; -const F32 LOD_1_SCREEN_COVERAGE = 0.30f; -const F32 LOD_2_SCREEN_COVERAGE = 0.40f; +//const F32 LOD_0_SCREEN_COVERAGE = 0.15f; +//const F32 LOD_1_SCREEN_COVERAGE = 0.30f; +//const F32 LOD_2_SCREEN_COVERAGE = 0.40f; std::set<LLPointer<LLHUDText> > LLHUDText::sTextObjects; std::vector<LLPointer<LLHUDText> > LLHUDText::sVisibleTextObjects; @@ -80,15 +79,14 @@ BOOL LLHUDText::sDisplayText = TRUE ; bool lltextobject_further_away::operator()(const LLPointer<LLHUDText>& lhs, const LLPointer<LLHUDText>& rhs) const { - return (lhs->getDistance() > rhs->getDistance()) ? true : false; + return lhs->getDistance() > rhs->getDistance(); } LLHUDText::LLHUDText(const U8 type) : LLHUDObject(type), - mUseBubble(FALSE), - mUsePixelSize(TRUE), - mVisibleOffScreen(FALSE), + mOnHUDAttachment(FALSE), +// mVisibleOffScreen(FALSE), mWidth(0.f), mHeight(0.f), mFontp(LLFontGL::getFontSansSerifSmall()), @@ -98,7 +96,7 @@ LLHUDText::LLHUDText(const U8 type) : mOffsetY(0), mTextAlignment(ALIGN_TEXT_CENTER), mVertAlignment(ALIGN_VERT_CENTER), - mLOD(0), +// mLOD(0), mHidden(FALSE) { mColor = LLColor4(1.f, 1.f, 1.f, 1.f); @@ -106,7 +104,6 @@ LLHUDText::LLHUDText(const U8 type) : mFadeDistance = 8.f; mFadeRange = 4.f; mZCompare = TRUE; - mDropShadow = TRUE; mOffscreen = FALSE; mRadius = 0.1f; LLPointer<LLHUDText> ptr(this); @@ -117,112 +114,6 @@ LLHUDText::~LLHUDText() { } - -BOOL LLHUDText::lineSegmentIntersect(const LLVector3& start, const LLVector3& end, LLVector3& intersection, BOOL debug_render) -{ - if (!mVisible || mHidden) - { - return FALSE; - } - - // don't pick text that isn't bound to a viewerobject or isn't in a bubble - if (!mSourceObject || mSourceObject->mDrawable.isNull() || !mUseBubble) - { - return FALSE; - } - - F32 alpha_factor = 1.f; - LLColor4 text_color = mColor; - if (mDoFade) - { - if (mLastDistance > mFadeDistance) - { - alpha_factor = llmax(0.f, 1.f - (mLastDistance - mFadeDistance)/mFadeRange); - text_color.mV[3] = text_color.mV[3]*alpha_factor; - } - } - if (text_color.mV[3] < 0.01f) - { - return FALSE; - } - - mOffsetY = lltrunc(mHeight * ((mVertAlignment == ALIGN_VERT_CENTER) ? 0.5f : 1.f)); - - // scale screen size of borders down - //RN: for now, text on hud objects is never occluded - - LLVector3 x_pixel_vec; - LLVector3 y_pixel_vec; - - if (mOnHUDAttachment) - { - x_pixel_vec = LLVector3::y_axis / (F32)gViewerWindow->getWindowWidthScaled(); - y_pixel_vec = LLVector3::z_axis / (F32)gViewerWindow->getWindowHeightScaled(); - } - else - { - LLViewerCamera::getInstance()->getPixelVectors(mPositionAgent, y_pixel_vec, x_pixel_vec); - } - - LLVector3 width_vec = mWidth * x_pixel_vec; - LLVector3 height_vec = mHeight * y_pixel_vec; - - LLCoordGL screen_pos; - LLViewerCamera::getInstance()->projectPosAgentToScreen(mPositionAgent, screen_pos, FALSE); - - LLVector2 screen_offset; - screen_offset = updateScreenPos(mPositionOffset); - - LLVector3 render_position = mPositionAgent - + (x_pixel_vec * screen_offset.mV[VX]) - + (y_pixel_vec * screen_offset.mV[VY]); - - - if (mUseBubble) - { - LLVector3 bg_pos = render_position - + (F32)mOffsetY * y_pixel_vec - - (width_vec / 2.f) - - (height_vec); - //LLUI::translate(bg_pos.mV[VX], bg_pos.mV[VY], bg_pos.mV[VZ]); - - LLVector3 v[] = - { - bg_pos, - bg_pos + width_vec, - bg_pos + width_vec + height_vec, - bg_pos + height_vec, - }; - - if (debug_render) - { - gGL.begin(LLRender::LINE_STRIP); - gGL.vertex3fv(v[0].mV); - gGL.vertex3fv(v[1].mV); - gGL.vertex3fv(v[2].mV); - gGL.vertex3fv(v[3].mV); - gGL.vertex3fv(v[0].mV); - gGL.vertex3fv(v[2].mV); - gGL.end(); - } - - LLVector3 dir = end-start; - F32 t = 0.f; - - if (LLTriangleRayIntersect(v[0], v[1], v[2], start, dir, NULL, NULL, &t, FALSE) || - LLTriangleRayIntersect(v[2], v[3], v[0], start, dir, NULL, NULL, &t, FALSE) ) - { - if (t <= 1.f) - { - intersection = start + dir*t; - return TRUE; - } - } - } - - return FALSE; -} - void LLHUDText::render() { if (!mOnHUDAttachment && sDisplayText) @@ -248,21 +139,13 @@ void LLHUDText::renderText(BOOL for_select) return; } - // don't pick text that isn't bound to a viewerobject or isn't in a bubble - if (for_select && - (!mSourceObject || mSourceObject->mDrawable.isNull() || !mUseBubble)) + // don't pick text + if (for_select) { return; } - if (for_select) - { - gGL.getTexUnit(0)->disable(); - } - else - { - gGL.getTexUnit(0)->enable(LLTexUnit::TT_TEXTURE); - } + gGL.getTexUnit(0)->enable(LLTexUnit::TT_TEXTURE); LLGLState gls_blend(GL_BLEND, for_select ? FALSE : TRUE); LLGLState gls_alpha(GL_ALPHA_TEST, for_select ? FALSE : TRUE); @@ -290,7 +173,7 @@ void LLHUDText::renderText(BOOL for_select) LLUIImagePtr imagep = LLUI::getUIImage("Rounded_Square"); // *TODO: make this a per-text setting - LLColor4 bg_color = LLUIColorTable::instance().getColor("BackgroundChatColor"); + LLColor4 bg_color = LLUIColorTable::instance().getColor("ObjectBubbleColor"); bg_color.setAlpha(gSavedSettings.getF32("ChatBubbleOpacity") * alpha_factor); const S32 border_height = 16; @@ -336,178 +219,17 @@ void LLHUDText::renderText(BOOL for_select) LLViewerCamera::getInstance()->projectPosAgentToScreen(mPositionAgent, screen_pos, FALSE); LLVector2 screen_offset; - if (!mUseBubble) - { - screen_offset = mPositionOffset; - } - else - { - screen_offset = updateScreenPos(mPositionOffset); - } + screen_offset = mPositionOffset; LLVector3 render_position = mPositionAgent + (x_pixel_vec * screen_offset.mV[VX]) + (y_pixel_vec * screen_offset.mV[VY]); - //if (mOnHUD) - //{ - // render_position.mV[VY] -= fmodf(render_position.mV[VY], 1.f / (F32)gViewerWindow->getWindowWidthScaled()); - // render_position.mV[VZ] -= fmodf(render_position.mV[VZ], 1.f / (F32)gViewerWindow->getWindowHeightScaled()); - //} - //else - //{ - // render_position = LLViewerCamera::getInstance()->roundToPixel(render_position); - //} - - if (mUseBubble) - { - LLGLDepthTest gls_depth(GL_TRUE, GL_FALSE); - LLUI::pushMatrix(); - { - LLVector3 bg_pos = render_position - + (F32)mOffsetY * y_pixel_vec - - (width_vec / 2.f) - - (height_vec); - LLUI::translate(bg_pos.mV[VX], bg_pos.mV[VY], bg_pos.mV[VZ]); - - if (for_select) - { - gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); - S32 name = mSourceObject->mGLName; - LLColor4U coloru((U8)(name >> 16), (U8)(name >> 8), (U8)name); - gGL.color4ubv(coloru.mV); - gl_segmented_rect_3d_tex(border_scale_vec, scaled_border_width, scaled_border_height, width_vec, height_vec); - LLUI::popMatrix(); - return; - } - else - { - gGL.getTexUnit(0)->bind(imagep->getImage()); - - gGL.color4fv(bg_color.mV); - gl_segmented_rect_3d_tex(border_scale_vec, scaled_border_width, scaled_border_height, width_vec, height_vec); - - if ( mLabelSegments.size()) - { - LLUI::pushMatrix(); - { - gGL.color4f(text_color.mV[VX], text_color.mV[VY], text_color.mV[VZ], gSavedSettings.getF32("ChatBubbleOpacity") * alpha_factor); - LLVector3 label_height = (mFontp->getLineHeight() * mLabelSegments.size() + (VERTICAL_PADDING / 3.f)) * y_pixel_vec; - LLVector3 label_offset = height_vec - label_height; - LLUI::translate(label_offset.mV[VX], label_offset.mV[VY], label_offset.mV[VZ]); - gl_segmented_rect_3d_tex_top(border_scale_vec, scaled_border_width, scaled_border_height, width_vec, label_height); - } - LLUI::popMatrix(); - } - } - - BOOL outside_width = llabs(mPositionOffset.mV[VX]) > mWidth * 0.5f; - BOOL outside_height = llabs(mPositionOffset.mV[VY] + (mVertAlignment == ALIGN_VERT_TOP ? mHeight * 0.5f : 0.f)) > mHeight * (mVertAlignment == ALIGN_VERT_TOP ? mHeight * 0.75f : 0.5f); - - // draw line segments pointing to parent object - if (!mOffscreen && (outside_width || outside_height)) - { - LLUI::pushMatrix(); - { - gGL.color4fv(bg_color.mV); - LLVector3 target_pos = -1.f * (mPositionOffset.mV[VX] * x_pixel_vec + mPositionOffset.mV[VY] * y_pixel_vec); - target_pos += (width_vec / 2.f); - target_pos += mVertAlignment == ALIGN_VERT_CENTER ? (height_vec * 0.5f) : LLVector3::zero; - target_pos -= 3.f * x_pixel_vec; - target_pos -= 6.f * y_pixel_vec; - LLUI::translate(target_pos.mV[VX], target_pos.mV[VY], target_pos.mV[VZ]); - gl_segmented_rect_3d_tex(border_scale_vec, 3.f * x_pixel_vec, 3.f * y_pixel_vec, 6.f * x_pixel_vec, 6.f * y_pixel_vec); - } - LLUI::popMatrix(); - - gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); - LLGLDepthTest gls_depth(mZCompare ? GL_TRUE : GL_FALSE, GL_FALSE); - - LLVector3 box_center_offset; - box_center_offset = (width_vec * 0.5f) + (height_vec * 0.5f); - LLUI::translate(box_center_offset.mV[VX], box_center_offset.mV[VY], box_center_offset.mV[VZ]); - gGL.color4fv(bg_color.mV); - LLUI::setLineWidth(2.0); - gGL.begin(LLRender::LINES); - { - if (outside_width) - { - LLVector3 vert; - // draw line in x then y - if (mPositionOffset.mV[VX] < 0.f) - { - // start at right edge - vert = width_vec * 0.5f; - gGL.vertex3fv(vert.mV); - } - else - { - // start at left edge - vert = width_vec * -0.5f; - gGL.vertex3fv(vert.mV); - } - vert = -mPositionOffset.mV[VX] * x_pixel_vec; - gGL.vertex3fv(vert.mV); - gGL.vertex3fv(vert.mV); - vert -= mPositionOffset.mV[VY] * y_pixel_vec; - vert -= ((mVertAlignment == ALIGN_VERT_TOP) ? (height_vec * 0.5f) : LLVector3::zero); - gGL.vertex3fv(vert.mV); - } - else - { - LLVector3 vert; - // draw line in y then x - if (mPositionOffset.mV[VY] < 0.f) - { - // start at top edge - vert = (height_vec * 0.5f) - (mPositionOffset.mV[VX] * x_pixel_vec); - gGL.vertex3fv(vert.mV); - } - else - { - // start at bottom edge - vert = (height_vec * -0.5f) - (mPositionOffset.mV[VX] * x_pixel_vec); - gGL.vertex3fv(vert.mV); - } - vert = -mPositionOffset.mV[VY] * y_pixel_vec - mPositionOffset.mV[VX] * x_pixel_vec; - vert -= ((mVertAlignment == ALIGN_VERT_TOP) ? (height_vec * 0.5f) : LLVector3::zero); - gGL.vertex3fv(vert.mV); - } - } - gGL.end(); - LLUI::setLineWidth(1.0); - - } - } - LLUI::popMatrix(); - } - F32 y_offset = (F32)mOffsetY; // Render label { gGL.getTexUnit(0)->setTextureBlendType(LLTexUnit::TB_MULT); - - for(std::vector<LLHUDTextSegment>::iterator segment_iter = mLabelSegments.begin(); - segment_iter != mLabelSegments.end(); ++segment_iter ) - { - const LLFontGL* fontp = (segment_iter->mStyle == LLFontGL::BOLD) ? mBoldFontp : mFontp; - y_offset -= fontp->getLineHeight(); - - F32 x_offset; - if (mTextAlignment == ALIGN_TEXT_CENTER) - { - x_offset = -0.5f*segment_iter->getWidth(fontp); - } - else // ALIGN_LEFT - { - x_offset = -0.5f * mWidth + (HORIZONTAL_PADDING / 2.f); - } - - LLColor4 label_color(0.f, 0.f, 0.f, 1.f); - label_color.mV[VALPHA] = alpha_factor; - hud_render_text(segment_iter->getText(), render_position, *fontp, segment_iter->mStyle, LLFontGL::NO_SHADOW, x_offset, y_offset, label_color, mOnHUDAttachment); - } } // Render text @@ -528,15 +250,11 @@ void LLHUDText::renderText(BOOL for_select) for (std::vector<LLHUDTextSegment>::iterator segment_iter = mTextSegments.begin() + start_segment; segment_iter != mTextSegments.end(); ++segment_iter ) { - const LLFontGL* fontp = (segment_iter->mStyle == LLFontGL::BOLD) ? mBoldFontp : mFontp; + const LLFontGL* fontp = segment_iter->mFont; y_offset -= fontp->getLineHeight(); U8 style = segment_iter->mStyle; - LLFontGL::ShadowType shadow = LLFontGL::NO_SHADOW; - if (mDropShadow) - { - shadow = LLFontGL::DROP_SHADOW; - } + LLFontGL::ShadowType shadow = LLFontGL::DROP_SHADOW; F32 x_offset; if (mTextAlignment== ALIGN_TEXT_CENTER) @@ -556,21 +274,12 @@ void LLHUDText::renderText(BOOL for_select) } /// Reset the default color to white. The renderer expects this to be the default. gGL.color4f(1.0f, 1.0f, 1.0f, 1.0f); - if (for_select) - { - gGL.getTexUnit(0)->enable(LLTexUnit::TT_TEXTURE); - } -} - -void LLHUDText::setStringUTF8(const std::string &wtext) -{ - setString(utf8str_to_wstring(wtext)); } -void LLHUDText::setString(const LLWString &wtext) +void LLHUDText::setString(const std::string &text_utf8) { mTextSegments.clear(); - addLine(wtext, mColor); + addLine(text_utf8, mColor); } void LLHUDText::clearString() @@ -579,21 +288,19 @@ void LLHUDText::clearString() } -void LLHUDText::addLine(const std::string &str, const LLColor4& color, const LLFontGL::StyleFlags style) +void LLHUDText::addLine(const std::string &text_utf8, + const LLColor4& color, + const LLFontGL::StyleFlags style, + const LLFontGL* font) { - addLine(utf8str_to_wstring(str), color, style); -} - - -void LLHUDText::addLine(const LLWString &wstr, const LLColor4& color, const LLFontGL::StyleFlags style) -{ - if (gNoRender) - { - return; - } - if (!wstr.empty()) + LLWString wline = utf8str_to_wstring(text_utf8); + if (!wline.empty()) { - LLWString wline(wstr); + // use default font for segment if custom font not specified + if (!font) + { + font = mFontp; + } typedef boost::tokenizer<boost::char_separator<llwchar>, LLWString::const_iterator, LLWString > tokenizer; LLWString seps(utf8str_to_wstring("\r\n")); boost::char_separator<llwchar> sep(seps.c_str()); @@ -606,8 +313,10 @@ void LLHUDText::addLine(const LLWString &wstr, const LLColor4& color, const LLFo U32 line_length = 0; do { - S32 segment_length = mFontp->maxDrawableChars(iter->substr(line_length).c_str(), mUseBubble ? HUD_TEXT_MAX_WIDTH : HUD_TEXT_MAX_WIDTH_NO_BUBBLE, wline.length(), LLFontGL::WORD_BOUNDARY_IF_POSSIBLE); - mTextSegments.push_back(LLHUDTextSegment(iter->substr(line_length, segment_length), style, color)); + F32 max_pixels = HUD_TEXT_MAX_WIDTH_NO_BUBBLE; + S32 segment_length = font->maxDrawableChars(iter->substr(line_length).c_str(), max_pixels, wline.length(), LLFontGL::WORD_BOUNDARY_IF_POSSIBLE); + LLHUDTextSegment segment(iter->substr(line_length, segment_length), style, color, font); + mTextSegments.push_back(segment); line_length += segment_length; } while (line_length != iter->size()); @@ -616,47 +325,6 @@ void LLHUDText::addLine(const LLWString &wstr, const LLColor4& color, const LLFo } } -void LLHUDText::setLabel(const std::string &label) -{ - setLabel(utf8str_to_wstring(label)); -} - -void LLHUDText::setLabel(const LLWString &wlabel) -{ - mLabelSegments.clear(); - - if (!wlabel.empty()) - { - LLWString wstr(wlabel); - LLWString seps(utf8str_to_wstring("\r\n")); - LLWString empty; - - typedef boost::tokenizer<boost::char_separator<llwchar>, LLWString::const_iterator, LLWString > tokenizer; - boost::char_separator<llwchar> sep(seps.c_str(), empty.c_str(), boost::keep_empty_tokens); - - tokenizer tokens(wstr, sep); - tokenizer::iterator iter = tokens.begin(); - - while (iter != tokens.end()) - { - U32 line_length = 0; - do - { - S32 segment_length = mFontp->maxDrawableChars(iter->substr(line_length).c_str(), mUseBubble ? HUD_TEXT_MAX_WIDTH : HUD_TEXT_MAX_WIDTH_NO_BUBBLE, wstr.length(), LLFontGL::WORD_BOUNDARY_IF_POSSIBLE); - mLabelSegments.push_back(LLHUDTextSegment(iter->substr(line_length, segment_length), LLFontGL::NORMAL, mColor)); - line_length += segment_length; - } - while (line_length != iter->size()); - ++iter; - } - } -} - -void LLHUDText::setDropShadow(const BOOL do_shadow) -{ - mDropShadow = do_shadow; -} - void LLHUDText::setZCompare(const BOOL zcompare) { mZCompare = zcompare; @@ -678,12 +346,17 @@ void LLHUDText::setColor(const LLColor4 &color) } } - -void LLHUDText::setUsePixelSize(const BOOL use_pixel_size) +void LLHUDText::setAlpha(F32 alpha) { - mUsePixelSize = use_pixel_size; + mColor.mV[VALPHA] = alpha; + for (std::vector<LLHUDTextSegment>::iterator segment_iter = mTextSegments.begin(); + segment_iter != mTextSegments.end(); ++segment_iter ) + { + segment_iter->mColor.mV[VALPHA] = alpha; + } } + void LLHUDText::setDoFade(const BOOL do_fade) { mDoFade = do_fade; @@ -751,7 +424,7 @@ void LLHUDText::updateVisibility() mLastDistance = (mPositionAgent - LLViewerCamera::getInstance()->getOrigin()).magVec(); - if (mLOD >= 3 || !mTextSegments.size() || (mDoFade && (mLastDistance > mFadeDistance + mFadeRange))) + if (!mTextSegments.size() || (mDoFade && (mLastDistance > mFadeDistance + mFadeRange))) { mVisible = FALSE; return; @@ -769,15 +442,15 @@ void LLHUDText::updateVisibility() mOffscreen = FALSE; if (!LLViewerCamera::getInstance()->sphereInFrustum(render_position, mRadius)) { - if (!mVisibleOffScreen) - { +// if (!mVisibleOffScreen) +// { mVisible = FALSE; return; - } - else - { - mOffscreen = TRUE; - } +// } +// else +// { +// mOffscreen = TRUE; +// } } mVisible = TRUE; @@ -792,11 +465,11 @@ LLVector2 LLHUDText::updateScreenPos(LLVector2 &offset) LLVector3 y_pixel_vec; LLViewerCamera::getInstance()->getPixelVectors(mPositionAgent, y_pixel_vec, x_pixel_vec); LLVector3 world_pos = mPositionAgent + (offset.mV[VX] * x_pixel_vec) + (offset.mV[VY] * y_pixel_vec); - if (!LLViewerCamera::getInstance()->projectPosAgentToScreen(world_pos, screen_pos, FALSE) && mVisibleOffScreen) - { - // bubble off-screen, so find a spot for it along screen edge - LLViewerCamera::getInstance()->projectPosAgentToScreenEdge(world_pos, screen_pos); - } +// if (!LLViewerCamera::getInstance()->projectPosAgentToScreen(world_pos, screen_pos, FALSE) && mVisibleOffScreen) +// { +// // bubble off-screen, so find a spot for it along screen edge +// LLViewerCamera::getInstance()->projectPosAgentToScreenEdge(world_pos, screen_pos); +// } screen_pos_vec.setVec((F32)screen_pos.mX, (F32)screen_pos.mY); @@ -827,12 +500,12 @@ LLVector2 LLHUDText::updateScreenPos(LLVector2 &offset) void LLHUDText::updateSize() { + F32 height = 0.f; F32 width = 0.f; S32 max_lines = getMaxLines(); - S32 lines = (max_lines < 0) ? (S32)mTextSegments.size() : llmin((S32)mTextSegments.size(), max_lines); - - F32 height = (F32)mFontp->getLineHeight() * (lines + mLabelSegments.size()); + //S32 lines = (max_lines < 0) ? (S32)mTextSegments.size() : llmin((S32)mTextSegments.size(), max_lines); + //F32 height = (F32)mFontp->getLineHeight() * (lines + mLabelSegments.size()); S32 start_segment; if (max_lines < 0) start_segment = 0; @@ -841,17 +514,12 @@ void LLHUDText::updateSize() std::vector<LLHUDTextSegment>::iterator iter = mTextSegments.begin() + start_segment; while (iter != mTextSegments.end()) { - width = llmax(width, llmin(iter->getWidth(mFontp), HUD_TEXT_MAX_WIDTH)); + const LLFontGL* fontp = iter->mFont; + height += fontp->getLineHeight(); + width = llmax(width, llmin(iter->getWidth(fontp), HUD_TEXT_MAX_WIDTH)); ++iter; } - iter = mLabelSegments.begin(); - while (iter != mLabelSegments.end()) - { - width = llmax(width, llmin(iter->getWidth(mFontp), HUD_TEXT_MAX_WIDTH)); - ++iter; - } - if (width == 0.f) { return; @@ -860,18 +528,8 @@ void LLHUDText::updateSize() width += HORIZONTAL_PADDING; height += VERTICAL_PADDING; - if (!mResizeTimer.getStarted() && (width != mWidth || height != mHeight)) - { - mResizeTimer.start(); - } - - // *NOTE: removed logic which did a divide by zero. - F32 u = 1.f;//llclamp(mResizeTimer.getElapsedTimeF32() / RESIZE_TIME, 0.f, 1.f); - if (u == 1.f) - { - mResizeTimer.stop(); - } - + // *TODO: Could do some sort of timer-based resize logic here + F32 u = 1.f; mWidth = llmax(width, lerp(mWidth, (F32)width, u)); mHeight = llmax(height, lerp(mHeight, (F32)height, u)); } @@ -895,146 +553,31 @@ void LLHUDText::updateAll() // sort back to front for rendering purposes std::sort(sVisibleTextObjects.begin(), sVisibleTextObjects.end(), lltextobject_further_away()); std::sort(sVisibleHUDTextObjects.begin(), sVisibleHUDTextObjects.end(), lltextobject_further_away()); - - // iterate from front to back, and set LOD based on current screen coverage - F32 screen_area = (F32)(gViewerWindow->getWindowWidthScaled() * gViewerWindow->getWindowHeightScaled()); - F32 current_screen_area = 0.f; - std::vector<LLPointer<LLHUDText> >::reverse_iterator r_it; - for (r_it = sVisibleTextObjects.rbegin(); r_it != sVisibleTextObjects.rend(); ++r_it) - { - LLHUDText* textp = (*r_it); - if (textp->mUseBubble) - { - if (current_screen_area / screen_area > LOD_2_SCREEN_COVERAGE) - { - textp->setLOD(3); - } - else if (current_screen_area / screen_area > LOD_1_SCREEN_COVERAGE) - { - textp->setLOD(2); - } - else if (current_screen_area / screen_area > LOD_0_SCREEN_COVERAGE) - { - textp->setLOD(1); - } - else - { - textp->setLOD(0); - } - textp->updateSize(); - // find on-screen position and initialize collision rectangle - textp->mTargetPositionOffset = textp->updateScreenPos(LLVector2::zero); - current_screen_area += (F32)(textp->mSoftScreenRect.getWidth() * textp->mSoftScreenRect.getHeight()); - } - } - - LLStat* camera_vel_stat = LLViewerCamera::getInstance()->getVelocityStat(); - F32 camera_vel = camera_vel_stat->getCurrent(); - if (camera_vel > MAX_STABLE_CAMERA_VELOCITY) - { - return; - } - - VisibleTextObjectIterator src_it; - - for (S32 i = 0; i < NUM_OVERLAP_ITERATIONS; i++) - { - for (src_it = sVisibleTextObjects.begin(); src_it != sVisibleTextObjects.end(); ++src_it) - { - LLHUDText* src_textp = (*src_it); - - if (!src_textp->mUseBubble) - { - continue; - } - VisibleTextObjectIterator dst_it = src_it; - ++dst_it; - for (; dst_it != sVisibleTextObjects.end(); ++dst_it) - { - LLHUDText* dst_textp = (*dst_it); - - if (!dst_textp->mUseBubble) - { - continue; - } - if (src_textp->mSoftScreenRect.overlaps(dst_textp->mSoftScreenRect)) - { - LLRectf intersect_rect = src_textp->mSoftScreenRect; - intersect_rect.intersectWith(dst_textp->mSoftScreenRect); - intersect_rect.stretch(-BUFFER_SIZE * 0.5f); - - F32 src_center_x = src_textp->mSoftScreenRect.getCenterX(); - F32 src_center_y = src_textp->mSoftScreenRect.getCenterY(); - F32 dst_center_x = dst_textp->mSoftScreenRect.getCenterX(); - F32 dst_center_y = dst_textp->mSoftScreenRect.getCenterY(); - F32 intersect_center_x = intersect_rect.getCenterX(); - F32 intersect_center_y = intersect_rect.getCenterY(); - LLVector2 force = lerp(LLVector2(dst_center_x - intersect_center_x, dst_center_y - intersect_center_y), - LLVector2(intersect_center_x - src_center_x, intersect_center_y - src_center_y), - 0.5f); - force.setVec(dst_center_x - src_center_x, dst_center_y - src_center_y); - force.normVec(); - - LLVector2 src_force = -1.f * force; - LLVector2 dst_force = force; - - LLVector2 force_strength; - F32 src_mult = dst_textp->mMass / (dst_textp->mMass + src_textp->mMass); - F32 dst_mult = 1.f - src_mult; - F32 src_aspect_ratio = src_textp->mSoftScreenRect.getWidth() / src_textp->mSoftScreenRect.getHeight(); - F32 dst_aspect_ratio = dst_textp->mSoftScreenRect.getWidth() / dst_textp->mSoftScreenRect.getHeight(); - src_force.mV[VY] *= src_aspect_ratio; - src_force.normVec(); - dst_force.mV[VY] *= dst_aspect_ratio; - dst_force.normVec(); - - src_force.mV[VX] *= llmin(intersect_rect.getWidth() * src_mult, intersect_rect.getHeight() * SPRING_STRENGTH); - src_force.mV[VY] *= llmin(intersect_rect.getHeight() * src_mult, intersect_rect.getWidth() * SPRING_STRENGTH); - dst_force.mV[VX] *= llmin(intersect_rect.getWidth() * dst_mult, intersect_rect.getHeight() * SPRING_STRENGTH); - dst_force.mV[VY] *= llmin(intersect_rect.getHeight() * dst_mult, intersect_rect.getWidth() * SPRING_STRENGTH); - - src_textp->mTargetPositionOffset += src_force; - dst_textp->mTargetPositionOffset += dst_force; - src_textp->mTargetPositionOffset = src_textp->updateScreenPos(src_textp->mTargetPositionOffset); - dst_textp->mTargetPositionOffset = dst_textp->updateScreenPos(dst_textp->mTargetPositionOffset); - } - } - } - } - - VisibleTextObjectIterator this_object_it; - for (this_object_it = sVisibleTextObjects.begin(); this_object_it != sVisibleTextObjects.end(); ++this_object_it) - { - if (!(*this_object_it)->mUseBubble) - { - continue; - } - (*this_object_it)->mPositionOffset = lerp((*this_object_it)->mPositionOffset, (*this_object_it)->mTargetPositionOffset, LLCriticalDamp::getInterpolant(POSITION_DAMPING_TC)); - } } -void LLHUDText::setLOD(S32 lod) -{ - mLOD = lod; - //RN: uncomment this to visualize LOD levels - //std::string label = llformat("%d", lod); - //setLabel(label); -} +//void LLHUDText::setLOD(S32 lod) +//{ +// mLOD = lod; +// //RN: uncomment this to visualize LOD levels +// //std::string label = llformat("%d", lod); +// //setLabel(label); +//} S32 LLHUDText::getMaxLines() { - switch(mLOD) - { - case 0: - return mMaxLines; - case 1: - return mMaxLines > 0 ? mMaxLines / 2 : 5; - case 2: - return mMaxLines > 0 ? mMaxLines / 3 : 2; - default: - // label only - return 0; - } + return mMaxLines; + //switch(mLOD) + //{ + //case 0: + // return mMaxLines; + //case 1: + // return mMaxLines > 0 ? mMaxLines / 2 : 5; + //case 2: + // return mMaxLines > 0 ? mMaxLines / 3 : 2; + //default: + // // label only + // return 0; + //} } void LLHUDText::markDead() @@ -1085,22 +628,6 @@ void LLHUDText::shift(const LLVector3& offset) mPositionAgent += offset; } -//static -void LLHUDText::addPickable(std::set<LLViewerObject*> &pick_list) -{ - //this might put an object on the pick list a second time, overriding it's mGLName, which is ok - // *FIX: we should probably cull against pick frustum - VisibleTextObjectIterator text_it; - for (text_it = sVisibleTextObjects.begin(); text_it != sVisibleTextObjects.end(); ++text_it) - { - if (!(*text_it)->mUseBubble) - { - continue; - } - pick_list.insert((*text_it)->mSourceObject); - } -} - //static // called when UI scale changes, to flush font width caches void LLHUDText::reshape() @@ -1115,11 +642,6 @@ void LLHUDText::reshape() { segment_iter->clearFontWidthMap(); } - for(segment_iter = textp->mLabelSegments.begin(); - segment_iter != textp->mLabelSegments.end(); ++segment_iter ) - { - segment_iter->clearFontWidthMap(); - } } } diff --git a/indra/newview/llhudtext.h b/indra/newview/llhudtext.h index dc14a8c764..27b8f07cca 100644 --- a/indra/newview/llhudtext.h +++ b/indra/newview/llhudtext.h @@ -34,18 +34,15 @@ #define LL_LLHUDTEXT_H #include "llpointer.h" -#include "lldarrayptr.h" #include "llhudobject.h" #include "v4color.h" #include "v4coloru.h" #include "v2math.h" #include "llrect.h" -#include "llframetimer.h" #include "llfontgl.h" #include <set> #include <vector> -#include "lldarray.h" // Renders a 2D text billboard floating at the location specified. class LLDrawable; @@ -62,14 +59,19 @@ protected: class LLHUDTextSegment { public: - LLHUDTextSegment(const LLWString& text, const LLFontGL::StyleFlags style, const LLColor4& color) - : mColor(color), mStyle(style), mText(text) {} + LLHUDTextSegment(const LLWString& text, const LLFontGL::StyleFlags style, const LLColor4& color, const LLFontGL* font) + : mColor(color), + mStyle(style), + mText(text), + mFont(font) + {} F32 getWidth(const LLFontGL* font); - const LLWString& getText() const { return mText; }; + const LLWString& getText() const { return mText; } void clearFontWidthMap() { mFontWidthMap.clear(); } LLColor4 mColor; LLFontGL::StyleFlags mStyle; + const LLFontGL* mFont; private: LLWString mText; std::map<const LLFontGL*, F32> mFontWidthMap; @@ -89,20 +91,21 @@ public: } EVertAlignment; public: - void setStringUTF8(const std::string &utf8string); - void setString(const LLWString &wstring); + // Set entire string, eliminating existing lines + void setString(const std::string& text_utf8); + void clearString(); - void addLine(const std::string &text, const LLColor4& color, const LLFontGL::StyleFlags style = LLFontGL::NORMAL); - void addLine(const LLWString &wtext, const LLColor4& color, const LLFontGL::StyleFlags style = LLFontGL::NORMAL); - void setLabel(const std::string &label); - void setLabel(const LLWString &label); - void setDropShadow(const BOOL do_shadow); + + // Add text a line at a time, allowing custom formatting + void addLine(const std::string &text_utf8, const LLColor4& color, const LLFontGL::StyleFlags style = LLFontGL::NORMAL, const LLFontGL* font = NULL); + + // Sets the default font for lines with no font specified void setFont(const LLFontGL* font); void setColor(const LLColor4 &color); - void setUsePixelSize(const BOOL use_pixel_size); + void setAlpha(F32 alpha); void setZCompare(const BOOL zcompare); void setDoFade(const BOOL do_fade); - void setVisibleOffScreen(BOOL visible) { mVisibleOffScreen = visible; } +// void setVisibleOffScreen(BOOL visible) { mVisibleOffScreen = visible; } // mMaxLines of -1 means unlimited lines. void setMaxLines(S32 max_lines) { mMaxLines = max_lines; } @@ -116,21 +119,17 @@ public: /*virtual*/ void markDead(); friend class LLHUDObject; /*virtual*/ F32 getDistance() const { return mLastDistance; } - void setUseBubble(BOOL use_bubble) { mUseBubble = use_bubble; } - S32 getLOD() { return mLOD; } BOOL getVisible() { return mVisible; } BOOL getHidden() const { return mHidden; } void setHidden( BOOL hide ) { mHidden = hide; } void setOnHUDAttachment(BOOL on_hud) { mOnHUDAttachment = on_hud; } void shift(const LLVector3& offset); - BOOL lineSegmentIntersect(const LLVector3& start, const LLVector3& end, LLVector3& intersection, BOOL debug_render = FALSE); - static void shiftAll(const LLVector3& offset); static void renderAllHUD(); - static void addPickable(std::set<LLViewerObject*> &pick_list); static void reshape(); static void setDisplayText(BOOL flag) { sDisplayText = flag ; } + protected: LLHUDText(const U8 type); @@ -138,21 +137,17 @@ protected: /*virtual*/ void renderForSelect(); void renderText(BOOL for_select); static void updateAll(); - void setLOD(S32 lod); S32 getMaxLines(); private: ~LLHUDText(); - BOOL mOnHUD; - BOOL mUseBubble; - BOOL mDropShadow; + BOOL mOnHUDAttachment; BOOL mDoFade; F32 mFadeRange; F32 mFadeDistance; F32 mLastDistance; - BOOL mUsePixelSize; BOOL mZCompare; - BOOL mVisibleOffScreen; +// BOOL mVisibleOffScreen; BOOL mOffscreen; LLColor4 mColor; LLVector3 mScale; @@ -170,11 +165,8 @@ private: S32 mOffsetY; F32 mRadius; std::vector<LLHUDTextSegment> mTextSegments; - std::vector<LLHUDTextSegment> mLabelSegments; - LLFrameTimer mResizeTimer; ETextAlignment mTextAlignment; EVertAlignment mVertAlignment; - S32 mLOD; BOOL mHidden; static BOOL sDisplayText ; diff --git a/indra/newview/llimview.cpp b/indra/newview/llimview.cpp index 15dbc03f70..e8215a462e 100644 --- a/indra/newview/llimview.cpp +++ b/indra/newview/llimview.cpp @@ -34,6 +34,7 @@ #include "llimview.h" +#include "llavatarnamecache.h" // IDEVO #include "llfloaterreg.h" #include "llfontgl.h" #include "llgl.h" @@ -631,7 +632,7 @@ bool LLIMModel::clearSession(const LLUUID& session_id) void LLIMModel::getMessagesSilently(const LLUUID& session_id, std::list<LLSD>& messages, int start_index) { LLIMSession* session = findIMSession(session_id); - if (!session) + if (!session) { llwarns << "session " << session_id << "does not exist " << llendl; return; @@ -639,7 +640,7 @@ void LLIMModel::getMessagesSilently(const LLUUID& session_id, std::list<LLSD>& m int i = session->mMsgs.size() - start_index; - for (std::list<LLSD>::iterator iter = session->mMsgs.begin(); + for (std::list<LLSD>::iterator iter = session->mMsgs.begin(); iter != session->mMsgs.end() && i > 0; iter++) { @@ -1908,6 +1909,11 @@ BOOL LLIncomingCallDialog::postBuild() { caller_name = LLTextUtil::formatPhoneNumber(caller_name); } + else + { + // IDEVO + caller_name = LLCacheName::cleanFullName(caller_name); + } setTitle(caller_name + " " + call_type); @@ -2036,6 +2042,13 @@ void LLIncomingCallDialog::processCallResponse(S32 response) { if (gCacheName->getFullName(caller_id, correct_session_name)) { + // IDEVO really should be using callbacks here + LLAvatarName av_name; + if (LLAvatarNameCache::useDisplayNames() + && LLAvatarNameCache::get(caller_id, &av_name)) + { + correct_session_name = av_name.mDisplayName + " (" + av_name.mSLID + ")"; + } correct_session_name.append(ADHOC_NAME_SUFFIX); } } @@ -2547,7 +2560,8 @@ void LLIMMgr::inviteToSession( { if (caller_name.empty()) { - gCacheName->get(caller_id, FALSE, boost::bind(&LLIMMgr::onInviteNameLookup, payload, _1, _2, _3, _4)); + gCacheName->get(caller_id, false, + boost::bind(&LLIMMgr::onInviteNameLookup, payload, _1, _2, _3)); } else { @@ -2557,9 +2571,9 @@ void LLIMMgr::inviteToSession( } } -void LLIMMgr::onInviteNameLookup(LLSD payload, const LLUUID& id, const std::string& first, const std::string& last, BOOL is_group) +void LLIMMgr::onInviteNameLookup(LLSD payload, const LLUUID& id, const std::string& name, bool is_group) { - payload["caller_name"] = first + " " + last; + payload["caller_name"] = name; payload["session_name"] = payload["caller_name"].asString(); std::string notify_box_type = payload["notify_box_type"].asString(); @@ -2780,13 +2794,12 @@ void LLIMMgr::noteOfflineUsers( for(S32 i = 0; i < count; ++i) { info = at.getBuddyInfo(ids.get(i)); - std::string first, last; + std::string full_name; if(info && !info->isOnline() - && gCacheName->getName(ids.get(i), first, last)) + && gCacheName->getFullName(ids.get(i), full_name)) { LLUIString offline = LLTrans::getString("offline_message"); - offline.setArg("[FIRST]", first); - offline.setArg("[LAST]", last); + offline.setArg("[NAME]", full_name); im_model.proccessOnlineOfflineNotification(session_id, offline); } } diff --git a/indra/newview/llimview.h b/indra/newview/llimview.h index ffa8a16797..758ea667ef 100644 --- a/indra/newview/llimview.h +++ b/indra/newview/llimview.h @@ -458,7 +458,7 @@ private: void processIMTypingCore(const LLIMInfo* im_info, BOOL typing); - static void onInviteNameLookup(LLSD payload, const LLUUID& id, const std::string& first, const std::string& last, BOOL is_group); + static void onInviteNameLookup(LLSD payload, const LLUUID& id, const std::string& name, bool is_group); void notifyObserverSessionAdded(const LLUUID& session_id, const std::string& name, const LLUUID& other_participant_id); void notifyObserverSessionRemoved(const LLUUID& session_id); diff --git a/indra/newview/llinspectavatar.cpp b/indra/newview/llinspectavatar.cpp index e48bb77bda..5ce99914fe 100644 --- a/indra/newview/llinspectavatar.cpp +++ b/indra/newview/llinspectavatar.cpp @@ -37,6 +37,7 @@ #include "llagent.h" #include "llagentdata.h" #include "llavataractions.h" +#include "llavatarnamecache.h" #include "llavatarpropertiesprocessor.h" #include "llcallingcard.h" #include "lldateutil.h" @@ -144,11 +145,11 @@ private: bool isNotFriend(); // Callback for gCacheName to look up avatar name - void nameUpdatedCallback( - const LLUUID& id, - const std::string& first, - const std::string& last, - BOOL is_group); + void onNameCache(const LLUUID& id, + const std::string& name, + bool is_group); + void onAvatarNameCache(const LLUUID& agent_id, + const LLAvatarName& av_name); private: LLUUID mAvatarID; @@ -336,6 +337,7 @@ void LLInspectAvatar::requestUpdate() // Clear out old data so it doesn't flash between old and new getChild<LLUICtrl>("user_name")->setValue(""); + getChild<LLUICtrl>("user_slid")->setValue(""); getChild<LLUICtrl>("user_subtitle")->setValue(""); getChild<LLUICtrl>("user_details")->setValue(""); @@ -373,9 +375,19 @@ void LLInspectAvatar::requestUpdate() childSetValue("avatar_icon", LLSD(mAvatarID) ); - gCacheName->get(mAvatarID, FALSE, - boost::bind(&LLInspectAvatar::nameUpdatedCallback, - this, _1, _2, _3, _4)); + // JAMESDEBUG HACK: Request via both legacy name system and new + // name system to set mAvatarName for not-yet-converted friendship + // request system. + gCacheName->get(mAvatarID, false, + boost::bind(&LLInspectAvatar::onNameCache, + this, _1, _2, _3)); + + if (LLAvatarNameCache::useDisplayNames()) + { + LLAvatarNameCache::get(mAvatarID, + boost::bind(&LLInspectAvatar::onAvatarNameCache, + this, _1, _2)); + } } void LLInspectAvatar::processAvatarData(LLAvatarData* data) @@ -612,16 +624,33 @@ void LLInspectAvatar::onVolumeChange(const LLSD& data) gVoiceClient->setUserVolume(mAvatarID, volume); } -void LLInspectAvatar::nameUpdatedCallback( +void LLInspectAvatar::onNameCache( const LLUUID& id, - const std::string& first, - const std::string& last, - BOOL is_group) + const std::string& full_name, + bool is_group) { if (id == mAvatarID) { - mAvatarName = first + " " + last; - childSetValue("user_name", LLSD(mAvatarName) ); + mAvatarName = full_name; + + // IDEVO JAMESDEBUG - need to always display a display name + if (!LLAvatarNameCache::useDisplayNames()) + { + getChild<LLUICtrl>("user_name")->setValue(full_name); + getChild<LLUICtrl>("user_slid")->setValue(""); + } + } +} + +void LLInspectAvatar::onAvatarNameCache( + const LLUUID& agent_id, + const LLAvatarName& av_name) +{ + if (agent_id == mAvatarID) + { + // JAMESDEBUG what to do about mAvatarName ? + getChild<LLUICtrl>("user_name")->setValue(av_name.mDisplayName); + getChild<LLUICtrl>("user_slid")->setValue(av_name.mSLID); } } diff --git a/indra/newview/llinspectgroup.cpp b/indra/newview/llinspectgroup.cpp index 7fd7b69021..364da3f64c 100644 --- a/indra/newview/llinspectgroup.cpp +++ b/indra/newview/llinspectgroup.cpp @@ -84,9 +84,8 @@ public: // Callback for gCacheName to look up group name // Faster than waiting for group properties to return void nameUpdatedCallback(const LLUUID& id, - const std::string& first, - const std::string& last, - BOOL is_group); + const std::string& name, + bool is_group); // Button/menu callbacks void onClickViewProfile(); @@ -225,21 +224,19 @@ void LLInspectGroup::requestUpdate() mPropertiesRequest = new LLFetchGroupData(mGroupID, this); // Name lookup will be faster out of cache, use that - gCacheName->get(mGroupID, TRUE, + gCacheName->get(mGroupID, true, boost::bind(&LLInspectGroup::nameUpdatedCallback, - this, _1, _2, _3, _4)); + this, _1, _2, _3)); } void LLInspectGroup::nameUpdatedCallback( const LLUUID& id, - const std::string& first, - const std::string& last, - BOOL is_group) + const std::string& name, + bool is_group) { if (id == mGroupID) { - // group names are returned as a first name - childSetValue("group_name", LLSD(first) ); + childSetValue("group_name", LLSD(name) ); } // Otherwise possibly a request for an older inspector, ignore it diff --git a/indra/newview/llinspectremoteobject.cpp b/indra/newview/llinspectremoteobject.cpp index 66e4a1bf66..e91f68f0c9 100644 --- a/indra/newview/llinspectremoteobject.cpp +++ b/indra/newview/llinspectremoteobject.cpp @@ -66,7 +66,7 @@ public: private: void update(); - static void nameCallback(const LLUUID& id, const std::string& first, const std::string& last, BOOL is_group, void* data); + void onNameCache(const LLUUID& id, const std::string& name, bool is_group); private: LLUUID mObjectID; @@ -121,7 +121,8 @@ void LLInspectRemoteObject::onOpen(const LLSD& data) mOwner = ""; if (gCacheName) { - gCacheName->get(mOwnerID, mGroupOwned, nameCallback, this); + gCacheName->get(mOwnerID, mGroupOwned, + boost::bind(&LLInspectRemoteObject::onNameCache, this, _1, _2, _3)); } // update the inspector with the current object state @@ -152,16 +153,10 @@ void LLInspectRemoteObject::onClickClose() closeFloater(); } -//static -void LLInspectRemoteObject::nameCallback(const LLUUID& id, const std::string& first, const std::string& last, BOOL is_group, void* data) +void LLInspectRemoteObject::onNameCache(const LLUUID& id, const std::string& name, bool is_group) { - LLInspectRemoteObject *self = (LLInspectRemoteObject*)data; - self->mOwner = first; - if (!last.empty()) - { - self->mOwner += " " + last; - } - self->update(); + mOwner = name; + update(); } void LLInspectRemoteObject::update() diff --git a/indra/newview/llinventorybridge.cpp b/indra/newview/llinventorybridge.cpp index b9b195c89a..f6e839e2f8 100644 --- a/indra/newview/llinventorybridge.cpp +++ b/indra/newview/llinventorybridge.cpp @@ -35,6 +35,7 @@ // external projects #include "lltransfersourceasset.h" +#include "llavatarnamecache.h" // IDEVO #include "llagent.h" #include "llagentcamera.h" @@ -3672,6 +3673,13 @@ void LLCallingCardBridge::performAction(LLInventoryModel* model, std::string act { std::string callingcard_name; gCacheName->getFullName(item->getCreatorUUID(), callingcard_name); + // IDEVO + LLAvatarName av_name; + if (LLAvatarNameCache::useDisplayNames() + && LLAvatarNameCache::get(item->getCreatorUUID(), &av_name)) + { + callingcard_name = av_name.mDisplayName + " (" + av_name.mSLID + ")"; + } LLUUID session_id = gIMMgr->addSession(callingcard_name, IM_NOTHING_SPECIAL, item->getCreatorUUID()); if (session_id != LLUUID::null) { diff --git a/indra/newview/llinventorymodel.cpp b/indra/newview/llinventorymodel.cpp index 6452ae82f8..43ce45da7c 100644 --- a/indra/newview/llinventorymodel.cpp +++ b/indra/newview/llinventorymodel.cpp @@ -740,7 +740,8 @@ U32 LLInventoryModel::updateItem(const LLViewerInventoryItem* item) new_item->setCreator(id); std::string avatar_name; // Fetch the currect name - gCacheName->get(id, FALSE, boost::bind(&LLViewerInventoryItem::onCallingCardNameLookup, new_item.get(), _1, _2, _3)); + gCacheName->get(id, false, + boost::bind(&LLViewerInventoryItem::onCallingCardNameLookup, new_item.get(), _1, _2, _3)); } } else if (new_item->getType() == LLAssetType::AT_GESTURE) diff --git a/indra/newview/lllogininstance.cpp b/indra/newview/lllogininstance.cpp index 454fd29fdc..1878c1e9d3 100644 --- a/indra/newview/lllogininstance.cpp +++ b/indra/newview/lllogininstance.cpp @@ -120,15 +120,33 @@ LLSD LLLoginInstance::getResponse() void LLLoginInstance::constructAuthParams(const LLSD& credentials) { + // *Note: this is where gUserAuth used to be created. + // Set up auth request options. -//#define LL_MINIMIAL_REQUESTED_OPTIONS LLSD requested_options; - // *Note: this is where gUserAuth used to be created. + requested_options.append("global-textures"); requested_options.append("inventory-root"); requested_options.append("inventory-skeleton"); //requested_options.append("inventory-meat"); //requested_options.append("inventory-skel-targets"); + requested_options.append("login-flags"); + +//#define LL_MINIMIAL_REQUESTED_OPTIONS #if (!defined LL_MINIMIAL_REQUESTED_OPTIONS) + // *NOTE: Keep alphabetized for easier merges + requested_options.append("adult_compliant"); + requested_options.append("buddy-list"); + requested_options.append("classified_categories"); + requested_options.append("display_names"); + requested_options.append("event_categories"); + requested_options.append("event_notifications"); + requested_options.append("gestures"); + if(gSavedSettings.getBOOL("ConnectAsGod")) + { + gSavedSettings.setBOOL("UseDebugMenus", TRUE); + requested_options.append("god-connect"); + } + requested_options.append("initial-outfit"); if(FALSE == gSavedSettings.getBOOL("NoInventoryLibrary")) { requested_options.append("inventory-lib-root"); @@ -136,25 +154,11 @@ void LLLoginInstance::constructAuthParams(const LLSD& credentials) requested_options.append("inventory-skel-lib"); // requested_options.append("inventory-meat-lib"); } - - requested_options.append("initial-outfit"); - requested_options.append("gestures"); - requested_options.append("event_categories"); - requested_options.append("event_notifications"); - requested_options.append("classified_categories"); - requested_options.append("adult_compliant"); //requested_options.append("inventory-targets"); - requested_options.append("buddy-list"); + requested_options.append("tutorial_setting"); requested_options.append("ui-config"); + // *NOTE: Keep alphabetized for easier merges #endif - requested_options.append("tutorial_setting"); - requested_options.append("login-flags"); - requested_options.append("global-textures"); - if(gSavedSettings.getBOOL("ConnectAsGod")) - { - gSavedSettings.setBOOL("UseDebugMenus", TRUE); - requested_options.append("god-connect"); - } char hashed_mac_string[MD5HEX_STR_SIZE]; /* Flawfinder: ignore */ LLMD5 hashed_mac; diff --git a/indra/newview/llmutelist.cpp b/indra/newview/llmutelist.cpp index 7cb192e026..7126914260 100644 --- a/indra/newview/llmutelist.cpp +++ b/indra/newview/llmutelist.cpp @@ -118,9 +118,8 @@ LLMute::LLMute(const LLUUID& id, const std::string& name, EType type, U32 flags) LLNameValue* lastname = mute_object->getNVPair("LastName"); if (firstname && lastname) { - mName.assign( firstname->getString() ); - mName.append(" "); - mName.append( lastname->getString() ); + mName = LLCacheName::buildFullName( + firstname->getString(), lastname->getString()); } mType = mute_object->isAvatar() ? AGENT : OBJECT; } @@ -416,7 +415,7 @@ void LLMuteList::updateRemove(const LLMute& mute) gAgent.sendReliableMessage(); } -void notify_automute_callback(const LLUUID& agent_id, const std::string& first_name, const std::string& last_name, BOOL is_group, LLMuteList::EAutoReason reason) +void notify_automute_callback(const LLUUID& agent_id, const std::string& full_name, bool is_group, LLMuteList::EAutoReason reason) { std::string notif_name; switch (reason) @@ -434,8 +433,7 @@ void notify_automute_callback(const LLUUID& agent_id, const std::string& first_n } LLSD args; - args["FIRST"] = first_name; - args["LAST"] = last_name; + args["NAME"] = full_name; LLNotificationPtr notif_ptr = LLNotifications::instance().add(notif_name, args, LLSD()); if (notif_ptr) @@ -450,7 +448,7 @@ void notify_automute_callback(const LLUUID& agent_id, const std::string& first_n } -BOOL LLMuteList::autoRemove(const LLUUID& agent_id, const EAutoReason reason, const std::string& first_name, const std::string& last_name) +BOOL LLMuteList::autoRemove(const LLUUID& agent_id, const EAutoReason reason) { BOOL removed = FALSE; @@ -460,24 +458,17 @@ BOOL LLMuteList::autoRemove(const LLUUID& agent_id, const EAutoReason reason, co removed = TRUE; remove(automute); - if (first_name.empty() && last_name.empty()) - { - std::string cache_first, cache_last; - if (gCacheName->getName(agent_id, cache_first, cache_last)) + std::string full_name; + if (gCacheName->getFullName(agent_id, full_name)) { // name in cache, call callback directly - notify_automute_callback(agent_id, cache_first, cache_last, FALSE, reason); + notify_automute_callback(agent_id, full_name, false, reason); } else { // not in cache, lookup name from cache - gCacheName->get(agent_id, FALSE, boost::bind(¬ify_automute_callback, _1, _2, _3, _4, reason)); - } - } - else - { - // call callback directly - notify_automute_callback(agent_id, first_name, last_name, FALSE, reason); + gCacheName->get(agent_id, false, + boost::bind(¬ify_automute_callback, _1, _2, _3, reason)); } } diff --git a/indra/newview/llmutelist.h b/indra/newview/llmutelist.h index 79b556bdbb..ad4fd2345d 100644 --- a/indra/newview/llmutelist.h +++ b/indra/newview/llmutelist.h @@ -69,7 +69,7 @@ public: public: LLUUID mID; // agent or object id - std::string mName; // agent or object name + std::string mName; // agent or object name, does not store last name "Resident" EType mType; // needed for UI display of existing mutes U32 mFlags; // flags pertaining to this mute entry }; @@ -102,7 +102,7 @@ public: // Remove both normal and legacy mutes, for any or all properties. BOOL remove(const LLMute& mute, U32 flags = 0); - BOOL autoRemove(const LLUUID& agent_id, const EAutoReason reason, const std::string& first_name = LLStringUtil::null, const std::string& last_name = LLStringUtil::null); + BOOL autoRemove(const LLUUID& agent_id, const EAutoReason reason); // Name is required to test against legacy text-only mutes. BOOL isMuted(const LLUUID& id, const std::string& name = LLStringUtil::null, U32 flags = 0) const; diff --git a/indra/newview/llnamebox.cpp b/indra/newview/llnamebox.cpp index cd810b9793..da3e95e947 100644 --- a/indra/newview/llnamebox.cpp +++ b/indra/newview/llnamebox.cpp @@ -87,26 +87,15 @@ void LLNameBox::setNameID(const LLUUID& name_id, BOOL is_group) setText(mInitialValue); } -void LLNameBox::refresh(const LLUUID& id, const std::string& firstname, - const std::string& lastname, BOOL is_group) +void LLNameBox::refresh(const LLUUID& id, const std::string& full_name, bool is_group) { if (id == mNameID) { - std::string name; - if (!is_group) - { - name = firstname + " " + lastname; - } - else - { - name = firstname; - } - setName(name, is_group); + setName(full_name, is_group); } } -void LLNameBox::refreshAll(const LLUUID& id, const std::string& firstname, - const std::string& lastname, BOOL is_group) +void LLNameBox::refreshAll(const LLUUID& id, const std::string& full_name, bool is_group) { std::set<LLNameBox*>::iterator it; for (it = LLNameBox::sInstances.begin(); @@ -114,7 +103,7 @@ void LLNameBox::refreshAll(const LLUUID& id, const std::string& firstname, ++it) { LLNameBox* box = *it; - box->refresh(id, firstname, lastname, is_group); + box->refresh(id, full_name, is_group); } } diff --git a/indra/newview/llnamebox.h b/indra/newview/llnamebox.h index 48b54faec8..2fe8990653 100644 --- a/indra/newview/llnamebox.h +++ b/indra/newview/llnamebox.h @@ -59,10 +59,9 @@ public: void setNameID(const LLUUID& name_id, BOOL is_group); - void refresh(const LLUUID& id, const std::string& first, const std::string& last, BOOL is_group); + void refresh(const LLUUID& id, const std::string& full_name, bool is_group); - static void refreshAll(const LLUUID& id, const std::string& firstname, - const std::string& lastname, BOOL is_group); + static void refreshAll(const LLUUID& id, const std::string& full_name, bool is_group); protected: LLNameBox (const Params&); diff --git a/indra/newview/llnameeditor.cpp b/indra/newview/llnameeditor.cpp index 65601da7da..0c704a1f56 100644 --- a/indra/newview/llnameeditor.cpp +++ b/indra/newview/llnameeditor.cpp @@ -81,26 +81,15 @@ void LLNameEditor::setNameID(const LLUUID& name_id, BOOL is_group) setText(name); } -void LLNameEditor::refresh(const LLUUID& id, const std::string& firstname, - const std::string& lastname, BOOL is_group) +void LLNameEditor::refresh(const LLUUID& id, const std::string& full_name, bool is_group) { if (id == mNameID) { - std::string name; - if (!is_group) - { - name = firstname + " " + lastname; - } - else - { - name = firstname; - } - setText(name); + setText(full_name); } } -void LLNameEditor::refreshAll(const LLUUID& id, const std::string& firstname, - const std::string& lastname, BOOL is_group) +void LLNameEditor::refreshAll(const LLUUID& id, const std::string& full_name, bool is_group) { std::set<LLNameEditor*>::iterator it; for (it = LLNameEditor::sInstances.begin(); @@ -108,7 +97,7 @@ void LLNameEditor::refreshAll(const LLUUID& id, const std::string& firstname, ++it) { LLNameEditor* box = *it; - box->refresh(id, firstname, lastname, is_group); + box->refresh(id, full_name, is_group); } } diff --git a/indra/newview/llnameeditor.h b/indra/newview/llnameeditor.h index 99e03a1166..a75c492aca 100644 --- a/indra/newview/llnameeditor.h +++ b/indra/newview/llnameeditor.h @@ -65,10 +65,9 @@ public: void setNameID(const LLUUID& name_id, BOOL is_group); - void refresh(const LLUUID& id, const std::string& first, const std::string& last, BOOL is_group); + void refresh(const LLUUID& id, const std::string& full_name, bool is_group); - static void refreshAll(const LLUUID& id, const std::string& firstname, - const std::string& lastname, BOOL is_group); + static void refreshAll(const LLUUID& id, const std::string& full_name, bool is_group); // Take/return agent UUIDs diff --git a/indra/newview/llnamelistctrl.cpp b/indra/newview/llnamelistctrl.cpp index d605d4430e..c5706e8345 100644 --- a/indra/newview/llnamelistctrl.cpp +++ b/indra/newview/llnamelistctrl.cpp @@ -356,22 +356,11 @@ void LLNameListCtrl::removeNameItem(const LLUUID& agent_id) } // public -void LLNameListCtrl::refresh(const LLUUID& id, const std::string& first, - const std::string& last, BOOL is_group) +void LLNameListCtrl::refresh(const LLUUID& id, const std::string& full_name, bool is_group) { //llinfos << "LLNameListCtrl::refresh " << id << " '" << first << " " // << last << "'" << llendl; - std::string fullname; - if (!is_group) - { - fullname = first + " " + last; - } - else - { - fullname = first; - } - // TODO: scan items for that ID, fix if necessary item_list::iterator iter; for (iter = getItemList().begin(); iter != getItemList().end(); iter++) @@ -382,7 +371,7 @@ void LLNameListCtrl::refresh(const LLUUID& id, const std::string& first, LLScrollListCell* cell = item->getColumn(mNameColumnIndex); if (cell) { - cell->setValue(fullname); + cell->setValue(full_name); } } } @@ -392,15 +381,14 @@ void LLNameListCtrl::refresh(const LLUUID& id, const std::string& first, // static -void LLNameListCtrl::refreshAll(const LLUUID& id, const std::string& first, - const std::string& last, BOOL is_group) +void LLNameListCtrl::refreshAll(const LLUUID& id, const std::string& full_name, bool is_group) { LLInstanceTrackerScopedGuard guard; LLInstanceTracker<LLNameListCtrl>::instance_iter it; for (it = guard.beginInstances(); it != guard.endInstances(); ++it) { LLNameListCtrl& ctrl = *it; - ctrl.refresh(id, first, last, is_group); + ctrl.refresh(id, full_name, is_group); } } diff --git a/indra/newview/llnamelistctrl.h b/indra/newview/llnamelistctrl.h index 1c26ee5db4..6d61214712 100644 --- a/indra/newview/llnamelistctrl.h +++ b/indra/newview/llnamelistctrl.h @@ -105,10 +105,9 @@ public: void removeNameItem(const LLUUID& agent_id); - void refresh(const LLUUID& id, const std::string& first, const std::string& last, BOOL is_group); + void refresh(const LLUUID& id, const std::string& full_name, bool is_group); - static void refreshAll(const LLUUID& id, const std::string& firstname, - const std::string& lastname, BOOL is_group); + static void refreshAll(const LLUUID& id, const std::string& full_name, bool is_group); // LLView interface /*virtual*/ BOOL handleDragAndDrop(S32 x, S32 y, MASK mask, diff --git a/indra/newview/llnotificationhandlerutil.cpp b/indra/newview/llnotificationhandlerutil.cpp index 95b946f307..2ca2df152b 100644 --- a/indra/newview/llnotificationhandlerutil.cpp +++ b/indra/newview/llnotificationhandlerutil.cpp @@ -113,8 +113,11 @@ void LLSysHandler::removeExclusiveNotifications(const LLNotificationPtr& notif) } const static std::string GRANTED_MODIFY_RIGHTS("GrantedModifyRights"), - REVOKED_MODIFY_RIGHTS("RevokedModifyRights"), OBJECT_GIVE_ITEM( - "ObjectGiveItem"), PAYMENT_RECIVED("PaymentRecived"), + REVOKED_MODIFY_RIGHTS("RevokedModifyRights"), + OBJECT_GIVE_ITEM("ObjectGiveItem"), + OBJECT_GIVE_ITEM_UNKNOWN_USER("ObjectGiveItemUnknownUser"), + PAYMENT_RECEIVED("PaymentReceived"), + PAYMENT_SENT("PaymentSent"), ADD_FRIEND_WITH_MESSAGE("AddFriendWithMessage"), USER_GIVE_ITEM("UserGiveItem"), INVENTORY_ACCEPTED("InventoryAccepted"), @@ -136,7 +139,8 @@ bool LLHandlerUtil::canLogToIM(const LLNotificationPtr& notification) { return GRANTED_MODIFY_RIGHTS == notification->getName() || REVOKED_MODIFY_RIGHTS == notification->getName() - || PAYMENT_RECIVED == notification->getName() + || PAYMENT_RECEIVED == notification->getName() + || PAYMENT_SENT == notification->getName() || OFFER_FRIENDSHIP == notification->getName() || FRIENDSHIP_OFFERED == notification->getName() || FRIENDSHIP_ACCEPTED == notification->getName() diff --git a/indra/newview/llpanelavatar.cpp b/indra/newview/llpanelavatar.cpp index dd632ccefe..e3628f4763 100644 --- a/indra/newview/llpanelavatar.cpp +++ b/indra/newview/llpanelavatar.cpp @@ -224,12 +224,11 @@ void LLPanelAvatarNotes::rightsConfirmationCallback(const LLSD& notification, void LLPanelAvatarNotes::confirmModifyRights(bool grant, S32 rights) { - std::string first, last; + std::string full_name; LLSD args; - if (gCacheName->getName(getAvatarId(), first, last)) + if (gCacheName->getFullName(getAvatarId(), full_name)) { - args["FIRST_NAME"] = first; - args["LAST_NAME"] = last; + args["NAME"] = full_name; } if (grant) diff --git a/indra/newview/llpanelavatartag.cpp b/indra/newview/llpanelavatartag.cpp index 7563cc7f61..173fb851ce 100644 --- a/indra/newview/llpanelavatartag.cpp +++ b/indra/newview/llpanelavatartag.cpp @@ -86,7 +86,7 @@ void LLPanelAvatarTag::setAvatarId(const LLUUID& avatar_id) { mIcon->setValue(avatar_id); } - setName(std::string(mIcon->getFirstName()+ " "+ mIcon->getLastName())); + setName(std::string(mIcon->getFullName())); } boost::signals2::connection LLPanelAvatarTag::setLeftButtonClickCallback( diff --git a/indra/newview/llpanelgroupinvite.cpp b/indra/newview/llpanelgroupinvite.cpp index 11d3768a3d..38922e1b99 100644 --- a/indra/newview/llpanelgroupinvite.cpp +++ b/indra/newview/llpanelgroupinvite.cpp @@ -404,16 +404,18 @@ void LLPanelGroupInvite::addUsers(uuid_vec_t& agent_ids) std::vector<std::string> names; for (S32 i = 0; i < (S32)agent_ids.size(); i++) { + std::string fullname; LLUUID agent_id = agent_ids[i]; LLViewerObject* dest = gObjectList.findObject(agent_id); - std::string fullname; if(dest && dest->isAvatar()) { LLNameValue* nvfirst = dest->getNVPair("FirstName"); LLNameValue* nvlast = dest->getNVPair("LastName"); if(nvfirst && nvlast) { - fullname = std::string(nvfirst->getString()) + " " + std::string(nvlast->getString()); + fullname = LLCacheName::buildFullName( + nvfirst->getString(), nvlast->getString()); + } if (!fullname.empty()) { @@ -436,8 +438,7 @@ void LLPanelGroupInvite::addUsers(uuid_vec_t& agent_ids) { // actually it should happen, just in case gCacheName->get(LLUUID(agent_id), false, boost::bind( - &LLPanelGroupInvite::addUserCallback, this, _1, _2, - _3)); + &LLPanelGroupInvite::addUserCallback, this, _1, _2)); // for this special case! //when there is no cached name we should remove resident from agent_ids list to avoid breaking of sequence // removed id will be added in callback @@ -453,16 +454,16 @@ void LLPanelGroupInvite::addUsers(uuid_vec_t& agent_ids) mImplementation->addUsers(names, agent_ids); } -void LLPanelGroupInvite::addUserCallback(const LLUUID& id, const std::string& first_name, const std::string& last_name) +void LLPanelGroupInvite::addUserCallback(const LLUUID& id, const std::string& full_name) { std::vector<std::string> names; uuid_vec_t agent_ids; - std::string full_name = first_name + " " + last_name; agent_ids.push_back(id); - names.push_back(first_name + " " + last_name); + names.push_back(full_name); mImplementation->addUsers(names, agent_ids); } + void LLPanelGroupInvite::draw() { LLPanel::draw(); diff --git a/indra/newview/llpanelgroupinvite.h b/indra/newview/llpanelgroupinvite.h index 2ed443ed46..520107c33a 100644 --- a/indra/newview/llpanelgroupinvite.h +++ b/indra/newview/llpanelgroupinvite.h @@ -46,7 +46,7 @@ public: /** * this callback is being used to add a user whose fullname isn't been loaded before invoking of addUsers(). */ - void addUserCallback(const LLUUID& id, const std::string& first_name, const std::string& last_name); + void addUserCallback(const LLUUID& id, const std::string& full_name); void clear(); void update(); diff --git a/indra/newview/llpanelgroupnotices.cpp b/indra/newview/llpanelgroupnotices.cpp index 230e484fad..265505ea9b 100644 --- a/indra/newview/llpanelgroupnotices.cpp +++ b/indra/newview/llpanelgroupnotices.cpp @@ -36,6 +36,7 @@ #include "llview.h" +#include "llcachename.h" #include "llinventory.h" #include "llviewerinventory.h" #include "llinventorydefines.h" @@ -546,6 +547,9 @@ void LLPanelGroupNotices::processNotices(LLMessageSystem* msg) msg->getU8("Data","AssetType",asset_type,i); msg->getU32("Data","Timestamp",timestamp,i); + // IDEVO clean up legacy "Resident" names + name = LLCacheName::cleanFullName(name); + LLSD row; row["id"] = id; diff --git a/indra/newview/llpanelimcontrolpanel.cpp b/indra/newview/llpanelimcontrolpanel.cpp index c34f0633b9..ed1de8d612 100644 --- a/indra/newview/llpanelimcontrolpanel.cpp +++ b/indra/newview/llpanelimcontrolpanel.cpp @@ -184,7 +184,7 @@ void LLPanelIMControlPanel::onViewProfileButtonClicked() void LLPanelIMControlPanel::onAddFriendButtonClicked() { LLAvatarIconCtrl* avatar_icon = getChild<LLAvatarIconCtrl>("avatar_icon"); - std::string full_name = avatar_icon->getFirstName() + " " + avatar_icon->getLastName(); + std::string full_name = avatar_icon->getFullName(); LLAvatarActions::requestFriendshipDialog(mAvatarID, full_name); } @@ -226,6 +226,15 @@ void LLPanelIMControlPanel::setSessionId(const LLUUID& session_id) childSetEnabled("share_btn", FALSE); childSetEnabled("teleport_btn", FALSE); childSetEnabled("pay_btn", FALSE); + + getChild<LLTextBox>("avatar_name")->setValue(im_session->mName); + getChild<LLTextBox>("avatar_name")->setToolTip(im_session->mName); + } + else + { + // If the participant is an avatar, fetch the currect name + gCacheName->get(mAvatarID, false, + boost::bind(&LLPanelIMControlPanel::onNameCache, this, _1, _2, _3)); } } @@ -241,6 +250,16 @@ void LLPanelIMControlPanel::changed(U32 mask) } } +void LLPanelIMControlPanel::onNameCache(const LLUUID& id, const std::string& full_name, bool is_group) +{ + if ( id == mAvatarID ) + { + std::string avatar_name = full_name; + getChild<LLTextBox>("avatar_name")->setValue(avatar_name); + getChild<LLTextBox>("avatar_name")->setToolTip(avatar_name); + } +} + LLPanelGroupControlPanel::LLPanelGroupControlPanel(const LLUUID& session_id): mParticipantList(NULL) { diff --git a/indra/newview/llpanelimcontrolpanel.h b/indra/newview/llpanelimcontrolpanel.h index ce8fc58e56..45f4b95903 100644 --- a/indra/newview/llpanelimcontrolpanel.h +++ b/indra/newview/llpanelimcontrolpanel.h @@ -89,6 +89,9 @@ public: // LLFriendObserver trigger virtual void changed(U32 mask); +protected: + void onNameCache(const LLUUID& id, const std::string& full_name, bool is_group); + private: void onViewProfileButtonClicked(); void onAddFriendButtonClicked(); diff --git a/indra/newview/llpanellandmarkinfo.cpp b/indra/newview/llpanellandmarkinfo.cpp index 4ffd43cb0f..c03bc82904 100644 --- a/indra/newview/llpanellandmarkinfo.cpp +++ b/indra/newview/llpanellandmarkinfo.cpp @@ -45,6 +45,7 @@ #include "llagent.h" #include "llagentui.h" #include "lllandmarkactions.h" +#include "llslurl.h" #include "llviewerinventory.h" #include "llviewerparcelmgr.h" #include "llviewerregion.h" @@ -231,13 +232,15 @@ void LLPanelLandmarkInfo::displayItemInfo(const LLInventoryItem* pItem) ////////////////// if (pItem->getCreatorUUID().notNull()) { - std::string name; + // IDEVO LLUUID creator_id = pItem->getCreatorUUID(); - if (!gCacheName->getFullName(creator_id, name)) - { - gCacheName->get(creator_id, FALSE, - boost::bind(&LLPanelPlaceInfo::nameUpdatedCallback, mCreator, _2, _3)); - } + std::string name = + LLSLURL::buildCommand("agent", creator_id, "inspect"); + //if (!gCacheName->getFullName(creator_id, name)) + //{ + // gCacheName->get(creator_id, FALSE, + // boost::bind(&LLPanelPlaceInfo::nameUpdatedCallback, mCreator, _2, _3)); + //} mCreator->setText(name); } else @@ -254,20 +257,24 @@ void LLPanelLandmarkInfo::displayItemInfo(const LLInventoryItem* pItem) if (perm.isGroupOwned()) { LLUUID group_id = perm.getGroup(); - if (!gCacheName->getGroupName(group_id, name)) - { - gCacheName->get(group_id, TRUE, - boost::bind(&LLPanelPlaceInfo::nameUpdatedCallback, mOwner, _2, _3)); - } + // IDEVO + //if (!gCacheName->getGroupName(group_id, name)) + //{ + // gCacheName->get(group_id, TRUE, + // boost::bind(&LLPanelPlaceInfo::nameUpdatedCallback, mOwner, _2, _3)); + //} + name = LLSLURL::buildCommand("group", group_id, "inspect"); } else { LLUUID owner_id = perm.getOwner(); - if (!gCacheName->getFullName(owner_id, name)) - { - gCacheName->get(owner_id, FALSE, - boost::bind(&LLPanelPlaceInfo::nameUpdatedCallback, mOwner, _2, _3)); - } + // IDEVO + //if (!gCacheName->getFullName(owner_id, name)) + //{ + // gCacheName->get(owner_id, FALSE, + // boost::bind(&LLPanelPlaceInfo::nameUpdatedCallback, mOwner, _2, _3)); + //} + name = LLSLURL::buildCommand("agent", owner_id, "inspect"); } mOwner->setText(name); } diff --git a/indra/newview/llpanellogin.cpp b/indra/newview/llpanellogin.cpp index 67aea5544d..840becd44f 100644 --- a/indra/newview/llpanellogin.cpp +++ b/indra/newview/llpanellogin.cpp @@ -213,7 +213,7 @@ LLPanelLogin::LLPanelLogin(const LLRect &rect, } #if !USE_VIEWER_AUTH - childSetPrevalidate("first_name_edit", LLTextValidate::validateASCIIPrintableNoSpace); + //childSetPrevalidate("login_id_edit", LLTextValidate::validateASCIIPrintableNoSpace); childSetPrevalidate("last_name_edit", LLTextValidate::validateASCIIPrintableNoSpace); childSetCommitCallback("password_edit", mungePassword, this); @@ -493,7 +493,7 @@ void LLPanelLogin::giveFocus() if( sInstance ) { // Grab focus and move cursor to first blank input field - std::string first = sInstance->childGetText("first_name_edit"); + std::string first = sInstance->childGetText("login_id_edit"); std::string pass = sInstance->childGetText("password_edit"); BOOL have_first = !first.empty(); @@ -509,7 +509,7 @@ void LLPanelLogin::giveFocus() else { // User doesn't have a name, so start there. - edit = sInstance->getChild<LLLineEditor>("first_name_edit"); + edit = sInstance->getChild<LLLineEditor>("login_id_edit"); } if (edit) @@ -531,8 +531,8 @@ void LLPanelLogin::showLoginWidgets() // *TODO: Append all the usual login parameters, like first_login=Y etc. std::string splash_screen_url = sInstance->getString("real_url"); web_browser->navigateTo( splash_screen_url, "text/html" ); - LLUICtrl* first_name_edit = sInstance->getChild<LLUICtrl>("first_name_edit"); - first_name_edit->setFocus(TRUE); + LLUICtrl* login_id_edit = sInstance->getChild<LLUICtrl>("login_id_edit"); + login_id_edit->setFocus(TRUE); } // static @@ -564,8 +564,15 @@ void LLPanelLogin::setFields(const std::string& firstname, return; } - sInstance->childSetText("first_name_edit", firstname); - sInstance->childSetText("last_name_edit", lastname); + std::string login_id = firstname; + if (!lastname.empty() && lastname != "Resident") + { + // support traditional First Last name slurls + login_id += " "; + login_id += lastname; + } + sInstance->childSetText("login_id_edit", login_id); + sInstance->childSetText("last_name_edit", std::string()); // Max "actual" password length is 16 characters. // Hex digests are always 32 characters. @@ -618,10 +625,24 @@ void LLPanelLogin::getFields(std::string *firstname, return; } - *firstname = sInstance->childGetText("first_name_edit"); - LLStringUtil::trim(*firstname); + std::string login_id = sInstance->childGetText("login_id_edit"); + LLStringUtil::trim(login_id); - *lastname = sInstance->childGetText("last_name_edit"); + U32 pos = login_id.find(' '); + if (pos != std::string::npos) + { + // old-style Firstname Lastname + *firstname = login_id.substr(0, pos); + *lastname = login_id.substr(pos+1); + } + else + { + // new-style single SLID string + *firstname = login_id; + *lastname = "Resident"; + } + + LLStringUtil::trim(*firstname); LLStringUtil::trim(*lastname); *password = sInstance->mMungedPassword; @@ -909,8 +930,10 @@ void LLPanelLogin::onClickConnect(void *) // JC - Make sure the fields all get committed. sInstance->setFocus(FALSE); - std::string first = sInstance->childGetText("first_name_edit"); - std::string last = sInstance->childGetText("last_name_edit"); + // Do SLID "Resident" name mangling + std::string first, last, unused_password; + getFields(&first, &last, &unused_password); + LLComboBox* combo = sInstance->getChild<LLComboBox>("start_location_combo"); std::string combo_text = combo->getSimple(); diff --git a/indra/newview/llpanelme.cpp b/indra/newview/llpanelme.cpp index 3f620869e0..483741e643 100644 --- a/indra/newview/llpanelme.cpp +++ b/indra/newview/llpanelme.cpp @@ -32,17 +32,25 @@ #include "llviewerprecompiledheaders.h" +#include "llpanelme.h" + +// Viewer includes #include "llpanelprofile.h" #include "llavatarconstants.h" -#include "llpanelme.h" #include "llagent.h" #include "llagentcamera.h" #include "llagentwearables.h" -#include "lliconctrl.h" #include "llsidetray.h" +#include "llviewercontrol.h" +#include "llviewerdisplayname.h" + +// Linden libraries +#include "llavatarnamecache.h" // IDEVO +#include "lliconctrl.h" +#include "llnotifications.h" +#include "llnotificationsutil.h" // IDEVO #include "lltabcontainer.h" #include "lltexturectrl.h" -#include "llviewercontrol.h" #define PICKER_SECOND_LIFE "2nd_life_pic" #define PICKER_FIRST_LIFE "real_world_pic" @@ -180,6 +188,13 @@ void LLPanelMyProfileEdit::onOpen(const LLSD& key) // Disable editing until data is loaded, or edited fields will be overwritten when data // is loaded. enableEditing(false); + + // Only allow changing name if this region/grid supports it + bool use_display_names = LLAvatarNameCache::useDisplayNames(); + LLUICtrl* set_name = getChild<LLUICtrl>("set_name"); + set_name->setVisible(use_display_names); + set_name->setEnabled(use_display_names); + LLPanelMyProfile::onOpen(getAvatarId()); } @@ -213,13 +228,21 @@ void LLPanelMyProfileEdit::processProfileProperties(const LLAvatarData* avatar_d childSetValue("show_in_search_checkbox", (BOOL)(avatar_data->flags & AVATAR_ALLOW_PUBLISH)); - std::string first, last; - BOOL found = gCacheName->getName(avatar_data->avatar_id, first, last); - if (found) - { - childSetTextArg("name_text", "[FIRST]", first); - childSetTextArg("name_text", "[LAST]", last); - } + // IDEVO - These fields do not seem to exist any more. + //std::string full_name; + //BOOL found = gCacheName->getFullName(avatar_data->avatar_id, full_name); + //if (found) + //{ + // childSetTextArg("name_text", "[NAME]", full_name); + //} + LLAvatarNameCache::get(avatar_data->avatar_id, + boost::bind(&LLPanelMyProfileEdit::onNameCache, this, _1, _2)); +} + +void LLPanelMyProfileEdit::onNameCache(const LLUUID& agent_id, const LLAvatarName& av_name) +{ + getChild<LLUICtrl>("user_name")->setValue( av_name.mDisplayName ); + getChild<LLUICtrl>("user_slid")->setValue( av_name.mSLID ); } BOOL LLPanelMyProfileEdit::postBuild() @@ -229,6 +252,9 @@ BOOL LLPanelMyProfileEdit::postBuild() childSetTextArg("partner_edit_link", "[URL]", getString("partner_edit_link_url")); childSetTextArg("my_account_link", "[URL]", getString("my_account_link_url")); + getChild<LLUICtrl>("set_name")->setCommitCallback( + boost::bind(&LLPanelMyProfileEdit::onClickSetName, this)); + return LLPanelAvatarProfile::postBuild(); } /** @@ -256,8 +282,10 @@ void LLPanelMyProfileEdit::resetData() { LLPanelMyProfile::resetData(); - childSetTextArg("name_text", "[FIRST]", LLStringUtil::null); - childSetTextArg("name_text", "[LAST]", LLStringUtil::null); + //childSetTextArg("name_text", "[FIRST]", LLStringUtil::null); + //childSetTextArg("name_text", "[LAST]", LLStringUtil::null); + getChild<LLUICtrl>("user_name")->setValue( LLSD() ); + getChild<LLUICtrl>("user_slid")->setValue( LLSD() ); } void LLPanelMyProfileEdit::onTexturePickerMouseEnter(LLUICtrl* ctrl) @@ -269,6 +297,95 @@ void LLPanelMyProfileEdit::onTexturePickerMouseLeave(LLUICtrl* ctrl) mTextureEditIconMap[ctrl->getName()]->setVisible(FALSE); } +void LLPanelMyProfileEdit::onCacheSetName(bool success, + const std::string& reason, + const LLSD& content) +{ + if (success) + { + // Inform the user that the change took place, but will take a while + // to percolate. + LLSD args; + // *TODO: get estimated percolation time from service + S32 timeout_hours = 72; + args["HOURS"] = llformat("%d", timeout_hours); + LLNotificationsUtil::add("SetDisplayNameSuccess", args); + + // Re-fetch my name, as it may have been sanitized by the service + LLAvatarNameCache::get(getAvatarId(), + boost::bind(&LLPanelMyProfileEdit::onNameCache, this, _1, _2)); + return; + } + + // Request failed, notify the user + std::string error_tag = content["error_tag"].asString(); + llinfos << "set name failure error_tag " << error_tag << llendl; + + // We might have a localized string for this message + if (!error_tag.empty() + && LLNotifications::getInstance()->templateExists(error_tag)) + { + LLNotificationsUtil::add(error_tag); + return; + } + + // The server error might have a localized message for us + std::string lang_code = LLUI::getLanguage(); + LLSD error_desc = content["error_description"]; + if (error_desc.has( lang_code )) + { + LLSD args; + args["MESSAGE"] = error_desc[lang_code].asString(); + LLNotificationsUtil::add("GenericAlert", args); + return; + } + + // No specific error, throw a generic one + LLNotificationsUtil::add("SetDisplayNameFailedGeneric"); +} + +void LLPanelMyProfileEdit::onDialogSetName(const LLSD& notification, const LLSD& response) +{ + S32 option = LLNotificationsUtil::getSelectedOption(notification, response); + if (option == 0) + { + LLUUID agent_id = notification["payload"]["agent_id"]; + if (agent_id.isNull()) return; + + std::string display_name = response["display_name"].asString(); + LLViewerDisplayName::set(display_name, + boost::bind(&LLPanelMyProfileEdit::onCacheSetName, this, + _1, _2, _3)); + } +} + +void LLPanelMyProfileEdit::onClickSetName() +{ + // IDEVO + LLUUID agent_id = getAvatarId(); + std::string display_name; + LLAvatarName av_name; + if (LLAvatarNameCache::useDisplayNames() + && LLAvatarNameCache::get(agent_id, &av_name)) + { + display_name = av_name.mDisplayName; + } + else + { + gCacheName->getFullName(agent_id, display_name); + } + + if (!display_name.empty()) + { + LLSD args; + args["DISPLAY_NAME"] = display_name; + LLSD payload; + payload["agent_id"] = agent_id; + LLNotificationsUtil::add("SetDisplayName", args, payload, + boost::bind(&LLPanelMyProfileEdit::onDialogSetName, this, _1, _2)); + } +} + void LLPanelMyProfileEdit::enableEditing(bool enable) { childSetEnabled("2nd_life_pic", enable); diff --git a/indra/newview/llpanelme.h b/indra/newview/llpanelme.h index f2b38de3d6..f3caf026dc 100644 --- a/indra/newview/llpanelme.h +++ b/indra/newview/llpanelme.h @@ -34,8 +34,9 @@ #define LL_LLPANELMEPROFILE_H #include "llpanel.h" -#include "llpanelavatar.h" +#include "llpanelprofile.h" +class LLAvatarName; class LLPanelMyProfileEdit; class LLPanelProfile; class LLIconCtrl; @@ -89,11 +90,15 @@ protected: /*virtual*/void resetData(); void processProfileProperties(const LLAvatarData* avatar_data); + void onNameCache(const LLUUID& agent_id, const LLAvatarName& av_name); private: void initTexturePickerMouseEvents(); void onTexturePickerMouseEnter(LLUICtrl* ctrl); void onTexturePickerMouseLeave(LLUICtrl* ctrl); + void onClickSetName(); + void onDialogSetName(const LLSD& notification, const LLSD& response); + void onCacheSetName(bool success, const std::string& reason, const LLSD& content); /** * Enabled/disables controls to prevent overwriting edited data upon receiving diff --git a/indra/newview/llpanelmediasettingspermissions.cpp b/indra/newview/llpanelmediasettingspermissions.cpp index e5caaaaffc..227dbb3da7 100644 --- a/indra/newview/llpanelmediasettingspermissions.cpp +++ b/indra/newview/llpanelmediasettingspermissions.cpp @@ -115,7 +115,7 @@ void LLPanelMediaSettingsPermissions::draw() if(mPermsGroupName) { mPermsGroupName->setNameID(LLUUID::null, TRUE); - mPermsGroupName->refresh(LLUUID::null, LLStringUtil::null, LLStringUtil::null, true); + mPermsGroupName->refresh(LLUUID::null, std::string(), true); mPermsGroupName->setEnabled(false); }; }; @@ -194,7 +194,7 @@ void LLPanelMediaSettingsPermissions::initValues( void* userdata, const LLSD& me data_set[ i ].ctrl_ptr->setTentative( media_settings[ tentative_key ].asBoolean() ); }; }; - + // *NOTE: If any of a particular flavor is tentative, we have to disable // them all because of an architectural issue: namely that we represent // these as a bit field, and we can't selectively apply only one bit to all selected @@ -238,21 +238,21 @@ void LLPanelMediaSettingsPermissions::getValues( LLSD &fill_me_in, bool include_ { // moved over from the 'General settings' tab if (include_tentative || !mControls->getTentative()) fill_me_in[LLMediaEntry::CONTROLS_KEY] = (LLSD::Integer)mControls->getCurrentIndex(); - - // *NOTE: For some reason, gcc does not like these symbol references in the - // expressions below (inside the static_casts). I have NO idea why :(. - // For some reason, assigning them to const temp vars here fixes the link - // error. Bizarre. - const U8 none = LLMediaEntry::PERM_NONE; - const U8 owner = LLMediaEntry::PERM_OWNER; - const U8 group = LLMediaEntry::PERM_GROUP; - const U8 anyone = LLMediaEntry::PERM_ANYONE; - const LLSD::Integer control = static_cast<LLSD::Integer>( + + // *NOTE: For some reason, gcc does not like these symbol references in the + // expressions below (inside the static_casts). I have NO idea why :(. + // For some reason, assigning them to const temp vars here fixes the link + // error. Bizarre. + const U8 none = LLMediaEntry::PERM_NONE; + const U8 owner = LLMediaEntry::PERM_OWNER; + const U8 group = LLMediaEntry::PERM_GROUP; + const U8 anyone = LLMediaEntry::PERM_ANYONE; + const LLSD::Integer control = static_cast<LLSD::Integer>( (mPermsOwnerControl->getValue() ? owner : none ) | (mPermsGroupControl->getValue() ? group: none ) | (mPermsWorldControl->getValue() ? anyone : none )); - const LLSD::Integer interact = static_cast<LLSD::Integer>( - (mPermsOwnerInteract->getValue() ? owner: none ) | + const LLSD::Integer interact = static_cast<LLSD::Integer>( + (mPermsOwnerInteract->getValue() ? owner: none ) | (mPermsGroupInteract->getValue() ? group : none ) | (mPermsWorldInteract->getValue() ? anyone : none )); @@ -266,15 +266,15 @@ void LLPanelMediaSettingsPermissions::getValues( LLSD &fill_me_in, bool include_ !mPermsGroupControl->getTentative() || !mPermsWorldControl->getTentative()) { - fill_me_in[LLMediaEntry::PERMS_CONTROL_KEY] = control; + fill_me_in[LLMediaEntry::PERMS_CONTROL_KEY] = control; } if (include_tentative || !mPermsOwnerInteract->getTentative() || !mPermsGroupInteract->getTentative() || !mPermsWorldInteract->getTentative()) { - fill_me_in[LLMediaEntry::PERMS_INTERACT_KEY] = interact; - } + fill_me_in[LLMediaEntry::PERMS_INTERACT_KEY] = interact; +} } diff --git a/indra/newview/llpanelpermissions.cpp b/indra/newview/llpanelpermissions.cpp index 71d16a08b4..6bac4ae196 100644 --- a/indra/newview/llpanelpermissions.cpp +++ b/indra/newview/llpanelpermissions.cpp @@ -385,7 +385,7 @@ void LLPanelPermissions::refresh() if (mLabelGroupName) { mLabelGroupName->setNameID(LLUUID::null, TRUE); - mLabelGroupName->refresh(LLUUID::null,LLStringUtil::null, LLStringUtil::null, TRUE); + mLabelGroupName->refresh(LLUUID::null, std::string(), true); mLabelGroupName->setEnabled(FALSE); } } diff --git a/indra/newview/llpanelpicks.cpp b/indra/newview/llpanelpicks.cpp index bde8d02885..291da5fdd2 100644 --- a/indra/newview/llpanelpicks.cpp +++ b/indra/newview/llpanelpicks.cpp @@ -235,9 +235,9 @@ void LLPanelPicks::processProperties(void* data, EAvatarProcessorType type) LLAvatarPicks* avatar_picks = static_cast<LLAvatarPicks*>(data); if(avatar_picks && getAvatarId() == avatar_picks->target_id) { - std::string name, second_name; - gCacheName->getName(getAvatarId(),name,second_name); - childSetTextArg("pick_title", "[NAME]",name); + std::string full_name; + gCacheName->getFullName(getAvatarId(), full_name); + childSetTextArg("pick_title", "[NAME]", full_name); // Save selection, to be able to edit same item after saving changes. See EXT-3023. LLUUID selected_id = mPicksList->getSelectedValue()[PICK_ID]; diff --git a/indra/newview/llpanelplaceinfo.cpp b/indra/newview/llpanelplaceinfo.cpp index f6133d4446..4c3d6e2758 100644 --- a/indra/newview/llpanelplaceinfo.cpp +++ b/indra/newview/llpanelplaceinfo.cpp @@ -281,9 +281,7 @@ void LLPanelPlaceInfo::createPick(const LLVector3d& pos_global, LLPanelPickEdit* } // static -void LLPanelPlaceInfo::nameUpdatedCallback(LLTextBox* text, - const std::string& first, - const std::string& last) +void LLPanelPlaceInfo::onNameCache(LLTextBox* text, const std::string& full_name) { - text->setText(first + " " + last); + text->setText(full_name); } diff --git a/indra/newview/llpanelplaceinfo.h b/indra/newview/llpanelplaceinfo.h index deedbd2b0f..0d7a09b5de 100644 --- a/indra/newview/llpanelplaceinfo.h +++ b/indra/newview/llpanelplaceinfo.h @@ -102,9 +102,7 @@ public: void createPick(const LLVector3d& pos_global, LLPanelPickEdit* pick_panel); protected: - static void nameUpdatedCallback(LLTextBox* text, - const std::string& first, - const std::string& last); + static void onNameCache(LLTextBox* text, const std::string& full_name); /** * mParcelID is valid only for remote places, in other cases it's null. See resetLocation() diff --git a/indra/newview/llpanelplaceprofile.cpp b/indra/newview/llpanelplaceprofile.cpp index 1a1650c38b..41ca237b1e 100644 --- a/indra/newview/llpanelplaceprofile.cpp +++ b/indra/newview/llpanelplaceprofile.cpp @@ -51,6 +51,7 @@ #include "llappviewer.h" #include "llcallbacklist.h" #include "llfloaterbuycurrency.h" +#include "llslurl.h" // IDEVO #include "llstatusbar.h" #include "llviewercontrol.h" #include "llviewerparcelmgr.h" @@ -427,11 +428,11 @@ void LLPanelPlaceProfile::displaySelectedParcelInfo(LLParcel* parcel, if(!parcel->getGroupID().isNull()) { // FIXME: Using parcel group as region group. - gCacheName->get(parcel->getGroupID(), TRUE, - boost::bind(&LLPanelPlaceInfo::nameUpdatedCallback, mRegionGroupText, _2, _3)); + gCacheName->get(parcel->getGroupID(), true, + boost::bind(&LLPanelPlaceInfo::onNameCache, mRegionGroupText, _2)); - gCacheName->get(parcel->getGroupID(), TRUE, - boost::bind(&LLPanelPlaceInfo::nameUpdatedCallback, mParcelOwner, _2, _3)); + gCacheName->get(parcel->getGroupID(), true, + boost::bind(&LLPanelPlaceInfo::onNameCache, mParcelOwner, _2)); } else { @@ -443,10 +444,14 @@ void LLPanelPlaceProfile::displaySelectedParcelInfo(LLParcel* parcel, else { // Figure out the owner's name - gCacheName->get(parcel->getOwnerID(), FALSE, - boost::bind(&LLPanelPlaceInfo::nameUpdatedCallback, mParcelOwner, _2, _3)); - gCacheName->get(region->getOwner(), FALSE, - boost::bind(&LLPanelPlaceInfo::nameUpdatedCallback, mRegionOwnerText, _2, _3)); + // IDEVO + //gCacheName->get(parcel->getOwnerID(), FALSE, + // boost::bind(&LLPanelPlaceInfo::nameUpdatedCallback, mParcelOwner, _2, _3)); + std::string parcel_owner = + LLSLURL::buildCommand("agent", parcel->getOwnerID(), "inspect"); + mParcelOwner->setText(parcel_owner); + gCacheName->get(region->getOwner(), false, + boost::bind(&LLPanelPlaceInfo::onNameCache, mRegionOwnerText, _2)); } if(LLParcel::OS_LEASE_PENDING == parcel->getOwnershipStatus()) @@ -468,8 +473,8 @@ void LLPanelPlaceProfile::displaySelectedParcelInfo(LLParcel* parcel, const LLUUID& auth_buyer_id = parcel->getAuthorizedBuyerID(); if(auth_buyer_id.notNull()) { - gCacheName->get(auth_buyer_id, TRUE, - boost::bind(&LLPanelPlaceInfo::nameUpdatedCallback, mSaleToText, _2, _3)); + gCacheName->get(auth_buyer_id, true, + boost::bind(&LLPanelPlaceInfo::onNameCache, mSaleToText, _2)); // Show sales info to a specific person or a group he belongs to. if (auth_buyer_id != gAgent.getID() && !gAgent.isInGroup(auth_buyer_id)) diff --git a/indra/newview/llpanelprofile.h b/indra/newview/llpanelprofile.h index f1aa3f10f8..be5b440050 100644 --- a/indra/newview/llpanelprofile.h +++ b/indra/newview/llpanelprofile.h @@ -33,7 +33,6 @@ #ifndef LL_LLPANELPROFILE_H #define LL_LLPANELPROFILE_H -#include "llviewerprecompiledheaders.h" #include "llpanel.h" #include "llpanelavatar.h" diff --git a/indra/newview/llpanelprofileview.cpp b/indra/newview/llpanelprofileview.cpp index 044036ea50..1afe2b9d44 100644 --- a/indra/newview/llpanelprofileview.cpp +++ b/indra/newview/llpanelprofileview.cpp @@ -32,11 +32,12 @@ #include "llviewerprecompiledheaders.h" +#include "llpanelprofileview.h" + #include "llavatarconstants.h" +#include "llavatarnamecache.h" // IDEVO #include "lluserrelations.h" -#include "llpanelprofileview.h" - #include "llavatarpropertiesprocessor.h" #include "llcallingcard.h" #include "llpanelavatar.h" @@ -104,11 +105,15 @@ void LLPanelProfileView::onOpen(const LLSD& key) if(id.notNull() && getAvatarId() != id) { setAvatarId(id); + + // clear name fields, which might have old data + getChild<LLUICtrl>("user_name")->setValue( LLSD() ); + getChild<LLUICtrl>("user_slid")->setValue( LLSD() ); } // Update the avatar name. - gCacheName->get(getAvatarId(), FALSE, - boost::bind(&LLPanelProfileView::onAvatarNameCached, this, _1, _2, _3, _4)); + LLAvatarNameCache::get(getAvatarId(), + boost::bind(&LLPanelProfileView::onAvatarNameCache, this, _1, _2)); updateOnlineStatus(); @@ -198,10 +203,11 @@ void LLPanelProfileView::processOnlineStatus(bool online) mStatusText->setValue(status); } -void LLPanelProfileView::onAvatarNameCached(const LLUUID& id, const std::string& first_name, const std::string& last_name, BOOL is_group) +void LLPanelProfileView::onAvatarNameCache(const LLUUID& agent_id, + const LLAvatarName& av_name) { - llassert(getAvatarId() == id); - getChild<LLUICtrl>("user_name", FALSE)->setValue(first_name + " " + last_name); + getChild<LLUICtrl>("user_name")->setValue( av_name.mDisplayName ); + getChild<LLUICtrl>("user_slid")->setValue( av_name.mSLID ); } // EOF diff --git a/indra/newview/llpanelprofileview.h b/indra/newview/llpanelprofileview.h index 9b87e146a8..dedb617c27 100644 --- a/indra/newview/llpanelprofileview.h +++ b/indra/newview/llpanelprofileview.h @@ -39,6 +39,7 @@ #include "llagent.h" #include "lltooldraganddrop.h" +class LLAvatarName; class LLPanelProfile; class LLPanelProfileTab; class LLTextBox; @@ -99,11 +100,11 @@ protected: private: // LLCacheName will call this function when avatar name is loaded from server. // This is required to display names that have not been cached yet. - void onAvatarNameCached( - const LLUUID& id, - const std::string& first_name, - const std::string& last_name, - BOOL is_group); +// void onNameCache( +// const LLUUID& id, +// const std::string& full_name, +// bool is_group); + void onAvatarNameCache(const LLUUID& agent_id, const LLAvatarName& av_name); LLTextBox* mStatusText; AvatarStatusObserver* mAvatarStatusObserver; diff --git a/indra/newview/llsidepaneltaskinfo.cpp b/indra/newview/llsidepaneltaskinfo.cpp index 6ebe55e362..2a0360460c 100644 --- a/indra/newview/llsidepaneltaskinfo.cpp +++ b/indra/newview/llsidepaneltaskinfo.cpp @@ -350,7 +350,7 @@ void LLSidepanelTaskInfo::refresh() if (mLabelGroupName) { mLabelGroupName->setNameID(LLUUID::null, TRUE); - mLabelGroupName->refresh(LLUUID::null,LLStringUtil::null, LLStringUtil::null, TRUE); + mLabelGroupName->refresh(LLUUID::null, std::string(), true); mLabelGroupName->setEnabled(FALSE); } } diff --git a/indra/newview/llspeakers.cpp b/indra/newview/llspeakers.cpp index ba6a44dff4..7f78c14aab 100644 --- a/indra/newview/llspeakers.cpp +++ b/indra/newview/llspeakers.cpp @@ -74,12 +74,13 @@ LLSpeaker::LLSpeaker(const LLUUID& id, const std::string& name, const ESpeakerTy void LLSpeaker::lookupName() { - gCacheName->get(mID, FALSE, boost::bind(&LLSpeaker::onAvatarNameLookup, this, _1, _2, _3, _4)); + gCacheName->get(mID, false, + boost::bind(&LLSpeaker::onNameCache, this, _1, _2, _3)); } -void LLSpeaker::onAvatarNameLookup(const LLUUID& id, const std::string& first, const std::string& last, BOOL is_group) +void LLSpeaker::onNameCache(const LLUUID& id, const std::string& full_name, bool is_group) { - mDisplayName = first + " " + last; + mDisplayName = full_name; } bool LLSpeaker::isInVoiceChannel() diff --git a/indra/newview/llspeakers.h b/indra/newview/llspeakers.h index 2bb160b7ce..402c2d95b9 100644 --- a/indra/newview/llspeakers.h +++ b/indra/newview/llspeakers.h @@ -66,7 +66,7 @@ public: ~LLSpeaker() {}; void lookupName(); - void onAvatarNameLookup(const LLUUID& id, const std::string& first, const std::string& last, BOOL is_group); + void onNameCache(const LLUUID& id, const std::string& full_name, bool is_group); bool isInVoiceChannel(); diff --git a/indra/newview/llstartup.cpp b/indra/newview/llstartup.cpp index 7ad7799515..9867372001 100644 --- a/indra/newview/llstartup.cpp +++ b/indra/newview/llstartup.cpp @@ -52,6 +52,7 @@ #endif #include "llares.h" +#include "llavatarnamecache.h" #include "lllandmark.h" #include "llcachename.h" #include "lldir.h" @@ -266,11 +267,11 @@ void apply_udp_blacklist(const std::string& csv); bool process_login_success_response(); void transition_back_to_login_panel(const std::string& emsg); -void callback_cache_name(const LLUUID& id, const std::string& firstname, const std::string& lastname, BOOL is_group) +void callback_cache_name(const LLUUID& id, const std::string& full_name, bool is_group) { - LLNameListCtrl::refreshAll(id, firstname, lastname, is_group); - LLNameBox::refreshAll(id, firstname, lastname, is_group); - LLNameEditor::refreshAll(id, firstname, lastname, is_group); + LLNameListCtrl::refreshAll(id, full_name, is_group); + LLNameBox::refreshAll(id, full_name, is_group); + LLNameEditor::refreshAll(id, full_name, is_group); // TODO: Actually be intelligent about the refresh. // For now, just brute force refresh the dialogs. @@ -1281,16 +1282,7 @@ bool idle_startup() gXferManager->registerCallbacks(gMessageSystem); - if ( gCacheName == NULL ) - { - gCacheName = new LLCacheName(gMessageSystem); - gCacheName->addObserver(&callback_cache_name); - gCacheName->LocalizeCacheName("waiting", LLTrans::getString("AvatarNameWaiting")); - gCacheName->LocalizeCacheName("nobody", LLTrans::getString("AvatarNameNobody")); - gCacheName->LocalizeCacheName("none", LLTrans::getString("GroupNameNone")); - // Load stored cache if possible - LLAppViewer::instance()->loadNameCache(); - } + LLStartUp::initNameCache(); //gCacheName is required for nearby chat history loading //so I just moved nearby history loading a few states further @@ -1628,7 +1620,6 @@ bool idle_startup() LLClassifiedInfo::loadCategories(classified_categories); } - // This method MUST be called before gInventory.findCategoryUUIDForType because of // gInventory.mIsAgentInvUsable is set to true in the gInventory.buildParentChildMap. gInventory.buildParentChildMap(); @@ -2776,6 +2767,32 @@ void LLStartUp::fontInit() LLFontGL::loadDefaultFonts(); } +void LLStartUp::initNameCache() +{ + // Can be called multiple times + if ( gCacheName ) return; + + gCacheName = new LLCacheName(gMessageSystem); + gCacheName->addObserver(&callback_cache_name); + gCacheName->localizeCacheName("waiting", LLTrans::getString("AvatarNameWaiting")); + gCacheName->localizeCacheName("nobody", LLTrans::getString("AvatarNameNobody")); + gCacheName->localizeCacheName("none", LLTrans::getString("GroupNameNone")); + // Load stored cache if possible + LLAppViewer::instance()->loadNameCache(); + + // Start cache in not-running state until we figure out if we have + // capabilities for display name lookup + LLAvatarNameCache::initClass(false); +} + +void LLStartUp::cleanupNameCache() +{ + LLAvatarNameCache::cleanupClass(); + + delete gCacheName; + gCacheName = NULL; +} + bool LLStartUp::dispatchURL() { // ok, if we've gotten this far and have a startup URL diff --git a/indra/newview/llstartup.h b/indra/newview/llstartup.h index 92fe9521d3..14a7c71544 100644 --- a/indra/newview/llstartup.h +++ b/indra/newview/llstartup.h @@ -95,6 +95,10 @@ public: // Load default fonts not already loaded at start screen static void fontInit(); + static void initNameCache(); + + static void cleanupNameCache(); + // outfit_folder_name can be a folder anywhere in your inventory, // but the name must be a case-sensitive exact match. // gender_name is either "male" or "female" diff --git a/indra/newview/lltoolpie.cpp b/indra/newview/lltoolpie.cpp index ae244cd8a1..67db778bdb 100644 --- a/indra/newview/lltoolpie.cpp +++ b/indra/newview/lltoolpie.cpp @@ -40,6 +40,7 @@ #include "llagent.h" #include "llagentcamera.h" +#include "llavatarnamecache.h" #include "llviewercontrol.h" #include "llfocusmgr.h" //#include "llfirstuse.h" @@ -859,23 +860,39 @@ BOOL LLToolPie::handleTooltipObject( LLViewerObject* hover_object, std::string l || !existing_inspector->getVisible() || existing_inspector->getKey()["avatar_id"].asUUID() != hover_object->getID()) { - std::string avatar_name; + // IDEVO JAMESDEBUG try to get display name + SLID + std::string final_name; + std::string full_name; + if (!gCacheName->getFullName(hover_object->getID(), full_name)) + { LLNameValue* firstname = hover_object->getNVPair("FirstName"); LLNameValue* lastname = hover_object->getNVPair("LastName"); if (firstname && lastname) { - avatar_name = llformat("%s %s", firstname->getString(), lastname->getString()); + full_name = LLCacheName::buildFullName( + firstname->getString(), lastname->getString()); + } + else + { + full_name = LLTrans::getString("TooltipPerson"); + } + } + LLAvatarName av_name; + if (LLAvatarNameCache::useDisplayNames() + && LLAvatarNameCache::get(hover_object->getID(), &av_name)) + { + final_name = av_name.mDisplayName + " (" + av_name.mSLID + ")"; } else { - avatar_name = LLTrans::getString("TooltipPerson"); + final_name = full_name; } // *HACK: We may select this object, so pretend it was clicked mPick = mHoverPick; LLInspector::Params p; p.fillFrom(LLUICtrlFactory::instance().getDefaultParams<LLInspector>()); - p.message(avatar_name); + p.message(final_name); p.image.name("Inspector_I"); p.click_callback(boost::bind(showAvatarInspector, hover_object->getID())); p.visible_time_near(6.f); diff --git a/indra/newview/lltracker.cpp b/indra/newview/lltracker.cpp index cc074287c4..c81a062ade 100644 --- a/indra/newview/lltracker.cpp +++ b/indra/newview/lltracker.cpp @@ -570,16 +570,16 @@ void LLTracker::renderBeacon(LLVector3d pos_global, std::string text; text = llformat( "%.0f m", to_vec.magVec()); - LLWString wstr; - wstr += utf8str_to_wstring(label); - wstr += '\n'; - wstr += utf8str_to_wstring(text); + std::string str; + str += label; + str += '\n'; + str += text; hud_textp->setFont(LLFontGL::getFontSansSerif()); hud_textp->setZCompare(FALSE); hud_textp->setColor(LLColor4(1.f, 1.f, 1.f, llmax(0.2f, llmin(1.f,(dist-FADE_DIST)/FADE_DIST)))); - hud_textp->setString(wstr); + hud_textp->setString(str); hud_textp->setVertAlignment(LLHUDText::ALIGN_VERT_CENTER); hud_textp->setPositionAgent(pos_agent); } diff --git a/indra/newview/llviewerdisplay.cpp b/indra/newview/llviewerdisplay.cpp index f0800e82e7..944f4b74b7 100644 --- a/indra/newview/llviewerdisplay.cpp +++ b/indra/newview/llviewerdisplay.cpp @@ -323,7 +323,7 @@ void display(BOOL rebuild, F32 zoom_factor, int subfield, BOOL for_snapshot) LLImageGL::updateStats(gFrameTimeSeconds); LLVOAvatar::sRenderName = gSavedSettings.getS32("AvatarNameTagMode"); - LLVOAvatar::sRenderGroupTitles = (gSavedSettings.getBOOL("RenderShowGroupTitleAll") && gSavedSettings.getS32("AvatarNameTagMode")); + LLVOAvatar::sRenderGroupTitles = (gSavedSettings.getBOOL("NameTagShowGroupTitles") && gSavedSettings.getS32("AvatarNameTagMode")); gPipeline.mBackfaceCull = TRUE; gFrameCount++; diff --git a/indra/newview/llviewerdisplayname.cpp b/indra/newview/llviewerdisplayname.cpp new file mode 100644 index 0000000000..bec2687cca --- /dev/null +++ b/indra/newview/llviewerdisplayname.cpp @@ -0,0 +1,202 @@ +/** + * @file llviewerdisplayname.cpp + * @brief Wrapper for display name functionality + * + * $LicenseInfo:firstyear=2010&license=viewergpl$ + * + * Copyright (c) 2010, Linden Research, Inc. + * + * Second Life Viewer Source Code + * The source code in this file ("Source Code") is provided by Linden Lab + * to you under the terms of the GNU General Public License, version 2.0 + * ("GPL"), unless you have obtained a separate licensing agreement + * ("Other License"), formally executed by you and Linden Lab. Terms of + * the GPL can be found in doc/GPL-license.txt in this distribution, or + * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2 + * + * There are special exceptions to the terms and conditions of the GPL as + * it is applied to this Source Code. View the full text of the exception + * in the file doc/FLOSS-exception.txt in this software distribution, or + * online at + * http://secondlifegrid.net/programs/open_source/licensing/flossexception + * + * By copying, modifying or distributing this software, you acknowledge + * that you have read and understood your obligations described above, + * and agree to abide by those obligations. + * + * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO + * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, + * COMPLETENESS OR PERFORMANCE. + * $/LicenseInfo$ + */ +#include "llviewerprecompiledheaders.h" + +#include "llviewerdisplayname.h" + +// viewer includes +#include "llagent.h" +#include "llviewerregion.h" +#include "llvoavatar.h" + +// library includes +#include "llavatarnamecache.h" +#include "llhttpclient.h" +#include "llhttpnode.h" +#include "llnotificationsutil.h" +#include "llui.h" // getLanguage() + +namespace LLViewerDisplayName +{ + // Fired when viewer receives server response to display name change + set_name_signal_t sSetDisplayNameSignal; +} + +class LLSetDisplayNameResponder : public LLHTTPClient::Responder +{ +public: + // only care about errors + /*virtual*/ void error(U32 status, const std::string& reason) + { + LLViewerDisplayName::sSetDisplayNameSignal(false, "", LLSD()); + LLViewerDisplayName::sSetDisplayNameSignal.disconnect_all_slots(); + } +}; + +void LLViewerDisplayName::set(const std::string& display_name, const set_name_slot_t& slot) +{ + // TODO: simple validation here + + LLViewerRegion* region = gAgent.getRegion(); + llassert(region); + std::string cap_url = region->getCapability("SetDisplayName"); + if (cap_url.empty()) + { + // this server does not support display names, report error + slot(false, "unsupported", LLSD()); + return; + } + + // People API can return localized error messages. Indicate our + // language preference via header. + LLSD headers; + headers["Accept-Language"] = LLUI::getLanguage(); + + // People API requires both the old and new value to change a variable. + // Our display name will be in cache before the viewer's UI is available + // to request a change, so we can use direct lookup without callback. + LLAvatarName av_name; + if (!LLAvatarNameCache::get( gAgent.getID(), &av_name)) + { + slot(false, "name unavailable", LLSD()); + return; + } + + // People API expects array of [ "old value", "new value" ] + LLSD change_array = LLSD::emptyArray(); + change_array.append(av_name.mDisplayName); + change_array.append(display_name); + + llinfos << "Set name POST to " << cap_url << llendl; + + // Record our caller for when the server sends back a reply + sSetDisplayNameSignal.connect(slot); + + // POST the requested change. The sim will not send a response back to + // this request directly, rather it will send a separate message after it + // communicates with the back-end. + LLSD body; + body["display_name"] = change_array; + LLHTTPClient::post(cap_url, body, new LLSetDisplayNameResponder, headers); +} + +class LLSetDisplayNameReply : public LLHTTPNode +{ + LOG_CLASS(LLSetDisplayNameReply); +public: + /*virtual*/ void post( + LLHTTPNode::ResponsePtr response, + const LLSD& context, + const LLSD& input) const + { + LLSD body = input["body"]; + + S32 status = body["status"].asInteger(); + bool success = (status == 200); + std::string reason = body["reason"].asString(); + LLSD content = body["content"]; + + llinfos << "status " << status << " reason " << reason << llendl; + + // If viewer's concept of display name is out-of-date, the set request + // will fail with 409 Conflict. If that happens, fetch up-to-date + // name information. + if (status == 409) + { + LLUUID agent_id = gAgent.getID(); + // Flush stale data + LLAvatarNameCache::erase( agent_id ); + // Queue request for new data + LLAvatarName ignored; + LLAvatarNameCache::get( agent_id, &ignored ); + // Kill name tag, as it is wrong + LLVOAvatar::invalidateNameTag( agent_id ); + } + + // inform caller of result + LLViewerDisplayName::sSetDisplayNameSignal(success, reason, content); + LLViewerDisplayName::sSetDisplayNameSignal.disconnect_all_slots(); + } +}; + +#include "llsdserialize.h" + +class LLDisplayNameUpdate : public LLHTTPNode +{ + /*virtual*/ void post( + LLHTTPNode::ResponsePtr response, + const LLSD& context, + const LLSD& input) const + { + LLSD body = input["body"]; + LLUUID agent_id = body["agent_id"]; + std::string old_display_name = body["old_display_name"]; + // By convention this record is called "agent" in the People API + LLSD name_data = body["agent"]; + + // Inject the new name data into cache + LLAvatarName av_name; + av_name.fromLLSD( name_data ); + + // Name expiration time may be provided in headers, or we may use a + // default value + // JAMESDEBUG TODO: get actual headers out of ResponsePtr + //LLSD headers = response->mHeaders; + LLSD headers; + av_name.mExpires = + LLAvatarNameCache::nameExpirationFromHeaders(headers); + + LLAvatarNameCache::insert(agent_id, av_name); + + // force name tag to update + LLVOAvatar::invalidateNameTag(agent_id); + + // Don't show a notification for my name, because we'll show a nicer + // dialog + if (agent_id != gAgent.getID()) + { + LLSD args; + args["OLD_NAME"] = old_display_name; + args["SLID"] = av_name.mSLID; + args["NEW_NAME"] = av_name.mDisplayName; + LLNotificationsUtil::add("DisplayNameUpdate", args); + } + } +}; + +LLHTTPRegistration<LLSetDisplayNameReply> + gHTTPRegistrationMessageSetDisplayNameReply( + "/message/SetDisplayNameReply"); + +LLHTTPRegistration<LLDisplayNameUpdate> + gHTTPRegistrationMessageDisplayNameUpdate( + "/message/DisplayNameUpdate"); diff --git a/indra/newview/llviewerdisplayname.h b/indra/newview/llviewerdisplayname.h new file mode 100644 index 0000000000..c77388531b --- /dev/null +++ b/indra/newview/llviewerdisplayname.h @@ -0,0 +1,53 @@ +/** + * @file llviewerdisplayname.h + * @brief Wrapper for display name functionality + * + * $LicenseInfo:firstyear=2010&license=viewergpl$ + * + * Copyright (c) 2010, Linden Research, Inc. + * + * Second Life Viewer Source Code + * The source code in this file ("Source Code") is provided by Linden Lab + * to you under the terms of the GNU General Public License, version 2.0 + * ("GPL"), unless you have obtained a separate licensing agreement + * ("Other License"), formally executed by you and Linden Lab. Terms of + * the GPL can be found in doc/GPL-license.txt in this distribution, or + * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2 + * + * There are special exceptions to the terms and conditions of the GPL as + * it is applied to this Source Code. View the full text of the exception + * in the file doc/FLOSS-exception.txt in this software distribution, or + * online at + * http://secondlifegrid.net/programs/open_source/licensing/flossexception + * + * By copying, modifying or distributing this software, you acknowledge + * that you have read and understood your obligations described above, + * and agree to abide by those obligations. + * + * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO + * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, + * COMPLETENESS OR PERFORMANCE. + * $/LicenseInfo$ + */ +#ifndef LLVIEWERDISPLAYNAME_H +#define LLVIEWERDISPLAYNAME_H + +#include <boost/signals2.hpp> + +class LLSD; +class LLUUID; + +namespace LLViewerDisplayName +{ + typedef boost::signals2::signal< + void (bool success, const std::string& reason, const LLSD& content)> + set_name_signal_t; + typedef set_name_signal_t::slot_type set_name_slot_t; + + // Sends an update to the server to change a display name + // and call back when done. May not succeed due to service + // unavailable or name not available. + void set(const std::string& display_name, const set_name_slot_t& slot); +} + +#endif // LLVIEWERDISPLAYNAME_H diff --git a/indra/newview/llviewerinventory.cpp b/indra/newview/llviewerinventory.cpp index ed3d6a0464..e88f496fc9 100644 --- a/indra/newview/llviewerinventory.cpp +++ b/indra/newview/llviewerinventory.cpp @@ -1652,9 +1652,9 @@ bool LLViewerInventoryItem::checkPermissionsSet(PermissionMask mask) const //---------- -void LLViewerInventoryItem::onCallingCardNameLookup(const LLUUID& id, const std::string& first_name, const std::string& last_name) +void LLViewerInventoryItem::onCallingCardNameLookup(const LLUUID& id, const std::string& name, bool is_group) { - rename(first_name + " " + last_name); + rename(name); gInventory.addChangedMask(LLInventoryObserver::LABEL, getUUID()); gInventory.notifyObservers(); } diff --git a/indra/newview/llviewerinventory.h b/indra/newview/llviewerinventory.h index f296ce35ff..84922bf61d 100644 --- a/indra/newview/llviewerinventory.h +++ b/indra/newview/llviewerinventory.h @@ -161,7 +161,7 @@ public: bool checkPermissionsSet(PermissionMask mask) const; // callback - void onCallingCardNameLookup(const LLUUID& id, const std::string& first_name, const std::string& last_name); + void onCallingCardNameLookup(const LLUUID& id, const std::string& name, bool is_group); // If this is a broken link, try to fix it and any other identical link. BOOL regenerateLink(); diff --git a/indra/newview/llviewerjointattachment.cpp b/indra/newview/llviewerjointattachment.cpp index 2b4b78d82d..b230203561 100644 --- a/indra/newview/llviewerjointattachment.cpp +++ b/indra/newview/llviewerjointattachment.cpp @@ -39,6 +39,7 @@ #include "llviewercontrol.h" #include "lldrawable.h" #include "llgl.h" +#include "llhudtext.h" #include "llrender.h" #include "llvoavatar.h" #include "llvolume.h" diff --git a/indra/newview/llviewermenu.cpp b/indra/newview/llviewermenu.cpp index 7464423f55..0a3f72b38f 100644 --- a/indra/newview/llviewermenu.cpp +++ b/indra/newview/llviewermenu.cpp @@ -34,6 +34,7 @@ #include "llviewermenu.h" // linden library includes +#include "llavatarnamecache.h" // IDEVO #include "llfloaterreg.h" #include "llcombobox.h" #include "llinventorypanel.h" @@ -107,7 +108,6 @@ #include "llfloatercamera.h" #include "lluilistener.h" #include "llappearancemgr.h" -#include "lltrans.h" using namespace LLVOAvatarDefines; @@ -2777,9 +2777,8 @@ class LLObjectMute : public view_listener_t LLNameValue *lastname = avatar->getNVPair("LastName"); if (firstname && lastname) { - name = firstname->getString(); - name += " "; - name += lastname->getString(); + name = LLCacheName::buildFullName( + firstname->getString(), lastname->getString()); } type = LLMute::AGENT; @@ -3125,58 +3124,6 @@ bool enable_freeze_eject(const LLSD& avatar_id) return new_value; } -class LLAvatarGiveCard : public view_listener_t -{ - bool handleEvent(const LLSD& userdata) - { - llinfos << "handle_give_card()" << llendl; - LLViewerObject* dest = LLSelectMgr::getInstance()->getSelection()->getPrimaryObject(); - if(dest && dest->isAvatar()) - { - bool found_name = false; - LLSD args; - LLSD old_args; - LLNameValue* nvfirst = dest->getNVPair("FirstName"); - LLNameValue* nvlast = dest->getNVPair("LastName"); - if(nvfirst && nvlast) - { - args["FIRST"] = nvfirst->getString(); - args["LAST"] = nvlast->getString(); - old_args["FIRST"] = nvfirst->getString(); - old_args["LAST"] = nvlast->getString(); - found_name = true; - } - LLViewerRegion* region = dest->getRegion(); - LLHost dest_host; - if(region) - { - dest_host = region->getHost(); - } - if(found_name && dest_host.isOk()) - { - LLMessageSystem* msg = gMessageSystem; - msg->newMessage("OfferCallingCard"); - msg->nextBlockFast(_PREHASH_AgentData); - msg->addUUIDFast(_PREHASH_AgentID, gAgent.getID()); - msg->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID()); - msg->nextBlockFast(_PREHASH_AgentBlock); - msg->addUUIDFast(_PREHASH_DestID, dest->getID()); - LLUUID transaction_id; - transaction_id.generate(); - msg->addUUIDFast(_PREHASH_TransactionID, transaction_id); - msg->sendReliable(dest_host); - LLNotificationsUtil::add("OfferedCard", args); - } - else - { - LLNotificationsUtil::add("CantOfferCallingCard", old_args); - } - } - return true; - } -}; - - void login_done(S32 which, void *user) { @@ -3596,21 +3543,17 @@ void request_friendship(const LLUUID& dest_id) LLViewerObject* dest = gObjectList.findObject(dest_id); if(dest && dest->isAvatar()) { - std::string fullname; - LLSD args; + std::string full_name; LLNameValue* nvfirst = dest->getNVPair("FirstName"); LLNameValue* nvlast = dest->getNVPair("LastName"); if(nvfirst && nvlast) { - args["FIRST"] = nvfirst->getString(); - args["LAST"] = nvlast->getString(); - fullname = nvfirst->getString(); - fullname += " "; - fullname += nvlast->getString(); + full_name = LLCacheName::buildFullName( + nvfirst->getString(), nvlast->getString()); } - if (!fullname.empty()) + if (!full_name.empty()) { - LLAvatarActions::requestFriendshipDialog(dest_id, fullname); + LLAvatarActions::requestFriendshipDialog(dest_id, full_name); } else { @@ -7648,6 +7591,15 @@ class LLWorldToggleCameraControls : public view_listener_t } }; +// IDEVO JAMESDEBUG temp code for testing +void toggle_display_names() +{ + bool use = LLAvatarNameCache::useDisplayNames(); + LLAvatarNameCache::setUseDisplayNames(!use); + + LLVOAvatar::invalidateNameTags(); +} + void show_navbar_context_menu(LLView* ctrl, S32 x, S32 y) { static LLMenuGL* show_navbar_context_menu = LLUICtrlFactory::getInstance()->createFromFile<LLMenuGL>("menu_hide_navbar.xml", @@ -7812,6 +7764,7 @@ void initialize_menus() view_listener_t::addMenu(new LLAdvancedToggleConsole(), "Advanced.ToggleConsole"); view_listener_t::addMenu(new LLAdvancedCheckConsole(), "Advanced.CheckConsole"); view_listener_t::addMenu(new LLAdvancedDumpInfoToConsole(), "Advanced.DumpInfoToConsole"); + // Advanced > HUD Info view_listener_t::addMenu(new LLAdvancedToggleHUDInfo(), "Advanced.ToggleHUDInfo"); view_listener_t::addMenu(new LLAdvancedCheckHUDInfo(), "Advanced.CheckHUDInfo"); @@ -7990,7 +7943,6 @@ void initialize_menus() view_listener_t::addMenu(new LLAvatarDebug(), "Avatar.Debug"); view_listener_t::addMenu(new LLAvatarVisibleDebug(), "Avatar.VisibleDebug"); view_listener_t::addMenu(new LLAvatarInviteToGroup(), "Avatar.InviteToGroup"); - view_listener_t::addMenu(new LLAvatarGiveCard(), "Avatar.GiveCard"); commit.add("Avatar.Eject", boost::bind(&handle_avatar_eject, LLSD())); view_listener_t::addMenu(new LLAvatarSendIM(), "Avatar.SendIM"); view_listener_t::addMenu(new LLAvatarCall(), "Avatar.Call"); diff --git a/indra/newview/llviewermessage.cpp b/indra/newview/llviewermessage.cpp index 46adb0a46b..185bf2c406 100644 --- a/indra/newview/llviewermessage.cpp +++ b/indra/newview/llviewermessage.cpp @@ -34,9 +34,11 @@ #include "llviewermessage.h" #include "boost/lexical_cast.hpp" +// Linden libraries #include "llanimationstates.h" #include "llaudioengine.h" #include "llavataractions.h" +#include "llavatarnamecache.h" // IDEVO HACK #include "lscript_byteformat.h" #include "lleconomy.h" #include "lleventtimer.h" @@ -85,6 +87,7 @@ #include "llspeakers.h" #include "lltrans.h" #include "llviewerfoldertype.h" +#include "llvoavatar.h" // IDEVO HACK #include "lluri.h" #include "llviewergenericmessage.h" #include "llviewermenu.h" @@ -137,6 +140,8 @@ extern BOOL gDebugClicks; // function prototypes bool check_offer_throttle(const std::string& from_name, bool check_only); +static void process_money_balance_reply_extended(LLMessageSystem* msg); +static void process_money_balance_reply_legacy(const std::string& desc); //inventory offer throttle globals LLFrameTimer gThrottleTimer; @@ -1199,27 +1204,24 @@ bool highlight_offered_item(const LLUUID& item_id) } void inventory_offer_mute_callback(const LLUUID& blocked_id, - const std::string& first_name, - const std::string& last_name, - BOOL is_group, LLOfferInfo* offer = NULL) + const std::string& full_name, + bool is_group, + LLOfferInfo* offer = NULL) { - std::string from_name; + std::string from_name = full_name; LLMute::EType type; if (is_group) { type = LLMute::GROUP; - from_name = first_name; } else if(offer && offer->mFromObject) { //we have to block object by name because blocked_id is an id of owner type = LLMute::BY_NAME; - from_name = offer->mFromName; } else { type = LLMute::AGENT; - from_name = first_name + " " + last_name; } // id should be null for BY_NAME mute, see LLMuteList::add for details @@ -1392,7 +1394,7 @@ bool LLOfferInfo::inventory_offer_callback(const LLSD& notification, const LLSD& // * we can't build two messages at once. if (2 == button) // Block { - gCacheName->get(mFromID, mFromGroup, boost::bind(&inventory_offer_mute_callback,_1,_2,_3,_4,this)); + gCacheName->get(mFromID, mFromGroup, boost::bind(&inventory_offer_mute_callback,_1,_2,_3,this)); } std::string from_string; // Used in the pop-up. @@ -1526,7 +1528,7 @@ bool LLOfferInfo::inventory_task_offer_callback(const LLSD& notification, const // * we can't build two messages at once. if (2 == button) { - gCacheName->get(mFromID, mFromGroup, boost::bind(&inventory_offer_mute_callback,_1,_2,_3,_4,this)); + gCacheName->get(mFromID, mFromGroup, boost::bind(&inventory_offer_mute_callback,_1,_2,_3,this)); } LLMessageSystem* msg = gMessageSystem; @@ -1574,12 +1576,12 @@ bool LLOfferInfo::inventory_task_offer_callback(const LLSD& notification, const } else { - std::string first_name, last_name; - if (gCacheName->getName(mFromID, first_name, last_name)) + std::string full_name; + if (gCacheName->getFullName(mFromID, full_name)) { from_string = LLTrans::getString("InvOfferAnObjectNamed") + " "+ LLTrans::getString("'") + mFromName - + LLTrans::getString("'")+" " + LLTrans::getString("InvOfferOwnedBy") + first_name + " " + last_name; - chatHistory_string = mFromName + " " + LLTrans::getString("InvOfferOwnedBy") + " " + first_name + " " + last_name; + + LLTrans::getString("'")+" " + LLTrans::getString("InvOfferOwnedBy") + full_name; + chatHistory_string = mFromName + " " + LLTrans::getString("InvOfferOwnedBy") + " " + full_name; } else { @@ -1783,7 +1785,14 @@ void inventory_offer_handler(LLOfferInfo* info) payload["give_inventory_notification"] = FALSE; args["OBJECTFROMNAME"] = info->mFromName; args["NAME"] = info->mFromName; - args["NAME_SLURL"] = LLSLURL::buildCommand("agent", info->mFromID, "about"); + if (info->mFromGroup) + { + args["NAME_SLURL"] = LLSLURL::buildCommand("group", info->mFromID, "about"); + } + else + { + args["NAME_SLURL"] = LLSLURL::buildCommand("agent", info->mFromID, "about"); + } std::string verb = "select?name=" + LLURI::escape(msg); args["ITEM_SLURL"] = LLSLURL::buildCommand("inventory", info->mObjectID, verb.c_str()); @@ -1966,6 +1975,75 @@ static bool parse_lure_bucket(const std::string& bucket, return true; } +// Strip out "Resident" for display, but only if the message came from a user +// (rather than a script) +static std::string clean_name_from_im(const std::string& name, EInstantMessage type) +{ + switch(type) + { + case IM_NOTHING_SPECIAL: + case IM_MESSAGEBOX: + case IM_GROUP_INVITATION: + case IM_INVENTORY_OFFERED: + case IM_INVENTORY_ACCEPTED: + case IM_INVENTORY_DECLINED: + case IM_GROUP_VOTE: + case IM_GROUP_MESSAGE_DEPRECATED: + //IM_TASK_INVENTORY_OFFERED + //IM_TASK_INVENTORY_ACCEPTED + //IM_TASK_INVENTORY_DECLINED + case IM_NEW_USER_DEFAULT: + case IM_SESSION_INVITE: + case IM_SESSION_P2P_INVITE: + case IM_SESSION_GROUP_START: + case IM_SESSION_CONFERENCE_START: + case IM_SESSION_SEND: + case IM_SESSION_LEAVE: + //IM_FROM_TASK + case IM_BUSY_AUTO_RESPONSE: + case IM_CONSOLE_AND_CHAT_HISTORY: + case IM_LURE_USER: + case IM_LURE_ACCEPTED: + case IM_LURE_DECLINED: + case IM_GODLIKE_LURE_USER: + case IM_YET_TO_BE_USED: + case IM_GROUP_ELECTION_DEPRECATED: + //IM_GOTO_URL + //IM_FROM_TASK_AS_ALERT + case IM_GROUP_NOTICE: + case IM_GROUP_NOTICE_INVENTORY_ACCEPTED: + case IM_GROUP_NOTICE_INVENTORY_DECLINED: + case IM_GROUP_INVITATION_ACCEPT: + case IM_GROUP_INVITATION_DECLINE: + case IM_GROUP_NOTICE_REQUESTED: + case IM_FRIENDSHIP_OFFERED: + case IM_FRIENDSHIP_ACCEPTED: + case IM_FRIENDSHIP_DECLINED_DEPRECATED: + //IM_TYPING_START + //IM_TYPING_STOP + return LLCacheName::cleanFullName(name); + default: + return name; + } +} + +static std::string clean_name_from_task_im(const std::string& msg) +{ + boost::smatch match; + static const boost::regex returned_exp( + "(.*been returned to your inventory lost and found folder by )(.+)( (from|near).*)"); + if (boost::regex_match(msg, match, returned_exp)) + { + // match objects are 1-based for groups + std::string final = match[1].str(); + std::string name = match[2].str(); + final += LLCacheName::cleanFullName(name); + final += match[3].str(); + return final; + } + return msg; +} + void process_improved_im(LLMessageSystem *msg, void **user_data) { if (gNoRender) @@ -2013,6 +2091,8 @@ void process_improved_im(LLMessageSystem *msg, void **user_data) { name = LLTrans::getString("Unnamed"); } + // IDEVO convert new-style "Resident" names for display + name = clean_name_from_im(name, dialog); BOOL is_busy = gAgent.getBusy(); BOOL is_muted = LLMuteList::getInstance()->isMuted(from_id, name, LLMute::flagTextChat); @@ -2319,6 +2399,15 @@ void process_improved_im(LLMessageSystem *msg, void **user_data) invite_bucket = (struct invite_bucket_t*) &binary_bucket[0]; S32 membership_fee = ntohl(invite_bucket->membership_fee); + // IDEVO Clean up legacy name "Resident" in message constructed in + // lldatagroups.cpp + U32 pos = message.find(" has invited you to join a group.\n"); + if (pos != std::string::npos) + { + // use cleaned-up name from above + message = name + message.substr(pos); + } + LLSD payload; payload["transaction_id"] = session_id; payload["group_id"] = from_id; @@ -2505,6 +2594,9 @@ void process_improved_im(LLMessageSystem *msg, void **user_data) chat.mSourceType = CHAT_SOURCE_SYSTEM; } + // IDEVO Some messages have embedded resident names + message = clean_name_from_task_im(message); + LLSD query_string; query_string["owner"] = from_id; query_string["slurl"] = location; @@ -2820,9 +2912,8 @@ void process_offer_callingcard(LLMessageSystem* msg, void**) LLNameValue* nvlast = source->getNVPair("LastName"); if (nvfirst && nvlast) { - args["FIRST"] = nvfirst->getString(); - args["LAST"] = nvlast->getString(); - source_name = std::string(nvfirst->getString()) + " " + nvlast->getString(); + source_name = LLCacheName::buildFullName( + nvfirst->getString(), nvlast->getString()); } } @@ -2855,7 +2946,6 @@ void process_decline_callingcard(LLMessageSystem* msg, void**) LLNotificationsUtil::add("CallingCardDeclined"); } - void process_chat_from_simulator(LLMessageSystem *msg, void **user_data) { LLChat chat; @@ -2871,7 +2961,6 @@ void process_chat_from_simulator(LLMessageSystem *msg, void **user_data) LLViewerObject* chatter; msg->getString("ChatData", "FromName", from_name); - chat.mFromName = from_name; msg->getUUID("ChatData", "SourceID", from_id); chat.mFromID = from_id; @@ -2890,6 +2979,27 @@ void process_chat_from_simulator(LLMessageSystem *msg, void **user_data) chat.mTime = LLFrameTimer::getElapsedSeconds(); + // IDEVO Correct for new-style "Resident" names + if (chat.mSourceType == CHAT_SOURCE_AGENT) + { + // JAMESDEBUG - I don't know if it's OK to change this here, if + // anything downstream does lookups by name, for instance + LLAvatarName av_name; + if (LLAvatarNameCache::useDisplayNames() + && LLAvatarNameCache::get(from_id, &av_name)) + { + chat.mFromName = av_name.mDisplayName; + } + else + { + chat.mFromName = LLCacheName::cleanFullName(from_name); + } + } + else + { + chat.mFromName = from_name; + } + BOOL is_busy = gAgent.getBusy(); BOOL is_muted = FALSE; @@ -4743,7 +4853,71 @@ void process_time_dilation(LLMessageSystem *msg, void **user_data) } */ - +// Both Product Engine and I wrote solutions to non-localized payment messages. +// Their code probably has more localized strings against it. +// James Cook, 2010-03-27 +// +//static void show_money_balance_notification(const std::string& desc) +//{ +// // Intercept some messages constructed in lltransactionflags.cpp +// // to fix avatar names and allow localization. +// LLSD args; +// LLSD payload; +// std::string name; +// boost::smatch match; +// const char* notification_name = NULL; +// +// // <name> paid you L$<amount> for <reason>. +// static const boost::regex paid_you_for("(.+) paid you L\\$(\\d+) for (.*)\\."); +// // <name> paid you L$<amount>. +// static const boost::regex paid_you("(.+) paid you L\\$(\\d+)\\."); +// // You paid <name> L$<amount> [for <reason>]. +// static const boost::regex you_paid("You paid (.*) L\\$(\\d+)(.*)\\."); +// +// if (boost::regex_match(desc, match, paid_you_for)) +// { +// name = match[1].str(); +// // IDEVO strip legacy "Resident" name +// name = LLCacheName::cleanFullName(name); +// args["NAME"] = name; +// args["AMOUNT"] = match[2].str(); +// args["REASON"] = match[3].str(); +// notification_name = "PaymentReceivedFor"; +// } +// else if (boost::regex_match(desc, match, paid_you)) +// { +// name = match[1].str(); +// // IDEVO strip legacy "Resident" name +// name = LLCacheName::cleanFullName(name); +// args["NAME"] = name; +// args["AMOUNT"] = match[2].str(); +// notification_name = "PaymentReceived"; +// } +// else if (boost::regex_match(desc, match, you_paid)) +// { +// name = match[1].str(); +// // IDEVO strip legacy "Resident" name +// name = LLCacheName::cleanFullName(name); +// args["NAME"] = name; +// args["AMOUNT"] = match[2].str(); +// args["REASON"] = match[3].str(); +// notification_name = "PaymentSent"; +// } +// +// // if name extracted and name cache contains avatar id send loggable notification +// LLUUID from_id; +// if (notification_name != NULL +// && gCacheName->getUUID(name, from_id)) +// { +// payload["from_id"] = from_id; +// LLNotificationsUtil::add(notification_name, args, payload); +// } +// else +// { +// args["MESSAGE"] = desc; +// LLNotificationsUtil::add("SystemMessage", args); +// } +//} void process_money_balance_reply( LLMessageSystem* msg, void** ) { @@ -4751,93 +4925,166 @@ void process_money_balance_reply( LLMessageSystem* msg, void** ) S32 credit = 0; S32 committed = 0; std::string desc; + LLUUID tid; + msg->getUUID("MoneyData", "TransactionID", tid); msg->getS32("MoneyData", "MoneyBalance", balance); msg->getS32("MoneyData", "SquareMetersCredit", credit); msg->getS32("MoneyData", "SquareMetersCommitted", committed); msg->getStringFast(_PREHASH_MoneyData, _PREHASH_Description, desc); LL_INFOS("Messaging") << "L$, credit, committed: " << balance << " " << credit << " " << committed << LL_ENDL; - + if (gStatusBar) { - // S32 old_balance = gStatusBar->getBalance(); - - // This is an update, not the first transmission of balance - /* if (old_balance != 0) - { - // this is actually an update - if (balance > old_balance) - { - LLFirstUse::useBalanceIncrease(balance - old_balance); - } - else if (balance < old_balance) - { - LLFirstUse::useBalanceDecrease(balance - old_balance); - } - } - */ gStatusBar->setBalance(balance); gStatusBar->setLandCredit(credit); gStatusBar->setLandCommitted(committed); } - LLUUID tid; - msg->getUUID("MoneyData", "TransactionID", tid); + if (desc.empty() + || !gSavedSettings.getBOOL("NotifyMoneyChange")) + { + // ...nothing to display + return; + } + + // Suppress duplicate messages about the same transaction static std::deque<LLUUID> recent; - if(!desc.empty() && gSavedSettings.getBOOL("NotifyMoneyChange") - && (std::find(recent.rbegin(), recent.rend(), tid) == recent.rend())) + if (std::find(recent.rbegin(), recent.rend(), tid) != recent.rend()) { - // Make the user confirm the transaction, since they might - // have missed something during an event. - // *TODO: Translate - LLSD args; - + return; + } - // this is a marker to retrieve avatar name from server message: - // "<avatar name> paid you L$" - const std::string marker = "paid you L$"; + // Once the 'recent' container gets large enough, chop some + // off the beginning. + const U32 MAX_LOOKBACK = 30; + const S32 POP_FRONT_SIZE = 12; + if(recent.size() > MAX_LOOKBACK) + { + LL_DEBUGS("Messaging") << "Removing oldest transaction records" << LL_ENDL; + recent.erase(recent.begin(), recent.begin() + POP_FRONT_SIZE); + } + //LL_DEBUGS("Messaging") << "Pushing back transaction " << tid << LL_ENDL; + recent.push_back(tid); - args["MESSAGE"] = desc; + if (msg->has("TransactionInfo")) + { + // JAMESDEBUG TODO - for test, do both!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + process_money_balance_reply_legacy(desc); - // extract avatar name from system message - S32 marker_pos = desc.find(marker, 0); + // ...message has extended info for localization + process_money_balance_reply_extended(msg); + } + else + { + // *NOTE: Can remove this after server 1.40 is widely deployed. + process_money_balance_reply_legacy(desc); + } +} - std::string base_name = desc.substr(0, marker_pos); - - std::string name = base_name; - LLStringUtil::trim(name); +static void process_money_balance_reply_extended(LLMessageSystem* msg) +{ + // Added in server 1.40 and viewer 2.1, support for localization + // and agent ids for name lookup. + S32 transaction_type = 0; + LLUUID source_id; + BOOL is_source_group = FALSE; + LLUUID dest_id; + BOOL is_dest_group = FALSE; + S32 amount = 0; + std::string item_description; + + msg->getS32("TransactionInfo", "TransactionType", transaction_type); + msg->getUUID("TransactionInfo", "SourceID", source_id); + msg->getBOOL("TransactionInfo", "IsSourceGroup", is_source_group); + msg->getUUID("TransactionInfo", "DestID", dest_id); + msg->getBOOL("TransactionInfo", "IsDestGroup", is_dest_group); + msg->getS32("TransactionInfo", "Amount", amount); + msg->getString("TransactionInfo", "ItemDescription", item_description); + LL_INFOS("Money") << "MoneyBalanceReply source " << source_id + << " dest " << dest_id + << " type " << transaction_type + << " item " << item_description << LL_ENDL; + + const char* source_type = (is_source_group ? "group" : "agent"); + std::string source_slurl = + LLSLURL::buildCommand( source_type, source_id, "about"); + + const char* dest_type = (is_dest_group ? "group" : "agent"); + std::string dest_slurl = + LLSLURL::buildCommand( dest_type, dest_id, "about"); - // if name extracted and name cache contains avatar id send loggable notification - LLUUID from_id; - if(name.size() > 0 && gCacheName->getUUID(name, from_id)) - { - //description always comes not localized. lets fix this + // + // + // JAMESDEBUG TODO HERE!!! + // + // + + switch (transaction_type) + { + case TRANS_OBJECT_SALE: + case TRANS_LAND_SALE: + case TRANS_LAND_PASS_SALE: + case TRANS_GROUP_LAND_DEED: + case TRANS_GROUP_CREATE: + case TRANS_GROUP_JOIN: + case TRANS_UPLOAD_CHARGE: + default: + llinfos << "HERE!" << llendl; + break; + } +} + +// *NOTE: This can be removed after server 1.40 is widely deployed, as it will +// send an extra TransactionInfo block to allow proper localization. +static void process_money_balance_reply_legacy(const std::string& desc) +{ + LLSD args; + + // this is a marker to retrieve avatar name from server message: + // "<avatar name> paid you L$" + const std::string marker = "paid you L$"; + + args["MESSAGE"] = desc; - //ammount paid - std::string ammount = desc.substr(marker_pos + marker.length(),desc.length() - marker.length() - marker_pos); + // extract avatar name from system message + S32 marker_pos = desc.find(marker, 0); + + std::string base_name = desc.substr(0, marker_pos); - //reform description - LLStringUtil::format_map_t str_args; - str_args["NAME"] = base_name; - str_args["AMOUNT"] = ammount; - std::string new_description = LLTrans::getString("paid_you_ldollars", str_args); + std::string name = base_name; + LLStringUtil::trim(name); + // if name extracted and name cache contains avatar id send loggable notification + LLUUID from_id; + if(name.size() > 0 && gCacheName->getUUID(name, from_id)) + { + //description always comes not localized. lets fix this - args["MESSAGE"] = new_description; - args["NAME"] = name; - LLSD payload; - payload["from_id"] = from_id; - LLNotificationsUtil::add("PaymentRecived", args, payload); - } - //AD *HACK: Parsing incoming string to localize messages that come from server! EXT-5986 - // It's only a temporarily and ineffective measure. It doesn't affect performance much - // because we get here only for specific type of messages, but anyway it is not right to do it! - // *TODO: Server-side changes should be made and this code removed. - else + //ammount paid + std::string ammount = desc.substr(marker_pos + marker.length(),desc.length() - marker.length() - marker_pos); + + //reform description + LLStringUtil::format_map_t str_args; + str_args["NAME"] = LLCacheName::cleanFullName(name); + str_args["AMOUNT"] = ammount; + std::string new_description = LLTrans::getString("paid_you_ldollars", str_args); + + args["MESSAGE"] = new_description; + args["NAME"] = LLCacheName::cleanFullName(name); + LLSD payload; + payload["from_id"] = from_id; + LLNotificationsUtil::add("PaymentReceived", args, payload); + } + //AD *HACK: Parsing incoming string to localize messages that come from server! EXT-5986 + // It's only a temporarily and ineffective measure. It doesn't affect performance much + // because we get here only for specific type of messages, but anyway it is not right to do it! + // *TODO: Server-side changes should be made and this code removed. + else + { + if(desc.find("You paid")==0) { - if(desc.find("You paid")==0) - { // Regular expression for message parsing- change it in case of server-side changes. // Each set of parenthesis will later be used to find arguments of message we generate // in the end of this if- (.*) gives us name of money receiver, (\\d+)-amount of money we pay @@ -4865,7 +5112,7 @@ void process_money_balance_reply( LLMessageSystem* msg, void** ) std::string name = std::string(matches[1]); if(!name.empty()) { - str_args["[NAME]"] = name; + str_args["[NAME]"] = LLCacheName::cleanFullName(name); line = "you_paid_ldollars"; } @@ -4887,23 +5134,11 @@ void process_money_balance_reply( LLMessageSystem* msg, void** ) line = LLTrans::getString(line, str_args); args["MESSAGE"] = line; } - } - - LLNotificationsUtil::add("SystemMessage", args); } - // Once the 'recent' container gets large enough, chop some - // off the beginning. - const U32 MAX_LOOKBACK = 30; - const S32 POP_FRONT_SIZE = 12; - if(recent.size() > MAX_LOOKBACK) - { - LL_DEBUGS("Messaging") << "Removing oldest transaction records" << LL_ENDL; - recent.erase(recent.begin(), recent.begin() + POP_FRONT_SIZE); - } - //LL_DEBUGS("Messaging") << "Pushing back transaction " << tid << LL_ENDL; - recent.push_back(tid); + LLNotificationsUtil::add("SystemMessage", args); } + } bool handle_special_notification_callback(const LLSD& notification, const LLSD& response) @@ -5147,7 +5382,7 @@ void handle_show_mean_events(void *) //LLFloaterBump::showInstance(); } -void mean_name_callback(const LLUUID &id, const std::string& first, const std::string& last, BOOL always_false) +void mean_name_callback(const LLUUID &id, const std::string& full_name, bool is_group) { if (gNoRender) { @@ -5169,8 +5404,7 @@ void mean_name_callback(const LLUUID &id, const std::string& first, const std::s LLMeanCollisionData *mcd = *iter; if (mcd->mPerp == id) { - mcd->mFirstName = first; - mcd->mLastName = last; + mcd->mFullName = full_name; } } } @@ -5224,8 +5458,7 @@ void process_mean_collision_alert_message(LLMessageSystem *msgsystem, void **use { LLMeanCollisionData *mcd = new LLMeanCollisionData(gAgentID, perp, time, type, mag); gMeanCollisionList.push_front(mcd); - const BOOL is_group = FALSE; - gCacheName->get(perp, is_group, &mean_name_callback); + gCacheName->get(perp, false, boost::bind(&mean_name_callback, _1, _2, _3)); } } } @@ -5447,7 +5680,7 @@ void process_script_question(LLMessageSystem *msg, void **user_data) // so we'll reuse the same namespace for both throttle types. std::string throttle_name = owner_name; std::string self_name; - LLAgentUI::buildName( self_name ); + LLAgentUI::buildFullname( self_name ); if( owner_name == self_name ) { throttle_name = taskid.getString(); @@ -5483,7 +5716,7 @@ void process_script_question(LLMessageSystem *msg, void **user_data) S32 count = 0; LLSD args; args["OBJECTNAME"] = object_name; - args["NAME"] = owner_name; + args["NAME"] = LLCacheName::cleanFullName(owner_name); // check the received permission flags against each permission for (S32 i = 0; i < SCRIPT_PERMISSION_EOF; i++) @@ -6096,8 +6329,7 @@ void process_script_dialog(LLMessageSystem* msg, void**) LLNotificationPtr notification; if (!first_name.empty()) { - args["FIRST"] = first_name; - args["LAST"] = last_name; + args["NAME"] = LLCacheName::buildFullName(first_name, last_name); notification = LLNotifications::instance().add( LLNotification::Params("ScriptDialog").substitutions(args).payload(payload).form_elements(form.asLLSD())); } @@ -6130,7 +6362,7 @@ static LLNotificationFunctorRegistration callback_load_url_reg("LoadWebPage", ca // We've got the name of the person who owns the object hurling the url. // Display confirmation dialog. -void callback_load_url_name(const LLUUID& id, const std::string& first, const std::string& last, BOOL is_group) +void callback_load_url_name(const LLUUID& id, const std::string& full_name, bool is_group) { std::vector<LLSD>::iterator it; for (it = gLoadUrlList.begin(); it != gLoadUrlList.end(); ) @@ -6143,11 +6375,11 @@ void callback_load_url_name(const LLUUID& id, const std::string& first, const st std::string owner_name; if (is_group) { - owner_name = first + LLTrans::getString("Group"); + owner_name = full_name + LLTrans::getString("Group"); } else { - owner_name = first + " " + last; + owner_name = full_name; } // For legacy name-only mutes. @@ -6207,7 +6439,8 @@ void process_load_url(LLMessageSystem* msg, void**) // Add to list of pending name lookups gLoadUrlList.push_back(payload); - gCacheName->get(owner_id, owner_is_group, &callback_load_url_name); + gCacheName->get(owner_id, owner_is_group, + boost::bind(&callback_load_url_name, _1, _2, _3)); } diff --git a/indra/newview/llviewerobject.cpp b/indra/newview/llviewerobject.cpp index bb7933c10e..09e568d7be 100644 --- a/indra/newview/llviewerobject.cpp +++ b/indra/newview/llviewerobject.cpp @@ -69,6 +69,7 @@ #include "llface.h" #include "llfloaterproperties.h" #include "llfollowcam.h" +#include "llhudtext.h" #include "llselectmgr.h" #include "llrendersphere.h" #include "lltooldraganddrop.h" @@ -1080,7 +1081,7 @@ U32 LLViewerObject::processUpdateMessage(LLMessageSystem *mesgsys, // alpha was flipped so that it zero encoded better coloru.mV[3] = 255 - coloru.mV[3]; mText->setColor(LLColor4(coloru)); - mText->setStringUTF8(temp_string); + mText->setString(temp_string); if (mDrawable.notNull()) { @@ -1472,7 +1473,7 @@ U32 LLViewerObject::processUpdateMessage(LLMessageSystem *mesgsys, dp->unpackBinaryDataFixed(coloru.mV, 4, "Color"); coloru.mV[3] = 255 - coloru.mV[3]; mText->setColor(LLColor4(coloru)); - mText->setStringUTF8(temp_string); + mText->setString(temp_string); setChanged(TEXTURE); } @@ -4132,7 +4133,7 @@ void LLViewerObject::setDebugText(const std::string &utf8text) mText->setOnHUDAttachment(isHUDAttachment()); } mText->setColor(LLColor4::white); - mText->setStringUTF8(utf8text); + mText->setString(utf8text); mText->setZCompare(FALSE); mText->setDoFade(FALSE); updateText(); diff --git a/indra/newview/llviewerobject.h b/indra/newview/llviewerobject.h index be83fb7ef8..346f33727f 100644 --- a/indra/newview/llviewerobject.h +++ b/indra/newview/llviewerobject.h @@ -37,7 +37,6 @@ #include "llassetstorage.h" #include "lldarrayptr.h" -#include "llhudtext.h" #include "llhudicon.h" #include "llinventory.h" #include "llrefcount.h" @@ -60,6 +59,7 @@ class LLColor4; class LLFrameTimer; class LLDrawable; class LLHost; +class LLHUDText; class LLWorld; class LLNameValue; class LLNetMap; diff --git a/indra/newview/llviewerobjectlist.cpp b/indra/newview/llviewerobjectlist.cpp index 752aeaaab0..f682a05532 100644 --- a/indra/newview/llviewerobjectlist.cpp +++ b/indra/newview/llviewerobjectlist.cpp @@ -53,7 +53,7 @@ #include "lltooltip.h" #include "llworld.h" #include "llstring.h" -#include "llhudtext.h" +#include "llhudnametag.h" #include "lldrawable.h" #include "xform.h" #include "llsky.h" @@ -1201,7 +1201,7 @@ void LLViewerObjectList::generatePickList(LLCamera &camera) } } - LLHUDText::addPickable(mSelectPickList); + LLHUDNameTag::addPickable(mSelectPickList); for (std::vector<LLCharacter*>::iterator iter = LLCharacter::sInstances.begin(); iter != LLCharacter::sInstances.end(); ++iter) diff --git a/indra/newview/llviewerparcelmgr.cpp b/indra/newview/llviewerparcelmgr.cpp index a591cc1e14..c5d4ed1088 100644 --- a/indra/newview/llviewerparcelmgr.cpp +++ b/indra/newview/llviewerparcelmgr.cpp @@ -2075,10 +2075,9 @@ void LLViewerParcelMgr::deedLandToGroup() args["GROUP_NAME"] = group_name; if(mCurrentParcel->getContributeWithDeed()) { - std::string first_name, last_name; - gCacheName->getName(mCurrentParcel->getOwnerID(), first_name, last_name); - args["FIRST_NAME"] = first_name; - args["LAST_NAME"] = last_name; + std::string full_name; + gCacheName->getFullName(mCurrentParcel->getOwnerID(), full_name); + args["NAME"] = full_name; LLNotificationsUtil::add("DeedLandToGroupWithContribution",args, LLSD(), deedAlertCB); } else diff --git a/indra/newview/llviewerregion.cpp b/indra/newview/llviewerregion.cpp index c48668df9a..0ef38b2d7c 100644 --- a/indra/newview/llviewerregion.cpp +++ b/indra/newview/llviewerregion.cpp @@ -34,7 +34,9 @@ #include "llviewerregion.h" +// linden libraries #include "indra_constants.h" +#include "llavatarnamecache.h" // name lookup cap url #include "llfloaterreg.h" #include "llmath.h" #include "llhttpclient.h" @@ -174,7 +176,9 @@ public: mRegion->showReleaseNotes(); } } - + + mRegion->setCapabilitiesReceived(true); + if (STATE_SEED_GRANTED_WAIT == LLStartUp::getStartupState()) { LLStartUp::setStartupState( STATE_SEED_CAP_GRANTED ); @@ -231,7 +235,8 @@ LLViewerRegion::LLViewerRegion(const U64 &handle, // LLCapabilityListener binds all the globals it expects to need at // construction time. mCapabilityListener(host.getString(), gMessageSystem, *this, - gAgent.getID(), gAgent.getSessionID()) + gAgent.getID(), gAgent.getSessionID()), + mCapabilitiesReceived(false) { mWidth = region_width_meters; mOriginGlobal = from_region_handle(handle); @@ -1485,6 +1490,7 @@ void LLViewerRegion::setSeedCapability(const std::string& url) LLSD capabilityNames = LLSD::emptyArray(); capabilityNames.append("AttachmentResources"); + capabilityNames.append("AvatarPickerSearch"); capabilityNames.append("ChatSessionRequest"); capabilityNames.append("CopyInventoryFromNotecard"); capabilityNames.append("DispatchRegionInfo"); @@ -1495,6 +1501,7 @@ void LLViewerRegion::setSeedCapability(const std::string& url) capabilityNames.append("ObjectMediaNavigate"); capabilityNames.append("FetchLib"); capabilityNames.append("FetchLibDescendents"); + capabilityNames.append("GetDisplayNames"); capabilityNames.append("GetTexture"); capabilityNames.append("GroupProposalBallot"); capabilityNames.append("HomeLocation"); @@ -1516,6 +1523,7 @@ void LLViewerRegion::setSeedCapability(const std::string& url) capabilityNames.append("SendUserReport"); capabilityNames.append("SendUserReportWithScreenshot"); capabilityNames.append("ServerReleaseNotes"); + capabilityNames.append("SetDisplayName"); capabilityNames.append("StartGroupProposal"); capabilityNames.append("TextureStats"); capabilityNames.append("UntrustedSimulatorMessage"); @@ -1573,6 +1581,16 @@ std::string LLViewerRegion::getCapability(const std::string& name) const return iter->second; } +bool LLViewerRegion::capabilitiesReceived() const +{ + return mCapabilitiesReceived; +} + +void LLViewerRegion::setCapabilitiesReceived(bool received) +{ + mCapabilitiesReceived = received; +} + void LLViewerRegion::logActiveCapabilities() const { int count = 0; diff --git a/indra/newview/llviewerregion.h b/indra/newview/llviewerregion.h index 5c4d5a61fd..400180a01c 100644 --- a/indra/newview/llviewerregion.h +++ b/indra/newview/llviewerregion.h @@ -235,6 +235,11 @@ public: void setCapability(const std::string& name, const std::string& url); // implements LLCapabilityProvider virtual std::string getCapability(const std::string& name) const; + + // has region received its final (not seed) capability list? + bool capabilitiesReceived() const; + void setCapabilitiesReceived(bool received); + static bool isSpecialCapabilityName(const std::string &name); void logActiveCapabilities() const; @@ -415,6 +420,7 @@ private: private: bool mAlive; // can become false if circuit disconnects + bool mCapabilitiesReceived; //spatial partitions for objects in this region std::vector<LLSpatialPartition*> mObjectPartition; diff --git a/indra/newview/llviewerwindow.cpp b/indra/newview/llviewerwindow.cpp index 7a3f88ed6f..fea197dd11 100644 --- a/indra/newview/llviewerwindow.cpp +++ b/indra/newview/llviewerwindow.cpp @@ -122,6 +122,7 @@ #include "llglheaders.h" #include "lltooltip.h" #include "llhudmanager.h" +#include "llhudobject.h" #include "llhudview.h" #include "llimagebmp.h" #include "llimagej2c.h" @@ -1204,12 +1205,8 @@ BOOL LLViewerWindow::handlePaint(LLWindow *window, S32 x, S32 y, S32 width, S //SetBKColor(hdc, RGB(255, 255, 255)); FillRect(hdc, &wnd_rect, CreateSolidBrush(RGB(255, 255, 255))); - std::string name_str; - LLAgentUI::buildName(name_str); - std::string temp_str; - temp_str = llformat( "%s FPS %3.1f Phy FPS %2.1f Time Dil %1.3f", /* Flawfinder: ignore */ - name_str.c_str(), + temp_str = llformat( "FPS %3.1f Phy FPS %2.1f Time Dil %1.3f", /* Flawfinder: ignore */ LLViewerStats::getInstance()->mFPSStat.getMeanPerSec(), LLViewerStats::getInstance()->mSimPhysicsFPS.getPrev(0), LLViewerStats::getInstance()->mSimTimeDilation.getPrev(0)); @@ -1908,7 +1905,7 @@ void LLViewerWindow::reshape(S32 width, S32 height) // clear font width caches if (display_scale_changed) { - LLHUDText::reshape(); + LLHUDObject::reshapeAll(); } sendShapeToSim(); @@ -4081,7 +4078,7 @@ BOOL LLViewerWindow::rawSnapshot(LLImageRaw *raw, S32 image_width, S32 image_hei send_agent_pause(); //rescale fonts initFonts(scale_factor); - LLHUDText::reshape(); + LLHUDObject::reshapeAll(); } S32 output_buffer_offset_y = 0; @@ -4210,7 +4207,7 @@ BOOL LLViewerWindow::rawSnapshot(LLImageRaw *raw, S32 image_width, S32 image_hei if (high_res) { initFonts(1.f); - LLHUDText::reshape(); + LLHUDObject::reshapeAll(); } // Pre-pad image to number of pixels such that the line length is a multiple of 4 bytes (for BMP encoding) diff --git a/indra/newview/llvoavatar.cpp b/indra/newview/llvoavatar.cpp index 134af871ce..8fa845e54a 100644 --- a/indra/newview/llvoavatar.cpp +++ b/indra/newview/llvoavatar.cpp @@ -44,6 +44,7 @@ #include <ctype.h> #include "llaudioengine.h" +#include "llcachename.h" #include "noise.h" #include "sound_ids.h" @@ -51,8 +52,10 @@ #include "llagentcamera.h" #include "llagentwearables.h" #include "llanimationstates.h" +#include "llavatarnamecache.h" #include "llavatarpropertiesprocessor.h" #include "llviewercontrol.h" +#include "llcallingcard.h" // IDEVO for LLAvatarTracker #include "lldrawpoolavatar.h" #include "lldriverparam.h" #include "lleditingmotion.h" @@ -61,6 +64,8 @@ #include "llheadrotmotion.h" #include "llhudeffecttrail.h" #include "llhudmanager.h" +#include "llhudnametag.h" +#include "llhudtext.h" // for mText/mDebugText #include "llkeyframefallmotion.h" #include "llkeyframestandmotion.h" #include "llkeyframewalkmotion.h" @@ -652,12 +657,15 @@ LLVOAvatar::LLVOAvatar(const LLUUID& id, mAppearanceAnimating(FALSE), mNameString(), mTitle(), - mNameAway(FALSE), - mNameBusy(FALSE), - mNameMute(FALSE), + mNameAway(false), + mNameBusy(false), + mNameMute(false), + mNameAppearance(false), + mNameFriend(false), + mNameAlpha(0.f), mRenderGroupTitles(sRenderGroupTitles), - mNameAppearance(FALSE), - mNameCloud(FALSE), + mNameCloud(false), + mUseDisplayNames( LLAvatarNameCache::useDisplayNames() ), mFirstTEMessageReceived( FALSE ), mFirstAppearanceMessageReceived( FALSE ), mCulled( FALSE ), @@ -2673,204 +2681,242 @@ void LLVOAvatar::idleUpdateNameTag(const LLVector3& root_pos_last) && gSavedSettings.getS32("AvatarNameTagMode") )); } - if ( render_name ) + if ( !render_name ) { - BOOL new_name = FALSE; - if (visible_chat != mVisibleChat) + if (mNameText) { - mVisibleChat = visible_chat; - new_name = TRUE; + // ...clean up old name tag + mNameText->markDead(); + mNameText = NULL; + sNumVisibleChatBubbles--; } - - if (sRenderGroupTitles != mRenderGroupTitles) + return; + } + + BOOL new_name = FALSE; + if (visible_chat != mVisibleChat) + { + mVisibleChat = visible_chat; + new_name = TRUE; + } + + if (sRenderGroupTitles != mRenderGroupTitles) + { + mRenderGroupTitles = sRenderGroupTitles; + new_name = TRUE; + } + + // IDEVO HACK to force refresh + if (LLAvatarNameCache::useDisplayNames() != mUseDisplayNames) + { + mUseDisplayNames = LLAvatarNameCache::useDisplayNames(); + new_name = TRUE; + } + + // First Calculate Alpha + // If alpha > 0, create mNameText if necessary, otherwise delete it + F32 alpha = 0.f; + if (mAppAngle > 5.f) + { + const F32 START_FADE_TIME = NAME_SHOW_TIME - FADE_DURATION; + if (!visible_chat && sRenderName == RENDER_NAME_FADE && time_visible > START_FADE_TIME) + { + alpha = 1.f - (time_visible - START_FADE_TIME) / FADE_DURATION; + } + else { - mRenderGroupTitles = sRenderGroupTitles; - new_name = TRUE; + // ...not fading, full alpha + alpha = 1.f; } + } + else if (mAppAngle > 2.f) + { + // far away is faded out also + alpha = (mAppAngle-2.f)/3.f; + } + + if (alpha <= 0.f) + { + if (mNameText) + { + mNameText->markDead(); + mNameText = NULL; + sNumVisibleChatBubbles--; + } + return; + } + + if (!mNameText) + { + mNameText = static_cast<LLHUDNameTag*>( LLHUDObject::addHUDObject( + LLHUDObject::LL_HUD_NAME_TAG) ); + //mNameText->setMass(10.f); + mNameText->setSourceObject(this); + mNameText->setVertAlignment(LLHUDNameTag::ALIGN_VERT_TOP); + mNameText->setVisibleOffScreen(TRUE); + mNameText->setMaxLines(11); + mNameText->setFadeDistance(CHAT_NORMAL_RADIUS, 5.f); + sNumVisibleChatBubbles++; + new_name = TRUE; + } + + LLVector3 name_position = idleUpdateNameTagPosition(root_pos_last); + mNameText->setPositionAgent(name_position); + + idleUpdateNameTagText(new_name); + + idleUpdateNameTagAlpha(new_name, alpha); +} + +void LLVOAvatar::idleUpdateNameTagText(BOOL new_name) +{ + LLNameValue *title = getNVPair("Title"); + LLNameValue* firstname = getNVPair("FirstName"); + LLNameValue* lastname = getNVPair("LastName"); + + // Avatars must have a first and last name + if (!firstname || !lastname) return; + + bool is_away = mSignaledAnimations.find(ANIM_AGENT_AWAY) != mSignaledAnimations.end(); + bool is_busy = mSignaledAnimations.find(ANIM_AGENT_BUSY) != mSignaledAnimations.end(); + bool is_appearance = mSignaledAnimations.find(ANIM_AGENT_CUSTOMIZE) != mSignaledAnimations.end(); + bool is_muted; + if (isSelf()) + { + is_muted = false; + } + else + { + is_muted = LLMuteList::getInstance()->isMuted(getID()); + } + bool is_friend = LLAvatarTracker::instance().isBuddy(getID()); + bool is_cloud = getIsCloud(); + + // Rebuild name tag if state change detected + if (mNameString.empty() + || new_name + || (!title && !mTitle.empty()) + || (title && mTitle != title->getString()) + || is_away != mNameAway + || is_busy != mNameBusy + || is_muted != mNameMute + || is_appearance != mNameAppearance + || is_friend != mNameFriend + || is_cloud != mNameCloud) + { + LLColor4 name_tag_color = getNameTagColor(is_friend); + + clearNameTag(); - // First Calculate Alpha - // If alpha > 0, create mNameText if necessary, otherwise delete it + if (is_away || is_muted || is_busy || is_appearance) { - F32 alpha = 0.f; - if (mAppAngle > 5.f) + std::string line; + if (is_away) { - const F32 START_FADE_TIME = NAME_SHOW_TIME - FADE_DURATION; - if (!visible_chat && sRenderName == RENDER_NAME_FADE && time_visible > START_FADE_TIME) - { - alpha = 1.f - (time_visible - START_FADE_TIME) / FADE_DURATION; - } - else - { - // ...not fading, full alpha - alpha = 1.f; - } + line += LLTrans::getString("AvatarAway"); + line += ", "; + } + if (is_busy) + { + line += LLTrans::getString("AvatarBusy"); + line += ", "; + } + if (is_muted) + { + line += LLTrans::getString("AvatarMuted"); + line += ", "; + } + if (is_appearance) + { + line += LLTrans::getString("AvatarEditingAppearance"); + line += ", "; } - else if (mAppAngle > 2.f) + if (is_cloud) { - // far away is faded out also - alpha = (mAppAngle-2.f)/3.f; + line += LLTrans::getString("LoadingData"); + line += ", "; } + // trim last ", " + line.resize( line.length() - 2 ); + LLColor4 status_color = + LLUIColorTable::getInstance()->getColor("NameTagStatus"); + addNameTagLine(line, status_color, LLFontGL::NORMAL, + LLFontGL::getFontSansSerifSmall()); + } - if (alpha > 0.f) + if (sRenderGroupTitles + && title && title->getString() && title->getString()[0] != '\0') + { + LLColor4 group_color = + LLUIColorTable::getInstance()->getColor("NameTagGroup"); + std::string title_str = title->getString(); + LLStringFn::replace_ascii_controlchars(title_str,LL_UNKNOWN_CHAR); + addNameTagLine(title_str, group_color, LLFontGL::NORMAL, + LLFontGL::getFontSansSerifSmall()); + } + + static LLUICachedControl<bool> show_display_names("NameTagShowDisplayNames"); + static LLUICachedControl<bool> show_slids("NameTagShowSLIDs"); + + if (LLAvatarNameCache::useDisplayNames()) + { + LLAvatarName av_name; + if (!LLAvatarNameCache::get(getID(), &av_name)) { - if (!mNameText) - { - mNameText = (LLHUDText *)LLHUDObject::addHUDObject(LLHUDObject::LL_HUD_TEXT); - mNameText->setMass(10.f); - mNameText->setSourceObject(this); - mNameText->setVertAlignment(LLHUDText::ALIGN_VERT_TOP); - mNameText->setVisibleOffScreen(TRUE); - mNameText->setMaxLines(11); - mNameText->setFadeDistance(CHAT_NORMAL_RADIUS, 5.f); - mNameText->setUseBubble(TRUE); - sNumVisibleChatBubbles++; - new_name = TRUE; - } - - LLColor4 avatar_name_color = LLUIColorTable::instance().getColor( "AvatarNameColor" ); - avatar_name_color.setAlpha(alpha); - mNameText->setColor(avatar_name_color); - - LLQuaternion root_rot = mRoot.getWorldRotation(); - mNameText->setUsePixelSize(TRUE); - LLVector3 pixel_right_vec; - LLVector3 pixel_up_vec; - LLViewerCamera::getInstance()->getPixelVectors(root_pos_last, pixel_up_vec, pixel_right_vec); - LLVector3 camera_to_av = root_pos_last - LLViewerCamera::getInstance()->getOrigin(); - camera_to_av.normalize(); - LLVector3 local_camera_at = camera_to_av * ~root_rot; - LLVector3 local_camera_up = camera_to_av % LLViewerCamera::getInstance()->getLeftAxis(); - local_camera_up.normalize(); - local_camera_up = local_camera_up * ~root_rot; - - local_camera_up.scaleVec(mBodySize * 0.5f); - local_camera_at.scaleVec(mBodySize * 0.5f); + // ...call this function back when the name arrives + // and force a rebuild + LLAvatarNameCache::get(getID(), + boost::bind(&LLVOAvatar::clearNameTag, this)); + } - LLVector3 name_position = mRoot.getWorldPosition() + - (local_camera_up * root_rot) - - (projected_vec(local_camera_at * root_rot, camera_to_av)); - name_position += pixel_up_vec * 15.f; - mNameText->setPositionAgent(name_position); + // Might be blank if name not available yet, that's OK + if (show_display_names) + { + addNameTagLine(av_name.mDisplayName, name_tag_color, LLFontGL::NORMAL, + LLFontGL::getFontSansSerif()); } - else if (mNameText) + // Suppress SLID display if display name matches exactly (ugh) + if (show_slids && !av_name.mIsDisplayNameDefault) { - mNameText->markDead(); - mNameText = NULL; - sNumVisibleChatBubbles--; + // JAMESDEBUG HACK + LLColor4 slid_color = name_tag_color * 0.83f; + addNameTagLine(av_name.mSLID, slid_color, LLFontGL::NORMAL, + LLFontGL::getFontSansSerifSmall()); } } - - LLNameValue *title = getNVPair("Title"); - LLNameValue* firstname = getNVPair("FirstName"); - LLNameValue* lastname = getNVPair("LastName"); - - if (mNameText.notNull() && firstname && lastname) - { - const BOOL is_away = mSignaledAnimations.find(ANIM_AGENT_AWAY) != mSignaledAnimations.end(); - const BOOL is_busy = mSignaledAnimations.find(ANIM_AGENT_BUSY) != mSignaledAnimations.end(); - const BOOL is_appearance = mSignaledAnimations.find(ANIM_AGENT_CUSTOMIZE) != mSignaledAnimations.end(); - const BOOL is_muted = isSelf() ? FALSE : LLMuteList::getInstance()->isMuted(getID()); - const BOOL is_cloud = getIsCloud(); - - if (mNameString.empty() || - new_name || - (!title && !mTitle.empty()) || - (title && mTitle != title->getString()) || - (is_away != mNameAway || is_busy != mNameBusy || is_muted != mNameMute) - || is_appearance != mNameAppearance - || is_cloud != mNameCloud - ) - { - std::string line; - if (!sRenderGroupTitles) - { - // If all group titles are turned off, stack first name - // on a line above last name - line += firstname->getString(); - line += "\n"; - } - else if (title && title->getString() && title->getString()[0] != '\0') - { - line += title->getString(); - LLStringFn::replace_ascii_controlchars(line,LL_UNKNOWN_CHAR); - line += "\n"; - line += firstname->getString(); - } - else - { - line += firstname->getString(); - } + else + { + static LLUICachedControl<bool> small_avatar_names("SmallAvatarNames"); + const LLFontGL* font = + (small_avatar_names ? LLFontGL::getFontSansSerif() : LLFontGL::getFontSansSerifBig() ); + std::string full_name = + LLCacheName::buildFullName( firstname->getString(), lastname->getString() ); + addNameTagLine(full_name, name_tag_color, LLFontGL::NORMAL, font); + } - line += " "; - line += lastname->getString(); - BOOL need_comma = FALSE; + mNameAway = is_away; + mNameBusy = is_busy; + mNameMute = is_muted; + mNameAppearance = is_appearance; + mNameFriend = is_friend; + mNameCloud = is_cloud; + mTitle = title ? title->getString() : ""; + LLStringFn::replace_ascii_controlchars(mTitle,LL_UNKNOWN_CHAR); + new_name = TRUE; + } - if (is_away || is_muted || is_busy) - { - line += " ("; - if (is_away) - { - line += LLTrans::getString("AvatarAway"); - need_comma = TRUE; - } - if (is_busy) - { - if (need_comma) - { - line += ", "; - } - line += LLTrans::getString("AvatarBusy"); - need_comma = TRUE; - } - if (is_muted) - { - if (need_comma) - { - line += ", "; - } - line += LLTrans::getString("AvatarMuted"); - need_comma = TRUE; - } - line += ")"; - } - if (is_cloud) - { - line += "\n"; - line += "(" + LLTrans::getString("LoadingData") + ")"; - } - else if (is_appearance) - { - line += "\n"; - line += LLTrans::getString("AvatarEditingAppearance"); - } - mNameAway = is_away; - mNameBusy = is_busy; - mNameMute = is_muted; - mNameAppearance = is_appearance; - mNameCloud = is_cloud; - mTitle = title ? title->getString() : ""; - LLStringFn::replace_ascii_controlchars(mTitle,LL_UNKNOWN_CHAR); - mNameString = utf8str_to_wstring(line); - new_name = TRUE; - } - - if (visible_chat) - { - mNameText->setDropShadow(TRUE); - mNameText->setFont(LLFontGL::getFontSansSerif()); - mNameText->setTextAlignment(LLHUDText::ALIGN_TEXT_LEFT); - mNameText->setFadeDistance(CHAT_NORMAL_RADIUS * 2.f, 5.f); - if (new_name) - { - mNameText->setLabel(mNameString); - } + if (mVisibleChat) + { + mNameText->setFont(LLFontGL::getFontSansSerif()); + mNameText->setTextAlignment(LLHUDNameTag::ALIGN_TEXT_LEFT); + mNameText->setFadeDistance(CHAT_NORMAL_RADIUS * 2.f, 5.f); - char line[MAX_STRING]; /* Flawfinder: ignore */ - line[0] = '\0'; - std::deque<LLChat>::iterator chat_iter = mChats.begin(); - mNameText->clearString(); + char line[MAX_STRING]; /* Flawfinder: ignore */ + line[0] = '\0'; + std::deque<LLChat>::iterator chat_iter = mChats.begin(); + mNameText->clearString(); - LLColor4 new_chat = LLUIColorTable::instance().getColor( "AvatarNameColor" ); + LLColor4 new_chat = LLUIColorTable::instance().getColor( "NameTagChat" ); LLColor4 normal_chat = lerp(new_chat, LLColor4(0.8f, 0.8f, 0.8f, 1.f), 0.7f); LLColor4 old_chat = lerp(normal_chat, LLColor4(0.6f, 0.6f, 0.6f, 1.f), 0.7f); if (mTyping && mChats.size() >= MAX_BUBBLE_CHAT_UTTERANCES) @@ -2897,17 +2943,17 @@ void LLVOAvatar::idleUpdateNameTag(const LLVector3& root_pos_last) if (chat_fade_amt < 1.f) { F32 u = clamp_rescale(chat_fade_amt, 0.9f, 1.f, 0.f, 1.f); - mNameText->addLine(utf8str_to_wstring(chat_iter->mText), lerp(new_chat, normal_chat, u), style); + mNameText->addLine(chat_iter->mText, lerp(new_chat, normal_chat, u), style); } else if (chat_fade_amt < 2.f) { F32 u = clamp_rescale(chat_fade_amt, 1.9f, 2.f, 0.f, 1.f); - mNameText->addLine(utf8str_to_wstring(chat_iter->mText), lerp(normal_chat, old_chat, u), style); + mNameText->addLine(chat_iter->mText, lerp(normal_chat, old_chat, u), style); } else if (chat_fade_amt < 3.f) { // *NOTE: only remove lines down to minimum number - mNameText->addLine(utf8str_to_wstring(chat_iter->mText), old_chat, style); + mNameText->addLine(chat_iter->mText, old_chat, style); } } mNameText->setVisibleOffScreen(TRUE); @@ -2932,24 +2978,128 @@ void LLVOAvatar::idleUpdateNameTag(const LLVector3& root_pos_last) } else { - mNameText->setFont(LLFontGL::getFontSansSerif()); - mNameText->setTextAlignment(LLHUDText::ALIGN_TEXT_CENTER); - mNameText->setFadeDistance(CHAT_NORMAL_RADIUS, 5.f); - mNameText->setVisibleOffScreen(FALSE); - if (new_name) - { - mNameText->setLabel(""); - mNameText->setString(mNameString); + // ...not using chat bubbles, just names + mNameText->setTextAlignment(LLHUDNameTag::ALIGN_TEXT_CENTER); + mNameText->setFadeDistance(CHAT_NORMAL_RADIUS, 5.f); + mNameText->setVisibleOffScreen(FALSE); + } +} + +void LLVOAvatar::addNameTagLine(const std::string& line, const LLColor4& color, S32 style, const LLFontGL* font) +{ + llassert(mNameText); + if (mVisibleChat) + { + mNameText->addLabel(line); + } + else + { + mNameText->addLine(line, color, (LLFontGL::StyleFlags)style, font); + } + mNameString += line; + mNameString += '\n'; +} + +void LLVOAvatar::clearNameTag() +{ + mNameString.clear(); + if (mNameText) + { + mNameText->setLabel(""); + mNameText->setString( "" ); + } +} + +//static +void LLVOAvatar::invalidateNameTag(const LLUUID& agent_id) +{ + LLViewerObject* obj = gObjectList.findObject(agent_id); + if (!obj) return; + + LLVOAvatar* avatar = dynamic_cast<LLVOAvatar*>(obj); + if (!avatar) return; + + avatar->clearNameTag(); +} + +//static +void LLVOAvatar::invalidateNameTags() +{ + std::vector<LLCharacter*>::iterator it = LLCharacter::sInstances.begin(); + for ( ; it != LLCharacter::sInstances.end(); ++it) + { + LLVOAvatar* avatar = dynamic_cast<LLVOAvatar*>(*it); + if (!avatar) continue; + if (avatar->isDead()) continue; + + avatar->clearNameTag(); + } +} + +// Compute name tag position during idle update +LLVector3 LLVOAvatar::idleUpdateNameTagPosition(const LLVector3& root_pos_last) +{ + LLQuaternion root_rot = mRoot.getWorldRotation(); + LLVector3 pixel_right_vec; + LLVector3 pixel_up_vec; + LLViewerCamera::getInstance()->getPixelVectors(root_pos_last, pixel_up_vec, pixel_right_vec); + LLVector3 camera_to_av = root_pos_last - LLViewerCamera::getInstance()->getOrigin(); + camera_to_av.normalize(); + LLVector3 local_camera_at = camera_to_av * ~root_rot; + LLVector3 local_camera_up = camera_to_av % LLViewerCamera::getInstance()->getLeftAxis(); + local_camera_up.normalize(); + local_camera_up = local_camera_up * ~root_rot; + + local_camera_up.scaleVec(mBodySize * 0.5f); + local_camera_at.scaleVec(mBodySize * 0.5f); + + LLVector3 name_position = mRoot.getWorldPosition() + + (local_camera_up * root_rot) - + (projected_vec(local_camera_at * root_rot, camera_to_av)); + name_position += pixel_up_vec * 15.f; + return name_position; } - } + +void LLVOAvatar::idleUpdateNameTagAlpha(BOOL new_name, F32 alpha) +{ + llassert(mNameText); + + if (new_name + || alpha != mNameAlpha) + { + mNameText->setAlpha(alpha); + mNameAlpha = alpha; + } +} + +LLColor4 LLVOAvatar::getNameTagColor(bool is_friend) +{ + const char* color_name; + if (is_friend) + { + color_name = "NameTagFriend"; + } + else if (LLAvatarNameCache::useDisplayNames()) + { + // ...color based on whether SLID "matches" a computed display + // name + LLAvatarName av_name; + if (LLAvatarNameCache::get(getID(), &av_name) + && av_name.mIsDisplayNameDefault) + { + color_name = "NameTagMatch"; + } + else + { + color_name = "NameTagMismatch"; } } - else if (mNameText) + else { - mNameText->markDead(); - mNameText = NULL; - sNumVisibleChatBubbles--; + // ...not using display names + color_name = "NameTagLegacy"; } + return LLUIColorTable::getInstance()->getColor( color_name ); } //-------------------------------------------------------------------- @@ -7545,9 +7695,7 @@ std::string LLVOAvatar::getFullname() const LLNameValue* last = getNVPair("LastName"); if (first && last) { - name += first->getString(); - name += " "; - name += last->getString(); + name = LLCacheName::buildFullName( first->getString(), last->getString() ); } return name; diff --git a/indra/newview/llvoavatar.h b/indra/newview/llvoavatar.h index c80d59966c..7043f677f7 100644 --- a/indra/newview/llvoavatar.h +++ b/indra/newview/llvoavatar.h @@ -65,7 +65,7 @@ extern const LLUUID ANIM_AGENT_WALK_ADJUST; class LLTexLayerSet; class LLVoiceVisualizer; -class LLHUDText; +class LLHUDNameTag; class LLHUDEffectSpiral; class LLTexGlobalColor; class LLVOAvatarBoneInfo; @@ -210,6 +210,15 @@ public: void idleUpdateLoadingEffect(); void idleUpdateWindEffect(); void idleUpdateNameTag(const LLVector3& root_pos_last); + void idleUpdateNameTagText(BOOL new_name); + LLVector3 idleUpdateNameTagPosition(const LLVector3& root_pos_last); + void idleUpdateNameTagAlpha(BOOL new_name, F32 alpha); + LLColor4 getNameTagColor(bool is_friend); + void clearNameTag(); + static void invalidateNameTag(const LLUUID& agent_id); + // force all name tags to rebuild, useful when display names turned on/off + static void invalidateNameTags(); + void addNameTagLine(const std::string& line, const LLColor4& color, S32 style, const LLFontGL* font); void idleUpdateRenderCost(); void idleUpdateTractorBeam(); void idleUpdateBelowWater(); @@ -824,21 +833,24 @@ protected: static void getAnimLabels(LLDynamicArray<std::string>* labels); static void getAnimNames(LLDynamicArray<std::string>* names); private: - LLWString mNameString; + std::string mNameString; // UTF-8 title + name + status std::string mTitle; - BOOL mNameAway; - BOOL mNameBusy; - BOOL mNameMute; - BOOL mNameAppearance; - BOOL mNameCloud; + bool mNameAway; + bool mNameBusy; + bool mNameMute; + bool mNameAppearance; + bool mNameFriend; + bool mNameCloud; + F32 mNameAlpha; BOOL mRenderGroupTitles; + bool mUseDisplayNames; // IDEVO HACK to force refresh //-------------------------------------------------------------------- // Display the name (then optionally fade it out) //-------------------------------------------------------------------- public: LLFrameTimer mChatTimer; - LLPointer<LLHUDText> mNameText; + LLPointer<LLHUDNameTag> mNameText; private: LLFrameTimer mTimeVisible; std::deque<LLChat> mChats; diff --git a/indra/newview/llvoiceclient.cpp b/indra/newview/llvoiceclient.cpp index 542ec16547..5e12d16ad7 100644 --- a/indra/newview/llvoiceclient.cpp +++ b/indra/newview/llvoiceclient.cpp @@ -7179,18 +7179,8 @@ void LLVoiceClient::notifyFriendObservers() void LLVoiceClient::lookupName(const LLUUID &id) { - BOOL is_group = FALSE; - gCacheName->get(id, is_group, &LLVoiceClient::onAvatarNameLookup); -} - -//static -void LLVoiceClient::onAvatarNameLookup(const LLUUID& id, const std::string& first, const std::string& last, BOOL is_group) -{ - if(gVoiceClient) - { - std::string name = llformat("%s %s", first.c_str(), last.c_str()); - gVoiceClient->avatarNameResolved(id, name); - } + gCacheName->get(id, false, + boost::bind(&LLVoiceClient::avatarNameResolved, this, _1, _2)); } void LLVoiceClient::avatarNameResolved(const LLUUID &id, const std::string &name) diff --git a/indra/newview/llvoiceclient.h b/indra/newview/llvoiceclient.h index a29c386182..70b1e7be79 100644 --- a/indra/newview/llvoiceclient.h +++ b/indra/newview/llvoiceclient.h @@ -482,7 +482,6 @@ static void updatePosition(void); void removeObserver(LLFriendObserver* observer); void lookupName(const LLUUID &id); - static void onAvatarNameLookup(const LLUUID& id, const std::string& first, const std::string& last, BOOL is_group); void avatarNameResolved(const LLUUID &id, const std::string &name); typedef std::vector<std::string> deviceList; diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index 2d2fc38573..a22dab6f08 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -70,6 +70,8 @@ #include "llfloaterreg.h" #include "llgldbg.h" #include "llhudmanager.h" +#include "llhudnametag.h" +#include "llhudtext.h" #include "lllightconstants.h" #include "llresmgr.h" #include "llselectmgr.h" @@ -2079,6 +2081,7 @@ void LLPipeline::shiftObjects(const LLVector3 &offset) } LLHUDText::shiftAll(offset); + LLHUDNameTag::shiftAll(offset); display_update_camera(); } @@ -5272,7 +5275,8 @@ LLViewerObject* LLPipeline::lineSegmentIntersectInWorld(const LLVector3& start, ++iter) { LLVOAvatar* av = (LLVOAvatar*) *iter; - if (av->mNameText.notNull() && av->mNameText->lineSegmentIntersect(start, local_end, position)) + if (av->mNameText.notNull() + && av->mNameText->lineSegmentIntersect(start, local_end, position)) { drawable = av->mDrawable; local_end = position; diff --git a/indra/newview/skins/default/colors.xml b/indra/newview/skins/default/colors.xml index 99603530d8..580cbbd7d0 100644 --- a/indra/newview/skins/default/colors.xml +++ b/indra/newview/skins/default/colors.xml @@ -115,9 +115,6 @@ name="AlertTextColor" value="0.58 0.66 0.84 1" /> <color - name="AvatarNameColor" - reference="White" /> - <color name="AvatarListItemIconDefaultColor" reference="White" /> <color @@ -525,6 +522,38 @@ <color name="MultiSliderTriangleColor" reference="Unused?" /> + <!-- + <color + name="NameTagBackground" + value="0.85 0.85 0.85 0.80" /> + --> + <color + name="NameTagBackground" + value="0 0 0 1" /> + <color + name="NameTagChat" + reference="White" /> + <color + name="NameTagFriend" + value="0.447 0.784 0.663 1" /> + <color + name="NameTagGroup" + value="1 1 1 1" /> + <color + name="NameTagLegacy" + reference="White" /> + <color + name="NameTagMatch" + reference="White" /> + <color + name="NameTagMismatch" + value="1 0.776 0.212 1" /> + <color + name="NameTagSLID" + value="1 1 1 1" /> + <color + name="NameTagStatus" + value="1 1 1 1" /> <color name="NetMapBackgroundColor" value="0 0 0 0" /> @@ -559,6 +588,9 @@ name="NotifyTextColor" reference="White" /> <color + name="ObjectBubbleColor" + reference="DkGray_66" /> + <color name="ObjectChatColor" reference="EmphasisColor" /> <color diff --git a/indra/newview/skins/default/textures/Rounded_Rect.png b/indra/newview/skins/default/textures/Rounded_Rect.png Binary files differnew file mode 100644 index 0000000000..c270c28039 --- /dev/null +++ b/indra/newview/skins/default/textures/Rounded_Rect.png diff --git a/indra/newview/skins/default/textures/icons/Generic_Group_Large.png b/indra/newview/skins/default/textures/icons/Generic_Group_Large.png Binary files differnew file mode 100644 index 0000000000..4d4f1e1bee --- /dev/null +++ b/indra/newview/skins/default/textures/icons/Generic_Group_Large.png diff --git a/indra/newview/skins/default/textures/icons/Person_Check.png b/indra/newview/skins/default/textures/icons/Person_Check.png Binary files differnew file mode 100644 index 0000000000..f8638540d4 --- /dev/null +++ b/indra/newview/skins/default/textures/icons/Person_Check.png diff --git a/indra/newview/skins/default/textures/icons/Person_Star.png b/indra/newview/skins/default/textures/icons/Person_Star.png Binary files differnew file mode 100644 index 0000000000..ad10580ac4 --- /dev/null +++ b/indra/newview/skins/default/textures/icons/Person_Star.png diff --git a/indra/newview/skins/default/textures/locked_image.j2c b/indra/newview/skins/default/textures/locked_image.j2c Binary files differnew file mode 100644 index 0000000000..9e8998d675 --- /dev/null +++ b/indra/newview/skins/default/textures/locked_image.j2c diff --git a/indra/newview/skins/default/textures/map_infohub.tga b/indra/newview/skins/default/textures/map_infohub.tga Binary files differnew file mode 100644 index 0000000000..545b8e532c --- /dev/null +++ b/indra/newview/skins/default/textures/map_infohub.tga diff --git a/indra/newview/skins/default/textures/textures.xml b/indra/newview/skins/default/textures/textures.xml index 15bac6de0d..8a1b618afe 100644 --- a/indra/newview/skins/default/textures/textures.xml +++ b/indra/newview/skins/default/textures/textures.xml @@ -330,6 +330,8 @@ with the same filename but different name <texture name="Pause_Off" file_name="icons/Pause_Off.png" preload="false" /> <texture name="Pause_Over" file_name="icons/Pause_Over.png" preload="false" /> <texture name="Pause_Press" file_name="icons/Pause_Press.png" preload="false" /> + <texture name="Person_Check" file_name="icons/Person_Check.png" preload="false" /> + <texture name="Person_Star" file_name="icons/Person_Star.png" preload="false" /> <texture name="Play_Off" file_name="icons/Play_Off.png" preload="false" /> <texture name="Play_Over" file_name="icons/Play_Over.png" preload="false" /> <texture name="Play_Press" file_name="icons/Play_Press.png" preload="false" /> @@ -359,6 +361,7 @@ with the same filename but different name <texture name="Resize_Corner" file_name="windows/Resize_Corner.png" preload="true" /> + <texture name="Rounded_Rect" file_name="Rounded_Rect.png" preload="true" scale.left="6" scale.top="24" scale.right="58" scale.bottom="6" /> <texture name="Rounded_Square" file_name="rounded_square.j2c" preload="true" scale.left="16" scale.top="16" scale.right="112" scale.bottom="16" /> <texture name="Row_Selection" file_name="navbar/Row_Selection.png" preload="false" /> diff --git a/indra/newview/skins/default/xui/da/floater_windlight_options.xml b/indra/newview/skins/default/xui/da/floater_windlight_options.xml index 65f3f67a70..56f94b24e9 100644 --- a/indra/newview/skins/default/xui/da/floater_windlight_options.xml +++ b/indra/newview/skins/default/xui/da/floater_windlight_options.xml @@ -1,18 +1,18 @@ -<?xml version="1.0" encoding="utf-8" standalone="yes"?> +<?xml version="1.0" encoding="utf-8" standalone="yes" ?> <floater name="WindLight floater" title="AVANCERET OPSÆTNING FOR HIMMEL"> <text name="KeyFramePresetsText"> Faste indstillinger: </text> - <button label="Ny" label_selected="Ny" name="WLNewPreset"/> - <button label="Gem" label_selected="Gem" name="WLSavePreset"/> - <button label="Slet" label_selected="Slet" name="WLDeletePreset"/> - <button label="Dags cyklus" label_selected="Dags cyklus" name="WLDayCycleMenuButton"/> + <button label="Ny" label_selected="Ny" name="WLNewPreset" /> + <button label="Gem" label_selected="Gem" name="WLSavePreset" /> + <button label="Slet" label_selected="Slet" name="WLDeletePreset" /> + <button label="Dags cyklus" label_selected="Dags cyklus" name="WLDayCycleMenuButton" /> <tab_container name="WindLight Tabs"> <panel label="ATMOSFÆRE" name="Atmosphere"> <text name="BHText"> Blå - horisont </text> - <button label="?" name="WLBlueHorizonHelp"/> + <button label="?" name="WLBlueHorizonHelp" /> <text name="BHText2"> R </text> @@ -25,19 +25,19 @@ <text name="BHText5"> I </text> - <slider label="" name="WLBlueHorizonR"/> - <slider label="" name="WLBlueHorizonG"/> - <slider label="" name="WLBlueHorizonB"/> - <slider label="" name="WLBlueHorizonI"/> + <slider label="" name="WLBlueHorizonR" /> + <slider label="" name="WLBlueHorizonG" /> + <slider label="" name="WLBlueHorizonB" /> + <slider label="" name="WLBlueHorizonI" /> <text name="BDensText"> Dis - horisont </text> - <button label="?" name="WLHazeHorizonHelp"/> - <slider label="" name="WLHazeHorizon"/> + <button label="?" name="WLHazeHorizonHelp" /> + <slider label="" name="WLHazeHorizon" /> <text name="BDensText2"> Blå - tæthed </text> - <button label="?" name="WLBlueDensityHelp"/> + <button label="?" name="WLBlueDensityHelp" /> <text name="BHText6"> R </text> @@ -50,36 +50,36 @@ <text name="BHText9"> I </text> - <slider label="" name="WLBlueDensityR"/> - <slider label="" name="WLBlueDensityG"/> - <slider label="" name="WLBlueDensityB"/> - <slider label="" name="WLBlueDensityI"/> + <slider label="" name="WLBlueDensityR" /> + <slider label="" name="WLBlueDensityG" /> + <slider label="" name="WLBlueDensityB" /> + <slider label="" name="WLBlueDensityI" /> <text name="HDText"> Dis - intensitet </text> - <button label="?" name="WLHazeDensityHelp"/> - <slider label="" name="WLHazeDensity"/> + <button label="?" name="WLHazeDensityHelp" /> + <slider label="" name="WLHazeDensity" /> <text name="DensMultText"> Densitet faktor </text> - <button label="?" name="WLDensityMultHelp"/> - <slider label="" name="WLDensityMult"/> + <button label="?" name="WLDensityMultHelp" /> + <slider label="" name="WLDensityMult" /> <text name="WLDistanceMultText"> Distance faktor </text> - <button label="?" name="WLDistanceMultHelp"/> - <slider label="" name="WLDistanceMult"/> + <button label="?" name="WLDistanceMultHelp" /> + <slider label="" name="WLDistanceMult" /> <text name="MaxAltText"> Maximum højde </text> - <button label="?" name="WLMaxAltitudeHelp"/> - <slider label="" name="WLMaxAltitude"/> + <button label="?" name="WLMaxAltitudeHelp" /> + <slider label="" name="WLMaxAltitude" /> </panel> <panel label="LYS" name="Lighting"> <text name="SLCText"> Sol/Måne farve </text> - <button label="?" name="WLSunlightColorHelp"/> + <button label="?" name="WLSunlightColorHelp" /> <text name="BHText"> R </text> @@ -92,19 +92,19 @@ <text name="BHText4"> I </text> - <slider label="" name="WLSunlightR"/> - <slider label="" name="WLSunlightG"/> - <slider label="" name="WLSunlightB"/> - <slider label="" name="WLSunlightI"/> + <slider label="" name="WLSunlightR" /> + <slider label="" name="WLSunlightG" /> + <slider label="" name="WLSunlightB" /> + <slider label="" name="WLSunlightI" /> <text name="TODText"> Sol/Måne position </text> - <button label="?" name="WLTimeOfDayHelp"/> - <slider label="" name="WLSunAngle"/> + <button label="?" name="WLTimeOfDayHelp" /> + <slider label="" name="WLSunAngle" /> <text name="WLAmbientText"> Omgivende </text> - <button label="?" name="WLAmbientHelp"/> + <button label="?" name="WLAmbientHelp" /> <text name="BHText5"> R </text> @@ -117,37 +117,37 @@ <text name="BHText8"> I </text> - <slider label="" name="WLAmbientR"/> - <slider label="" name="WLAmbientG"/> - <slider label="" name="WLAmbientB"/> - <slider label="" name="WLAmbientI"/> + <slider label="" name="WLAmbientR" /> + <slider label="" name="WLAmbientG" /> + <slider label="" name="WLAmbientB" /> + <slider label="" name="WLAmbientI" /> <text name="WLEastAngleText"> Øst vinkel </text> - <button label="?" name="WLEastAngleHelp"/> - <slider label="" name="WLEastAngle"/> + <button label="?" name="WLEastAngleHelp" /> + <slider label="" name="WLEastAngle" /> <text name="SunGlowText"> Sol glød </text> - <button label="?" name="WLSunGlowHelp"/> - <slider label="Fokus " name="WLGlowB"/> - <slider label="Størr. " name="WLGlowR"/> + <button label="?" name="WLSunGlowHelp" /> + <slider label="Fokus " name="WLGlowB" /> + <slider label="Størr. " name="WLGlowR" /> <text name="SceneGammaText"> Lysintensitet (gamma) </text> - <button label="?" name="WLSceneGammaHelp"/> - <slider label="" name="WLGamma"/> + <button label="?" name="WLSceneGammaHelp" /> + <slider label="" name="WLGamma" /> <text name="WLStarText"> Stjerne intensitet </text> - <button label="?" name="WLStarBrightnessHelp"/> - <slider label="" name="WLStarAlpha"/> + <button label="?" name="WLStarBrightnessHelp" /> + <slider label="" name="WLStarAlpha" /> </panel> <panel label="SKYER" name="Clouds"> <text name="WLCloudColorText"> Farve på skyer </text> - <button label="?" name="WLCloudColorHelp"/> + <button label="?" name="WLCloudColorHelp" /> <text name="BHText"> R </text> @@ -160,14 +160,14 @@ <text name="BHText4"> I </text> - <slider label="" name="WLCloudColorR"/> - <slider label="" name="WLCloudColorG"/> - <slider label="" name="WLCloudColorB"/> - <slider label="" name="WLCloudColorI"/> + <slider label="" name="WLCloudColorR" /> + <slider label="" name="WLCloudColorG" /> + <slider label="" name="WLCloudColorB" /> + <slider label="" name="WLCloudColorI" /> <text name="WLCloudColorText2"> Skyer XY/Tæthed </text> - <button label="?" name="WLCloudDensityHelp"/> + <button label="?" name="WLCloudDensityHelp" /> <text name="BHText5"> X </text> @@ -177,23 +177,23 @@ <text name="BHText7"> T </text> - <slider label="" name="WLCloudX"/> - <slider label="" name="WLCloudY"/> - <slider label="" name="WLCloudDensity"/> + <slider label="" name="WLCloudX" /> + <slider label="" name="WLCloudY" /> + <slider label="" name="WLCloudDensity" /> <text name="WLCloudCoverageText"> Skydække </text> - <button label="?" name="WLCloudCoverageHelp"/> - <slider label="" name="WLCloudCoverage"/> + <button label="?" name="WLCloudCoverageHelp" /> + <slider label="" name="WLCloudCoverage" /> <text name="WLCloudScaleText"> Skystørrelse </text> - <button label="?" name="WLCloudScaleHelp"/> - <slider label="" name="WLCloudScale"/> + <button label="?" name="WLCloudScaleHelp" /> + <slider label="" name="WLCloudScale" /> <text name="WLCloudDetailText"> Sky detaljer(XY/tæthed) </text> - <button label="?" name="WLCloudDetailHelp"/> + <button label="?" name="WLCloudDetailHelp" /> <text name="BHText8"> X </text> @@ -203,23 +203,23 @@ <text name="BHText10"> T </text> - <slider label="" name="WLCloudDetailX"/> - <slider label="" name="WLCloudDetailY"/> - <slider label="" name="WLCloudDetailDensity"/> + <slider label="" name="WLCloudDetailX" /> + <slider label="" name="WLCloudDetailY" /> + <slider label="" name="WLCloudDetailDensity" /> <text name="WLCloudScrollXText"> Sky drift X </text> - <button label="?" name="WLCloudScrollXHelp"/> - <check_box label="Lås" name="WLCloudLockX"/> - <slider label="" name="WLCloudScrollX"/> + <button label="?" name="WLCloudScrollXHelp" /> + <check_box label="Lås" name="WLCloudLockX" /> + <slider label="" name="WLCloudScrollX" /> <text name="WLCloudScrollYText"> Sky drift Y </text> - <button label="?" name="WLCloudScrollYHelp"/> - <check_box label="Lås" name="WLCloudLockY"/> - <slider label="" name="WLCloudScrollY"/> - <check_box label="Benyt simple skyer" name="DrawClassicClouds"/> - <button label="?" name="WLClassicCloudsHelp"/> + <button label="?" name="WLCloudScrollYHelp" /> + <check_box label="Lås" name="WLCloudLockY" /> + <slider label="" name="WLCloudScrollY" /> + <check_box label="Benyt simple skyer" name="DrawClassicClouds" /> + <button label="?" name="WLClassicCloudsHelp" /> </panel> </tab_container> <string name="WLDefaultSkyNames"> diff --git a/indra/newview/skins/default/xui/da/panel_classified_info.xml b/indra/newview/skins/default/xui/da/panel_classified_info.xml index 28f8936457..0bb52b8fa6 100644 --- a/indra/newview/skins/default/xui/da/panel_classified_info.xml +++ b/indra/newview/skins/default/xui/da/panel_classified_info.xml @@ -40,7 +40,7 @@ </layout_panel> <layout_panel name="descr_layout_panel"> <text name="classified_desc_label" value="Beskrivelse:"/> - <text_editor name="classified_desc" value="[description]"/> + <text_editor name="classified_desc" value="[description]"/> </layout_panel> </layout_stack> </panel> diff --git a/indra/newview/skins/default/xui/en/floater_about_land.xml b/indra/newview/skins/default/xui/en/floater_about_land.xml index 40c6b14a4a..233db347e4 100644 --- a/indra/newview/skins/default/xui/en/floater_about_land.xml +++ b/indra/newview/skins/default/xui/en/floater_about_land.xml @@ -1892,7 +1892,7 @@ Only large parcels can be listed in search. name="access_estate_defined"> (Defined by the Estate) </panel.string> - <panel.string + <panel.string name="allow_public_access"> Allow Public Access ([MATURITY]) </panel.string> diff --git a/indra/newview/skins/default/xui/en/floater_avatar_picker.xml b/indra/newview/skins/default/xui/en/floater_avatar_picker.xml index f59badfcb4..489b7c0536 100644 --- a/indra/newview/skins/default/xui/en/floater_avatar_picker.xml +++ b/indra/newview/skins/default/xui/en/floater_avatar_picker.xml @@ -5,11 +5,11 @@ height="350" layout="topleft" min_height="200" - min_width="265" + min_width="400" name="avatarpicker" help_topic="avatarpicker" title="CHOOSE RESIDENT" - width="265"> + width="500"> <floater.string name="not_found"> '[TEXT]' not found @@ -40,7 +40,7 @@ name="ResidentChooserTabs" tab_position="top" top="20" - width="265"> + width="500"> <panel border="none" height="150" @@ -83,14 +83,28 @@ left_pad="5" name="Find" width="45" /> - <scroll_list - follows="all" - height="98" - layout="topleft" - left="0" - name="SearchResults" - top="52" - width="132" /> + <scroll_list + draw_heading="true" + follows="all" + height="98" + layout="topleft" + left="0" + name="SearchResults" + top="52" + width="132"> + <columns + label="Name" + name="name" + width="100" /> + <columns + label="SL ID" + name="slid" + width="100" /> + <columns + label="Age" + name="age" + width="100" /> + </scroll_list> </panel> <panel border="none" @@ -207,16 +221,16 @@ </panel> </tab_container> <button - follows="right|bottom" + follows="left|bottom" height="23" label="OK" label_selected="OK" name="ok_btn" top_pad="3" - left="46" + left="10" width="100" /> <button - follows="right|bottom" + follows="left|bottom" height="23" label="Cancel" label_selected="Cancel" diff --git a/indra/newview/skins/default/xui/en/floater_bumps.xml b/indra/newview/skins/default/xui/en/floater_bumps.xml index 303c28d7c8..1f2fe62b3c 100644 --- a/indra/newview/skins/default/xui/en/floater_bumps.xml +++ b/indra/newview/skins/default/xui/en/floater_bumps.xml @@ -14,23 +14,23 @@ </floater.string> <floater.string name="bump"> - [TIME] [FIRST] [LAST] bumped you + [TIME] [NAME] bumped you </floater.string> <floater.string name="llpushobject"> - [TIME] [FIRST] [LAST] pushed you with a script + [TIME] [NAME] pushed you with a script </floater.string> <floater.string name="selected_object_collide"> - [TIME] [FIRST] [LAST] hit you with an object + [TIME] [NAME] hit you with an object </floater.string> <floater.string name="scripted_object_collide"> - [TIME] [FIRST] [LAST] hit you with a scripted object + [TIME] [NAME] hit you with a scripted object </floater.string> <floater.string name="physical_object_collide"> - [TIME] [FIRST] [LAST] hit you with a physical object + [TIME] [NAME] hit you with a physical object </floater.string> <floater.string name="timeStr"> diff --git a/indra/newview/skins/default/xui/en/floater_pay.xml b/indra/newview/skins/default/xui/en/floater_pay.xml index 509cffe490..3730890e59 100644 --- a/indra/newview/skins/default/xui/en/floater_pay.xml +++ b/indra/newview/skins/default/xui/en/floater_pay.xml @@ -16,28 +16,7 @@ name="payee_resident"> Pay Resident </string> - <text - type="string" - length="1" - follows="left|top" - height="18" - layout="topleft" - left="12" - name="payee_label" - top="22" - width="75"> - Pay: - </text> - <icon - height="16" - width="16" - image_name="Generic_Person" - mouse_opaque="true" - name="icon_person" - tool_tip="Person" - top_pad="0" - left="10" - /> + <text type="string" length="1" @@ -45,10 +24,11 @@ font="SansSerifSmall" height="16" layout="topleft" - left_pad="7" + left="10" name="payee_name" - width="210"> - [FIRST] [LAST] + top="25" + width="230"> + Test Name </text> <button height="23" diff --git a/indra/newview/skins/default/xui/en/floater_pay_object.xml b/indra/newview/skins/default/xui/en/floater_pay_object.xml index d09a0a0535..c65dd6e49f 100644 --- a/indra/newview/skins/default/xui/en/floater_pay_object.xml +++ b/indra/newview/skins/default/xui/en/floater_pay_object.xml @@ -2,7 +2,7 @@ <floater legacy_header_height="18" can_minimize="false" - height="220" + height="225" layout="topleft" name="Give Money" help_topic="give_money" @@ -16,27 +16,15 @@ name="payee_resident"> Pay Resident </string> - <icon - height="16" - width="16" - image_name="Generic_Person" - mouse_opaque="true" - name="icon_person" - tool_tip="Person" - top_pad="24" - left="10" - /> <text - type="string" - length="1" follows="left|top" height="16" layout="topleft" - left_pad="7" - top_delta="3" + left="10" + top_pad="24" name="payee_name" - width="184"> - [FIRST] [LAST] + width="200"> + Ericacita Moostopolison </text> <text type="string" @@ -45,9 +33,9 @@ halign="left" height="14" layout="topleft" - left="34" + left="10" name="object_name_label" - top_pad="0" + top_pad="5" width="180"> Via object: </text> @@ -58,7 +46,7 @@ mouse_opaque="true" name="icon_object" tool_tip="Objects" - top_pad="0" + top_pad="5" left="10" /> <text diff --git a/indra/newview/skins/default/xui/en/floater_tools.xml b/indra/newview/skins/default/xui/en/floater_tools.xml index cc9e72cfb5..db49757069 100644 --- a/indra/newview/skins/default/xui/en/floater_tools.xml +++ b/indra/newview/skins/default/xui/en/floater_tools.xml @@ -252,7 +252,7 @@ height="28" control_name="EditLinkedParts" label="Edit linked" - layout="topleft" + layout="topleft" name="checkbox edit linked parts" > <check_box.commit_callback function="BuildTool.selectComponent"/> @@ -757,7 +757,7 @@ name="General" top="16" width="295"> -<panel.string + <panel.string name="text deed continued"> Deed </panel.string> diff --git a/indra/newview/skins/default/xui/en/inspect_avatar.xml b/indra/newview/skins/default/xui/en/inspect_avatar.xml index 194ae151d2..a7ab021225 100644 --- a/indra/newview/skins/default/xui/en/inspect_avatar.xml +++ b/indra/newview/skins/default/xui/en/inspect_avatar.xml @@ -9,7 +9,7 @@ bg_opaque_image="Inspector_Background" can_close="false" can_minimize="false" - height="148" + height="164" layout="topleft" name="inspect_avatar" single_instance="true" @@ -47,9 +47,20 @@ follows="top|left" height="16" left="8" + name="user_slid" + font="SansSerifSmall" + text_color="White" + value="James.pinden" + width="175" + use_ellipses="true" /> + <text + follows="top|left" + height="16" + left="8" name="user_subtitle" font="SansSerifSmall" text_color="White" + top_pad="0" value="11 Months, 3 days old" width="175" use_ellipses="true" /> @@ -108,7 +119,7 @@ height="20" label="Add Friend" left="8" - top="119" + top="135" name="add_friend_btn" width="90" /> <button diff --git a/indra/newview/skins/default/xui/en/notifications.xml b/indra/newview/skins/default/xui/en/notifications.xml index 149a254f49..b01a071c2a 100644 --- a/indra/newview/skins/default/xui/en/notifications.xml +++ b/indra/newview/skins/default/xui/en/notifications.xml @@ -257,7 +257,7 @@ Save all changes to clothing/body parts? name="GrantModifyRights" type="alertmodal"> Granting modify rights to another Resident allows them to change, delete or take ANY objects you may have in-world. Be VERY careful when handing out this permission. -Do you want to grant modify rights for [FIRST_NAME] [LAST_NAME]? +Do you want to grant modify rights for [NAME]? <usetemplate name="okcancelbuttons" notext="No" @@ -280,7 +280,7 @@ Do you want to grant modify rights for the selected Residents? icon="alertmodal.tga" name="RevokeModifyRights" type="alertmodal"> -Do you want to revoke modify rights for [FIRST_NAME] [LAST_NAME]? +Do you want to revoke modify rights for [NAME]? <usetemplate name="okcancelbuttons" notext="No" @@ -2049,7 +2049,7 @@ Would you be my friend? icon="alertmodal.tga" name="RemoveFromFriends" type="alertmodal"> -Do you want to remove [FIRST_NAME] [LAST_NAME] from your Friends List? +Do you want to remove [NAME] from your Friends List? <usetemplate name="okcancelbuttons" notext="Cancel" @@ -2302,7 +2302,7 @@ Deed this [AREA] m² of land to the group '[GROUP_NAME]'? name="DeedLandToGroupWithContribution" type="alertmodal"> By deeding this parcel, the group will be required to have and maintain sufficient land use credits. -The deed will include a simultaneous land contribution to the group from '[FIRST_NAME] [LAST_NAME]'. +The deed will include a simultaneous land contribution to the group from '[NAME]'. The purchase price of the land is not refunded to the owner. If a deeded parcel is sold, the sale price will be divided evenly among group members. Deed this [AREA] m² of land to the group '[GROUP_NAME]'? @@ -3069,6 +3069,68 @@ You are no longer frozen. <notification icon="alertmodal.tga" + name="SetDisplayName" + type="alertmodal"> +Change your display name? + <form name="form"> + <input name="display_name" type="text"> +[DISPLAY_NAME] + </input> + <button + default="true" + index="0" + name="Change" + text="Change"/> + <button + index="1" + name="Cancel" + text="Cancel"/> + </form> + </notification> + + <notification + icon="alertmodal.tga" + name="SetDisplayNameSuccess" + type="alertmodal"> +Thanks for updating your name! + +Just like in real life, it takes a while for everyone to learn about a new name. Please allow [HOURS] hours for your name to update in object ownership, scripts, search, etc. + </notification> + + <notification + icon="alertmodal.tga" + name="SetDisplayNameFailedGeneric" + type="alertmodal"> + Sorry, we could not set your display name. Please try again later. + </notification> + + <notification + icon="alertmodal.tga" + name="AgentDisplayNameUpdateThresholdExceeded" + type="alertmodal"> +Sorry, you can only change your name once every 24 hours. + +Please try again later. + </notification> + + <notification + icon="alertmodal.tga" + name="AgentDisplayNameSetBlocked" + type="alertmodal"> + Sorry, we could not set your requested name because it contains a banned word. + + Please try a different name. + </notification> + + <notification + icon="notifytip.tga" + name="DisplayNameUpdate" + type="notifytip"> + [OLD_NAME] ([SLID]) is now known as [NEW_NAME]. + </notification> + + <notification + icon="alertmodal.tga" name="OfferTeleport" type="alertmodal"> Offer a teleport to your location with the following message? @@ -4370,14 +4432,14 @@ Topic: [SUBJECT], Message: [MESSAGE] icon="notifytip.tga" name="FriendOnline" type="notifytip"> -[FIRST] [LAST] is Online +[NAME] is Online </notification> <notification icon="notifytip.tga" name="FriendOffline" type="notifytip"> -[FIRST] [LAST] is Offline +[NAME] is Offline </notification> <notification @@ -4544,13 +4606,6 @@ You cannot remove protected categories. <notification icon="notifytip.tga" - name="OfferedCard" - type="notifytip"> -You have offered a calling card to [FIRST] [LAST] - </notification> - - <notification - icon="notifytip.tga" name="UnableToBuyWhileDownloading" type="notifytip"> Unable to buy while downloading object data. @@ -4703,7 +4758,14 @@ Please select at least one type of content to search (General, Moderate, or Adul <notification icon="notify.tga" - name="PaymentRecived" + name="PaymentReceived" + type="notify"> +[MESSAGE] + </notification> + + <notification + icon="notify.tga" + name="PaymentSent" type="notify"> [MESSAGE] </notification> @@ -4792,7 +4854,7 @@ The objects you own on the selected parcel of land have been returned back to yo icon="notify.tga" name="OtherObjectsReturned" type="notify"> -The objects on the selected parcel of land that is owned by [FIRST] [LAST] have been returned to his or her inventory. +The objects on the selected parcel of land that is owned by [NAME] have been returned to his or her inventory. </notification> <notification @@ -5417,7 +5479,7 @@ Grant this request? icon="notify.tga" name="ScriptDialog" type="notify"> -[FIRST] [LAST]'s '[TITLE]' +[NAME]'s '[TITLE]' [MESSAGE] <form name="form"> <button @@ -5630,21 +5692,21 @@ Click Accept to join the call or Decline to decline the invitation. Click Block icon="notify.tga" name="AutoUnmuteByIM" type="notify"> -[FIRST] [LAST] was sent an instant message and has been automatically unblocked. +[NAME] was sent an instant message and has been automatically unblocked. </notification> <notification icon="notify.tga" name="AutoUnmuteByMoney" type="notify"> -[FIRST] [LAST] was given money and has been automatically unblocked. +[NAME] was given money and has been automatically unblocked. </notification> <notification icon="notify.tga" name="AutoUnmuteByInventory" type="notify"> -[FIRST] [LAST] was offered inventory and has been automatically unblocked. +[NAME] was offered inventory and has been automatically unblocked. </notification> <notification diff --git a/indra/newview/skins/default/xui/en/panel_edit_classified.xml b/indra/newview/skins/default/xui/en/panel_edit_classified.xml index 7383edf63d..62a364473c 100644 --- a/indra/newview/skins/default/xui/en/panel_edit_classified.xml +++ b/indra/newview/skins/default/xui/en/panel_edit_classified.xml @@ -218,12 +218,12 @@ value="Content type:" width="250" /> <icons_combo_box - follows="left|top" - height="23" + follows="left|top" + height="23" label="General Content" layout="topleft" left="10" - name="content_type" + name="content_type" top_pad="5" width="156"> <icons_combo_box.drop_down_button @@ -233,8 +233,8 @@ pad_left="3"/> <icons_combo_box.item label="Moderate Content" - name="mature_ci" - value="Mature"> + name="mature_ci" + value="Mature"> <item.columns halign="center" type="icon" @@ -243,8 +243,8 @@ </icons_combo_box.item> <icons_combo_box.item label="General Content" - name="pg_ci" - value="PG"> + name="pg_ci" + value="PG"> <item.columns halign="center" type="icon" diff --git a/indra/newview/skins/default/xui/en/panel_edit_profile.xml b/indra/newview/skins/default/xui/en/panel_edit_profile.xml index dff2b9a214..bce988da9d 100644 --- a/indra/newview/skins/default/xui/en/panel_edit_profile.xml +++ b/indra/newview/skins/default/xui/en/panel_edit_profile.xml @@ -87,12 +87,41 @@ min_height="300" left="0" width="292"> + <text + follows="top|left" + font="SansSerifBigBold" + height="20" + layout="topleft" + left="10" + name="user_name" + text_color="white" + top="4" + value="Hamilton Hitchings" + width="280" /> + <text + follows="top|left" + height="13" + layout="topleft" + left="10" + name="user_slid" + text_color="LtGray" + top_pad="5" + value="(hamilton.linden)" + width="150" /> + <button + follows="top|left" + height="20" + label="Set Name..." + left="170" + name="set_name" + top_delta="-4" + width="110" /> <panel name="lifes_images_panel" follows="left|top|right" height="244" layout="topleft" - top="0" + top="37" left="0" width="292"> <panel @@ -145,8 +174,8 @@ height="102" layout="topleft" left="123" - top="25" - max_length="511" + top="62" + max_length="512" name="sl_description_edit" width="157" word_wrap="true"> @@ -200,8 +229,8 @@ height="102" layout="topleft" left="123" - max_length="254" - top="157" + max_length="512" + top="195" name="fl_description_edit" width="157" word_wrap="true"> diff --git a/indra/newview/skins/default/xui/en/panel_landmarks.xml b/indra/newview/skins/default/xui/en/panel_landmarks.xml index a7e87f2a1e..8d43cc816c 100644 --- a/indra/newview/skins/default/xui/en/panel_landmarks.xml +++ b/indra/newview/skins/default/xui/en/panel_landmarks.xml @@ -3,7 +3,7 @@ name="Landmarks" top="0" height="400" - layout="topleft" + layout="topleft" left="0" width="313" help_topic="panel_landmarks" @@ -88,7 +88,7 @@ </accordion_tab> </accordion> <panel - background_visible="true" + background_visible="true" bevel_style="none" bottom="0" follows="left|right|bottom" diff --git a/indra/newview/skins/default/xui/en/panel_login.xml b/indra/newview/skins/default/xui/en/panel_login.xml index a725548e61..e004596f2b 100644 --- a/indra/newview/skins/default/xui/en/panel_login.xml +++ b/indra/newview/skins/default/xui/en/panel_login.xml @@ -60,28 +60,31 @@ name="first_name_text" top="20" left="20" width="150"> -First name: + Second Life ID or Name: </text> <line_editor follows="left|bottom" height="22" -label="First" +label="e.g. bobsmith12 or Stellar Sunshine" left_delta="0" -max_length="31" -name="first_name_edit" +max_length="63" +name="login_id_edit" +prevalidate_callback="ascii" select_on_focus="true" -tool_tip="[SECOND_LIFE] First Name" +tool_tip="[SECOND_LIFE] ID" top_pad="0" - width="135" /> + width="200" /> <text follows="left|bottom" font="SansSerifSmall" height="16" - left_pad="8" + left="230" name="last_name_text" top="20" + visible="false" width="150"> - Last name: </text> + Last name: + </text> <line_editor follows="left|bottom" height="22" @@ -91,12 +94,13 @@ name="last_name_edit" select_on_focus="true" tool_tip="[SECOND_LIFE] Last Name" top_pad="0" + visible="false" width="135" /> <text follows="left|bottom" font="SansSerifSmall" height="15" -left_pad="8" +left="230" name="password_text" top="20" width="150"> diff --git a/indra/newview/skins/default/xui/en/panel_people.xml b/indra/newview/skins/default/xui/en/panel_people.xml index b79ef1e287..f5228f5d35 100644 --- a/indra/newview/skins/default/xui/en/panel_people.xml +++ b/indra/newview/skins/default/xui/en/panel_people.xml @@ -81,7 +81,7 @@ Looking for people to hang out with? Try the [secondlife:///app/worldmap World M width="317"> <panel background_opaque="true" - background_visible="true" + background_visible="true" bg_alpha_color="DkGray" bg_opaque_color="DkGray" follows="all" @@ -157,7 +157,7 @@ Looking for people to hang out with? Try the [secondlife:///app/worldmap World M </panel> <panel background_opaque="true" - background_visible="true" + background_visible="true" bg_alpha_color="DkGray" bg_opaque_color="DkGray" follows="all" @@ -282,7 +282,7 @@ Looking for people to hang out with? Try the [secondlife:///app/worldmap World M </panel> <panel background_opaque="true" - background_visible="true" + background_visible="true" bg_alpha_color="DkGray" bg_opaque_color="DkGray" follows="all" @@ -372,7 +372,7 @@ Looking for people to hang out with? Try the [secondlife:///app/worldmap World M </panel> <panel background_opaque="true" - background_visible="true" + background_visible="true" bg_alpha_color="DkGray" bg_opaque_color="DkGray" follows="all" diff --git a/indra/newview/skins/default/xui/en/panel_preferences_advanced.xml b/indra/newview/skins/default/xui/en/panel_preferences_advanced.xml index 0129d97616..063d51e08d 100644 --- a/indra/newview/skins/default/xui/en/panel_preferences_advanced.xml +++ b/indra/newview/skins/default/xui/en/panel_preferences_advanced.xml @@ -320,4 +320,12 @@ Automatic position for: function="Floater.Show" parameter="pref_joystick" /> </button> + <check_box + follows="top|left" + height="15" + label="Use Display Names (PLACEHOLDER)" + left="30" + name="display_names_check" + width="237" + tool_tip="Check to use display names in chat, IM, name tags, etc."/> </panel> diff --git a/indra/newview/skins/default/xui/en/panel_preferences_general.xml b/indra/newview/skins/default/xui/en/panel_preferences_general.xml index 9eaabbe77b..15db679f2a 100644 --- a/indra/newview/skins/default/xui/en/panel_preferences_general.xml +++ b/indra/newview/skins/default/xui/en/panel_preferences_general.xml @@ -222,49 +222,90 @@ </text> <radio_group control_name="AvatarNameTagMode" - height="20" + height="45" layout="topleft" left="50" name="Name_Tag_Preference"> <radio_item label="Off" - layout="topleft" name="radio" value="0" width="75" /> <radio_item label="On" - layout="topleft" - left_pad="12" + left_delta="0" name="radio2" + top_pad="5" value="1" width="75" /> <radio_item label="Show briefly" - layout="topleft" - left_pad="12" + left_delta="0" name="radio3" + top_pad="5" value="2" width="160" /> </radio_group> <check_box enabled_control="AvatarNameTagMode" + control_name="SmallAvatarNames" + height="16" + initial_value="true" + label="Small name tags" + layout="topleft" + left="70" + name="small_avatar_names_checkbox" + top_pad="4" + width="200" /> + <check_box + enabled_control="AvatarNameTagMode" control_name="RenderNameShowSelf" height="16" label="Show my name" layout="topleft" - left="50" + left="70" name="show_my_name_checkbox1" + top_pad="4" width="300" /> - <check_box + <text + follows="left|top" + height="15" + layout="topleft" + left="250" + name="name_tags_textbox" + top="175" + width="200"> + Tags show: + </text> + <check_box + control_name="NameTagShowGroupTitles" enabled_control="AvatarNameTagMode" - control_name="RenderShowGroupTitleAll" height="16" - label="Show group titles" - layout="topleft" - left_delta="175" + label="Group titles" + left="265" name="show_all_title_checkbox1" - width="200" /> + tool_tip="Show group titles, like Officer or Member" + top_pad="5" /> + <!-- + <check_box + control_name="NameTagShowDisplayNames" + enabled_control="AvatarNameTagMode" + height="16" + label="Display names" + left_delta="0" + name="show_display_names" + tool_tip="Show display names, like José Sanchez" + top_pad="5" /> + --> + <check_box + control_name="NameTagShowSLIDs" + enabled_control="AvatarNameTagMode" + height="16" + label="Second Life IDs" + left_delta="0" + name="show_slids" + tool_tip="Show SL ID, like bobsmith123" + top_pad="5" /> <text type="string" length="1" @@ -273,7 +314,7 @@ layout="topleft" left="30" name="effects_color_textbox" - top_pad="15" + top="290" width="200"> My effects: </text> @@ -354,7 +395,7 @@ use_ellipses="false" hover="false" commit_on_focus_lost = "true" - follows="left|top|right" + follows="left|top" height="60" layout="topleft" left="50" diff --git a/indra/newview/skins/default/xui/en/panel_profile_view.xml b/indra/newview/skins/default/xui/en/panel_profile_view.xml index 5a96ba2dd2..aca778193a 100644 --- a/indra/newview/skins/default/xui/en/panel_profile_view.xml +++ b/indra/newview/skins/default/xui/en/panel_profile_view.xml @@ -48,8 +48,19 @@ height="13" layout="topleft" left="45" + name="user_slid" + text_color="LtGray" + value="" + width="150" /> + <text + follows="top|left" + halign="right" + height="13" + layout="topleft" + left="150" name="status" text_color="LtGray_50" + top_delta="0" value="Online" width="150" /> <tab_container diff --git a/indra/newview/skins/default/xui/en/sidepanel_task_info.xml b/indra/newview/skins/default/xui/en/sidepanel_task_info.xml index d46783e058..0f7dc47401 100644 --- a/indra/newview/skins/default/xui/en/sidepanel_task_info.xml +++ b/indra/newview/skins/default/xui/en/sidepanel_task_info.xml @@ -167,7 +167,7 @@ left_pad="0" name="Creator Name" top_delta="0" - width="140"> + width="225"> Erica Linden </text> <text @@ -191,7 +191,7 @@ left_pad="0" name="Owner Name" top_delta="0" - width="140"> + width="225"> Erica Linden </text> <text diff --git a/indra/newview/skins/default/xui/en/strings.xml b/indra/newview/skins/default/xui/en/strings.xml index f544449d02..5bf1cd50f1 100644 --- a/indra/newview/skins/default/xui/en/strings.xml +++ b/indra/newview/skins/default/xui/en/strings.xml @@ -95,7 +95,7 @@ <string name="TooltipObjectIMUrl">Click to view this object's description</string> <string name="TooltipMapUrl">Click to view this location on a map</string> <string name="TooltipSLAPP">Click to run the secondlife:// command</string> - <string name="CurrentURL" value=" CurrentURL: [CurrentURL]" /> + <string name="CurrentURL" value=" CurrentURL: [CurrentURL]" /> <string name="TooltipPrice" value=" L$[PRICE]-" /> @@ -2997,7 +2997,7 @@ If you continue to receive this message, contact the [SUPPORT_SITE]. You are the only user in this session. </string> <string name="offline_message"> - [FIRST] [LAST] is offline. + [NAME] is offline. </string> <string name="invite_message"> Click the [BUTTON NAME] button to accept/connect to this voice chat. @@ -3086,6 +3086,7 @@ If you continue to receive this message, contact the [SUPPORT_SITE]. <string name="you_paid_ldollars_no_info">You paid L$[AMOUNT].</string> <string name="you_paid_ldollars_no_reason">You paid [NAME] L$[AMOUNT].</string> <string name="you_paid_ldollars_no_name">You paid L$[AMOUNT] [REASON].</string> + <string name="for item">for [ITEM]</string> <string name="for a parcel of land">for a parcel of land</string> <string name="for a land access pass">for a land access pass</string> <string name="for deeding land">for deeding land</string> diff --git a/indra/newview/skins/default/xui/es/notifications.xml b/indra/newview/skins/default/xui/es/notifications.xml index 49f30ae807..777d52ca3a 100644 --- a/indra/newview/skins/default/xui/es/notifications.xml +++ b/indra/newview/skins/default/xui/es/notifications.xml @@ -1347,7 +1347,7 @@ Esta actualización no es obligatoria, pero te sugerimos instalarla para mejorar </notification> <notification name="BusyModeSet"> Pasar al modo ocupado. -Se ocultará el chat y los mensajes instantáneos (éstos recibirán tu Respuesta en el modo ocupado). Se rehusarán todos los ofrecimientos de teleporte. Todas las ofertas de inventario irán a tu Papelera. +Se ocultará el chat y los mensajes instantáneos (éstos recibirán tu Respuesta en el modo ocupado). Se rehusarán todos los ofrecimientos de teleporte. Todas las ofertas de inventario irán a tu Papelera. <usetemplate ignoretext="Cambio mi estado al modo ocupado" name="okignore" yestext="OK"/> </notification> <notification name="JoinedTooManyGroupsMember"> @@ -1814,7 +1814,7 @@ Linden Lab </form> </notification> <notification name="ConfirmDeleteProtectedCategory"> - La carpeta '[FOLDERNAME]' pertenece al sistema, y borrar carpetas del sistema puede provocar inestabilidad. ¿Estás seguro de que quieres borrarla? + La carpeta '[FOLDERNAME]' pertenece al sistema, y borrar carpetas del sistema puede provocar inestabilidad. ¿Estás seguro de que quieres borrarla? <usetemplate ignoretext="Confirmar antes de borrar una carpeta del sistema" name="okcancelignore" notext="Cancelar" yestext="OK"/> </notification> <notification name="ConfirmEmptyTrash"> @@ -2387,7 +2387,7 @@ Esto añadirá un marcador en tu inventario para que puedas enviarle rápidament Si permaneces en esta región serás desconectado. </notification> <notification name="RegionRestartSeconds"> - Esta región se reiniciará en [SECONDS] segundos. + Esta región se reiniciará en [SECONDS] segundos. Si permaneces en esta región serás desconectado. </notification> <notification name="LoadWebPage"> @@ -2454,7 +2454,7 @@ Si no confias en este objeto y en su creador, deberías rehusar esta petición. <notification name="BuyLindenDollarSuccess"> ¡Gracias por tu pago! -Tu saldo de L$ se actualizará cuando se complete el proceso. Si el proceso tarda más de 20 minutos, se cancelará tu transacción, y la cantidad se cargará en tu saldo de US$. +Tu saldo de L$ se actualizará cuando se complete el proceso. Si el proceso tarda más de 20 minutos, se cancelará tu transacción, y la cantidad se cargará en tu saldo de US$. Puedes revisar el estado de tu pago en el Historial de transacciones de tu [http://secondlife.com/account/ Panel de Control] </notification> diff --git a/indra/newview/skins/default/xui/fr/notifications.xml b/indra/newview/skins/default/xui/fr/notifications.xml index d38afe13d2..a678782e4a 100644 --- a/indra/newview/skins/default/xui/fr/notifications.xml +++ b/indra/newview/skins/default/xui/fr/notifications.xml @@ -178,7 +178,7 @@ Voulez-vous continuer ? <notification name="JoinGroupNoCost"> Vous vous apprêtez à rejoindre le groupe [NAME]. Voulez-vous continuer ? - <usetemplate name="okcancelbuttons" notext="Annuler" yestext="Rejoindre"/> + <usetemplate name="okcancelbuttons" notext="Annuler" yestext="Fusionner"/> </notification> <notification name="JoinGroupCannotAfford"> Rejoindre ce groupe coûte [COST] L$. diff --git a/indra/newview/skins/default/xui/ja/panel_group_land_money.xml b/indra/newview/skins/default/xui/ja/panel_group_land_money.xml index ef6d8cce47..c0449f1221 100644 --- a/indra/newview/skins/default/xui/ja/panel_group_land_money.xml +++ b/indra/newview/skins/default/xui/ja/panel_group_land_money.xml @@ -45,7 +45,7 @@ あなたの貢献: </text> <text name="your_contribution_units"> - m² + 平方メートル </text> <text name="your_contribution_max_value"> (最大 [AMOUNT]) diff --git a/indra/newview/skins/default/xui/ja/panel_group_roles.xml b/indra/newview/skins/default/xui/ja/panel_group_roles.xml index 8a629be910..db6fe268c7 100644 --- a/indra/newview/skins/default/xui/ja/panel_group_roles.xml +++ b/indra/newview/skins/default/xui/ja/panel_group_roles.xml @@ -17,7 +17,7 @@ Ctrl キーを押しながらメンバー名をクリックすると <name_list name="member_list"> <name_list.columns label="メンバー" name="name"/> <name_list.columns label="寄付" name="donated"/> - <name_list.columns label="ログイン" name="online"/> + <name_list.columns label="ステータス" name="online"/> </name_list> <button label="招待" name="member_invite"/> <button label="追放" name="member_eject"/> @@ -44,7 +44,7 @@ Ctrl キーを押しながらメンバー名をクリックすると <filter_editor label="役割を選別" name="filter_input"/> <scroll_list name="role_list"> <scroll_list.columns label="役割" name="name"/> - <scroll_list.columns label="タイトル" name="title"/> + <scroll_list.columns label="肩書き" name="title"/> <scroll_list.columns label="#" name="members"/> </scroll_list> <button label="新しい役割" name="role_create"/> diff --git a/indra/newview/skins/default/xui/pt/strings.xml b/indra/newview/skins/default/xui/pt/strings.xml index 51b6581d42..66fbbfc916 100644 --- a/indra/newview/skins/default/xui/pt/strings.xml +++ b/indra/newview/skins/default/xui/pt/strings.xml @@ -1260,10 +1260,10 @@ Script não encontrado no servidor. </string> <string name="CompileQueueProblemDownloading"> - Problema no download + Problema no download </string> <string name="CompileQueueInsufficientPermDownload"> - Permissões insuficientes para fazer o download do script. + Permissões insuficientes para fazer o download do script. </string> <string name="CompileQueueInsufficientPermFor"> Permissões insuficientes para @@ -1564,7 +1564,7 @@ (vai atualizar depois de publicado) </string> <string name="NoPicksClassifiedsText"> - Você não criou nenhum Destaque ou Anúncio. Clique no botão "+" para criar um Destaque ou Anúncio. + Você não criou nenhum Destaque ou Anúncio. Clique no botão "+" para criar um Destaque ou Anúncio. </string> <string name="NoAvatarPicksClassifiedsText"> O usuário não tem nenhum destaque ou anúncio diff --git a/indra/newview/tests/lldateutil_test.cpp b/indra/newview/tests/lldateutil_test.cpp index 7ba82fbd2c..e19983db8f 100644 --- a/indra/newview/tests/lldateutil_test.cpp +++ b/indra/newview/tests/lldateutil_test.cpp @@ -189,4 +189,14 @@ namespace tut LLDateUtil::ageFromDate("12/13/2009", now), "3 weeks old" ); } + + template<> template<> + void dateutil_object_t::test<6>() + { + set_test_name("ISO dates"); + LLDate now(std::string("2010-01-04T12:00:00Z")); + ensure_equals("days", + LLDateUtil::ageFromDateISO("2009-12-13", now), + "3 weeks old" ); + } } |