void LLPanelPreference::setControlFalse(const LLSD& user_data)
{
	std::string control_name = user_data.asString();
	LLControlVariable* control = findControl(control_name);
	
	if (control)
		control->set(LLSD(FALSE));
}
void LLControlGroup::setString(const std::string& name, const std::string &val)
{
	LLControlVariable* control = getControl(name);
	
	if (control && control->isType(TYPE_STRING))
	{
		control->set(val);
	}
	else
	{
		CONTROL_ERRS << "Invalid 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());
	}
	else
	{
		CONTROL_ERRS << "Invalid LLColor4 control " << name << llendl;
	}
}
void LLControlGroup::setU32(const std::string& name, U32 val)
{
	LLControlVariable* control = getControl(name);
	
	if (control && control->isType(TYPE_U32))
	{
		control->set((LLSD::Integer) val);
	}
	else
	{
		CONTROL_ERRS << "Invalid control " << name << llendl;
	}
}
Example #5
0
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;
	}
}
Example #6
0
void LLControlGroup::setRect(const std::string& name, const LLRect &val)
{
	LLControlVariable* control = getControl(name);

	if (control && control->isType(TYPE_RECT))
	{
		control->set(val.getValue());
		if(mChangeCallback)
			mChangeCallback(name,llformat("[%f,%f,%f,%f]",val.mBottom,val.mLeft,val.mRight,val.mTop));
	}
	else
	{
		CONTROL_ERRS << "Invalid rect control " << name << llendl;
	}
}
Example #7
0
void LLControlGroup::setF32(const std::string& name, F32 val)
{
	LLControlVariable* control = getControl(name);
	
	if (control && control->isType(TYPE_F32))
	{
		control->set(val);
		if(mChangeCallback)
			mChangeCallback(name,llformat("%f",val));
	}
	else
	{
		CONTROL_ERRS << "Invalid control " << name << llendl;
	}
}
Example #8
0
void LLControlGroup::setBOOL(const std::string& name, BOOL val)
{
	LLControlVariable* control = getControl(name);
	
	if (control && control->isType(TYPE_BOOLEAN))
	{
		control->set(val);
		if(mChangeCallback)
			mChangeCallback(name,(val) ? "1" : "0");
	}
	else
	{
		CONTROL_ERRS << "Invalid control " << name << llendl;
	}
}
void LLControlGroup::setValue(const std::string& name, const LLSD& val)
{
	if (name.empty())
	{
		return;
	}

	LLControlVariable* control = getControl(name);
	
	if (control)
	{
		control->set(val);
	}
	else
	{
		CONTROL_ERRS << "Invalid control " << name << llendl;
	}
}
void LLPanelPreference::cancel()
{
	for (control_values_map_t::iterator iter =  mSavedValues.begin();
		 iter !=  mSavedValues.end(); ++iter)
	{
		LLControlVariable* control = iter->first;
		LLSD ctrl_value = iter->second;
		control->set(ctrl_value);
	}

	for (string_color_map_t::iterator iter = mSavedColors.begin();
		 iter != mSavedColors.end(); ++iter)
	{
		LLColorSwatchCtrl* color_swatch = findChild<LLColorSwatchCtrl>(iter->first);
		if(color_swatch)
		{
			color_swatch->set(iter->second);
			color_swatch->onCommit();
		}
	}
}
//static
void LLViewerControlListener::toggleControl(LLControlGroup * controls, LLSD const & event_data)
{
	if(event_data.has("key"))
	{
		std::string key(event_data["key"]);

		if(controls->controlExists(key))
		{
			LLControlVariable * control = controls->getControl(key);
			if(control->isType(TYPE_BOOLEAN))
			{
				control->set(!control->get().asBoolean());
			}
			else
			{
				llwarns << "requested toggle of non-boolean control: \"" << key << "\", type is " << control->type() << llendl;
			}
		}
		else
		{
			llwarns << "requested unknown control: \"" << key << '\"' << llendl;
		}
	}
}
//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();

	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;
	}
}
Example #13
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;
}
void wlfPanel_AdvSettings::onClickExpandBtn()
{
	LLControlVariable* ctrl = gSavedSettings.getControl("wlfAdvSettingsPopup");
	ctrl->set(!ctrl->get());
}
static void toggle_time_value()
{
	LLControlVariable* control = gSavedSettings.getControl("LiruLocalTime");
	control->set(!control->get());
}