much more on data resources loading and bugfixes

This commit is contained in:
codeimp 2007-10-26 13:17:20 +00:00
parent 947bdb59e9
commit eb92d78761
26 changed files with 1162 additions and 182 deletions

BIN
Resources/UnknownImage.cpt Normal file

Binary file not shown.

BIN
Resources/UnknownImage.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.6 KiB

View file

@ -77,7 +77,7 @@
<Compile Include="Geometry\Vector2D.cs" />
<Compile Include="Geometry\Vector3D.cs" />
<Compile Include="Data\TexturePatch.cs" />
<Compile Include="Data\TexturePatchFormat.cs" />
<Compile Include="Data\ImageDataFormat.cs" />
<Compile Include="Data\DataReader.cs" />
<Compile Include="Data\DataLocationList.cs" />
<Compile Include="Data\DataManager.cs" />
@ -166,10 +166,14 @@
<Compile Include="IO\Configuration.cs" />
<Compile Include="General\General.cs" />
<Compile Include="IO\ClippedStream.cs" />
<Compile Include="IO\DoomFlatReader.cs" />
<Compile Include="IO\DoomMapSetIO.cs" />
<Compile Include="IO\DoomPictureReader.cs" />
<Compile Include="IO\FileImageReader.cs" />
<Compile Include="IO\IImageReader.cs" />
<Compile Include="IO\Lump.cs" />
<Compile Include="IO\MapSetIO.cs" />
<Compile Include="IO\UnknownImageReader.cs" />
<Compile Include="IO\WAD.cs" />
<Compile Include="Interface\MainForm.cs">
<SubType>Form</SubType>
@ -245,6 +249,7 @@
</ItemGroup>
<ItemGroup>
<Content Include="Resources\Builder.ico" />
<None Include="Resources\UnknownImage.png" />
<None Include="Resources\ThingsMode.png" />
<None Include="Resources\VerticesMode.png" />
<None Include="Resources\SectorsMode.png" />

View file

@ -51,6 +51,10 @@ namespace CodeImp.DoomBuilder.Config
// Map lumps
private IDictionary maplumpnames;
// Texture/flat sources
private IDictionary textureranges;
private IDictionary flatranges;
// Things
private List<ThingCategory> thingcategories;
private Dictionary<int, ThingTypeInfo> things;
@ -68,6 +72,10 @@ namespace CodeImp.DoomBuilder.Config
// Map lumps
public IDictionary MapLumpNames { get { return maplumpnames; } }
// Texture/flat sources
public IDictionary TextureRanges { get { return textureranges; } }
public IDictionary FlatRanges { get { return flatranges; } }
// Things
public List<ThingCategory> ThingCategories { get { return thingcategories; } }
@ -95,6 +103,10 @@ namespace CodeImp.DoomBuilder.Config
// Get map lumps
maplumpnames = cfg.ReadSetting("maplumpnames", new Hashtable());
// Get texture and flat sources
textureranges = cfg.ReadSetting("textures", new Hashtable());
flatranges = cfg.ReadSetting("flats", new Hashtable());
// Get thing categories
dic = cfg.ReadSetting("thingtypes", new Hashtable());
foreach(DictionaryEntry de in dic)

View file

@ -26,6 +26,7 @@ using System.Drawing.Imaging;
using System.IO;
using CodeImp.DoomBuilder.IO;
using System.Windows.Forms;
using SlimDX.Direct3D9;
#endregion
@ -161,6 +162,8 @@ namespace CodeImp.DoomBuilder.Data
LoadPalette();
General.WriteLogLine("Loading textures...");
LoadTextures();
General.WriteLogLine("Loading flats...");
LoadFlats();
}
// This unloads all data
@ -236,7 +239,7 @@ namespace CodeImp.DoomBuilder.Data
// This loads the textures
private void LoadTextures()
{
PatchNames pnames;
PatchNames pnames = new PatchNames();
ICollection<ImageData> images;
// Go for all opened containers
@ -282,16 +285,16 @@ namespace CodeImp.DoomBuilder.Data
return null;
}
// This returns a texture by string
public ImageData GetTextureByName(string name)
// This returns an image by string
public ImageData GetTextureImage(string name)
{
// Get the long name
long longname = Lump.MakeLongName(name);
return GetTextureByLongName(longname);
return GetTextureImage(longname);
}
// This returns a texture by long
public ImageData GetTextureByLongName(long longname)
// This returns an image by long
public ImageData GetTextureImage(long longname)
{
// Does this texture exist?
if(textures.ContainsKey(longname))
@ -305,21 +308,95 @@ namespace CodeImp.DoomBuilder.Data
return new NullImage();
}
}
// This returns a bitmap by string
public Bitmap GetTextureBitmap(string name)
{
ImageData img = GetTextureImage(name);
img.LoadImage();
return img.Bitmap;
}
// This returns a bitmap by string
public Bitmap GetTextureBitmap(long longname)
{
ImageData img = GetTextureImage(longname);
img.LoadImage();
return img.Bitmap;
}
// This returns a texture by string
public Texture GetTextureTexture(string name)
{
ImageData img = GetTextureImage(name);
img.LoadImage();
img.CreateTexture();
return img.Texture;
}
// This returns a texture by string
public Texture GetTextureTexture(long longname)
{
ImageData img = GetTextureImage(longname);
img.LoadImage();
img.CreateTexture();
return img.Texture;
}
#endregion
#region ================== Flats
// This returns a flat by string
public ImageData GetFlatByName(string name)
// This loads the flats
private void LoadFlats()
{
ICollection<ImageData> images;
// Go for all opened containers
foreach(DataReader dr in containers)
{
// Load flats
images = dr.LoadFlats();
if(images != null)
{
// Go for all flats
foreach(ImageData img in images)
{
// Add or replace in flats list
flats.Remove(img.LongName);
flats.Add(img.LongName, img);
}
}
}
}
// This returns a specific flat stream
public Stream GetFlatData(string pname)
{
Stream flat;
// Go for all opened containers
for(int i = containers.Count - 1; i >= 0; i--)
{
// This contain provides this flat?
flat = containers[i].GetFlatData(pname);
if(flat != null) return flat;
}
// No such patch found
return null;
}
// This returns an image by string
public ImageData GetFlatImage(string name)
{
// Get the long name
long longname = Lump.MakeLongName(name);
return GetFlatByLongName(longname);
return GetFlatImage(longname);
}
// This returns a flat by long
public ImageData GetFlatByLongName(long longname)
// This returns an image by long
public ImageData GetFlatImage(long longname)
{
// Does this flat exist?
if(flats.ContainsKey(longname))
@ -334,20 +411,54 @@ namespace CodeImp.DoomBuilder.Data
}
}
// This returns a bitmap by string
public Bitmap GetFlatBitmap(string name)
{
ImageData img = GetFlatImage(name);
img.LoadImage();
return img.Bitmap;
}
// This returns a bitmap by string
public Bitmap GetFlatBitmap(long longname)
{
ImageData img = GetFlatImage(longname);
img.LoadImage();
return img.Bitmap;
}
// This returns a texture by string
public Texture GetFlatTexture(string name)
{
ImageData img = GetFlatImage(name);
img.LoadImage();
img.CreateTexture();
return img.Texture;
}
// This returns a texture by string
public Texture GetFlatTexture(long longname)
{
ImageData img = GetFlatImage(longname);
img.LoadImage();
img.CreateTexture();
return img.Texture;
}
#endregion
#region ================== Sprites
// This returns a sprite by string
public ImageData GetSpriteByName(string name)
// This returns an image by string
public ImageData GetSpriteImage(string name)
{
// Get the long name
long longname = Lump.MakeLongName(name);
return GetSpriteByLongName(longname);
return GetSpriteImage(longname);
}
// This returns a sprite by long
public ImageData GetSpriteByLongName(long longname)
// This returns an image by long
public ImageData GetSpriteImage(long longname)
{
// Does this sprite exist?
if(sprites.ContainsKey(longname))
@ -362,6 +473,40 @@ namespace CodeImp.DoomBuilder.Data
}
}
// This returns a bitmap by string
public Bitmap GetSpriteBitmap(string name)
{
ImageData img = GetSpriteImage(name);
img.LoadImage();
return img.Bitmap;
}
// This returns a bitmap by string
public Bitmap GetSpriteBitmap(long longname)
{
ImageData img = GetSpriteImage(longname);
img.LoadImage();
return img.Bitmap;
}
// This returns a texture by string
public Texture GetSpriteTexture(string name)
{
ImageData img = GetSpriteImage(name);
img.LoadImage();
img.CreateTexture();
return img.Texture;
}
// This returns a texture by string
public Texture GetSpriteTexture(long longname)
{
ImageData img = GetSpriteImage(longname);
img.LoadImage();
img.CreateTexture();
return img.Texture;
}
#endregion
}
}

