Ejemplo n.º 1
0
        // This loads the textures
        public override ICollection <ImageData> LoadTextures(PatchNames pnames)
        {
            Dictionary <long, ImageData> images = new Dictionary <long, ImageData>();
            ICollection <ImageData>      collection;
            List <ImageData>             imgset = new List <ImageData>();

            // Error when suspended
            if (issuspended)
            {
                throw new Exception("Data reader is suspended");
            }

            // Load from wad files (NOTE: backward order, because the last wad's images have priority)
            for (int i = wads.Count - 1; i >= 0; i--)
            {
                collection = wads[i].LoadTextures(pnames);
                AddImagesToList(images, collection);
            }

            // Should we load the images in this directory as textures?
            if (roottextures)
            {
                collection = LoadDirectoryImages("", ImageDataFormat.DOOMPICTURE, false);
                AddImagesToList(images, collection);
            }

            // Add images from texture directory
            collection = LoadDirectoryImages(TEXTURES_DIR, ImageDataFormat.DOOMPICTURE, true);
            AddImagesToList(images, collection);

            // Load TEXTURE1 lump file
            imgset.Clear();
            string texture1file = FindFirstFile("TEXTURE1", false);

            if ((texture1file != null) && FileExists(texture1file))
            {
                MemoryStream filedata = LoadFile(texture1file);
                WADReader.LoadTextureSet("TEXTURE1", filedata, ref imgset, pnames);
                filedata.Dispose();
            }

            // Load TEXTURE2 lump file
            string texture2file = FindFirstFile("TEXTURE2", false);

            if ((texture2file != null) && FileExists(texture2file))
            {
                MemoryStream filedata = LoadFile(texture2file);
                WADReader.LoadTextureSet("TEXTURE2", filedata, ref imgset, pnames);
                filedata.Dispose();
            }

            // Add images from TEXTURE1 and TEXTURE2 lump files
            AddImagesToList(images, imgset);

            // Load TEXTURES lump file
            imgset.Clear();
            string[] alltexturefiles = GetAllFilesWithTitle("", "TEXTURES", false);
            foreach (string texturesfile in alltexturefiles)
            {
                MemoryStream filedata = LoadFile(texturesfile);
                WADReader.LoadHighresTextures(filedata, texturesfile, ref imgset, images, null);
                filedata.Dispose();
            }

            // Add images from TEXTURES lump file
            AddImagesToList(images, imgset);

            // Add images to the container-specific texture set
            foreach (ImageData img in images.Values)
            {
                textureset.AddImage(img);
            }

            return(new List <ImageData>(images.Values));
        }