Content is a singleton responsible for loading data.
Ejemplo n.º 1
0
        public void Init(Content content)
        {
            //load and build catalog
            ItemsByGUID = new Dictionary<uint, ObjectCatalogItem>();
            ItemsByCategory = new List<ObjectCatalogItem>[30];
            for (int i = 0; i < 30; i++) ItemsByCategory[i] = new List<ObjectCatalogItem>();

            var packingslip = new XmlDocument();

            packingslip.Load(content.GetPath("packingslips/catalog.xml"));
            var objectInfos = packingslip.GetElementsByTagName("P");

            foreach (XmlNode objectInfo in objectInfos)
            {
                sbyte Category = Convert.ToSByte(objectInfo.Attributes["s"].Value);
                uint guid = Convert.ToUInt32(objectInfo.Attributes["g"].Value, 16);
                if (Category < 0) continue;
                var item = new ObjectCatalogItem()
                {
                    GUID = guid,
                    Category = Category,
                    Price = Convert.ToUInt32(objectInfo.Attributes["p"].Value),
                    Name = objectInfo.Attributes["n"].Value
                };
                ItemsByCategory[Category].Add(item);
                ItemsByGUID[guid] = item;
            }

            //load and build Content Objects into catalog
            if (File.Exists(Path.Combine(FSOEnvironment.ContentDir, "Objects/catalog_downloads.xml")))
            {
                var dpackingslip = new XmlDocument();

                dpackingslip.Load(Path.Combine(FSOEnvironment.ContentDir, "Objects/catalog_downloads.xml"));
                var downloadInfos = dpackingslip.GetElementsByTagName("P");

                foreach (XmlNode objectInfo in downloadInfos)
                {
                    sbyte dCategory = Convert.ToSByte(objectInfo.Attributes["s"].Value);
                    uint dguid = Convert.ToUInt32(objectInfo.Attributes["g"].Value, 16);
                    if (dCategory < 0) continue;
                    var ditem = new ObjectCatalogItem()
                    {
                        GUID = dguid,
                        Category = dCategory,
                        Price = Convert.ToUInt32(objectInfo.Attributes["p"].Value),
                        Name = objectInfo.Attributes["n"].Value
                    };

                    ItemsByCategory[dCategory].Add(ditem);
                    ItemsByGUID[dguid] = ditem;

                }
            }
        }
Ejemplo n.º 2
0
 public Audio(Content contentManager)
 {
     this.ContentManager = contentManager;
 }
Ejemplo n.º 3
0
 public static void Init(string basepath, GraphicsDevice device)
 {
     INSTANCE = new Content(basepath, device);
 }
 public WorldWallProvider(Content contentManager)
 {
     this.ContentManager = contentManager;
 }
Ejemplo n.º 5
0
        /// <summary>
        /// Gets a resource.
        /// </summary>
        /// <param name="filename">The filename of the resource to get.</param>
        /// <returns>A GameGlobal instance containing the resource.</returns>
        public GameGlobal Get(string filename, bool ts1)
        {
            string filepath;

            Files.Formats.IFF.IffFile iff = null;

            filename = filename.ToLowerInvariant();
            lock (Cache)
            {
                if (Cache.ContainsKey(filename))
                {
                    return(Cache[filename]);
                }

                if (!ts1)
                {
                    filepath = Path.Combine(Content.Get().BasePath, "objectdata/globals/" + filename + ".iff");

                    //if we can't load this let it throw an exception...
                    //probably sanity check this when we add user objects.
                    if (File.Exists(filepath))
                    {
                        iff = new Files.Formats.IFF.IffFile(filepath);
                    }
                }


                if (GlobalFar != null && iff == null)
                {
                    var Giff = new IffFile();

                    var bytes = GlobalFar.GetEntry(GlobalFar.GetAllEntries().FirstOrDefault(x => x.Key.ToLowerInvariant() == (filename + ".iff").ToLowerInvariant()));
                    using (var stream = new MemoryStream(bytes))
                    {
                        Giff.Read(stream);
                    }

                    if (Giff != null)
                    {
                        iff = Giff;
                    }
                }


                OTFFile otf = null;
                try
                {
                    otf = new OTFFile(Path.Combine(Content.Get().BasePath, "objectdata/globals/" + filename + ".otf"));
                }
                catch (IOException)
                {
                    //if we can't load an otf, it probably doesn't exist.
                }
                var resource = new GameGlobalResource(iff, otf);

                var item = new GameGlobal
                {
                    Resource = resource
                };

                Cache.Add(filename, item);

                return(item);
            }
        }
Ejemplo n.º 6
0
 public AvatarThumbnailProvider(Content contentManager)
     : base(contentManager, new TextureCodec(), new Regex(".*/thumbnails/.*\\.dat"))
 {
 }
 public AvatarAppearanceProvider(Content contentManager) : base(contentManager, new AppearanceCodec(),
                                                                new Regex(".*/appearances/.*\\.dat"),
                                                                new Regex("Avatar/Appearances/.*\\.apr"))
 {
 }