View file

@ -106,5 +106,15 @@ namespace CodeImp.DoomBuilder.Data
public virtual ICollection<ImageData> LoadTextures(PatchNames pnames) { return null; }
#endregion
#region ================== Flats
// When implemented, this loads the flats
public virtual ICollection<ImageData> LoadFlats() { return null; }
// When implemented, this returns the flat lump
public virtual Stream GetFlatData(string pname) { return null; }
#endregion
}
}

View file

@ -3,6 +3,8 @@ using System.Collections;
using System.Collections.Generic;
using System.Globalization;
using System.Text;
using System.IO;
using CodeImp.DoomBuilder.IO;
namespace CodeImp.DoomBuilder.Data
{
@ -14,9 +16,6 @@ namespace CodeImp.DoomBuilder.Data
#region ================== Variables
private DataReader source;
private string lumpname;
#endregion
#region ================== Properties
@ -26,11 +25,9 @@ namespace CodeImp.DoomBuilder.Data
#region ================== Constructor / Disposer
// Constructor
public FlatImage(string name, DataReader source, string lumpname)
public FlatImage(string name)
{
// Initialize
this.source = source;
this.lumpname = lumpname;
SetName(name);
// We have no destructor
@ -57,10 +54,42 @@ namespace CodeImp.DoomBuilder.Data
// This loads the image
public override void LoadImage()
{
Stream lumpdata;
MemoryStream mem;
IImageReader reader;
byte[] membytes;
// Leave when already loaded
if(this.IsLoaded) return;
// Get the lump data stream
lumpdata = General.Map.Data.GetPatchData(Name);
if(lumpdata != null)
{
// Copy lump data to memory
lumpdata.Seek(0, SeekOrigin.Begin);
membytes = new byte[(int)lumpdata.Length];
lumpdata.Read(membytes, 0, (int)lumpdata.Length);
mem = new MemoryStream(membytes);
mem.Seek(0, SeekOrigin.Begin);
// Get a reader for the data
reader = ImageDataFormat.GetImageReader(mem, ImageDataFormat.DOOMFLAT, General.Map.Data.Palette);
if(reader is UnknownImageReader)
{
// Data is in an unknown format!
General.WriteLogLine("WARNING: Flat lump '" + Name + "' data format could not be read!");
}
// Read data as bitmap
mem.Seek(0, SeekOrigin.Begin);
bitmap = reader.ReadAsBitmap(mem);
}
else
{
// Missing a patch lump!
General.WriteLogLine("WARNING: Missing flat lump '" + Name + "'!");
}
// Pass on to base
base.LoadImage();

View file

@ -130,21 +130,25 @@ namespace CodeImp.DoomBuilder.Data
{
BitmapData bmpdata;
// Clean up old memory if reserved
if(pixeldata != null)
// Only do this when data is not created yet
if((pixeldata == null) && IsLoaded)
{
General.VirtualFree((void*)pixeldata, new UIntPtr(pixeldatasize), General.MEM_RELEASE);
pixeldata = null;
GC.RemoveMemoryPressure(pixeldatasize);
// Clean up old memory if reserved
if(pixeldata != null)
{
General.VirtualFree((void*)pixeldata, new UIntPtr(pixeldatasize), General.MEM_RELEASE);
pixeldata = null;
GC.RemoveMemoryPressure(pixeldatasize);
}
// Make a data copy of the bits for the 2D renderer
bmpdata = bitmap.LockBits(new Rectangle(0, 0, bitmap.Size.Width, bitmap.Size.Height), ImageLockMode.ReadOnly, PixelFormat.Format32bppArgb);
pixeldatasize = (uint)(bmpdata.Width * bmpdata.Height * sizeof(PixelColor));
pixeldata = (PixelColor*)General.VirtualAlloc(IntPtr.Zero, new UIntPtr(pixeldatasize), General.MEM_COMMIT, General.PAGE_READWRITE);
General.CopyMemory((void*)pixeldata, bmpdata.Scan0.ToPointer(), new UIntPtr(pixeldatasize));
bitmap.UnlockBits(bmpdata);
GC.AddMemoryPressure(pixeldatasize);
}
// Make a data copy of the bits for the 2D renderer
bmpdata = bitmap.LockBits(new Rectangle(0, 0, bitmap.Size.Width, bitmap.Size.Height), ImageLockMode.ReadOnly, PixelFormat.Format32bppArgb);
pixeldatasize = (uint)(bmpdata.Width * bmpdata.Height * sizeof(PixelColor));
pixeldata = (PixelColor*)General.VirtualAlloc(IntPtr.Zero, new UIntPtr(pixeldatasize), General.MEM_COMMIT, General.PAGE_READWRITE);
General.CopyMemory((void*)pixeldata, bmpdata.Scan0.ToPointer(), new UIntPtr(pixeldatasize));
bitmap.UnlockBits(bmpdata);
GC.AddMemoryPressure(pixeldatasize);
}
// This creates the Direct3D texture
@ -153,7 +157,7 @@ namespace CodeImp.DoomBuilder.Data
MemoryStream memstream;
// Only do this when texture is not created yet
if(texture == null)
if((texture == null) && IsLoaded)
{
// Write to memory stream and read from memory
memstream = new MemoryStream();

View file

@ -0,0 +1,114 @@
#region ================== Copyright (c) 2007 Pascal vd Heiden
/*
* Copyright (c) 2007 Pascal vd Heiden, www.codeimp.com
* This program is released under GNU General Public License
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
*/
#endregion
#region ================== Namespaces
using System;
using System.Collections;
using System.Collections.Generic;
using System.Globalization;
using System.Text;
using System.IO;
using System.Drawing.Imaging;
using CodeImp.DoomBuilder.IO;
#endregion
namespace CodeImp.DoomBuilder.Data
{
public static class ImageDataFormat
{
// Input guess formats
public const int UNKNOWN = 0; // No clue.
public const int DOOMPICTURE = 1; // Could be Doom Picture format (column list rendered data)
public const int DOOMFLAT = 2; // Could be Doom Flat format (raw 8-bit pixel data)
// File format signatures
private static readonly int[] PNG_SIGNATURE = new int[] { 137, 80, 78, 71, 13, 10, 26, 10 };
private static readonly int[] GIF_SIGNATURE = new int[] { 71, 73, 70 };
private static readonly int[] BMP_SIGNATURE = new int[] { 66, 77 };
// This check image data and returns the appropriate image reader
public static IImageReader GetImageReader(Stream data, int guessformat, Playpal palette)
{
BinaryReader bindata = new BinaryReader(data);
DoomPictureReader picreader;
DoomFlatReader flatreader;
// First check the formats that provide the means to 'ensure' that
// it actually is that format. Then guess the Doom image format.
// Data long enough to check for signatures?
if(data.Length > 10)
{
// Check for PNG signature
data.Seek(0, SeekOrigin.Begin);
if(CheckSignature(data, PNG_SIGNATURE)) return new FileImageReader();
// Check for GIF signature
data.Seek(0, SeekOrigin.Begin);
if(CheckSignature(data, GIF_SIGNATURE)) return new FileImageReader();
// Check for BMP signature
data.Seek(0, SeekOrigin.Begin);
if(CheckSignature(data, BMP_SIGNATURE))
{
// Check if data size matches the size specified in the data
if(bindata.ReadUInt32() <= data.Length) return new FileImageReader();
}
}
// Could it be a doom picture?
if(guessformat == DOOMPICTURE)
{
// Check if data is valid for a doom picture
data.Seek(0, SeekOrigin.Begin);
picreader = new DoomPictureReader(palette);
if(picreader.Validate(data)) return picreader;
}
// Could it be a doom flat?
else if(guessformat == DOOMFLAT)
{
// Check if data is valid for a doom flat
data.Seek(0, SeekOrigin.Begin);
flatreader = new DoomFlatReader(palette);
if(flatreader.Validate(data)) return flatreader;
}
// Format not supported
return new UnknownImageReader();
}
// This checks a signature as byte array
// NOTE: Expects the stream position to be at the start of the
// signature, and expects the stream to be long enough.
private static bool CheckSignature(Stream data, int[] sig)
{
int b;
// Go for all bytes
for(int i = 0; i < sig.Length; i++)
{
// When byte doesnt match the signature, leave
b = data.ReadByte();
if(b != sig[i]) return false;
}
// Signature matches
return true;
}
}
}

View file

@ -49,6 +49,13 @@ namespace CodeImp.DoomBuilder.Data
#region ================== Constructor / Disposer
// Constructor for empty list
public PatchNames()
{
// Create array
pnames = new string[0];
}
// Constructor
public PatchNames(Stream stream)
{

View file

@ -96,12 +96,13 @@ namespace CodeImp.DoomBuilder.Data
public override void LoadImage()
{
uint datalength = (uint)(width * height * sizeof(PixelColor));
DoomPictureReader reader = new DoomPictureReader(General.Map.Data.Palette);
IImageReader reader;
BitmapData bitmapdata;
MemoryStream mem;
PixelColor* pixels;
Stream patchdata;
byte[] membytes;
bool failed = false;
// Leave when already loaded
if(this.IsLoaded) return;
@ -126,14 +127,33 @@ namespace CodeImp.DoomBuilder.Data
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("WARNING: Patch lump '" + p.lumpname + "' data format could not be read, while loading texture '" + this.Name + "'!");
failed = true;
break;
}
// Draw the patch
mem.Seek(0, SeekOrigin.Begin);
reader.DrawToPixelData(mem, pixels, width, height, p.x, p.y);
}
else
{
// Missing a patch lump!
General.WriteLogLine("WARNING: Missing patch lump '" + p.lumpname + "' while loading texture '" + this.Name + "'!");
}
}
// Done
bitmap.UnlockBits(bitmapdata);
// When failed, use the error picture
if(failed) bitmap = UnknownImageReader.ReadAsBitmap();
// Pass on to base
base.LoadImage();
}

View file

@ -129,6 +129,7 @@ namespace CodeImp.DoomBuilder.Data
public override ICollection<ImageData> LoadTextures(PatchNames pnames)
{
List<ImageData> images = new List<ImageData>();
string rangestart, rangeend;
Lump lump;
// Load two sets of textures, if available
@ -137,10 +138,59 @@ namespace CodeImp.DoomBuilder.Data
lump = file.FindLump("TEXTURE2");
if(lump != null) LoadTextureSet(lump.Stream, ref images, pnames);
// Read ranges from configuration
foreach(DictionaryEntry r in General.Map.Config.TextureRanges)
{
// Read start and end
rangestart = General.Map.Config.ReadSetting("textures." + r.Key + ".start", "");
rangeend = General.Map.Config.ReadSetting("textures." + r.Key + ".end", "");
if((rangestart.Length > 0) && (rangeend.Length > 0))
{
// Load texture range
LoadTexturesRange(rangestart, rangeend, ref images, pnames);
}
}
// Return result
return images;
}
// This loads a range of textures
private void LoadTexturesRange(string startlump, string endlump, ref List<ImageData> images, PatchNames pnames)
{
int startindex, endindex;
float defaultscale;
TextureImage image;
// Determine default scale
defaultscale = General.Map.Config.DefaultTextureScale;
// Continue until no more start can be found
startindex = file.FindLumpIndex(startlump);
while(startindex > -1)
{
// Find end index
endindex = file.FindLumpIndex(endlump, startindex + 1);
if(endindex == -1) endindex = file.Lumps.Count - 1;
// Go for all lumps between start and end exclusive
for(int i = startindex + 1; i < endindex; i++)
{
// Make the image object
image = new TextureImage(file.Lumps[i].Name, 0, 0, defaultscale, defaultscale);
// Add single patch
image.AddPatch(new TexturePatch(file.Lumps[i].Name, 0, 0));
// Add image to collection
images.Add(image);
}
// Find the next start
startindex = file.FindLumpIndex(startlump, endindex);
}
}
// This loads a set of textures
private void LoadTextureSet(Stream texturedata, ref List<ImageData> images, PatchNames pnames)
{
@ -263,5 +313,75 @@ namespace CodeImp.DoomBuilder.Data
}
#endregion
#region ================== Flats
// This loads the textures
public override ICollection<ImageData> LoadFlats()
{
List<ImageData> images = new List<ImageData>();
string rangestart, rangeend;
// Read ranges from configuration
foreach(DictionaryEntry r in General.Map.Config.FlatRanges)
{
// Read start and end
rangestart = General.Map.Config.ReadSetting("flats." + r.Key + ".start", "");
rangeend = General.Map.Config.ReadSetting("flats." + r.Key + ".end", "");
if((rangestart.Length > 0) && (rangeend.Length > 0))
{
// Load texture range
LoadFlatsRange(rangestart, rangeend, ref images);
}
}
// Return result
return images;
}
// This loads a range of flats
private void LoadFlatsRange(string startlump, string endlump, ref List<ImageData> images)
{
int startindex, endindex;
float defaultscale;
FlatImage image;
// Determine default scale
defaultscale = General.Map.Config.DefaultTextureScale;
// Continue until no more start can be found
startindex = file.FindLumpIndex(startlump);
while(startindex > -1)
{
// Find end index
endindex = file.FindLumpIndex(endlump, startindex + 1);
if(endindex == -1) endindex = file.Lumps.Count - 1;
// Go for all lumps between start and end exclusive
for(int i = startindex + 1; i < endindex; i++)
{
// Make the image object
image = new FlatImage(file.Lumps[i].Name);
// Add image to collection
images.Add(image);
}
// Find the next start
startindex = file.FindLumpIndex(startlump, endindex);
}
}
// This finds and returns a patch stream
public override Stream GetFlatData(string pname)
{
Lump lump;
// Find the lump
lump = file.FindLump(pname);
if(lump != null) return lump.Stream; else return null;
}
#endregion
}
}

