diff options
Diffstat (limited to 'linden/indra/newview/llwaterparammanager.cpp')
-rw-r--r-- | linden/indra/newview/llwaterparammanager.cpp | 87 |
1 files changed, 54 insertions, 33 deletions
diff --git a/linden/indra/newview/llwaterparammanager.cpp b/linden/indra/newview/llwaterparammanager.cpp index f4f1163..83bf555 100644 --- a/linden/indra/newview/llwaterparammanager.cpp +++ b/linden/indra/newview/llwaterparammanager.cpp | |||
@@ -4,7 +4,7 @@ | |||
4 | * | 4 | * |
5 | * $LicenseInfo:firstyear=2007&license=viewergpl$ | 5 | * $LicenseInfo:firstyear=2007&license=viewergpl$ |
6 | * | 6 | * |
7 | * Copyright (c) 2007-2008, Linden Research, Inc. | 7 | * Copyright (c) 2007-2009, Linden Research, Inc. |
8 | * | 8 | * |
9 | * Second Life Viewer Source Code | 9 | * Second Life Viewer Source Code |
10 | * The source code in this file ("Source Code") is provided by Linden Lab | 10 | * The source code in this file ("Source Code") is provided by Linden Lab |
@@ -89,48 +89,57 @@ LLWaterParamManager::~LLWaterParamManager() | |||
89 | void LLWaterParamManager::loadAllPresets(const std::string& file_name) | 89 | void LLWaterParamManager::loadAllPresets(const std::string& file_name) |
90 | { | 90 | { |
91 | std::string path_name(gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "windlight/water", "")); | 91 | std::string path_name(gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "windlight/water", "")); |
92 | LL_INFOS2("AppInit", "Shaders") << "Loading water settings from " << path_name << LL_ENDL; | 92 | LL_INFOS2("AppInit", "Shaders") << "Loading Default water settings from " << path_name << LL_ENDL; |
93 | 93 | ||
94 | //mParamList.clear(); | ||
95 | |||
96 | bool found = true; | 94 | bool found = true; |
97 | while(found) | 95 | while(found) |
98 | { | 96 | { |
99 | std::string name; | 97 | std::string name; |
100 | found = gDirUtilp->getNextFileInDir(path_name, "*.xml", name, false); | 98 | found = gDirUtilp->getNextFileInDir(path_name, "*.xml", name, false); |
101 | 99 | if(found) | |
102 | LL_DEBUGS2("AppInit", "Shaders") << "name: " << name << LL_ENDL; | ||
103 | |||
104 | // if we have one | ||
105 | if(found) | ||
106 | { | 100 | { |
101 | |||
102 | name=name.erase(name.length()-4); | ||
103 | |||
107 | // bugfix for SL-46920: preventing filenames that break stuff. | 104 | // bugfix for SL-46920: preventing filenames that break stuff. |
108 | char * curl_str = curl_unescape(name.c_str(), name.size()); | 105 | char * curl_str = curl_unescape(name.c_str(), name.size()); |
109 | std::string unescaped_name(curl_str); | 106 | std::string unescaped_name(curl_str); |
110 | curl_free(curl_str); | 107 | curl_free(curl_str); |
111 | curl_str = NULL; | 108 | curl_str = NULL; |
112 | 109 | ||
113 | // not much error checking here since we're getting rid of this | 110 | LL_DEBUGS2("AppInit", "Shaders") << "name: " << name << LL_ENDL; |
114 | std::string water_name = unescaped_name.substr(0, unescaped_name.size() - 4); | 111 | loadPreset(unescaped_name,FALSE); |
115 | 112 | } | |
116 | std::string cur_path(gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "windlight/water", name)); | 113 | } |
117 | LL_DEBUGS2("AppInit", "Shaders") << "Loading water from " << cur_path << LL_ENDL; | 114 | |
115 | // And repeat for user presets, note the user presets will modify any system presets already loaded | ||
116 | |||
117 | std::string path_name2(gDirUtilp->getExpandedFilename( LL_PATH_USER_SETTINGS , "windlight/water", "")); | ||
118 | LL_INFOS2("AppInit", "Shaders") << "Loading User water settings from " << path_name2 << LL_ENDL; | ||
118 | 119 | ||
119 | llifstream water_xml(cur_path); | 120 | found = true; |
120 | if (water_xml) | 121 | while(found) |
121 | { | 122 | { |
122 | LLSD water_data(LLSD::emptyMap()); | 123 | std::string name; |
123 | LLPointer<LLSDParser> parser = new LLSDXMLParser(); | 124 | found = gDirUtilp->getNextFileInDir(path_name2, "*.xml", name, false); |
124 | parser->parse(water_xml, water_data, LLSDSerialize::SIZE_UNLIMITED); | 125 | if(found) |
126 | { | ||
127 | name=name.erase(name.length()-4); | ||
125 | 128 | ||
126 | addParamSet(water_name, water_data); | 129 | // bugfix for SL-46920: preventing filenames that break stuff. |
127 | water_xml.close(); | 130 | char * curl_str = curl_unescape(name.c_str(), name.size()); |
128 | } | 131 | std::string unescaped_name(curl_str); |
132 | curl_free(curl_str); | ||
133 | curl_str = NULL; | ||
134 | |||
135 | LL_DEBUGS2("AppInit", "Shaders") << "name: " << name << LL_ENDL; | ||
136 | loadPreset(unescaped_name,FALSE); | ||
129 | } | 137 | } |
130 | } | 138 | } |
139 | |||
131 | } | 140 | } |
132 | 141 | ||
133 | void LLWaterParamManager::loadPreset(const std::string & name) | 142 | void LLWaterParamManager::loadPreset(const std::string & name,bool propagate) |
134 | { | 143 | { |
135 | // bugfix for SL-46920: preventing filenames that break stuff. | 144 | // bugfix for SL-46920: preventing filenames that break stuff. |
136 | char * curl_str = curl_escape(name.c_str(), name.size()); | 145 | char * curl_str = curl_escape(name.c_str(), name.size()); |
@@ -142,8 +151,17 @@ void LLWaterParamManager::loadPreset(const std::string & name) | |||
142 | 151 | ||
143 | std::string pathName(gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "windlight/water", escaped_filename)); | 152 | std::string pathName(gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "windlight/water", escaped_filename)); |
144 | llinfos << "Loading water settings from " << pathName << llendl; | 153 | llinfos << "Loading water settings from " << pathName << llendl; |
145 | 154 | ||
146 | llifstream presetsXML(pathName); | 155 | std::ifstream presetsXML; |
156 | presetsXML.open(pathName.c_str()); | ||
157 | |||
158 | // That failed, try loading from the users area instead. | ||
159 | if(!presetsXML) | ||
160 | { | ||
161 | pathName=gDirUtilp->getExpandedFilename( LL_PATH_USER_SETTINGS , "windlight/water", escaped_filename); | ||
162 | llinfos << "Loading User water setting from " << pathName << llendl; | ||
163 | presetsXML.open(pathName.c_str()); | ||
164 | } | ||
147 | 165 | ||
148 | if (presetsXML) | 166 | if (presetsXML) |
149 | { | 167 | { |
@@ -170,10 +188,12 @@ void LLWaterParamManager::loadPreset(const std::string & name) | |||
170 | return; | 188 | return; |
171 | } | 189 | } |
172 | 190 | ||
173 | getParamSet(name, mCurParams); | 191 | if(propagate) |
174 | 192 | { | |
175 | propagateParameters(); | 193 | getParamSet(name, mCurParams); |
176 | } | 194 | propagateParameters(); |
195 | } | ||
196 | } | ||
177 | 197 | ||
178 | void LLWaterParamManager::savePreset(const std::string & name) | 198 | void LLWaterParamManager::savePreset(const std::string & name) |
179 | { | 199 | { |
@@ -187,7 +207,7 @@ void LLWaterParamManager::savePreset(const std::string & name) | |||
187 | 207 | ||
188 | // make an empty llsd | 208 | // make an empty llsd |
189 | LLSD paramsData(LLSD::emptyMap()); | 209 | LLSD paramsData(LLSD::emptyMap()); |
190 | std::string pathName(gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "windlight/water", escaped_filename)); | 210 | std::string pathName(gDirUtilp->getExpandedFilename( LL_PATH_USER_SETTINGS , "windlight/water", escaped_filename)); |
191 | 211 | ||
192 | // fill it with LLSD windlight params | 212 | // fill it with LLSD windlight params |
193 | paramsData = mParamList[name].getAll(); | 213 | paramsData = mParamList[name].getAll(); |
@@ -390,7 +410,8 @@ bool LLWaterParamManager::removeParamSet(const std::string& name, bool delete_fr | |||
390 | 410 | ||
391 | if(delete_from_disk) | 411 | if(delete_from_disk) |
392 | { | 412 | { |
393 | std::string path_name(gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "windlight/water", "")); | 413 | |
414 | std::string path_name(gDirUtilp->getExpandedFilename( LL_PATH_USER_SETTINGS , "windlight/water", "")); | ||
394 | 415 | ||
395 | // use full curl escaped name | 416 | // use full curl escaped name |
396 | char * curl_str = curl_escape(name.c_str(), name.size()); | 417 | char * curl_str = curl_escape(name.c_str(), name.size()); |