Ejemplo n.º 1
0
void LLWLParamManager::savePreset(const std::string & name)
{
	// bugfix for SL-46920: preventing filenames that break stuff.
	char * curl_str = curl_escape(name.c_str(), name.size());
	std::string escaped_filename(curl_str);
	curl_free(curl_str);
	curl_str = NULL;

	escaped_filename += ".xml";

	// make an empty llsd
	LLSD paramsData(LLSD::emptyMap());
	std::string pathName(gDirUtilp->getExpandedFilename( LL_PATH_USER_SETTINGS , "windlight/skies", escaped_filename));

	// fill it with LLSD windlight params
	paramsData = mParamList[name].getAll();

	// write to file
	llofstream presetsXML(pathName);
	LLPointer<LLSDFormatter> formatter = new LLSDXMLFormatter();
	formatter->format(paramsData, presetsXML, LLSDFormatter::OPTIONS_PRETTY);
	presetsXML.close();

	propagateParameters();
	notifyObservers();
}
Ejemplo n.º 2
0
void LLWLParamManager::loadPreset(const std::string & name,bool propagate)
{
	
	// bugfix for SL-46920: preventing filenames that break stuff.
	char * curl_str = curl_escape(name.c_str(), name.size());
	std::string escaped_filename(curl_str);
	curl_free(curl_str);
	curl_str = NULL;

	escaped_filename += ".xml";

	std::string pathName(gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "windlight/skies", escaped_filename));
	LL_DEBUGS2("AppInit", "Shaders") << "Loading WindLight sky setting from " << pathName << LL_ENDL; 

	llifstream presetsXML;
	presetsXML.open(pathName.c_str());

	// That failed, try loading from the users area instead.
	if(!presetsXML)
	{
		pathName=gDirUtilp->getExpandedFilename( LL_PATH_USER_SETTINGS , "windlight/skies", escaped_filename);
		LL_DEBUGS2("AppInit", "Shaders")<< "Loading User WindLight sky setting from "  << LL_ENDL; 
		presetsXML.open(pathName.c_str());
	}

	if (presetsXML)
	{
		LLSD paramsData(LLSD::emptyMap());

		LLPointer<LLSDParser> parser = new LLSDXMLParser();

		parser->parse(presetsXML, paramsData, LLSDSerialize::SIZE_UNLIMITED);

		std::map<std::string, LLWLParamSet>::iterator mIt = mParamList.find(name);
		if(mIt == mParamList.end())
		{
			addParamSet(name, paramsData);
		}
		else 
		{
			setParamSet(name, paramsData);
		}
		presetsXML.close();
	} 
	else 
	{
		llwarns << "Can't find " << name << llendl;
		return;
	}

	
	if(propagate)
	{
		getParamSet(name, mCurParams);
		propagateParameters();
	}

	notifyObservers();
}	
Ejemplo n.º 3
0
void LLWLParamManager::loadPreset(const std::string & name,bool propagate)
{
	// Check if we already have the preset before we try loading it again.
	if(mParamList.find(name) != mParamList.end())
	{
		if(propagate)
		{
			getParamSet(name, mCurParams);
			propagateParameters();
		}
		return;
	}

	// bugfix for SL-46920: preventing filenames that break stuff.
	char * curl_str = curl_escape(name.c_str(), name.size());
	std::string escaped_filename(curl_str);
	curl_free(curl_str);
	curl_str = NULL;

	escaped_filename += ".xml";

	std::string pathName(gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "windlight/skies", escaped_filename));
	LL_DEBUGS2("AppInit", "Shaders") << "Loading WindLight sky setting from " << pathName << LL_ENDL; 

	llifstream presetsXML;
	presetsXML.open(pathName.c_str());

	// That failed, try loading from the users area instead.
	if(!presetsXML)
	{
		pathName=gDirUtilp->getExpandedFilename( LL_PATH_USER_SETTINGS , "windlight/skies", escaped_filename);
		LL_DEBUGS2("AppInit", "Shaders")<< "Loading User WindLight sky setting from "  << LL_ENDL; 
		presetsXML.open(pathName.c_str());
	}

	if (presetsXML)
	{
		loadPresetXML(name, presetsXML);
		presetsXML.close();
	} 
	else 
	{
		llwarns << "Can't find " << name << llendl;
		return;
	}

	
	if(propagate)
	{
		getParamSet(name, mCurParams);
		propagateParameters();
	}

	notifyObservers();
}	
Ejemplo n.º 4
0
void LLWLDayCycle::saveDayCycle(const std::string & fileName)
{
	
	// bugfix for SL-46920: preventing filenames that break stuff.
	char * curl_str = curl_escape(fileName.c_str(), fileName.size());
	std::string escaped_filename(curl_str);
	curl_free(curl_str);
	curl_str = NULL;

	escaped_filename += ".xml";

	std::string pathName(gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "windlight/days", escaped_filename));
	llinfos << "Saving Day Cycle preset from " << pathName << llendl;

	llofstream day_cycle_xml;
	day_cycle_xml.open(pathName.c_str());

	// That failed, try loading from the users area instead.
	if(!day_cycle_xml)
	{
		pathName=gDirUtilp->getExpandedFilename( LL_PATH_USER_SETTINGS , "windlight/days", escaped_filename);
		llinfos << "Saving User Day Cycle preset from " << pathName << llendl;
		day_cycle_xml.open(pathName.c_str());
	}

	LLSD day_data(LLSD::emptyArray());

	for(std::map<F32, std::string>::const_iterator mIt = mTimeMap.begin();
		mIt != mTimeMap.end();
		++mIt) 
	{
		LLSD key(LLSD::emptyArray());
		key.append(mIt->first);
		key.append(mIt->second);
		day_data.append(key);
	}

	LLPointer<LLSDFormatter> formatter = new LLSDXMLFormatter();
	formatter->format(day_data, day_cycle_xml, LLSDFormatter::OPTIONS_PRETTY);
	day_cycle_xml.close();
}
Ejemplo n.º 5
0
void LLWLDayCycle::loadDayCycle(const std::string & fileName)
{
	// clear the first few things
	mTimeMap.clear();

	// bugfix for SL-46920: preventing filenames that break stuff.
	char * curl_str = curl_escape(fileName.c_str(), fileName.size());
	std::string escaped_filename(curl_str);
	curl_free(curl_str);
	curl_str = NULL;

	escaped_filename += ".xml";

	std::string pathName(gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "windlight/days", escaped_filename));
	llinfos << "Loading Day Cycle preset from " << pathName << llendl;

	llifstream day_cycle_xml;
	day_cycle_xml.open(pathName.c_str());

	// That failed, try loading from the users area instead.
	if(!day_cycle_xml)
	{
		pathName=gDirUtilp->getExpandedFilename( LL_PATH_USER_SETTINGS , "windlight/days", escaped_filename);
		llinfos << "Loading User Day Cycle preset from " << pathName << llendl;
		day_cycle_xml.open(pathName.c_str());
	}

	if (day_cycle_xml)
	{
		// load and parse it
		LLSD day_data(LLSD::emptyArray());
		LLPointer<LLSDParser> parser = new LLSDXMLParser();
		parser->parse(day_cycle_xml, day_data, LLSDSerialize::SIZE_UNLIMITED);
		llinfos << "Loading day cycle into timeline..." << llendl;
		// add each key
		for(S32 i = 0; i < day_data.size(); ++i)
		{
			llinfos << "Loading value" << i << llendl;
			// make sure it's a two array
			if(day_data[i].size() != 2)
			{
				continue;
			}
			
			// check each param name exists in param manager
			bool success;
			LLWLParamSet pset;
			success = LLWLParamManager::instance()->getParamSet(day_data[i][1].asString(), pset);
			if(!success)
			{
				// alert the user
				LLSD args;
				args["SKY"] = day_data[i][1].asString();
				LLNotifications::instance().add("WLMissingSky", args);
				continue;
			}
			
			// then add the key
			addKey((F32)day_data[i][0].asReal(), day_data[i][1].asString());
		}

		day_cycle_xml.close();
	}
	else 
	{
		llwarns << "Can't find " << fileName << llendl;
		return;
	}
}