diff options
Diffstat (limited to 'indra/newview/llviewermessage.cpp')
-rw-r--r-- | indra/newview/llviewermessage.cpp | 138 |
1 files changed, 109 insertions, 29 deletions
diff --git a/indra/newview/llviewermessage.cpp b/indra/newview/llviewermessage.cpp index a04c919310..c35173a7d4 100644 --- a/indra/newview/llviewermessage.cpp +++ b/indra/newview/llviewermessage.cpp @@ -2,31 +2,25 @@ * @file llviewermessage.cpp * @brief Dumping ground for viewer-side message system callbacks. * - * $LicenseInfo:firstyear=2002&license=viewergpl$ - * - * Copyright (c) 2002-2009, Linden Research, Inc. - * + * $LicenseInfo:firstyear=2002&license=viewerlgpl$ * 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 + * Copyright (C) 2010, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. * - * 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 + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. * - * 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. + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * - * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO - * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, - * COMPLETENESS OR PERFORMANCE. + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA * $/LicenseInfo$ */ @@ -83,10 +77,12 @@ #include "llimview.h" #include "llspeakers.h" #include "lltrans.h" +#include "lltranslate.h" #include "llviewerfoldertype.h" #include "lluri.h" #include "llviewergenericmessage.h" #include "llviewermenu.h" +#include "llviewerjoystick.h" #include "llviewerobjectlist.h" #include "llviewerparcelmgr.h" #include "llviewerstats.h" @@ -2189,7 +2185,9 @@ void process_improved_im(LLMessageSystem *msg, void **user_data) std::string saved; if(offline == IM_OFFLINE) { - saved = llformat("(Saved %s) ", formatted_time(timestamp).c_str()); + LLStringUtil::format_map_t args; + args["[LONG_TIMESTAMP]"] = formatted_time(timestamp); + saved = LLTrans::getString("Saved_message", args); } buffer = saved + message; @@ -2657,7 +2655,7 @@ void process_improved_im(LLMessageSystem *msg, void **user_data) { LLVector3 pos, look_at; U64 region_handle; - U8 region_access; + U8 region_access = SIM_ACCESS_MIN; std::string region_info = ll_safe_string((char*)binary_bucket, binary_bucket_size); std::string region_access_str = LLStringUtil::null; std::string region_access_icn = LLStringUtil::null; @@ -2913,6 +2911,50 @@ void process_decline_callingcard(LLMessageSystem* msg, void**) LLNotificationsUtil::add("CallingCardDeclined"); } +class ChatTranslationReceiver : public LLTranslate::TranslationReceiver +{ +public : + ChatTranslationReceiver(const std::string &from_lang, const std::string &to_lang, const std::string &mesg, + const LLChat &chat, const LLSD &toast_args) + : LLTranslate::TranslationReceiver(from_lang, to_lang), + m_chat(chat), + m_toastArgs(toast_args), + m_origMesg(mesg) + { + } + + static boost::intrusive_ptr<ChatTranslationReceiver> build(const std::string &from_lang, const std::string &to_lang, const std::string &mesg, const LLChat &chat, const LLSD &toast_args) + { + return boost::intrusive_ptr<ChatTranslationReceiver>(new ChatTranslationReceiver(from_lang, to_lang, mesg, chat, toast_args)); + } + +protected: + void handleResponse(const std::string &translation, const std::string &detected_language) + { + // filter out non-interesting responeses + if ( !translation.empty() + && (m_toLang != detected_language) + && (LLStringUtil::compareInsensitive(translation, m_origMesg) != 0) ) + { + m_chat.mText += " (" + translation + ")"; + } + + LLNotificationsUI::LLNotificationManager::instance().onChat(m_chat, m_toastArgs); + } + + void handleFailure() + { + LLTranslate::TranslationReceiver::handleFailure(); + m_chat.mText += " (?)"; + + LLNotificationsUI::LLNotificationManager::instance().onChat(m_chat, m_toastArgs); + } + +private: + LLChat m_chat; + std::string m_origMesg; + LLSD m_toastArgs; +}; void process_chat_from_simulator(LLMessageSystem *msg, void **user_data) { @@ -2968,7 +3010,8 @@ void process_chat_from_simulator(LLMessageSystem *msg, void **user_data) // Make swirly things only for talking objects. (not script debug messages, though) if (chat.mSourceType == CHAT_SOURCE_OBJECT - && chat.mChatType != CHAT_TYPE_DEBUG_MSG) + && chat.mChatType != CHAT_TYPE_DEBUG_MSG + && gSavedSettings.getBOOL("EffectScriptChatParticles") ) { LLPointer<LLViewerPartSourceChat> psc = new LLViewerPartSourceChat(chatter->getPositionAgent()); psc->setSourceObject(chatter); @@ -3116,7 +3159,22 @@ void process_chat_from_simulator(LLMessageSystem *msg, void **user_data) args["type"] = LLNotificationsUI::NT_NEARBYCHAT; chat.mOwnerID = owner_id; - LLNotificationsUI::LLNotificationManager::instance().onChat(chat, args); + if (gSavedSettings.getBOOL("TranslateChat") && chat.mSourceType != CHAT_SOURCE_SYSTEM) + { + if (chat.mChatStyle == CHAT_STYLE_IRC) + { + mesg = mesg.substr(4, std::string::npos); + } + const std::string from_lang = ""; // leave empty to trigger autodetect + const std::string to_lang = LLTranslate::getTranslateLanguage(); + + LLHTTPClient::ResponderPtr result = ChatTranslationReceiver::build(from_lang, to_lang, mesg, chat, args); + LLTranslate::translateMessage(result, from_lang, to_lang, mesg); + } + else + { + LLNotificationsUI::LLNotificationManager::instance().onChat(chat, args); + } } } @@ -3132,6 +3190,8 @@ void process_teleport_start(LLMessageSystem *msg, void**) U32 teleport_flags = 0x0; msg->getU32("Info", "TeleportFlags", teleport_flags); + LL_DEBUGS("Messaging") << "Got TeleportStart with TeleportFlags=" << teleport_flags << ". gTeleportDisplay: " << gTeleportDisplay << ", gAgent.mTeleportState: " << gAgent.getTeleportState() << LL_ENDL; + if (teleport_flags & TELEPORT_FLAGS_DISABLE_CANCEL) { gViewerWindow->setProgressCancelButtonVisible(FALSE); @@ -3150,6 +3210,7 @@ void process_teleport_start(LLMessageSystem *msg, void**) gAgent.setTeleportState( LLAgent::TELEPORT_START ); make_ui_sound("UISndTeleportOut"); + LL_INFOS("Messaging") << "Teleport initiated by remote TeleportStart message with TeleportFlags: " << teleport_flags << LL_ENDL; // Don't call LLFirstUse::useTeleport here because this could be // due to being killed, which would send you home, not to a Telehub } @@ -3491,6 +3552,12 @@ void process_agent_movement_complete(LLMessageSystem* msg, void**) if( is_teleport ) { + if (gAgent.getTeleportKeepsLookAt()) + { + // *NOTE: the LookAt data we get from the sim here doesn't + // seem to be useful, so get it from the camera instead + look_at = LLViewerCamera::getInstance()->getAtAxis(); + } // Force the camera back onto the agent, don't animate. gAgentCamera.setFocusOnAvatar(TRUE, FALSE); gAgentCamera.slamLookAt(look_at); @@ -3537,7 +3604,7 @@ void process_agent_movement_complete(LLMessageSystem* msg, void**) { LLTracker::stopTracking(NULL); } - else if ( is_teleport ) + else if ( is_teleport && !gAgent.getTeleportKeepsLookAt() ) { //look at the beacon LLVector3 global_agent_pos = agent_pos; @@ -5809,7 +5876,18 @@ void process_teleport_local(LLMessageSystem *msg,void**) if( gAgent.getTeleportState() != LLAgent::TELEPORT_NONE ) { - gAgent.setTeleportState( LLAgent::TELEPORT_NONE ); + if( gAgent.getTeleportState() == LLAgent::TELEPORT_LOCAL ) + { + // To prevent TeleportStart messages re-activating the progress screen right + // after tp, keep the teleport state and let progress screen clear it after a short delay + // (progress screen is active but not visible) *TODO: remove when SVC-5290 is fixed + gTeleportDisplayTimer.reset(); + gTeleportDisplay = TRUE; + } + else + { + gAgent.setTeleportState( LLAgent::TELEPORT_NONE ); + } } // Sim tells us whether the new position is off the ground @@ -5825,8 +5903,10 @@ void process_teleport_local(LLMessageSystem *msg,void**) gAgent.setPositionAgent(pos); gAgentCamera.slamLookAt(look_at); - // likewise make sure the camera is behind the avatar - gAgentCamera.resetView(TRUE, TRUE); + if ( !(gAgent.getTeleportKeepsLookAt() && LLViewerJoystick::getInstance()->getOverrideCamera()) ) + { + gAgentCamera.resetView(TRUE, TRUE); + } // send camera update to new region gAgentCamera.updateCamera(); |