diff options
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Framework/PrimitiveBaseShape.cs | 38 | ||||
-rw-r--r-- | OpenSim/Region/CoreModules/World/Media/Moap/MoapModule.cs | 58 |
2 files changed, 29 insertions, 67 deletions
diff --git a/OpenSim/Framework/PrimitiveBaseShape.cs b/OpenSim/Framework/PrimitiveBaseShape.cs index de7e42d..685599a 100644 --- a/OpenSim/Framework/PrimitiveBaseShape.cs +++ b/OpenSim/Framework/PrimitiveBaseShape.cs | |||
@@ -1238,7 +1238,7 @@ namespace OpenSim.Framework | |||
1238 | return null; | 1238 | return null; |
1239 | } | 1239 | } |
1240 | 1240 | ||
1241 | public void WriteXml(XmlWriter writer) | 1241 | public string ToXml() |
1242 | { | 1242 | { |
1243 | lock (this) | 1243 | lock (this) |
1244 | { | 1244 | { |
@@ -1265,18 +1265,26 @@ namespace OpenSim.Framework | |||
1265 | xtw.WriteEndElement(); | 1265 | xtw.WriteEndElement(); |
1266 | 1266 | ||
1267 | xtw.Flush(); | 1267 | xtw.Flush(); |
1268 | writer.WriteRaw(sw.ToString()); | 1268 | return sw.ToString(); |
1269 | } | 1269 | } |
1270 | } | 1270 | } |
1271 | } | 1271 | } |
1272 | } | 1272 | } |
1273 | 1273 | ||
1274 | public void ReadXml(XmlReader reader) | 1274 | public void WriteXml(XmlWriter writer) |
1275 | { | ||
1276 | writer.WriteRaw(ToXml()); | ||
1277 | } | ||
1278 | |||
1279 | public static MediaList FromXml(string rawXml) | ||
1275 | { | 1280 | { |
1276 | if (reader.IsEmptyElement) | 1281 | MediaList ml = new MediaList(); |
1277 | return; | 1282 | ml.ReadXml(rawXml); |
1278 | 1283 | return ml; | |
1279 | string rawXml = reader.ReadInnerXml(); | 1284 | } |
1285 | |||
1286 | public void ReadXml(string rawXml) | ||
1287 | { | ||
1280 | using (StringReader sr = new StringReader(rawXml)) | 1288 | using (StringReader sr = new StringReader(rawXml)) |
1281 | { | 1289 | { |
1282 | using (XmlTextReader xtr = new XmlTextReader(sr)) | 1290 | using (XmlTextReader xtr = new XmlTextReader(sr)) |
@@ -1292,8 +1300,6 @@ namespace OpenSim.Framework | |||
1292 | xtr.ReadStartElement("osmedia"); | 1300 | xtr.ReadStartElement("osmedia"); |
1293 | 1301 | ||
1294 | OSDArray osdMeArray = (OSDArray)OSDParser.DeserializeLLSDXml(xtr.ReadInnerXml()); | 1302 | OSDArray osdMeArray = (OSDArray)OSDParser.DeserializeLLSDXml(xtr.ReadInnerXml()); |
1295 | |||
1296 | List<MediaEntry> mediaEntries = new List<MediaEntry>(); | ||
1297 | foreach (OSD osdMe in osdMeArray) | 1303 | foreach (OSD osdMe in osdMeArray) |
1298 | { | 1304 | { |
1299 | MediaEntry me = (osdMe is OSDMap ? MediaEntry.FromOSD(osdMe) : new MediaEntry()); | 1305 | MediaEntry me = (osdMe is OSDMap ? MediaEntry.FromOSD(osdMe) : new MediaEntry()); |
@@ -1303,7 +1309,15 @@ namespace OpenSim.Framework | |||
1303 | xtr.ReadEndElement(); | 1309 | xtr.ReadEndElement(); |
1304 | } | 1310 | } |
1305 | } | 1311 | } |
1306 | } | 1312 | } |
1313 | |||
1314 | public void ReadXml(XmlReader reader) | ||
1315 | { | ||
1316 | if (reader.IsEmptyElement) | ||
1317 | return; | ||
1318 | |||
1319 | ReadXml(reader.ReadInnerXml()); | ||
1320 | } | ||
1307 | } | 1321 | } |
1308 | } | 1322 | } |
1309 | } \ No newline at end of file | 1323 | } \ No newline at end of file |
diff --git a/OpenSim/Region/CoreModules/World/Media/Moap/MoapModule.cs b/OpenSim/Region/CoreModules/World/Media/Moap/MoapModule.cs index 339a979..52acf81 100644 --- a/OpenSim/Region/CoreModules/World/Media/Moap/MoapModule.cs +++ b/OpenSim/Region/CoreModules/World/Media/Moap/MoapModule.cs | |||
@@ -203,67 +203,15 @@ namespace OpenSim.Region.CoreModules.Media.Moap | |||
203 | if (null == part.Shape.MediaRaw) | 203 | if (null == part.Shape.MediaRaw) |
204 | return; | 204 | return; |
205 | 205 | ||
206 | using (StringReader sr = new StringReader(part.Shape.MediaRaw)) | 206 | part.Shape.Media = PrimitiveBaseShape.MediaList.FromXml(part.Shape.MediaRaw); |
207 | { | ||
208 | using (XmlTextReader xtr = new XmlTextReader(sr)) | ||
209 | { | ||
210 | xtr.MoveToContent(); | ||
211 | |||
212 | string type = xtr.GetAttribute("type"); | ||
213 | //m_log.DebugFormat("[MOAP]: Loaded media texture entry with type {0}", type); | ||
214 | |||
215 | if (type != MEDIA_TEXTURE_TYPE) | ||
216 | return; | ||
217 | |||
218 | xtr.ReadStartElement("osmedia"); | ||
219 | |||
220 | OSDArray osdMeArray = (OSDArray)OSDParser.DeserializeLLSDXml(xtr.ReadInnerXml()); | ||
221 | |||
222 | PrimitiveBaseShape.MediaList mediaEntries = new PrimitiveBaseShape.MediaList(); | ||
223 | foreach (OSD osdMe in osdMeArray) | ||
224 | { | ||
225 | MediaEntry me = (osdMe is OSDMap ? MediaEntry.FromOSD(osdMe) : new MediaEntry()); | ||
226 | mediaEntries.Add(me); | ||
227 | } | ||
228 | |||
229 | xtr.ReadEndElement(); | ||
230 | |||
231 | part.Shape.Media = mediaEntries; | ||
232 | } | ||
233 | } | ||
234 | } | 207 | } |
235 | 208 | ||
236 | protected void OnSceneObjectPartPreSave(SceneObjectPart part) | 209 | protected void OnSceneObjectPartPreSave(SceneObjectPart part) |
237 | { | 210 | { |
238 | if (null == part.Shape.Media) | 211 | if (null == part.Shape.Media) |
239 | return; | 212 | return; |
240 | 213 | ||
241 | using (StringWriter sw = new StringWriter()) | 214 | part.Shape.MediaRaw = part.Shape.Media.ToXml(); |
242 | { | ||
243 | using (XmlTextWriter xtw = new XmlTextWriter(sw)) | ||
244 | { | ||
245 | xtw.WriteStartElement("osmedia"); | ||
246 | xtw.WriteAttributeString("type", MEDIA_TEXTURE_TYPE); | ||
247 | xtw.WriteAttributeString("major_version", "0"); | ||
248 | xtw.WriteAttributeString("minor_version", "1"); | ||
249 | |||
250 | OSDArray meArray = new OSDArray(); | ||
251 | foreach (MediaEntry me in part.Shape.Media) | ||
252 | { | ||
253 | OSD osd = (null == me ? new OSD() : me.GetOSD()); | ||
254 | meArray.Add(osd); | ||
255 | } | ||
256 | |||
257 | xtw.WriteStartElement("osdata"); | ||
258 | xtw.WriteRaw(OSDParser.SerializeLLSDXmlString(meArray)); | ||
259 | xtw.WriteEndElement(); | ||
260 | |||
261 | xtw.WriteEndElement(); | ||
262 | |||
263 | xtw.Flush(); | ||
264 | part.Shape.MediaRaw = sw.ToString(); | ||
265 | } | ||
266 | } | ||
267 | } | 215 | } |
268 | 216 | ||
269 | protected void OnSceneObjectPartCopy(SceneObjectPart copy, SceneObjectPart original, bool userExposed) | 217 | protected void OnSceneObjectPartCopy(SceneObjectPart copy, SceneObjectPart original, bool userExposed) |