234
Source/IO/DoomFlatReader.cs Normal file
View file

@ -0,0 +1,234 @@
#region ================== Copyright (c) 2007 Pascal vd Heiden
/*
* Copyright (c) 2007 Pascal vd Heiden, www.codeimp.com
* This program is released under GNU General Public License
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
*/
#endregion
#region ================== Namespaces
using System;
using System.Collections;
using System.Collections.Generic;
using System.Globalization;
using System.Text;
using System.IO;
using CodeImp.DoomBuilder.Map;
using CodeImp.DoomBuilder.Geometry;
using System.Drawing;
using CodeImp.DoomBuilder.Data;
using CodeImp.DoomBuilder.Rendering;
using System.Drawing.Imaging;
#endregion
namespace CodeImp.DoomBuilder.IO
{
public unsafe class DoomFlatReader : IImageReader
{
#region ================== Variables
// Palette to use
private Playpal palette;
#endregion
#region ================== Constructor / Disposer
// Constructor
public DoomFlatReader(Playpal palette)
{
// Initialize
this.palette = palette;
// We have no destructor
GC.SuppressFinalize(this);
}
#endregion
#region ================== Methods
// This validates the data as doom flat
public bool Validate(Stream stream)
{
float sqrlength;
// Check if the flat is square
sqrlength = (float)Math.Sqrt(stream.Length);
if(sqrlength == (float)Math.Truncate(sqrlength))
{
// Success when not 0
return ((int)sqrlength > 0);
}
// Check if the data is more than 4096
else if(stream.Length > 4096)
{
// Success
return true;
}
// Format invalid
return false;
}
// This creates a Bitmap from the given data
// Returns null on failure
public Bitmap ReadAsBitmap(Stream stream)
{
BitmapData bitmapdata;
PixelColor* pixeldata;
PixelColor* targetdata;
int width, height;
Bitmap bmp;
// Read pixel data
pixeldata = ReadAsPixelData(stream, out width, out height);
if(pixeldata != null)
{
// Create bitmap and lock pixels
bmp = new Bitmap(width, height, PixelFormat.Format32bppArgb);
bitmapdata = bmp.LockBits(new Rectangle(0, 0, width, height), ImageLockMode.WriteOnly, PixelFormat.Format32bppArgb);
targetdata = (PixelColor*)bitmapdata.Scan0.ToPointer();
// Copy the pixels
General.CopyMemory((void*)targetdata, (void*)pixeldata, new UIntPtr((uint)(width * height * sizeof(PixelColor))));
// Done
bmp.UnlockBits(bitmapdata);
}
else
{
// Failed loading picture
bmp = null;
}
// Free memory
General.VirtualFree((void*)pixeldata, new UIntPtr((uint)(width * height * sizeof(PixelColor))), General.MEM_RELEASE);
// Return result
return bmp;
}
// This draws the picture to the given pixel color data
// Throws exception on failure
public unsafe void DrawToPixelData(Stream stream, PixelColor* target, int targetwidth, int targetheight, int x, int y)
{
Bitmap bmp;
BitmapData bmpdata;
PixelColor* pixels;
int ox, oy, tx, ty;
int width, height;
// Get bitmap
bmp = ReadAsBitmap(stream);
width = bmp.Size.Width;
height = bmp.Size.Height;
// Lock bitmap pixels
bmpdata = bmp.LockBits(new Rectangle(0, 0, width, height), ImageLockMode.ReadOnly, PixelFormat.Format32bppArgb);
pixels = (PixelColor*)bmpdata.Scan0.ToPointer();
// Go for all pixels in the original image
for(ox = 0; ox < width; ox++)
{
for(oy = 0; oy < height; oy++)
{
// Copy this pixel?
if(pixels[oy * width + ox].a > 0.5f)
{
// Calculate target pixel and copy when within bounds
tx = x + ox;
ty = y + oy;
if((tx >= 0) && (tx < targetwidth) && (ty >= 0) && (ty < targetheight))
target[ty * targetwidth + tx] = pixels[oy * width + ox];
}
}
}
// Done
bmp.UnlockBits(bmpdata);
}
// This creates pixel color data from the given data
// Returns null on failure
public PixelColor* ReadAsPixelData(Stream stream, out int width, out int height)
{
BinaryReader reader = new BinaryReader(stream);
PixelColor* pixeldata = null;
float sqrlength;
byte[] bytes;
uint datalength;
// Check if the flat is square
sqrlength = (float)Math.Sqrt(stream.Length);
if(sqrlength == (float)Math.Truncate(sqrlength))
{
// Calculate image size
width = (int)sqrlength;
height = (int)sqrlength;
}
// Check if the data is more than 4096
else if(stream.Length > 4096)
{
// Image will be 64x64
width = 64;
height = 64;
}
else
{
// Invalid
width = 0;
height = 0;
return null;
}
#if !DEBUG
try
{
#endif
// Valid width and height?
if((width <= 0) || (height <= 0)) return null;
// Allocate memory
datalength = (uint)(sizeof(PixelColor) * width * height);
pixeldata = (PixelColor*)General.VirtualAlloc(IntPtr.Zero, new UIntPtr(datalength), General.MEM_COMMIT, General.PAGE_READWRITE);
General.ZeroMemory(new IntPtr(pixeldata), (int)datalength);
// Read flat bytes from stream
bytes = new byte[width * height];
stream.Read(bytes, 0, width * height);
// Convert bytes with palette
for(uint i = 0; i < width * height; i++) pixeldata[i] = palette[bytes[i]];
// Return pointer
return pixeldata;
#if !DEBUG
}
catch(Exception)
{
// Free memory if allocated
if(datalength > 0) General.VirtualFree((void*)pixeldata, new UIntPtr(datalength), General.MEM_RELEASE);
// Return nothing
return null;
}
#endif
}
#endregion
}
}

