Beispiel #1
0
std::string LLControlGroup::findString(const std::string& name)
{
    LLControlVariable* control = getControl(name);

    if (control && control->isType(TYPE_STRING))
        return control->get().asString();
    return LLStringUtil::null;
}
LLSD LLControlGroup::getLLSD(const std::string& name)
{
	LLControlVariable* control = getControl(name);
	
	if (control && control->isType(TYPE_LLSD))
		return control->getValue();
	CONTROL_ERRS << "Invalid LLSD control " << name << llendl;
	return LLSD();
}
LLColor3 LLControlGroup::getColor3(const std::string& name)
{
	LLControlVariable* control = getControl(name);
	
	if (control && control->isType(TYPE_COL3))
		return control->get();
	else
	{
		CONTROL_ERRS << "Invalid LLColor3 control " << name << llendl;
		return LLColor3::white;
	}
}
LLVector3d LLControlGroup::getVector3d(const std::string& name)
{
	LLControlVariable* control = getControl(name);
	
	if (control && control->isType(TYPE_VEC3D))
		return control->get();
	else
	{
		CONTROL_ERRS << "Invalid LLVector3d control " << name << llendl;
		return LLVector3d::zero;
	}
}
std::string LLControlGroup::getString(const std::string& name)
{
	LLControlVariable* control = getControl(name);
	
	if (control && control->isType(TYPE_STRING))
		return control->get().asString();
	else
	{
		CONTROL_ERRS << "Invalid string control " << name << llendl;
		return LLStringUtil::null;
	}
}
F32 LLControlGroup::getF32(const std::string& name)
{
	LLControlVariable* control = getControl(name);
	
	if (control && control->isType(TYPE_F32))
		return (F32) control->get().asReal();
	else
	{
		CONTROL_ERRS << "Invalid F32 control " << name << llendl;
		return 0.0f;
	}
}
U32 LLControlGroup::getU32(const std::string& name)
{
	LLControlVariable* control = getControl(name);
	
	if (control && control->isType(TYPE_U32))		
		return control->get().asInteger();
	else
	{
		CONTROL_ERRS << "Invalid U32 control " << name << llendl;
		return 0;
	}
}
BOOL LLControlGroup::getBOOL(const std::string& name)
{
	LLControlVariable* control = getControl(name);
	
	if (control && control->isType(TYPE_BOOLEAN))
		return control->get().asBoolean();
	else
	{
		CONTROL_ERRS << "Invalid BOOL control " << name << llendl;
		return FALSE;
	}
}
LLRect LLControlGroup::getRect(const std::string& name)
{
	LLControlVariable* control = getControl(name);
	
	if (control && control->isType(TYPE_RECT))
		return control->get();
	else
	{
		CONTROL_ERRS << "Invalid rect control " << name << llendl;
		return LLRect::null;
	}
}
void LLControlGroup::setLLSD(const std::string& name, const LLSD& val)
{
	LLControlVariable* control = getControl(name);
	
	if (control && control->isType(TYPE_LLSD))
	{
		setValue(name, val);
	}
	else
	{
		CONTROL_ERRS << "Invalid LLSD 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::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::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;
	}
}
Beispiel #14
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;
	}
}
Beispiel #15
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;
	}
}
Beispiel #16
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;
	}
}
Beispiel #17
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;
	}
}
//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;
		}
	}
}
//----------------------------------------------------------------------------
// LLControlGroupCLP defintions
//----------------------------------------------------------------------------
void setControlValueCB(const LLCommandLineParser::token_vector_t& value,
                       const std::string& opt_name,
                       LLControlGroup* ctrlGroup)
{
    // *FIX: Do sematic conversion here.
    // LLSD (ImplString) Is no good for doing string to type conversion for...
    // booleans
    // compound types
    // ?...

    LLControlVariable* ctrl = ctrlGroup->getControl(opt_name);
    if(NULL != ctrl)
    {
        switch(ctrl->type())
        {
        case TYPE_BOOLEAN:
            if(value.size() > 1)
            {
                llwarns << "Ignoring extra tokens." << llendl;
            }

            if(value.size() > 0)
            {
                // There's a token. check the string for true/false/1/0 etc.
                BOOL result = false;
                BOOL gotSet = LLStringUtil::convertToBOOL(value[0], result);
                if(gotSet)
                {
                    ctrl->setValue(LLSD(result), false);
                }
            }
            else
            {
                ctrl->setValue(LLSD(true), false);
            }
            break;

        default:
        {
            // For the default types, let llsd do the conversion.
            if(value.size() > 1 && ctrl->isType(TYPE_LLSD))
            {
                // Assume its an array...
                LLSD llsdArray;
                for(unsigned int i = 0; i < value.size(); ++i)
                {
                    LLSD llsdValue;
                    llsdValue.assign(LLSD::String(value[i]));
                    llsdArray.set(i, llsdValue);
                }

                ctrl->setValue(llsdArray, false);
            }
            else if(value.size() > 0)
            {
                if(value.size() > 1)
                {
                    llwarns << "Ignoring extra tokens mapped to the setting: " << opt_name << "." << llendl;
                }

                LLSD llsdValue;
                llsdValue.assign(LLSD::String(value[0]));
                ctrl->setValue(llsdValue, false);
            }
        }
        break;
        }
    }
    else
    {
        llwarns << "Command Line option mapping '"
                << opt_name
                << "' not found! Ignoring."
                << llendl;
    }
}