// This loads the sprites public override IEnumerable <ImageData> LoadSprites(Dictionary <string, TexturesParser> cachedparsers) { // Error when suspended if (issuspended) { throw new Exception("Data reader is suspended"); } Dictionary <long, ImageData> images = new Dictionary <long, ImageData>(); List <ImageData> imgset = new List <ImageData>(); // Load from wad files // Note the backward order, because the last wad's images have priority for (int i = wads.Count - 1; i >= 0; i--) { IEnumerable <ImageData> collection = wads[i].LoadSprites(cachedparsers); AddImagesToList(images, collection); } // Load TEXTURES lump file imgset.Clear(); string[] alltexturefiles = GetAllFilesWhichTitleStartsWith("", "TEXTURES", false); //mxd foreach (string texturesfile in alltexturefiles) { //mxd. Added TexturesParser caching string fullpath = Path.Combine(this.location.location, texturesfile); if (cachedparsers.ContainsKey(fullpath)) { // Make the textures foreach (TextureStructure t in cachedparsers[fullpath].Sprites) { imgset.Add(t.MakeImage()); } } else { MemoryStream filedata = LoadFile(texturesfile); TextResourceData data = new TextResourceData(this, filedata, texturesfile, true); //mxd cachedparsers.Add(fullpath, WADReader.LoadTEXTURESSprites(data, ref imgset)); //mxd filedata.Dispose(); } } // Add images from TEXTURES lump file AddImagesToList(images, imgset); return(new List <ImageData>(images.Values)); }
// This loads the textures public override IEnumerable <ImageData> LoadFlats(Dictionary <string, TexturesParser> cachedparsers) { Dictionary <long, ImageData> images = new Dictionary <long, ImageData>(); IEnumerable <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 the backward order, because the last wad's images have priority for (int i = wads.Count - 1; i >= 0; i--) { collection = wads[i].LoadFlats(cachedparsers); AddImagesToList(images, collection); } // Should we load the images in this directory as flats? if (rootflats) { collection = LoadDirectoryImages("", ImageDataFormat.DOOMFLAT, false); AddImagesToList(images, collection); } // Add images from flats directory collection = LoadDirectoryImages(FLATS_DIR, ImageDataFormat.DOOMFLAT, true); AddImagesToList(images, collection); // Load TEXTURES lump file string[] alltexturefiles = GetAllFilesWhichTitleStartsWith("", "TEXTURES", false); //mxd foreach (string texturesfile in alltexturefiles) { //mxd. Added TexturesParser caching string fullpath = Path.Combine(this.location.location, texturesfile); if (cachedparsers.ContainsKey(fullpath)) { // Make the textures foreach (TextureStructure t in cachedparsers[fullpath].Flats) { imgset.Add(t.MakeImage()); } } else { MemoryStream filedata = LoadFile(texturesfile); TextResourceData data = new TextResourceData(this, filedata, texturesfile, true); //mxd cachedparsers.Add(fullpath, WADReader.LoadTEXTURESFlats(data, ref imgset)); //mxd 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.AddFlat(img); } return(new List <ImageData>(images.Values)); }
// This loads the textures public override IEnumerable <ImageData> LoadTextures(PatchNames pnames, Dictionary <string, TexturesParser> cachedparsers) { // Error when suspended if (issuspended) { throw new Exception("Data reader is suspended"); } Dictionary <long, ImageData> images = new Dictionary <long, ImageData>(); IEnumerable <ImageData> collection; // Load from wad files (NOTE: backward order, because the last wad's images have priority) for (int i = wads.Count - 1; i >= 0; i--) { PatchNames wadpnames = wads[i].LoadPatchNames(); //mxd collection = wads[i].LoadTextures((wadpnames != null && wadpnames.Length > 0) ? wadpnames : pnames, cachedparsers); //mxd AddImagesToList(images, collection); } // Should we load the images in this directory as textures? if (roottextures) { collection = LoadDirectoryImages("", ImageDataFormat.DOOMPICTURE, false); AddImagesToList(images, collection); } // Load TEXTURE1 lump file List <ImageData> imgset = new List <ImageData>(); 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 files imgset.Clear(); string[] alltexturefiles = GetAllFilesWhichTitleStartsWith("", "TEXTURES", false); //mxd foreach (string texturesfile in alltexturefiles) { //mxd. Added TexturesParser caching string fullpath = Path.Combine(this.location.location, texturesfile); if (cachedparsers.ContainsKey(fullpath)) { // Make the textures foreach (TextureStructure t in cachedparsers[fullpath].Textures) { imgset.Add(t.MakeImage()); } } else { MemoryStream filedata = LoadFile(texturesfile); TextResourceData data = new TextResourceData(this, filedata, texturesfile, true); //mxd cachedparsers.Add(fullpath, WADReader.LoadTEXTURESTextures(data, ref imgset)); //mxd filedata.Dispose(); } } // Add images from TEXTURES lump file AddImagesToList(images, imgset); //mxd. Add images from texture directory. Textures defined in TEXTURES override ones in "textures" folder collection = LoadDirectoryImages(TEXTURES_DIR, ImageDataFormat.DOOMPICTURE, true); AddImagesToList(images, collection); // Add images to the container-specific texture set foreach (ImageData img in images.Values) { textureset.AddTexture(img); } return(new List <ImageData>(images.Values)); }