2009-04-19 18:07:22 +00:00
|
|
|
|
|
|
|
#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.Collections.Generic;
|
|
|
|
using System.IO;
|
|
|
|
using CodeImp.DoomBuilder.Config;
|
2012-06-01 10:17:47 +00:00
|
|
|
using CodeImp.DoomBuilder.GZBuilder.Data;
|
2009-04-19 18:07:22 +00:00
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
namespace CodeImp.DoomBuilder.Data
|
|
|
|
{
|
|
|
|
internal abstract class DataReader
|
|
|
|
{
|
2014-01-08 09:46:57 +00:00
|
|
|
#region ================== Constants
|
|
|
|
|
|
|
|
protected const string SPRITE_NAME_PATTERN = "(?i)\\A[a-z0-9]{4}([a-z][0-9]{0,2})$"; //mxd
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
2009-04-19 18:07:22 +00:00
|
|
|
#region ================== Variables
|
|
|
|
|
|
|
|
protected DataLocation location;
|
2014-02-21 14:42:12 +00:00
|
|
|
protected bool issuspended;
|
|
|
|
protected bool isdisposed;
|
2009-04-19 18:07:22 +00:00
|
|
|
protected ResourceTextureSet textureset;
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region ================== Properties
|
|
|
|
|
|
|
|
public DataLocation Location { get { return location; } }
|
|
|
|
public bool IsDisposed { get { return isdisposed; } }
|
|
|
|
public bool IsSuspended { get { return issuspended; } }
|
|
|
|
public ResourceTextureSet TextureSet { get { return textureset; } }
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region ================== Constructor / Disposer
|
|
|
|
|
|
|
|
// Constructor
|
2015-05-27 12:38:03 +00:00
|
|
|
protected DataReader(DataLocation dl)
|
2009-04-19 18:07:22 +00:00
|
|
|
{
|
|
|
|
// Keep information
|
|
|
|
location = dl;
|
2010-08-14 10:21:38 +00:00
|
|
|
textureset = new ResourceTextureSet(GetTitle(), dl);
|
2009-04-19 18:07:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Disposer
|
|
|
|
public virtual void Dispose()
|
|
|
|
{
|
|
|
|
// Not already disposed?
|
|
|
|
if(!isdisposed)
|
|
|
|
{
|
|
|
|
// Done
|
|
|
|
textureset = null;
|
|
|
|
isdisposed = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region ================== Management
|
|
|
|
|
|
|
|
// This returns a short name
|
|
|
|
public abstract string GetTitle();
|
|
|
|
|
|
|
|
// This suspends use of this resource
|
|
|
|
public virtual void Suspend()
|
|
|
|
{
|
|
|
|
issuspended = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
// This resumes use of this resource
|
|
|
|
public virtual void Resume()
|
|
|
|
{
|
|
|
|
issuspended = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region ================== Palette
|
|
|
|
|
|
|
|
// When implemented, this should find and load a PLAYPAL palette
|
|
|
|
public virtual Playpal LoadPalette() { return null; }
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
2009-05-12 09:50:08 +00:00
|
|
|
#region ================== Colormaps
|
|
|
|
|
|
|
|
// When implemented, this loads the colormaps
|
|
|
|
public virtual ICollection<ImageData> LoadColormaps() { return null; }
|
|
|
|
|
|
|
|
// When implemented, this returns the colormap lump
|
|
|
|
public virtual Stream GetColormapData(string pname) { return null; }
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
2009-04-19 18:07:22 +00:00
|
|
|
#region ================== Textures
|
|
|
|
|
|
|
|
// When implemented, this should read the patch names
|
|
|
|
public virtual PatchNames LoadPatchNames() { return null; }
|
|
|
|
|
|
|
|
// When implemented, this returns the patch lump
|
2014-11-25 11:52:01 +00:00
|
|
|
public virtual Stream GetPatchData(string pname, bool longname) { return null; }
|
2012-07-23 21:28:23 +00:00
|
|
|
|
2009-04-19 18:07:22 +00:00
|
|
|
// When implemented, this returns the texture lump
|
2014-11-25 11:52:01 +00:00
|
|
|
public virtual Stream GetTextureData(string pname, bool longname) { return null; }
|
2009-04-19 18:07:22 +00:00
|
|
|
|
|
|
|
// When implemented, this loads the textures
|
|
|
|
public virtual ICollection<ImageData> LoadTextures(PatchNames pnames) { return null; }
|
2010-08-12 19:59:06 +00:00
|
|
|
|
2009-04-19 18:07:22 +00:00
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region ================== Flats
|
|
|
|
|
|
|
|
// When implemented, this loads the flats
|
|
|
|
public virtual ICollection<ImageData> LoadFlats() { return null; }
|
|
|
|
|
|
|
|
// When implemented, this returns the flat lump
|
2014-11-25 11:52:01 +00:00
|
|
|
public virtual Stream GetFlatData(string pname, bool longname) { return null; }
|
2009-04-19 18:07:22 +00:00
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region ================== Sprites
|
2010-08-18 09:07:54 +00:00
|
|
|
|
|
|
|
// When implemented, this loads the sprites
|
|
|
|
public virtual ICollection<ImageData> LoadSprites() { return null; }
|
2009-04-19 18:07:22 +00:00
|
|
|
|
|
|
|
// When implemented, this returns the sprite lump
|
|
|
|
public virtual Stream GetSpriteData(string pname) { return null; }
|
|
|
|
|
|
|
|
// When implemented, this checks if the given sprite lump exists
|
|
|
|
public virtual bool GetSpriteExists(string pname) { return false; }
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
2012-07-23 21:28:23 +00:00
|
|
|
#region ================== Decorate, Modeldef, Mapinfo, Gldefs, etc...
|
2009-04-19 18:07:22 +00:00
|
|
|
|
2015-12-18 10:16:53 +00:00
|
|
|
// When implemented, this returns the DECORATE lump
|
|
|
|
public abstract Dictionary<string, Stream> GetDecorateData(string pname); // { return new Dictionary<string, Stream>(); }
|
2009-04-19 18:07:22 +00:00
|
|
|
|
2015-12-18 10:16:53 +00:00
|
|
|
//mxd. When implemented, this returns the MODELDEF lump
|
|
|
|
public abstract Dictionary<string, Stream> GetModeldefData(); // { return new Dictionary<string, Stream>(); }
|
2012-05-21 23:51:32 +00:00
|
|
|
|
2015-12-18 10:16:53 +00:00
|
|
|
//mxd. When implemented, this returns the MAPINFO lump
|
|
|
|
public abstract Dictionary<string, Stream> GetMapinfoData(); // { return new Dictionary<string, Stream>(); }
|
2012-06-01 10:17:47 +00:00
|
|
|
|
2015-12-18 10:16:53 +00:00
|
|
|
//mxd. When implemented, this returns the GLDEFS lump
|
|
|
|
public abstract Dictionary<string, Stream> GetGldefsData(GameType gametype); // { return new Dictionary<string, Stream>(); }
|
2012-06-01 10:17:47 +00:00
|
|
|
|
2015-12-18 10:16:53 +00:00
|
|
|
//mxd. When implemented, this returns the REVERBS lump
|
|
|
|
public abstract Dictionary<string, Stream> GetReverbsData(); // { return new Dictionary<string, Stream>(); }
|
2015-01-25 23:22:42 +00:00
|
|
|
|
2015-12-18 10:16:53 +00:00
|
|
|
//mxd. When implemented, this returns the VOXELDEF lump
|
|
|
|
public abstract KeyValuePair<string, Stream> GetVoxeldefData(); // { return new KeyValuePair<string, Stream>(); }
|
2014-01-03 10:33:45 +00:00
|
|
|
|
2015-12-18 10:16:53 +00:00
|
|
|
//mxd. When implemented, this returns the SNDSEQ lump
|
|
|
|
public abstract Dictionary<string, Stream> GetSndSeqData(); // { return new Dictionary<string, Stream>(); }
|
2014-01-03 10:33:45 +00:00
|
|
|
|
2015-12-18 10:16:53 +00:00
|
|
|
//mxd. When implemented, this returns the ANIMDEFS lump
|
|
|
|
public abstract Dictionary<string, Stream> GetAnimdefsData();
|
2014-01-03 10:33:45 +00:00
|
|
|
|
2015-12-18 10:16:53 +00:00
|
|
|
//mxd. When implemented, this returns the list of voxel model names
|
|
|
|
public abstract IEnumerable<string> GetVoxelNames(); // { return null; }
|
|
|
|
|
|
|
|
//mxd. When implemented, this returns the voxel lump
|
|
|
|
public abstract Stream GetVoxelData(string name); // { return null; }
|
2015-05-28 13:45:01 +00:00
|
|
|
|
2013-09-11 09:47:53 +00:00
|
|
|
//mxd
|
2015-12-18 10:16:53 +00:00
|
|
|
internal abstract MemoryStream LoadFile(string name);// { return null; }
|
|
|
|
internal abstract bool FileExists(string filename);// { return false; }
|
2012-07-23 21:28:23 +00:00
|
|
|
|
2009-04-19 18:07:22 +00:00
|
|
|
#endregion
|
|
|
|
}
|
|
|
|
}
|