[Radar] Optimize hidden column evaluation and generation out of draw call.

Please view this diff without space changes.
This commit is contained in:
Inusaito Sayori
2014-09-11 03:37:51 -04:00
parent a68983b37f
commit ff8b4fd95a

View File

@@ -700,151 +700,171 @@ void LLFloaterAvatarList::refreshAvatarList()
LLScrollListItem::Params element; LLScrollListItem::Params element;
element.value = av_id; element.value = av_id;
LLScrollListCell::Params mark; static const LLCachedControl<bool> hide_mark("RadarColumnMarkHidden");
mark.column = "marked"; if (!hide_mark)
mark.type = "text";
if (entry->isMarked())
{ {
mark.value = "X"; LLScrollListCell::Params mark;
mark.color = LLColor4::blue; mark.column = "marked";
mark.font_style = "BOLD"; mark.type = "text";
} if (entry->isMarked())
{
LLScrollListCell::Params name; mark.value = "X";
name.column = "avatar_name"; mark.color = LLColor4::blue;
name.type = "text"; mark.font_style = "BOLD";
name.value = entry->getName(); }
if (entry->isFocused()) element.columns.add(mark);
{
name.font_style = "BOLD";
}
//<edit> custom colors for certain types of avatars!
//Changed a bit so people can modify them in settings. And since they're colors, again it's possibly account-based. Starting to think I need a function just to determine that. - HgB
//name.color = gColors.getColor( "MapAvatar" );
LLViewerRegion* parent_estate = LLWorld::getInstance()->getRegionFromPosGlobal(entry->getPosition());
LLUUID estate_owner = LLUUID::null;
if (parent_estate && parent_estate->isAlive())
{
estate_owner = parent_estate->getOwner();
} }
static const LLCachedControl<LLColor4> unselected_color(gColors, "ScrollUnselectedColor", LLColor4(0.f, 0.f, 0.f, 0.8f)); static const LLCachedControl<LLColor4> unselected_color(gColors, "ScrollUnselectedColor", LLColor4(0.f, 0.f, 0.f, 0.8f));
static LLCachedControl<LLColor4> sDefaultListText(gColors, "DefaultListText"); static const LLCachedControl<LLColor4> sDefaultListText(gColors, "DefaultListText");
static LLCachedControl<LLColor4> sRadarTextChatRange(gColors, "RadarTextChatRange");
static LLCachedControl<LLColor4> sRadarTextShoutRange(gColors, "RadarTextShoutRange");
static LLCachedControl<LLColor4> sRadarTextDrawDist(gColors, "RadarTextDrawDist");
static LLCachedControl<LLColor4> sRadarTextYoung(gColors, "RadarTextYoung");
static const LLCachedControl<LLColor4> ascent_muted_color("AscentMutedColor", LLColor4(0.7f,0.7f,0.7f,1.f)); static const LLCachedControl<LLColor4> ascent_muted_color("AscentMutedColor", LLColor4(0.7f,0.7f,0.7f,1.f));
LLColor4 color = sDefaultListText; LLColor4 color = sDefaultListText;
//Lindens are always more Linden than your friend, make that take precedence // Name never hidden
if (mm_getMarkerColor(av_id, color)) {}
else if (LLMuteList::getInstance()->isLinden(av_id))
{ {
static const LLCachedControl<LLColor4> ascent_linden_color("AscentLindenColor", LLColor4(0.f,0.f,1.f,1.f)); LLScrollListCell::Params name;
color = ascent_linden_color; name.column = "avatar_name";
name.type = "text";
name.value = entry->getName();
if (entry->isFocused())
{
name.font_style = "BOLD";
}
//<edit> custom colors for certain types of avatars!
//Changed a bit so people can modify them in settings. And since they're colors, again it's possibly account-based. Starting to think I need a function just to determine that. - HgB
//name.color = gColors.getColor( "MapAvatar" );
LLUUID estate_owner = LLUUID::null;
if (LLViewerRegion* parent_estate = LLWorld::getInstance()->getRegionFromPosGlobal(entry->getPosition()))
if (parent_estate->isAlive())
estate_owner = parent_estate->getOwner();
//Lindens are always more Linden than your friend, make that take precedence
if (mm_getMarkerColor(av_id, color)) {}
else if (LLMuteList::getInstance()->isLinden(av_id))
{
static const LLCachedControl<LLColor4> ascent_linden_color("AscentLindenColor", LLColor4(0.f,0.f,1.f,1.f));
color = ascent_linden_color;
}
//check if they are an estate owner at their current position
else if (estate_owner.notNull() && av_id == estate_owner)
{
static const LLCachedControl<LLColor4> ascent_estate_owner_color("AscentEstateOwnerColor", LLColor4(1.f,0.6f,1.f,1.f));
color = ascent_estate_owner_color;
}
//without these dots, SL would suck.
else if (LLAvatarActions::isFriend(av_id))
{
static const LLCachedControl<LLColor4> ascent_friend_color("AscentFriendColor", LLColor4(1.f,1.f,0.f,1.f));
color = ascent_friend_color;
}
//big fat jerkface who is probably a jerk, display them as such.
else if (LLMuteList::getInstance()->isMuted(av_id))
{
color = ascent_muted_color;
}
name.color = color*0.5f + unselected_color*0.5f;
element.columns.add(name);
} }
//check if they are an estate owner at their current position
else if (estate_owner.notNull() && av_id == estate_owner)
{
static const LLCachedControl<LLColor4> ascent_estate_owner_color("AscentEstateOwnerColor", LLColor4(1.f,0.6f,1.f,1.f));
color = ascent_estate_owner_color;
}
//without these dots, SL would suck.
else if (LLAvatarActions::isFriend(av_id))
{
static const LLCachedControl<LLColor4> ascent_friend_color("AscentFriendColor", LLColor4(1.f,1.f,0.f,1.f));
color = ascent_friend_color;
}
//big fat jerkface who is probably a jerk, display them as such.
else if (LLMuteList::getInstance()->isMuted(av_id))
{
color = ascent_muted_color;
}
name.color = color*0.5f + unselected_color*0.5f;
char temp[32]; char temp[32];
color = sDefaultListText; // Distance never hidden
LLScrollListCell::Params dist;
dist.column = "distance";
dist.type = "text";
if (UnknownAltitude)
{ {
strcpy(temp, "?"); color = sDefaultListText;
if (entry->mStats[STAT_TYPE_DRAW]) LLScrollListCell::Params dist;
dist.column = "distance";
dist.type = "text";
static const LLCachedControl<LLColor4> sRadarTextDrawDist(gColors, "RadarTextDrawDist");
if (UnknownAltitude)
{ {
color = sRadarTextDrawDist; strcpy(temp, "?");
} if (entry->mStats[STAT_TYPE_DRAW])
} {
else color = sRadarTextDrawDist;
{ }
if (distance <= LFSimFeatureHandler::getInstance()->shoutRange())
{
snprintf(temp, sizeof(temp), "%.1f", distance);
color = (distance > LFSimFeatureHandler::getInstance()->sayRange()) ? sRadarTextShoutRange : sRadarTextChatRange;
} }
else else
{ {
if (entry->mStats[STAT_TYPE_DRAW]) color = sRadarTextDrawDist; if (distance <= LFSimFeatureHandler::getInstance()->shoutRange())
snprintf(temp, sizeof(temp), "%d", (S32)distance); {
static const LLCachedControl<LLColor4> sRadarTextChatRange(gColors, "RadarTextChatRange");
static const LLCachedControl<LLColor4> sRadarTextShoutRange(gColors, "RadarTextShoutRange");
snprintf(temp, sizeof(temp), "%.1f", distance);
color = (distance > LFSimFeatureHandler::getInstance()->sayRange()) ? sRadarTextShoutRange : sRadarTextChatRange;
}
else
{
if (entry->mStats[STAT_TYPE_DRAW]) color = sRadarTextDrawDist;
snprintf(temp, sizeof(temp), "%d", (S32)distance);
}
} }
dist.value = temp;
dist.color = color * 0.7f + unselected_color * 0.3f; // Liru: Blend testing!
//dist.color = color;
element.columns.add(dist);
} }
dist.value = temp;
dist.color = color * 0.7f + unselected_color * 0.3f; // Liru: Blend testing!
//dist.color = color;
LLScrollListCell::Params pos; static const LLCachedControl<bool> hide_pos("RadarColumnPositionHidden");
position -= simpos; if (!hide_pos)
{
LLScrollListCell::Params pos;
position -= simpos;
S32 x(position.mdV[VX]); S32 x(position.mdV[VX]);
S32 y(position.mdV[VY]); S32 y(position.mdV[VY]);
if (x >= 0 && x <= width && y >= 0 && y <= width) if (x >= 0 && x <= width && y >= 0 && y <= width)
{ {
snprintf(temp, sizeof(temp), "%d, %d", x, y); snprintf(temp, sizeof(temp), "%d, %d", x, y);
}
else
{
temp[0] = '\0';
if (y < 0)
{
strcat(temp, "S");
}
else if (y > width)
{
strcat(temp, "N");
}
if (x < 0)
{
strcat(temp, "W");
}
else if (x > width)
{
strcat(temp, "E");
}
}
pos.column = "position";
pos.type = "text";
pos.value = temp;
element.columns.add(pos);
} }
else
{
temp[0] = '\0';
if (y < 0)
{
strcat(temp, "S");
}
else if (y > width)
{
strcat(temp, "N");
}
if (x < 0)
{
strcat(temp, "W");
}
else if (x > width)
{
strcat(temp, "E");
}
}
pos.column = "position";
pos.type = "text";
pos.value = temp;
LLScrollListCell::Params alt; static const LLCachedControl<bool> hide_alt("RadarColumnAltitudeHidden");
alt.column = "altitude"; if (!hide_alt)
alt.type = "text";
if (UnknownAltitude)
{ {
strcpy(temp, "?"); LLScrollListCell::Params alt;
alt.column = "altitude";
alt.type = "text";
if (UnknownAltitude)
{
strcpy(temp, "?");
}
else
{
snprintf(temp, sizeof(temp), "%d", (S32)position.mdV[VZ]);
}
alt.value = temp;
element.columns.add(alt);
} }
else
{
snprintf(temp, sizeof(temp), "%d", (S32)position.mdV[VZ]);
}
alt.value = temp;
LLScrollListCell::Params act;
static const LLCachedControl<bool> hide_act("RadarColumnActivityHidden"); static const LLCachedControl<bool> hide_act("RadarColumnActivityHidden");
if (!hide_act) if (!hide_act)
{ {
LLScrollListCell::Params act;
act.column = "activity"; act.column = "activity";
act.type = "icon"; act.type = "icon";
switch(entry->getActivity()) switch(entry->getActivity())
@@ -880,12 +900,13 @@ void LLFloaterAvatarList::refreshAvatarList()
default: default:
break; break;
} }
element.columns.add(act);
} }
LLScrollListCell::Params voice;
static const LLCachedControl<bool> hide_voice("RadarColumnVoiceHidden"); static const LLCachedControl<bool> hide_voice("RadarColumnVoiceHidden");
if (!hide_voice) if (!hide_voice)
{ {
LLScrollListCell::Params voice;
voice.column("voice"); voice.column("voice");
voice.type("icon"); voice.type("icon");
// transplant from llparticipantlist.cpp, update accordingly. // transplant from llparticipantlist.cpp, update accordingly.
@@ -914,71 +935,78 @@ void LLFloaterAvatarList::refreshAvatarList()
voice.color(speakerp->mStatus > LLSpeaker::STATUS_VOICE_ACTIVE ? LLColor4::transparent : speakerp->mDotColor); voice.color(speakerp->mStatus > LLSpeaker::STATUS_VOICE_ACTIVE ? LLColor4::transparent : speakerp->mDotColor);
} }
} }
element.columns.add(voice);
} }
LLScrollListCell::Params agep; static const LLCachedControl<bool> hide_age("RadarColumnAgeHidden");
agep.column = "age"; if (!hide_age)
agep.type = "text";
color = sDefaultListText;
std::string age = boost::lexical_cast<std::string>(entry->mAge);
if (entry->mAge > -1)
{ {
static const LLCachedControl<U32> sAvatarAgeAlertDays(gSavedSettings, "AvatarAgeAlertDays"); LLScrollListCell::Params agep;
if ((U32)entry->mAge < sAvatarAgeAlertDays) agep.column = "age";
color = sRadarTextYoung; agep.type = "text";
} color = sDefaultListText;
else std::string age = boost::lexical_cast<std::string>(entry->mAge);
{ if (entry->mAge > -1)
age = "?";
}
agep.value = age;
agep.color = color;
int dur = difftime(time(NULL), entry->getTime());
int hours = dur / 3600;
int mins = (dur % 3600) / 60;
int secs = (dur % 3600) % 60;
LLScrollListCell::Params time;
time.column = "time";
time.type = "text";
time.value = llformat("%d:%02d:%02d", hours, mins, secs);
LLScrollListCell::Params viewer;
viewer.column = "client";
viewer.type = "text";
static const LLCachedControl<LLColor4> avatar_name_color(gColors, "AvatarNameColor",LLColor4(0.98f, 0.69f, 0.36f, 1.f));
color = avatar_name_color;
if (LLVOAvatar* avatarp = gObjectList.findAvatar(av_id))
{
std::string client = SHClientTagMgr::instance().getClientName(avatarp, false);
if (client.empty())
{ {
color = unselected_color; static const LLCachedControl<U32> sAvatarAgeAlertDays(gSavedSettings, "AvatarAgeAlertDays");
client = "?"; if ((U32)entry->mAge < sAvatarAgeAlertDays)
{
static const LLCachedControl<LLColor4> sRadarTextYoung(gColors, "RadarTextYoung");
color = sRadarTextYoung;
}
} }
else SHClientTagMgr::instance().getClientColor(avatarp, false, color); else
viewer.value = client.c_str(); {
age = "?";
}
agep.value = age;
agep.color = color;
element.columns.add(agep);
} }
else
{
viewer.value = getString("Out Of Range");
}
//Blend to make the color show up better
viewer.color = color *.5f + unselected_color * .5f;
// Add individual column cell params to the item param static const LLCachedControl<bool> hide_time("RadarColumnTimeHidden");
element.columns.add(mark); if (!hide_time)
element.columns.add(name); {
element.columns.add(dist); int dur = difftime(time(NULL), entry->getTime());
element.columns.add(pos); int hours = dur / 3600;
element.columns.add(alt); int mins = (dur % 3600) / 60;
if (!hide_act) element.columns.add(act); int secs = (dur % 3600) % 60;
if (!hide_voice) element.columns.add(voice);
element.columns.add(agep); LLScrollListCell::Params time;
element.columns.add(time); time.column = "time";
element.columns.add(viewer); time.type = "text";
time.value = llformat("%d:%02d:%02d", hours, mins, secs);
element.columns.add(time);
}
static const LLCachedControl<bool> hide_client("RadarColumnClientHidden");
if (!hide_client)
{
LLScrollListCell::Params viewer;
viewer.column = "client";
viewer.type = "text";
static const LLCachedControl<LLColor4> avatar_name_color(gColors, "AvatarNameColor",LLColor4(0.98f, 0.69f, 0.36f, 1.f));
color = avatar_name_color;
if (LLVOAvatar* avatarp = gObjectList.findAvatar(av_id))
{
std::string client = SHClientTagMgr::instance().getClientName(avatarp, false);
if (client.empty())
{
color = unselected_color;
client = "?";
}
else SHClientTagMgr::instance().getClientColor(avatarp, false, color);
viewer.value = client.c_str();
}
else
{
viewer.value = getString("Out Of Range");
}
//Blend to make the color show up better
viewer.color = color *.5f + unselected_color * .5f;
element.columns.add(viewer);
}
// Add to list // Add to list
mAvatarList->addRow(element); mAvatarList->addRow(element);