Example #1
0
// Checked: 2009-06-03 (RLVa-0.2.0h) | Modified: RLVa-0.2.0h
std::string RlvExtGetSet::onGetDebug(std::string strSetting)
{
	S16 dbgFlags;
	if ( (findDebugSetting(strSetting, dbgFlags)) && ((dbgFlags & DBG_READ) == DBG_READ) )
	{
		if ((dbgFlags & DBG_PSEUDO) == 0)
		{
			LLControlVariable* pSetting = gSavedSettings.getControl(strSetting);
			if (pSetting)
			{
				switch (pSetting->type())
				{
					case TYPE_U32:
						return llformat("%u", gSavedSettings.getU32(strSetting));
					case TYPE_S32:
						return llformat("%d", gSavedSettings.getS32(strSetting));
					case TYPE_BOOLEAN:
						return llformat("%d", gSavedSettings.getBOOL(strSetting));
					default:
						RLV_ERRS << "Unexpected debug setting type" << LL_ENDL;
						break;
				}
			}
		}
		else
		{
			return onGetPseudoDebug(strSetting);
		}
	}
	return std::string();
}
Example #2
0
// Checked: 2009-10-10 (RLVa-1.0.4e) | Modified: RLVa-1.0.4e
ERlvCmdRet RlvExtGetSet::onSetDebug(std::string strSetting, const std::string& strValue)
{
	S16 dbgFlags; ERlvCmdRet eRet = RLV_RET_FAILED_UNKNOWN;
	if ( (findDebugSetting(strSetting, dbgFlags)) && ((dbgFlags & DBG_WRITE) == DBG_WRITE) )
	{
		eRet = RLV_RET_FAILED_OPTION;
		if ((dbgFlags & DBG_PSEUDO) == 0)
		{
			LLControlVariable* pSetting = gSavedSettings.getControl(strSetting);
			if (pSetting)
			{
				U32 u32Value; S32 s32Value; BOOL fValue;
				switch (pSetting->type())
				{
					case TYPE_U32:
						if (LLStringUtil::convertToU32(strValue, u32Value))
						{
							gSavedSettings.setU32(strSetting, u32Value);
							eRet = RLV_RET_SUCCESS;
						}
						break;
					case TYPE_S32:
						if (LLStringUtil::convertToS32(strValue, s32Value))
						{
							gSavedSettings.setS32(strSetting, s32Value);
							eRet = RLV_RET_SUCCESS;
						}
						break;
					case TYPE_BOOLEAN:
						if (LLStringUtil::convertToBOOL(strValue, fValue))
						{
							gSavedSettings.setBOOL(strSetting, fValue);
							eRet = RLV_RET_SUCCESS;
						}
						break;
					default:
						RLV_ERRS << "Unexpected debug setting type" << LL_ENDL;
						eRet = RLV_RET_FAILED;
						break;
				}

				// Default settings should persist if they were marked that way, but non-default settings should never persist
				pSetting->setPersist( (pSetting->isDefault()) ? ((dbgFlags & DBG_PERSIST) == DBG_PERSIST) : false );
			}
		}
		else
		{
			eRet = onSetPseudoDebug(strSetting, strValue);
		}
	}
	return eRet;
}
Example #3
0
U32 LLControlGroup::saveToFile(const std::string& filename, BOOL nondefault_only)
{
    LLSD settings;
    int num_saved = 0;
    for (ctrl_name_table_t::iterator iter = mNameTable.begin();
            iter != mNameTable.end(); iter++)
    {
        LLControlVariable* control = iter->second;
        if (!control)
        {
            llwarns << "Tried to save invalid control: " << iter->first << llendl;
        }

        if( control && control->isPersisted() )
        {
            if (!(nondefault_only && (control->isSaveValueDefault())))
            {
                settings[iter->first]["Type"] = typeEnumToString(control->type());
                settings[iter->first]["Comment"] = control->getComment();
                settings[iter->first]["Value"] = control->getSaveValue();
                ++num_saved;
            }
            else
            {
                // Debug spam
                // llinfos << "Skipping " << control->getName() << llendl;
            }
        }
    }
    llofstream file;
    file.open(filename);
    if (file.is_open())
    {
        LLSDSerialize::toPrettyXML(settings, file);
        file.close();
        llinfos << "Saved to " << filename << llendl;
    }
    else
    {
        // This is a warning because sometime we want to use settings files which can't be written...
        llwarns << "Unable to open settings file: " << filename << llendl;
        return 0;
    }
    return num_saved;
}
Example #4
0
void LLControlGroup::connectCOAVars(LLControlGroup &OtherGroup)
{
    LLControlVariable *pCOAVar = NULL;
    for (ctrl_name_table_t::iterator iter = mNameTable.begin();
            iter != mNameTable.end(); iter++)
    {
        if(iter->second->isCOA())
        {
            LLControlVariable *pParent = iter->second;
            LLControlVariable *pChild = OtherGroup.getControl(pParent->getName());
            if(!pChild)
            {
                OtherGroup.declareControl(
                    pParent->getName(),
                    pParent->type(),
                    pParent->getDefault(),
                    pParent->getComment(),
                    pParent->isPersisted(),
                    true);

                pChild = OtherGroup.getControl(pParent->getName());
            }
            if(pChild)
            {
                pParent->setCOAConnect(pChild,true);
                pChild->setCOAConnect(pParent,false);
            }
        }
        else if(iter->second->getName() == "AscentStoreSettingsPerAccount")
            pCOAVar = iter->second;
    }
    if(pCOAVar)
    {
        pCOAVar->getSignal()->connect(boost::bind(&LLControlGroup::handleCOASettingChange, this, _2));
        pCOAVar->firePropertyChanged();
    }
}
U32 LLControlGroup::saveToFile(const std::string& filename, BOOL nondefault_only)
{
	LLSD settings;
	int num_saved = 0;
	for (ctrl_name_table_t::iterator iter = mNameTable.begin();
		 iter != mNameTable.end(); iter++)
	{
		LLControlVariable* control = iter->second;
		if (!control)
		{
			LL_WARNS("Settings") << "Tried to save invalid control: " << iter->first << LL_ENDL;
		}
		else if( control->shouldSave(nondefault_only) )
		{
			settings[iter->first]["Type"] = typeEnumToString(control->type());
			settings[iter->first]["Comment"] = control->getComment();
			settings[iter->first]["Value"] = control->getSaveValue();
			settings[iter->first]["Backup"] = control->isBackupable();		// <FS:Zi> Backup Settings
			++num_saved;
		}
	}
	llofstream file;
	file.open(filename.c_str());
	if (file.is_open())
	{
		LLSDSerialize::toPrettyXML(settings, file);
		file.close();
		LL_INFOS("Settings") << "Saved to " << filename << LL_ENDL;
	}
	else
	{
        // This is a warning because sometime we want to use settings files which can't be written...
		LL_WARNS("Settings") << "Unable to open settings file: " << filename << LL_ENDL;
		return 0;
	}
	return num_saved;
}
//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 #7
0
//----------------------------------------------------------------------------
// 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;
    }
}
//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;
		}
	}
}