void LLWLDayCycle::loadDayCycle(const std::string & fileName) { // now load the file std::string pathName(gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "windlight/days", fileName)); llinfos << "Loading DayCycle settings from " << pathName << llendl; llifstream day_cycle_xml(pathName); if (day_cycle_xml.is_open()) { // clear the first few things mTimeMap.clear(); // load and parse it LLSD day_data(LLSD::emptyArray()); LLPointer<LLSDParser> parser = new LLSDXMLParser(); parser->parse(day_cycle_xml, day_data, LLSDSerialize::SIZE_UNLIMITED); // add each key for(S32 i = 0; i < day_data.size(); ++i) { // 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(); } }
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(); }
void LLWLDayCycle::saveDayCycle(const std::string & fileName) { LLSD day_data(LLSD::emptyArray()); std::string pathName(gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "windlight/days", fileName)); //llinfos << "Saving WindLight settings to " << pathName << llendl; 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); } llofstream day_cycle_xml(pathName); LLPointer<LLSDFormatter> formatter = new LLSDXMLFormatter(); formatter->format(day_data, day_cycle_xml, LLSDFormatter::OPTIONS_PRETTY); day_cycle_xml.close(); }
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; } }