Related to normal bug EXT-6302 (TP requests need to display destination region maturity) - added displaying maturity rating with an icon.

Reviewed by Vadim Savchuk at https://codereview.productengine.com/secondlife/r/229/.

--HG--
branch : product-engine
master
Eugene Mutavchi 2010-04-23 21:52:18 +03:00
parent c540ef450a
commit d0204a2b14
7 changed files with 104 additions and 17 deletions

View File

@ -765,3 +765,35 @@ std::string LLUrlEntryNoLink::getLabel(const std::string &url, const LLUrlLabelC
{
return getUrl(url);
}
//
// LLUrlEntryIcon describes an icon with <icon>...</icon> tags
//
LLUrlEntryIcon::LLUrlEntryIcon()
{
mPattern = boost::regex("<icon\\s*>\\s*([^<]*)?\\s*</icon\\s*>",
boost::regex::perl|boost::regex::icase);
mDisabledLink = true;
}
std::string LLUrlEntryIcon::getUrl(const std::string &url) const
{
return LLStringUtil::null;
}
std::string LLUrlEntryIcon::getLabel(const std::string &url, const LLUrlLabelCallback &cb)
{
return LLStringUtil::null;
}
std::string LLUrlEntryIcon::getIcon(const std::string &url)
{
// Grep icon info between <icon>...</icon> tags
// matches[1] contains the icon name/path
boost::match_results<std::string::const_iterator> matches;
mIcon = (boost::regex_match(url, matches, mPattern) && matches[1].matched)
? matches[1]
: LLStringUtil::null;
LLStringUtil::trim(mIcon);
return mIcon;
}

View File

@ -77,7 +77,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
std::string getIcon() const { return mIcon; }
virtual std::string getIcon(const std::string &url) { return mIcon; }
/// Return the color to render the displayed text
LLUIColor getColor() const { return mColor; }
@ -296,4 +296,17 @@ public:
/*virtual*/ std::string getUrl(const std::string &string) const;
};
///
/// LLUrlEntryIcon describes an icon with <icon>...</icon> tags
///
class LLUrlEntryIcon : public LLUrlEntryBase
{
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);
};
#endif

View File

