diff options
author | Leyla Farazha <leyla@lindenlab.com> | 2010-10-08 16:56:02 -0700 |
---|---|---|
committer | Leyla Farazha <leyla@lindenlab.com> | 2010-10-08 16:56:02 -0700 |
commit | 7ffc9b06c820d70724af2aef361ff9964e584e73 (patch) | |
tree | 0de4ae5f3312aff15270e9fd46bce080e05718db /indra/newview | |
parent | 3abd522936a7a82b2ab76f5ec27bcfc99deb55f0 (diff) |
Created a floater for setting display name
Diffstat (limited to 'indra/newview')
-rw-r--r-- | indra/newview/CMakeLists.txt | 2 | ||||
-rw-r--r-- | indra/newview/llcallfloater.cpp | 3 | ||||
-rw-r--r-- | indra/newview/llfloaterdisplayname.cpp | 178 | ||||
-rw-r--r-- | indra/newview/llfloaterdisplayname.h | 38 | ||||
-rw-r--r-- | indra/newview/llhints.cpp | 5 | ||||
-rw-r--r-- | indra/newview/llpanelme.cpp | 106 | ||||
-rw-r--r-- | indra/newview/llpanelme.h | 5 | ||||
-rw-r--r-- | indra/newview/llviewerdisplayname.cpp | 13 | ||||
-rw-r--r-- | indra/newview/llviewerdisplayname.h | 7 | ||||
-rw-r--r-- | indra/newview/llviewerfloaterreg.cpp | 2 | ||||
-rw-r--r-- | indra/newview/skins/default/xui/en/floater_display_name.xml | 83 | ||||
-rw-r--r-- | indra/newview/skins/default/xui/en/notifications.xml | 41 |
12 files changed, 358 insertions, 125 deletions
diff --git a/indra/newview/CMakeLists.txt b/indra/newview/CMakeLists.txt index 74b9179cb4..bd2489769a 100644 --- a/indra/newview/CMakeLists.txt +++ b/indra/newview/CMakeLists.txt @@ -169,6 +169,7 @@ set(viewer_SOURCE_FILES llfloatercamera.cpp llfloatercolorpicker.cpp llfloaterdaycycle.cpp + llfloaterdisplayname.cpp llfloaterenvsettings.cpp llfloaterevent.cpp llfloaterfonttest.cpp @@ -701,6 +702,7 @@ set(viewer_HEADER_FILES llfloatercamera.h llfloatercolorpicker.h llfloaterdaycycle.h + llfloaterdisplayname.h llfloaterenvsettings.h llfloaterevent.h llfloaterfonttest.h diff --git a/indra/newview/llcallfloater.cpp b/indra/newview/llcallfloater.cpp index d3ef144ea8..078bd73379 100644 --- a/indra/newview/llcallfloater.cpp +++ b/indra/newview/llcallfloater.cpp @@ -45,6 +45,7 @@ #include "llspeakers.h" #include "lltextutil.h" #include "lltransientfloatermgr.h" +#include "llviewerdisplayname.h" #include "llviewerwindow.h" #include "llvoicechannel.h" #include "llviewerparcelmgr.h" @@ -117,6 +118,8 @@ LLCallFloater::LLCallFloater(const LLSD& key) // update the agent's name if display name setting change LLAvatarNameCache::addUseDisplayNamesCallback(boost::bind(&LLCallFloater::updateAgentModeratorState, this)); + LLViewerDisplayName::addNameChangedCallback(boost::bind(&LLCallFloater::updateAgentModeratorState, this)); + } LLCallFloater::~LLCallFloater() diff --git a/indra/newview/llfloaterdisplayname.cpp b/indra/newview/llfloaterdisplayname.cpp new file mode 100644 index 0000000000..11ac3d8fdf --- /dev/null +++ b/indra/newview/llfloaterdisplayname.cpp @@ -0,0 +1,178 @@ +/** + * @file llfloaterdisplayname.cpp + * @author Leyla Farazha + * @brief Implementation of the LLFloaterDisplayName class. + * + * $LicenseInfo:firstyear=2002&license=viewerlgpl$ + * Second Life Viewer Source Code + * 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. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + + +#include "llviewerprecompiledheaders.h" +#include "llfloaterreg.h" +#include "llfloater.h" + +#include "llnotificationsutil.h" +#include "llviewerdisplayname.h" + +#include "llnotifications.h" +#include "llfloaterdisplayname.h" +#include "llavatarnamecache.h" + +#include "llagent.h" + + +class LLFloaterDisplayName : public LLFloater +{ +public: + LLFloaterDisplayName(const LLSD& key); + virtual ~LLFloaterDisplayName() {}; + /*virtual*/ BOOL postBuild(); + void onSave(); + void onReset(); + void onCancel(); + /*virtual*/ void onOpen(const LLSD& key); + +private: + + void onCacheSetName(bool success, + const std::string& reason, + const LLSD& content); +}; + +LLFloaterDisplayName::LLFloaterDisplayName(const LLSD& key) + : LLFloater(key) +{ +} + +void LLFloaterDisplayName::onOpen(const LLSD& key) +{ + getChild<LLUICtrl>("display_name_editor")->clear(); + getChild<LLUICtrl>("display_name_confirm")->clear(); +} + +BOOL LLFloaterDisplayName::postBuild() +{ + getChild<LLUICtrl>("reset_btn")->setCommitCallback(boost::bind(&LLFloaterDisplayName::onReset, this)); + getChild<LLUICtrl>("cancel_btn")->setCommitCallback(boost::bind(&LLFloaterDisplayName::onCancel, this)); + getChild<LLUICtrl>("save_btn")->setCommitCallback(boost::bind(&LLFloaterDisplayName::onSave, this)); + + center(); + + return TRUE; +} + +void LLFloaterDisplayName::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; + args["DISPLAY_NAME"] = content["display_name"]; + 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 + // error_args will usually be empty from the server. + 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 LLFloaterDisplayName::onCancel() +{ + setVisible(false); +} + +void LLFloaterDisplayName::onReset() +{ + LLViewerDisplayName::set("", + boost::bind(&LLFloaterDisplayName::onCacheSetName, this, _1, _2, _3)); + + setVisible(false); +} + + +void LLFloaterDisplayName::onSave() +{ + std::string display_name_utf8 = getChild<LLUICtrl>("display_name_editor")->getValue().asString(); + std::string display_name_confirm = getChild<LLUICtrl>("display_name_confirm")->getValue().asString(); + + if (display_name_utf8.compare(display_name_confirm)) + { + LLNotificationsUtil::add("SetDisplayNameMismatch"); + return; + } + + const U32 DISPLAY_NAME_MAX_LENGTH = 31; // characters, not bytes + LLWString display_name_wstr = utf8string_to_wstring(display_name_utf8); + if (display_name_wstr.size() > DISPLAY_NAME_MAX_LENGTH) + { + LLSD args; + args["LENGTH"] = llformat("%d", DISPLAY_NAME_MAX_LENGTH); + LLNotificationsUtil::add("SetDisplayNameFailedLength", args); + return; + } + + LLViewerDisplayName::set(display_name_utf8, + boost::bind(&LLFloaterDisplayName::onCacheSetName, this, _1, _2, _3)); + + setVisible(false); +} + + +////////////////////////////////////////////////////////////////////////////// +// LLInspectObjectUtil +////////////////////////////////////////////////////////////////////////////// +void LLFloaterDisplayNameUtil::registerFloater() +{ + LLFloaterReg::add("display_name", "floater_display_name.xml", + &LLFloaterReg::build<LLFloaterDisplayName>); +} diff --git a/indra/newview/llfloaterdisplayname.h b/indra/newview/llfloaterdisplayname.h new file mode 100644 index 0000000000..a00bf56712 --- /dev/null +++ b/indra/newview/llfloaterdisplayname.h @@ -0,0 +1,38 @@ +/** + * @file llfloaterdisplayname.h + * + * $LicenseInfo:firstyear=2009&license=viewerlgpl$ + * Second Life Viewer Source Code + * 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. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + +#ifndef LLFLOATERDISPLAYNAME_H +#define LLFLOATERDISPLAYNAME_H + + +namespace LLFloaterDisplayNameUtil +{ + // Register with LLFloaterReg + void registerFloater(); +} + + + +#endif diff --git a/indra/newview/llhints.cpp b/indra/newview/llhints.cpp index d837ed8205..b326fc26f2 100644 --- a/indra/newview/llhints.cpp +++ b/indra/newview/llhints.cpp @@ -210,10 +210,15 @@ void LLHintPopup::draw() } else if (!targetp->isInVisibleChain()) { + setEnabled(false); + setMouseOpaque(false); // if target is invisible, don't draw, but keep alive in case widget comes back } else { + setEnabled(true); + setMouseOpaque(true); + LLRect target_rect; targetp->localRectToOtherView(targetp->getLocalRect(), &target_rect, getParent()); diff --git a/indra/newview/llpanelme.cpp b/indra/newview/llpanelme.cpp index 3cc6b32678..9a13d00685 100644 --- a/indra/newview/llpanelme.cpp +++ b/indra/newview/llpanelme.cpp @@ -35,6 +35,7 @@ #include "llagentcamera.h" #include "llagentwearables.h" #include "llfirstuse.h" +#include "llfloaterreg.h" #include "llhints.h" #include "llsidetray.h" #include "llviewercontrol.h" @@ -208,6 +209,14 @@ void LLPanelMyProfileEdit::onOpen(const LLSD& key) } } +void LLPanelMyProfileEdit::onClose(const LLSD& key) +{ + if (LLAvatarNameCache::useDisplayNames()) + { + LLFirstUse::setDisplayName(false); + } +} + void LLPanelMyProfileEdit::processProperties(void* data, EAvatarProcessorType type) { if(APT_PROPERTIES == type) @@ -262,6 +271,12 @@ void LLPanelMyProfileEdit::onNameCache(const LLUUID& agent_id, const LLAvatarNam } } +void LLPanelMyProfileEdit::onAvatarNameChanged() +{ + LLAvatarNameCache::get(getAvatarId(), + boost::bind(&LLPanelMyProfileEdit::onNameCache, this, _1, _2)); +} + BOOL LLPanelMyProfileEdit::postBuild() { initTexturePickerMouseEvents(); @@ -273,7 +288,7 @@ BOOL LLPanelMyProfileEdit::postBuild() boost::bind(&LLPanelMyProfileEdit::onClickSetName, this)); LLHints::registerHintTarget("set_display_name", getChild<LLUICtrl>("set_name")->getHandle()); - + LLViewerDisplayName::addNameChangedCallback(boost::bind(&LLPanelMyProfileEdit::onAvatarNameChanged, this)); return LLPanelAvatarProfile::postBuild(); } /** @@ -316,88 +331,6 @@ 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; - args["DISPLAY_NAME"] = content["display_name"]; - 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 - // error_args will usually be empty from the server. - 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 || option == 1) - { - LLUUID agent_id = notification["payload"]["agent_id"]; - if (agent_id.isNull()) return; - - std::string display_name_utf8; - if (option == 0) - { - // user gave us a name - display_name_utf8 = response["display_name"].asString(); - } - else - { - // reset back to People API default - display_name_utf8 = ""; - } - - const U32 DISPLAY_NAME_MAX_LENGTH = 31; // characters, not bytes - LLWString display_name_wstr = utf8string_to_wstring(display_name_utf8); - if (display_name_wstr.size() > DISPLAY_NAME_MAX_LENGTH) - { - LLSD args; - args["LENGTH"] = llformat("%d", DISPLAY_NAME_MAX_LENGTH); - LLNotificationsUtil::add("SetDisplayNameFailedLength", args); - return; - } - - LLViewerDisplayName::set(display_name_utf8, - boost::bind(&LLPanelMyProfileEdit::onCacheSetName, this, - _1, _2, _3)); - } -} - void LLPanelMyProfileEdit::onClickSetName() { LLAvatarNameCache::get(getAvatarId(), @@ -444,12 +377,7 @@ void LLPanelMyProfileEdit::onAvatarNameCache(const LLUUID& agent_id, const LLAva return; } - LLSD args; - args["DISPLAY_NAME"] = av_name.mDisplayName; - LLSD payload; - payload["agent_id"] = agent_id; - LLNotificationsUtil::add("SetDisplayName", args, payload, - boost::bind(&LLPanelMyProfileEdit::onDialogSetName, this, _1, _2)); + LLFloaterReg::showInstance("display_name"); } void LLPanelMyProfileEdit::enableEditing(bool enable) diff --git a/indra/newview/llpanelme.h b/indra/newview/llpanelme.h index 93264922f6..d5b2fee869 100644 --- a/indra/newview/llpanelme.h +++ b/indra/newview/llpanelme.h @@ -78,6 +78,9 @@ public: /*virtual*/BOOL postBuild(); /*virtual*/ void onOpen(const LLSD& key); + /*virtual*/ void onClose(const LLSD& key); + + void onAvatarNameChanged(); protected: @@ -91,8 +94,6 @@ private: 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); void onAvatarNameCache(const LLUUID& id, const LLAvatarName& av_name); /** diff --git a/indra/newview/llviewerdisplayname.cpp b/indra/newview/llviewerdisplayname.cpp index f71a7c2d20..5741fab29a 100644 --- a/indra/newview/llviewerdisplayname.cpp +++ b/indra/newview/llviewerdisplayname.cpp @@ -44,6 +44,15 @@ namespace LLViewerDisplayName { // Fired when viewer receives server response to display name change set_name_signal_t sSetDisplayNameSignal; + + // Fired when there is a change in the agent's name + name_changed_signal_t sNameChangedSignal; + + void addNameChangedCallback(const name_changed_signal_t::slot_type& cb) + { + sNameChangedSignal.connect(cb); + } + } class LLSetDisplayNameResponder : public LLHTTPClient::Responder @@ -183,6 +192,10 @@ class LLDisplayNameUpdate : public LLHTTPNode args["SLID"] = av_name.mUsername; args["NEW_NAME"] = av_name.mDisplayName; LLNotificationsUtil::add("DisplayNameUpdate", args); + if (agent_id == gAgent.getID()) + { + LLViewerDisplayName::sNameChangedSignal(); + } } }; diff --git a/indra/newview/llviewerdisplayname.h b/indra/newview/llviewerdisplayname.h index 922263eb12..16d59ae43b 100644 --- a/indra/newview/llviewerdisplayname.h +++ b/indra/newview/llviewerdisplayname.h @@ -38,11 +38,16 @@ namespace LLViewerDisplayName 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; + + typedef boost::signals2::signal<void (void)> name_changed_signal_t; + typedef name_changed_signal_t::slot_type name_changed_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); + void set(const std::string& display_name, const set_name_slot_t& slot); + + void addNameChangedCallback(const name_changed_signal_t::slot_type& cb); } #endif // LLVIEWERDISPLAYNAME_H diff --git a/indra/newview/llviewerfloaterreg.cpp b/indra/newview/llviewerfloaterreg.cpp index 7490ccf77a..b3f14b441d 100644 --- a/indra/newview/llviewerfloaterreg.cpp +++ b/indra/newview/llviewerfloaterreg.cpp @@ -49,6 +49,7 @@ #include "llfloaterbump.h" #include "llfloatercamera.h" #include "llfloaterdaycycle.h" +#include "llfloaterdisplayname.h" #include "llfloaterevent.h" #include "llfloatersearch.h" #include "llfloaterenvsettings.h" @@ -176,6 +177,7 @@ void LLViewerFloaterReg::registerFloaters() LLInspectObjectUtil::registerFloater(); LLInspectRemoteObjectUtil::registerFloater(); LLNotificationsUI::registerFloater(); + LLFloaterDisplayNameUtil::registerFloater(); LLFloaterReg::add("lagmeter", "floater_lagmeter.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterLagMeter>); LLFloaterReg::add("land_holdings", "floater_land_holdings.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterLandHoldings>); diff --git a/indra/newview/skins/default/xui/en/floater_display_name.xml b/indra/newview/skins/default/xui/en/floater_display_name.xml new file mode 100644 index 0000000000..ecf2e524aa --- /dev/null +++ b/indra/newview/skins/default/xui/en/floater_display_name.xml @@ -0,0 +1,83 @@ +<?xml version="1.0" encoding="utf-8" standalone="yes" ?> +<floater + legacy_header_height="18" + can_minimize="false" + can_close="false" + height="280" + layout="topleft" + name="Display Name" + help_topic="display_name" + save_rect="false" + width="440"> + <text + type="string" + length="1" + follows="left|top" + font="SansSerif" + height="40" + layout="topleft" + left="25" + name="info_text" + top="40" + use_ellipses="true" + width="400" + wrap="true"> + The name you give your avatar is called your Display Name. You can change it once a week. + </text> + <text + top_pad="15" + width="150" + height="20" + font="SansSerif" + name="set_name_label"> + New display name: + </text> + <line_editor + width="330" + name="display_name_editor" + max_length_chars="31" + height="20" + top_pad="5" + left="50" /> + <text + top_pad="15" + left="25" + width="300" + height="20" + font="SansSerif" + name="set_name_label"> + Type your new name again to confirm: + </text> + <line_editor + width="330" + name="display_name_confirm" + max_length_chars="31" + height="20" + top_pad="5" + left="50" /> + <button + height="23" + label="Save" + layout="topleft" + font="SansSerif" + left="35" + name="save_btn" + top_pad="40" + width="120" /> + <button + height="23" + label="Reset" + layout="topleft" + font="SansSerif" + left_pad="5" + name="reset_btn" + width="120" /> + <button + height="23" + label="Cancel" + font="SansSerif" + layout="topleft" + left_pad="5" + name="cancel_btn" + width="120" /> +</floater> diff --git a/indra/newview/skins/default/xui/en/notifications.xml b/indra/newview/skins/default/xui/en/notifications.xml index b837dfbed5..4e25efe555 100644 --- a/indra/newview/skins/default/xui/en/notifications.xml +++ b/indra/newview/skins/default/xui/en/notifications.xml @@ -3186,38 +3186,6 @@ You are no longer frozen. <notification icon="alertmodal.tga" - name="SetDisplayName" - type="alert"> - The name above your avatar's head is called a [secondlife:///app/help/display_name display_name]. You can change it periodically. - - During the evaluation period of this Project Viewer release, you are able to update your Display Name as frequently as you wish. When this feature goes officially live, you will able to update your Display Name only once a week. - - Press reset to make it the same as your username. - - Change your display name? - <form name="form"> - <input name="display_name" max_length_chars="31" type="text"> -[DISPLAY_NAME] - </input> - <button - default="true" - index="0" - name="Change" - text="Change"/> - <button - index="1" - name="Reset" - text="Reset"/> - <button - index="2" - name="Cancel" - text="Cancel"/> - </form> - <unique/> - </notification> - - <notification - icon="alertmodal.tga" name="SetDisplayNameSuccess" type="alert"> Hi [DISPLAY_NAME]! @@ -3256,7 +3224,14 @@ Please try a shorter name. Sorry, we could not set your display name. Please try again later. </notification> -<!-- *NOTE: This should never happen, users should see SetDisplayNameFailedLockout above --> + <notification + icon="alertmodal.tga" + name="SetDisplayNameMismatch" + type="alertmodal"> + The display names you entered do not match. Please re-enter. + </notification> + + <!-- *NOTE: This should never happen, users should see SetDisplayNameFailedLockout above --> <notification icon="alertmodal.tga" name="AgentDisplayNameUpdateThresholdExceeded" |