View file

@ -112,7 +112,7 @@ namespace CodeImp.DoomBuilder.IO
// Create new item
t = map.CreateThing();
t.Update(type, x, y, 0, angle, flags, 0, 0, Thing.EMPTY_ARGS);
t.DetermineSector();
//t.DetermineSector();
t.UpdateConfiguration();
}

View file

@ -33,12 +33,8 @@ using System.Drawing.Imaging;
namespace CodeImp.DoomBuilder.IO
{
public unsafe class DoomPictureReader
public unsafe class DoomPictureReader : IImageReader
{
#region ================== Constants
#endregion
#region ================== Variables
// Palette to use
@ -46,10 +42,6 @@ namespace CodeImp.DoomBuilder.IO
#endregion
#region ================== Properties
#endregion
#region ================== Constructor / Disposer
// Constructor
@ -57,12 +49,54 @@ namespace CodeImp.DoomBuilder.IO
{
// Initialize
this.palette = palette;
// We have no destructor
GC.SuppressFinalize(this);
}
#endregion
#region ================== Methods
// This validates the data as doom picture
public bool Validate(Stream stream)
{
BinaryReader reader = new BinaryReader(stream);
int width, height;
int dataoffset;
int datalength;
int columnaddr;
// Initialize
dataoffset = (int)stream.Position;
datalength = (int)stream.Length - (int)stream.Position;
// Need at least 4 bytes
if(datalength < 4) return false;
// Read size and offset
width = reader.ReadInt16();
height = reader.ReadInt16();
reader.ReadInt16();
reader.ReadInt16();
// Valid width and height?
if((width <= 0) || (height <= 0)) return false;
// Go for all columns
for(int x = 0; x < width; x++)
{
// Get column address
columnaddr = reader.ReadInt32();
// Check if address is outside valid range
if((columnaddr < (8 + width * 4)) || (columnaddr >= datalength)) return false;
}
// Return success
return true;
}
// This creates a Bitmap from the given data
// Returns null on failure
public Bitmap ReadAsBitmap(Stream stream)
@ -87,13 +121,18 @@ namespace CodeImp.DoomBuilder.IO
// Done
bmp.UnlockBits(bitmapdata);
return bmp;
}
else
{
// Failed loading picture
return null;
bmp = null;
}
// Free memory
General.VirtualFree((void*)pixeldata, new UIntPtr((uint)(width * height * sizeof(PixelColor))), General.MEM_RELEASE);
// Return result
return bmp;
}
// This draws the picture to the given pixel color data
@ -152,59 +191,64 @@ namespace CodeImp.DoomBuilder.IO
try
{
#endif
// Read size and offset
width = reader.ReadInt16();
height = reader.ReadInt16();
offsetx = reader.ReadInt16();
offsety = reader.ReadInt16();
// Read size and offset
width = reader.ReadInt16();
height = reader.ReadInt16();
offsetx = reader.ReadInt16();
offsety = reader.ReadInt16();
// Valid width and height?
if((width <= 0) || (height <= 0)) return null;
// Read the column addresses
columns = new int[width];
for(int x = 0; x < width; x++) columns[x] = reader.ReadInt32();
// Allocate memory
datalength = (uint)(sizeof(PixelColor) * width * height);
pixeldata = (PixelColor*)General.VirtualAlloc(IntPtr.Zero, new UIntPtr(datalength), General.MEM_COMMIT, General.PAGE_READWRITE);
General.ZeroMemory(new IntPtr(pixeldata), (int)datalength);
// Go for all columns
for(int x = 0; x < width; x++)
{
// Seek to column start
stream.Seek(dataoffset + columns[x], SeekOrigin.Begin);
// Read first post start
y = reader.ReadByte();
// Read the column addresses
columns = new int[width];
for(int x = 0; x < width; x++) columns[x] = reader.ReadInt32();
// Allocate memory
datalength = (uint)(sizeof(PixelColor) * width * height);
pixeldata = (PixelColor*)General.VirtualAlloc(IntPtr.Zero, new UIntPtr(datalength), General.MEM_COMMIT, General.PAGE_READWRITE);
General.ZeroMemory(new IntPtr(pixeldata), (int)datalength);
// Go for all columns
for(int x = 0; x < width; x++)
// Continue while not end of column reached
while(y < 255)
{
// Seek to column start
stream.Seek(dataoffset + columns[x], SeekOrigin.Begin);
// Read first post start
y = reader.ReadByte();
// Read number of pixels in post
count = reader.ReadByte();
// Continue while not end of column reached
while(y < 255)
// Skip unused pixel
stream.Seek(1, SeekOrigin.Current);
// Draw post
for(int yo = 0; yo < count; yo++)
{
// Read number of pixels in post
count = reader.ReadByte();
// Read pixel color index
p = reader.ReadByte();
// Skip unused pixel
stream.Seek(1, SeekOrigin.Current);
// Draw post
for(int yo = 0; yo < count; yo++)
{
// Read pixel color index
p = reader.ReadByte();
// Draw pixel
pixeldata[(y + yo) * width + x] = palette[p];
}
// Skip unused pixel
stream.Seek(1, SeekOrigin.Current);
// Read next post start
y = reader.ReadByte();
// Draw pixel
pixeldata[(y + yo) * width + x] = palette[p];
}
}
// Skip unused pixel
stream.Seek(1, SeekOrigin.Current);
// Return pointer
return pixeldata;
// Read next post start
y = reader.ReadByte();
}
}
// Return pointer
return pixeldata;
#if !DEBUG
}
catch(Exception)

