aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Framework
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Framework/PrimitiveBaseShape.cs90
1 files changed, 87 insertions, 3 deletions
diff --git a/OpenSim/Framework/PrimitiveBaseShape.cs b/OpenSim/Framework/PrimitiveBaseShape.cs
index 03ddb33..de7e42d 100644
--- a/OpenSim/Framework/PrimitiveBaseShape.cs
+++ b/OpenSim/Framework/PrimitiveBaseShape.cs
@@ -29,7 +29,10 @@ using System;
29using System.Collections.Generic; 29using System.Collections.Generic;
30using System.Drawing; 30using System.Drawing;
31using System.Drawing.Imaging; 31using System.Drawing.Imaging;
32using System.IO;
32using System.Reflection; 33using System.Reflection;
34using System.Xml;
35using System.Xml.Schema;
33using System.Xml.Serialization; 36using System.Xml.Serialization;
34using log4net; 37using log4net;
35using OpenMetaverse; 38using OpenMetaverse;
@@ -183,7 +186,7 @@ namespace OpenSim.Framework
183 /// Entries to store media textures on each face 186 /// Entries to store media textures on each face
184 /// </summary> 187 /// </summary>
185 /// Do not change this value directly - always do it through an IMoapModule. 188 /// Do not change this value directly - always do it through an IMoapModule.
186 public List<MediaEntry> Media { get; set; } 189 public MediaList Media { get; set; }
187 190
188 public PrimitiveBaseShape() 191 public PrimitiveBaseShape()
189 { 192 {
@@ -1221,5 +1224,86 @@ namespace OpenSim.Framework
1221 1224
1222 return prim; 1225 return prim;
1223 } 1226 }
1224 } 1227
1225} 1228 public class MediaList : List<MediaEntry>, IXmlSerializable
1229 {
1230 public const string MEDIA_TEXTURE_TYPE = "sl";
1231
1232 public MediaList() : base() {}
1233 public MediaList(IEnumerable<MediaEntry> collection) : base(collection) {}
1234 public MediaList(int capacity) : base(capacity) {}
1235
1236 public XmlSchema GetSchema()
1237 {
1238 return null;
1239 }
1240
1241 public void WriteXml(XmlWriter writer)
1242 {
1243 lock (this)
1244 {
1245 using (StringWriter sw = new StringWriter())
1246 {
1247 using (XmlTextWriter xtw = new XmlTextWriter(sw))
1248 {
1249 xtw.WriteStartElement("osmedia");
1250 xtw.WriteAttributeString("type", MEDIA_TEXTURE_TYPE);
1251 xtw.WriteAttributeString("major_version", "0");
1252 xtw.WriteAttributeString("minor_version", "1");
1253
1254 OSDArray meArray = new OSDArray();
1255 foreach (MediaEntry me in this)
1256 {
1257 OSD osd = (null == me ? new OSD() : me.GetOSD());
1258 meArray.Add(osd);
1259 }
1260
1261 xtw.WriteStartElement("osdata");
1262 xtw.WriteRaw(OSDParser.SerializeLLSDXmlString(meArray));
1263 xtw.WriteEndElement();
1264
1265 xtw.WriteEndElement();
1266
1267 xtw.Flush();
1268 writer.WriteRaw(sw.ToString());
1269 }
1270 }
1271 }
1272 }
1273
1274 public void ReadXml(XmlReader reader)
1275 {
1276 if (reader.IsEmptyElement)
1277 return;
1278
1279 string rawXml = reader.ReadInnerXml();
1280 using (StringReader sr = new StringReader(rawXml))
1281 {
1282 using (XmlTextReader xtr = new XmlTextReader(sr))
1283 {
1284 xtr.MoveToContent();
1285
1286 string type = xtr.GetAttribute("type");
1287 //m_log.DebugFormat("[MOAP]: Loaded media texture entry with type {0}", type);
1288
1289 if (type != MEDIA_TEXTURE_TYPE)
1290 return;
1291
1292 xtr.ReadStartElement("osmedia");
1293
1294 OSDArray osdMeArray = (OSDArray)OSDParser.DeserializeLLSDXml(xtr.ReadInnerXml());
1295
1296 List<MediaEntry> mediaEntries = new List<MediaEntry>();
1297 foreach (OSD osdMe in osdMeArray)
1298 {
1299 MediaEntry me = (osdMe is OSDMap ? MediaEntry.FromOSD(osdMe) : new MediaEntry());
1300 Add(me);
1301 }
1302
1303 xtr.ReadEndElement();
1304 }
1305 }
1306 }
1307 }
1308 }
1309} \ No newline at end of file