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;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using System.Text;
|
|
|
|
using System.IO;
|
|
|
|
using CodeImp.DoomBuilder.Map;
|
2013-08-08 11:04:13 +00:00
|
|
|
using System.Collections;
|
2013-08-10 11:28:51 +00:00
|
|
|
using CodeImp.DoomBuilder.Types;
|
2009-04-19 18:07:22 +00:00
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
namespace CodeImp.DoomBuilder.IO
|
|
|
|
{
|
|
|
|
internal class UniversalMapSetIO : MapSetIO
|
|
|
|
{
|
|
|
|
#region ================== Constants
|
|
|
|
|
|
|
|
// Name of the UDMF configuration file
|
2013-08-08 11:04:13 +00:00
|
|
|
private const string UDMF_UI_CONFIG_NAME = "UDMF_UI.cfg";
|
2009-04-19 18:07:22 +00:00
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region ================== Constructor / Disposer
|
|
|
|
|
|
|
|
// Constructor
|
2013-08-08 11:04:13 +00:00
|
|
|
public UniversalMapSetIO(WAD wad, MapManager manager) : base(wad, manager)
|
2009-04-19 18:07:22 +00:00
|
|
|
{
|
2009-07-31 11:00:11 +00:00
|
|
|
if((manager != null) && (manager.Config != null))
|
2009-04-19 18:07:22 +00:00
|
|
|
{
|
2009-07-31 11:00:11 +00:00
|
|
|
// Make configuration
|
2013-08-08 11:04:13 +00:00
|
|
|
Configuration config = new Configuration();
|
2009-07-31 11:00:11 +00:00
|
|
|
|
2013-08-27 14:22:19 +00:00
|
|
|
//mxd. Find a resource named UDMF_UI.cfg
|
2009-07-31 11:00:11 +00:00
|
|
|
string[] resnames = General.ThisAssembly.GetManifestResourceNames();
|
|
|
|
foreach(string rn in resnames)
|
2009-04-19 18:07:22 +00:00
|
|
|
{
|
2009-07-31 11:00:11 +00:00
|
|
|
// Found it?
|
2016-02-01 22:04:00 +00:00
|
|
|
if(rn.EndsWith(UDMF_UI_CONFIG_NAME, StringComparison.OrdinalIgnoreCase))
|
2009-07-31 11:00:11 +00:00
|
|
|
{
|
|
|
|
// Get a stream from the resource
|
|
|
|
Stream udmfcfg = General.ThisAssembly.GetManifestResourceStream(rn);
|
|
|
|
StreamReader udmfcfgreader = new StreamReader(udmfcfg, Encoding.ASCII);
|
|
|
|
|
|
|
|
// Load configuration from stream
|
|
|
|
config.InputConfiguration(udmfcfgreader.ReadToEnd());
|
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
|
|
|
Dictionary<string, MapElementType> elements = new Dictionary<string, MapElementType>
|
|
|
|
{
|
|
|
|
{ "vertex", MapElementType.VERTEX },
|
|
|
|
{ "linedef", MapElementType.LINEDEF },
|
|
|
|
{ "sidedef", MapElementType.SIDEDEF },
|
|
|
|
{ "sector", MapElementType.SECTOR },
|
|
|
|
{ "thing", MapElementType.THING }
|
|
|
|
};
|
|
|
|
|
|
|
|
foreach(KeyValuePair<string, MapElementType> group in elements)
|
2014-11-11 11:47:10 +00:00
|
|
|
{
|
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
|
|
|
IDictionary dic = config.ReadSetting("uifields." + group.Key, new Hashtable());
|
2013-08-05 13:03:08 +00:00
|
|
|
|
2014-02-26 14:11:06 +00:00
|
|
|
Dictionary<string, UniversalType> values = new Dictionary<string, UniversalType>(StringComparer.Ordinal);
|
2014-11-11 11:47:10 +00:00
|
|
|
foreach(DictionaryEntry de in dic)
|
|
|
|
{
|
2013-08-10 11:28:51 +00:00
|
|
|
values.Add(de.Key.ToString(), (UniversalType)de.Value);
|
2013-08-08 11:04:13 +00:00
|
|
|
}
|
2013-08-05 13:03:08 +00:00
|
|
|
|
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
|
|
|
uifields.Add(group.Value, values);
|
2013-08-08 11:04:13 +00:00
|
|
|
}
|
2009-07-31 11:00:11 +00:00
|
|
|
|
|
|
|
// Done
|
|
|
|
udmfcfgreader.Dispose();
|
|
|
|
break;
|
|
|
|
}
|
2009-04-19 18:07:22 +00:00
|
|
|
}
|
|
|
|
}
|
2013-08-08 11:04:13 +00:00
|
|
|
}
|
2009-04-19 18:07:22 +00:00
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region ================== Properties
|
|
|
|
|
|
|
|
public override int MaxSidedefs { get { return int.MaxValue; } }
|
|
|
|
public override int MaxVertices { get { return int.MaxValue; } }
|
|
|
|
public override int MaxLinedefs { get { return int.MaxValue; } }
|
|
|
|
public override int MaxSectors { get { return int.MaxValue; } }
|
|
|
|
public override int MaxThings { get { return int.MaxValue; } }
|
|
|
|
public override int MinTextureOffset { get { return int.MinValue; } }
|
|
|
|
public override int MaxTextureOffset { get { return int.MaxValue; } }
|
2022-12-30 14:46:25 +00:00
|
|
|
public override int VertexDecimals { get { return 5; } }
|
|
|
|
public override string DecimalsFormat { get { return "0.00000"; } }
|
2009-04-19 18:07:22 +00:00
|
|
|
public override bool HasLinedefTag { get { return true; } }
|
|
|
|
public override bool HasThingTag { get { return true; } }
|
|
|
|
public override bool HasThingAction { get { return true; } }
|
|
|
|
public override bool HasCustomFields { get { return true; } }
|
|
|
|
public override bool HasThingHeight { get { return true; } }
|
|
|
|
public override bool HasActionArgs { get { return true; } }
|
|
|
|
public override bool HasMixedActivations { get { return true; } }
|
|
|
|
public override bool HasPresetActivations { get { return false; } }
|
|
|
|
public override bool HasBuiltInActivations { get { return false; } }
|
2009-07-31 11:00:11 +00:00
|
|
|
public override bool HasNumericLinedefFlags { get { return false; } }
|
|
|
|
public override bool HasNumericThingFlags { get { return false; } }
|
|
|
|
public override bool HasNumericLinedefActivations { get { return false; } }
|
2009-04-19 18:07:22 +00:00
|
|
|
public override int MaxTag { get { return int.MaxValue; } }
|
|
|
|
public override int MinTag { get { return int.MinValue; } }
|
|
|
|
public override int MaxAction { get { return int.MaxValue; } }
|
|
|
|
public override int MinAction { get { return int.MinValue; } }
|
2010-08-14 10:21:38 +00:00
|
|
|
public override int MaxArgument { get { return int.MaxValue; } }
|
|
|
|
public override int MinArgument { get { return int.MinValue; } }
|
2009-04-19 18:07:22 +00:00
|
|
|
public override int MaxEffect { get { return int.MaxValue; } }
|
|
|
|
public override int MinEffect { get { return int.MinValue; } }
|
|
|
|
public override int MaxBrightness { get { return int.MaxValue; } }
|
|
|
|
public override int MinBrightness { get { return int.MinValue; } }
|
2016-02-28 21:21:50 +00:00
|
|
|
public override int MaxThingType { get { return short.MaxValue; } } //mxd. Editor numbers must be in [1 .. 32767] range
|
|
|
|
public override int MinThingType { get { return 1; } } //mxd
|
2014-01-10 15:08:39 +00:00
|
|
|
public override float MaxCoordinate { get { return short.MaxValue; } } //mxd. UDMF maps are still bounded to -32768 .. 32767 range
|
|
|
|
public override float MinCoordinate { get { return short.MinValue; } } //mxd
|
2010-10-05 08:31:27 +00:00
|
|
|
public override int MaxThingAngle { get { return int.MaxValue; } }
|
|
|
|
public override int MinThingAngle { get { return int.MinValue; } }
|
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 override Dictionary<MapElementType, Dictionary<string, UniversalType>> UIFields { get { return uifields; } } //mxd
|
2009-04-19 18:07:22 +00:00
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region ================== Reading
|
|
|
|
|
|
|
|
// This reads a map from the file and returns a MapSet
|
|
|
|
public override MapSet Read(MapSet map, string mapname)
|
|
|
|
{
|
2013-08-12 10:15:08 +00:00
|
|
|
UniversalStreamReader udmfreader = new UniversalStreamReader(uifields); //mxd
|
2009-04-19 18:07:22 +00:00
|
|
|
|
|
|
|
// Find the index where first map lump begins
|
|
|
|
int firstindex = wad.FindLumpIndex(mapname) + 1;
|
|
|
|
|
|
|
|
// Get the TEXTMAP lump from wad file
|
|
|
|
Lump lump = wad.FindLump("TEXTMAP", firstindex);
|
|
|
|
if(lump == null) throw new Exception("Could not find required lump TEXTMAP!");
|
|
|
|
|
|
|
|
// Read the UDMF data
|
|
|
|
lump.Stream.Seek(0, SeekOrigin.Begin);
|
2020-03-29 19:44:29 +00:00
|
|
|
udmfreader.SetKnownCustomTypes = false;
|
2009-04-19 18:07:22 +00:00
|
|
|
udmfreader.Read(map, lump.Stream);
|
|
|
|
|
|
|
|
// Return result
|
|
|
|
return map;
|
|
|
|
}
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region ================== Writing
|
|
|
|
|
|
|
|
// This writes a MapSet to the file
|
|
|
|
public override void Write(MapSet map, string mapname, int position)
|
|
|
|
{
|
|
|
|
UniversalStreamWriter udmfwriter = new UniversalStreamWriter();
|
|
|
|
|
|
|
|
// Write map to memory stream
|
|
|
|
MemoryStream memstream = new MemoryStream();
|
|
|
|
memstream.Seek(0, SeekOrigin.Begin);
|
|
|
|
udmfwriter.RememberCustomTypes = true;
|
|
|
|
udmfwriter.Write(map, memstream, manager.Config.EngineName);
|
|
|
|
|
|
|
|
// Find insert position and remove old lump
|
2014-11-11 11:47:10 +00:00
|
|
|
int insertpos = MapManager.RemoveSpecificLump(wad, "TEXTMAP", position, MapManager.TEMP_MAP_HEADER, manager.Config.MapLumps);
|
2009-04-19 18:07:22 +00:00
|
|
|
if(insertpos == -1) insertpos = position + 1;
|
|
|
|
if(insertpos > wad.Lumps.Count) insertpos = wad.Lumps.Count;
|
|
|
|
|
|
|
|
// Create the lump from memory
|
|
|
|
Lump lump = wad.Insert("TEXTMAP", insertpos, (int)memstream.Length);
|
|
|
|
lump.Stream.Seek(0, SeekOrigin.Begin);
|
|
|
|
memstream.WriteTo(lump.Stream);
|
|
|
|
|
|
|
|
// Done
|
|
|
|
memstream.Dispose();
|
|
|
|
}
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|