UltimateZoneBuilder/Source/Core/IO/MapSetIO.cs

197 lines
5.9 KiB
C#
Raw Normal View History

#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.Generic;
using System.Diagnostics;
using System.Globalization;
using System.Reflection;
using CodeImp.DoomBuilder.Map;
using CodeImp.DoomBuilder.Types;
#endregion
namespace CodeImp.DoomBuilder.IO
{
internal abstract class MapSetIO : IMapSetIO
{
#region ================== Constants
#endregion
#region ================== Variables
// WAD File
protected WAD wad;
// Map manager
protected MapManager manager;
//mxd
Removed "Paste Properties Options" action. Added "Paste Properties Special" actions in "Classic" and "Visual" categories. They work the same way as "Paste Special" action. Added: "Copy Properties", "Paste Properties" and "Paste Properties Special" options are now shown in the Edit menu if current classic mode supports them. Changed, Paste Properties Special window: only options relevant to current map format are now displayed. Changed, Paste Properties Special window, UDMF: all UI-managed options are now available. Fixed: MAPINFO parser was unable to process "include" directives. Fixed, General interface: selection info was reset to "Nothing selected" after few seconds regardless of current selection. Fixed, Visual mode: thing bounding boxes were not updated when changing things positions using Randomize mode. Fixed, Visual mode: event lines were displayed at incorrect height when entering Visual mode for the first time. Fixed, Texture Browser window: when MixTexturesFlats Game Configuration option is disabled, textures/flats are no longer shown in the Used group when flats/textures with the same names are used in the map. Fixed(?): probably fixed an exception some users reported when trying to initialize a Classic mode after switching from Visual mode with "Sync cameras" option enabled. Changed, Game configurations, Thing Categories: a block must have at least one thing category property to be recognized as a thing category. Changed, Visplane Explorer: the plugin now outputs more info when it fails to initialize vpo.dll. Cosmetic, Thing Edit window, Doom/Hexen map format: adjusted UI layout so thing flags control no longer displays scrollbars in Hexen map format. Internal: merged methods from UDMFTools into UniFields, removed UDMFTools. Updated Inno Setup script (added VC++ 2008 SP1 distributive). Updated ZDoom_DECORATE.cfg (A_CheckBlock). Updated documentation (added "System Requirements" page).
2015-10-09 12:38:12 +00:00
protected Dictionary<MapElementType, Dictionary<string, UniversalType>> uifields;
#endregion
#region ================== Properties
public abstract int MaxSidedefs { get; }
public abstract int MaxVertices { get; }
public abstract int MaxLinedefs { get; }
public abstract int MaxSectors { get; }
public abstract int MaxThings { get; }
public abstract int MinTextureOffset { get; }
public abstract int MaxTextureOffset { get; }
public abstract int VertexDecimals { get; }
public abstract string DecimalsFormat { get; }
public abstract bool HasLinedefTag { get; }
public abstract bool HasThingTag { get; }
public abstract bool HasThingAction { get; }
public abstract bool HasCustomFields { get; }
public abstract bool HasThingHeight { get; }
public abstract bool HasActionArgs { get; }
public abstract bool HasMixedActivations { get; }
public abstract bool HasPresetActivations { get; }
public abstract bool HasBuiltInActivations { get; }
public abstract bool HasNumericLinedefFlags { get; }
public abstract bool HasNumericThingFlags { get; }
public abstract bool HasNumericLinedefActivations { get; }
public abstract int MaxTag { get; }
public abstract int MinTag { get; }
public abstract int MaxAction { get; }
public abstract int MinAction { get; }
public abstract int MaxArgument { get; }
public abstract int MinArgument { get; }
public abstract int MaxEffect { get; }
public abstract int MinEffect { get; }
public abstract int MaxBrightness { get; }
public abstract int MinBrightness { get; }
public abstract int MaxThingType { get; }
public abstract int MinThingType { get; }
public abstract float MaxCoordinate { get; }
public abstract float MinCoordinate { get; }
public abstract int MaxThingAngle { get; }
public abstract int MinThingAngle { get; }
Removed "Paste Properties Options" action. Added "Paste Properties Special" actions in "Classic" and "Visual" categories. They work the same way as "Paste Special" action. Added: "Copy Properties", "Paste Properties" and "Paste Properties Special" options are now shown in the Edit menu if current classic mode supports them. Changed, Paste Properties Special window: only options relevant to current map format are now displayed. Changed, Paste Properties Special window, UDMF: all UI-managed options are now available. Fixed: MAPINFO parser was unable to process "include" directives. Fixed, General interface: selection info was reset to "Nothing selected" after few seconds regardless of current selection. Fixed, Visual mode: thing bounding boxes were not updated when changing things positions using Randomize mode. Fixed, Visual mode: event lines were displayed at incorrect height when entering Visual mode for the first time. Fixed, Texture Browser window: when MixTexturesFlats Game Configuration option is disabled, textures/flats are no longer shown in the Used group when flats/textures with the same names are used in the map. Fixed(?): probably fixed an exception some users reported when trying to initialize a Classic mode after switching from Visual mode with "Sync cameras" option enabled. Changed, Game configurations, Thing Categories: a block must have at least one thing category property to be recognized as a thing category. Changed, Visplane Explorer: the plugin now outputs more info when it fails to initialize vpo.dll. Cosmetic, Thing Edit window, Doom/Hexen map format: adjusted UI layout so thing flags control no longer displays scrollbars in Hexen map format. Internal: merged methods from UDMFTools into UniFields, removed UDMFTools. Updated Inno Setup script (added VC++ 2008 SP1 distributive). Updated ZDoom_DECORATE.cfg (A_CheckBlock). Updated documentation (added "System Requirements" page).
2015-10-09 12:38:12 +00:00
public abstract Dictionary<MapElementType, Dictionary<string, UniversalType>> UIFields { get; } //mxd
#endregion
#region ================== Constructor / Disposer
// Constructor
protected MapSetIO(WAD wad, MapManager manager)
{
// Initialize
this.wad = wad;
this.manager = manager;
Removed "Paste Properties Options" action. Added "Paste Properties Special" actions in "Classic" and "Visual" categories. They work the same way as "Paste Special" action. Added: "Copy Properties", "Paste Properties" and "Paste Properties Special" options are now shown in the Edit menu if current classic mode supports them. Changed, Paste Properties Special window: only options relevant to current map format are now displayed. Changed, Paste Properties Special window, UDMF: all UI-managed options are now available. Fixed: MAPINFO parser was unable to process "include" directives. Fixed, General interface: selection info was reset to "Nothing selected" after few seconds regardless of current selection. Fixed, Visual mode: thing bounding boxes were not updated when changing things positions using Randomize mode. Fixed, Visual mode: event lines were displayed at incorrect height when entering Visual mode for the first time. Fixed, Texture Browser window: when MixTexturesFlats Game Configuration option is disabled, textures/flats are no longer shown in the Used group when flats/textures with the same names are used in the map. Fixed(?): probably fixed an exception some users reported when trying to initialize a Classic mode after switching from Visual mode with "Sync cameras" option enabled. Changed, Game configurations, Thing Categories: a block must have at least one thing category property to be recognized as a thing category. Changed, Visplane Explorer: the plugin now outputs more info when it fails to initialize vpo.dll. Cosmetic, Thing Edit window, Doom/Hexen map format: adjusted UI layout so thing flags control no longer displays scrollbars in Hexen map format. Internal: merged methods from UDMFTools into UniFields, removed UDMFTools. Updated Inno Setup script (added VC++ 2008 SP1 distributive). Updated ZDoom_DECORATE.cfg (A_CheckBlock). Updated documentation (added "System Requirements" page).
2015-10-09 12:38:12 +00:00
this.uifields = new Dictionary<MapElementType, Dictionary<string, UniversalType>>(); //mxd
}
#endregion
#region ================== Static Methods
// This returns and instance of the specified IO class
public static MapSetIO Create(string classname)
{
return Create(classname, null, null);
}
// This returns and instance of the specified IO class
public static MapSetIO Create(string classname, WAD wadfile, MapManager manager)
{
object[] args;
MapSetIO result;
string fullname;
try
{
// Create arguments
args = new object[2];
args[0] = wadfile;
args[1] = manager;
// 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);
Removed "Paste Properties Options" action. Added "Paste Properties Special" actions in "Classic" and "Visual" categories. They work the same way as "Paste Special" action. Added: "Copy Properties", "Paste Properties" and "Paste Properties Special" options are now shown in the Edit menu if current classic mode supports them. Changed, Paste Properties Special window: only options relevant to current map format are now displayed. Changed, Paste Properties Special window, UDMF: all UI-managed options are now available. Fixed: MAPINFO parser was unable to process "include" directives. Fixed, General interface: selection info was reset to "Nothing selected" after few seconds regardless of current selection. Fixed, Visual mode: thing bounding boxes were not updated when changing things positions using Randomize mode. Fixed, Visual mode: event lines were displayed at incorrect height when entering Visual mode for the first time. Fixed, Texture Browser window: when MixTexturesFlats Game Configuration option is disabled, textures/flats are no longer shown in the Used group when flats/textures with the same names are used in the map. Fixed(?): probably fixed an exception some users reported when trying to initialize a Classic mode after switching from Visual mode with "Sync cameras" option enabled. Changed, Game configurations, Thing Categories: a block must have at least one thing category property to be recognized as a thing category. Changed, Visplane Explorer: the plugin now outputs more info when it fails to initialize vpo.dll. Cosmetic, Thing Edit window, Doom/Hexen map format: adjusted UI layout so thing flags control no longer displays scrollbars in Hexen map format. Internal: merged methods from UDMFTools into UniFields, removed UDMFTools. Updated Inno Setup script (added VC++ 2008 SP1 distributive). Updated ZDoom_DECORATE.cfg (A_CheckBlock). Updated documentation (added "System Requirements" page).
2015-10-09 12:38:12 +00:00
//mxd.
public string GetElementName(MapElementType elementtype)
{
switch(elementtype)
{
case MapElementType.VERTEX: return "vertex";
case MapElementType.LINEDEF: return "linedef";
case MapElementType.SIDEDEF: return "sidedef";
case MapElementType.SECTOR: return "sector";
case MapElementType.THING: return "thing";
default: throw new NotSupportedException("Tried to get element name of unsupported map element type!");
}
}
public MapElementType GetElementType(string elementname)
{
switch(elementname)
{
case "vertex": return MapElementType.VERTEX;
case "linedef": return MapElementType.LINEDEF;
case "sidedef": return MapElementType.SIDEDEF;
case "sector": return MapElementType.SECTOR;
case "thing": return MapElementType.THING;
default: throw new NotSupportedException("Tried to get element type of unsupported map element type!");
}
}
#endregion
}
}