Added support for TEXTURES and DECORATE files that have different extensions (they will be loaded cumulatively)

This commit is contained in:
codeimp 2010-08-13 15:19:51 +00:00
parent 5f63667a66
commit 012673554d
5 changed files with 63 additions and 15 deletions

View file

@ -278,7 +278,13 @@ namespace CodeImp.DoomBuilder.Data
{
return files.GetAllFiles(path, subfolders).ToArray();
}
// This returns all files in a given directory that have the given file title
protected override string[] GetAllFilesWithTitle(string path, string title, bool subfolders)
{
return files.GetAllFilesWithTitle(path, title, subfolders).ToArray();
}
// This returns all files in a given directory that match the given extension
protected override string[] GetFilesWithExt(string path, string extension, bool subfolders)
{

View file

@ -274,7 +274,13 @@ namespace CodeImp.DoomBuilder.Data
{
return files.GetAllFiles(path, subfolders).ToArray();
}
// This returns all files in a given directory that have the given title
protected override string[] GetAllFilesWithTitle(string path, string title, bool subfolders)
{
return files.GetAllFilesWithTitle(path, title, subfolders).ToArray();
}
// This returns all files in a given directory that match the given extension
protected override string[] GetFilesWithExt(string path, string extension, bool subfolders)
{

View file

@ -202,20 +202,20 @@ namespace CodeImp.DoomBuilder.Data
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 texturesfile = FindFirstFile("TEXTURES", false);
if((texturesfile != null) && FileExists(texturesfile))
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);
@ -342,8 +342,8 @@ namespace CodeImp.DoomBuilder.Data
// Find in root directory
string filename = Path.GetFileName(pname);
string pathname = Path.GetDirectoryName(pname);
string foundfile = (filename.IndexOf('.') > -1) ? FindFirstFileWithExt(pathname, filename, false) : FindFirstFile(pathname, filename, false);
if((foundfile != null) && FileExists(foundfile))
string[] allfilenames = GetAllFilesWithTitle(pathname, filename, false);
foreach(string foundfile in allfilenames)
{
streams.Add(LoadFile(foundfile));
}
@ -406,10 +406,13 @@ namespace CodeImp.DoomBuilder.Data
// This must return true if the specified file exists
protected abstract bool FileExists(string filename);
// This must return all files in a given directory
protected abstract string[] GetAllFiles(string path, bool subfolders);
// This must return all files in a given directory that have the given file title
protected abstract string[] GetAllFilesWithTitle(string path, string title, bool subfolders);
// This must return all files in a given directory that match the given extension
protected abstract string[] GetFilesWithExt(string path, string extension, bool subfolders);

View file

@ -305,6 +305,7 @@ namespace CodeImp.DoomBuilder.Data
{
List<ImageData> images = new List<ImageData>();
string rangestart, rangeend;
int lumpindex;
Lump lump;
// Error when suspended
@ -322,16 +323,19 @@ namespace CodeImp.DoomBuilder.Data
// Load texture range
LoadTexturesRange(range.start, range.end, ref images, pnames);
}
// Load TEXTURES lump file
lump = file.FindLump("TEXTURES");
if(lump != null)
lumpindex = file.FindLumpIndex("TEXTURES");
while(lumpindex > -1)
{
MemoryStream filedata = new MemoryStream(lump.Stream.ReadAllBytes());
MemoryStream filedata = new MemoryStream(file.Lumps[lumpindex].Stream.ReadAllBytes());
WADReader.LoadHighresTextures(filedata, "TEXTURES", ref images, null, null);
filedata.Dispose();
// Find next
lumpindex = file.FindLumpIndex("TEXTURES", lumpindex + 1);
}
// Add images to the container-specific texture set
foreach(ImageData img in images)
textureset.AddTexture(img);

View file

@ -138,6 +138,35 @@ namespace CodeImp.DoomBuilder.IO
}
}
// This returns a list of all files that are in the given path and subdirectories and have the given title
public List<string> GetAllFilesWithTitle(string path, string title)
{
path = CorrectPath(path).ToLowerInvariant();
title = title.ToLowerInvariant();
List<string> files = new List<string>(entries.Length);
for(int i = 0; i < entries.Length; i++)
if(entries[i].path.StartsWith(path) && (entries[i].filetitle == title))
files.Add(entries[i].filepathname);
return files;
}
// This returns a list of all files that are in the given path (optionally in subdirectories) and have the given title
public List<string> GetAllFilesWithTitle(string path, string title, bool subdirectories)
{
if(subdirectories)
return GetAllFilesWithTitle(path, title);
else
{
path = CorrectPath(path).ToLowerInvariant();
title = title.ToLowerInvariant();
List<string> files = new List<string>(entries.Length);
for(int i = 0; i < entries.Length; i++)
if((entries[i].path == path) && (entries[i].filetitle == title))
files.Add(entries[i].filepathname);
return files;
}
}
// This returns a list of all files that are in the given path and subdirectories and have the given extension
public List<string> GetAllFiles(string path, string extension)
{