2007-06-24 18:56:43 +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;
|
|
|
|
using System.Collections;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using System.Globalization;
|
|
|
|
using System.Text;
|
|
|
|
using System.IO;
|
|
|
|
using CodeImp.DoomBuilder.Map;
|
|
|
|
using System.Reflection;
|
|
|
|
using System.Diagnostics;
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
namespace CodeImp.DoomBuilder.IO
|
|
|
|
{
|
2007-10-24 17:25:03 +00:00
|
|
|
public abstract class MapSetIO
|
2007-06-24 18:56:43 +00:00
|
|
|
{
|
|
|
|
#region ================== Constants
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region ================== Variables
|
|
|
|
|
|
|
|
// WAD File
|
|
|
|
protected WAD wad;
|
|
|
|
|
2007-10-13 16:58:55 +00:00
|
|
|
// Map manager
|
|
|
|
protected MapManager manager;
|
|
|
|
|
2007-06-24 18:56:43 +00:00
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region ================== Properties
|
|
|
|
|
2007-10-13 14:05:45 +00:00
|
|
|
public abstract int MaxSidedefs { get; }
|
|
|
|
|
2007-06-24 18:56:43 +00:00
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region ================== Constructor / Disposer
|
|
|
|
|
|
|
|
// Constructor
|
2007-10-13 16:58:55 +00:00
|
|
|
public MapSetIO(WAD wad, MapManager manager)
|
2007-06-24 18:56:43 +00:00
|
|
|
{
|
|
|
|
// Initialize
|
|
|
|
this.wad = wad;
|
2007-10-13 16:58:55 +00:00
|
|
|
this.manager = manager;
|
2007-06-24 18:56:43 +00:00
|
|
|
}
|
2007-10-13 16:58:55 +00:00
|
|
|
|
2007-06-24 18:56:43 +00:00
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region ================== Static Methods
|
|
|
|
|
|
|
|
// This returns and instance of the specified IO class
|
2007-10-13 16:58:55 +00:00
|
|
|
public static MapSetIO Create(string classname, WAD wadfile, MapManager manager)
|
2007-06-24 18:56:43 +00:00
|
|
|
{
|
|
|
|
object[] args;
|
|
|
|
MapSetIO result;
|
|
|
|
string fullname;
|
|
|
|
|
|
|
|
try
|
|
|
|
{
|
|
|
|
// Create arguments
|
2007-10-13 16:58:55 +00:00
|
|
|
args = new object[2];
|
2007-06-24 18:56:43 +00:00
|
|
|
args[0] = wadfile;
|
2007-10-13 16:58:55 +00:00
|
|
|
args[1] = manager;
|
2007-06-24 18:56:43 +00:00
|
|
|
|
|
|
|
// Make the full class name
|
|
|
|
fullname = "CodeImp.DoomBuilder.IO." + classname;
|
|
|
|
|
|
|
|
// Create IO class
|
|
|
|
result = (MapSetIO)General.ThisAssembly.CreateInstance(fullname, false,
|
|
|
|
BindingFlags.Default, null, args, CultureInfo.CurrentCulture, new object[0]);
|
|
|
|
|
|
|
|
// Check result
|
|
|
|
if(result != null)
|
|
|
|
{
|
|
|
|
// Success
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// No such class
|
|
|
|
throw new ArgumentException("No such map format interface found: \"" + classname + "\"");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// Catch errors
|
|
|
|
catch(TargetInvocationException e)
|
|
|
|
{
|
|
|
|
// Throw the actual exception
|
|
|
|
Debug.WriteLine(DateTime.Now.ToShortDateString() + " " + DateTime.Now.ToShortTimeString());
|
|
|
|
Debug.WriteLine(e.InnerException.Source + " throws " + e.InnerException.GetType().Name + ":");
|
|
|
|
Debug.WriteLine(e.InnerException.Message);
|
|
|
|
Debug.WriteLine(e.InnerException.StackTrace);
|
|
|
|
throw e.InnerException;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region ================== Methods
|
|
|
|
|
|
|
|
// Required implementations
|
|
|
|
public abstract MapSet Read(MapSet map, string mapname);
|
|
|
|
public abstract void Write(MapSet map, string mapname, int position);
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
}
|
|
|
|
}
|