예제 #1
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;
}
예제 #2
0
// Checked: 2009-06-03 (RLVa-0.2.0h) | Modified: RLVa-0.2.0h
RlvExtGetSet::RlvExtGetSet()
{
	if (!m_DbgAllowed.size())	// m_DbgAllowed is static and should only be initialized once
	{
		m_DbgAllowed.insert(std::pair<std::string, S16>("AvatarSex", DBG_READ | DBG_WRITE | DBG_PSEUDO));
		m_DbgAllowed.insert(std::pair<std::string, S16>("RenderResolutionDivisor", DBG_READ | DBG_WRITE));
		#ifdef RLV_EXTENSION_CMD_GETSETDEBUG_EX
			m_DbgAllowed.insert(std::pair<std::string, S16>(RLV_SETTING_FORBIDGIVETORLV, DBG_READ));
			m_DbgAllowed.insert(std::pair<std::string, S16>(RLV_SETTING_NOSETENV, DBG_READ));
			m_DbgAllowed.insert(std::pair<std::string, S16>("WindLightUseAtmosShaders", DBG_READ));
		#endif // RLV_EXTENSION_CMD_GETSETDEBUG_EX

		// Cache persistance of every setting
		LLControlVariable* pSetting;
		for (std::map<std::string, S16>::iterator itDbg = m_DbgAllowed.begin(); itDbg != m_DbgAllowed.end(); ++itDbg)
		{
			if ( ((pSetting = gSavedSettings.getControl(itDbg->first)) != NULL) && (pSetting->isPersisted()) )
				itDbg->second |= DBG_PERSIST;
		}
	}
}
예제 #3
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();
    }
}
예제 #4
0
U32 LLControlGroup::loadFromFile(const std::string& filename, bool set_default_values, bool revert_if_not_found)
{
	std::string name;
	LLSD settings;
	LLSD control_map;
	llifstream infile;
	infile.open(filename);
	if(!infile.is_open())
	{
		llwarns << "Cannot find file " << filename << " to load." << llendl;
		return 0;
	}

	S32 ret = LLSDSerialize::fromXML(settings, infile);

	if (ret <= 0)
	{
		infile.close();
		llwarns << "Unable to open LLSD control file " << filename << ". Trying Legacy Method." << llendl;		
		return loadFromFileLegacy(filename, TRUE, TYPE_STRING);
	}

	U32	validitems = 0;
	bool hidefromsettingseditor = false;
	
	for(LLSD::map_const_iterator itr = settings.beginMap(); itr != settings.endMap(); ++itr)
	{
		bool persist = true;
		name = (*itr).first;
		control_map = (*itr).second;
		
		if(control_map.has("Persist")) 
		{
			persist = control_map["Persist"].asInteger();
		}
		
		// Sometimes we want to use the settings system to provide cheap persistence, but we
		// don't want the settings themselves to be easily manipulated in the UI because 
		// doing so can cause support problems. So we have this option:
		if(control_map.has("HideFromEditor"))
		{
			hidefromsettingseditor = control_map["HideFromEditor"].asInteger();
		}
		else
		{
			hidefromsettingseditor = false;
		}
		
		// If the control exists just set the value from the input file.
		LLControlVariable* existing_control = getControl(name);
		if(existing_control)
		{
			if(set_default_values)
			{
				// Override all previously set properties of this control.
				// ... except for type. The types must match.
				eControlType new_type = typeStringToEnum(control_map["Type"].asString());
				if(existing_control->isType(new_type))
				{
					existing_control->setDefaultValue(control_map["Value"]);
					existing_control->setPersist(persist);
					existing_control->setHiddenFromSettingsEditor(hidefromsettingseditor);
					existing_control->setComment(control_map["Comment"].asString());
				}
				else
				{
					llerrs << "Mismatched type of control variable '"
						   << name << "' found while loading '"
						   << filename << "'." << llendl;
				}
			}
			else if(existing_control->isPersisted())
			{
				
				existing_control->setValue(control_map["Value"]);
			}
			// *NOTE: If not persisted and not setting defaults, 
			// the value should not get loaded.
		}
		else
		{
			declareControl(name, 
						   typeStringToEnum(control_map["Type"].asString()), 
						   control_map["Value"], 
						   control_map["Comment"].asString(), 
						   persist,
						   hidefromsettingseditor
						   );
		}
		
		++validitems;
	}

	// [KITTY VIEWER]
	if(revert_if_not_found)
	{
		ctrl_name_table_t::iterator control_iter;
		for (control_iter = mNameTable.begin();
			 control_iter != mNameTable.end();
			 ++control_iter)
		{
			if(!settings.has((*control_iter).first))
			{
				LLControlVariable* control = (*control_iter).second;
				if(control->isPersisted() && !control->isDefault())
				{
					control->resetToDefault(true);
				}
			}
		}
	}
	// [/KITTY VIEWER]

	return validitems;
}