View file

@ -0,0 +1,99 @@
#region ================== Copyright (c) 2007 Pascal vd Heiden
/*
* Copyright (c) 2007 Pascal vd Heiden, www.codeimp.com
* This program is released under GNU General Public License
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
*/
#endregion
#region ================== Namespaces
using System;
using System.Collections;
using System.Collections.Generic;
using System.Globalization;
using System.Text;
using System.IO;
using CodeImp.DoomBuilder.Map;
using CodeImp.DoomBuilder.Geometry;
using System.Drawing;
using CodeImp.DoomBuilder.Data;
using CodeImp.DoomBuilder.Rendering;
using System.Drawing.Imaging;
#endregion
namespace CodeImp.DoomBuilder.IO
{
public unsafe class FileImageReader : IImageReader
{
#region ================== Constructor / Disposer
// Constructor
public FileImageReader()
{
// We have no destructor
GC.SuppressFinalize(this);
}
#endregion
#region ================== Methods
// This reads the image and returns a Bitmap
public Bitmap ReadAsBitmap(Stream stream)
{
return (Bitmap)Bitmap.FromStream(stream);
}
// This draws the picture to the given pixel color data
// Throws exception on failure
public unsafe void DrawToPixelData(Stream stream, PixelColor* target, int targetwidth, int targetheight, int x, int y)
{
Bitmap bmp;
BitmapData bmpdata;
PixelColor* pixels;
int ox, oy, tx, ty;
int width, height;
// Get bitmap
bmp = ReadAsBitmap(stream);
width = bmp.Size.Width;
height = bmp.Size.Height;
// Lock bitmap pixels
bmpdata = bmp.LockBits(new Rectangle(0, 0, width, height), ImageLockMode.ReadOnly, PixelFormat.Format32bppArgb);
pixels = (PixelColor*)bmpdata.Scan0.ToPointer();
// Go for all pixels in the original image
for(ox = 0; ox < width; ox++)
{
for(oy = 0; oy < height; oy++)
{
// Copy this pixel?
if(pixels[oy * width + ox].a > 0.5f)
{
// Calculate target pixel and copy when within bounds
tx = x + ox;
ty = y + oy;
if((tx >= 0) && (tx < targetwidth) && (ty >= 0) && (ty < targetheight))
target[ty * targetwidth + tx] = pixels[oy * width + ox];
}
}
}
// Done
bmp.UnlockBits(bmpdata);
}
#endregion
}
}

