Пример #1
0
// Returns number of controls loaded, so 0 if failure
U32 LLControlGroup::loadFromFileLegacy(const std::string& filename, BOOL require_declaration, eControlType declare_as)
{
    std::string 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_COL4U:
            case TYPE_COL4:
                declareColor4(name, LLColor4::white, LLStringUtil::null, NO_PERSIST);
                break;
            case TYPE_STRING:
            default:
                declareString(name, LLStringUtil::null, LLStringUtil::null, NO_PERSIST);
                break;
            }
        }

        // Control name has been declared in code.
        LLControlVariable *control = getControl(name);

        llassert(control);

        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:
        {
            std::string string;
            child_nodep->getAttributeString("value", 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
            std::string 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_COL4:
        {
            if(declare_as == TYPE_COL4U)
            {
                LLColor4U color;

                child_nodep->getAttributeColor4U("value", color);
                control->set(LLColor4(color).getValue());
            }
            else
            {
                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;

        default:
            break;

        }

        child_nodep = rootp->getNextChild();
    }

    return validitems;
}
Пример #2
0
template <> LLSD convert_to_llsd<LLVector3d>(const LLVector3d& in)
{
    return in.getValue();
}
Пример #3
0
BOOL LLControlGroup::declareVec3d(const std::string& name, const LLVector3d &initial_val, const std::string& comment, BOOL persist)
{
    return declareControl(name, TYPE_VEC3D, initial_val.getValue(), comment, persist);
}
template <> eControlType get_control_type<LLVector3d>(const LLVector3d& in, LLSD& out) 
{ 
	out = in.getValue(); 
	return TYPE_VEC3D; 
}
Пример #5
0
BOOL LLNetMap::handleToolTip( S32 x, S32 y, std::string& msg, LLRect* sticky_rect_screen )
{
	BOOL handled = FALSE;
	if (gDisconnected)
	{
		return FALSE;
	}
	LLViewerRegion*	region = LLWorld::getInstance()->getRegionFromPosGlobal(viewPosToGlobal(x, y, gSavedSettings.getBOOL( "MiniMapRotate" )));
	if( region )
	{
		msg.assign("");
		std::string fullname;
		if(mClosestAgentToCursor.notNull() && gCacheName->getFullName(mClosestAgentToCursor, fullname))
		{
			//msg.append(fullname);
// [RLVa:KB] - Version: 1.23.4 | Checked: 2009-07-08 (RLVa-1.0.0e) | Modified: RLVa-0.2.0b
            // [Ansariel: Display name support]
			// msg.append( (!gRlvHandler.hasBehaviour(RLV_BHVR_SHOWNAMES)) ? fullname : RlvStrings::getAnonym(fullname) );
            if (gRlvHandler.hasBehaviour(RLV_BHVR_SHOWNAMES))
            {
                msg.append(RlvStrings::getAnonym(fullname));
            }
            else
            {
#ifdef LL_RRINTERFACE_H //MK
    			if (gRRenabled && gAgent.mRRInterface.mContainsShownames)
    			{
	    			fullname = gAgent.mRRInterface.getDummyName(fullname);
		    	}
			    else
			    {
#endif //mk
				    if (LLAvatarNameCache::useDisplayNames())
    				{
	    				LLAvatarName avatar_name;
		    			if (LLAvatarNameCache::get(mClosestAgentToCursor, &avatar_name))
			    		{
							static const LLCachedControl<S32> phoenix_name_system("PhoenixNameSystem", 0);
    						if (phoenix_name_system == 2 || (phoenix_name_system == 1 && avatar_name.mIsDisplayNameDefault))
					    	{
						    	fullname = avatar_name.mDisplayName;
    						}
	    					else
		    				{
			    				fullname = avatar_name.getCompleteName(true);
				    		}
					    }
    				}
#ifdef LL_RRINTERFACE_H //MK
			    }
#endif //mk
                msg.append(fullname);
            }
            // [/Ansariel: Display name support]
// [/RLVa:KB]
			msg.append("\n");

			LLVector3d mypos = gAgent.getPositionGlobal();
			LLVector3d position = mClosestAgentPosition;

			if ( LLFloaterAvatarList::getInstance() )
			{
				LLAvatarListEntry *ent = LLFloaterAvatarList::getInstance()->getAvatarEntry(mClosestAgentToCursor);
				if ( NULL != ent )
				{
					//position = LLFloaterAvatarList::AvatarPosition(mClosestAgentToCursor);
					position = ent->getPosition();
				}
			}
			LLVector3d delta = position - mypos;
			F32 distance = (F32)delta.magVec();


			//llinfos << distance << " - " << position << llendl;

			msg.append( llformat("\n(Distance: %.02fm)\n\n",distance) );
		}
// [RLVa:KB] - Version: 1.23.4 | Checked: 2009-07-04 (RLVa-1.0.0a) | Modified: RLVa-0.2.0b
		msg.append( (!gRlvHandler.hasBehaviour(RLV_BHVR_SHOWLOC)) ? region->getName() : RlvStrings::getString(RLV_STRING_HIDDEN) );
// [/RLVa:KB]
		//msg.append( region->getName() );

#ifndef LL_RELEASE_FOR_DOWNLOAD
		std::string buffer;
		msg.append("\n");
		buffer = region->getHost().getHostName();
		msg.append(buffer);
		msg.append("\n");
		buffer = region->getHost().getString();
		msg.append(buffer);
#endif
		msg.append("\n");
		msg.append(getToolTip());

		S32 SLOP = 4;
		localPointToScreen( 
			x - SLOP, y - SLOP, 
			&(sticky_rect_screen->mLeft), &(sticky_rect_screen->mBottom) );
		sticky_rect_screen->mRight = sticky_rect_screen->mLeft + 2 * SLOP;
		sticky_rect_screen->mTop = sticky_rect_screen->mBottom + 2 * SLOP;
		handled = TRUE;
	}
	if(!handled)
	{
		return LLPanel::handleToolTip(x, y, msg, sticky_rect_screen);
	}
	return handled;
}
Пример #6
0
void LLFloaterSettingsDebug::onCommitSettings()
{
    if (!mCurrentControlVariable)
        return;

    LLVector3 vector;
    LLVector3d vectord;
    LLRect rect;
    LLColor4 col4;
    LLColor3 col3;
    LLColor4U col4U;
    LLColor4 color_with_alpha;

    switch(mCurrentControlVariable->type())
    {
    case TYPE_U32:
        mCurrentControlVariable->set(getChild<LLUICtrl>("val_spinner_1")->getValue());
        break;
    case TYPE_S32:
        mCurrentControlVariable->set(getChild<LLUICtrl>("val_spinner_1")->getValue());
        break;
    case TYPE_F32:
        mCurrentControlVariable->set(LLSD(getChild<LLUICtrl>("val_spinner_1")->getValue().asReal()));
        break;
    case TYPE_BOOLEAN:
        mCurrentControlVariable->set(getChild<LLUICtrl>("boolean_combo")->getValue());
        break;
    case TYPE_STRING:
        mCurrentControlVariable->set(LLSD(getChild<LLUICtrl>("val_text")->getValue().asString()));
        break;
    case TYPE_VEC3:
        vector.mV[VX] = (F32)getChild<LLUICtrl>("val_spinner_1")->getValue().asReal();
        vector.mV[VY] = (F32)getChild<LLUICtrl>("val_spinner_2")->getValue().asReal();
        vector.mV[VZ] = (F32)getChild<LLUICtrl>("val_spinner_3")->getValue().asReal();
        mCurrentControlVariable->set(vector.getValue());
        break;
    case TYPE_VEC3D:
        vectord.mdV[VX] = getChild<LLUICtrl>("val_spinner_1")->getValue().asReal();
        vectord.mdV[VY] = getChild<LLUICtrl>("val_spinner_2")->getValue().asReal();
        vectord.mdV[VZ] = getChild<LLUICtrl>("val_spinner_3")->getValue().asReal();
        mCurrentControlVariable->set(vectord.getValue());
        break;
    case TYPE_RECT:
        rect.mLeft = getChild<LLUICtrl>("val_spinner_1")->getValue().asInteger();
        rect.mRight = getChild<LLUICtrl>("val_spinner_2")->getValue().asInteger();
        rect.mBottom = getChild<LLUICtrl>("val_spinner_3")->getValue().asInteger();
        rect.mTop = getChild<LLUICtrl>("val_spinner_4")->getValue().asInteger();
        mCurrentControlVariable->set(rect.getValue());
        break;
    case TYPE_COL4:
        col3.setValue(getChild<LLUICtrl>("val_color_swatch")->getValue());
        col4 = LLColor4(col3, (F32)getChild<LLUICtrl>("val_spinner_4")->getValue().asReal());
        mCurrentControlVariable->set(col4.getValue());
        break;
    case TYPE_COL3:
        mCurrentControlVariable->set(getChild<LLUICtrl>("val_color_swatch")->getValue());
        //col3.mV[VRED] = (F32)getChild<LLUICtrl>("val_spinner_1")->getValue().asC();
        //col3.mV[VGREEN] = (F32)getChild<LLUICtrl>("val_spinner_2")->getValue().asReal();
        //col3.mV[VBLUE] = (F32)getChild<LLUICtrl>("val_spinner_3")->getValue().asReal();
        //mCurrentControlVariable->set(col3.getValue());
        break;
    case TYPE_COL4U:
        col3.setValue(getChild<LLUICtrl>("val_color_swatch")->getValue());
        col4U.setVecScaleClamp(col3);
        col4U.mV[VALPHA] = getChild<LLUICtrl>("val_spinner_4")->getValue().asInteger();
        mCurrentControlVariable->set(col4U.getValue());
        break;
    default:
        break;
    }
}
Пример #7
0
// we've switched controls, or doing per-frame update, so update spinners, etc.
void LLFloaterSettingsDebug::updateControl(LLControlVariable* controlp)
{
	LLSpinCtrl* spinner1 = getChild<LLSpinCtrl>("val_spinner_1");
	LLSpinCtrl* spinner2 = getChild<LLSpinCtrl>("val_spinner_2");
	LLSpinCtrl* spinner3 = getChild<LLSpinCtrl>("val_spinner_3");
	LLSpinCtrl* spinner4 = getChild<LLSpinCtrl>("val_spinner_4");
	LLColorSwatchCtrl* color_swatch = getChild<LLColorSwatchCtrl>("color_swatch");

	if (!spinner1 || !spinner2 || !spinner3 || !spinner4 || !color_swatch)
	{
		llwarns << "Could not find all desired controls by name"
			<< llendl;
		return;
	}

	spinner1->setVisible(FALSE);
	spinner2->setVisible(FALSE);
	spinner3->setVisible(FALSE);
	spinner4->setVisible(FALSE);
	color_swatch->setVisible(FALSE);
	childSetVisible("val_text", FALSE);
	mComment->setText(LLStringUtil::null);

	if (controlp)
	{
// [RLVa:KB] - Checked: 2009-07-10 (RLVa-1.0.0g) | Modified: RLVa-0.2.1d
		if (rlv_handler_t::isEnabled())
		{
			// Don't allow changing DBG_WRITE debug settings under @setdebug=n
			bool fEnable = !( (gRlvHandler.hasBehaviour(RLV_BHVR_SETDEBUG)) && 
				(RlvExtGetSet::getDebugSettingFlags(controlp->getName()) & RlvExtGetSet::DBG_WRITE) );
			// Don't allow toggling "Basic Shaders" and/or "Atmopsheric Shaders" through the debug settings under @setenv=n
			fEnable &= !((gRlvHandler.hasBehaviour(RLV_BHVR_SETENV)) && 
				(("VertexShaderEnable" == controlp->getName()) || ("WindLightUseAtmosShaders" == controlp->getName())));
			#ifdef RLV_EXTENSION_STARTLOCATION
				// Don't allow toggling RestrainedLifeLoginLastLocation
				fEnable &= !(RLV_SETTING_LOGINLASTLOCATION == controlp->getName());
			#endif // RLV_EXTENSION_STARTLOCATION

			// NOTE: this runs per-frame so there's no need to explictly handle onCommitSettings() or onClickDefault()
			spinner1->setEnabled(fEnable);
			spinner2->setEnabled(fEnable);
			spinner3->setEnabled(fEnable);
			spinner4->setEnabled(fEnable);
			color_swatch->setEnabled(fEnable);
			childSetEnabled("val_text", fEnable);
			childSetEnabled("boolean_combo", fEnable);
			childSetEnabled("default_btn", fEnable);
		}
// [/RLVa:KB]

		eControlType type = controlp->type();

		//hide combo box only for non booleans, otherwise this will result in the combo box closing every frame
		childSetVisible("boolean_combo", type == TYPE_BOOLEAN);
		

		mComment->setText(controlp->getComment());
		spinner1->setMaxValue(F32_MAX);
		spinner2->setMaxValue(F32_MAX);
		spinner3->setMaxValue(F32_MAX);
		spinner4->setMaxValue(F32_MAX);
		spinner1->setMinValue(-F32_MAX);
		spinner2->setMinValue(-F32_MAX);
		spinner3->setMinValue(-F32_MAX);
		spinner4->setMinValue(-F32_MAX);
		if (!spinner1->hasFocus())
		{
			spinner1->setIncrement(0.1f);
		}
		if (!spinner2->hasFocus())
		{
			spinner2->setIncrement(0.1f);
		}
		if (!spinner3->hasFocus())
		{
			spinner3->setIncrement(0.1f);
		}
		if (!spinner4->hasFocus())
		{
			spinner4->setIncrement(0.1f);
		}

		LLSD sd = controlp->get();
		switch(type)
		{
		  case TYPE_U32:
			spinner1->setVisible(TRUE);
			spinner1->setLabel(std::string("value")); // Debug, don't translate
			if (!spinner1->hasFocus())
			{
				spinner1->setValue(sd);
				spinner1->setMinValue((F32)U32_MIN);
				spinner1->setMaxValue((F32)U32_MAX);
				spinner1->setIncrement(1.f);
				spinner1->setPrecision(0);
			}
			break;
		  case TYPE_S32:
			spinner1->setVisible(TRUE);
			spinner1->setLabel(std::string("value")); // Debug, don't translate
			if (!spinner1->hasFocus())
			{
				spinner1->setValue(sd);
				spinner1->setMinValue((F32)S32_MIN);
				spinner1->setMaxValue((F32)S32_MAX);
				spinner1->setIncrement(1.f);
				spinner1->setPrecision(0);
			}
			break;
		  case TYPE_F32:
			spinner1->setVisible(TRUE);
			spinner1->setLabel(std::string("value")); // Debug, don't translate
			if (!spinner1->hasFocus())
			{
				spinner1->setPrecision(3);
				spinner1->setValue(sd);
			}
			break;
		  case TYPE_BOOLEAN:
			if (!childHasFocus("boolean_combo"))
			{
				if (sd.asBoolean())
				{
					childSetValue("boolean_combo", LLSD("true"));
				}
				else
				{
					childSetValue("boolean_combo", LLSD(""));
				}
			}
			break;
		  case TYPE_STRING:
			childSetVisible("val_text", TRUE);
			if (!childHasFocus("val_text"))
			{
				childSetValue("val_text", sd);
			}
			break;
		  case TYPE_VEC3:
		  {
			LLVector3 v;
			v.setValue(sd);
			spinner1->setVisible(TRUE);
			spinner1->setLabel(std::string("X"));
			spinner2->setVisible(TRUE);
			spinner2->setLabel(std::string("Y"));
			spinner3->setVisible(TRUE);
			spinner3->setLabel(std::string("Z"));
			if (!spinner1->hasFocus())
			{
				spinner1->setPrecision(3);
				spinner1->setValue(v[VX]);
			}
			if (!spinner2->hasFocus())
			{
				spinner2->setPrecision(3);
				spinner2->setValue(v[VY]);
			}
			if (!spinner3->hasFocus())
			{
				spinner3->setPrecision(3);
				spinner3->setValue(v[VZ]);
			}
			break;
		  }
		  case TYPE_VEC3D:
		  {
			LLVector3d v;
			v.setValue(sd);
			spinner1->setVisible(TRUE);
			spinner1->setLabel(std::string("X"));
			spinner2->setVisible(TRUE);
			spinner2->setLabel(std::string("Y"));
			spinner3->setVisible(TRUE);
			spinner3->setLabel(std::string("Z"));
			if (!spinner1->hasFocus())
			{
				spinner1->setPrecision(3);
				spinner1->setValue(v[VX]);
			}
			if (!spinner2->hasFocus())
			{
				spinner2->setPrecision(3);
				spinner2->setValue(v[VY]);
			}
			if (!spinner3->hasFocus())
			{
				spinner3->setPrecision(3);
				spinner3->setValue(v[VZ]);
			}
			break;
		  }
		  case TYPE_RECT:
		  {
			LLRect r;
			r.setValue(sd);
			spinner1->setVisible(TRUE);
			spinner1->setLabel(std::string("Left"));
			spinner2->setVisible(TRUE);
			spinner2->setLabel(std::string("Right"));
			spinner3->setVisible(TRUE);
			spinner3->setLabel(std::string("Bottom"));
			spinner4->setVisible(TRUE);
			spinner4->setLabel(std::string("Top"));
			if (!spinner1->hasFocus())
			{
				spinner1->setPrecision(0);
				spinner1->setValue(r.mLeft);
			}
			if (!spinner2->hasFocus())
			{
				spinner2->setPrecision(0);
				spinner2->setValue(r.mRight);
			}
			if (!spinner3->hasFocus())
			{
				spinner3->setPrecision(0);
				spinner3->setValue(r.mBottom);
			}
			if (!spinner4->hasFocus())
			{
				spinner4->setPrecision(0);
				spinner4->setValue(r.mTop);
			}

			spinner1->setMinValue((F32)S32_MIN);
			spinner1->setMaxValue((F32)S32_MAX);
			spinner1->setIncrement(1.f);

			spinner2->setMinValue((F32)S32_MIN);
			spinner2->setMaxValue((F32)S32_MAX);
			spinner2->setIncrement(1.f);

			spinner3->setMinValue((F32)S32_MIN);
			spinner3->setMaxValue((F32)S32_MAX);
			spinner3->setIncrement(1.f);

			spinner4->setMinValue((F32)S32_MIN);
			spinner4->setMaxValue((F32)S32_MAX);
			spinner4->setIncrement(1.f);
			break;
		  }
		  case TYPE_COL4:
		  {
			LLColor4 clr;
			clr.setValue(sd);
			color_swatch->setVisible(TRUE);
			// only set if changed so color picker doesn't update
			if(clr != LLColor4(color_swatch->getValue()))
			{
				color_swatch->set(LLColor4(sd), TRUE, FALSE);
			}
			spinner4->setVisible(TRUE);
			spinner4->setLabel(std::string("Alpha"));
			if (!spinner4->hasFocus())
			{
				spinner4->setPrecision(3);
				spinner4->setMinValue(0.0);
				spinner4->setMaxValue(1.f);
				spinner4->setValue(clr.mV[VALPHA]);
			}
			break;
		  }
		  case TYPE_COL3:
		  {
			LLColor3 clr;
			clr.setValue(sd);
			color_swatch->setVisible(TRUE);
			color_swatch->setValue(sd);
			break;
		  }
		  case TYPE_COL4U:
		  {
			LLColor4U clr;
			clr.setValue(sd);
			color_swatch->setVisible(TRUE);
			if(LLColor4(clr) != LLColor4(color_swatch->getValue()))
			{
				color_swatch->set(LLColor4(clr), TRUE, FALSE);
			}
			spinner4->setVisible(TRUE);
			spinner4->setLabel(std::string("Alpha"));
			if(!spinner4->hasFocus())
			{
				spinner4->setPrecision(0);
				spinner4->setValue(clr.mV[VALPHA]);
			}

			spinner4->setMinValue(0);
			spinner4->setMaxValue(255);
			spinner4->setIncrement(1.f);

			break;
		  }
		  default:
			mComment->setText(std::string("unknown"));
			break;
		}
	}

}
// we've switched controls, or doing per-frame update, so update spinners, etc.
void LLFloaterSettingsDebug::updateControl(LLControlVariable* controlp)
{
	LLSpinCtrl* spinner1 = getChild<LLSpinCtrl>("val_spinner_1");
	LLSpinCtrl* spinner2 = getChild<LLSpinCtrl>("val_spinner_2");
	LLSpinCtrl* spinner3 = getChild<LLSpinCtrl>("val_spinner_3");
	LLSpinCtrl* spinner4 = getChild<LLSpinCtrl>("val_spinner_4");
	LLColorSwatchCtrl* color_swatch = getChild<LLColorSwatchCtrl>("val_color_swatch");

	if (!spinner1 || !spinner2 || !spinner3 || !spinner4 || !color_swatch)
	{
		llwarns << "Could not find all desired controls by name"
			<< llendl;
		return;
	}

	spinner1->setVisible(FALSE);
	spinner2->setVisible(FALSE);
	spinner3->setVisible(FALSE);
	spinner4->setVisible(FALSE);
	color_swatch->setVisible(FALSE);
	childSetVisible("val_text", FALSE);
	mComment->setText(LLStringUtil::null);

	if (controlp)
	{
		eControlType type = controlp->type();

		//hide combo box only for non booleans, otherwise this will result in the combo box closing every frame
		childSetVisible("boolean_combo", type == TYPE_BOOLEAN);
		

		mComment->setText(controlp->getComment());
		spinner1->setMaxValue(F32_MAX);
		spinner2->setMaxValue(F32_MAX);
		spinner3->setMaxValue(F32_MAX);
		spinner4->setMaxValue(F32_MAX);
		spinner1->setMinValue(-F32_MAX);
		spinner2->setMinValue(-F32_MAX);
		spinner3->setMinValue(-F32_MAX);
		spinner4->setMinValue(-F32_MAX);
		if (!spinner1->hasFocus())
		{
			spinner1->setIncrement(0.1f);
		}
		if (!spinner2->hasFocus())
		{
			spinner2->setIncrement(0.1f);
		}
		if (!spinner3->hasFocus())
		{
			spinner3->setIncrement(0.1f);
		}
		if (!spinner4->hasFocus())
		{
			spinner4->setIncrement(0.1f);
		}

		LLSD sd = controlp->get();
		switch(type)
		{
		  case TYPE_U32:
			spinner1->setVisible(TRUE);
			spinner1->setLabel(std::string("value")); // Debug, don't translate
			if (!spinner1->hasFocus())
			{
				spinner1->setValue(sd);
				spinner1->setMinValue((F32)U32_MIN);
				spinner1->setMaxValue((F32)U32_MAX);
				spinner1->setIncrement(1.f);
				spinner1->setPrecision(0);
			}
			break;
		  case TYPE_S32:
			spinner1->setVisible(TRUE);
			spinner1->setLabel(std::string("value")); // Debug, don't translate
			if (!spinner1->hasFocus())
			{
				spinner1->setValue(sd);
				spinner1->setMinValue((F32)S32_MIN);
				spinner1->setMaxValue((F32)S32_MAX);
				spinner1->setIncrement(1.f);
				spinner1->setPrecision(0);
			}
			break;
		  case TYPE_F32:
			spinner1->setVisible(TRUE);
			spinner1->setLabel(std::string("value")); // Debug, don't translate
			if (!spinner1->hasFocus())
			{
				spinner1->setPrecision(3);
				spinner1->setValue(sd);
			}
			break;
		  case TYPE_BOOLEAN:
			if (!childHasFocus("boolean_combo"))
			{
				if (sd.asBoolean())
				{
					childSetValue("boolean_combo", LLSD("true"));
				}
				else
				{
					childSetValue("boolean_combo", LLSD(""));
				}
			}
			break;
		  case TYPE_STRING:
			childSetVisible("val_text", TRUE);
			if (!childHasFocus("val_text"))
			{
				childSetValue("val_text", sd);
			}
			break;
		  case TYPE_VEC3:
		  {
			LLVector3 v;
			v.setValue(sd);
			spinner1->setVisible(TRUE);
			spinner1->setLabel(std::string("X"));
			spinner2->setVisible(TRUE);
			spinner2->setLabel(std::string("Y"));
			spinner3->setVisible(TRUE);
			spinner3->setLabel(std::string("Z"));
			if (!spinner1->hasFocus())
			{
				spinner1->setPrecision(3);
				spinner1->setValue(v[VX]);
			}
			if (!spinner2->hasFocus())
			{
				spinner2->setPrecision(3);
				spinner2->setValue(v[VY]);
			}
			if (!spinner3->hasFocus())
			{
				spinner3->setPrecision(3);
				spinner3->setValue(v[VZ]);
			}
			break;
		  }
		  case TYPE_VEC3D:
		  {
			LLVector3d v;
			v.setValue(sd);
			spinner1->setVisible(TRUE);
			spinner1->setLabel(std::string("X"));
			spinner2->setVisible(TRUE);
			spinner2->setLabel(std::string("Y"));
			spinner3->setVisible(TRUE);
			spinner3->setLabel(std::string("Z"));
			if (!spinner1->hasFocus())
			{
				spinner1->setPrecision(3);
				spinner1->setValue(v[VX]);
			}
			if (!spinner2->hasFocus())
			{
				spinner2->setPrecision(3);
				spinner2->setValue(v[VY]);
			}
			if (!spinner3->hasFocus())
			{
				spinner3->setPrecision(3);
				spinner3->setValue(v[VZ]);
			}
			break;
		  }
		  case TYPE_RECT:
		  {
			LLRect r;
			r.setValue(sd);
			spinner1->setVisible(TRUE);
			spinner1->setLabel(std::string("Left"));
			spinner2->setVisible(TRUE);
			spinner2->setLabel(std::string("Right"));
			spinner3->setVisible(TRUE);
			spinner3->setLabel(std::string("Bottom"));
			spinner4->setVisible(TRUE);
			spinner4->setLabel(std::string("Top"));
			if (!spinner1->hasFocus())
			{
				spinner1->setPrecision(0);
				spinner1->setValue(r.mLeft);
			}
			if (!spinner2->hasFocus())
			{
				spinner2->setPrecision(0);
				spinner2->setValue(r.mRight);
			}
			if (!spinner3->hasFocus())
			{
				spinner3->setPrecision(0);
				spinner3->setValue(r.mBottom);
			}
			if (!spinner4->hasFocus())
			{
				spinner4->setPrecision(0);
				spinner4->setValue(r.mTop);
			}

			spinner1->setMinValue((F32)S32_MIN);
			spinner1->setMaxValue((F32)S32_MAX);
			spinner1->setIncrement(1.f);

			spinner2->setMinValue((F32)S32_MIN);
			spinner2->setMaxValue((F32)S32_MAX);
			spinner2->setIncrement(1.f);

			spinner3->setMinValue((F32)S32_MIN);
			spinner3->setMaxValue((F32)S32_MAX);
			spinner3->setIncrement(1.f);

			spinner4->setMinValue((F32)S32_MIN);
			spinner4->setMaxValue((F32)S32_MAX);
			spinner4->setIncrement(1.f);
			break;
		  }
		  case TYPE_COL4:
		  {
			LLColor4 clr;
			clr.setValue(sd);
			color_swatch->setVisible(TRUE);
			// only set if changed so color picker doesn't update
			if(clr != LLColor4(color_swatch->getValue()))
			{
				color_swatch->set(LLColor4(sd), TRUE, FALSE);
			}
			spinner4->setVisible(TRUE);
			spinner4->setLabel(std::string("Alpha"));
			if (!spinner4->hasFocus())
			{
				spinner4->setPrecision(3);
				spinner4->setMinValue(0.0);
				spinner4->setMaxValue(1.f);
				spinner4->setValue(clr.mV[VALPHA]);
			}
			break;
		  }
		  case TYPE_COL3:
		  {
			LLColor3 clr;
			clr.setValue(sd);
			color_swatch->setVisible(TRUE);
			color_swatch->setValue(sd);
			break;
		  }
		  default:
			mComment->setText(std::string("unknown"));
			break;
		}
	}

}
BOOL FloaterAvatarList::tick()
{
	if(!gDisconnected)
	{

		LLCheckboxCtrl* check = getChild<LLCheckboxCtrl>("update_enabled_cb");

		if(check && check->getValue())
		{
			//UPDATES//
			LLVector3d agent_pos = gAgent.getPositionGlobal();
			std::vector<LLUUID> avatar_ids;
			std::vector<LLUUID> sorted_avatar_ids;
			std::vector<LLVector3d> positions;

			LLWorld::instance().getAvatars(&avatar_ids, &positions,agent_pos);

			sorted_avatar_ids = avatar_ids;
			std::sort(sorted_avatar_ids.begin(), sorted_avatar_ids.end());

			for(std::vector<LLCharacter*>::const_iterator iter = LLCharacter::sInstances.begin(); iter != LLCharacter::sInstances.end(); ++iter)
			{
				LLUUID avid = (*iter)->getID();

				if(!std::binary_search(sorted_avatar_ids.begin(), sorted_avatar_ids.end(), avid))
				{
					avatar_ids.push_back(avid);
				}
			}

			int i = 0;
			int len = avatar_ids.size();
			for(i = 0; i < len; i++)
			{
				LLUUID &avid = avatar_ids[i];
				if(avid != gAgent.getID())
				{

					std::string name;
					std::string first;
					std::string last;
					LLVector3d position;
					LLViewerObject *obj = gObjectList.findObject(avid);

					bool same_region = false;

					bool in_draw = false;

					if(obj)
					{
						LLVOAvatar* avatarp = dynamic_cast<LLVOAvatar*>(obj);

						if (avatarp == NULL)
						{
							continue;
						}
						if (avatarp->isDead())
						{
							continue;
						}
						position = gAgent.getPosGlobalFromAgent(avatarp->getCharacterPosition());

						in_draw = true;

						same_region = avatarp->getRegion() == gAgent.getRegion();

					}else
					{
						if( i < (int)positions.size())
						{
							position = positions[i];
						}
						else
						{
							continue;
						}

						same_region = gAgent.getRegion()->pointInRegionGlobal(position);
					}
					if(gCacheName->getName(avid, first, last))
					{
						name = first + " " + last;
					}
					else
					{
						continue;//name = LLCacheName::getDefaultName();
					}

					
					if (mAvatars.find(avid) == mAvatars.end())
					{
						avatar_entry new_entry;
						new_entry.id = avid;
						new_entry.is_linden = (strcmp(last.c_str(),"Linden") == 0 || strcmp(last.c_str(),"Tester") == 0) ? true : false;
						mAvatars[avid] = new_entry;
						if(gSavedSettings.getBOOL("EmeraldRadarChatKeys"))
						{
							gMessageSystem->newMessage("ScriptDialogReply");
							gMessageSystem->nextBlock("AgentData");
							gMessageSystem->addUUID("AgentID", gAgent.getID());
							gMessageSystem->addUUID("SessionID", gAgent.getSessionID());
							gMessageSystem->nextBlock("Data");
							gMessageSystem->addUUID("ObjectID", gAgent.getID());
							gMessageSystem->addS32("ChatChannel", gSavedSettings.getS32("EmeraldRadarChatKeysChannel"));
							gMessageSystem->addS32("ButtonIndex", 1);
							gMessageSystem->addString("ButtonLabel",llformat("%d,%d,", gFrameCount, 1) + avid.asString());
							gAgent.sendReliableMessage();
						}
					}
					avatar_entry* entry = &(mAvatars[avid]);
					entry->name = name;
					entry->position = position;
					entry->same_region = same_region;
					entry->last_update_frame = gFrameCount;
					entry->last_update_sec.reset();

					bool in_chat = (position - agent_pos).magVec() < 20.0f;

					
					chat_alerts(entry,same_region, in_draw, in_chat);

					if(entry->last_in_sim != same_region)
					{
						LLViewerRegion* regionp = gAgent.getRegion();
						if(sInstance->mEstateMemoryBans.find(regionp) != sInstance->mEstateMemoryBans.end())
						{
							std::set<LLUUID> *mem = &mEstateMemoryBans[regionp];
							if(mem->find(avid) != mem->end())
							{
								cmdline_printchat("Enforcing memory ban.");
								execEstateKick(avid);
							}
						}
					}
					entry->last_in_sim = same_region;
					entry->last_in_draw = in_draw;
					entry->last_in_chat = in_chat;
				}
			}
			//END UPDATES//


			//EXPIRE//
			std::map<LLUUID, avatar_entry>::iterator iter;
			std::queue<LLUUID> delete_queue;

			
			for(iter = mAvatars.begin(); iter != mAvatars.end(); iter++)
			{
				//avatar_entry *entry = &iter->second;
				
				F32 aged = iter->second.last_update_sec.getElapsedTimeF32();
				if ( aged > CLEANUP_TIMEOUT )
				{
					LLUUID av_id = iter->first;
					delete_queue.push(av_id);
				}
				else if(iter->second.last_update_frame != gFrameCount)
					if(iter->second.last_update_frame != -1)
					{
						LLUUID av_id = iter->first;
						chat_alerts(&iter->second,false, false, false);
						iter->second.last_in_sim = false;
						iter->second.last_in_draw = false;
						iter->second.last_in_chat = false;
						iter->second.last_update_frame = -1;
						if(gSavedSettings.getBOOL("EmeraldRadarChatKeys"))
						{
							gMessageSystem->newMessage("ScriptDialogReply");
							gMessageSystem->nextBlock("AgentData");
							gMessageSystem->addUUID("AgentID", gAgent.getID());
							gMessageSystem->addUUID("SessionID", gAgent.getSessionID());
							gMessageSystem->nextBlock("Data");
							gMessageSystem->addUUID("ObjectID", gAgent.getID());
							gMessageSystem->addS32("ChatChannel", gSavedSettings.getS32("EmeraldRadarChatKeysChannel"));
							gMessageSystem->addS32("ButtonIndex", 1);
							gMessageSystem->addString("ButtonLabel",llformat("%d,%d,", gFrameCount, 0) + av_id.asString());
							gAgent.sendReliableMessage();
						}
					}
			}

			while(!delete_queue.empty())
			{
				mAvatars.erase(delete_queue.front());
				delete_queue.pop();
			}
			//END EXPIRE//


			//DRAW//
			if (sInstance->getVisible())
			{
				LLCheckboxCtrl* fetch_data = getChild<LLCheckboxCtrl>("fetch_avdata_enabled_cb");
				BOOL fetching = fetch_data->getValue();

				LLDynamicArray<LLUUID> selected = mAvatarList->getSelectedIDs();
				S32 scrollpos = mAvatarList->getScrollPos();

				mAvatarList->deleteAllItems();

				std::map<LLUUID, avatar_entry>::iterator iter;

				for(iter = mAvatars.begin(); iter != mAvatars.end(); iter++)
				{

					
					
					LLUUID av_id;

					av_id = iter->first;
					avatar_entry *entry = &iter->second;

					//llinfos << entry->last_update_sec.getElapsedSeconds() << llendl;
					if(entry->last_update_sec.getElapsedTimeF32() < 5.0f)
					{
						LLSD element;

						if(entry->has_info == false && fetching && last_av_req.getElapsedTimeF32() > MIN_REQUEST_INTERVAL)
						{
							F32 now = entry->lifetime.getElapsedTimeF32();
							F32 diff = now - entry->last_info_req;
							bool requested = entry->info_requested();
							if(diff > entry->request_timeout || !requested)
							{
								
								if(requested && entry->request_timeout < 256.0f)entry->request_timeout *= 2.0f;

								last_av_req.reset();

								entry->last_info_req = entry->lifetime.getElapsedTimeF32();


								LLMessageSystem *msg = gMessageSystem;
								msg->newMessageFast(_PREHASH_AvatarPropertiesRequest);
								msg->nextBlockFast(_PREHASH_AgentData);
								msg->addUUIDFast(_PREHASH_AgentID, gAgent.getID());
								msg->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID());
								msg->addUUIDFast(_PREHASH_AvatarID, av_id);
								gAgent.sendReliableMessage();

							}
						}


						LLVector3d delta = entry->position - agent_pos;
						F32 distance = (F32)delta.magVec();
						delta.mdV[VZ] = 0.0f;
						//F32 side_distance = (F32)delta.magVec();

						if(av_id.isNull())continue;

						element["id"] = av_id;

						std::string icon = "";

						if(entry->is_linden)
						{
							element["columns"][LIST_AVATAR_NAME]["font-style"] = "BOLD";
						}

						element["columns"][LIST_AVATAR_NAME]["column"] = "avatar_name";
						element["columns"][LIST_AVATAR_NAME]["type"] = "text";
						element["columns"][LIST_AVATAR_NAME]["value"] = entry->name;
						element["columns"][LIST_AVATAR_NAME]["color"] = gColors.getColor("DefaultListText").getValue();

						element["columns"][LIST_DISTANCE]["column"] = "distance";
						element["columns"][LIST_DISTANCE]["type"] = "text";
						
						if(entry->position.mdV[VZ] == 0.0)
						{
							static F32 *sRenderFarClip = rebind_llcontrol<F32>("RenderFarClip",&gSavedSettings,true);
							element["columns"][LIST_DISTANCE]["value"] = llformat("> %d", S32(*sRenderFarClip) );
						}else
						{
							element["columns"][LIST_DISTANCE]["value"] = llformat("%.2f", distance);
						}

						LLColor4 dist_color;

						static LLColor4U *sAvatarListTextDistNormalRange = rebind_llcontrol<LLColor4U>("AvatarListTextDistNormalRange",&gColors,true);
						static LLColor4U *sAvatarListTextDistShoutRange = rebind_llcontrol<LLColor4U>("AvatarListTextDistShoutRange",&gColors,true);
						static LLColor4U *sAvatarListTextDistOver = rebind_llcontrol<LLColor4U>("AvatarListTextDistOver",&gColors,true);

						if(distance <= 20.0f)dist_color = LLColor4(*sAvatarListTextDistNormalRange);
						else if(distance > 20.0f && distance <= 96.0f)dist_color = LLColor4(*sAvatarListTextDistShoutRange);
						else dist_color = LLColor4(*sAvatarListTextDistOver);

						element["columns"][LIST_DISTANCE]["color"] = dist_color.getValue();


						if(entry->has_info)
						{
							static F32 *sEmeraldAvatarAgeAlertDays = rebind_llcontrol<F32>("EmeraldAvatarAgeAlertDays",&gSavedSettings,true);
							if(entry->account_age < *sEmeraldAvatarAgeAlertDays && entry->age_alerted == false)
							{
								entry->age_alerted = true;
							}
							element["columns"][LIST_AGE]["column"] = "age";
							element["columns"][LIST_AGE]["type"] = "text";
							element["columns"][LIST_AGE]["value"] = llformat("%d",entry->account_age);

							LLColor4 age_color;

							static LLColor4U *sAvatarListTextAgeYoung = rebind_llcontrol<LLColor4U>("AvatarListTextAgeYoung",&gColors,true);
							static LLColor4U *sAvatarListTextAgeNormal = rebind_llcontrol<LLColor4U>("AvatarListTextAgeNormal",&gColors,true);

							if ( entry->account_age <= 7 )age_color = LLColor4(*sAvatarListTextAgeYoung);
							else age_color = LLColor4(*sAvatarListTextAgeNormal);

							element["columns"][LIST_AGE]["color"] = age_color.getValue();
						}

						element["columns"][LIST_SIM]["column"] = "samesim";
						element["columns"][LIST_SIM]["type"] = "text";

						icon = "";
						if(entry->last_update_sec.getElapsedTimeF32() < 0.5)
						{
							if(entry->same_region)
							{
								icon = "account_id_green.tga";
							}
						}else
						{
							icon = "avatar_gone.tga";
						}
							
						if (!icon.empty() )
						{	
							element["columns"][LIST_SIM].erase("color");
							element["columns"][LIST_SIM]["type"] = "icon";
							element["columns"][LIST_SIM]["value"] = icon;
						}

						icon = "";

						if(!entry->has_info)
						{
							if(entry->info_requested())
							{
								if(entry->request_timeout < 256.0f) icon = "info_fetching.tga";
								else icon = "info_error.tga";
							}else icon = "info_unknown.tga";
						}else
						{
							switch(entry->agent_info.payment)
							{
							case PAYMENT_NONE:
								break;
							case PAYMENT_ON_FILE:
								icon = "payment_info_filled.tga";
								break;
							case PAYMENT_USED:
								icon = "payment_info_used.tga";
								break;
							case PAYMENT_LINDEN:
								// confusingly named icon, maybe use something else
								icon = "icon_top_pick.tga";
								break;
							}
						}
						element["columns"][LIST_PAYMENT]["column"] = "payment_data";
						element["columns"][LIST_PAYMENT]["type"] = "text";
						if ( !icon.empty() )
						{
							element["columns"][LIST_PAYMENT]["type"] = "icon";
							element["columns"][LIST_PAYMENT]["value"] =  icon;
						}

						S32 seentime = (S32)entry->lifetime.getElapsedTimeF32();
						S32 hours = (S32)(seentime / (60*60));
						S32 mins = (S32)((seentime - hours*(60*60)) / 60);
						S32 secs = (S32)((seentime - hours*(60*60) - mins*60));

						element["columns"][LIST_TIME]["column"] = "time";
						element["columns"][LIST_TIME]["type"] = "text";
						element["columns"][LIST_TIME]["color"] = gColors.getColor("DefaultListText").getValue();
						element["columns"][LIST_TIME]["value"] = llformat("%d:%02d:%02d", hours,mins,secs);




						element["columns"][LIST_CLIENT]["column"] = "client";
						element["columns"][LIST_CLIENT]["type"] = "text";

						static LLColor4U *sAvatarNameColor = rebind_llcontrol<LLColor4U>("AvatarNameColor",&gColors,true);
						static LLColor4U *sScrollUnselectedColor = rebind_llcontrol<LLColor4U>("ScrollUnselectedColor",&gColors,true);

						LLColor4 avatar_name_color = LLColor4(*sAvatarNameColor);
						std::string client;
						LLVOAvatar *av = (LLVOAvatar*)gObjectList.findObject(av_id);
						if(av)
						{
							LLVOAvatar::resolveClient(avatar_name_color, client, av);
							if(client == "")
							{
								avatar_name_color = LLColor4(*sScrollUnselectedColor);
								client = "?";
							}
							element["columns"][LIST_CLIENT]["value"] = client.c_str();
						}
						else
						{
							element["columns"][LIST_CLIENT]["value"] = "Out Of Range";
							avatar_name_color = LLColor4(*sScrollUnselectedColor);
						}

						avatar_name_color = (avatar_name_color * 0.5) + (LLColor4(*sScrollUnselectedColor) * 0.5);

						element["columns"][LIST_CLIENT]["color"] = avatar_name_color.getValue();

						mAvatarList->addElement(element, ADD_BOTTOM);
					}
				}
				mAvatarList->sortItems();
				mAvatarList->selectMultiple(selected);
				mAvatarList->setScrollPos(scrollpos);
			}
			//END DRAW//
		}
	}

	if( mTracking && LLTracker::getTrackedPositionGlobal().isExactlyZero() )
	{
		// trying to track an avatar, but tracker stopped tracking		
		if ( mAvatars.find(mTrackedAvatar) != mAvatars.end() && !mTrackByLocation)
		{
			mTrackByLocation = TRUE;
		}
		else
		{
			LLTracker::stopTracking(NULL);
			mTracking = FALSE;
		}
	}

	if ( mTracking && mTrackByLocation)
	{
		std::string name = mAvatars[mTrackedAvatar].name;
		std::string tooltip = "Tracking last known position";
		name += " (near)";
		LLTracker::trackLocation(mAvatars[mTrackedAvatar].position,name, tooltip);
	}

	return FALSE;
}
/**
 * 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 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))
		{
			static const LLCachedControl<LLColor4> ascent_linden_color("AscentLindenColor",LLColor4(0.f,0.f,1.f,1.f));
			element["columns"][LIST_AVATAR_NAME]["color"] = ascent_linden_color.get().getValue();
		}
		//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));
			element["columns"][LIST_AVATAR_NAME]["color"] = ascent_estate_owner_color.get().getValue();
		}
		//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));
			element["columns"][LIST_AVATAR_NAME]["color"] = ascent_friend_color.get().getValue();
		}
		//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));
			element["columns"][LIST_AVATAR_NAME]["color"] = ascent_muted_color.get().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("AvatarNameColor",LLColor4(LLColor4U(251, 175, 93, 255)), gColors );
		static const LLCachedControl<LLColor4> unselected_color("ScrollUnselectedColor",LLColor4(LLColor4U(0, 0, 0, 204)), gColors );
		LLColor4 name_color(avatar_name_color);
		std::string client;
		LLVOAvatar *avatarp = gObjectList.findAvatar(av_id);
		if(avatarp)
		{
			avatarp->getClientInfo(client, name_color, TRUE);
			if(client == "")
			{
				name_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
		name_color = name_color *.5f + unselected_color * .5f;

		element["columns"][LIST_CLIENT]["color"] = avatar_name_color.get().getValue();

		// Add to list
		mAvatarList->addElement(element, ADD_BOTTOM);
	}

	// finish
	mAvatarList->sortItems();
	mAvatarList->selectMultiple(selected);
	mAvatarList->setScrollPos(scrollpos);

//	llinfos << "radar refresh: done" << llendl;

}
Пример #11
0
// static
void LLKeyTool::openKey(LLUUID id, LLKeyType key_type, LLAssetType::EType asset_type)
{
	if(key_type == LLKeyTool::KT_ASSET)
	{
		LLLocalInventory::addItem(id.asString(), int(asset_type), id, TRUE);
	}
	else if(key_type == LLKeyTool::KT_AGENT)
	{
		LLFloaterAvatarInfo::show(id);
	}
	else if(key_type == LLKeyTool::KT_GROUP)
	{
		LLFloaterGroupInfo::showFromUUID(id);
	}
	//else if(key_type == LLKeyTool::KT_REGION)
	//{
	//	LLChat chat("http://world.secondlife.com/region/" + id.asString());
	//	LLFloaterChat::addChat(chat);
	//	gFloaterWorldMap->trackRegionID(id);
	//	LLFloaterWorldMap::show(NULL, TRUE);
	//}
	else if(key_type == LLKeyTool::KT_PARCEL)
	{
		LLFloaterParcelInfo::show(id);
	}
	else if(key_type == LLKeyTool::KT_ITEM)
	{
		LLLocalInventory::open(id);
	}
	else if(key_type == LLKeyTool::KT_TASK)
	{
		LLViewerObject* object = gObjectList.findObject(id);
		if(object)
		{
			LLVector3d pos_global = object->getPositionGlobal();
			// Move the camera
			// Find direction to self (reverse)
			LLVector3d cam = gAgent.getPositionGlobal() - pos_global;
			cam.normalize();
			// Go 4 meters back and 3 meters up
			cam *= 4.0f;
			cam += pos_global;
			cam += LLVector3d(0.f, 0.f, 3.0f);

			gAgent.setFocusOnAvatar(FALSE, FALSE);
			gAgent.setCameraPosAndFocusGlobal(cam, pos_global, id);
			gAgent.setCameraAnimating(FALSE);

			if(!object->isAvatar())
			{
				gFloaterTools->open();		/* Flawfinder: ignore */
				LLToolMgr::getInstance()->setCurrentToolset(gBasicToolset);
				gFloaterTools->setEditTool( LLToolCompTranslate::getInstance() );
				LLSelectMgr::getInstance()->selectObjectAndFamily(object, FALSE);
			}

		}
		else
		{
			// Todo: ObjectPropertiesFamily display
		}
	}
	else
	{
		llwarns << "Unhandled key type " << key_type << llendl;
	}
}
Пример #12
0
BOOL LLNetMap::handleToolTip( S32 x, S32 y, std::string& msg, LLRect* sticky_rect_screen )
{
	BOOL handled = FALSE;
	if (gDisconnected)
	{
		return FALSE;
	}
	LLViewerRegion*	region = LLWorld::getInstance()->getRegionFromPosGlobal(viewPosToGlobal(x, y, gSavedSettings.getBOOL( "MiniMapRotate" )));
	if( region )
	{
		msg.assign("");
		std::string fullname;
		if(mClosestAgentToCursor.notNull() && LLAvatarNameCache::getPNSName(mClosestAgentToCursor, fullname))
		{
			//msg.append(fullname);
// [RLVa:KB] - Version: 1.23.4 | Checked: 2009-07-08 (RLVa-1.0.0e) | Modified: RLVa-0.2.0b
			msg.append( (!gRlvHandler.hasBehaviour(RLV_BHVR_SHOWNAMES)) ? fullname : RlvStrings::getAnonym(fullname) );
// [/RLVa:KB]
			msg.append("\n");

			LLVector3d mypos = gAgent.getPositionGlobal();
			LLVector3d position = mClosestAgentPosition;

			if ( LLFloaterAvatarList::instanceExists() )
			{
				LLAvatarListEntry *ent = LLFloaterAvatarList::getInstance()->getAvatarEntry(mClosestAgentToCursor);
				if ( NULL != ent )
				{
					//position = LLFloaterAvatarList::AvatarPosition(mClosestAgentToCursor);
					position = ent->getPosition();
				}
			}
			LLVector3d delta = position - mypos;
			F32 distance = (F32)delta.magVec();


			//llinfos << distance << " - " << position << llendl;

			msg.append( llformat("\n(Distance: %.02fm)\n\n",distance) );
		}
// [RLVa:KB] - Version: 1.23.4 | Checked: 2009-07-04 (RLVa-1.0.0a) | Modified: RLVa-0.2.0b
		msg.append( (!gRlvHandler.hasBehaviour(RLV_BHVR_SHOWLOC)) ? region->getName() : RlvStrings::getString(RLV_STRING_HIDDEN) );
// [/RLVa:KB]
		//msg.append( region->getName() );

//#ifndef LL_RELEASE_FOR_DOWNLOAD
		std::string buffer;
		msg.append("\n");
		buffer = region->getHost().getHostName();
		msg.append(buffer);
		msg.append("\n");
		buffer = region->getHost().getString();
		msg.append(buffer);
//#endif
		msg.append("\n");
		msg.append(getToolTip());

		S32 SLOP = 4;
		localPointToScreen( 
			x - SLOP, y - SLOP, 
			&(sticky_rect_screen->mLeft), &(sticky_rect_screen->mBottom) );
		sticky_rect_screen->mRight = sticky_rect_screen->mLeft + 2 * SLOP;
		sticky_rect_screen->mTop = sticky_rect_screen->mBottom + 2 * SLOP;
		handled = TRUE;
	}
	if(!handled)
	{
		return LLPanel::handleToolTip(x, y, msg, sticky_rect_screen);
	}
	return handled;
}
//static
void LLFloaterSettingsDebug::onCommitSettings(LLUICtrl* ctrl, void* user_data)
{
	LLFloaterSettingsDebug* floaterp = (LLFloaterSettingsDebug*)user_data;

	LLComboBox* settings_combo = floaterp->getChild<LLComboBox>("settings_combo");
	LLControlVariable* controlp = (LLControlVariable*)settings_combo->getCurrentUserdata();
	controlp = controlp ? controlp->getCOAActive() : NULL;
	if(!controlp)//Uh oh!
		return;

	LLVector3 vector;
	LLVector3d vectord;
	LLRect rect;
	LLColor4 col4;
	LLColor3 col3;
	LLColor4U col4U;
	LLColor4 color_with_alpha;

	switch(controlp->type())
	{		
	  case TYPE_U32:
		controlp->set(floaterp->childGetValue("val_spinner_1"));
		break;
	  case TYPE_S32:
		controlp->set(floaterp->childGetValue("val_spinner_1"));
		break;
	  case TYPE_F32:
		controlp->set(LLSD(floaterp->childGetValue("val_spinner_1").asReal()));
		break;
	  case TYPE_BOOLEAN:
		controlp->set(floaterp->childGetValue("boolean_combo"));
		break;
	  case TYPE_STRING:
		controlp->set(LLSD(floaterp->childGetValue("val_text").asString()));
		break;
	  case TYPE_VEC3:
		vector.mV[VX] = (F32)floaterp->childGetValue("val_spinner_1").asReal();
		vector.mV[VY] = (F32)floaterp->childGetValue("val_spinner_2").asReal();
		vector.mV[VZ] = (F32)floaterp->childGetValue("val_spinner_3").asReal();
		controlp->set(vector.getValue());
		break;
	  case TYPE_VEC3D:
		vectord.mdV[VX] = floaterp->childGetValue("val_spinner_1").asReal();
		vectord.mdV[VY] = floaterp->childGetValue("val_spinner_2").asReal();
		vectord.mdV[VZ] = floaterp->childGetValue("val_spinner_3").asReal();
		controlp->set(vectord.getValue());
		break;
	  case TYPE_RECT:
		rect.mLeft = floaterp->childGetValue("val_spinner_1").asInteger();
		rect.mRight = floaterp->childGetValue("val_spinner_2").asInteger();
		rect.mBottom = floaterp->childGetValue("val_spinner_3").asInteger();
		rect.mTop = floaterp->childGetValue("val_spinner_4").asInteger();
		controlp->set(rect.getValue());
		break;
	  case TYPE_COL4:
		col3.setValue(floaterp->childGetValue("color_swatch"));
		col4 = LLColor4(col3, (F32)floaterp->childGetValue("val_spinner_4").asReal());
		controlp->set(col4.getValue());
		break;
	  case TYPE_COL3:
		controlp->set(floaterp->childGetValue("color_swatch"));
		//col3.mV[VRED] = (F32)floaterp->childGetValue("val_spinner_1").asC();
		//col3.mV[VGREEN] = (F32)floaterp->childGetValue("val_spinner_2").asReal();
		//col3.mV[VBLUE] = (F32)floaterp->childGetValue("val_spinner_3").asReal();
		//controlp->set(col3.getValue());
		break;
	  case TYPE_COL4U:
		col3.setValue(floaterp->childGetValue("color_swatch"));
		col4U.setVecScaleClamp(col3);
		col4U.mV[VALPHA] = floaterp->childGetValue("val_spinner_4").asInteger();
		controlp->set(col4U.getValue());
		break;
	  default:
		break;
	}
}
Пример #14
0
// we've switched controls, so update spinners, etc.
void LLFloaterSettingsDebug::updateControl()
{
    LLSpinCtrl* spinner1 = getChild<LLSpinCtrl>("val_spinner_1");
    LLSpinCtrl* spinner2 = getChild<LLSpinCtrl>("val_spinner_2");
    LLSpinCtrl* spinner3 = getChild<LLSpinCtrl>("val_spinner_3");
    LLSpinCtrl* spinner4 = getChild<LLSpinCtrl>("val_spinner_4");
    LLColorSwatchCtrl* color_swatch = getChild<LLColorSwatchCtrl>("val_color_swatch");
    LLUICtrl* bool_ctrl = getChild<LLUICtrl>("boolean_combo");

    if (!spinner1 || !spinner2 || !spinner3 || !spinner4 || !color_swatch)
    {
        llwarns << "Could not find all desired controls by name"
                << llendl;
        return;
    }

    spinner1->setVisible(FALSE);
    spinner2->setVisible(FALSE);
    spinner3->setVisible(FALSE);
    spinner4->setVisible(FALSE);
    color_swatch->setVisible(FALSE);
    getChildView("val_text")->setVisible( FALSE);
    mComment->setText(LLStringUtil::null);
    childSetEnabled("copy_btn", false);
    childSetEnabled("default_btn", false);
    bool_ctrl->setVisible(false);

    if (mCurrentControlVariable)
    {
// [RLVa:KB] - Checked: 2011-05-28 (RLVa-1.4.0a) | Modified: RLVa-1.4.0a
        // If "HideFromEditor" was toggled while the floater is open then we need to manually disable access to the control
        mOldVisibility = mCurrentControlVariable->isHiddenFromSettingsEditor();
        spinner1->setEnabled(!mOldVisibility);
        spinner2->setEnabled(!mOldVisibility);
        spinner3->setEnabled(!mOldVisibility);
        spinner4->setEnabled(!mOldVisibility);
        color_swatch->setEnabled(!mOldVisibility);
        childSetEnabled("val_text", !mOldVisibility);
        bool_ctrl->setEnabled(!mOldVisibility);
        childSetEnabled("default_btn", !mOldVisibility);
// [/RLVa:KB]

        childSetEnabled("copy_btn", true);

        eControlType type = mCurrentControlVariable->type();

        mComment->setText(mCurrentControlVariable->getName() + std::string(": ") + mCurrentControlVariable->getComment());

        spinner1->setMaxValue(F32_MAX);
        spinner2->setMaxValue(F32_MAX);
        spinner3->setMaxValue(F32_MAX);
        spinner4->setMaxValue(F32_MAX);
        spinner1->setMinValue(-F32_MAX);
        spinner2->setMinValue(-F32_MAX);
        spinner3->setMinValue(-F32_MAX);
        spinner4->setMinValue(-F32_MAX);
        if (!spinner1->hasFocus())
        {
            spinner1->setIncrement(0.1f);
        }
        if (!spinner2->hasFocus())
        {
            spinner2->setIncrement(0.1f);
        }
        if (!spinner3->hasFocus())
        {
            spinner3->setIncrement(0.1f);
        }
        if (!spinner4->hasFocus())
        {
            spinner4->setIncrement(0.1f);
        }

        LLSD sd = mCurrentControlVariable->get();
        switch(type)
        {
        case TYPE_U32:
            spinner1->setVisible(TRUE);
            spinner1->setLabel(std::string("value")); // Debug, don't translate
            if (!spinner1->hasFocus())
            {
                spinner1->setValue(sd);
                spinner1->setMinValue((F32)U32_MIN);
                spinner1->setMaxValue((F32)U32_MAX);
                spinner1->setIncrement(1.f);
                spinner1->setPrecision(0);
            }
            break;
        case TYPE_S32:
            spinner1->setVisible(TRUE);
            spinner1->setLabel(std::string("value")); // Debug, don't translate
            if (!spinner1->hasFocus())
            {
                spinner1->setValue(sd);
                spinner1->setMinValue((F32)S32_MIN);
                spinner1->setMaxValue((F32)S32_MAX);
                spinner1->setIncrement(1.f);
                spinner1->setPrecision(0);
            }
            break;
        case TYPE_F32:
            spinner1->setVisible(TRUE);
            spinner1->setLabel(std::string("value")); // Debug, don't translate
            if (!spinner1->hasFocus())
            {
                spinner1->setPrecision(3);
                spinner1->setValue(sd);
            }
            break;
        case TYPE_BOOLEAN:
            bool_ctrl->setVisible(true);
            if (!bool_ctrl->hasFocus())
            {
                if (sd.asBoolean())
                {
                    bool_ctrl->setValue(LLSD("TRUE"));
                }
                else
                {
                    bool_ctrl->setValue(LLSD("FALSE"));
                }
            }
            break;
        case TYPE_STRING:
            getChildView("val_text")->setVisible( TRUE);
            if (!getChild<LLUICtrl>("val_text")->hasFocus())
            {
                getChild<LLUICtrl>("val_text")->setValue(sd);
            }
            break;
        case TYPE_VEC3:
        {
            LLVector3 v;
            v.setValue(sd);
            spinner1->setVisible(TRUE);
            spinner1->setLabel(std::string("X"));
            spinner2->setVisible(TRUE);
            spinner2->setLabel(std::string("Y"));
            spinner3->setVisible(TRUE);
            spinner3->setLabel(std::string("Z"));
            if (!spinner1->hasFocus())
            {
                spinner1->setPrecision(3);
                spinner1->setValue(v[VX]);
            }
            if (!spinner2->hasFocus())
            {
                spinner2->setPrecision(3);
                spinner2->setValue(v[VY]);
            }
            if (!spinner3->hasFocus())
            {
                spinner3->setPrecision(3);
                spinner3->setValue(v[VZ]);
            }
            break;
        }
        case TYPE_VEC3D:
        {
            LLVector3d v;
            v.setValue(sd);
            spinner1->setVisible(TRUE);
            spinner1->setLabel(std::string("X"));
            spinner2->setVisible(TRUE);
            spinner2->setLabel(std::string("Y"));
            spinner3->setVisible(TRUE);
            spinner3->setLabel(std::string("Z"));
            if (!spinner1->hasFocus())
            {
                spinner1->setPrecision(3);
                spinner1->setValue(v[VX]);
            }
            if (!spinner2->hasFocus())
            {
                spinner2->setPrecision(3);
                spinner2->setValue(v[VY]);
            }
            if (!spinner3->hasFocus())
            {
                spinner3->setPrecision(3);
                spinner3->setValue(v[VZ]);
            }
            break;
        }
        case TYPE_RECT:
        {
            LLRect r;
            r.setValue(sd);
            spinner1->setVisible(TRUE);
            spinner1->setLabel(std::string("Left"));
            spinner2->setVisible(TRUE);
            spinner2->setLabel(std::string("Right"));
            spinner3->setVisible(TRUE);
            spinner3->setLabel(std::string("Bottom"));
            spinner4->setVisible(TRUE);
            spinner4->setLabel(std::string("Top"));
            if (!spinner1->hasFocus())
            {
                spinner1->setPrecision(0);
                spinner1->setValue(r.mLeft);
            }
            if (!spinner2->hasFocus())
            {
                spinner2->setPrecision(0);
                spinner2->setValue(r.mRight);
            }
            if (!spinner3->hasFocus())
            {
                spinner3->setPrecision(0);
                spinner3->setValue(r.mBottom);
            }
            if (!spinner4->hasFocus())
            {
                spinner4->setPrecision(0);
                spinner4->setValue(r.mTop);
            }

            spinner1->setMinValue((F32)S32_MIN);
            spinner1->setMaxValue((F32)S32_MAX);
            spinner1->setIncrement(1.f);

            spinner2->setMinValue((F32)S32_MIN);
            spinner2->setMaxValue((F32)S32_MAX);
            spinner2->setIncrement(1.f);

            spinner3->setMinValue((F32)S32_MIN);
            spinner3->setMaxValue((F32)S32_MAX);
            spinner3->setIncrement(1.f);

            spinner4->setMinValue((F32)S32_MIN);
            spinner4->setMaxValue((F32)S32_MAX);
            spinner4->setIncrement(1.f);
            break;
        }
        case TYPE_COL4:
        {
            LLColor4 clr;
            clr.setValue(sd);
            color_swatch->setVisible(TRUE);
            // only set if changed so color picker doesn't update
            if(clr != LLColor4(color_swatch->getValue()))
            {
                color_swatch->set(LLColor4(sd), TRUE, FALSE);
            }
            spinner4->setVisible(TRUE);
            spinner4->setLabel(std::string("Alpha"));
            if (!spinner4->hasFocus())
            {
                spinner4->setPrecision(3);
                spinner4->setMinValue(0.0);
                spinner4->setMaxValue(1.f);
                spinner4->setValue(clr.mV[VALPHA]);
            }
            break;
        }
        case TYPE_COL3:
        {
            LLColor3 clr;
            clr.setValue(sd);
            color_swatch->setVisible(TRUE);
            color_swatch->setValue(sd);
            break;
        }
        case TYPE_COL4U:
        {
            LLColor4U clr;
            clr.setValue(sd);
            color_swatch->setVisible(TRUE);
            if(LLColor4(clr) != LLColor4(color_swatch->getValue()))
            {
                color_swatch->set(LLColor4(clr), TRUE, FALSE);
            }
            spinner4->setVisible(TRUE);
            spinner4->setLabel(std::string("Alpha"));
            if(!spinner4->hasFocus())
            {
                spinner4->setPrecision(0);
                spinner4->setValue(clr.mV[VALPHA]);
            }

            spinner4->setMinValue(0);
            spinner4->setMaxValue(255);
            spinner4->setIncrement(1.f);

            break;
        }
        default:
            mComment->setText(std::string("unknown"));
            break;
        }
    }

}
void LLFloaterSettingsDebug::onCommitSettings()
{
	LLComboBox* settings_combo = getChild<LLComboBox>("settings_combo");
	LLControlVariable* controlp = (LLControlVariable*)settings_combo->getCurrentUserdata();

	if (!controlp)
	{
		return;
	}

	LLVector3 vector;
	LLVector3d vectord;
	LLRect rect;
	LLColor4 col4;
	LLColor3 col3;
	LLColor4U col4U;
	LLColor4 color_with_alpha;

	switch(controlp->type())
	{		
	  case TYPE_U32:
		controlp->set(getChild<LLUICtrl>("val_spinner_1")->getValue());
		break;
	  case TYPE_S32:
		controlp->set(getChild<LLUICtrl>("val_spinner_1")->getValue());
		break;
	  case TYPE_F32:
		controlp->set(LLSD(getChild<LLUICtrl>("val_spinner_1")->getValue().asReal()));
		break;
	  case TYPE_BOOLEAN:
		controlp->set(getChild<LLUICtrl>("boolean_combo")->getValue());
		break;
	  case TYPE_STRING:
		controlp->set(LLSD(getChild<LLUICtrl>("val_text")->getValue().asString()));
		break;
	  case TYPE_VEC3:
		vector.mV[VX] = (F32)getChild<LLUICtrl>("val_spinner_1")->getValue().asReal();
		vector.mV[VY] = (F32)getChild<LLUICtrl>("val_spinner_2")->getValue().asReal();
		vector.mV[VZ] = (F32)getChild<LLUICtrl>("val_spinner_3")->getValue().asReal();
		controlp->set(vector.getValue());
		break;
	  case TYPE_VEC3D:
		vectord.mdV[VX] = getChild<LLUICtrl>("val_spinner_1")->getValue().asReal();
		vectord.mdV[VY] = getChild<LLUICtrl>("val_spinner_2")->getValue().asReal();
		vectord.mdV[VZ] = getChild<LLUICtrl>("val_spinner_3")->getValue().asReal();
		controlp->set(vectord.getValue());
		break;
	  case TYPE_RECT:
		rect.mLeft = getChild<LLUICtrl>("val_spinner_1")->getValue().asInteger();
		rect.mRight = getChild<LLUICtrl>("val_spinner_2")->getValue().asInteger();
		rect.mBottom = getChild<LLUICtrl>("val_spinner_3")->getValue().asInteger();
		rect.mTop = getChild<LLUICtrl>("val_spinner_4")->getValue().asInteger();
		controlp->set(rect.getValue());
		break;
	  case TYPE_COL4:
		col3.setValue(getChild<LLUICtrl>("val_color_swatch")->getValue());
		col4 = LLColor4(col3, (F32)getChild<LLUICtrl>("val_spinner_4")->getValue().asReal());
		controlp->set(col4.getValue());
		break;
	  case TYPE_COL3:
		controlp->set(getChild<LLUICtrl>("val_color_swatch")->getValue());
		//col3.mV[VRED] = (F32)floaterp->getChild<LLUICtrl>("val_spinner_1")->getValue().asC();
		//col3.mV[VGREEN] = (F32)floaterp->getChild<LLUICtrl>("val_spinner_2")->getValue().asReal();
		//col3.mV[VBLUE] = (F32)floaterp->getChild<LLUICtrl>("val_spinner_3")->getValue().asReal();
		//controlp->set(col3.getValue());
		break;
	  default:
		break;
	}
}
// This function selects an ideal viewing distance based on the focused object, pick normal, and padding value
void LLViewerMediaFocus::setCameraZoom(LLViewerObject* object, LLVector3 normal, F32 padding_factor, bool zoom_in_only)
{
    if (object)
    {
        gAgentCamera.setFocusOnAvatar(FALSE, ANIMATE);

        LLBBox bbox = object->getBoundingBoxAgent();
        LLVector3d center = gAgent.getPosGlobalFromAgent(bbox.getCenterAgent());
        F32 height;
        F32 width;
        F32 depth;
        F32 angle_of_view;
        F32 distance;

        // We need the aspect ratio, and the 3 components of the bbox as height, width, and depth.
        F32 aspect_ratio = getBBoxAspectRatio(bbox, normal, &height, &width, &depth);
        F32 camera_aspect = LLViewerCamera::getInstance()->getAspect();

        lldebugs << "normal = " << normal << ", aspect_ratio = " << aspect_ratio << ", camera_aspect = " << camera_aspect << llendl;

        // We will normally use the side of the volume aligned with the short side of the screen (i.e. the height for
        // a screen in a landscape aspect ratio), however there is an edge case where the aspect ratio of the object is
        // more extreme than the screen.  In this case we invert the logic, using the longer component of both the object
        // and the screen.
        bool invert = (camera_aspect > 1.0f && aspect_ratio > camera_aspect) ||
                      (camera_aspect < 1.0f && aspect_ratio < camera_aspect);

        // To calculate the optimum viewing distance we will need the angle of the shorter side of the view rectangle.
        // In portrait mode this is the width, and in landscape it is the height.
        // We then calculate the distance based on the corresponding side of the object bbox (width for portrait, height for landscape)
        // We will add half the depth of the bounding box, as the distance projection uses the center point of the bbox.
        if(camera_aspect < 1.0f || invert)
        {
            angle_of_view = llmax(0.1f, LLViewerCamera::getInstance()->getView() * LLViewerCamera::getInstance()->getAspect());
            distance = width * 0.5 * padding_factor / tan(angle_of_view * 0.5f );

            lldebugs << "using width (" << width << "), angle_of_view = " << angle_of_view << ", distance = " << distance << llendl;
        }
        else
        {
            angle_of_view = llmax(0.1f, LLViewerCamera::getInstance()->getView());
            distance = height * 0.5 * padding_factor / tan(angle_of_view * 0.5f );

            lldebugs << "using height (" << height << "), angle_of_view = " << angle_of_view << ", distance = " << distance << llendl;
        }

        distance += depth * 0.5;

        // Finally animate the camera to this new position and focal point
        LLVector3d camera_pos, target_pos;
        // The target lookat position is the center of the selection (in global coords)
        target_pos = center;
        // Target look-from (camera) position is "distance" away from the target along the normal
        LLVector3d pickNormal = LLVector3d(normal);
        pickNormal.normalize();
        camera_pos = target_pos + pickNormal * distance;
        if (pickNormal == LLVector3d::z_axis || pickNormal == LLVector3d::z_axis_neg)
        {
            // If the normal points directly up, the camera will "flip" around.
            // We try to avoid this by adjusting the target camera position a
            // smidge towards current camera position
            // *NOTE: this solution is not perfect.  All it attempts to solve is the
            // "looking down" problem where the camera flips around when it animates
            // to that position.  You still are not guaranteed to be looking at the
            // media in the correct orientation.  What this solution does is it will
            // put the camera into position keeping as best it can the current
            // orientation with respect to the face.  In other words, if before zoom
            // the media appears "upside down" from the camera, after zooming it will
            // still be upside down, but at least it will not flip.
            LLVector3d cur_camera_pos = LLVector3d(gAgentCamera.getCameraPositionGlobal());
            LLVector3d delta = (cur_camera_pos - camera_pos);
            F64 len = delta.length();
            delta.normalize();
            // Move 1% of the distance towards original camera location
            camera_pos += 0.01 * len * delta;
        }

        // If we are not allowing zooming out and the old camera position is closer to
        // the center then the new intended camera position, don't move camera and return
        if (zoom_in_only &&
                (dist_vec_squared(gAgentCamera.getCameraPositionGlobal(), target_pos) < dist_vec_squared(camera_pos, target_pos)))
        {
            return;
        }

        gAgentCamera.setCameraPosAndFocusGlobal(camera_pos, target_pos, object->getID() );

    }
    else
    {
        // If we have no object, focus back on the avatar.
        gAgentCamera.setFocusOnAvatar(TRUE, ANIMATE);
    }
}
// we've switched controls, or doing per-frame update, so update spinners, etc.
void LLFloaterSettingsDebug::updateControl(LLControlVariable* controlp)
{
	LLSpinCtrl* spinner1 = getChild<LLSpinCtrl>("val_spinner_1");
	LLSpinCtrl* spinner2 = getChild<LLSpinCtrl>("val_spinner_2");
	LLSpinCtrl* spinner3 = getChild<LLSpinCtrl>("val_spinner_3");
	LLSpinCtrl* spinner4 = getChild<LLSpinCtrl>("val_spinner_4");
	LLColorSwatchCtrl* color_swatch = getChild<LLColorSwatchCtrl>("val_color_swatch");

	if (!spinner1 || !spinner2 || !spinner3 || !spinner4 || !color_swatch)
	{
		llwarns << "Could not find all desired controls by name"
			<< llendl;
		return;
	}

	spinner1->setVisible(FALSE);
	spinner2->setVisible(FALSE);
	spinner3->setVisible(FALSE);
	spinner4->setVisible(FALSE);
	color_swatch->setVisible(FALSE);
	getChildView("val_text")->setVisible( FALSE);
	mComment->setText(LLStringUtil::null);

	if (controlp)
	{
// [RLVa:KB] - Checked: 2011-05-28 (RLVa-1.4.0a) | Modified: RLVa-1.4.0a
		// If "HideFromEditor" was toggled while the floater is open then we need to manually disable access to the control
		// NOTE: this runs per-frame so there's no need to explictly handle onCommitSettings() or onClickDefault()
		bool fEnable = !controlp->isHiddenFromSettingsEditor();
		spinner1->setEnabled(fEnable);
		spinner2->setEnabled(fEnable);
		spinner3->setEnabled(fEnable);
		spinner4->setEnabled(fEnable);
		color_swatch->setEnabled(fEnable);
		childSetEnabled("val_text", fEnable);
		childSetEnabled("boolean_combo", fEnable);
		childSetEnabled("default_btn", fEnable);
// [/RLVa:KB]

		eControlType type = controlp->type();

		//hide combo box only for non booleans, otherwise this will result in the combo box closing every frame
		getChildView("boolean_combo")->setVisible( type == TYPE_BOOLEAN);
		

		mComment->setText(controlp->getComment());
		spinner1->setMaxValue(F32_MAX);
		spinner2->setMaxValue(F32_MAX);
		spinner3->setMaxValue(F32_MAX);
		spinner4->setMaxValue(F32_MAX);
		spinner1->setMinValue(-F32_MAX);
		spinner2->setMinValue(-F32_MAX);
		spinner3->setMinValue(-F32_MAX);
		spinner4->setMinValue(-F32_MAX);
		if (!spinner1->hasFocus())
		{
			spinner1->setIncrement(0.1f);
		}
		if (!spinner2->hasFocus())
		{
			spinner2->setIncrement(0.1f);
		}
		if (!spinner3->hasFocus())
		{
			spinner3->setIncrement(0.1f);
		}
		if (!spinner4->hasFocus())
		{
			spinner4->setIncrement(0.1f);
		}

		LLSD sd = controlp->get();
		switch(type)
		{
		  case TYPE_U32:
			spinner1->setVisible(TRUE);
			spinner1->setLabel(std::string("value")); // Debug, don't translate
			if (!spinner1->hasFocus())
			{
				spinner1->setValue(sd);
				spinner1->setMinValue((F32)U32_MIN);
				spinner1->setMaxValue((F32)U32_MAX);
				spinner1->setIncrement(1.f);
				spinner1->setPrecision(0);
			}
			break;
		  case TYPE_S32:
			spinner1->setVisible(TRUE);
			spinner1->setLabel(std::string("value")); // Debug, don't translate
			if (!spinner1->hasFocus())
			{
				spinner1->setValue(sd);
				spinner1->setMinValue((F32)S32_MIN);
				spinner1->setMaxValue((F32)S32_MAX);
				spinner1->setIncrement(1.f);
				spinner1->setPrecision(0);
			}
			break;
		  case TYPE_F32:
			spinner1->setVisible(TRUE);
			spinner1->setLabel(std::string("value")); // Debug, don't translate
			if (!spinner1->hasFocus())
			{
				spinner1->setPrecision(3);
				spinner1->setValue(sd);
			}
			break;
		  case TYPE_BOOLEAN:
			if (!getChild<LLUICtrl>("boolean_combo")->hasFocus())
			{
				if (sd.asBoolean())
				{
					getChild<LLUICtrl>("boolean_combo")->setValue(LLSD("true"));
				}
				else
				{
					getChild<LLUICtrl>("boolean_combo")->setValue(LLSD(""));
				}
			}
			break;
		  case TYPE_STRING:
			getChildView("val_text")->setVisible( TRUE);
			if (!getChild<LLUICtrl>("val_text")->hasFocus())
			{
				getChild<LLUICtrl>("val_text")->setValue(sd);
			}
			break;
		  case TYPE_VEC3:
		  {
			LLVector3 v;
			v.setValue(sd);
			spinner1->setVisible(TRUE);
			spinner1->setLabel(std::string("X"));
			spinner2->setVisible(TRUE);
			spinner2->setLabel(std::string("Y"));
			spinner3->setVisible(TRUE);
			spinner3->setLabel(std::string("Z"));
			if (!spinner1->hasFocus())
			{
				spinner1->setPrecision(3);
				spinner1->setValue(v[VX]);
			}
			if (!spinner2->hasFocus())
			{
				spinner2->setPrecision(3);
				spinner2->setValue(v[VY]);
			}
			if (!spinner3->hasFocus())
			{
				spinner3->setPrecision(3);
				spinner3->setValue(v[VZ]);
			}
			break;
		  }
		  case TYPE_VEC3D:
		  {
			LLVector3d v;
			v.setValue(sd);
			spinner1->setVisible(TRUE);
			spinner1->setLabel(std::string("X"));
			spinner2->setVisible(TRUE);
			spinner2->setLabel(std::string("Y"));
			spinner3->setVisible(TRUE);
			spinner3->setLabel(std::string("Z"));
			if (!spinner1->hasFocus())
			{
				spinner1->setPrecision(3);
				spinner1->setValue(v[VX]);
			}
			if (!spinner2->hasFocus())
			{
				spinner2->setPrecision(3);
				spinner2->setValue(v[VY]);
			}
			if (!spinner3->hasFocus())
			{
				spinner3->setPrecision(3);
				spinner3->setValue(v[VZ]);
			}
			break;
		  }
		  case TYPE_RECT:
		  {
			LLRect r;
			r.setValue(sd);
			spinner1->setVisible(TRUE);
			spinner1->setLabel(std::string("Left"));
			spinner2->setVisible(TRUE);
			spinner2->setLabel(std::string("Right"));
			spinner3->setVisible(TRUE);
			spinner3->setLabel(std::string("Bottom"));
			spinner4->setVisible(TRUE);
			spinner4->setLabel(std::string("Top"));
			if (!spinner1->hasFocus())
			{
				spinner1->setPrecision(0);
				spinner1->setValue(r.mLeft);
			}
			if (!spinner2->hasFocus())
			{
				spinner2->setPrecision(0);
				spinner2->setValue(r.mRight);
			}
			if (!spinner3->hasFocus())
			{
				spinner3->setPrecision(0);
				spinner3->setValue(r.mBottom);
			}
			if (!spinner4->hasFocus())
			{
				spinner4->setPrecision(0);
				spinner4->setValue(r.mTop);
			}

			spinner1->setMinValue((F32)S32_MIN);
			spinner1->setMaxValue((F32)S32_MAX);
			spinner1->setIncrement(1.f);

			spinner2->setMinValue((F32)S32_MIN);
			spinner2->setMaxValue((F32)S32_MAX);
			spinner2->setIncrement(1.f);

			spinner3->setMinValue((F32)S32_MIN);
			spinner3->setMaxValue((F32)S32_MAX);
			spinner3->setIncrement(1.f);

			spinner4->setMinValue((F32)S32_MIN);
			spinner4->setMaxValue((F32)S32_MAX);
			spinner4->setIncrement(1.f);
			break;
		  }
		  case TYPE_COL4:
		  {
			LLColor4 clr;
			clr.setValue(sd);
			color_swatch->setVisible(TRUE);
			// only set if changed so color picker doesn't update
			if(clr != LLColor4(color_swatch->getValue()))
			{
				color_swatch->set(LLColor4(sd), TRUE, FALSE);
			}
			spinner4->setVisible(TRUE);
			spinner4->setLabel(std::string("Alpha"));
			if (!spinner4->hasFocus())
			{
				spinner4->setPrecision(3);
				spinner4->setMinValue(0.0);
				spinner4->setMaxValue(1.f);
				spinner4->setValue(clr.mV[VALPHA]);
			}
			break;
		  }
		  case TYPE_COL3:
		  {
			LLColor3 clr;
			clr.setValue(sd);
			color_swatch->setVisible(TRUE);
			color_swatch->setValue(sd);
			break;
		  }
		  default:
			mComment->setText(std::string("unknown"));
			break;
		}
	}

}
Пример #18
0
BOOL LLNetMap::handleToolTip( S32 x, S32 y, std::string& msg, LLRect* sticky_rect_screen )
{
	BOOL handled = FALSE;
	if (gDisconnected)
	{
		return FALSE;
	}
	LLViewerRegion*	region = LLWorld::getInstance()->getRegionFromPosGlobal( viewPosToGlobal( x, y , gSavedSettings.getBOOL( "MiniMapRotate" )) );
	if( region )
	{
		msg.assign("");
		std::string fullname;
		if(mClosestAgentToCursor.notNull() && gCacheName->getFullName(mClosestAgentToCursor, fullname))
		{
//			msg.append(fullname);
// [RLVa:KB] - Version: 1.23.4 | Checked: 2009-07-08 (RLVa-1.0.0e) | Modified: RLVa-0.2.0b
            // [Ansariel/Henri: Display name support]
			// msg.append( (!gRlvHandler.hasBehaviour(RLV_BHVR_SHOWNAMES)) ? fullname : RlvStrings::getAnonym(fullname) );
            if (gRlvHandler.hasBehaviour(RLV_BHVR_SHOWNAMES))
            {
                msg.append(RlvStrings::getAnonym(fullname));
            }
            else
            {
			    if (LLAvatarNameCache::useDisplayNames())
				{
    				LLAvatarName avatar_name;
	    			if (LLAvatarNameCache::get(mClosestAgentToCursor, &avatar_name))
		    		{
						static LLCachedControl<S32> sPhoenixNameSystem(gSavedSettings, "PhoenixNameSystem");
						if (sPhoenixNameSystem == 2 || (sPhoenixNameSystem == 1 && avatar_name.mIsDisplayNameDefault))
				    	{
					    	fullname = avatar_name.mDisplayName;
						}
    					else
	    				{
		    				fullname = avatar_name.getCompleteName(true);
			    		}
				    }
				}
                msg.append(fullname);
            }
            // [/Ansariel/Henri: Display name support]
// [/RLVa:KB]
			msg.append("\n");

			LLVector3d mypos = gAgent.getPositionGlobal();
			LLVector3d position = mClosestAgentPosition;
			bool isHigher1020mBug = (position.mdV[VZ] == 0.0);

			if ( LLFloaterAvatarList::getInstance() )
			{
				LLAvatarListEntry *ent = LLFloaterAvatarList::getInstance()->getAvatarEntry(mClosestAgentToCursor);
				if ( NULL != ent )
				{
					//position = LLFloaterAvatarList::AvatarPosition(mClosestAgentToCursor);
					position = ent->getPosition();

					// If avatar is >1020m and no viewer object exists,
					// it is beyond far clip, so the distance value is wrong!
					isHigher1020mBug = (isHigher1020mBug && gObjectList.findObject(mClosestAgentToCursor) == NULL);
				}
			}

			F32 distance;
			static LLCachedControl<F32> farClip(gSavedSettings, "RenderFarClip");
			if (!isHigher1020mBug)
			{
				LLVector3d delta = position - mypos;
				distance = (F32)delta.magVec();
				msg.append( llformat("\n(Distance: %.02fm)\n\n",distance) );
			}
			else
			{
				distance = F32(farClip);
				msg.append( llformat("\n(Distance: > %.02fm)\n\n",distance) );
			}
		}
//		msg.append( region->getName() );
// [RLVa:KB] - Version: 1.23.4 | Checked: 2009-07-04 (RLVa-1.0.0a) | Modified: RLVa-0.2.0b
		msg.append( (!gRlvHandler.hasBehaviour(RLV_BHVR_SHOWLOC)) ? region->getName() : RlvStrings::getString(RLV_STRING_HIDDEN) );
// [/RLVa:KB]
//		msg.append( region->getName() );

#ifndef LL_RELEASE_FOR_DOWNLOAD
		std::string buffer;
		msg.append("\n");
		buffer = region->getHost().getHostName();
		msg.append(buffer);
		msg.append("\n");
		buffer = region->getHost().getString();
		msg.append(buffer);
#endif
		msg.append("\n");
		msg.append(getToolTip());

		S32 SLOP = 4;
		localPointToScreen( 
			x - SLOP, y - SLOP, 
			&(sticky_rect_screen->mLeft), &(sticky_rect_screen->mBottom) );
		sticky_rect_screen->mRight = sticky_rect_screen->mLeft + 2 * SLOP;
		sticky_rect_screen->mTop = sticky_rect_screen->mBottom + 2 * SLOP;
		handled = TRUE;
	}
	if(!handled)
	{
		return LLPanel::handleToolTip(x, y, msg, sticky_rect_screen);
	}
	return handled;
}