コード例 #1
0
ファイル: llcontrol.cpp プロジェクト: 9skunks/imprudence
BOOL LLControlGroup::declareBOOL(const std::string& name, const BOOL initial_val, const std::string& comment, BOOL persist)
{
	return declareControl(name, TYPE_BOOLEAN, initial_val, comment, persist);
}
コード例 #2
0
ファイル: llcontrol.cpp プロジェクト: 9skunks/imprudence
BOOL LLControlGroup::declareString(const std::string& name, const std::string& initial_val, const std::string& comment, BOOL persist)
{
	return declareControl(name, TYPE_STRING, initial_val, comment, persist);
}
コード例 #3
0
ファイル: llcontrol.cpp プロジェクト: 9skunks/imprudence
BOOL LLControlGroup::declareU32(const std::string& name, const U32 initial_val, const std::string& comment, BOOL persist)
{
	return declareControl(name, TYPE_U32, (LLSD::Integer) initial_val, comment, persist);
}
コード例 #4
0
ファイル: llcontrol.cpp プロジェクト: 9skunks/imprudence
BOOL LLControlGroup::declareF32(const std::string& name, const F32 initial_val, const std::string& comment, BOOL persist)
{
	return declareControl(name, TYPE_F32, initial_val, comment, persist);
}
コード例 #5
0
ファイル: llcontrol.cpp プロジェクト: N3X15/Luna-Viewer
BOOL LLControlGroup::declareLLSD(const std::string& name, const LLSD &initial_val, const std::string& comment, BOOL persist )
{
	return declareControl(name, TYPE_LLSD, initial_val, comment, persist);
}
コード例 #6
0
ファイル: llcontrol.cpp プロジェクト: 9skunks/imprudence
U32 LLControlGroup::loadFromFile(const std::string& filename, bool set_default_values)
{
	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:

		// To actually only hide  adult settings and the world search url.
		// Upside of the latter is that it also makes it harder to use the viewer with OpenSim.
		// And teenagers never would dare ever to touch the settings.xml file.
		// 
		// For it's anyway useful to be able to change them we should add in future
		// a possibility to unhide them again, e.g. typing "I'm up to no good" to channel 666,
		// tripple-rightclick the avatars nose and then play a "I will tell your MUM that you 
		// changed ADULT setting in the DEBUG MENU!" gesture in world.
		//
/*
		if(control_map.has("HideFromEditor"))
		{
			hidefromsettingseditor = control_map["HideFromEditor"].asInteger();
		}
		else
		{
			hidefromsettingseditor = false;
		}
*/
		
// [RLVa:KB] - Checked: 2010-06-20 (RLVa-1.1.2a) | Added: RLVa-1.1.2a
		// HACK-RLVa: bad code but it's just a temporary measure to provide a smooth changeover from the old to the new rebranded settings
		if ( (name.length() >= 14) && (0 == name.find("RestrainedLife")) )
		{
			// Transparently convert the old settings name to the new one while preserving the user override
			name = "RestrainedLove" + name.substr(14);
		}
// [/RLVa:KB]

		// 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;
	}

	return validitems;
}
コード例 #7
0
U32 LLControlGroup::loadFromFile(const std::string& filename, bool set_default_values)
{
    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 persist = false;
    for(LLSD::map_const_iterator itr = settings.beginMap(); itr != settings.endMap(); ++itr)
    {
        name = (*itr).first;
        control_map = (*itr).second;

        if(control_map.has("Persist"))
        {
            persist = control_map["Persist"].asInteger();
        }

        // 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->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
                          );
        }

        ++validitems;
    }

    return validitems;
}
コード例 #8
0
ファイル: llcontrol.cpp プロジェクト: wish-ds/firestorm-ds
BOOL LLControlGroup::declareColor4(const std::string& name, const LLColor4 &initial_val, const std::string& comment, BOOL persist )
{
	return declareControl(name, TYPE_COL4, initial_val.getValue(), comment, SANITY_TYPE_NONE, LLSD(), std::string(""), persist);
}
コード例 #9
0
U32 LLControlGroup::loadFromFile(const std::string& filename, bool set_default_values, bool save_values)
{
	LLSD settings;
	llifstream infile;
	infile.open(filename.c_str());
	if(!infile.is_open())
	{
		LL_WARNS("Settings") << "Cannot find file " << filename << " to load." << LL_ENDL;
		return 0;
	}

	if (LLSDParser::PARSE_FAILURE == LLSDSerialize::fromXML(settings, infile))
	{
		infile.close();
		LL_WARNS("Settings") << "Unable to parse LLSD control file " << filename << ". Trying Legacy Method." << LL_ENDL;
		return loadFromFileLegacy(filename, TRUE, TYPE_STRING);
	}

	U32	validitems = 0;
	bool hidefromsettingseditor = false;
	
	for(LLSD::map_const_iterator itr = settings.beginMap(); itr != settings.endMap(); ++itr)
	{
		LLControlVariable::ePersist persist = LLControlVariable::PERSIST_NONDFT;
		bool can_backup = true;		// <FS:Zi> Backup Settings
		std::string const & name = itr->first;
		LLSD const & control_map = itr->second;
		
		if(control_map.has("Persist")) 
		{
			persist = control_map["Persist"].asInteger()?
					  LLControlVariable::PERSIST_NONDFT : LLControlVariable::PERSIST_NO;
		}

		// <FS:Zi> Backup Settings
		if(control_map.has("Backup")) 
		{
			can_backup = control_map["Backup"].asInteger();
		}
		// </FS:Zi>

		// 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)
		{
			// set_default_values is true when we're loading the initial,
			// immutable files from app_settings, e.g. settings.xml.
			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());
					existing_control->setBackupable(can_backup);		// <FS:Zi> Backup Settings
				}
				else
				{
					LL_ERRS() << "Mismatched type of control variable '"
						   << name << "' found while loading '"
						   << filename << "'." << LL_ENDL;
				}
			}
			else if(existing_control->isPersisted())
			{
				// save_values is specifically false for (e.g.)
				// SessionSettingsFile and UserSessionSettingsFile -- in other
				// words, for a file that's supposed to be transient.
				existing_control->setValue(control_map["Value"], save_values);
			}
			// *NOTE: If not persisted and not setting defaults, 
			// the value should not get loaded.
		}
		else
		{
			// We've never seen this control before. Either we're loading up
			// the initial set of default settings files (set_default_values)
			// -- or we're loading user settings last saved by a viewer that
			// supports a superset of the variables we know.
			// CHOP-962: if we're loading an unrecognized user setting, make
			// sure we save it later. If you try an experimental viewer, tweak
			// a new setting, briefly revert to an old viewer, then return to
			// the new one, we don't want the old viewer to discard the
			// setting you changed.
			if (! set_default_values)
			{
				// Using PERSIST_ALWAYS insists that saveToFile() (which calls
				// LLControlVariable::shouldSave()) must save this control
				// variable regardless of its value. We can safely set this
				// LLControlVariable persistent because the 'persistent' flag
				// is not itself persisted!
				persist = LLControlVariable::PERSIST_ALWAYS;
				// We want to mention unrecognized user settings variables
				// (e.g. from a newer version of the viewer) in the log. But
				// we also arrive here for Boolean variables generated by
				// the notifications subsystem when the user checks "Don't
				// show me this again." These aren't declared in settings.xml;
				// they're actually named for the notification they suppress.
				// We don't want to mention those. Apologies, this is a bit of
				// a hack: we happen to know that user settings go into an
				// LLControlGroup whose name is "Global".
				if (getKey() == "Global")
				{
					LL_INFOS("LLControlGroup") << "preserving unrecognized " << getKey()
											   << " settings variable " << name << LL_ENDL;
				}
			}

			declareControl(name, 
						   typeStringToEnum(control_map["Type"].asString()), 
						   control_map["Value"], 
						   control_map["Comment"].asString(),
						   sanityTypeStringToEnum(control_map["SanityCheckType"].asString()),
						   control_map["SanityValue"],
						   control_map["SanityComment"].asString(),
						   persist,
						   can_backup,		// <FS:Zi> Backup Settings
						   hidefromsettingseditor
						   );
		}

		++validitems;
	}

	LL_DEBUGS("Settings") << "Loaded " << validitems << " settings from " << filename << LL_ENDL;
	return validitems;
}
コード例 #10
0
ファイル: llcontrol.cpp プロジェクト: HizWylder/GIS
U32 LLControlGroup::loadFromFile(const std::string& filename, bool set_default_values, bool save_values)
{
	LLSD settings;
	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;
		std::string const & name = itr->first;
		LLSD const & 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"], save_values);
			}
			// *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;
	}

	return validitems;
}
コード例 #11
0
LLControlVariable* LLControlGroup::declareLLSD(const std::string& name, const LLSD &initial_val, const std::string& comment, LLControlVariable::ePersist persist )
{
	return declareControl(name, TYPE_LLSD, initial_val, comment, SANITY_TYPE_NONE, LLSD(), std::string(""), persist);
}
コード例 #12
0
LLControlVariable* LLControlGroup::declareRect(const std::string& name, const LLRect &initial_val, const std::string& comment, LLControlVariable::ePersist persist)
{
	return declareControl(name, TYPE_RECT, initial_val.getValue(), comment, SANITY_TYPE_NONE, LLSD(), std::string(""), persist);
}
コード例 #13
0
LLControlVariable* LLControlGroup::declareU32(const std::string& name, const U32 initial_val, const std::string& comment, LLControlVariable::ePersist persist)
{
	return declareControl(name, TYPE_U32, (LLSD::Integer) initial_val, comment, SANITY_TYPE_NONE, LLSD(), std::string(""), persist);
}
コード例 #14
0
ファイル: llcontrol.cpp プロジェクト: 9skunks/imprudence
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);
}
コード例 #15
0
ファイル: llcontrol.cpp プロジェクト: N3X15/Luna-Viewer
BOOL LLControlGroup::declareColor3(const std::string& name, const LLColor3 &initial_val, const std::string& comment, BOOL persist )
{
	return declareControl(name, TYPE_COL3, initial_val.getValue(), comment, persist);
}
コード例 #16
0
ファイル: llcontrol.cpp プロジェクト: 9skunks/imprudence
BOOL LLControlGroup::declareRect(const std::string& name, const LLRect &initial_val, const std::string& comment, BOOL persist)
{
	return declareControl(name, TYPE_RECT, initial_val.getValue(), comment, persist);
}
コード例 #17
0
ファイル: llcontrol.cpp プロジェクト: wish-ds/firestorm-ds
BOOL LLControlGroup::declareString(const std::string& name, const std::string& initial_val, const std::string& comment, BOOL persist)
{
	return declareControl(name, TYPE_STRING, initial_val, comment, SANITY_TYPE_NONE, LLSD(), std::string(""), persist);
}