////////////////////////////////////////////////////////////////////////////// // called (infrequently) when the color changes so the subject of the swatch can be updated. void LLColorSwatchCtrl::onColorChanged ( void* data, EColorPickOp pick_op ) { LLColorSwatchCtrl* subject = ( LLColorSwatchCtrl* )data; if ( subject ) { LLFloaterColorPicker* pickerp = (LLFloaterColorPicker*)subject->mPickerHandle.get(); if (pickerp) { // move color across from selector to internal widget storage LLColor4 updatedColor ( pickerp->getCurR (), pickerp->getCurG (), pickerp->getCurB (), subject->mColor.mV[VALPHA] ); // keep current alpha subject->mColor = updatedColor; subject->setControlValue(updatedColor.getValue()); if (pick_op == COLOR_CANCEL && subject->mOnCancelCallback) { subject->mOnCancelCallback(subject, subject->mCallbackUserData); } else if (pick_op == COLOR_SELECT && subject->mOnSelectCallback) { subject->mOnSelectCallback(subject, subject->mCallbackUserData); } else { // just commit change subject->onCommit (); } } } }
void LLControlGroup::setColor4(const LLString& name, const LLColor4 &val) { LLControlBase* control = getControl(name); if (control && control->isType(TYPE_COL4)) { control->set(val.getValue()); } else { CONTROL_ERRS << "Invalid LLColor4 control " << name << llendl; } }
void LLControlGroup::setColor4(const std::string& name, const LLColor4 &val) { LLControlVariable* control = getControl(name); if (control && control->isType(TYPE_COL4)) { control->set(val.getValue()); if(mChangeCallback) mChangeCallback(name,llformat("<%f,%f,%f,%f>",val.mV[VX],val.mV[VY],val.mV[VZ],val.mV[VW])); } else { CONTROL_ERRS << "Invalid LLColor4 control " << name << llendl; } }
//Generate highlight color segments for this paragraph. Pass in default color of paragraph. void LLConsole::Paragraph::makeParagraphColorSegments (const LLColor4 &color) { LLSD paragraph_color_segments; LLColor4 lcolor=color; paragraph_color_segments[0]["text"] =wstring_to_utf8str(mParagraphText); LLSD color_sd = color.getValue(); paragraph_color_segments[0]["color"]=color_sd; for(LLSD::array_const_iterator color_segment_it = paragraph_color_segments.beginArray(); color_segment_it != paragraph_color_segments.endArray(); ++color_segment_it) { LLSD color_llsd = (*color_segment_it)["color"]; std::string color_str = (*color_segment_it)["text"].asString(); ParagraphColorSegment color_segment; color_segment.mColor.setValue(color_llsd); color_segment.mNumChars = color_str.length(); mParagraphColorSegments.push_back(color_segment); } }
/** * 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->getName().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 fucks 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(); } static const LLCachedControl<LLColor4> unselected_color(gColors, "ScrollUnselectedColor",LLColor4(LLColor4U(0, 0, 0, 204)) ); LLColor4 name_color = unselected_color; //Lindens are always more Linden than your friend, make that take precedence if(LLMuteList::getInstance()->isLinden(av_name)) { static const LLCachedControl<LLColor4> ascent_linden_color("AscentLindenColor",LLColor4(0.f,0.f,1.f,1.f)); name_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)); name_color = ascent_estate_owner_color; } //without these dots, SL would suck. else if(is_agent_friend(av_id)) { static const LLCachedControl<LLColor4> ascent_friend_color("AscentFriendColor",LLColor4(1.f,1.f,0.f,1.f)); name_color = ascent_friend_color; } //big fat jerkface who is probably a jerk, display them as such. else if(LLMuteList::getInstance()->isMuted(av_id)) { static const LLCachedControl<LLColor4> ascent_muted_color("AscentMutedColor",LLColor4(0.7f,0.7f,0.7f,1.f)); name_color = ascent_muted_color; } name_color = name_color*0.5f + unselected_color*0.5f; element["columns"][LIST_AVATAR_NAME]["color"] = name_color.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"; static const LLCachedControl<LLColor4> avatar_name_color(gColors, "AvatarNameColor",LLColor4(LLColor4U(251, 175, 93, 255)) ); LLColor4 client_color(avatar_name_color); std::string client; LLVOAvatar *avatarp = gObjectList.findAvatar(av_id); if(avatarp) { avatarp->getClientInfo(client, client_color, TRUE); if(client == "") { client_color = unselected_color; 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 client_color = client_color *.5f + unselected_color * .5f; element["columns"][LIST_CLIENT]["color"] = client_color.getValue(); // Add to list mAvatarList->addElement(element, ADD_BOTTOM); } // finish mAvatarList->sortItems(); mAvatarList->selectMultiple(selected); mAvatarList->setScrollPos(scrollpos); // llinfos << "radar refresh: done" << llendl; }
// Returns number of controls loaded, so 0 if failure U32 LLControlGroup::loadFromFile(const LLString& filename, BOOL require_declaration, eControlType declare_as) { LLString name; LLXmlTree xml_controls; if (!xml_controls.parseFile(filename)) { llwarns << "Unable to open control file " << filename << llendl; return 0; } LLXmlTreeNode* rootp = xml_controls.getRoot(); if (!rootp || !rootp->hasAttribute("version")) { llwarns << "No valid settings header found in control file " << filename << llendl; return 0; } U32 item = 0; U32 validitems = 0; S32 version; rootp->getAttributeS32("version", version); // Check file version if (version != CURRENT_VERSION) { llinfos << filename << " does not appear to be a version " << CURRENT_VERSION << " controls file" << llendl; return 0; } LLXmlTreeNode* child_nodep = rootp->getFirstChild(); while(child_nodep) { name = child_nodep->getName(); BOOL declared = controlExists(name); if (require_declaration && !declared) { // Declaration required, but this name not declared. // Complain about non-empty names. if (!name.empty()) { //read in to end of line llwarns << "LLControlGroup::loadFromFile() : Trying to set \"" << name << "\", setting doesn't exist." << llendl; } child_nodep = rootp->getNextChild(); continue; } // Got an item. Load it up. item++; // If not declared, assume it's a string if (!declared) { switch(declare_as) { case TYPE_COL4: declareColor4(name, LLColor4::white, "", NO_PERSIST); break; case TYPE_COL4U: declareColor4U(name, LLColor4U::white, "", NO_PERSIST); break; case TYPE_STRING: default: declareString(name, LLString::null, "", NO_PERSIST); break; } } // Control name has been declared in code. LLControlBase *control = getControl(name); llassert(control); mLoadedSettings.insert(name); switch(control->mType) { case TYPE_F32: { F32 initial = 0.f; child_nodep->getAttributeF32("value", initial); control->set(initial); validitems++; } break; case TYPE_S32: { S32 initial = 0; child_nodep->getAttributeS32("value", initial); control->set(initial); validitems++; } break; case TYPE_U32: { U32 initial = 0; child_nodep->getAttributeU32("value", initial); control->set((LLSD::Integer) initial); validitems++; } break; case TYPE_BOOLEAN: { BOOL initial = FALSE; child_nodep->getAttributeBOOL("value", initial); control->set(initial); validitems++; } break; case TYPE_STRING: { LLString string; child_nodep->getAttributeString("value", string); if (string == LLString::null) { string = ""; } control->set(string); validitems++; } break; case TYPE_VEC3: { LLVector3 vector; child_nodep->getAttributeVector3("value", vector); control->set(vector.getValue()); validitems++; } break; case TYPE_VEC3D: { LLVector3d vector; child_nodep->getAttributeVector3d("value", vector); control->set(vector.getValue()); validitems++; } break; case TYPE_RECT: { //RN: hack to support reading rectangles from a string LLString rect_string; child_nodep->getAttributeString("value", rect_string); std::istringstream istream(rect_string); S32 left, bottom, width, height; istream >> left >> bottom >> width >> height; LLRect rect; rect.setOriginAndSize(left, bottom, width, height); control->set(rect.getValue()); validitems++; } break; case TYPE_COL4U: { LLColor4U color; child_nodep->getAttributeColor4U("value", color); control->set(color.getValue()); validitems++; } break; case TYPE_COL4: { LLColor4 color; child_nodep->getAttributeColor4("value", color); control->set(color.getValue()); validitems++; } break; case TYPE_COL3: { LLVector3 color; child_nodep->getAttributeVector3("value", color); control->set(LLColor3(color.mV).getValue()); validitems++; } break; } child_nodep = rootp->getNextChild(); } return validitems; }
U32 LLControlGroup::loadFromFileLegacy(const LLString& filename, BOOL require_declaration, eControlType declare_as) { U32 item = 0; U32 validitems = 0; llifstream file; S32 version; file.open(filename.c_str()); /*Flawfinder: ignore*/ if (!file) { llinfos << "LLControlGroup::loadFromFile unable to open." << llendl; return 0; } // Check file version LLString name; file >> name; file >> version; if (name != "version" || version != CURRENT_VERSION) { llinfos << filename << " does not appear to be a version " << CURRENT_VERSION << " controls file" << llendl; return 0; } while (!file.eof()) { file >> name; if (name.empty()) { continue; } if (name.substr(0,2) == "//") { // This is a comment. char buffer[MAX_STRING]; /*Flawfinder: ignore*/ file.getline(buffer, MAX_STRING); continue; } BOOL declared = mNameTable.find(name) != mNameTable.end(); if (require_declaration && !declared) { // Declaration required, but this name not declared. // Complain about non-empty names. if (!name.empty()) { //read in to end of line char buffer[MAX_STRING]; /*Flawfinder: ignore*/ file.getline(buffer, MAX_STRING); llwarns << "LLControlGroup::loadFromFile() : Trying to set \"" << name << "\", setting doesn't exist." << llendl; } continue; } // Got an item. Load it up. item++; // If not declared, assume it's a string if (!declared) { switch(declare_as) { case TYPE_COL4: declareColor4(name, LLColor4::white, LLString::null, NO_PERSIST); break; case TYPE_COL4U: declareColor4U(name, LLColor4U::white, LLString::null, NO_PERSIST); break; case TYPE_STRING: default: declareString(name, LLString::null, LLString::null, NO_PERSIST); break; } } // Control name has been declared in code. LLControlBase *control = getControl(name); llassert(control); mLoadedSettings.insert(name); switch(control->mType) { case TYPE_F32: { F32 initial; file >> initial; control->set(initial); validitems++; } break; case TYPE_S32: { S32 initial; file >> initial; control->set(initial); validitems++; } break; case TYPE_U32: { U32 initial; file >> initial; control->set((LLSD::Integer) initial); validitems++; } break; case TYPE_BOOLEAN: { char boolstring[256]; /*Flawfinder: ignore*/ BOOL valid = FALSE; BOOL initial = FALSE; file >> boolstring; if (!strcmp("TRUE", boolstring)) { initial = TRUE; valid = TRUE; } else if (!strcmp("FALSE", boolstring)) { initial = FALSE; valid = TRUE; } if (valid) { control->set(initial); } else { llinfos << filename << "Item " << item << ": Invalid BOOL control " << name << ", " << boolstring << llendl; } validitems++; } break; case TYPE_STRING: { LLString string; file >> string; control->set(string); validitems++; } break; case TYPE_VEC3: { F32 x, y, z; file >> x >> y >> z; LLVector3 vector(x, y, z); control->set(vector.getValue()); validitems++; } break; case TYPE_VEC3D: { F64 x, y, z; file >> x >> y >> z; LLVector3d vector(x, y, z); control->set(vector.getValue()); validitems++; } break; case TYPE_RECT: { S32 left, bottom, width, height; file >> left >> bottom >> width >> height; LLRect rect; rect.setOriginAndSize(left, bottom, width, height); control->set(rect.getValue()); validitems++; } break; case TYPE_COL4U: { S32 red, green, blue, alpha; LLColor4U color; file >> red >> green >> blue >> alpha; color.setVec(red, green, blue, alpha); control->set(color.getValue()); validitems++; } break; case TYPE_COL4: { LLColor4 color; file >> color.mV[VRED] >> color.mV[VGREEN] >> color.mV[VBLUE] >> color.mV[VALPHA]; control->set(color.getValue()); validitems++; } break; case TYPE_COL3: { LLColor3 color; file >> color.mV[VRED] >> color.mV[VGREEN] >> color.mV[VBLUE]; control->set(color.getValue()); validitems++; } break; } } file.close(); return validitems; }
BOOL LLControlGroup::declareColor4(const LLString& name, const LLColor4 &initial_val, const LLString& comment, BOOL persist ) { return declareControl(name, TYPE_COL4, initial_val.getValue(), comment, persist); }
/** * 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; LLAvatarListEntry *entry = &iter->second; // Skip if avatar hasn't been around if (entry->isDead()) { continue; } av_id = entry->getID(); 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 fucks 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"] = entry->getName().c_str(); if (entry->isFocused()) { element["columns"][LIST_AVATAR_NAME]["font-style"] = "BOLD"; } if (LLMuteList::getInstance()->isMuted(av_id)) { element["columns"][LIST_AVATAR_NAME]["color"] = LLColor4::red2.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::red; } } else { if (distance < 100.0) { snprintf(temp, sizeof(temp), "%.1f", distance); if (distance > 20.0f) { color = LLColor4::yellow1; } else { color = LLColor4::green2; } } else { if (entry->isDrawn()) { color = LLColor4::red; } 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; // Add to list mAvatarList->addElement(element, ADD_BOTTOM); } // finish mAvatarList->sortItems(); mAvatarList->selectMultiple(selected); mAvatarList->setScrollPos(scrollpos); // llinfos << "radar refresh: done" << llendl; }
template <> eControlType get_control_type<LLColor4>(const LLColor4& in, LLSD& out) { out = in.getValue(); return TYPE_COL4; }
LLSD FSData::resolveClientTag(LLUUID id, bool new_system, LLColor4 color){ //WS: Create a new LLSD based on the data from the LegacyClientList if LLSD curtag; curtag["uuid"]=id.asString(); curtag["id_based"]=new_system; curtag["tex_color"]=color.getValue(); // If we don't want to display anything...return if(gSavedSettings.getU32("FSClientTagsVisibility2") == 0) { return curtag; } //WS: Do we want to use Legacy Clienttags? if(gSavedSettings.getU32("FSUseLegacyClienttags") > 0) { if(LegacyClientList.has(id.asString())) { curtag=LegacyClientList[id.asString()]; } else { if(id == LLUUID("5d9581af-d615-bc16-2667-2f04f8eeefe4"))//green { curtag["name"]="Phoenix"; curtag["color"] = LLColor4::green.getValue(); curtag["alt"] = "ed63fbd0-589e-fe1d-a3d0-16905efaa96b"; } else if(id == LLUUID("e35f7d40-6071-4b29-9727-5647bdafb5d5"))//white { curtag["name"] = "Phoenix"; curtag["color"] = LLColor4::white.getValue(); curtag["alt"] = "ed63fbd0-589e-fe1d-a3d0-16905efaa96b"; } else if(id == LLUUID("ae4e92fb-023d-23ba-d060-3403f953ab1a"))//pink { curtag["name"] = "Phoenix"; curtag["color"] = LLColor4::pink.getValue(); curtag["alt"] = "ed63fbd0-589e-fe1d-a3d0-16905efaa96b"; } else if(id == LLUUID("e71b780e-1a57-400d-4649-959f69ec7d51"))//red { curtag["name"] = "Phoenix"; curtag["color"] = LLColor4::red.getValue(); curtag["alt"] = "ed63fbd0-589e-fe1d-a3d0-16905efaa96b"; } else if(id == LLUUID("c1c189f5-6dab-fc03-ea5a-f9f68f90b018"))//orange { curtag["name"] = "Phoenix"; curtag["color"] = LLColor4::orange.getValue(); curtag["alt"] = "ed63fbd0-589e-fe1d-a3d0-16905efaa96b"; } else if(id == LLUUID("8cf0577c-22d3-6a73-523c-15c0a90d6c27")) //purple { curtag["name"] = "Phoenix"; curtag["color"] = LLColor4::purple.getValue(); curtag["alt"] = "ed63fbd0-589e-fe1d-a3d0-16905efaa96b"; } else if(id == LLUUID("5f0e7c32-38c3-9214-01f0-fb16a5b40128"))//yellow { curtag["name"] = "Phoenix"; curtag["color"] = LLColor4::yellow.getValue(); curtag["alt"] = "ed63fbd0-589e-fe1d-a3d0-16905efaa96b"; } else if(id == LLUUID("5bb6e4a6-8e24-7c92-be2e-91419bb0ebcb"))//blue { curtag["name"] = "Phoenix"; curtag["color"] = LLColor4::blue.getValue(); curtag["alt"] = "ed63fbd0-589e-fe1d-a3d0-16905efaa96b"; } else if(id == LLUUID("ed63fbd0-589e-fe1d-a3d0-16905efaa96b"))//default (red) { curtag["name"] = "Phoenix"; curtag["color"] = LLColor4::red.getValue(); } else if(id == LLUUID("c228d1cf-4b5d-4ba8-84f4-899a0796aa97"))//viewer 2.0 { curtag["name"] = "LL Viewer"; } else if(id == LLUUID("cc7a030f-282f-c165-44d2-b5ee572e72bf")) { curtag["name"] = "Imprudence"; } else if(id == LLUUID("54d93609-1392-2a93-255c-a9dd429ecca5")) { curtag["name"] = "Emergence"; } else if(id == LLUUID("8873757c-092a-98fb-1afd-ecd347566fcd")) { curtag["name"] = "Ascent"; } else if(id == LLUUID("f25263b7-6167-4f34-a4ef-af65213b2e39")) { curtag["name"] = "Singularity"; } if(curtag.has("name")) curtag["tpvd"]=true; } } // Filtering starts here: //WS: If the current tag has an "alt" definied and we don't want multiple colors. Resolve the alt. if((gSavedSettings.getU32("FSColorClienttags") == 1) && curtag.has("alt")) { curtag = resolveClientTag(curtag["alt"], new_system, color); } //WS: If we have a tag using the new system, check if we want to display it's name and/or color if(new_system) { if(gSavedSettings.getU32("FSClientTagsVisibility2") >= 3) { // strnlen() doesn't exist on OS X before 10.7. -- TS char tag_temp[UUID_BYTES+1]; strncpy(tag_temp,(const char*)&id.mData[0], UUID_BYTES); tag_temp[UUID_BYTES] = '\0'; U32 tag_len = strlen(tag_temp); std::string clienttagname = std::string((const char*)&id.mData[0], tag_len); LLStringFn::replace_ascii_controlchars(clienttagname, LL_UNKNOWN_CHAR); curtag["name"] = clienttagname; } if(gSavedSettings.getU32("FSColorClienttags") >= 3 || curtag["tpvd"].asBoolean()) { if(curtag["tpvd"].asBoolean() && gSavedSettings.getU32("FSColorClienttags") < 3) { if(color == LLColor4::blue || color == LLColor4::yellow || color == LLColor4::purple || color == LLColor4((F32)0.99,(F32)0.39,(F32)0.12,(F32)1) || color == LLColor4::red || color == LLColor4((F32)0.99,(F32)0.56,(F32)0.65,(F32)1) || color == LLColor4::white || color == LLColor4::green) { curtag["color"] = color.getValue(); } } else { curtag["color"] = color.getValue(); } } } //If we only want to display tpvd viewer. And "tpvd" is not available or false, then // clear the data, but keep the basedata (like uuid, id_based and tex_color) for (maybe) later displaying. if(gSavedSettings.getU32("FSClientTagsVisibility2") <= 1 && (!curtag.has("tpvd") || !curtag["tpvd"].asBoolean())) { curtag.clear(); } curtag["uuid"]=id.asString(); curtag["id_based"]=new_system; curtag["tex_color"]=color.getValue(); return curtag; }
LLSD LLTextParser::parsePartialLineHighlights(const std::string &text, const LLColor4 &color, EHighlightPosition part, S32 index) { //evil recursive string atomizer. LLSD ret_llsd, start_llsd, middle_llsd, end_llsd; for (S32 i=index;i<mHighlights.size();i++) { S32 condition = mHighlights[i]["condition"]; if ((S32)mHighlights[i]["highlight"]==PART && condition!=MATCHES) { if ( (condition==STARTS_WITH && part==START) || (condition==ENDS_WITH && part==END) || condition==CONTAINS || part==WHOLE ) { S32 start = findPattern(text,mHighlights[i]); if (start >= 0 ) { S32 end = std::string(mHighlights[i]["pattern"]).length(); S32 len = text.length(); EHighlightPosition newpart; if (start==0) { start_llsd[0]["text"] =text.substr(0,end); start_llsd[0]["color"]=mHighlights[i]["color"]; if (end < len) { if (part==END || part==WHOLE) newpart=END; else newpart=MIDDLE; end_llsd=parsePartialLineHighlights(text.substr( end ),color,newpart,i); } } else { if (part==START || part==WHOLE) newpart=START; else newpart=MIDDLE; start_llsd=parsePartialLineHighlights(text.substr(0,start),color,newpart,i+1); if (end < len) { middle_llsd[0]["text"] =text.substr(start,end); middle_llsd[0]["color"]=mHighlights[i]["color"]; if (part==END || part==WHOLE) newpart=END; else newpart=MIDDLE; end_llsd=parsePartialLineHighlights(text.substr( (start+end) ),color,newpart,i); } else { end_llsd[0]["text"] =text.substr(start,end); end_llsd[0]["color"]=mHighlights[i]["color"]; } } S32 retcount=0; //FIXME These loops should be wrapped into a subroutine. for (LLSD::array_iterator iter = start_llsd.beginArray(); iter != start_llsd.endArray();++iter) { LLSD highlight = *iter; ret_llsd[retcount++]=highlight; } for (LLSD::array_iterator iter = middle_llsd.beginArray(); iter != middle_llsd.endArray();++iter) { LLSD highlight = *iter; ret_llsd[retcount++]=highlight; } for (LLSD::array_iterator iter = end_llsd.beginArray(); iter != end_llsd.endArray();++iter) { LLSD highlight = *iter; ret_llsd[retcount++]=highlight; } return ret_llsd; } } } } //No patterns found. Just send back what was passed in. ret_llsd[0]["text"] =text; LLSD color_sd = color.getValue(); ret_llsd[0]["color"]=color_sd; return ret_llsd; }
template <> LLSD convert_to_llsd<LLColor4>(const LLColor4& in) { return in.getValue(); }
BOOL LLControlGroup::declareColor4(const std::string& name, const LLColor4 &initial_val, const std::string& comment, BOOL persist ) { return declareControl(name, TYPE_COL4, initial_val.getValue(), comment, SANITY_TYPE_NONE, LLSD(), std::string(""), persist); }