mirror of
https://git.do.srb2.org/STJr/UltimateZoneBuilder.git
synced 2025-01-18 14:31:50 +00:00
drama
This commit is contained in:
parent
065f1e6790
commit
319be16c03
10 changed files with 783 additions and 0 deletions
58
Source/Data/DataLocation.cs
Normal file
58
Source/Data/DataLocation.cs
Normal file
|
@ -0,0 +1,58 @@
|
|||
|
||||
#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;
|
||||
|
||||
#endregion
|
||||
|
||||
namespace CodeImp.DoomBuilder.Data
|
||||
{
|
||||
internal struct DataLocation
|
||||
{
|
||||
// Constants
|
||||
public const int RESOURCE_WAD = 0;
|
||||
public const int RESOURCE_DIRECTORY = 1;
|
||||
|
||||
// Members
|
||||
public int type;
|
||||
public string location;
|
||||
public bool textures;
|
||||
public bool flats;
|
||||
|
||||
// Constructor
|
||||
public DataLocation(int type, string location, bool textures, bool flats)
|
||||
{
|
||||
// Initialize
|
||||
this.type = type;
|
||||
this.location = location;
|
||||
this.textures = textures;
|
||||
this.flats = flats;
|
||||
}
|
||||
|
||||
// This displays the struct as string
|
||||
public override string ToString()
|
||||
{
|
||||
// Simply show location
|
||||
return location;
|
||||
}
|
||||
}
|
||||
}
|
88
Source/Data/DataLocationList.cs
Normal file
88
Source/Data/DataLocationList.cs
Normal file
|
@ -0,0 +1,88 @@
|
|||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Text;
|
||||
using CodeImp.DoomBuilder.IO;
|
||||
using System.Collections.Specialized;
|
||||
|
||||
namespace CodeImp.DoomBuilder.Data
|
||||
{
|
||||
internal class DataLocationList : List<DataLocation>
|
||||
{
|
||||
#region ================== Constructors
|
||||
|
||||
// This creates a new list
|
||||
public DataLocationList()
|
||||
{
|
||||
}
|
||||
|
||||
// This creates a list from a configuration structure
|
||||
public DataLocationList(Configuration cfg, string path)
|
||||
{
|
||||
IDictionary resinfo, rlinfo;
|
||||
DataLocation res;
|
||||
|
||||
// Go for all items in the map info
|
||||
resinfo = cfg.ReadSetting(path, new ListDictionary());
|
||||
foreach(DictionaryEntry rl in resinfo)
|
||||
{
|
||||
// Item is a structure?
|
||||
if(rl.Value is IDictionary)
|
||||
{
|
||||
// Create resource location
|
||||
rlinfo = (IDictionary)rl.Value;
|
||||
res = new DataLocation();
|
||||
|
||||
// Copy information from Configuration to ResourceLocation
|
||||
if(rlinfo.Contains("type") && (rlinfo["type"] is int)) res.type = (int)rlinfo["type"];
|
||||
if(rlinfo.Contains("location") && (rlinfo["location"] is string)) res.location = (string)rlinfo["location"];
|
||||
if(rlinfo.Contains("textures") && (rlinfo["textures"] is bool)) res.textures = (bool)rlinfo["textures"];
|
||||
if(rlinfo.Contains("flats") && (rlinfo["flats"] is bool)) res.flats = (bool)rlinfo["flats"];
|
||||
|
||||
// Add resource
|
||||
Add(res);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region ================== Methods
|
||||
|
||||
// This merges two lists together
|
||||
public static DataLocationList Combined(DataLocationList a, DataLocationList b)
|
||||
{
|
||||
DataLocationList result = new DataLocationList();
|
||||
result.AddRange(a);
|
||||
result.AddRange(b);
|
||||
return result;
|
||||
}
|
||||
|
||||
// This writes the list to configuration
|
||||
public void WriteToConfig(Configuration cfg, string path)
|
||||
{
|
||||
IDictionary resinfo, rlinfo;
|
||||
|
||||
// Fill structure
|
||||
resinfo = new ListDictionary();
|
||||
for(int i = 0; i < this.Count; i++)
|
||||
{
|
||||
// Create structure for resource
|
||||
rlinfo = new ListDictionary();
|
||||
rlinfo.Add("type", this[i].type);
|
||||
rlinfo.Add("location", this[i].location);
|
||||
rlinfo.Add("textures", this[i].textures);
|
||||
rlinfo.Add("flats", this[i].flats);
|
||||
|
||||
// Add structure
|
||||
resinfo.Add("resource" + i.ToString(CultureInfo.InvariantCulture), rlinfo);
|
||||
}
|
||||
|
||||
// Write to config
|
||||
cfg.WriteSetting(path, resinfo);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
82
Source/Data/DataManager.cs
Normal file
82
Source/Data/DataManager.cs
Normal file
|
@ -0,0 +1,82 @@
|
|||
|
||||
#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.Drawing;
|
||||
using System.Drawing.Imaging;
|
||||
using System.IO;
|
||||
|
||||
#endregion
|
||||
|
||||
namespace CodeImp.DoomBuilder.Data
|
||||
{
|
||||
internal class DataManager : IDisposable
|
||||
{
|
||||
#region ================== Constants
|
||||
|
||||
#endregion
|
||||
|
||||
#region ================== Variables
|
||||
|
||||
// Disposing
|
||||
private bool isdisposed = false;
|
||||
|
||||
#endregion
|
||||
|
||||
#region ================== Properties
|
||||
|
||||
// Disposing
|
||||
public bool IsDisposed { get { return isdisposed; } }
|
||||
|
||||
#endregion
|
||||
|
||||
#region ================== Constructor / Disposer
|
||||
|
||||
// Constructor
|
||||
public DataManager()
|
||||
{
|
||||
// Initialize
|
||||
|
||||
// We have no destructor
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
|
||||
// Diposer
|
||||
public void Dispose()
|
||||
{
|
||||
// Not already disposed?
|
||||
if(!isdisposed)
|
||||
{
|
||||
// Clean up
|
||||
|
||||
// Done
|
||||
isdisposed = true;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region ================== Methods
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
77
Source/Data/FileImage.cs
Normal file
77
Source/Data/FileImage.cs
Normal file
|
@ -0,0 +1,77 @@
|
|||
|
||||
#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.Drawing;
|
||||
using System.Drawing.Imaging;
|
||||
using System.IO;
|
||||
|
||||
#endregion
|
||||
|
||||
namespace CodeImp.DoomBuilder.Data
|
||||
{
|
||||
internal class FileImage : ImageData
|
||||
{
|
||||
#region ================== Variables
|
||||
|
||||
private string filepathname;
|
||||
|
||||
#endregion
|
||||
|
||||
#region ================== Constructor / Disposer
|
||||
|
||||
// Constructor
|
||||
public FileImage(string filepathname)
|
||||
{
|
||||
// Initialize
|
||||
this.filepathname = filepathname;
|
||||
this.name = Path.GetFileNameWithoutExtension(filepathname);
|
||||
|
||||
// We have no destructor
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region ================== Methods
|
||||
|
||||
// This loads the image
|
||||
public override void LoadImage()
|
||||
{
|
||||
//Bitmap fileimg;
|
||||
|
||||
// Leave when already loaded
|
||||
if(this.IsLoaded) return;
|
||||
|
||||
// Load file and convert to the right pixel format
|
||||
//fileimg = (Bitmap)Bitmap.FromFile(filepathname);
|
||||
//bitmap = fileimg.Clone(new Rectangle(new Point(0, 0), fileimg.Size), PixelFormat.Format32bppArgb);
|
||||
//fileimg.Dispose();
|
||||
bitmap = (Bitmap)Bitmap.FromFile(filepathname);
|
||||
|
||||
// Pass on to base
|
||||
base.LoadImage();
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
41
Source/Data/IDataContainer.cs
Normal file
41
Source/Data/IDataContainer.cs
Normal file
|
@ -0,0 +1,41 @@
|
|||
|
||||
#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.Drawing;
|
||||
using System.Drawing.Imaging;
|
||||
using System.IO;
|
||||
using CodeImp.DoomBuilder.IO;
|
||||
|
||||
#endregion
|
||||
|
||||
namespace CodeImp.DoomBuilder.Data
|
||||
{
|
||||
internal interface IDataContainer : IDisposable
|
||||
{
|
||||
// Properties
|
||||
bool IsDisposed { get; }
|
||||
|
||||
// Methods
|
||||
void Dispose();
|
||||
}
|
||||
}
|
146
Source/Data/ImageData.cs
Normal file
146
Source/Data/ImageData.cs
Normal file
|
@ -0,0 +1,146 @@
|
|||
|
||||
#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.Drawing;
|
||||
using SlimDX.Direct3D9;
|
||||
using System.Drawing.Imaging;
|
||||
using CodeImp.DoomBuilder.Rendering;
|
||||
|
||||
#endregion
|
||||
|
||||
namespace CodeImp.DoomBuilder.Data
|
||||
{
|
||||
internal unsafe abstract class ImageData : IDisposable
|
||||
{
|
||||
#region ================== Constants
|
||||
|
||||
#endregion
|
||||
|
||||
#region ================== Variables
|
||||
|
||||
// Properties
|
||||
protected string name;
|
||||
|
||||
// GDI bitmap
|
||||
protected Bitmap bitmap;
|
||||
|
||||
// 2D rendering data
|
||||
private PixelColor* pixeldata;
|
||||
private uint pixeldatasize;
|
||||
|
||||
// Direct3D texture
|
||||
protected Texture texture;
|
||||
|
||||
// Disposing
|
||||
protected bool isdisposed = false;
|
||||
|
||||
#endregion
|
||||
|
||||
#region ================== Properties
|
||||
|
||||
public string Name { get { return name; } }
|
||||
public PixelColor* PixelData { get { return pixeldata; } }
|
||||
public Bitmap Bitmap { get { return bitmap; } }
|
||||
public Texture Texture { get { return texture; } }
|
||||
public bool IsLoaded { get { return (bitmap == null); } }
|
||||
public bool IsDisposed { get { return isdisposed; } }
|
||||
|
||||
#endregion
|
||||
|
||||
#region ================== Constructor / Disposer
|
||||
|
||||
// Constructor
|
||||
public ImageData()
|
||||
{
|
||||
// Initialize
|
||||
|
||||
// We have no destructor
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
|
||||
// Diposer
|
||||
public virtual void Dispose()
|
||||
{
|
||||
// Not already disposed?
|
||||
if(!isdisposed)
|
||||
{
|
||||
// Clean up
|
||||
if(bitmap != null) bitmap.Dispose();
|
||||
if(texture != null) texture.Dispose();
|
||||
if(pixeldata != null) General.VirtualFree((void*)pixeldata, new UIntPtr(pixeldatasize), General.MEM_RELEASE);
|
||||
pixeldata = null;
|
||||
GC.RemoveMemoryPressure(pixeldatasize);
|
||||
|
||||
// Done
|
||||
isdisposed = true;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region ================== Management
|
||||
|
||||
// This loads the image resource
|
||||
public virtual void LoadImage()
|
||||
{
|
||||
BitmapData bmpdata;
|
||||
|
||||
// Check if loading worked
|
||||
if(bitmap != null)
|
||||
{
|
||||
/*
|
||||
// Check if loaded in correct pixel format
|
||||
if(bitmap.PixelFormat != PixelFormat.Format32bppArgb)
|
||||
{
|
||||
// Cannot work with pixel formats any other than A8R8G8B8
|
||||
throw new Exception("Image in unsupported pixel format");
|
||||
}
|
||||
*/
|
||||
|
||||
// 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);
|
||||
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
|
||||
public void CreateTexture()
|
||||
{
|
||||
// TODO: Write to memory stream and read with Texture.FromStream
|
||||
}
|
||||
|
||||
// This destroys the Direct3D texture
|
||||
public void ReleaseTexture()
|
||||
{
|
||||
// Trash it
|
||||
if(texture != null) texture.Dispose();
|
||||
texture = null;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
64
Source/Data/ImagePatch.cs
Normal file
64
Source/Data/ImagePatch.cs
Normal file
|
@ -0,0 +1,64 @@
|
|||
|
||||
#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.Drawing;
|
||||
using System.Drawing.Imaging;
|
||||
using System.IO;
|
||||
using CodeImp.DoomBuilder.IO;
|
||||
|
||||
#endregion
|
||||
|
||||
namespace CodeImp.DoomBuilder.Data
|
||||
{
|
||||
internal class ImagePatch
|
||||
{
|
||||
#region ================== Variables
|
||||
|
||||
private int index;
|
||||
private Point position;
|
||||
private Size size;
|
||||
private IDataContainer source;
|
||||
private ImagePatchFormat format;
|
||||
|
||||
#endregion
|
||||
|
||||
#region ================== Properties
|
||||
|
||||
#endregion
|
||||
|
||||
#region ================== Constructor / Disposer
|
||||
|
||||
// Constructor
|
||||
public ImagePatch()
|
||||
{
|
||||
// Initialize
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region ================== Methods
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
41
Source/Data/ImagePatchFormat.cs
Normal file
41
Source/Data/ImagePatchFormat.cs
Normal file
|
@ -0,0 +1,41 @@
|
|||
|
||||
#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;
|
||||
|
||||
#endregion
|
||||
|
||||
namespace CodeImp.DoomBuilder.Data
|
||||
{
|
||||
internal enum ImagePatchFormat : int
|
||||
{
|
||||
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
|
||||
}
|
||||
}
|
85
Source/Data/TextureImage.cs
Normal file
85
Source/Data/TextureImage.cs
Normal file
|
@ -0,0 +1,85 @@
|
|||
|
||||
#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;
|
||||
|
||||
#endregion
|
||||
|
||||
namespace CodeImp.DoomBuilder.Data
|
||||
{
|
||||
internal class TextureImage : ImageData
|
||||
{
|
||||
#region ================== Constants
|
||||
|
||||
#endregion
|
||||
|
||||
#region ================== Variables
|
||||
|
||||
#endregion
|
||||
|
||||
#region ================== Properties
|
||||
|
||||
#endregion
|
||||
|
||||
#region ================== Constructor / Disposer
|
||||
|
||||
// Constructor
|
||||
public TextureImage()
|
||||
{
|
||||
// Initialize
|
||||
|
||||
// We have no destructor
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
|
||||
// Diposer
|
||||
public override void Dispose()
|
||||
{
|
||||
// Not already disposed?
|
||||
if(!isdisposed)
|
||||
{
|
||||
// Clean up
|
||||
|
||||
// Done
|
||||
base.Dispose();
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region ================== Methods
|
||||
|
||||
// This loads the image
|
||||
public override void LoadImage()
|
||||
{
|
||||
// Leave when already loaded
|
||||
if(this.IsLoaded) return;
|
||||
|
||||
|
||||
|
||||
// Pass on to base
|
||||
base.LoadImage();
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
101
Source/Data/WADContainer.cs
Normal file
101
Source/Data/WADContainer.cs
Normal file
|
@ -0,0 +1,101 @@
|
|||
|
||||
#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.Drawing;
|
||||
using System.Drawing.Imaging;
|
||||
using System.IO;
|
||||
using CodeImp.DoomBuilder.IO;
|
||||
|
||||
#endregion
|
||||
|
||||
namespace CodeImp.DoomBuilder.Data
|
||||
{
|
||||
internal class WADContainer : IDataContainer
|
||||
{
|
||||
#region ================== Constants
|
||||
|
||||
#endregion
|
||||
|
||||
#region ================== Variables
|
||||
|
||||
// Source
|
||||
private WAD file;
|
||||
private bool managefile;
|
||||
|
||||
// Disposing
|
||||
private bool isdisposed = false;
|
||||
|
||||
#endregion
|
||||
|
||||
#region ================== Properties
|
||||
|
||||
// Disposing
|
||||
public bool IsDisposed { get { return isdisposed; } }
|
||||
|
||||
#endregion
|
||||
|
||||
#region ================== Constructor / Disposer
|
||||
|
||||
// Constructor
|
||||
public WADContainer(string filename)
|
||||
{
|
||||
// Initialize
|
||||
file = new WAD(filename, true);
|
||||
managefile = true;
|
||||
|
||||
// We have no destructor
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
|
||||
// Constructor
|
||||
public WADContainer(WAD wadfile)
|
||||
{
|
||||
// Initialize
|
||||
file = wadfile;
|
||||
managefile = false;
|
||||
|
||||
// We have no destructor
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
|
||||
// Diposer
|
||||
public void Dispose()
|
||||
{
|
||||
// Not already disposed?
|
||||
if(!isdisposed)
|
||||
{
|
||||
// Clean up
|
||||
if(managefile) file.Dispose();
|
||||
|
||||
// Done
|
||||
isdisposed = true;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region ================== Methods
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue