From 4aefe78975562d785282f59b6c2ea365b0bea11c Mon Sep 17 00:00:00 2001 From: MaxED Date: Mon, 14 Mar 2016 21:53:53 +0000 Subject: [PATCH] Fixed source window freezing while Open Map window was open when opening a wad by dragging & dropping it on the editor's main window. Image loading-related warnings and errors now display more information about the image resource. --- Source/Core/Config/ResourceTextureSet.cs | 4 +- Source/Core/Data/DataLocation.cs | 22 +++++++- Source/Core/Data/DataManager.cs | 68 +++++++++++++++--------- Source/Core/Data/DataReader.cs | 10 ++-- Source/Core/Data/DirectoryReader.cs | 50 ++++++++++++----- Source/Core/Data/FlatImage.cs | 5 +- Source/Core/Data/HiResImage.cs | 7 +-- Source/Core/Data/PK3Reader.cs | 49 ++++++++++++----- Source/Core/Data/PK3StructuredReader.cs | 6 +-- Source/Core/Data/SimpleTextureImage.cs | 5 +- Source/Core/Data/SpriteImage.cs | 5 +- Source/Core/Data/TEXTURESImage.cs | 6 +-- Source/Core/Data/TextureImage.cs | 5 +- Source/Core/Data/WADReader.cs | 54 +++++++++++++------ Source/Core/Windows/MainForm.cs | 30 ++++++++--- Source/Core/ZDoom/ActorStructure.cs | 4 +- Source/Core/ZDoom/StateStructure.cs | 4 +- Source/Core/ZDoom/ZDTextParser.cs | 4 +- 18 files changed, 232 insertions(+), 106 deletions(-) diff --git a/Source/Core/Config/ResourceTextureSet.cs b/Source/Core/Config/ResourceTextureSet.cs index c2ac788b..6ceca925 100644 --- a/Source/Core/Config/ResourceTextureSet.cs +++ b/Source/Core/Config/ResourceTextureSet.cs @@ -67,7 +67,7 @@ namespace CodeImp.DoomBuilder.Config { //mxd. Wad duplicates are checked by WadReader if(location.type != DataLocation.RESOURCE_WAD && textures.ContainsKey(image.LongName) && !image.HasPatchWithSameName) - General.ErrorLogger.Add(ErrorType.Warning, "Texture \"" + image.Name + "\" is double defined in resource \"" + this.Location.location + "\"."); + General.ErrorLogger.Add(ErrorType.Warning, "Texture \"" + image.Name + "\" is double defined in resource \"" + this.Location.GetDisplayName() + "\"."); textures[image.LongName] = image; } @@ -76,7 +76,7 @@ namespace CodeImp.DoomBuilder.Config { //mxd. Wad duplicates are checked by WadReader if(location.type != DataLocation.RESOURCE_WAD && flats.ContainsKey(image.LongName) && (!General.Map.Config.MixTexturesFlats || !image.HasPatchWithSameName)) - General.ErrorLogger.Add(ErrorType.Warning, "Flat \"" + image.Name + "\" is double defined in resource \"" + this.Location.location + "\"."); + General.ErrorLogger.Add(ErrorType.Warning, "Flat \"" + image.Name + "\" is double defined in resource \"" + this.Location.GetDisplayName() + "\"."); flats[image.LongName] = image; } diff --git a/Source/Core/Data/DataLocation.cs b/Source/Core/Data/DataLocation.cs index bbcddc2d..299259d0 100644 --- a/Source/Core/Data/DataLocation.cs +++ b/Source/Core/Data/DataLocation.cs @@ -33,6 +33,7 @@ namespace CodeImp.DoomBuilder.Data // Members public int type; public string location; + private string initiallocation; //mxd. Stores intial path inside a PK3/PK7. For display purposes only! private string name; //mxd public bool option1; public bool option2; @@ -44,12 +45,26 @@ namespace CodeImp.DoomBuilder.Data // Initialize this.type = type; this.location = location; + this.initiallocation = string.Empty; //mxd this.option1 = option1; this.option2 = option2; this.notfortesting = notfortesting; this.name = string.Empty; //mxd } + //mxd. Constructor for WADs inside of PK3s + internal DataLocation(int type, string location, string initiallocation, bool option1, bool option2, bool notfortesting) + { + // Initialize + this.type = type; + this.location = location; + this.initiallocation = initiallocation; + this.option1 = option1; + this.option2 = option2; + this.notfortesting = notfortesting; + this.name = string.Empty; + } + // This displays the struct as string public override string ToString() { @@ -57,8 +72,8 @@ namespace CodeImp.DoomBuilder.Data return location; } - //mxd. This returns short location name - public string GetShortName() + //mxd. This returns short location name. May not correspond to actual file location! Use for display purposes only! + public string GetDisplayName() { if(string.IsNullOrEmpty(name)) { @@ -70,6 +85,9 @@ namespace CodeImp.DoomBuilder.Data break; case RESOURCE_WAD: + name = (!string.IsNullOrEmpty(initiallocation) ? initiallocation : Path.GetFileName(location)); + break; + case RESOURCE_PK3: name = Path.GetFileName(location); break; diff --git a/Source/Core/Data/DataManager.cs b/Source/Core/Data/DataManager.cs index a16caec1..d55087b4 100644 --- a/Source/Core/Data/DataManager.cs +++ b/Source/Core/Data/DataManager.cs @@ -1025,13 +1025,13 @@ namespace CodeImp.DoomBuilder.Data } // This returns a specific patch stream - internal Stream GetPatchData(string pname, bool longname) + internal Stream GetPatchData(string pname, bool longname, ref string patchlocation) { // Go for all opened containers for(int i = containers.Count - 1; i > -1; i--) { // This contain provides this patch? - Stream patch = containers[i].GetPatchData(pname, longname); + Stream patch = containers[i].GetPatchData(pname, longname, ref patchlocation); if(patch != null) return patch; } @@ -1040,13 +1040,13 @@ namespace CodeImp.DoomBuilder.Data } // This returns a specific texture stream - internal Stream GetTextureData(string pname, bool longname) + internal Stream GetTextureData(string pname, bool longname, ref string texturelocation) { // Go for all opened containers for(int i = containers.Count - 1; i >= 0; i--) { // This container provides this patch? - Stream patch = containers[i].GetTextureData(pname, longname); + Stream patch = containers[i].GetTextureData(pname, longname, ref texturelocation); if(patch != null) return patch; } @@ -1251,13 +1251,13 @@ namespace CodeImp.DoomBuilder.Data } // This returns a specific flat stream - internal Stream GetFlatData(string pname, bool longname) + internal Stream GetFlatData(string pname, bool longname, ref string flatlocation) { // Go for all opened containers for(int i = containers.Count - 1; i >= 0; i--) { // This contain provides this flat? - Stream flat = containers[i].GetFlatData(pname, longname); + Stream flat = containers[i].GetFlatData(pname, longname, ref flatlocation); if(flat != null) return flat; } @@ -1374,7 +1374,7 @@ namespace CodeImp.DoomBuilder.Data if(!replaced) { - General.ErrorLogger.Add(ErrorType.Warning, "HiRes texture \"" + Path.Combine(dr.Location.GetShortName(), img.FilePathName) + "\" does not override any existing texture or flat."); + General.ErrorLogger.Add(ErrorType.Warning, "HiRes texture \"" + Path.Combine(dr.Location.GetDisplayName(), img.FilePathName) + "\" does not override any existing texture or flat."); dr.TextureSet.AddTexture(img); } @@ -1388,13 +1388,13 @@ namespace CodeImp.DoomBuilder.Data } //mxd. This returns a specific HiRes texture stream - internal Stream GetHiResTextureData(string name) + internal Stream GetHiResTextureData(string name, ref string hireslocation) { // Go for all opened containers for(int i = containers.Count - 1; i >= 0; i--) { // This container provides this texture? - Stream data = containers[i].GetHiResTextureData(name); + Stream data = containers[i].GetHiResTextureData(name, ref hireslocation); if(data != null) return data; } @@ -1446,17 +1446,30 @@ namespace CodeImp.DoomBuilder.Data // Sprite not in our collection yet? if(!sprites.ContainsKey(ti.SpriteLongName)) { - // Find sprite data - Stream spritedata = GetSpriteData(ti.Sprite); - if(spritedata != null) + //mxd. Go for all opened containers + bool spritefound = false; + if(!string.IsNullOrEmpty(ti.Sprite)) + { + for(int i = containers.Count - 1; i >= 0; i--) + { + // This contain provides this sprite? + if(containers[i].GetSpriteExists(ti.Sprite)) + { + spritefound = true; + break; + } + } + } + + if(spritefound) { // Make new sprite image image = new SpriteImage(ti.Sprite); // Add to collection sprites.Add(ti.SpriteLongName, image); - } - else //mxd + } + else { General.ErrorLogger.Add(ErrorType.Error, "Missing sprite lump \"" + ti.Sprite + "\". Forgot to include required resources?"); } @@ -1475,7 +1488,7 @@ namespace CodeImp.DoomBuilder.Data } // This returns a specific patch stream - internal Stream GetSpriteData(string pname) + internal Stream GetSpriteData(string pname, ref string spritelocation) { if(!string.IsNullOrEmpty(pname)) { @@ -1483,7 +1496,7 @@ namespace CodeImp.DoomBuilder.Data for(int i = containers.Count - 1; i >= 0; i--) { // This contain provides this patch? - Stream spritedata = containers[i].GetSpriteData(pname); + Stream spritedata = containers[i].GetSpriteData(pname, ref spritelocation); if(spritedata != null) return spritedata; } } @@ -1578,18 +1591,23 @@ namespace CodeImp.DoomBuilder.Data } else { - Stream spritedata = null; - - // Go for all opened containers - for(int i = containers.Count - 1; i >= 0; i--) + //mxd. Go for all opened containers + bool spritefound = false; + if(!string.IsNullOrEmpty(name)) { - // This container provides this sprite? - spritedata = containers[i].GetSpriteData(name); - if(spritedata != null) break; + for(int i = containers.Count - 1; i >= 0; i--) + { + // This contain provides this sprite? + if(containers[i].GetSpriteExists(name)) + { + spritefound = true; + break; + } + } } // Found anything? - if(spritedata != null) + if(spritefound) { // Make new sprite image SpriteImage image = new SpriteImage(name); @@ -2051,7 +2069,7 @@ namespace CodeImp.DoomBuilder.Data foreach(KeyValuePair g in parser.Entries) { if(modeldefentriesbyname.ContainsKey(g.Key)) - General.ErrorLogger.Add(ErrorType.Warning, "Model definition for actor \"" + g.Key + "\" is double defined in \"" + Path.Combine(data.Source.Location.GetShortName(), data.Filename) + "\""); + General.ErrorLogger.Add(ErrorType.Warning, "Model definition for actor \"" + g.Key + "\" is double defined in \"" + Path.Combine(data.Source.Location.GetDisplayName(), data.Filename) + "\""); modeldefentriesbyname[g.Key] = g.Value; } diff --git a/Source/Core/Data/DataReader.cs b/Source/Core/Data/DataReader.cs index a3be5e1a..cfb2a870 100644 --- a/Source/Core/Data/DataReader.cs +++ b/Source/Core/Data/DataReader.cs @@ -172,16 +172,16 @@ namespace CodeImp.DoomBuilder.Data public abstract PatchNames LoadPatchNames(); // When implemented, this returns the patch lump - public abstract Stream GetPatchData(string pname, bool longname); + public abstract Stream GetPatchData(string pname, bool longname, ref string patchlocation); // When implemented, this returns the texture lump - public abstract Stream GetTextureData(string pname, bool longname); + public abstract Stream GetTextureData(string pname, bool longname, ref string texturelocation); // When implemented, this loads the textures public abstract IEnumerable LoadTextures(PatchNames pnames, Dictionary cachedparsers); //mxd. When implemented, this returns the HiRes texture lump - public abstract Stream GetHiResTextureData(string pname); + public abstract Stream GetHiResTextureData(string pname, ref string hireslocation); //mxd. When implemented, this loads the HiRes textures public abstract IEnumerable LoadHiResTextures(); @@ -194,7 +194,7 @@ namespace CodeImp.DoomBuilder.Data public abstract IEnumerable LoadFlats(Dictionary cachedparsers); // When implemented, this returns the flat lump - public abstract Stream GetFlatData(string pname, bool longname); + public abstract Stream GetFlatData(string pname, bool longname, ref string flatlocation); #endregion @@ -204,7 +204,7 @@ namespace CodeImp.DoomBuilder.Data public abstract IEnumerable LoadSprites(Dictionary cachedparsers); // When implemented, this returns the sprite lump - public abstract Stream GetSpriteData(string pname); + public abstract Stream GetSpriteData(string pname, ref string spritelocation); // When implemented, this checks if the given sprite lump exists public abstract bool GetSpriteExists(string pname); diff --git a/Source/Core/Data/DirectoryReader.cs b/Source/Core/Data/DirectoryReader.cs index 6713b516..6b1a46a3 100644 --- a/Source/Core/Data/DirectoryReader.cs +++ b/Source/Core/Data/DirectoryReader.cs @@ -79,7 +79,7 @@ namespace CodeImp.DoomBuilder.Data #region ================== Textures // This finds and returns a patch stream - public override Stream GetPatchData(string pname, bool longname) + public override Stream GetPatchData(string pname, bool longname, ref string patchlocation) { // Error when suspended if(issuspended) throw new Exception("Data reader is suspended"); @@ -90,7 +90,7 @@ namespace CodeImp.DoomBuilder.Data { for(int i = wads.Count - 1; i > -1; i--) { - Stream data = wads[i].GetPatchData(pname, false); + Stream data = wads[i].GetPatchData(pname, false, ref patchlocation); if(data != null) return data; } } @@ -101,9 +101,15 @@ namespace CodeImp.DoomBuilder.Data { //mxd. Long names are absolute pname = pname.Replace(Path.AltDirectorySeparatorChar, Path.DirectorySeparatorChar); - return (FileExists(pname) ? LoadFile(pname) : null); + if(FileExists(pname)) + { + patchlocation = location.GetDisplayName(); + return LoadFile(pname); + } + return null; } - else if(General.Map.Config.MixTexturesFlats) + + if(General.Map.Config.MixTexturesFlats) { //mxd. Find in directories ZDoom expects them to be string dir = Path.GetDirectoryName(pname); @@ -112,8 +118,11 @@ namespace CodeImp.DoomBuilder.Data { string path = Path.Combine(loc, dir); string filename = FindFirstFile(path, name, true); - if(!string.IsNullOrEmpty(filename) && FileExists(filename)) + if(!string.IsNullOrEmpty(filename) && FileExists(filename)) + { + patchlocation = location.GetDisplayName(); //mxd return LoadFile(filename); + } } } else @@ -122,7 +131,10 @@ namespace CodeImp.DoomBuilder.Data string path = Path.Combine(PATCHES_DIR, Path.GetDirectoryName(pname)); string filename = FindFirstFile(path, Path.GetFileName(pname), true); if(!string.IsNullOrEmpty(filename) && FileExists(filename)) + { + patchlocation = location.GetDisplayName(); //mxd return LoadFile(filename); + } } } catch(Exception e) @@ -135,7 +147,7 @@ namespace CodeImp.DoomBuilder.Data } // This finds and returns a textue stream - public override Stream GetTextureData(string pname, bool longname) + public override Stream GetTextureData(string pname, bool longname, ref string texturelocation) { // Error when suspended if(issuspended) throw new Exception("Data reader is suspended"); @@ -146,7 +158,7 @@ namespace CodeImp.DoomBuilder.Data { for(int i = wads.Count - 1; i >= 0; i--) { - Stream data = wads[i].GetTextureData(pname, false); + Stream data = wads[i].GetTextureData(pname, false, ref texturelocation); if(data != null) return data; } } @@ -157,15 +169,23 @@ namespace CodeImp.DoomBuilder.Data if(longname) { pname = pname.Replace(Path.AltDirectorySeparatorChar, Path.DirectorySeparatorChar); - return (FileExists(pname) ? LoadFile(pname) : null); + if(FileExists(pname)) + { + texturelocation = location.GetDisplayName(); + return LoadFile(pname); + } + return null; } else { // Find in textures directory string path = Path.Combine(TEXTURES_DIR, Path.GetDirectoryName(pname)); string filename = FindFirstFile(path, Path.GetFileName(pname), true); - if(!string.IsNullOrEmpty(filename) && FileExists(filename)) + if(!string.IsNullOrEmpty(filename) && FileExists(filename)) + { + texturelocation = location.GetDisplayName(); //mxd return LoadFile(filename); + } } } catch(Exception e) @@ -178,7 +198,7 @@ namespace CodeImp.DoomBuilder.Data } //mxd. This finds and returns a HiRes textue stream - public override Stream GetHiResTextureData(string name) + public override Stream GetHiResTextureData(string name, ref string hireslocation) { // Error when suspended if(issuspended) throw new Exception("Data reader is suspended"); @@ -187,7 +207,7 @@ 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].GetHiResTextureData(name); + Stream data = wads[i].GetHiResTextureData(name, ref hireslocation); if(data != null) return data; } @@ -197,7 +217,10 @@ namespace CodeImp.DoomBuilder.Data string path = Path.Combine(HIRES_DIR, Path.GetDirectoryName(name)); string filename = FindFirstFile(path, Path.GetFileName(name), false); if(!string.IsNullOrEmpty(filename) && FileExists(filename)) + { + hireslocation = location.GetDisplayName(); return LoadFile(filename); + } } catch(Exception e) { @@ -246,7 +269,7 @@ namespace CodeImp.DoomBuilder.Data #region ================== Sprites // This finds and returns a sprite stream - public override Stream GetSpriteData(string pname) + public override Stream GetSpriteData(string pname, ref string spritelocation) { // Error when suspended if(issuspended) throw new Exception("Data reader is suspended"); @@ -254,7 +277,7 @@ namespace CodeImp.DoomBuilder.Data // Find in any of the wad files for(int i = wads.Count - 1; i >= 0; i--) { - Stream sprite = wads[i].GetSpriteData(pname); + Stream sprite = wads[i].GetSpriteData(pname, ref spritelocation); if(sprite != null) return sprite; } @@ -265,6 +288,7 @@ namespace CodeImp.DoomBuilder.Data string filename = FindFirstFile(path, Path.GetFileName(pname), true); if((filename != null) && FileExists(filename)) { + spritelocation = location.GetDisplayName(); //mxd return LoadFile(filename); } } diff --git a/Source/Core/Data/FlatImage.cs b/Source/Core/Data/FlatImage.cs index 46bf27a0..d03f9e05 100644 --- a/Source/Core/Data/FlatImage.cs +++ b/Source/Core/Data/FlatImage.cs @@ -53,7 +53,8 @@ namespace CodeImp.DoomBuilder.Data lock(this) { // Get the lump data stream - Stream lumpdata = General.Map.Data.GetFlatData(Name, hasLongName); + string flatlocation = string.Empty; //mxd + Stream lumpdata = General.Map.Data.GetFlatData(Name, hasLongName, ref flatlocation); if(lumpdata != null) { // Copy lump data to memory @@ -68,7 +69,7 @@ namespace CodeImp.DoomBuilder.Data if(reader is UnknownImageReader) { // Data is in an unknown format! - General.ErrorLogger.Add(ErrorType.Error, "Flat lump \"" + Name + "\" data format could not be read. Does this lump contain valid picture data at all?"); + General.ErrorLogger.Add(ErrorType.Error, "Flat lump \"" + Path.Combine(flatlocation, Name) + "\" data format could not be read. Does this lump contain valid picture data at all?"); bitmap = null; } else diff --git a/Source/Core/Data/HiResImage.cs b/Source/Core/Data/HiResImage.cs index 5d2f5d7c..f9115a4d 100644 --- a/Source/Core/Data/HiResImage.cs +++ b/Source/Core/Data/HiResImage.cs @@ -92,7 +92,8 @@ namespace CodeImp.DoomBuilder.Data { // Get the patch data stream if(bitmap != null) bitmap.Dispose(); bitmap = null; - Stream data = General.Map.Data.GetHiResTextureData(shortname); + string sourcelocation = string.Empty; + Stream data = General.Map.Data.GetHiResTextureData(shortname, ref sourcelocation); if(data != null) { // Copy patch data to memory @@ -119,7 +120,7 @@ namespace CodeImp.DoomBuilder.Data // Not loaded? if(bitmap == null) { - General.ErrorLogger.Add(ErrorType.Error, "Image lump \"" + shortname + "\" data format could not be read, while loading texture \"" + this.Name + "\". Does this lump contain valid picture data at all?"); + General.ErrorLogger.Add(ErrorType.Error, "Image lump \"" + Path.Combine(sourcelocation, shortname) + "\" data format could not be read, while loading HiRes texture \"" + this.Name + "\". Does this lump contain valid picture data at all?"); loadfailed = true; } else @@ -144,7 +145,7 @@ namespace CodeImp.DoomBuilder.Data } else { - General.ErrorLogger.Add(ErrorType.Error, "Image lump \"" + shortname + "\" could not be found, while loading texture \"" + this.Name + "\". Did you forget to include required resources?"); + General.ErrorLogger.Add(ErrorType.Error, "Image lump \"" + shortname + "\" could not be found, while loading HiRes texture \"" + this.Name + "\". Did you forget to include required resources?"); loadfailed = true; } diff --git a/Source/Core/Data/PK3Reader.cs b/Source/Core/Data/PK3Reader.cs index 8b1ec9da..14a9c583 100644 --- a/Source/Core/Data/PK3Reader.cs +++ b/Source/Core/Data/PK3Reader.cs @@ -150,7 +150,7 @@ namespace CodeImp.DoomBuilder.Data #region ================== Textures // This finds and returns a patch stream - public override Stream GetPatchData(string pname, bool longname) + public override Stream GetPatchData(string pname, bool longname, ref string patchlocation) { // Error when suspended if(issuspended) throw new Exception("Data reader is suspended"); @@ -161,14 +161,19 @@ namespace CodeImp.DoomBuilder.Data { for(int i = wads.Count - 1; i >= 0; i--) { - Stream data = wads[i].GetPatchData(pname, false); + Stream data = wads[i].GetPatchData(pname, false, ref patchlocation); if(data != null) return data; } } else { //mxd. Long names are absolute - return (FileExists(pname) ? LoadFile(pname) : null); + if(FileExists(pname)) + { + patchlocation = location.GetDisplayName(); + return LoadFile(pname); + } + return null; } if(General.Map.Config.MixTexturesFlats) @@ -177,8 +182,11 @@ namespace CodeImp.DoomBuilder.Data foreach(string loc in PatchLocations) { string filename = FindFirstFile(loc, pname, true); - if((filename != null) && FileExists(filename)) + if((filename != null) && FileExists(filename)) + { + patchlocation = location.GetDisplayName(); return LoadFile(filename); + } } } else @@ -186,7 +194,10 @@ namespace CodeImp.DoomBuilder.Data // Find in patches directory string filename = FindFirstFile(PATCHES_DIR, pname, true); if((filename != null) && FileExists(filename)) + { + patchlocation = location.GetDisplayName(); return LoadFile(filename); + } } // Nothing found @@ -194,7 +205,7 @@ namespace CodeImp.DoomBuilder.Data } // This finds and returns a textue stream - public override Stream GetTextureData(string pname, bool longname) + public override Stream GetTextureData(string pname, bool longname, ref string texturelocation) { // Error when suspended if(issuspended) throw new Exception("Data reader is suspended"); @@ -205,27 +216,35 @@ namespace CodeImp.DoomBuilder.Data { for(int i = wads.Count - 1; i >= 0; i--) { - Stream data = wads[i].GetTextureData(pname, false); + Stream data = wads[i].GetTextureData(pname, false, ref texturelocation); if(data != null) return data; } } else { //mxd. Long names are absolute - return (FileExists(pname) ? LoadFile(pname) : null); + if(FileExists(pname)) + { + texturelocation = location.GetDisplayName(); + return LoadFile(pname); + } + return null; } // Find in textures directory string filename = FindFirstFile(TEXTURES_DIR, pname, true); if(!string.IsNullOrEmpty(filename) && FileExists(filename)) + { + texturelocation = location.GetDisplayName(); return LoadFile(filename); + } // Nothing found return null; } //mxd. This finds and returns a HiRes textue stream - public override Stream GetHiResTextureData(string pname) + public override Stream GetHiResTextureData(string pname, ref string hireslocation) { // Error when suspended if(issuspended) throw new Exception("Data reader is suspended"); @@ -234,14 +253,17 @@ 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); + Stream data = wads[i].GetTextureData(pname, false, ref hireslocation); if(data != null) return data; } // Find in HiRes directory string filename = FindFirstFile(HIRES_DIR, pname, false); if(!string.IsNullOrEmpty(filename) && FileExists(filename)) + { + hireslocation = location.GetDisplayName(); return LoadFile(filename); + } // Nothing found return null; @@ -277,7 +299,7 @@ namespace CodeImp.DoomBuilder.Data #region ================== Sprites // This finds and returns a sprite stream - public override Stream GetSpriteData(string pname) + public override Stream GetSpriteData(string pname, ref string spritelocation) { string pfilename = pname.Replace('\\', '^'); @@ -287,7 +309,7 @@ namespace CodeImp.DoomBuilder.Data // Find in any of the wad files for(int i = wads.Count - 1; i >= 0; i--) { - Stream sprite = wads[i].GetSpriteData(pname); + Stream sprite = wads[i].GetSpriteData(pname, ref spritelocation); if(sprite != null) return sprite; } @@ -295,6 +317,7 @@ namespace CodeImp.DoomBuilder.Data string filename = FindFirstFile(SPRITES_DIR, pfilename, true); if((filename != null) && FileExists(filename)) { + spritelocation = location.GetDisplayName(); //mxd return LoadFile(filename); } @@ -477,7 +500,7 @@ namespace CodeImp.DoomBuilder.Data if(filedata == null) { //mxd - General.ErrorLogger.Add(ErrorType.Error, "Cannot find the file \"" + filename + "\" in archive \"" + location.location + "\"."); + General.ErrorLogger.Add(ErrorType.Error, "Cannot find the file \"" + filename + "\" in archive \"" + location.GetDisplayName() + "\"."); return null; } @@ -509,7 +532,7 @@ namespace CodeImp.DoomBuilder.Data case 60: case 62: case 124: - General.ErrorLogger.Add(ErrorType.Error, "Error in \"" + location.location + "\": unsupported character \"" + c + "\" in path \"" + path + "\". File loading was skipped."); + General.ErrorLogger.Add(ErrorType.Error, "Error in \"" + location.GetDisplayName() + "\": unsupported character \"" + c + "\" in path \"" + path + "\". File loading was skipped."); return false; default: diff --git a/Source/Core/Data/PK3StructuredReader.cs b/Source/Core/Data/PK3StructuredReader.cs index a6cb81ac..913dc57b 100644 --- a/Source/Core/Data/PK3StructuredReader.cs +++ b/Source/Core/Data/PK3StructuredReader.cs @@ -78,7 +78,7 @@ namespace CodeImp.DoomBuilder.Data foreach(string w in wadfiles) { string tempfile = CreateTempFile(w); - DataLocation wdl = new DataLocation(DataLocation.RESOURCE_WAD, tempfile, false, false, true); + DataLocation wdl = new DataLocation(DataLocation.RESOURCE_WAD, tempfile, Path.Combine(location.GetDisplayName(), Path.GetFileName(w)), false, false, true); wads.Add(new WADReader(wdl)); } } @@ -354,7 +354,7 @@ namespace CodeImp.DoomBuilder.Data } //mxd. - public override Stream GetFlatData(string pname, bool longname) + public override Stream GetFlatData(string pname, bool longname, ref string flatlocation) { // Error when suspended if(issuspended) throw new Exception("Data reader is suspended"); @@ -365,7 +365,7 @@ namespace CodeImp.DoomBuilder.Data { for(int i = wads.Count - 1; i > -1; i--) { - Stream data = wads[i].GetFlatData(pname, false); + Stream data = wads[i].GetFlatData(pname, false, ref flatlocation); if(data != null) return data; } } diff --git a/Source/Core/Data/SimpleTextureImage.cs b/Source/Core/Data/SimpleTextureImage.cs index ea71901b..c5d129f5 100644 --- a/Source/Core/Data/SimpleTextureImage.cs +++ b/Source/Core/Data/SimpleTextureImage.cs @@ -66,7 +66,8 @@ namespace CodeImp.DoomBuilder.Data { // Get the patch data stream if(bitmap != null) bitmap.Dispose(); bitmap = null; - Stream patchdata = General.Map.Data.GetTextureData(lumpname, hasLongName); + string patchlocation = string.Empty; //mxd + Stream patchdata = General.Map.Data.GetTextureData(lumpname, hasLongName, ref patchlocation); if(patchdata != null) { // Copy patch data to memory @@ -93,7 +94,7 @@ namespace CodeImp.DoomBuilder.Data // Not loaded? if(bitmap == null) { - General.ErrorLogger.Add(ErrorType.Error, "Image lump \"" + lumpname + "\" data format could not be read, while loading texture \"" + this.Name + "\". Does this lump contain valid picture data at all?"); + General.ErrorLogger.Add(ErrorType.Error, "Image lump \"" + Path.Combine(patchlocation, lumpname) + "\" data format could not be read, while loading texture \"" + this.Name + "\". Does this lump contain valid picture data at all?"); loadfailed = true; } else diff --git a/Source/Core/Data/SpriteImage.cs b/Source/Core/Data/SpriteImage.cs index 458a2192..9d8fb4be 100644 --- a/Source/Core/Data/SpriteImage.cs +++ b/Source/Core/Data/SpriteImage.cs @@ -78,7 +78,8 @@ namespace CodeImp.DoomBuilder.Data lock(this) { // Get the lump data stream - Stream lumpdata = General.Map.Data.GetSpriteData(Name); + string spritelocation = string.Empty; //mxd + Stream lumpdata = General.Map.Data.GetSpriteData(Name, ref spritelocation); if(lumpdata != null) { // Copy lump data to memory @@ -93,7 +94,7 @@ namespace CodeImp.DoomBuilder.Data if(reader is UnknownImageReader) { // Data is in an unknown format! - General.ErrorLogger.Add(ErrorType.Error, "Sprite lump \"" + Name + "\" data format could not be read. Does this lump contain valid picture data at all?"); + General.ErrorLogger.Add(ErrorType.Error, "Sprite lump \"" + Path.Combine(spritelocation, Name) + "\" data format could not be read. Does this lump contain valid picture data at all?"); bitmap = null; } else diff --git a/Source/Core/Data/TEXTURESImage.cs b/Source/Core/Data/TEXTURESImage.cs index d6761912..c39986bd 100644 --- a/Source/Core/Data/TEXTURESImage.cs +++ b/Source/Core/Data/TEXTURESImage.cs @@ -146,8 +146,8 @@ namespace CodeImp.DoomBuilder.Data if(p.skip) continue; // Get the patch data stream - Stream patchdata = General.Map.Data.GetPatchData(p.lumpname, p.haslongname); - + string patchlocation = string.Empty; //mxd + Stream patchdata = General.Map.Data.GetPatchData(p.lumpname, p.haslongname, ref patchlocation); if(patchdata != null) { // Copy patch data to memory @@ -170,7 +170,7 @@ namespace CodeImp.DoomBuilder.Data if(reader is UnknownImageReader) { // Data is in an unknown format! - General.ErrorLogger.Add(ErrorType.Error, "Patch lump \"" + p.lumpname + "\" data format could not be read, while loading texture \"" + this.Name + "\""); + General.ErrorLogger.Add(ErrorType.Error, "Patch lump \"" + Path.Combine(patchlocation, p.lumpname) + "\" data format could not be read, while loading texture \"" + this.Name + "\""); missingpatches++; //mxd } } diff --git a/Source/Core/Data/TextureImage.cs b/Source/Core/Data/TextureImage.cs index 6f82fb59..3866974d 100644 --- a/Source/Core/Data/TextureImage.cs +++ b/Source/Core/Data/TextureImage.cs @@ -102,7 +102,8 @@ namespace CodeImp.DoomBuilder.Data foreach(TexturePatch p in patches) { // Get the patch data stream - Stream patchdata = General.Map.Data.GetPatchData(p.lumpname, p.haslongname); + string patchlocation = string.Empty; //mxd + Stream patchdata = General.Map.Data.GetPatchData(p.lumpname, p.haslongname, ref patchlocation); if(patchdata != null) { // Copy patch data to memory @@ -124,7 +125,7 @@ namespace CodeImp.DoomBuilder.Data if(reader is UnknownImageReader) { // Data is in an unknown format! - General.ErrorLogger.Add(ErrorType.Error, "Patch lump \"" + p.lumpname + "\" data format could not be read, while loading texture \"" + this.Name + "\". Does this lump contain valid picture data at all?"); + General.ErrorLogger.Add(ErrorType.Error, "Patch lump \"" + Path.Combine(patchlocation, p.lumpname) + "\" data format could not be read, while loading texture \"" + this.Name + "\". Does this lump contain valid picture data at all?"); loadfailed = true; missingpatches++; //mxd } diff --git a/Source/Core/Data/WADReader.cs b/Source/Core/Data/WADReader.cs index dec6464a..51591f63 100644 --- a/Source/Core/Data/WADReader.cs +++ b/Source/Core/Data/WADReader.cs @@ -226,7 +226,7 @@ namespace CodeImp.DoomBuilder.Data foreach(KeyValuePair> group in failedranges) { if(successfulrangestarts.ContainsKey(group.Key.start)) continue; - General.ErrorLogger.Add(ErrorType.Warning, "\"" + group.Value.Key + "\" range at index " + group.Key.start + " is not closed in resource \"" + location.location + "\" (\"" + group.Value.Value + "\" marker is missing)."); + General.ErrorLogger.Add(ErrorType.Warning, "\"" + group.Value.Key + "\" range at index " + group.Key.start + " is not closed in resource \"" + location.GetDisplayName() + "\" (\"" + group.Value.Value + "\" marker is missing)."); } //mxd. Check duplicates @@ -236,7 +236,7 @@ namespace CodeImp.DoomBuilder.Data for(int i = range.start + 1; i < range.end; i++) { if(names.Contains(file.Lumps[i].Name)) - General.ErrorLogger.Add(ErrorType.Warning, elementname + " \"" + file.Lumps[i].Name + "\", index " + i + " is double defined in resource \"" + location.location + "\"."); + General.ErrorLogger.Add(ErrorType.Warning, elementname + " \"" + file.Lumps[i].Name + "\", index " + i + " is double defined in resource \"" + location.GetDisplayName() + "\"."); else names.Add(file.Lumps[i].Name); } @@ -390,7 +390,7 @@ namespace CodeImp.DoomBuilder.Data else { // Can't load image without size - General.ErrorLogger.Add(ErrorType.Error, "Can't load texture \"" + file.Lumps[i].Name + "\" because it doesn't contain any data."); + General.ErrorLogger.Add(ErrorType.Error, "Can't load texture \"" + file.Lumps[i].Name + "\" from \"" + location.GetDisplayName() + "\" because it doesn't contain any data."); } } } @@ -445,7 +445,7 @@ namespace CodeImp.DoomBuilder.Data else { // Can't load image without size - General.ErrorLogger.Add(ErrorType.Error, "Can't load HiRes texture \"" + file.Lumps[i].Name + "\" because it doesn't contain any data."); + General.ErrorLogger.Add(ErrorType.Error, "Can't load HiRes texture \"" + file.Lumps[i].Name + "\" from \"" + location.GetDisplayName() + "\" because it doesn't contain any data."); } } } @@ -592,7 +592,7 @@ namespace CodeImp.DoomBuilder.Data } // This finds and returns a patch stream - public override Stream GetPatchData(string pname, bool longname) + public override Stream GetPatchData(string pname, bool longname, ref string patchlocation) { // Error when suspended if(issuspended) throw new Exception("Data reader is suspended"); @@ -612,14 +612,22 @@ namespace CodeImp.DoomBuilder.Data foreach(LumpRange range in invertedflatranges) { lump = file.FindLump(pname, range.start, range.end); - if(lump != null) return lump.Stream; + if(lump != null) + { + patchlocation = location.GetDisplayName(); + return lump.Stream; + } } // Find the lump anywhere IN flat ranges foreach(LumpRange range in flatranges) { lump = file.FindLump(pname, range.start, range.end); - if(lump != null) return lump.Stream; + if(lump != null) + { + patchlocation = location.GetDisplayName(); + return lump.Stream; + } } } @@ -627,7 +635,7 @@ namespace CodeImp.DoomBuilder.Data } // This finds and returns a texture stream - public override Stream GetTextureData(string pname, bool longname) + public override Stream GetTextureData(string pname, bool longname, ref string texturelocation) { // Error when suspended if(issuspended) throw new Exception("Data reader is suspended"); @@ -637,14 +645,18 @@ namespace CodeImp.DoomBuilder.Data foreach(LumpRange range in textureranges) { Lump lump = file.FindLump(pname, range.start, range.end); - if(lump != null) return lump.Stream; + if(lump != null) + { + texturelocation = location.GetDisplayName(); //mxd + return lump.Stream; + } } return null; } //mxd. This finds and returns a HiRes texture stream - public override Stream GetHiResTextureData(string name) + public override Stream GetHiResTextureData(string name, ref string hireslocation) { // Error when suspended if(issuspended) throw new Exception("Data reader is suspended"); @@ -653,7 +665,11 @@ namespace CodeImp.DoomBuilder.Data foreach(LumpRange range in hiresranges) { Lump lump = file.FindLump(name, range.start, range.end); - if(lump != null) return lump.Stream; + if(lump != null) + { + hireslocation = location.GetDisplayName(); + return lump.Stream; + } } return null; @@ -744,7 +760,7 @@ namespace CodeImp.DoomBuilder.Data } // This finds and returns a patch stream - public override Stream GetFlatData(string pname, bool longname) + public override Stream GetFlatData(string pname, bool longname, ref string flatlocation) { // Error when suspended if(issuspended) throw new Exception("Data reader is suspended"); @@ -754,7 +770,11 @@ namespace CodeImp.DoomBuilder.Data foreach(LumpRange range in flatranges) { Lump lump = file.FindLump(pname, range.start, range.end); - if(lump != null) return lump.Stream; + if(lump != null) + { + flatlocation = location.GetDisplayName(); //mxd + return lump.Stream; + } } return null; @@ -825,7 +845,7 @@ namespace CodeImp.DoomBuilder.Data } // This finds and returns a sprite stream - public override Stream GetSpriteData(string pname) + public override Stream GetSpriteData(string pname, ref string spritelocation) { // Error when suspended if(issuspended) throw new Exception("Data reader is suspended"); @@ -834,7 +854,11 @@ namespace CodeImp.DoomBuilder.Data foreach(LumpRange range in spriteranges) { Lump lump = file.FindLump(pname, range.start, range.end); - if(lump != null) return lump.Stream; + if(lump != null) + { + spritelocation = location.GetDisplayName(); //mxd + return lump.Stream; + } } return null; diff --git a/Source/Core/Windows/MainForm.cs b/Source/Core/Windows/MainForm.cs index c7f4204d..8af1485b 100644 --- a/Source/Core/Windows/MainForm.cs +++ b/Source/Core/Windows/MainForm.cs @@ -722,32 +722,46 @@ namespace CodeImp.DoomBuilder.Windows } //mxd - private void OnDragDrop(object sender, DragEventArgs e) + private void OnDragDrop(object sender, DragEventArgs e) { if(e.Data.GetDataPresent(DataFormats.FileDrop)) { - string[] filePaths = (string[])e.Data.GetData(DataFormats.FileDrop); - if(filePaths.Length != 1) + string[] filepaths = (string[])e.Data.GetData(DataFormats.FileDrop); + if(filepaths.Length != 1) { General.Interface.DisplayStatus(StatusType.Warning, "Cannot open multiple files at once!"); return; } - if(!File.Exists(filePaths[0])) + if(!File.Exists(filepaths[0])) { - General.Interface.DisplayStatus(StatusType.Warning, "Cannot open \"" + filePaths[0] + "\": file does not exist!"); + General.Interface.DisplayStatus(StatusType.Warning, "Cannot open \"" + filepaths[0] + "\": file does not exist!"); return; } - string ext = Path.GetExtension(filePaths[0]); + string ext = Path.GetExtension(filepaths[0]); if(string.IsNullOrEmpty(ext) || ext.ToLower() != ".wad") { - General.Interface.DisplayStatus(StatusType.Warning, "Cannot open \"" + filePaths[0] + "\": only WAD files can be loaded this way!"); + General.Interface.DisplayStatus(StatusType.Warning, "Cannot open \"" + filepaths[0] + "\": only WAD files can be loaded this way!"); return; } + // If we call General.OpenMapFile here, it will lock the source window in the waiting state untill OpenMapOptionsForm is closed. + Timer t = new Timer { Tag = filepaths[0], Interval = 10 }; + t.Tick += OnDragDropTimerTick; + t.Start(); + } + } + + private void OnDragDropTimerTick(object sender, EventArgs e) + { + Timer t = sender as Timer; + if(t != null) + { + t.Stop(); + string targetwad = t.Tag.ToString(); this.Update(); // Update main window - General.OpenMapFile(filePaths[0], null); + General.OpenMapFile(targetwad, null); UpdateGZDoomPanel(); } } diff --git a/Source/Core/ZDoom/ActorStructure.cs b/Source/Core/ZDoom/ActorStructure.cs index 70826eef..7154c2d6 100644 --- a/Source/Core/ZDoom/ActorStructure.cs +++ b/Source/Core/ZDoom/ActorStructure.cs @@ -264,7 +264,7 @@ namespace CodeImp.DoomBuilder.ZDoom } else { - parser.ReportError("Unexpected end of structure"); + parser.ReportError("Expected actor state name"); return; } } @@ -403,7 +403,7 @@ namespace CodeImp.DoomBuilder.ZDoom string v = parser.ReadToken(); if(string.IsNullOrEmpty(v)) { - parser.ReportError("Unexpected end of structure"); + parser.ReportError("Expected \"Game\" property value"); return; } if(v == "\n") break; diff --git a/Source/Core/ZDoom/StateStructure.cs b/Source/Core/ZDoom/StateStructure.cs index 18f79caf..16354a5b 100644 --- a/Source/Core/ZDoom/StateStructure.cs +++ b/Source/Core/ZDoom/StateStructure.cs @@ -113,7 +113,7 @@ namespace CodeImp.DoomBuilder.ZDoom token = parser.StripTokenQuotes(token); //mxd. First part of the sprite name can be quoted if(string.IsNullOrEmpty(token)) { - parser.ReportError("Unexpected end of structure"); + parser.ReportError("Expected sprite name"); return; } @@ -122,7 +122,7 @@ namespace CodeImp.DoomBuilder.ZDoom string spriteframes = parser.StripTokenQuotes(parser.ReadToken()); //mxd. Frames can be quoted if(string.IsNullOrEmpty(spriteframes)) { - parser.ReportError("Unexpected end of structure"); + parser.ReportError("Expected sprite frame"); return; } diff --git a/Source/Core/ZDoom/ZDTextParser.cs b/Source/Core/ZDoom/ZDTextParser.cs index a9d26feb..851e23b4 100644 --- a/Source/Core/ZDoom/ZDTextParser.cs +++ b/Source/Core/ZDoom/ZDTextParser.cs @@ -604,7 +604,7 @@ namespace CodeImp.DoomBuilder.ZDoom } else { - shorterrorsource = Path.Combine(datalocation.GetShortName(), sourcename); + shorterrorsource = Path.Combine(datalocation.GetDisplayName(), sourcename); errorsource = Path.Combine(datalocation.location, sourcename); } @@ -616,7 +616,7 @@ namespace CodeImp.DoomBuilder.ZDoom { // Add a warning int errline = (datastream != null ? GetCurrentLineNumber() : CompilerError.NO_LINE_NUMBER); - string errsource = (ScriptType == ScriptType.ACS && sourcename.StartsWith("?") ? sourcename.Substring(1) : Path.Combine(datalocation.GetShortName(), sourcename)); + string errsource = (ScriptType == ScriptType.ACS && sourcename.StartsWith("?") ? sourcename.Substring(1) : Path.Combine(datalocation.GetDisplayName(), sourcename)); if(sourcelumpindex != -1) errsource += ":" + sourcelumpindex; General.ErrorLogger.Add(ErrorType.Warning, ScriptType + " warning in \"" + errsource + (errline != CompilerError.NO_LINE_NUMBER ? "\", line " + (errline + 1) : "\"") + ". "