View file

@ -21,21 +21,22 @@ using System.Collections;
using System.Collections.Generic;
using System.Globalization;
using System.Text;
using System.IO;
using CodeImp.DoomBuilder.Map;
using CodeImp.DoomBuilder.Geometry;
using System.Drawing;
using CodeImp.DoomBuilder.Data;
using CodeImp.DoomBuilder.Rendering;
using System.Drawing.Imaging;
#endregion
namespace CodeImp.DoomBuilder.Data
namespace CodeImp.DoomBuilder.IO
{
public enum TexturePatchFormat : int
public unsafe interface IImageReader
{
Unknown = 0, // Not determined yet
Invalid = 1, // Considered invalid
DoomImage = 2, // Doom Image format (column list rendered data)
DoomFlat = 3, // Doom Flat format (raw 8-bit pixel data)
PNG = 4, // Portable Network Graphic
Bitmap_P8 = 5, // Bitmap 8-bit Paletted
Bitmap_B5G6R5 = 6, // Bitmap 16-bit
Bitmap_B8G8R8 = 7, // Bitmap 24-bit
Bitmap_A8B8G8R8 = 8, // Bitmap 32-bit
// Methods
Bitmap ReadAsBitmap(Stream stream);
void DrawToPixelData(Stream stream, PixelColor* target, int targetwidth, int targetheight, int x, int y);
}
}

View file

@ -0,0 +1,105 @@
#region ================== Copyright (c) 2007 Pascal vd Heiden
/*
* Copyright (c) 2007 Pascal vd Heiden, www.codeimp.com
* This program is released under GNU General Public License
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
*/
#endregion
#region ================== Namespaces
using System;
using System.Collections;
using System.Collections.Generic;
using System.Globalization;
using System.Text;
using System.IO;
using CodeImp.DoomBuilder.Map;
using CodeImp.DoomBuilder.Geometry;
using System.Drawing;
using CodeImp.DoomBuilder.Data;
using CodeImp.DoomBuilder.Rendering;
using System.Drawing.Imaging;
#endregion
namespace CodeImp.DoomBuilder.IO
{
public unsafe class UnknownImageReader : IImageReader
{
#region ================== Constructor / Disposer
// Constructor
public UnknownImageReader()
{
// We have no destructor
GC.SuppressFinalize(this);
}
#endregion
#region ================== Methods
// This reads the image and returns a Bitmap
public Bitmap ReadAsBitmap(Stream stream)
{
return new Bitmap(CodeImp.DoomBuilder.Properties.Resources.UnknownImage);
}
// This reads the image and returns a Bitmap
public static Bitmap ReadAsBitmap()
{
return new Bitmap(CodeImp.DoomBuilder.Properties.Resources.UnknownImage);
}
// This draws the picture to the given pixel color data
// Throws exception on failure
public unsafe void DrawToPixelData(Stream stream, PixelColor* target, int targetwidth, int targetheight, int x, int y)
{
Bitmap bmp;
BitmapData bmpdata;
PixelColor* pixels;
int ox, oy, tx, ty;
int width, height;
// Get bitmap
bmp = ReadAsBitmap(stream);
width = bmp.Size.Width;
height = bmp.Size.Height;
// Lock bitmap pixels
bmpdata = bmp.LockBits(new Rectangle(0, 0, width, height), ImageLockMode.ReadOnly, PixelFormat.Format32bppArgb);
pixels = (PixelColor*)bmpdata.Scan0.ToPointer();
// Go for all pixels in the original image
for(ox = 0; ox < width; ox++)
{
for(oy = 0; oy < height; oy++)
{
// Copy this pixel?
if(pixels[oy * width + ox].a > 0.5f)
{
// Calculate target pixel and copy when within bounds
tx = x + ox;
ty = y + oy;
if((tx >= 0) && (tx < targetwidth) && (ty >= 0) && (ty < targetheight))
target[ty * targetwidth + tx] = pixels[oy * width + ox];
}
}
}
// Done
bmp.UnlockBits(bmpdata);
}
#endregion
}
}