@ -45,6 +45,7 @@ LLUrlRegistry::LLUrlRegistry()
{
// Urls are matched in the order that they were registered
registerUrl(new LLUrlEntryNoLink());
registerUrl(new LLUrlEntryIcon());
registerUrl(new LLUrlEntrySLURL());
registerUrl(new LLUrlEntryHTTP());
registerUrl(new LLUrlEntryHTTPLabel());
@ -135,7 +136,8 @@ static bool stringHasUrl(const std::string &text)
text.find(".net") != std::string::npos ||
text.find(".edu") != std::string::npos ||
text.find(".org") != std::string::npos ||
text.find("<nolink>") != std::string::npos);
text.find("<nolink>") != std::string::npos ||
text.find("<icon") != std::string::npos);
}
bool LLUrlRegistry::findUrl(const std::string &text, LLUrlMatch &match, const LLUrlLabelCallback &cb)
@ -177,7 +179,7 @@ bool LLUrlRegistry::findUrl(const std::string &text, LLUrlMatch &match, const LL
match_entry->getUrl(url),
match_entry->getLabel(url, cb),
match_entry->getTooltip(url),
match_entry->getIcon(),
match_entry->getIcon(url),
match_entry->getColor(),
match_entry->getMenuName(),
match_entry->getLocation(url),

View File

@ -1933,7 +1933,7 @@ protected:
}
};
static void parse_lure_bucket(const std::string& bucket,
static bool parse_lure_bucket(const std::string& bucket,
U64& region_handle,
LLVector3& pos,
LLVector3& look_at,
@ -1945,15 +1945,25 @@ static void parse_lure_bucket(const std::string& bucket,
tokenizer tokens(bucket, sep);
tokenizer::iterator iter = tokens.begin();
S32 gx = boost::lexical_cast<S32>((*(iter)).c_str());
S32 gy = boost::lexical_cast<S32>((*(++iter)).c_str());
S32 rx = boost::lexical_cast<S32>((*(++iter)).c_str());
S32 ry = boost::lexical_cast<S32>((*(++iter)).c_str());
S32 rz = boost::lexical_cast<S32>((*(++iter)).c_str());
S32 lx = boost::lexical_cast<S32>((*(++iter)).c_str());
S32 ly = boost::lexical_cast<S32>((*(++iter)).c_str());
S32 lz = boost::lexical_cast<S32>((*(++iter)).c_str());
S32 gx,gy,rx,ry,rz,lx,ly,lz;
try
{
gx = boost::lexical_cast<S32>((*(iter)).c_str());
gy = boost::lexical_cast<S32>((*(++iter)).c_str());
rx = boost::lexical_cast<S32>((*(++iter)).c_str());
ry = boost::lexical_cast<S32>((*(++iter)).c_str());
rz = boost::lexical_cast<S32>((*(++iter)).c_str());
lx = boost::lexical_cast<S32>((*(++iter)).c_str());
ly = boost::lexical_cast<S32>((*(++iter)).c_str());
lz = boost::lexical_cast<S32>((*(++iter)).c_str());
}
catch( boost::bad_lexical_cast& )
{
LL_WARNS("parse_lure_bucket")
<< "Couldn't parse lure bucket."
<< LL_ENDL;
return false;
}
// Grab region access
region_access = SIM_ACCESS_MIN;
if (++iter != tokens.end())
@ -1978,6 +1988,7 @@ static void parse_lure_bucket(const std::string& bucket,
look_at.setVec((F32)lx, (F32)ly, (F32)lz);
region_handle = to_region_handle(gx, gy);
return true;
}
void process_improved_im(LLMessageSystem *msg, void **user_data)
@ -2615,15 +2626,21 @@ void process_improved_im(LLMessageSystem *msg, void **user_data)
U64 region_handle;
U8 region_access;
std::string region_info = ll_safe_string((char*)binary_bucket, binary_bucket_size);
parse_lure_bucket(region_info, region_handle, pos, look_at, region_access);
std::string region_access_str = LLStringUtil::null;
std::string region_access_icn = LLStringUtil::null;
std::string region_access_str = LLViewerRegion::accessToString(region_access);
if (parse_lure_bucket(region_info, region_handle, pos, look_at, region_access))
{
region_access_str = LLViewerRegion::accessToString(region_access);
region_access_icn = LLViewerRegion::getAccessIcon(region_access);
}
LLSD args;
// *TODO: Translate -> [FIRST] [LAST] (maybe)
args["NAME_SLURL"] = LLSLURL::buildCommand("agent", from_id, "about");
args["MESSAGE"] = message;
args["MATURITY"] = region_access_str;
args["MATURITY_STR"] = region_access_str;
args["MATURITY_ICON"] = region_access_icn;
LLSD payload;
payload["from_id"] = from_id;
payload["lure_id"] = session_id;

View File

@ -626,6 +626,26 @@ std::string LLViewerRegion::accessToString(U8 sim_access)
}
}
// static
std::string LLViewerRegion::getAccessIcon(U8 sim_access)
{
switch(sim_access)
{
case SIM_ACCESS_MATURE:
return "Parcel_M_Dark";
case SIM_ACCESS_ADULT:
return "Parcel_R_Light";
case SIM_ACCESS_PG:
return "Parcel_PG_Light";
case SIM_ACCESS_MIN:
default:
return "";
}
}
// static
std::string LLViewerRegion::accessToShortString(U8 sim_access)
{

View File

@ -203,6 +203,9 @@ public:
// Returns "M", "PG", "A" etc.
static std::string accessToShortString(U8 sim_access);
// Return access icon name
static std::string getAccessIcon(U8 sim_access);
// helper function which just makes sure all interested parties
// can process the message.

View File

@ -5168,7 +5168,7 @@ An object named [OBJECTFROMNAME] owned by (an unknown Resident) has given you th
type="offer">
[NAME_SLURL] has offered to teleport you to their location:
[MESSAGE], ([MATURITY])
[MESSAGE] - [MATURITY_STR] &lt;icon&gt;[MATURITY_ICON]&lt;/icon&gt;
<form name="form">
<button
index="0"