Added: HiRes images are now also applied to sprites.

Fixed: HiRes images should be loaded from subdirectories too.
Fixed: in some cases the editor was unable to locate existing "LoRes" images when loading HiRes images.
Disabled some HiRes-related warnings, because the editor doesn't track all sprites or graphics.
This commit is contained in:
MaxED 2016-03-22 22:24:33 +00:00
parent 07a4c5c51e
commit 6b4dc3a287
5 changed files with 42 additions and 18 deletions

View file

@ -1356,33 +1356,53 @@ namespace CodeImp.DoomBuilder.Data
// Go for all textures
foreach(HiResImage img in hiresimages)
{
bool replaced = false;
// Replace when HiRes image name exactly matches a regular texture name,
// or when regular texture filename is 8 or less chars long
//bool replaced = false;
// Replace texture?
if(textures.ContainsKey(img.LongName))
long hash = GetFullLongTextureName(img.LongName);
if(textures.ContainsKey(hash) && (hash == img.LongName || Path.GetFileNameWithoutExtension(textures[hash].Name).Length <= CLASIC_IMAGE_NAME_LENGTH))
{
HiResImage replacer = new HiResImage(img);
replacer.ApplySettings(textures[img.LongName]);
textures[img.LongName] = replacer;
replaced = true;
replacer.ApplySettings(textures[hash]);
textures[hash] = replacer;
//replaced = true;
// Add to preview manager
previews.AddImage(replacer);
counter++;
}
// Replace flat?
if(flats.ContainsKey(img.LongName))
hash = GetFullLongFlatName(img.LongName);
if(flats.ContainsKey(hash) && (hash == img.LongName || Path.GetFileNameWithoutExtension(flats[hash].Name).Length <= CLASIC_IMAGE_NAME_LENGTH))
{
HiResImage replacer = new HiResImage(img);
replacer.ApplySettings(flats[img.LongName]);
flats[img.LongName] = replacer;
replaced = true;
replacer.ApplySettings(flats[hash]);
flats[hash] = replacer;
//replaced = true;
// Add to preview manager
previews.AddImage(replacer);
counter++;
}
if(!replaced)
// Replace sprite?
if(sprites.ContainsKey(img.LongName))
{
HiResImage replacer = new HiResImage(img);
replacer.ApplySettings(sprites[img.LongName]);
sprites[img.LongName] = replacer;
//replaced = true;
// Add to preview manager
previews.AddImage(replacer);
counter++;
}
// We don't load any graphics and most of the sprites, so this can result in a ton of false warnings...
/*if(!replaced)
{
General.ErrorLogger.Add(ErrorType.Warning, "HiRes texture \"" + Path.Combine(dr.Location.GetDisplayName(), img.FilePathName.Replace(Path.AltDirectorySeparatorChar, Path.DirectorySeparatorChar)) + "\" does not override any existing texture or flat.");
dr.TextureSet.AddTexture(img);
@ -1395,7 +1415,7 @@ namespace CodeImp.DoomBuilder.Data
previews.AddImage(img);
}
counter++;
counter++;*/
}
}
}

View file

@ -214,8 +214,7 @@ namespace CodeImp.DoomBuilder.Data
try
{
// Find in hires directory
string path = Path.Combine(HIRES_DIR, Path.GetDirectoryName(name));
string filename = FindFirstFile(path, Path.GetFileName(name), false);
string filename = FindFirstFile(HIRES_DIR, name, true);
if(!string.IsNullOrEmpty(filename) && FileExists(filename))
{
hireslocation = location.GetDisplayName();

View file

@ -87,7 +87,12 @@ namespace CodeImp.DoomBuilder.Data
internal void ApplySettings(ImageData overridden)
{
// Copy all the names...
name = overridden.Name;
virtualname = overridden.VirtualName;
displayname = overridden.DisplayName;
longname = overridden.LongName;
isFlat = overridden.IsFlat;
overridesettingsapplied = true;

View file

@ -244,7 +244,7 @@ namespace CodeImp.DoomBuilder.Data
}
//mxd. This finds and returns a HiRes textue stream
public override Stream GetHiResTextureData(string pname, ref string hireslocation)
public override Stream GetHiResTextureData(string name, ref string hireslocation)
{
// Error when suspended
if(issuspended) throw new Exception("Data reader is suspended");
@ -253,12 +253,12 @@ namespace CodeImp.DoomBuilder.Data
// Note the backward order, because the last wad's images have priority
for(int i = wads.Count - 1; i >= 0; i--)
{
Stream data = wads[i].GetTextureData(pname, false, ref hireslocation);
Stream data = wads[i].GetTextureData(name, false, ref hireslocation);
if(data != null) return data;
}
// Find in HiRes directory
string filename = FindFirstFile(HIRES_DIR, pname, false);
string filename = FindFirstFile(HIRES_DIR, name, true);
if(!string.IsNullOrEmpty(filename) && FileExists(filename))
{
hireslocation = location.GetDisplayName();

View file

@ -239,14 +239,14 @@ namespace CodeImp.DoomBuilder.Data
public override IEnumerable<HiResImage> LoadHiResTextures()
{
// Go for all files
string[] files = GetAllFiles(HIRES_DIR, false);
string[] files = GetAllFiles(HIRES_DIR, true);
List<HiResImage> result = new List<HiResImage>(files.Length);
foreach(string f in files)
{
if(string.IsNullOrEmpty(Path.GetFileNameWithoutExtension(f)))
{
// Can't load image without name
General.ErrorLogger.Add(ErrorType.Error, "Can't load an unnamed HiRes texture from \"" + HIRES_DIR + "\". Please consider giving names to your resources.");
General.ErrorLogger.Add(ErrorType.Error, "Can't load an unnamed HiRes texture from \"" + Path.Combine(this.location.GetDisplayName(), HIRES_DIR) + "\". Please consider giving names to your resources.");
}
else
{