View file

@ -30,13 +30,13 @@ namespace CodeImp.DoomBuilder.Interface
{
System.Windows.Forms.Label label1;
System.Windows.Forms.GroupBox groupBox1;
System.Windows.Forms.Label label13;
System.Windows.Forms.Label label5;
System.Windows.Forms.Label label4;
System.Windows.Forms.Label label3;
System.Windows.Forms.Label label2;
this.backoffset = new System.Windows.Forms.Label();
this.backoffsetlabel = new System.Windows.Forms.Label();
this.frontoffset = new System.Windows.Forms.Label();
this.frontoffsetlabel = new System.Windows.Forms.Label();
this.tag = new System.Windows.Forms.Label();
this.angle = new System.Windows.Forms.Label();
this.length = new System.Windows.Forms.Label();
@ -57,8 +57,6 @@ namespace CodeImp.DoomBuilder.Interface
this.backhightex = new System.Windows.Forms.Panel();
label1 = new System.Windows.Forms.Label();
groupBox1 = new System.Windows.Forms.GroupBox();
label13 = new System.Windows.Forms.Label();
label5 = new System.Windows.Forms.Label();
label4 = new System.Windows.Forms.Label();
label3 = new System.Windows.Forms.Label();
label2 = new System.Windows.Forms.Label();
@ -81,9 +79,9 @@ namespace CodeImp.DoomBuilder.Interface
groupBox1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)));
groupBox1.Controls.Add(this.backoffset);
groupBox1.Controls.Add(label13);
groupBox1.Controls.Add(this.backoffsetlabel);
groupBox1.Controls.Add(this.frontoffset);
groupBox1.Controls.Add(label5);
groupBox1.Controls.Add(this.frontoffsetlabel);
groupBox1.Controls.Add(this.tag);
groupBox1.Controls.Add(this.angle);
groupBox1.Controls.Add(this.length);
@ -108,14 +106,14 @@ namespace CodeImp.DoomBuilder.Interface
this.backoffset.TabIndex = 17;
this.backoffset.Text = "100, 100";
//
// label13
// backoffsetlabel
//
label13.AutoSize = true;
label13.Location = new System.Drawing.Point(111, 77);
label13.Name = "label13";
label13.Size = new System.Drawing.Size(66, 14);
label13.TabIndex = 14;
label13.Text = "Back offset:";
this.backoffsetlabel.AutoSize = true;
this.backoffsetlabel.Location = new System.Drawing.Point(111, 77);
this.backoffsetlabel.Name = "backoffsetlabel";
this.backoffsetlabel.Size = new System.Drawing.Size(66, 14);
this.backoffsetlabel.TabIndex = 14;
this.backoffsetlabel.Text = "Back offset:";
//
// frontoffset
//
@ -126,14 +124,14 @@ namespace CodeImp.DoomBuilder.Interface
this.frontoffset.TabIndex = 11;
this.frontoffset.Text = "100, 100";
//
// label5
// frontoffsetlabel
//
label5.AutoSize = true;
label5.Location = new System.Drawing.Point(110, 58);
label5.Name = "label5";
label5.Size = new System.Drawing.Size(67, 14);
label5.TabIndex = 8;
label5.Text = "Front offset:";
this.frontoffsetlabel.AutoSize = true;
this.frontoffsetlabel.Location = new System.Drawing.Point(110, 58);
this.frontoffsetlabel.Name = "frontoffsetlabel";
this.frontoffsetlabel.Size = new System.Drawing.Size(67, 14);
this.frontoffsetlabel.TabIndex = 8;
this.frontoffsetlabel.Text = "Front offset:";
//
// tag
//
@ -388,6 +386,8 @@ namespace CodeImp.DoomBuilder.Interface
private System.Windows.Forms.Panel backhightex;
private System.Windows.Forms.GroupBox frontpanel;
private System.Windows.Forms.GroupBox backpanel;
private System.Windows.Forms.Label backoffsetlabel;
private System.Windows.Forms.Label frontoffsetlabel;
}
}

View file

