void LLFloaterAvatarList::doCommand(void (*func)(const LLUUID &avatar, const std::string &name)) { LLDynamicArray<LLUUID> ids = mAvatarList->getSelectedIDs(); for (LLDynamicArray<LLUUID>::iterator itr = ids.begin(); itr != ids.end(); ++itr) { LLUUID avid = *itr; LLAvatarListEntry *entry = getAvatarEntry(avid); if (entry != NULL) { llinfos << "Executing command on " << entry->getDisplayName() << llendl; func(avid, entry->getName()); } } }
/** * Redraws the avatar list * Only does anything if the avatar list is visible. * @author Dale Glass */ void LLFloaterAvatarList::refreshAvatarList() { // Don't update list when interface is hidden if (!sInstance->getVisible()) return; // We rebuild the list fully each time it's refreshed // The assumption is that it's faster to refill it and sort than // to rebuild the whole list. LLDynamicArray<LLUUID> selected = mAvatarList->getSelectedIDs(); S32 scrollpos = mAvatarList->getScrollPos(); mAvatarList->deleteAllItems(); LLVector3d mypos = gAgent.getPositionGlobal(); LLVector3d posagent; posagent.setVec(gAgent.getPositionAgent()); LLVector3d simpos = mypos - posagent; std::map<LLUUID, LLAvatarListEntry>::iterator iter; for (iter = mAvatars.begin(); iter != mAvatars.end(); iter++) { LLSD element; LLUUID av_id; std::string av_name; LLAvatarListEntry *entry = &iter->second; // Skip if avatar hasn't been around if (entry->isDead()) { continue; } av_id = entry->getID(); av_name = entry->getDisplayName().c_str(); LLVector3d position = entry->getPosition(); BOOL UnknownAltitude = false; LLVector3d delta = position - mypos; F32 distance = (F32)delta.magVec(); if (position.mdV[VZ] == 0.0) { UnknownAltitude = true; distance = 9000.0; } delta.mdV[2] = 0.0f; F32 side_distance = (F32)delta.magVec(); // HACK: Workaround for an apparent bug: // sometimes avatar entries get stuck, and are registered // by the client as perpetually moving in the same direction. // this makes sure they get removed from the visible list eventually //jcool410 -- this f***s up seeing dueds thru minimap data > 1024m away, so, lets just say > 2048m to the side is bad //aka 8 sims if (side_distance > 2048.0f) { continue; } if (av_id.isNull()) { //llwarns << "Avatar with null key somehow got into the list!" << llendl; continue; } element["id"] = av_id; element["columns"][LIST_MARK]["column"] = "marked"; element["columns"][LIST_MARK]["type"] = "text"; if (entry->isMarked()) { element["columns"][LIST_MARK]["value"] = "X"; element["columns"][LIST_MARK]["color"] = LLColor4::blue.getValue(); element["columns"][LIST_MARK]["font-style"] = "BOLD"; } else { element["columns"][LIST_MARK]["value"] = ""; } element["columns"][LIST_AVATAR_NAME]["column"] = "avatar_name"; element["columns"][LIST_AVATAR_NAME]["type"] = "text"; element["columns"][LIST_AVATAR_NAME]["value"] = av_name; if (entry->isFocused()) { element["columns"][LIST_AVATAR_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 //element["columns"][LIST_AVATAR_NAME]["color"] = gColors.getColor( "MapAvatar" ).getValue(); LLViewerRegion* parent_estate = LLWorld::getInstance()->getRegionFromPosGlobal(entry->getPosition()); LLUUID estate_owner = LLUUID::null; if(parent_estate && parent_estate->isAlive()) { estate_owner = parent_estate->getOwner(); } //Lindens are always more Linden than your friend, make that take precedence if(LLMuteList::getInstance()->isLinden(av_name)) { element["columns"][LIST_AVATAR_NAME]["color"] = gCOASavedSettings->getColor4("AscentLindenColor").getValue(); } //check if they are an estate owner at their current position else if(estate_owner.notNull() && av_id == estate_owner) { element["columns"][LIST_AVATAR_NAME]["color"] = gCOASavedSettings->getColor4("AscentEstateOwnerColor").getValue(); } //without these dots, SL would suck. else if(is_agent_friend(av_id)) { element["columns"][LIST_AVATAR_NAME]["color"] = gCOASavedSettings->getColor4("AscentFriendColor").getValue(); } //big fat jerkface who is probably a jerk, display them as such. else if(LLMuteList::getInstance()->isMuted(av_id)) { element["columns"][LIST_AVATAR_NAME]["color"] = gCOASavedSettings->getColor4("AscentMutedColor").getValue(); } char temp[32]; LLColor4 color = LLColor4::black; element["columns"][LIST_DISTANCE]["column"] = "distance"; element["columns"][LIST_DISTANCE]["type"] = "text"; if (UnknownAltitude) { strcpy(temp, "?"); if (entry->isDrawn()) { color = LLColor4::green2; } } else { if (distance < 100.0) { snprintf(temp, sizeof(temp), "%.1f", distance); if (distance > 20.0f) { color = LLColor4::yellow1; } else { color = LLColor4::red; } } else { if (entry->isDrawn()) { color = LLColor4::green2; } snprintf(temp, sizeof(temp), "%d", (S32)distance); } } element["columns"][LIST_DISTANCE]["value"] = temp; element["columns"][LIST_DISTANCE]["color"] = color.getValue(); position = position - simpos; S32 x = (S32)position.mdV[VX]; S32 y = (S32)position.mdV[VY]; if (x >= 0 && x <= 256 && y >= 0 && y <= 256) { snprintf(temp, sizeof(temp), "%d, %d", x, y); } else { temp[0] = '\0'; if (y < 0) { strcat(temp, "S"); } else if (y > 256) { strcat(temp, "N"); } if (x < 0) { strcat(temp, "W"); } else if (x > 256) { strcat(temp, "E"); } } element["columns"][LIST_POSITION]["column"] = "position"; element["columns"][LIST_POSITION]["type"] = "text"; element["columns"][LIST_POSITION]["value"] = temp; element["columns"][LIST_ALTITUDE]["column"] = "altitude"; element["columns"][LIST_ALTITUDE]["type"] = "text"; if (UnknownAltitude) { strcpy(temp, "?"); } else { snprintf(temp, sizeof(temp), "%d", (S32)position.mdV[VZ]); } element["columns"][LIST_ALTITUDE]["value"] = temp; element["columns"][LIST_CLIENT]["column"] = "client"; element["columns"][LIST_CLIENT]["type"] = "text"; //element["columns"][LIST_METADATA]["column"] = "metadata"; //element["columns"][LIST_METADATA]["type"] = "text"; LLColor4 avatar_name_color = gColors.getColor( "AvatarNameColor" ); std::string client; LLVOAvatar *avatarp = (LLVOAvatar*)gObjectList.findObject(av_id); if(avatarp) { avatarp->getClientInfo(client, avatar_name_color, TRUE); if(client == "") { avatar_name_color = gColors.getColor( "ScrollUnselectedColor" ); client = "?"; } element["columns"][LIST_CLIENT]["value"] = client.c_str(); // <dogmode> // Don't expose Emerald's metadata. //if(avatarp->extraMetadata.length()) //{ // element["columns"][LIST_METADATA]["value"] = avatarp->extraMetadata.c_str(); //} } else { element["columns"][LIST_CLIENT]["value"] = "Out Of Range"; } //Blend to make the color show up better avatar_name_color = avatar_name_color * 0.5f + gColors.getColor( "ScrollUnselectedColor" ) * 0.5f; element["columns"][LIST_CLIENT]["color"] = avatar_name_color.getValue(); // Add to list mAvatarList->addElement(element, ADD_BOTTOM); } // finish mAvatarList->sortItems(); mAvatarList->selectMultiple(selected); mAvatarList->setScrollPos(scrollpos); // llinfos << "radar refresh: done" << llendl; }