From 68bc6749e5f900459dcd6001d3688760c811d62b Mon Sep 17 00:00:00 2001 From: Shyotl Date: Wed, 11 Jan 2012 00:49:14 -0600 Subject: [PATCH] Hooked LLTrans into LLNotification stuffs. Also, fixed [CURRENCY] showing up in several places on the buy land window. --- indra/llui/CMakeLists.txt | 1 + indra/llui/llnotifications.cpp | 218 +++++++++--------- indra/llui/llnotifications.h | 119 ++-------- indra/llui/llnotificationtemplate.h | 108 +++++++++ indra/llui/lltrans.h | 12 + indra/llxml/llcontrol.cpp | 3 +- indra/llxml/llcontrol.h | 2 +- indra/newview/llappviewer.cpp | 1 + indra/newview/llfirstuse.cpp | 2 - indra/newview/llfloaterbuyland.cpp | 11 +- indra/newview/llfloaterland.cpp | 1 - indra/newview/llfloaterpostcard.cpp | 3 +- indra/newview/llhoverview.cpp | 2 - indra/newview/llnotify.cpp | 16 +- indra/newview/llpanelclassified.cpp | 1 - indra/newview/llpanelgroupgeneral.cpp | 1 - indra/newview/llpanelinventory.cpp | 1 - indra/newview/llpanelmsgs.cpp | 22 +- indra/newview/llstartup.cpp | 8 +- indra/newview/llviewermessage.cpp | 1 - .../default/xui/en-us/floater_postcard.xml | 4 +- .../skins/default/xui/en-us/notifications.xml | 119 +++++----- .../skins/default/xui/en-us/strings.xml | 4 +- .../newview/skins/default/xui/fr/strings.xml | 5 +- 24 files changed, 363 insertions(+), 302 deletions(-) create mode 100644 indra/llui/llnotificationtemplate.h diff --git a/indra/llui/CMakeLists.txt b/indra/llui/CMakeLists.txt index dd25fff0a..7cdc0c13d 100644 --- a/indra/llui/CMakeLists.txt +++ b/indra/llui/CMakeLists.txt @@ -106,6 +106,7 @@ set(llui_HEADER_FILES llnotificationptr.h llnotifications.h llnotificationsutil.h + llnotificationtemplate.h llpanel.h llprogressbar.h llradiogroup.h diff --git a/indra/llui/llnotifications.cpp b/indra/llui/llnotifications.cpp index fa4a27564..dc0cf9c87 100644 --- a/indra/llui/llnotifications.cpp +++ b/indra/llui/llnotifications.cpp @@ -31,9 +31,13 @@ */ #include "linden_common.h" + +#include "llnotifications.h" +#include "llnotificationtemplate.h" #include "lluictrlfactory.h" #include "lldir.h" #include "llsdserialize.h" +#include "lltrans.h" #include "llnotifications.h" @@ -164,12 +168,7 @@ bool filterIgnoredNotifications(LLNotificationPtr notification) { LLNotificationFormPtr form = notification->getForm(); // Check to see if the user wants to ignore this alert - if (form->getIgnoreType() != LLNotificationForm::IGNORE_NO) - { - return LLUI::sConfigGroup->getWarning(notification->getName()); - } - - return true; + return !notification->getForm()->getIgnored(); } bool handleIgnoredNotification(const LLSD& payload) @@ -219,7 +218,8 @@ LLNotificationForm::LLNotificationForm() LLNotificationForm::LLNotificationForm(const std::string& name, const LLXMLNodePtr xml_node) : mFormData(LLSD::emptyArray()), - mIgnore(IGNORE_NO) + mIgnore(IGNORE_NO), + mInvertSetting(false) { if (!xml_node->hasName("form")) { @@ -248,7 +248,7 @@ LLNotificationForm::LLNotificationForm(const std::string& name, const LLXMLNodeP LLUI::sIgnoresGroup->declareLLSD(std::string("Default") + name, "", std::string("Default response for notification " + name)); } child->getAttributeString("text", mIgnoreMsg); - LLUI::sIgnoresGroup->addWarning(name); + mIgnoreSetting = LLUI::sIgnoresGroup->addWarning(name); } else { @@ -344,13 +344,13 @@ void LLNotificationForm::formatElements(const LLSD& substitutions) if ((*it).has("text")) { std::string text = (*it)["text"].asString(); - text = LLNotification::format(text, substitutions); + LLStringUtil::format(text, substitutions); (*it)["text"] = text; } if ((*it)["type"].asString() == "text" && (*it).has("value")) { std::string value = (*it)["value"].asString(); - value = LLNotification::format(value, substitutions); + LLStringUtil::format(value, substitutions); (*it)["value"] = value; } } @@ -367,6 +367,33 @@ std::string LLNotificationForm::getDefaultOption() return ""; } +LLControlVariablePtr LLNotificationForm::getIgnoreSetting() +{ + return mIgnoreSetting; +} + +bool LLNotificationForm::getIgnored() +{ + bool show = true; + if (mIgnore != LLNotificationForm::IGNORE_NO + && mIgnoreSetting) + { + show = mIgnoreSetting->getValue().asBoolean(); + if (mInvertSetting) show = !show; + } + + return !show; +} + +void LLNotificationForm::setIgnored(bool ignored) +{ + if (mIgnoreSetting) + { + if (mInvertSetting) ignored = !ignored; + mIgnoreSetting->setValue(!ignored); + } +} + LLNotificationTemplate::LLNotificationTemplate() : mExpireSeconds(0), mExpireOption(-1), @@ -417,6 +444,7 @@ LLNotification::LLNotification(const LLSD& sd) : LLSD LLNotification::asLLSD() { LLSD output; + output["id"] = mId; output["name"] = mTemplatep->mName; output["form"] = getForm()->asLLSD(); output["substitutions"] = mSubstitutions; @@ -545,7 +573,7 @@ void LLNotification::respond(const LLSD& response) if (mForm->getIgnoreType() != LLNotificationForm::IGNORE_NO) { - LLUI::sIgnoresGroup->setWarning(getName(), !mIgnored); + mForm->setIgnored(mIgnored); if (mIgnored && mForm->getIgnoreType() == LLNotificationForm::IGNORE_WITH_LAST_RESPONSE) { LLUI::sIgnoresGroup->setLLSD("Default" + getName(), response); @@ -555,6 +583,36 @@ void LLNotification::respond(const LLSD& response) update(); } +const std::string& LLNotification::getName() const +{ + return mTemplatep->mName; +} + +const std::string& LLNotification::getIcon() const +{ + return mTemplatep->mIcon; +} + + +bool LLNotification::isPersistent() const +{ + return mTemplatep->mPersist; +} +std::string LLNotification::getType() const +{ + return (mTemplatep ? mTemplatep->mType : ""); +} + +S32 LLNotification::getURLOption() const +{ + return (mTemplatep ? mTemplatep->mURLOption : -1); +} +bool LLNotification::hasUniquenessConstraints() const +{ + return (mTemplatep ? mTemplatep->mUnique : false); +} + + void LLNotification::setIgnored(bool ignore) { mIgnored = ignore; @@ -569,21 +627,6 @@ void LLNotification::setResponseFunctor(std::string const &responseFunctorName) mTemporaryResponder = false; } -bool LLNotification::payloadContainsAll(const std::vector& required_fields) const -{ - for(std::vector::const_iterator required_fields_it = required_fields.begin(); - required_fields_it != required_fields.end(); - required_fields_it++) - { - std::string required_field_name = *required_fields_it; - if( ! getPayload().has(required_field_name)) - { - return false; // a required field was not found - } - } - return true; // all required fields were found -} - bool LLNotification::isEquivalentTo(LLNotificationPtr that) const { if (this->mTemplatep->mName != that->mTemplatep->mName) @@ -592,11 +635,28 @@ bool LLNotification::isEquivalentTo(LLNotificationPtr that) const } if (this->mTemplatep->mUnique) { + const LLSD& these_substitutions = this->getSubstitutions(); + const LLSD& those_substitutions = that->getSubstitutions(); + const LLSD& this_payload = this->getPayload(); + const LLSD& that_payload = that->getPayload(); + // highlander bit sez there can only be one of these - return - this->payloadContainsAll(that->mTemplatep->mUniqueContext) && - that->payloadContainsAll(this->mTemplatep->mUniqueContext); + for (std::vector::const_iterator it = mTemplatep->mUniqueContext.begin(), end_it = mTemplatep->mUniqueContext.end(); + it != end_it; + ++it) + { + // if templates differ in either substitution strings or payload with the given field name + // then they are considered inequivalent + // use of get() avoids converting the LLSD value to a map as the [] operator would + if (these_substitutions.get(*it).asString() != those_substitutions.get(*it).asString() + || this_payload.get(*it).asString() != that_payload.get(*it).asString()) + { + return false; + } + } + return true; } + return false; } @@ -605,23 +665,15 @@ void LLNotification::init(const std::string& template_name, const LLSD& form_ele mTemplatep = LLNotifications::instance().getTemplate(template_name); if (!mTemplatep) return; - // add default substitutions - // TODO: change this to read from the translatable strings file! - if (gHippoGridManager->getConnectedGrid()->isSecondLife()) { - mSubstitutions["[SECOND_LIFE]"] = "Second Life"; + const LLStringUtil::format_map_t& default_args = LLTrans::getDefaultArgs(); + for (LLStringUtil::format_map_t::const_iterator iter = default_args.begin(); + iter != default_args.end(); ++iter) + { + mSubstitutions[iter->first] = iter->second; } - else { - mSubstitutions["[SECOND_LIFE]"] = gHippoGridManager->getConnectedGrid()->getGridName(); - } - mSubstitutions["[VIEWER_NAME]"] = LLNotifications::instance().getGlobalString("VIEWER_NAME"); - mSubstitutions["[VIEWER_SITE]"] = LLNotifications::instance().getGlobalString("VIEWER_SITE"); - - mSubstitutions["[GRID_NAME]"] = gHippoGridManager->getConnectedGrid()->getGridName(); - mSubstitutions["[GRID_SITE]"] = gHippoGridManager->getConnectedGrid()->getWebSite(); - mSubstitutions["[CURRENCY]"] = gHippoGridManager->getConnectedGrid()->getCurrencySymbol(); - mSubstitutions["_URL"] = getURL(); mSubstitutions["_NAME"] = template_name; + // TODO: something like this so that a missing alert is sensible: //mSubstitutions["_ARGS"] = get_all_arguments_as_text(mSubstitutions); @@ -631,6 +683,8 @@ void LLNotification::init(const std::string& template_name, const LLSD& form_ele // apply substitution to form labels mForm->formatElements(mSubstitutions); + mIgnored = mForm->getIgnored(); + LLDate rightnow = LLDate::now(); if (mTemplatep->mExpireSeconds) { @@ -653,63 +707,6 @@ std::string LLNotification::summarize() const return s; } -//static -std::string LLNotification::format(const std::string& s, const LLSD& substitutions) -{ - if (!substitutions.isMap()) - { - return s; - } - - std::ostringstream output; - // match strings like [NAME] - const boost::regex key("\\[([0-9_A-Z]+)]"); - - std::string::const_iterator start = s.begin(); - std::string::const_iterator end = s.end(); - boost::smatch match; - - while (boost::regex_search(start, end, match, key, boost::match_default)) - { - bool found_replacement = false; - std::string replacement; - - // see if we have a replacement for the bracketed string (without the brackets) - // test first using has() because if we just look up with operator[] we get back an - // empty string even if the value is missing. We want to distinguish between - // missing replacements and deliberately empty replacement strings. - if (substitutions.has(std::string(match[1].first, match[1].second))) - { - replacement = substitutions[std::string(match[1].first, match[1].second)].asString(); - found_replacement = true; - } - // if not, see if there's one WITH brackets - else if (substitutions.has(std::string(match[0].first, match[0].second))) - { - replacement = substitutions[std::string(match[0].first, match[0].second)].asString(); - found_replacement = true; - } - - if (found_replacement) - { - // found a replacement - // "hello world" is output - output << std::string(start, match[0].first) << replacement; - } - else - { - // we had no replacement, so leave the string we searched for so that it gets noticed by QA - // "hello [NAME_NOT_FOUND]" is output - output << std::string(start, match[0].second); - } - - // update search position - start = match[0].second; - } - // send the remainder of the string (with no further matches for bracketed names) - output << std::string(start, end); - return output.str(); -} std::string LLNotification::getMessage() const { @@ -718,15 +715,30 @@ std::string LLNotification::getMessage() const // cache it in the notification if (!mTemplatep) return std::string(); - return format(mTemplatep->mMessage, mSubstitutions); + + std::string message = mTemplatep->mMessage; + LLStringUtil::format(message, mSubstitutions); + return message; } std::string LLNotification::getLabel() const { - return (mTemplatep ? format(mTemplatep->mLabel, mSubstitutions) : ""); + if(!mTemplatep) + return std::string(); + + std::string label = mTemplatep->mLabel; + LLStringUtil::format(label, mSubstitutions); + return label; } - +std::string LLNotification::getURL() const +{ + if (!mTemplatep) + return std::string(); + std::string url = mTemplatep->mURL; + LLStringUtil::format(url, mSubstitutions); + return (mTemplatep ? url : ""); +} // ========================================================= // LLNotificationChannel implementation diff --git a/indra/llui/llnotifications.h b/indra/llui/llnotifications.h index 999f664a0..c513b82f9 100644 --- a/indra/llui/llnotifications.h +++ b/indra/llui/llnotifications.h @@ -217,6 +217,9 @@ public: // appends form elements from another form serialized as LLSD void append(const LLSD& sub_form); std::string getDefaultOption(); + LLPointer getIgnoreSetting(); + bool getIgnored(); + void setIgnored(bool ignored); EIgnoreType getIgnoreType() { return mIgnore; } std::string getIgnoreMessage() { return mIgnoreMsg; } @@ -224,80 +227,15 @@ public: private: LLSD mFormData; EIgnoreType mIgnore; - std::string mIgnoreMsg; + std::string mIgnoreMsg; + LLPointer mIgnoreSetting; + bool mInvertSetting; }; typedef boost::shared_ptr LLNotificationFormPtr; -// This is the class of object read from the XML file (notifications.xml, -// from the appropriate local language directory). -struct LLNotificationTemplate -{ - LLNotificationTemplate(); - // the name of the notification -- the key used to identify it - // Ideally, the key should follow variable naming rules - // (no spaces or punctuation). - std::string mName; - // The type of the notification - // used to control which queue it's stored in - std::string mType; - // The text used to display the notification. Replaceable parameters - // are enclosed in square brackets like this []. - std::string mMessage; - // The label for the notification; used for - // certain classes of notification (those with a window and a window title). - // Also used when a notification pops up underneath the current one. - // Replaceable parameters can be used in the label. - std::string mLabel; - // The name of the icon image. This should include an extension. - std::string mIcon; - // This is the Highlander bit -- "There Can Be Only One" - // An outstanding notification with this bit set - // is updated by an incoming notification with the same name, - // rather than creating a new entry in the queue. - // (used for things like progress indications, or repeating warnings - // like "the grid is going down in N minutes") - bool mUnique; - // if we want to be unique only if a certain part of the payload is constant - // specify the field names for the payload. The notification will only be - // combined if all of the fields named in the context are identical in the - // new and the old notification; otherwise, the notification will be - // duplicated. This is to support suppressing duplicate offers from the same - // sender but still differentiating different offers. Example: Invitation to - // conference chat. - std::vector mUniqueContext; - // If this notification expires automatically, this value will be - // nonzero, and indicates the number of seconds for which the notification - // will be valid (a teleport offer, for example, might be valid for - // 300 seconds). - U32 mExpireSeconds; - // if the offer expires, one of the options is chosen automatically - // based on its "value" parameter. This controls which one. - // If expireSeconds is specified, expireOption should also be specified. - U32 mExpireOption; - // if the notification contains a url, it's stored here (and replaced - // into the message where [_URL] is found) - std::string mURL; - // if there's a URL in the message, this controls which option visits - // that URL. Obsolete this and eliminate the buttons for affected - // messages when we allow clickable URLs in the UI - U32 mURLOption; - // does this notification persist across sessions? if so, it will be - // serialized to disk on first receipt and read on startup - bool mPersist; - // This is the name of the default functor, if present, to be - // used for the notification's callback. It is optional, and used only if - // the notification is constructed without an identified functor. - std::string mDefaultFunctor; - // The form data associated with a given notification (buttons, text boxes, etc) - LLNotificationFormPtr mForm; - // default priority for notifications of this type - ENotificationPriority mPriority; - // UUID of the audio file to be played when this notification arrives - // this is loaded as a name, but looked up to get the UUID upon template load. - // If null, it wasn't specified. - LLUUID mSoundEffect; -}; + +struct LLNotificationTemplate; // we want to keep a map of these by name, and it's best to manage them // with smart pointers @@ -401,21 +339,15 @@ private: // this is just for making it easy to look things up in a set organized by UUID -- DON'T USE IT // for anything real! - LLNotification(LLUUID uuid) : mId(uuid) {} + LLNotification(LLUUID uuid) : mId(uuid), mCancelled(false), mRespondedTo(false), mIgnored(false), mPriority(NOTIFICATION_PRIORITY_UNSPECIFIED), mTemporaryResponder(false) {} void cancel(); - bool payloadContainsAll(const std::vector& required_fields) const; - public: // constructor from a saved notification LLNotification(const LLSD& sd); - // This is a string formatter for substituting into the message directly - // from LLSD without going through the hopefully-to-be-obsoleted LLString - static std::string format(const std::string& text, const LLSD& substitutions); - void setResponseFunctor(std::string const &responseFunctorName); typedef enum e_response_template_type @@ -474,11 +406,12 @@ public: return mIgnored; } - const std::string& getName() const - { - return mTemplatep->mName; - } - + const std::string& getName() const; + + const std::string& getIcon() const; + + bool isPersistent() const; + const LLUUID& id() const { return mId; @@ -499,23 +432,11 @@ public: return mTimestamp; } - std::string getType() const - { - return (mTemplatep ? mTemplatep->mType : ""); - } - + std::string getType() const; std::string getMessage() const; std::string getLabel() const; - - std::string getURL() const - { - return (mTemplatep ? mTemplatep->mURL : ""); - } - - S32 getURLOption() const - { - return (mTemplatep ? mTemplatep->mURLOption : -1); - } + std::string getURL() const; + S32 getURLOption() const; const LLNotificationFormPtr getForm(); @@ -581,7 +502,7 @@ public: std::string summarize() const; - bool hasUniquenessConstraints() const { return (mTemplatep ? mTemplatep->mUnique : false);} + bool hasUniquenessConstraints() const; virtual ~LLNotification() {} }; @@ -650,7 +571,7 @@ namespace LLNotificationComparators struct orderBy { typedef boost::function field_t; - orderBy(field_t field, EDirection = ORDER_INCREASING) : mField(field) {} + orderBy(field_t field, EDirection direction = ORDER_INCREASING) : mField(field), mDirection(direction) {} bool operator()(LLNotificationPtr lhs, LLNotificationPtr rhs) { if (mDirection == ORDER_DECREASING) diff --git a/indra/llui/llnotificationtemplate.h b/indra/llui/llnotificationtemplate.h new file mode 100644 index 000000000..0c434be38 --- /dev/null +++ b/indra/llui/llnotificationtemplate.h @@ -0,0 +1,108 @@ +/** +* @file llnotificationtemplate.h +* @brief Description of notification contents +* @author Q (with assistance from Richard and Coco) +* +* $LicenseInfo:firstyear=2008&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 LL_LLNOTIFICATION_TEMPLATE_H +#define LL_LLNOTIFICATION_TEMPLATE_H + +#include "llnotifications.h" + + +typedef boost::shared_ptr LLNotificationFormPtr; + +// This is the class of object read from the XML file (notifications.xml, +// from the appropriate local language directory). +struct LLNotificationTemplate +{ + LLNotificationTemplate(); + // the name of the notification -- the key used to identify it + // Ideally, the key should follow variable naming rules + // (no spaces or punctuation). + std::string mName; + // The type of the notification + // used to control which queue it's stored in + std::string mType; + // The text used to display the notification. Replaceable parameters + // are enclosed in square brackets like this []. + std::string mMessage; + // The label for the notification; used for + // certain classes of notification (those with a window and a window title). + // Also used when a notification pops up underneath the current one. + // Replaceable parameters can be used in the label. + std::string mLabel; + // The name of the icon image. This should include an extension. + std::string mIcon; + // This is the Highlander bit -- "There Can Be Only One" + // An outstanding notification with this bit set + // is updated by an incoming notification with the same name, + // rather than creating a new entry in the queue. + // (used for things like progress indications, or repeating warnings + // like "the grid is going down in N minutes") + bool mUnique; + // if we want to be unique only if a certain part of the payload is constant + // specify the field names for the payload. The notification will only be + // combined if all of the fields named in the context are identical in the + // new and the old notification; otherwise, the notification will be + // duplicated. This is to support suppressing duplicate offers from the same + // sender but still differentiating different offers. Example: Invitation to + // conference chat. + std::vector mUniqueContext; + // If this notification expires automatically, this value will be + // nonzero, and indicates the number of seconds for which the notification + // will be valid (a teleport offer, for example, might be valid for + // 300 seconds). + U32 mExpireSeconds; + // if the offer expires, one of the options is chosen automatically + // based on its "value" parameter. This controls which one. + // If expireSeconds is specified, expireOption should also be specified. + U32 mExpireOption; + // if the notification contains a url, it's stored here (and replaced + // into the message where [_URL] is found) + std::string mURL; + // if there's a URL in the message, this controls which option visits + // that URL. Obsolete this and eliminate the buttons for affected + // messages when we allow clickable URLs in the UI + U32 mURLOption; + // does this notification persist across sessions? if so, it will be + // serialized to disk on first receipt and read on startup + bool mPersist; + // This is the name of the default functor, if present, to be + // used for the notification's callback. It is optional, and used only if + // the notification is constructed without an identified functor. + std::string mDefaultFunctor; + // The form data associated with a given notification (buttons, text boxes, etc) + LLNotificationFormPtr mForm; + // default priority for notifications of this type + ENotificationPriority mPriority; + // UUID of the audio file to be played when this notification arrives + // this is loaded as a name, but looked up to get the UUID upon template load. + // If null, it wasn't specified. + LLUUID mSoundEffect; +}; + + +#endif //LL_LLNOTIFICATION_TEMPLATE_H + diff --git a/indra/llui/lltrans.h b/indra/llui/lltrans.h index 432a12b1d..56ed08f3b 100644 --- a/indra/llui/lltrans.h +++ b/indra/llui/lltrans.h @@ -85,8 +85,20 @@ public: return getString(xml_desc, empty); } + // get the default args + static const LLStringUtil::format_map_t& getDefaultArgs() + { + return sDefaultArgs; + } + static void setDefaultArg(const std::string& name, const std::string& value); + // insert default args into an arg list + static void getArgs(LLStringUtil::format_map_t& args) + { + args.insert(sDefaultArgs.begin(), sDefaultArgs.end()); + } + private: typedef std::map template_map_t; static template_map_t sStringTemplates; diff --git a/indra/llxml/llcontrol.cpp b/indra/llxml/llcontrol.cpp index 9488e7a25..86dd63f37 100644 --- a/indra/llxml/llcontrol.cpp +++ b/indra/llxml/llcontrol.cpp @@ -1150,7 +1150,7 @@ static std::string get_warn_name(const std::string& name) return warnname; } -void LLControlGroup::addWarning(const std::string& name) +LLControlVariable *LLControlGroup::addWarning(const std::string& name) { // Note: may get called more than once per warning // (e.g. if allready loaded from a settings file), @@ -1159,6 +1159,7 @@ void LLControlGroup::addWarning(const std::string& name) std::string comment = std::string("Enables ") + name + std::string(" warning dialog"); declareBOOL(warnname, TRUE, comment); mWarnings.insert(warnname); + return getControl(warnname); } BOOL LLControlGroup::getWarning(const std::string& name) diff --git a/indra/llxml/llcontrol.h b/indra/llxml/llcontrol.h index a20bd1d6a..47df59d5e 100644 --- a/indra/llxml/llcontrol.h +++ b/indra/llxml/llcontrol.h @@ -336,7 +336,7 @@ public: // Ignorable Warnings // Add a config variable to be reset on resetWarnings() - void addWarning(const std::string& name); + LLControlVariable *addWarning(const std::string& name); BOOL getWarning(const std::string& name); void setWarning(const std::string& name, BOOL val); diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp index 739b6b781..23a8025f3 100644 --- a/indra/newview/llappviewer.cpp +++ b/indra/newview/llappviewer.cpp @@ -378,6 +378,7 @@ void init_default_trans_args() default_trans_args.insert("SECOND_LIFE_GRID"); default_trans_args.insert("SUPPORT_SITE"); default_trans_args.insert("CURRENCY"); + default_trans_args.insert("GRID_OWNER"); } //---------------------------------------------------------------------------- diff --git a/indra/newview/llfirstuse.cpp b/indra/newview/llfirstuse.cpp index d59167ddf..b8e8b37dc 100644 --- a/indra/newview/llfirstuse.cpp +++ b/indra/newview/llfirstuse.cpp @@ -95,7 +95,6 @@ void LLFirstUse::useBalanceIncrease(S32 delta) LLSD args; args["AMOUNT"] = llformat("%d",delta); - args["CURRENCY"] = gHippoGridManager->getConnectedGrid()->getCurrencySymbol(); LLNotificationsUtil::add("FirstBalanceIncrease", args); } } @@ -110,7 +109,6 @@ void LLFirstUse::useBalanceDecrease(S32 delta) LLSD args; args["AMOUNT"] = llformat("%d",-delta); - args["CURRENCY"] = gHippoGridManager->getConnectedGrid()->getCurrencySymbol(); LLNotificationsUtil::add("FirstBalanceDecrease", args); } } diff --git a/indra/newview/llfloaterbuyland.cpp b/indra/newview/llfloaterbuyland.cpp index bd8cd5286..c80708879 100644 --- a/indra/newview/llfloaterbuyland.cpp +++ b/indra/newview/llfloaterbuyland.cpp @@ -1042,18 +1042,17 @@ void LLFloaterBuyLandUI::refreshUI() cost_per_sqm = (F32)mParcelPrice / (F32)mParcelActualArea; } - LLStringUtil::format_map_t info_price_args; - info_price_args["[PRICE]"] = llformat("%d", mParcelPrice); - info_price_args["[PRICE_PER_SQM]"] = llformat("%.1f", cost_per_sqm); + string_args["[PRICE]"] = llformat("%d", mParcelPrice); + string_args["[PRICE_PER_SQM]"] = llformat("%.1f", cost_per_sqm); if (mParcelSoldWithObjects) { - info_price_args["[SOLD_WITH_OBJECTS]"] = getString("sold_with_objects"); + string_args["[SOLD_WITH_OBJECTS]"] = getString("sold_with_objects"); } else { - info_price_args["[SOLD_WITH_OBJECTS]"] = getString("sold_without_objects"); + string_args["[SOLD_WITH_OBJECTS]"] = getString("sold_without_objects"); } - childSetText("info_price", getString("info_price_string", info_price_args)); + childSetText("info_price", getString("info_price_string", string_args)); childSetVisible("info_price", mParcelIsForSale); } else diff --git a/indra/newview/llfloaterland.cpp b/indra/newview/llfloaterland.cpp index 9882a71e8..451d4472b 100644 --- a/indra/newview/llfloaterland.cpp +++ b/indra/newview/llfloaterland.cpp @@ -946,7 +946,6 @@ void LLPanelLandGeneral::onClickBuyPass(void* data) LLSD args; args["COST"] = cost; - args["CURRENCY"] = gHippoGridManager->getConnectedGrid()->getCurrencySymbol(); args["PARCEL_NAME"] = parcel_name; args["TIME"] = time; diff --git a/indra/newview/llfloaterpostcard.cpp b/indra/newview/llfloaterpostcard.cpp index a1b86b238..f4aa77aa9 100644 --- a/indra/newview/llfloaterpostcard.cpp +++ b/indra/newview/llfloaterpostcard.cpp @@ -55,6 +55,7 @@ #include "llstatusbar.h" #include "llviewerregion.h" #include "lleconomy.h" +#include "lltrans.h" #include "llgl.h" #include "llglheaders.h" @@ -362,7 +363,7 @@ bool LLFloaterPostcard::missingSubjMsgAlertCallback(const LLSD& notification, co { // Stuff the subject back into the form. LLStringUtil::format_map_t targs; - targs["[GRID_NAME]"] = gHippoGridManager->getConnectedGrid()->getGridName(); + targs["[SECOND_LIFE]"] = LLTrans::getString("SECOND_LIFE"); std::string subj = getString("default_subject"); LLStringUtil::format(subj, targs); diff --git a/indra/newview/llhoverview.cpp b/indra/newview/llhoverview.cpp index 171977066..ce2bb321a 100644 --- a/indra/newview/llhoverview.cpp +++ b/indra/newview/llhoverview.cpp @@ -482,7 +482,6 @@ void LLHoverView::updateText() else if (for_sale) { LLStringUtil::format_map_t args; - args["[CURRENCY]"] = gHippoGridManager->getConnectedGrid()->getCurrencySymbol(); args["[AMOUNT]"] = llformat("%d", nodep->mSaleInfo.getSalePrice()); line.append(LLTrans::getString("TooltipForSaleL$", args)); suppressObjectHoverDisplay = FALSE; // Show tip @@ -686,7 +685,6 @@ void LLHoverView::updateText() if (hover_parcel && hover_parcel->getParcelFlag(PF_FOR_SALE)) { LLStringUtil::format_map_t args; - args["[CURRENCY]"] = gHippoGridManager->getConnectedGrid()->getCurrencySymbol(); args["[AMOUNT]"] = llformat("%d", hover_parcel->getSalePrice()); line = LLTrans::getString("TooltipForSaleL$", args); mText.push_back(line); diff --git a/indra/newview/llnotify.cpp b/indra/newview/llnotify.cpp index 5d73bf540..20145004f 100644 --- a/indra/newview/llnotify.cpp +++ b/indra/newview/llnotify.cpp @@ -44,6 +44,7 @@ #include "lliconctrl.h" #include "lltextbox.h" #include "lltexteditor.h" +#include "lltrans.h" #include "lluiconstants.h" #include "llui.h" #include "llxmlnode.h" @@ -581,14 +582,15 @@ void LLNotifyBox::close() void LLNotifyBox::format(std::string& msg, const LLStringUtil::format_map_t& args) { - // XUI:translate! + // add default substitutions LLStringUtil::format_map_t targs = args; - targs["[SECOND_LIFE]"] = gHippoGridManager->getConnectedGrid()->getGridName(); - targs["[GRID_NAME]"] = gHippoGridManager->getConnectedGrid()->getGridName(); - targs["[GRID_OWNER]"] = gHippoGridManager->getConnectedGrid()->getGridOwner(); - targs["[GRID_SITE]"] = gHippoGridManager->getConnectedGrid()->getWebSite(); - targs["[CURRENCY]"] = gHippoGridManager->getConnectedGrid()->getCurrencySymbol(); - targs["[VIEWER_NAME]"] = "Singularity Viewer"; + const LLStringUtil::format_map_t& default_args = LLTrans::getDefaultArgs(); + for (LLStringUtil::format_map_t::const_iterator iter = default_args.begin(); + iter != default_args.end(); ++iter) + { + targs[iter->first] = iter->second; + } + LLStringUtil::format(msg, targs); } diff --git a/indra/newview/llpanelclassified.cpp b/indra/newview/llpanelclassified.cpp index 45dfb60b9..c34f1aa30 100644 --- a/indra/newview/llpanelclassified.cpp +++ b/indra/newview/llpanelclassified.cpp @@ -883,7 +883,6 @@ void LLPanelClassified::callbackGotPriceForListing(S32 option, std::string text, LLSD args; std::string price_text = llformat("%d", MINIMUM_PRICE_FOR_LISTING); args["MIN_PRICE"] = price_text; - args["[CURRENCY]"] = gHippoGridManager->getConnectedGrid()->getCurrencySymbol(); LLNotificationsUtil::add("MinClassifiedPrice", args); return; diff --git a/indra/newview/llpanelgroupgeneral.cpp b/indra/newview/llpanelgroupgeneral.cpp index 044b40337..d608f7a98 100644 --- a/indra/newview/llpanelgroupgeneral.cpp +++ b/indra/newview/llpanelgroupgeneral.cpp @@ -372,7 +372,6 @@ void LLPanelGroupGeneral::onClickJoin(void *userdata) S32 cost = gdatap->mMembershipFee; LLSD args; args["COST"] = llformat("%d", cost); - args["CURRENCY"] = gHippoGridManager->getConnectedGrid()->getCurrencySymbol(); LLSD payload; payload["group_id"] = self->mGroupID; diff --git a/indra/newview/llpanelinventory.cpp b/indra/newview/llpanelinventory.cpp index bfb4ca1d1..536322782 100644 --- a/indra/newview/llpanelinventory.cpp +++ b/indra/newview/llpanelinventory.cpp @@ -245,7 +245,6 @@ void LLTaskInvFVBridge::buyItem() { LLSD args; args["PRICE"] = llformat("%d",sale_info.getSalePrice()); - args["CURRENCY"] = gHippoGridManager->getConnectedGrid()->getCurrencySymbol(); args["OWNER"] = owner_name; if (sale_info.getSaleType() != LLSaleInfo::FS_CONTENTS) { diff --git a/indra/newview/llpanelmsgs.cpp b/indra/newview/llpanelmsgs.cpp index 42fb393ca..54e2f7dbe 100644 --- a/indra/newview/llpanelmsgs.cpp +++ b/indra/newview/llpanelmsgs.cpp @@ -40,6 +40,7 @@ #include "llviewercontrol.h" #include "lluictrlfactory.h" #include "llfirstuse.h" +#include "llnotificationtemplate.h" //----------------------------------------------------------------------------- LLPanelMsgs::LLPanelMsgs() : @@ -71,11 +72,14 @@ BOOL LLPanelMsgs::postBuild() return TRUE; } -void LLPanelMsgs::buildLists() -{ - LLScrollListCtrl& disabled_popups = getChildRef("disabled_popups"); - LLScrollListCtrl& enabled_popups = getChildRef("enabled_popups"); +void LLPanelMsgs::buildLists() //void LLFloaterPreference::buildPopupLists() in v3 +{ + LLScrollListCtrl& disabled_popups = + getChildRef("disabled_popups"); + LLScrollListCtrl& enabled_popups = + getChildRef("enabled_popups"); + disabled_popups.deleteAllItems(); enabled_popups.deleteAllItems(); @@ -90,14 +94,20 @@ void LLPanelMsgs::buildLists() if (ignore == LLNotificationForm::IGNORE_NO) continue; + LLSD params; + params["name"] = (*iter).first; + LLNotificationPtr notification = LLNotificationPtr(new LLNotification(params)); + LLSD row; - row["columns"][0]["value"] = formp->getIgnoreMessage(); + std::string ignore_msg = formp->getIgnoreMessage(); + LLStringUtil::format(ignore_msg,notification->getSubstitutions()); + row["columns"][0]["value"] = ignore_msg; row["columns"][0]["font"] = "SANSSERIF_SMALL"; row["columns"][0]["width"] = 300; LLScrollListItem* item = NULL; - bool show_popup = gSavedSettings.getWarning(templatep->mName); + bool show_popup = !formp->getIgnored(); if (!show_popup) { if (ignore == LLNotificationForm::IGNORE_WITH_LAST_RESPONSE) diff --git a/indra/newview/llstartup.cpp b/indra/newview/llstartup.cpp index 3313512d4..3fd18cf7d 100644 --- a/indra/newview/llstartup.cpp +++ b/indra/newview/llstartup.cpp @@ -991,7 +991,13 @@ bool idle_startup() gHippoGridManager->setCurrentGridAsConnected(); gHippoLimits->setLimits(); - LLTrans::setDefaultArg("CURRENCY",gHippoGridManager->getConnectedGrid()->getCurrencySymbol()); //replace [CURRENCY] with OS$, not L$ for instance. + if(!gHippoGridManager->getConnectedGrid()->isSecondLife()) + { + LLTrans::setDefaultArg("[CURRENCY]",gHippoGridManager->getConnectedGrid()->getCurrencySymbol()); //replace [CURRENCY] with OS$, not L$ for instance. + LLTrans::setDefaultArg("[SECOND_LIFE]", gHippoGridManager->getConnectedGrid()->getGridName()); + LLTrans::setDefaultArg("[SECOND_LIFE_GRID]", gHippoGridManager->getConnectedGrid()->getGridName() + " Grid"); + LLTrans::setDefaultArg("[GRID_OWNER]", gHippoGridManager->getConnectedGrid()->getGridOwner()); + } // create necessary directories // *FIX: these mkdir's should error check diff --git a/indra/newview/llviewermessage.cpp b/indra/newview/llviewermessage.cpp index 0610f07a2..a66d836e8 100644 --- a/indra/newview/llviewermessage.cpp +++ b/indra/newview/llviewermessage.cpp @@ -774,7 +774,6 @@ bool join_group_response(const LLSD& notification, const LLSD& response) delete_context_data = FALSE; LLSD args; args["COST"] = llformat("%d", fee); - args["CURRENCY"] = gHippoGridManager->getConnectedGrid()->getCurrencySymbol(); // Set the fee for next time to 0, so that we don't keep // asking about a fee. LLSD next_payload = notification["payload"]; diff --git a/indra/newview/skins/default/xui/en-us/floater_postcard.xml b/indra/newview/skins/default/xui/en-us/floater_postcard.xml index 1ac44fd2b..b6aabcf94 100644 --- a/indra/newview/skins/default/xui/en-us/floater_postcard.xml +++ b/indra/newview/skins/default/xui/en-us/floater_postcard.xml @@ -43,8 +43,8 @@