@ -50,8 +50,6 @@ namespace CodeImp.DoomBuilder.Interface
length.Text = l.Length.ToString("0.##");
angle.Text = l.AngleDeg.ToString() + "\u00B0";
tag.Text = l.Tag.ToString();
frontoffset.Visible = (l.Front != null);
backoffset.Visible = (l.Front != null);
// Front side available?
if(l.Front != null)
@ -61,9 +59,26 @@ namespace CodeImp.DoomBuilder.Interface
fronthighname.Text = l.Front.HighTexture;
frontmidname.Text = l.Front.MiddleTexture;
frontlowname.Text = l.Front.LowTexture;
fronthightex.BackgroundImage = FindTexture(l.Front.HighTexture);
frontmidtex.BackgroundImage = FindTexture(l.Front.MiddleTexture);
frontlowtex.BackgroundImage = FindTexture(l.Front.LowTexture);
fronthightex.BackgroundImage = General.Map.Data.GetTextureBitmap(l.Front.HighTexture);
frontmidtex.BackgroundImage = General.Map.Data.GetTextureBitmap(l.Front.MiddleTexture);
frontlowtex.BackgroundImage = General.Map.Data.GetTextureBitmap(l.Front.LowTexture);
frontoffsetlabel.Enabled = true;
frontoffset.Enabled = true;
frontpanel.Enabled = true;
}
else
{
// Show no info
frontoffsetlabel.Enabled = false;
frontoffset.Enabled = false;
frontpanel.Enabled = false;
frontoffset.Text = "--, --";
fronthighname.Text = "";
frontmidname.Text = "";
frontlowname.Text = "";
fronthightex.BackgroundImage = null;
frontmidtex.BackgroundImage = null;
frontlowtex.BackgroundImage = null;
}
// Back size available?
@ -74,14 +89,27 @@ namespace CodeImp.DoomBuilder.Interface
backhighname.Text = l.Back.HighTexture;
backmidname.Text = l.Back.MiddleTexture;
backlowname.Text = l.Back.LowTexture;
backhightex.BackgroundImage = FindTexture(l.Back.HighTexture);
backmidtex.BackgroundImage = FindTexture(l.Back.MiddleTexture);
backlowtex.BackgroundImage = FindTexture(l.Back.LowTexture);
backhightex.BackgroundImage = General.Map.Data.GetTextureBitmap(l.Back.HighTexture);
backmidtex.BackgroundImage = General.Map.Data.GetTextureBitmap(l.Back.MiddleTexture);
backlowtex.BackgroundImage = General.Map.Data.GetTextureBitmap(l.Back.LowTexture);
backoffsetlabel.Enabled = true;
backoffset.Enabled = true;
backpanel.Enabled = true;
}
else
{
// Show no info
backoffsetlabel.Enabled = false;
backoffset.Enabled = false;
backpanel.Enabled = false;
backoffset.Text = "--, --";
backhighname.Text = "";
backmidname.Text = "";
backlowname.Text = "";
backhightex.BackgroundImage = null;
backmidtex.BackgroundImage = null;
backlowtex.BackgroundImage = null;
}
// Show panels
frontpanel.Visible = (l.Front != null);
backpanel.Visible = (l.Back != null);
// Show the whole thing
this.Show();
@ -91,26 +119,19 @@ namespace CodeImp.DoomBuilder.Interface
// When visible changed
protected override void OnVisibleChanged(EventArgs e)
{
// Hide panels
// Hiding panels
if(!this.Visible)
{
frontpanel.Visible = false;
backpanel.Visible = false;
fronthightex.BackgroundImage = null;
frontmidtex.BackgroundImage = null;
frontlowtex.BackgroundImage = null;
backhightex.BackgroundImage = null;
backmidtex.BackgroundImage = null;
backlowtex.BackgroundImage = null;
}
// Call base
base.OnVisibleChanged(e);
}
// This loads and returns the texture image if possible
private Image FindTexture(string name)
{
ImageData img;
// Get it
img = General.Map.Data.GetTextureByName(name);
img.LoadImage();
return img.Bitmap;
}
}
}

View file

@ -132,21 +132,15 @@
<metadata name="backoffset.Locked" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="label13.Locked" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<metadata name="backoffsetlabel.Locked" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="label13.GenerateMember" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>False</value>
</metadata>
<metadata name="frontoffset.Locked" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="label5.Locked" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<metadata name="frontoffsetlabel.Locked" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="label5.GenerateMember" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>False</value>
</metadata>
<metadata name="tag.Locked" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>

View file

@ -56,23 +56,26 @@ namespace CodeImp.DoomBuilder.Interface
brightness.Text = s.Brightness.ToString();
floorname.Text = s.FloorTexture;
ceilingname.Text = s.CeilTexture;
floortex.BackgroundImage = FindFlat(s.FloorTexture);
ceilingtex.BackgroundImage = FindFlat(s.CeilTexture);
floortex.BackgroundImage = General.Map.Data.GetFlatBitmap(s.FloorTexture);
ceilingtex.BackgroundImage = General.Map.Data.GetFlatBitmap(s.CeilTexture);
// Show the whole thing
this.Show();
this.Update();
}
// This loads and returns the flat image if possible
private Image FindFlat(string name)
// When visible changed
protected override void OnVisibleChanged(EventArgs e)
{
ImageData img;
// Hiding panels
if(!this.Visible)
{
floortex.BackgroundImage = null;
ceilingtex.BackgroundImage = null;
}
// Get it
img = General.Map.Data.GetFlatByName(name);
img.LoadImage();
return img.Bitmap;
// Call base
base.OnVisibleChanged(e);
}
}
}

View file

@ -47,13 +47,14 @@ namespace CodeImp.DoomBuilder.Interface
ThingTypeInfo ti;
int zvalue;
string zinfo;
// Lookup thing info
ti = General.Map.Config.GetThingInfo(t.Type);
// TODO: Lookup action description from config
// Determine z info to show
t.DetermineSector();
if(t.Sector != null)
{
// Hangs from ceiling?
@ -71,7 +72,7 @@ namespace CodeImp.DoomBuilder.Interface
else
{
zvalue = t.ZOffset;
if(zvalue > 0) zinfo = "+" + zvalue.ToString(); else zinfo = zvalue.ToString();
if(zvalue >= 0) zinfo = "+" + zvalue.ToString(); else zinfo = zvalue.ToString();
}
// Thing info
@ -81,22 +82,24 @@ namespace CodeImp.DoomBuilder.Interface
tag.Text = ""; // TODO
angle.Text = t.AngleDeg.ToString() + "\u00B0";
spritename.Text = ti.Sprite;
spritetex.BackgroundImage = FindSprite(ti.Sprite);
spritetex.BackgroundImage = General.Map.Data.GetSpriteBitmap(ti.SpriteLongName);
// Show the whole thing
this.Show();
this.Update();
}
// This loads and returns the sprite image if possible
private Image FindSprite(string name)
// When visible changed
protected override void OnVisibleChanged(EventArgs e)
{
ImageData img;
// Hiding panels
if(!this.Visible)
{
spritetex.BackgroundImage = null;
}
// Get it
img = General.Map.Data.GetSpriteByName(name);
img.LoadImage();
return img.Bitmap;
// Call base
base.OnVisibleChanged(e);
}
}
}

View file

@ -137,6 +137,13 @@ namespace CodeImp.DoomBuilder.Properties {
}
}
internal static System.Drawing.Bitmap UnknownImage {
get {
object obj = ResourceManager.GetObject("UnknownImage", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
internal static System.Drawing.Bitmap VerticesMode {
get {
object obj = ResourceManager.GetObject("VerticesMode", resourceCulture);

View file

@ -157,4 +157,7 @@
<data name="Splash2small" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\Splash2small.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="UnknownImage" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\UnknownImage.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
</root>

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.6 KiB