diff --git a/Resources/UnknownTexture3D.png b/Resources/UnknownTexture3D.png
new file mode 100644
index 00000000..a126a781
Binary files /dev/null and b/Resources/UnknownTexture3D.png differ
diff --git a/Source/Builder.csproj b/Source/Builder.csproj
index 1d18f912..9a443fd3 100644
--- a/Source/Builder.csproj
+++ b/Source/Builder.csproj
@@ -124,7 +124,7 @@
-
+
@@ -672,6 +672,7 @@
+
diff --git a/Source/BuilderModes/ClassicModes/SectorsMode.cs b/Source/BuilderModes/ClassicModes/SectorsMode.cs
index 78a433c1..7d6612e2 100644
--- a/Source/BuilderModes/ClassicModes/SectorsMode.cs
+++ b/Source/BuilderModes/ClassicModes/SectorsMode.cs
@@ -458,7 +458,8 @@ namespace CodeImp.DoomBuilder.BuilderModes
{
// Show sector edit dialog
General.Interface.ShowEditSectors(selected);
-
+ General.Map.Map.Update();
+
// When a single sector was selected, deselect it now
if(selected.Count == 1)
{
diff --git a/Source/BuilderModes/VisualModes/VisualMiddleSingle.cs b/Source/BuilderModes/VisualModes/VisualMiddleSingle.cs
index 74455d2e..6f9d258e 100644
--- a/Source/BuilderModes/VisualModes/VisualMiddleSingle.cs
+++ b/Source/BuilderModes/VisualModes/VisualMiddleSingle.cs
@@ -75,7 +75,13 @@ namespace CodeImp.DoomBuilder.BuilderModes
{
Vector2D t1 = new Vector2D();
Vector2D t2 = new Vector2D();
+
+ if(Sidedef.MiddleTexture == "FOOBAR")
+ {
+ int g = 5;
+ }
+
// Texture given?
if((Sidedef.MiddleTexture.Length > 0) && (Sidedef.MiddleTexture[0] != '-'))
{
diff --git a/Source/Controls/ImageBrowserControl.cs b/Source/Controls/ImageBrowserControl.cs
index 37b254c3..dac45d94 100644
--- a/Source/Controls/ImageBrowserControl.cs
+++ b/Source/Controls/ImageBrowserControl.cs
@@ -83,7 +83,7 @@ namespace CodeImp.DoomBuilder.Controls
// Initialize
InitializeComponent();
items = new List();
- list.TileSize = new Size(General.Map.Data.Previews.ImageWidth + 26, General.Map.Data.Previews.ImageHeight + 26);
+ list.TileSize = new Size(General.Map.Data.Previews.MaxImageWidth + 26, General.Map.Data.Previews.MaxImageHeight + 26);
// Move textbox with label
objectname.Left = label.Right + label.Margin.Right + objectname.Margin.Left;
diff --git a/Source/Controls/ImageBrowserItem.cs b/Source/Controls/ImageBrowserItem.cs
index 7f2cf9a2..4f214bd3 100644
--- a/Source/Controls/ImageBrowserItem.cs
+++ b/Source/Controls/ImageBrowserItem.cs
@@ -97,9 +97,9 @@ namespace CodeImp.DoomBuilder.Controls
// Determine coordinates
SizeF textsize = g.MeasureString(this.Text, this.ListView.Font, bounds.Width * 2);
- Rectangle imagerect = new Rectangle(bounds.Left + ((bounds.Width - General.Map.Data.Previews.ImageWidth) >> 1),
- bounds.Top + ((bounds.Height - General.Map.Data.Previews.ImageHeight - (int)textsize.Height) >> 1),
- General.Map.Data.Previews.ImageWidth, General.Map.Data.Previews.ImageHeight);
+ Rectangle imagerect = new Rectangle(bounds.Left + ((bounds.Width - General.Map.Data.Previews.MaxImageWidth) >> 1),
+ bounds.Top + ((bounds.Height - General.Map.Data.Previews.MaxImageHeight - (int)textsize.Height) >> 1),
+ General.Map.Data.Previews.MaxImageWidth, General.Map.Data.Previews.MaxImageHeight);
PointF textpos = new PointF(bounds.Left + ((float)bounds.Width - textsize.Width) * 0.5f, bounds.Bottom - textsize.Height - 2);
// Determine colors
diff --git a/Source/Controls/ThingInfoPanel.cs b/Source/Controls/ThingInfoPanel.cs
index 08bdead9..ddec6057 100644
--- a/Source/Controls/ThingInfoPanel.cs
+++ b/Source/Controls/ThingInfoPanel.cs
@@ -141,7 +141,7 @@ namespace CodeImp.DoomBuilder.Controls
if(ti.Sprite.ToLowerInvariant().StartsWith(DataManager.INTERNAL_PREFIX) && (ti.Sprite.Length > DataManager.INTERNAL_PREFIX.Length))
{
spritename.Text = "";
- General.DisplayZoomedImage(spritetex, General.Map.Data.GetSpriteImage(ti.Sprite).Bitmap);
+ General.DisplayZoomedImage(spritetex, General.Map.Data.GetSpriteImage(ti.Sprite).GetBitmap());
}
else if(ti.Sprite.Length <= 8)
{
diff --git a/Source/Data/DataManager.cs b/Source/Data/DataManager.cs
index 73785b1f..c080e7b5 100644
--- a/Source/Data/DataManager.cs
+++ b/Source/Data/DataManager.cs
@@ -74,6 +74,7 @@ namespace CodeImp.DoomBuilder.Data
// Special images
private ImageData missingtexture3d;
+ private ImageData unknowntexture3d;
private ImageData hourglass3d;
private ImageData crosshair;
private ImageData crosshairbusy;
@@ -102,6 +103,7 @@ namespace CodeImp.DoomBuilder.Data
public List FlatNames { get { return flatnames; } }
public bool IsDisposed { get { return isdisposed; } }
public ImageData MissingTexture3D { get { return missingtexture3d; } }
+ public ImageData UnknownTexture3D { get { return unknowntexture3d; } }
public ImageData Hourglass3D { get { return hourglass3d; } }
public ImageData Crosshair3D { get { return crosshair; } }
public ImageData CrosshairBusy3D { get { return crosshairbusy; } }
@@ -140,6 +142,8 @@ namespace CodeImp.DoomBuilder.Data
// Load special images
missingtexture3d = new ResourceImage("MissingTexture3D.png");
missingtexture3d.LoadImage();
+ unknowntexture3d = new ResourceImage("UnknownTexture3D.png");
+ unknowntexture3d.LoadImage();
hourglass3d = new ResourceImage("Hourglass3D.png");
hourglass3d.LoadImage();
crosshair = new ResourceImage("Crosshair.png");
@@ -160,6 +164,8 @@ namespace CodeImp.DoomBuilder.Data
Unload();
missingtexture3d.Dispose();
missingtexture3d = null;
+ unknowntexture3d.Dispose();
+ unknowntexture3d = null;
hourglass3d.Dispose();
hourglass3d = null;
crosshair.Dispose();
@@ -721,7 +727,7 @@ namespace CodeImp.DoomBuilder.Data
else
{
// Return null image
- return new NullImage();
+ return new UnknownImage(Properties.Resources.UnknownImage);
}
}
@@ -845,7 +851,7 @@ namespace CodeImp.DoomBuilder.Data
else
{
// Return null image
- return new NullImage();
+ return new UnknownImage(Properties.Resources.UnknownImage);
}
}
@@ -997,7 +1003,7 @@ namespace CodeImp.DoomBuilder.Data
}
else
{
- return new NullImage();
+ return new UnknownImage(Properties.Resources.UnknownImage);
}
}
else
@@ -1038,7 +1044,7 @@ namespace CodeImp.DoomBuilder.Data
else
{
// Return null image
- return new NullImage();
+ return new UnknownImage(Properties.Resources.UnknownImage);
}
}
}
diff --git a/Source/Data/FileImage.cs b/Source/Data/FileImage.cs
index 79d8bd06..8b6e94ee 100644
--- a/Source/Data/FileImage.cs
+++ b/Source/Data/FileImage.cs
@@ -118,17 +118,17 @@ namespace CodeImp.DoomBuilder.Data
// Not loaded?
if(bitmap == null)
{
- General.WriteLogLine("WARNING: Image file '" + filepathname + "' data format could not be read, while loading texture '" + this.Name + "'!");
+ General.WriteLogLine("ERROR: Image file '" + filepathname + "' data format could not be read, while loading texture '" + this.Name + "'!");
loadfailed = true;
- filedata.Dispose();
- return;
}
-
- // Get width and height from image
- width = bitmap.Size.Width;
- height = bitmap.Size.Height;
- scaledwidth = (float)bitmap.Size.Width * scalex;
- scaledheight = (float)bitmap.Size.Height * scaley;
+ else
+ {
+ // Get width and height from image
+ width = bitmap.Size.Width;
+ height = bitmap.Size.Height;
+ scaledwidth = (float)bitmap.Size.Width * scalex;
+ scaledheight = (float)bitmap.Size.Height * scaley;
+ }
// Pass on to base
filedata.Dispose();
diff --git a/Source/Data/FlatImage.cs b/Source/Data/FlatImage.cs
index ad0917cd..88efdf8d 100644
--- a/Source/Data/FlatImage.cs
+++ b/Source/Data/FlatImage.cs
@@ -77,28 +77,38 @@ namespace CodeImp.DoomBuilder.Data
if(reader is UnknownImageReader)
{
// Data is in an unknown format!
- General.WriteLogLine("WARNING: Flat lump '" + Name + "' data format could not be read!");
+ General.WriteLogLine("ERROR: Flat lump '" + Name + "' data format could not be read!");
+ bitmap = null;
+ }
+ else
+ {
+ // Read data as bitmap
+ mem.Seek(0, SeekOrigin.Begin);
+ if(bitmap != null) bitmap.Dispose();
+ bitmap = reader.ReadAsBitmap(mem);
}
-
- // Read data as bitmap
- mem.Seek(0, SeekOrigin.Begin);
- if(bitmap != null) bitmap.Dispose();
- bitmap = reader.ReadAsBitmap(mem);
- if(bitmap == null) return;
// Done
mem.Dispose();
-
- // Get width and height from image
- width = bitmap.Size.Width;
- height = bitmap.Size.Height;
- scaledwidth = (float)width * General.Map.Config.DefaultFlatScale;
- scaledheight = (float)height * General.Map.Config.DefaultFlatScale;
+
+ if(bitmap != null)
+ {
+ // Get width and height from image
+ width = bitmap.Size.Width;
+ height = bitmap.Size.Height;
+ scaledwidth = (float)width * General.Map.Config.DefaultFlatScale;
+ scaledheight = (float)height * General.Map.Config.DefaultFlatScale;
+ }
+ else
+ {
+ loadfailed = true;
+ }
}
else
{
// Missing a patch lump!
- General.WriteLogLine("WARNING: Missing flat lump '" + Name + "'!");
+ General.WriteLogLine("ERROR: Missing flat lump '" + Name + "'!");
+ loadfailed = true;
}
// Pass on to base
diff --git a/Source/Data/ImageData.cs b/Source/Data/ImageData.cs
index 35c9079c..189ea1d1 100644
--- a/Source/Data/ImageData.cs
+++ b/Source/Data/ImageData.cs
@@ -80,8 +80,6 @@ namespace CodeImp.DoomBuilder.Data
public string Name { get { return name; } }
public long LongName { get { return longname; } }
public bool UseColorCorrection { get { return usecolorcorrection; } set { usecolorcorrection = value; } }
- //public Bitmap Bitmap { get { lock(this) { if(bitmap != null) return new Bitmap(bitmap); else return CodeImp.DoomBuilder.Properties.Resources.Hourglass; } } }
- public Bitmap Bitmap { get { lock(this) { if(bitmap != null) return bitmap; else return CodeImp.DoomBuilder.Properties.Resources.Hourglass; } } }
public Texture Texture { get { lock(this) { return texture; } } }
public bool IsPreviewLoaded { get { return (previewstate == ImageLoadState.Ready); } }
public bool IsImageLoaded { get { return (imagestate == ImageLoadState.Ready); } }
@@ -184,8 +182,30 @@ namespace CodeImp.DoomBuilder.Data
imagestate = ImageLoadState.None;
}
}
+
+ // This returns the bitmap image
+ public Bitmap GetBitmap()
+ {
+ lock(this)
+ {
+ // Image loaded successfully?
+ if(!loadfailed && (imagestate == ImageLoadState.Ready) && (bitmap != null))
+ {
+ return bitmap;
+ }
+ // Image loading failed?
+ else if(loadfailed)
+ {
+ return Properties.Resources.Failed;
+ }
+ else
+ {
+ return Properties.Resources.Hourglass;
+ }
+ }
+ }
- // This loads theimage
+ // This loads the image
public void LoadImage()
{
// Keep original dimensions
@@ -240,7 +260,7 @@ namespace CodeImp.DoomBuilder.Data
catch(Exception e)
{
bitmap = oldbitmap;
- General.WriteLogLine("ERROR: Cannot lock image '" + name + "' for pixel format conversion. " + e.GetType().Name + ": " + e.Message);
+ General.WriteLogLine("WARNING: Cannot lock image '" + name + "' for pixel format conversion. " + e.GetType().Name + ": " + e.Message);
}
}
@@ -254,7 +274,7 @@ namespace CodeImp.DoomBuilder.Data
}
catch(Exception e)
{
- General.WriteLogLine("ERROR: Cannot lock image '" + name + "' for color correction. " + e.GetType().Name + ": " + e.Message);
+ General.WriteLogLine("WARNING: Cannot lock image '" + name + "' for color correction. " + e.GetType().Name + ": " + e.Message);
}
// Bitmap locked?
@@ -274,10 +294,22 @@ namespace CodeImp.DoomBuilder.Data
// not try loading again until Reload Resources is used
loadfailed = true;
bitmap = new Bitmap(Properties.Resources.Failed);
+ }
+
+ if(bitmap != null)
+ {
width = bitmap.Size.Width;
height = bitmap.Size.Height;
- scaledwidth = (float)bitmap.Size.Width * General.Map.Config.DefaultTextureScale;
- scaledheight = (float)bitmap.Size.Height * General.Map.Config.DefaultTextureScale;
+ if((General.Map != null) && (General.Map.Config != null))
+ {
+ scaledwidth = (float)bitmap.Size.Width * General.Map.Config.DefaultTextureScale;
+ scaledheight = (float)bitmap.Size.Height * General.Map.Config.DefaultTextureScale;
+ }
+ else
+ {
+ scaledwidth = (float)bitmap.Size.Width;
+ scaledheight = (float)bitmap.Size.Height;
+ }
}
// Image is ready
@@ -293,7 +325,7 @@ namespace CodeImp.DoomBuilder.Data
lock(this)
{
// Only do this when texture is not created yet
- if(((texture == null) || (texture.Disposed)) && this.IsImageLoaded)
+ if(((texture == null) || (texture.Disposed)) && this.IsImageLoaded && !loadfailed)
{
Image img = bitmap;
if(loadfailed) img = Properties.Resources.Failed;
@@ -327,7 +359,7 @@ namespace CodeImp.DoomBuilder.Data
lock(this)
{
// Preview ready?
- if(previewstate == ImageLoadState.Ready)
+ if(!loadfailed && (previewstate == ImageLoadState.Ready))
{
// Draw preview
General.Map.Data.Previews.DrawPreview(previewindex, target, targetpos);
@@ -336,15 +368,15 @@ namespace CodeImp.DoomBuilder.Data
else if(loadfailed)
{
// Draw error bitmap
- targetpos = new Point(targetpos.X + ((General.Map.Data.Previews.ImageWidth - Properties.Resources.Hourglass.Width) >> 1),
- targetpos.Y + ((General.Map.Data.Previews.ImageHeight - Properties.Resources.Hourglass.Height) >> 1));
+ targetpos = new Point(targetpos.X + ((General.Map.Data.Previews.MaxImageWidth - Properties.Resources.Hourglass.Width) >> 1),
+ targetpos.Y + ((General.Map.Data.Previews.MaxImageHeight - Properties.Resources.Hourglass.Height) >> 1));
target.DrawImageUnscaled(Properties.Resources.Failed, targetpos);
}
else
{
// Draw loading bitmap
- targetpos = new Point(targetpos.X + ((General.Map.Data.Previews.ImageWidth - Properties.Resources.Hourglass.Width) >> 1),
- targetpos.Y + ((General.Map.Data.Previews.ImageHeight - Properties.Resources.Hourglass.Height) >> 1));
+ targetpos = new Point(targetpos.X + ((General.Map.Data.Previews.MaxImageWidth - Properties.Resources.Hourglass.Width) >> 1),
+ targetpos.Y + ((General.Map.Data.Previews.MaxImageHeight - Properties.Resources.Hourglass.Height) >> 1));
target.DrawImageUnscaled(Properties.Resources.Hourglass, targetpos);
}
}
diff --git a/Source/Data/PK3FileImage.cs b/Source/Data/PK3FileImage.cs
index 2aa366d8..f2b2d497 100644
--- a/Source/Data/PK3FileImage.cs
+++ b/Source/Data/PK3FileImage.cs
@@ -102,17 +102,17 @@ namespace CodeImp.DoomBuilder.Data
// Not loaded?
if(bitmap == null)
{
- General.WriteLogLine("WARNING: Image file '" + filepathname + "' data format could not be read, while loading texture '" + this.Name + "'!");
+ General.WriteLogLine("ERROR: Image file '" + filepathname + "' data format could not be read, while loading texture '" + this.Name + "'!");
loadfailed = true;
- filedata.Dispose();
- return;
}
-
- // Get width and height from image
- width = bitmap.Size.Width;
- height = bitmap.Size.Height;
- scaledwidth = (float)bitmap.Size.Width * scalex;
- scaledheight = (float)bitmap.Size.Height * scaley;
+ else
+ {
+ // Get width and height from image
+ width = bitmap.Size.Width;
+ height = bitmap.Size.Height;
+ scaledwidth = (float)bitmap.Size.Width * scalex;
+ scaledheight = (float)bitmap.Size.Height * scaley;
+ }
// Pass on to base
filedata.Dispose();
diff --git a/Source/Data/PreviewManager.cs b/Source/Data/PreviewManager.cs
index 91f64085..819d9c5d 100644
--- a/Source/Data/PreviewManager.cs
+++ b/Source/Data/PreviewManager.cs
@@ -47,8 +47,8 @@ namespace CodeImp.DoomBuilder.Data
#region ================== Variables
// Dimensions of a single preview image
- private int imagewidth = 64;
- private int imageheight = 64;
+ private int maxpreviewwidth = 64;
+ private int maxpreviewheight = 64;
// Images
private List images;
@@ -64,8 +64,8 @@ namespace CodeImp.DoomBuilder.Data
#region ================== Properties
// Constants
- public int ImageWidth { get { return imagewidth; } }
- public int ImageHeight { get { return imageheight; } }
+ public int MaxImageWidth { get { return maxpreviewwidth; } }
+ public int MaxImageHeight { get { return maxpreviewheight; } }
// Disposing
internal bool IsDisposed { get { return isdisposed; } }
@@ -89,8 +89,8 @@ namespace CodeImp.DoomBuilder.Data
// Initialize
images = new List();
imageque = new Queue();
- imagewidth = PREVIEW_SIZES[General.Settings.PreviewImageSize];
- imageheight = PREVIEW_SIZES[General.Settings.PreviewImageSize];
+ maxpreviewwidth = PREVIEW_SIZES[General.Settings.PreviewImageSize];
+ maxpreviewheight = PREVIEW_SIZES[General.Settings.PreviewImageSize];
// We have no destructor
GC.SuppressFinalize(this);
@@ -118,6 +118,8 @@ namespace CodeImp.DoomBuilder.Data
// This makes a preview for the given image and updates the image settings
private void MakeImagePreview(ImageData img)
{
+ int previewwidth, previewheight;
+ int imagewidth, imageheight;
Bitmap preview;
Graphics g;
@@ -125,13 +127,23 @@ namespace CodeImp.DoomBuilder.Data
{
// Load image if needed
if(!img.IsImageLoaded) img.LoadImage();
-
+ if(!img.LoadFailed)
+ {
+ imagewidth = img.Width;
+ imageheight = img.Height;
+ }
+ else
+ {
+ imagewidth = img.GetBitmap().Size.Width;
+ imageheight = img.GetBitmap().Size.Height;
+ }
+
// Determine preview size
- float scalex = (img.Width > imagewidth) ? ((float)imagewidth / (float)img.Width) : 1.0f;
- float scaley = (img.Height > imageheight) ? ((float)imageheight / (float)img.Height) : 1.0f;
+ float scalex = (img.Width > maxpreviewwidth) ? ((float)maxpreviewwidth / (float)imagewidth) : 1.0f;
+ float scaley = (img.Height > maxpreviewheight) ? ((float)maxpreviewheight / (float)imageheight) : 1.0f;
float scale = Math.Min(scalex, scaley);
- int previewwidth = (int)((float)img.Width * scale);
- int previewheight = (int)((float)img.Height * scale);
+ previewwidth = (int)((float)imagewidth * scale);
+ previewheight = (int)((float)imageheight * scale);
// Make new image
preview = new Bitmap(previewwidth, previewheight, IMAGE_FORMAT);
@@ -145,8 +157,8 @@ namespace CodeImp.DoomBuilder.Data
// Draw image onto atlas
Rectangle atlasrect = new Rectangle(0, 0, previewwidth, previewheight);
- RectangleF imgrect = General.MakeZoomedRect(new Size(img.Width, img.Height), atlasrect);
- g.DrawImage(img.Bitmap, imgrect);
+ RectangleF imgrect = General.MakeZoomedRect(new Size(imagewidth, imageheight), atlasrect);
+ g.DrawImage(img.GetBitmap(), imgrect);
g.Dispose();
// Unload image if no longer needed
@@ -177,8 +189,8 @@ namespace CodeImp.DoomBuilder.Data
lock(images) { image = images[previewindex]; }
// Adjust offset for the size of the preview image
- targetpos.X += (imagewidth - image.Width) >> 1;
- targetpos.Y += (imageheight - image.Height) >> 1;
+ targetpos.X += (maxpreviewwidth - image.Width) >> 1;
+ targetpos.Y += (maxpreviewheight - image.Height) >> 1;
// Draw from atlas to target
lock(image)
diff --git a/Source/Data/ResourceImage.cs b/Source/Data/ResourceImage.cs
index 2a787987..0e70d427 100644
--- a/Source/Data/ResourceImage.cs
+++ b/Source/Data/ResourceImage.cs
@@ -70,6 +70,9 @@ namespace CodeImp.DoomBuilder.Data
lock(this)
{
+ // No failure checking here. I anything fails here, it is not the user's fault,
+ // because the resources this loads are in the assembly.
+
// Get resource from memory
bitmapdata = General.ThisAssembly.GetManifestResourceStream("CodeImp.DoomBuilder.Resources." + Name);
if(bitmap != null) bitmap.Dispose();
diff --git a/Source/Data/SimpleTextureImage.cs b/Source/Data/SimpleTextureImage.cs
index 28a68730..092bd2e4 100644
--- a/Source/Data/SimpleTextureImage.cs
+++ b/Source/Data/SimpleTextureImage.cs
@@ -104,25 +104,31 @@ namespace CodeImp.DoomBuilder.Data
bitmap = null;
}
}
-
+
// Not loaded?
if(bitmap == null)
{
- General.WriteLogLine("WARNING: Image lump '" + lumpname + "' data format could not be read, while loading texture '" + this.Name + "'!");
+ General.WriteLogLine("ERROR: Image lump '" + lumpname + "' data format could not be read, while loading texture '" + this.Name + "'!");
loadfailed = true;
- return;
}
-
- // Get width and height from image
- width = bitmap.Size.Width;
- height = bitmap.Size.Height;
- scaledwidth = (float)width * scalex;
- scaledheight = (float)height * scaley;
+ else
+ {
+ // Get width and height from image
+ width = bitmap.Size.Width;
+ height = bitmap.Size.Height;
+ scaledwidth = (float)width * scalex;
+ scaledheight = (float)height * scaley;
+ }
// Done
mem.Dispose();
}
-
+ else
+ {
+ General.WriteLogLine("ERROR: Image lump '" + lumpname + "' could not be found, while loading texture '" + this.Name + "'!");
+ loadfailed = true;
+ }
+
// Pass on to base
base.LocalLoadImage();
}
diff --git a/Source/Data/SpriteImage.cs b/Source/Data/SpriteImage.cs
index e2758345..c90889ab 100644
--- a/Source/Data/SpriteImage.cs
+++ b/Source/Data/SpriteImage.cs
@@ -78,28 +78,37 @@ namespace CodeImp.DoomBuilder.Data
if(reader is UnknownImageReader)
{
// Data is in an unknown format!
- General.WriteLogLine("WARNING: Sprite lump '" + Name + "' data format could not be read!");
+ General.WriteLogLine("ERROR: Sprite lump '" + Name + "' data format could not be read!");
+ bitmap = null;
+ }
+ else
+ {
+ // Read data as bitmap
+ mem.Seek(0, SeekOrigin.Begin);
+ if(bitmap != null) bitmap.Dispose();
+ bitmap = reader.ReadAsBitmap(mem);
}
-
- // Read data as bitmap
- mem.Seek(0, SeekOrigin.Begin);
- if(bitmap != null) bitmap.Dispose();
- bitmap = reader.ReadAsBitmap(mem);
- if(bitmap == null) return;
// Done
mem.Dispose();
-
- // Get width and height from image
- width = bitmap.Size.Width;
- height = bitmap.Size.Height;
- scaledwidth = (float)bitmap.Size.Width;
- scaledheight = (float)bitmap.Size.Height;
+
+ if(bitmap != null)
+ {
+ // Get width and height from image
+ width = bitmap.Size.Width;
+ height = bitmap.Size.Height;
+ scaledwidth = (float)bitmap.Size.Width;
+ scaledheight = (float)bitmap.Size.Height;
+ }
+ else
+ {
+ loadfailed = true;
+ }
}
else
{
// Missing a patch lump!
- General.WriteLogLine("WARNING: Missing sprite lump '" + Name + "'!");
+ General.WriteLogLine("ERROR: Missing sprite lump '" + Name + "'!");
}
// Pass on to base
diff --git a/Source/Data/TextureImage.cs b/Source/Data/TextureImage.cs
index 07658d9d..36aa8596 100644
--- a/Source/Data/TextureImage.cs
+++ b/Source/Data/TextureImage.cs
@@ -76,9 +76,9 @@ namespace CodeImp.DoomBuilder.Data
{
uint datalength = (uint)(width * height * sizeof(PixelColor));
IImageReader reader;
- BitmapData bitmapdata;
+ BitmapData bitmapdata = null;
MemoryStream mem;
- PixelColor* pixels;
+ PixelColor* pixels = (PixelColor*)0;
Stream patchdata;
byte[] membytes;
@@ -101,57 +101,61 @@ namespace CodeImp.DoomBuilder.Data
{
// Unable to make bitmap
General.WriteLogLine("ERROR: Unable to load texture image '" + this.Name + "'. " + e.GetType().Name + ": " + e.Message);
- return;
+ loadfailed = true;
}
-
- // Go for all patches
- foreach(TexturePatch p in patches)
+
+ if(!loadfailed)
{
- // Get the patch data stream
- patchdata = General.Map.Data.GetPatchData(p.lumpname);
- if(patchdata != null)
+ // Go for all patches
+ foreach(TexturePatch p in patches)
{
- // Copy patch data to memory
- patchdata.Seek(0, SeekOrigin.Begin);
- membytes = new byte[(int)patchdata.Length];
- patchdata.Read(membytes, 0, (int)patchdata.Length);
- mem = new MemoryStream(membytes);
- mem.Seek(0, SeekOrigin.Begin);
-
- // Get a reader for the data
- reader = ImageDataFormat.GetImageReader(mem, ImageDataFormat.DOOMPICTURE, General.Map.Data.Palette);
- if(reader is UnknownImageReader)
+ // Get the patch data stream
+ patchdata = General.Map.Data.GetPatchData(p.lumpname);
+ if(patchdata != null)
{
- // Data is in an unknown format!
- General.WriteLogLine("WARNING: Patch lump '" + p.lumpname + "' data format could not be read, while loading texture '" + this.Name + "'!");
- loadfailed = true;
+ // Copy patch data to memory
+ patchdata.Seek(0, SeekOrigin.Begin);
+ membytes = new byte[(int)patchdata.Length];
+ patchdata.Read(membytes, 0, (int)patchdata.Length);
+ mem = new MemoryStream(membytes);
+ mem.Seek(0, SeekOrigin.Begin);
+
+ // Get a reader for the data
+ reader = ImageDataFormat.GetImageReader(mem, ImageDataFormat.DOOMPICTURE, General.Map.Data.Palette);
+ if(reader is UnknownImageReader)
+ {
+ // Data is in an unknown format!
+ General.WriteLogLine("ERROR: Patch lump '" + p.lumpname + "' data format could not be read, while loading texture '" + this.Name + "'!");
+ loadfailed = true;
+ }
+ else
+ {
+ // Draw the patch
+ mem.Seek(0, SeekOrigin.Begin);
+ try { reader.DrawToPixelData(mem, pixels, width, height, p.x, p.y); }
+ catch(InvalidDataException)
+ {
+ // Data cannot be read!
+ General.WriteLogLine("ERROR: Patch lump '" + p.lumpname + "' data format could not be read, while loading texture '" + this.Name + "'!");
+ loadfailed = true;
+ }
+ }
+
+ // Done
+ mem.Dispose();
}
else
{
- // Draw the patch
- mem.Seek(0, SeekOrigin.Begin);
- try { reader.DrawToPixelData(mem, pixels, width, height, p.x, p.y); }
- catch(InvalidDataException)
- {
- // Data cannot be read!
- General.WriteLogLine("WARNING: Patch lump '" + p.lumpname + "' data format could not be read, while loading texture '" + this.Name + "'!");
- loadfailed = true;
- }
+ // Missing a patch lump!
+ General.WriteLogLine("ERROR: Missing patch lump '" + p.lumpname + "' while loading texture '" + this.Name + "'!");
+ loadfailed = true;
}
-
- // Done
- mem.Dispose();
- }
- else
- {
- // Missing a patch lump!
- General.WriteLogLine("WARNING: Missing patch lump '" + p.lumpname + "' while loading texture '" + this.Name + "'!");
}
+
+ // Done
+ bitmap.UnlockBits(bitmapdata);
}
-
- // Done
- bitmap.UnlockBits(bitmapdata);
-
+
// Dispose bitmap if load failed
if(loadfailed && (bitmap != null))
{
diff --git a/Source/Data/NullImage.cs b/Source/Data/UnknownImage.cs
similarity index 64%
rename from Source/Data/NullImage.cs
rename to Source/Data/UnknownImage.cs
index 0208b39d..e73c1177 100644
--- a/Source/Data/NullImage.cs
+++ b/Source/Data/UnknownImage.cs
@@ -31,18 +31,27 @@ using System.IO;
namespace CodeImp.DoomBuilder.Data
{
- public sealed class NullImage : ImageData
+ public sealed class UnknownImage : ImageData
{
+ #region ================== Variables
+
+ private Bitmap loadbitmap = null;
+
+ #endregion
+
#region ================== Constructor / Disposer
// Constructor
- public NullImage()
+ public UnknownImage(Bitmap image)
{
// Initialize
this.width = 0;
this.height = 0;
+ this.loadbitmap = image;
SetName("");
-
+
+ LocalLoadImage();
+
// We have no destructor
GC.SuppressFinalize(this);
}
@@ -51,9 +60,22 @@ namespace CodeImp.DoomBuilder.Data
#region ================== Methods
- // Dont do anything
- protected override void LocalLoadImage() { bitmap = CodeImp.DoomBuilder.Properties.Resources.UnknownImage; }
- internal override void CreateTexture() { }
+ // This 'loads' the image
+ protected override void LocalLoadImage()
+ {
+ bitmap = loadbitmap;
+ base.LocalLoadImage();
+ }
+
+ // This returns a preview image
+ public override Image GetPreview()
+ {
+ lock(this)
+ {
+ // Make a copy
+ return new Bitmap(loadbitmap);
+ }
+ }
#endregion
}
diff --git a/Source/Editing/GridSetup.cs b/Source/Editing/GridSetup.cs
index 0c6be244..f094e975 100644
--- a/Source/Editing/GridSetup.cs
+++ b/Source/Editing/GridSetup.cs
@@ -60,7 +60,7 @@ namespace CodeImp.DoomBuilder.Editing
// Background
private string background = "";
private int backsource;
- private ImageData backimage = new NullImage();
+ private ImageData backimage = new UnknownImage(null);
private int backoffsetx, backoffsety;
private float backscalex, backscaley;
diff --git a/Source/Rendering/Renderer2D.cs b/Source/Rendering/Renderer2D.cs
index a9ad0c30..a89b8501 100644
--- a/Source/Rendering/Renderer2D.cs
+++ b/Source/Rendering/Renderer2D.cs
@@ -741,7 +741,7 @@ namespace CodeImp.DoomBuilder.Rendering
// Only if a background image is set
if((General.Map.Grid.Background != null) &&
- !(General.Map.Grid.Background is NullImage))
+ !(General.Map.Grid.Background is UnknownImage))
{
// Make vertices
backimageverts = CreateScreenVerts(windowsize);
@@ -1201,8 +1201,14 @@ namespace CodeImp.DoomBuilder.Rendering
ImageData img = General.Map.Data.GetFlatImage(longimagename);
if(img != null)
{
+ // Texture unknown?
+ if(img is UnknownImage)
+ {
+ General.Map.Data.UnknownTexture3D.CreateTexture();
+ t = General.Map.Data.UnknownTexture3D.Texture;
+ }
// Is the texture loaded?
- if(img.IsImageLoaded)
+ else if(img.IsImageLoaded && !img.LoadFailed)
{
if(img.Texture == null) img.CreateTexture();
t = img.Texture;
diff --git a/Source/Rendering/Renderer3D.cs b/Source/Rendering/Renderer3D.cs
index 5468a375..6dda9b53 100644
--- a/Source/Rendering/Renderer3D.cs
+++ b/Source/Rendering/Renderer3D.cs
@@ -517,7 +517,9 @@ namespace CodeImp.DoomBuilder.Rendering
ImageData curtexture;
// What texture to use?
- if((group.Key != null) && group.Key.IsImageLoaded && !group.Key.IsDisposed)
+ if(group.Key is UnknownImage)
+ curtexture = General.Map.Data.UnknownTexture3D;
+ else if((group.Key != null) && group.Key.IsImageLoaded && !group.Key.IsDisposed)
curtexture = group.Key;
else
curtexture = General.Map.Data.Hourglass3D;
@@ -571,43 +573,46 @@ namespace CodeImp.DoomBuilder.Rendering
foreach(KeyValuePair> group in thingspass)
{
ImageData curtexture;
-
- // What texture to use?
- if((group.Key != null) && group.Key.IsImageLoaded && !group.Key.IsDisposed)
- curtexture = group.Key;
- else
- curtexture = General.Map.Data.Hourglass3D;
-
- // Create Direct3D texture if still needed
- if((curtexture.Texture == null) || curtexture.Texture.Disposed)
- curtexture.CreateTexture();
-
- // Apply texture
- graphics.Device.SetTexture(0, curtexture.Texture);
- graphics.Shaders.World3D.Texture1 = curtexture.Texture;
- graphics.Shaders.World3D.ApplySettings();
-
- // Render all things with this texture
- foreach(VisualThing t in group.Value)
+
+ if(!(group.Key is UnknownImage))
{
- // Update buffer if needed
- t.Update();
-
- // Only do this sector when a vertexbuffer is created
- if(t.GeometryBuffer != null)
+ // What texture to use?
+ if((group.Key != null) && group.Key.IsImageLoaded && !group.Key.IsDisposed)
+ curtexture = group.Key;
+ else
+ curtexture = General.Map.Data.Hourglass3D;
+
+ // Create Direct3D texture if still needed
+ if((curtexture.Texture == null) || curtexture.Texture.Disposed)
+ curtexture.CreateTexture();
+
+ // Apply texture
+ graphics.Device.SetTexture(0, curtexture.Texture);
+ graphics.Shaders.World3D.Texture1 = curtexture.Texture;
+ graphics.Shaders.World3D.ApplySettings();
+
+ // Render all things with this texture
+ foreach(VisualThing t in group.Value)
{
- // Create the matrix for positioning / rotation
- world = t.Orientation;
- if(t.Billboard) world = Matrix.Multiply(world, billboard);
- world = Matrix.Multiply(world, t.Position);
- ApplyMatrices3D();
- graphics.Shaders.World3D.ApplySettings();
-
- // Apply buffer
- graphics.Device.SetStreamSource(0, t.GeometryBuffer, 0, WorldVertex.Stride);
-
- // Render!
- graphics.Device.DrawPrimitives(PrimitiveType.TriangleList, 0, t.Triangles);
+ // Update buffer if needed
+ t.Update();
+
+ // Only do this sector when a vertexbuffer is created
+ if(t.GeometryBuffer != null)
+ {
+ // Create the matrix for positioning / rotation
+ world = t.Orientation;
+ if(t.Billboard) world = Matrix.Multiply(world, billboard);
+ world = Matrix.Multiply(world, t.Position);
+ ApplyMatrices3D();
+ graphics.Shaders.World3D.ApplySettings();
+
+ // Apply buffer
+ graphics.Device.SetStreamSource(0, t.GeometryBuffer, 0, WorldVertex.Stride);
+
+ // Render!
+ graphics.Device.DrawPrimitives(PrimitiveType.TriangleList, 0, t.Triangles);
+ }
}
}
}
diff --git a/Source/Resources/UnknownTexture3D.png b/Source/Resources/UnknownTexture3D.png
new file mode 100644
index 00000000..a126a781
Binary files /dev/null and b/Source/Resources/UnknownTexture3D.png differ
diff --git a/Source/Windows/GridSetupForm.cs b/Source/Windows/GridSetupForm.cs
index 4e04181e..215cb67b 100644
--- a/Source/Windows/GridSetupForm.cs
+++ b/Source/Windows/GridSetupForm.cs
@@ -51,13 +51,13 @@ namespace CodeImp.DoomBuilder.Windows
// Background image?
if((General.Map.Grid.Background != null) &&
- !(General.Map.Grid.Background is NullImage))
+ !(General.Map.Grid.Background is UnknownImage))
{
// Show background image
showbackground.Checked = true;
backgroundname = General.Map.Grid.BackgroundName;
backgroundsource = General.Map.Grid.BackgroundSource;
- General.DisplayZoomedImage(backgroundimage, General.Map.Grid.Background.Bitmap);
+ General.DisplayZoomedImage(backgroundimage, General.Map.Grid.Background.GetBitmap());
}
else
{
@@ -101,7 +101,7 @@ namespace CodeImp.DoomBuilder.Windows
backgroundsource = GridSetup.SOURCE_TEXTURES;
ImageData img = General.Map.Data.GetTextureImage(result);
img.LoadImage();
- General.DisplayZoomedImage(backgroundimage, img.Bitmap);
+ General.DisplayZoomedImage(backgroundimage, img.GetBitmap());
}
}
@@ -119,7 +119,7 @@ namespace CodeImp.DoomBuilder.Windows
backgroundsource = GridSetup.SOURCE_FLATS;
ImageData img = General.Map.Data.GetFlatImage(result);
img.LoadImage();
- General.DisplayZoomedImage(backgroundimage, img.Bitmap);
+ General.DisplayZoomedImage(backgroundimage, img.GetBitmap());
}
}
@@ -134,7 +134,7 @@ namespace CodeImp.DoomBuilder.Windows
backgroundsource = GridSetup.SOURCE_FILE;
ImageData img = new FileImage(backgroundname, backgroundname, false, 1.0f, 1.0f);
img.LoadImage();
- General.DisplayZoomedImage(backgroundimage, new Bitmap(img.Bitmap));
+ General.DisplayZoomedImage(backgroundimage, new Bitmap(img.GetBitmap()));
img.Dispose();
}
}