flags and activations conversion to and from UDMF format (needed for copy/paste between map formats and prefabs)

This commit is contained in:
codeimp 2008-12-31 14:08:40 +00:00
parent 42fc938b77
commit 2b7cfbac06
27 changed files with 955 additions and 28 deletions

View file

@ -338,6 +338,24 @@ linedefflags
512 = "PassThru";
}
// Linedef flags UDMF translation table
// This is needed for copy/paste and prefabs to work properly
// When the UDMF field name is prefixed with ! it is inverted
linedefflagstranslation
{
1 = "blocking";
2 = "blockmonsters";
4 = "twosided";
8 = "dontpegtop";
16 = "dontpegbottom";
32 = "secret";
64 = "blocksound";
128 = "dontdraw";
256 = "mapped";
512 = "passuse";
}
// LINEDEF ACTIVATIONS
linedefactivations
{
@ -2494,6 +2512,20 @@ thingflags
64 = "Not Cooperative";
}
// Thing flags UDMF translation table
// This is needed for copy/paste and prefabs to work properly
// When the UDMF field name is prefixed with ! it is inverted
thingflagstranslation
{
1 = "skill1";
2 = "skill2";
4 = "skill3";
8 = "ambush";
16 = "!single";
32 = "!dm";
64 = "!coop";
}
// THING FLAGS ERROR MASK
// Mask for the thing flags which indicates the options
// that make the same thing appear in the same modes

View file

@ -288,6 +288,22 @@ linedefflags
256 = "Shown";
}
// Linedef flags UDMF translation table
// This is needed for copy/paste and prefabs to work properly
// When the UDMF field name is prefixed with ! it is inverted
linedefflagstranslation
{
1 = "blocking";
2 = "blockmonsters";
4 = "twosided";
8 = "dontpegtop";
16 = "dontpegbottom";
32 = "secret";
64 = "blocksound";
128 = "dontdraw";
256 = "mapped";
}
// LINEDEF ACTIVATIONS
linedefactivations
{
@ -985,6 +1001,18 @@ thingflags
16 = "Multiplayer";
}
// Thing flags UDMF translation table
// This is needed for copy/paste and prefabs to work properly
// When the UDMF field name is prefixed with ! it is inverted
thingflagstranslation
{
1 = "skill1";
2 = "skill2";
4 = "skill3";
8 = "ambush";
16 = "!single";
}
// THING FLAGS ERROR MASK
// Mask for the thing flags which indicates the options
// that make the same thing appear in the same modes

View file

@ -289,6 +289,22 @@ linedefflags
256 = "Shown";
}
// Linedef flags UDMF translation table
// This is needed for copy/paste and prefabs to work properly
// When the UDMF field name is prefixed with ! it is inverted
linedefflagstranslation
{
1 = "blocking";
2 = "blockmonsters";
4 = "twosided";
8 = "dontpegtop";
16 = "dontpegbottom";
32 = "secret";
64 = "blocksound";
128 = "dontdraw";
256 = "mapped";
}
// LINEDEF ACTIVATIONS
linedefactivations
{
@ -1214,6 +1230,18 @@ thingflags
16 = "Multiplayer";
}
// Thing flags UDMF translation table
// This is needed for copy/paste and prefabs to work properly
// When the UDMF field name is prefixed with ! it is inverted
thingflagstranslation
{
1 = "skill1";
2 = "skill2";
4 = "skill3";
8 = "ambush";
16 = "!single";
}
// THING FLAGS ERROR MASK
// Mask for the thing flags which indicates the options
// that make the same thing appear in the same modes

View file

@ -342,6 +342,22 @@ linedefflags
256 = "Shown";
}
// Linedef flags UDMF translation table
// This is needed for copy/paste and prefabs to work properly
// When the UDMF field name is prefixed with ! it is inverted
linedefflagstranslation
{
1 = "blocking";
2 = "blockmonsters";
4 = "twosided";
8 = "dontpegtop";
16 = "dontpegbottom";
32 = "secret";
64 = "blocksound";
128 = "dontdraw";
256 = "mapped";
}
// LINEDEF ACTIVATIONS
linedefactivations
{
@ -2444,6 +2460,18 @@ thingflags
16 = "Multiplayer";
}
// Thing flags UDMF translation table
// This is needed for copy/paste and prefabs to work properly
// When the UDMF field name is prefixed with ! it is inverted
thingflagstranslation
{
1 = "skill1";
2 = "skill2";
4 = "skill3";
8 = "ambush";
16 = "!single";
}
// THING FLAGS ERROR MASK
// Mask for the thing flags which indicates the options
// that make the same thing appear in the same modes

View file

@ -346,6 +346,24 @@ linedefflags
1024 = "3dMidTex";
}
// Linedef flags UDMF translation table
// This is needed for copy/paste and prefabs to work properly
// When the UDMF field name is prefixed with ! it is inverted
linedefflagstranslation
{
1 = "blocking";
2 = "blockmonsters";
4 = "twosided";
8 = "dontpegtop";
16 = "dontpegbottom";
32 = "secret";
64 = "blocksound";
128 = "dontdraw";
256 = "mapped";
512 = "passuse";
1024 = "midtex3d";
}
// LINEDEF ACTIVATIONS
linedefactivations
{
@ -2762,6 +2780,22 @@ thingflags
512 = "Dormant";
}
// Thing flags UDMF translation table
// This is needed for copy/paste and prefabs to work properly
// When the UDMF field name is prefixed with ! it is inverted
thingflagstranslation
{
1 = "skill1";
2 = "skill2";
4 = "skill3";
8 = "ambush";
16 = "!single";
32 = "!dm";
64 = "!coop";
128 = "friend";
512 = "dormant";
}
// THING FLAGS ERROR MASK
// Mask for the thing flags which indicates the options
// that make the same thing appear in the same modes

View file

@ -313,6 +313,22 @@ linedefflags
256 = "Shown";
}
// Linedef flags UDMF translation table
// This is needed for copy/paste and prefabs to work properly
// When the UDMF field name is prefixed with ! it is inverted
linedefflagstranslation
{
1 = "blocking";
2 = "blockmonsters";
4 = "twosided";
8 = "dontpegtop";
16 = "dontpegbottom";
32 = "secret";
64 = "blocksound";
128 = "dontdraw";
256 = "mapped";
}
// LINEDEF ACTIVATIONS
linedefactivations
{
@ -1034,6 +1050,18 @@ thingflags
16 = "Multiplayer";
}
// Thing flags UDMF translation table
// This is needed for copy/paste and prefabs to work properly
// When the UDMF field name is prefixed with ! it is inverted
thingflagstranslation
{
1 = "skill1";
2 = "skill2";
4 = "skill3";
8 = "ambush";
16 = "!single";
}
// THING FLAGS ERROR MASK
// Mask for the thing flags which indicates the options
// that make the same thing appear in the same modes

View file

@ -350,6 +350,30 @@ linedefactivations
5120 = "Projectile flies over";
}
// Linedef flags UDMF translation table
// This is needed for copy/paste and prefabs to work properly
// When the UDMF field name is prefixed with ! it is inverted
linedefflagstranslation
{
1 = "blocking";
2 = "blockmonsters";
4 = "twosided";
8 = "dontpegtop";
16 = "dontpegbottom";
32 = "secret";
64 = "blocksound";
128 = "dontdraw";
256 = "mapped";
512 = "repeatspecial";
1024 = "playeruse";
2048 = "monstercross";
3072 = "impact";
4096 = "playerpush";
5120 = "missilecross";
8192 = "monsteractivate";
32768 = "blockeverything";
}
// LINEDEF TYPES
linedeftypes
{
@ -2202,6 +2226,24 @@ thingflags
1024 = "Deathmatch";
}
// Thing flags UDMF translation table
// This is needed for copy/paste and prefabs to work properly
// When the UDMF field name is prefixed with ! it is inverted
thingflagstranslation
{
1 = "skill1";
2 = "skill2";
4 = "skill3";
8 = "ambush";
16 = "dormant";
32 = "class1";
64 = "class2";
128 = "class3";
256 = "single";
512 = "coop";
1024 = "dm";
}
// THING FLAGS ERROR MASK
// Mask for the thing flags which indicates the options
// that make the same thing appear in the same modes

View file

@ -339,6 +339,24 @@ linedefactivations
{
}
// Linedef flags UDMF translation table
// This is needed for copy/paste and prefabs to work properly
// When the UDMF field name is prefixed with ! it is inverted
linedefflagstranslation
{
1 = "blocking";
2 = "blockmonsters";
4 = "twosided";
8 = "dontpegtop";
16 = "dontpegbottom";
32 = "secret";
64 = "blocksound";
128 = "dontdraw";
256 = "mapped";
512 = "passuse";
1024 = "monsteractivate";
}
// LINEDEF TYPES
linedeftypes
{
@ -2574,6 +2592,20 @@ thingflags
64 = "Not Cooperative";
}
// Thing flags UDMF translation table
// This is needed for copy/paste and prefabs to work properly
// When the UDMF field name is prefixed with ! it is inverted
thingflagstranslation
{
1 = "skill1";
2 = "skill2";
4 = "skill3";
8 = "ambush";
16 = "!single";
32 = "!dm";
64 = "!coop";
}
// THING FLAGS ERROR MASK
// Mask for the thing flags which indicates the options
// that make the same thing appear in the same modes

View file

@ -360,6 +360,23 @@ linedefactivations
{
}
// Linedef flags UDMF translation table
// This is needed for copy/paste and prefabs to work properly
// When the UDMF field name is prefixed with ! it is inverted
linedefflagstranslation
{
1 = "blocking";
2 = "blockmonsters";
4 = "twosided";
8 = "dontpegtop";
16 = "dontpegbottom";
32 = "secret";
64 = "blocksound";
128 = "dontdraw";
256 = "mapped";
512 = "passuse";
}
// LINEDEF TYPES
linedeftypes
{
@ -2547,6 +2564,20 @@ thingflags
64 = "Not Cooperative";
}
// Thing flags UDMF translation table
// This is needed for copy/paste and prefabs to work properly
// When the UDMF field name is prefixed with ! it is inverted
thingflagstranslation
{
1 = "skill1";
2 = "skill2";
4 = "skill3";
8 = "ambush";
16 = "!single";
32 = "!dm";
64 = "!coop";
}
// THING FLAGS ERROR MASK
// Mask for the thing flags which indicates the options
// that make the same thing appear in the same modes

View file

@ -362,6 +362,23 @@ linedefactivations
{
}
// Linedef flags UDMF translation table
// This is needed for copy/paste and prefabs to work properly
// When the UDMF field name is prefixed with ! it is inverted
linedefflagstranslation
{
1 = "blocking";
2 = "blockmonsters";
4 = "twosided";
8 = "dontpegtop";
16 = "dontpegbottom";
32 = "secret";
64 = "blocksound";
128 = "dontdraw";
256 = "mapped";
512 = "passuse";
}
// LINEDEF TYPES
linedeftypes
{
@ -2489,6 +2506,20 @@ thingflags
64 = "Not Cooperative";
}
// Thing flags UDMF translation table
// This is needed for copy/paste and prefabs to work properly
// When the UDMF field name is prefixed with ! it is inverted
thingflagstranslation
{
1 = "skill1";
2 = "skill2";
4 = "skill3";
8 = "ambush";
16 = "!single";
32 = "!dm";
64 = "!coop";
}
// THING FLAGS ERROR MASK
// Mask for the thing flags which indicates the options
// that make the same thing appear in the same modes

View file

@ -378,6 +378,31 @@ linedefactivations
6144 = "Player presses Use (PassThru)";
}
// Linedef flags UDMF translation table
// This is needed for copy/paste and prefabs to work properly
// When the UDMF field name is prefixed with ! it is inverted
linedefflagstranslation
{
1 = "blocking";
2 = "blockmonsters";
4 = "twosided";
8 = "dontpegtop";
16 = "dontpegbottom";
32 = "secret";
64 = "blocksound";
128 = "dontdraw";
256 = "mapped";
512 = "repeatspecial";
1024 = "playeruse";
2048 = "monstercross";
3072 = "impact";
4096 = "playerpush";
5120 = "missilecross";
6144 = "passuse";
8192 = "monsteractivate";
32768 = "blockeverything";
}
// LINEDEF TYPES
linedeftypes
{

View file

@ -300,6 +300,23 @@ linedefactivations
{
}
// Linedef flags UDMF translation table
// This is needed for copy/paste and prefabs to work properly
// When the UDMF field name is prefixed with ! it is inverted
linedefflagstranslation
{
1 = "blocking";
2 = "blockmonsters";
4 = "twosided";
8 = "dontpegtop";
16 = "dontpegbottom";
32 = "secret";
64 = "blocksound";
128 = "dontdraw";
256 = "mapped";
4096 = "translucent";
}
// LINEDEF TYPES
linedeftypes
{
@ -1798,6 +1815,21 @@ thingflags
512 = "Modify visibility";
}
// Thing flags UDMF translation table
// This is needed for copy/paste and prefabs to work properly
// When the UDMF field name is prefixed with ! it is inverted
thingflagstranslation
{
1 = "skill1";
2 = "skill2";
4 = "skill3";
8 = "standing";
16 = "!single";
64 = "strifeally";
256 = "translucent";
512 = "invisible";
}
// THING FLAGS ERROR MASK
// Mask for the thing flags which indicates the options
// that make the same thing appear in the same modes

View file

@ -294,6 +294,22 @@ linedefactivations
{
}
// Linedef flags UDMF translation table
// This is needed for copy/paste and prefabs to work properly
// When the UDMF field name is prefixed with ! it is inverted
linedefflagstranslation
{
1 = "blocking";
2 = "blockmonsters";
4 = "twosided";
8 = "dontpegtop";
16 = "dontpegbottom";
32 = "secret";
64 = "blocksound";
128 = "dontdraw";
256 = "mapped";
}
// LINEDEF TYPES
linedeftypes
{
@ -1203,6 +1219,18 @@ thingflags
16 = "Multiplayer";
}
// Thing flags UDMF translation table
// This is needed for copy/paste and prefabs to work properly
// When the UDMF field name is prefixed with ! it is inverted
thingflagstranslation
{
1 = "skill1";
2 = "skill2";
4 = "skill3";
8 = "ambush";
16 = "!single";
}
// THING FLAGS ERROR MASK
// Mask for the thing flags which indicates the options
// that make the same thing appear in the same modes

View file

@ -361,6 +361,23 @@ linedefactivations
{
}
// Linedef flags UDMF translation table
// This is needed for copy/paste and prefabs to work properly
// When the UDMF field name is prefixed with ! it is inverted
linedefflagstranslation
{
1 = "blocking";
2 = "blockmonsters";
4 = "twosided";
8 = "dontpegtop";
16 = "dontpegbottom";
32 = "secret";
64 = "blocksound";
128 = "dontdraw";
256 = "mapped";
512 = "passuse";
}
// LINEDEF TYPES
linedeftypes
{
@ -2561,6 +2578,20 @@ thingflags
64 = "Not Cooperative";
}
// Thing flags UDMF translation table
// This is needed for copy/paste and prefabs to work properly
// When the UDMF field name is prefixed with ! it is inverted
thingflagstranslation
{
1 = "skill1";
2 = "skill2";
4 = "skill3";
8 = "ambush";
16 = "!single";
32 = "!dm";
64 = "!coop";
}
// THING FLAGS ERROR MASK
// Mask for the thing flags which indicates the options

View file

@ -4795,6 +4795,28 @@ thingflags
16384 = "Frozen while inactive";
}
// Thing flags UDMF translation table
// This is needed for copy/paste and prefabs to work properly
// When the UDMF field name is prefixed with ! it is inverted
thingflagstranslation
{
1 = "skill1";
2 = "skill2";
4 = "skill3";
8 = "ambush";
16 = "dormant";
32 = "class1";
64 = "class2";
128 = "class3";
256 = "single";
512 = "coop";
1024 = "dm";
2048 = "translucent";
4096 = "invisible";
8192 = "friend";
16384 = "standing";
}
// THING FLAGS ERROR MASK
// Mask for the thing flags which indicates the options
// that make the same thing appear in the same modes

View file

@ -533,6 +533,31 @@ linedefactivations
6144 = "Player presses Use (PassThru)";
}
// Linedef flags UDMF translation table
// This is needed for copy/paste and prefabs to work properly
// When the UDMF field name is prefixed with ! it is inverted
linedefflagstranslation
{
1 = "blocking";
2 = "blockmonsters";
4 = "twosided";
8 = "dontpegtop";
16 = "dontpegbottom";
32 = "secret";
64 = "blocksound";
128 = "dontdraw";
256 = "mapped";
512 = "repeatspecial";
1024 = "playeruse";
2048 = "monstercross";
3072 = "impact";
4096 = "playerpush";
5120 = "missilecross";
6144 = "passuse";
8192 = "monsteractivate";
32768 = "blockeverything";
}
// LINEDEF TYPES
linedeftypes
{
@ -4787,6 +4812,28 @@ thingflags
16384 = "Frozen while inactive";
}
// Thing flags UDMF translation table
// This is needed for copy/paste and prefabs to work properly
// When the UDMF field name is prefixed with ! it is inverted
thingflagstranslation
{
1 = "skill1";
2 = "skill2";
4 = "skill3";
8 = "ambush";
16 = "dormant";
32 = "class1";
64 = "class2";
128 = "class3";
256 = "single";
512 = "coop";
1024 = "dm";
2048 = "translucent";
4096 = "invisible";
8192 = "friend";
16384 = "standing";
}
// THING FLAGS ERROR MASK
// Mask for the thing flags which indicates the options
// that make the same thing appear in the same modes

View file

@ -378,6 +378,31 @@ linedefactivations
6144 = "Player presses Use (PassThru)";
}
// Linedef flags UDMF translation table
// This is needed for copy/paste and prefabs to work properly
// When the UDMF field name is prefixed with ! it is inverted
linedefflagstranslation
{
1 = "blocking";
2 = "blockmonsters";
4 = "twosided";
8 = "dontpegtop";
16 = "dontpegbottom";
32 = "secret";
64 = "blocksound";
128 = "dontdraw";
256 = "mapped";
512 = "repeatspecial";
1024 = "playeruse";
2048 = "monstercross";
3072 = "impact";
4096 = "playerpush";
5120 = "missilecross";
6144 = "passuse";
8192 = "monsteractivate";
32768 = "blockeverything";
}
// LINEDEF TYPES
linedeftypes
{
@ -4632,6 +4657,28 @@ thingflags
16384 = "Frozen while inactive";
}
// Thing flags UDMF translation table
// This is needed for copy/paste and prefabs to work properly
// When the UDMF field name is prefixed with ! it is inverted
thingflagstranslation
{
1 = "skill1";
2 = "skill2";
4 = "skill3";
8 = "ambush";
16 = "dormant";
32 = "class1";
64 = "class2";
128 = "class3";
256 = "single";
512 = "coop";
1024 = "dm";
2048 = "translucent";
4096 = "invisible";
8192 = "friend";
16384 = "standing";
}
// THING FLAGS ERROR MASK
// Mask for the thing flags which indicates the options
// that make the same thing appear in the same modes

View file

@ -539,6 +539,32 @@ linedefactivations
7168 = "Projectile hits or crosses";
}
// Linedef flags UDMF translation table
// This is needed for copy/paste and prefabs to work properly
// When the UDMF field name is prefixed with ! it is inverted
linedefflagstranslation
{
1 = "blocking";
2 = "blockmonsters";
4 = "twosided";
8 = "dontpegtop";
16 = "dontpegbottom";
32 = "secret";
64 = "blocksound";
128 = "dontdraw";
256 = "mapped";
512 = "repeatspecial";
1024 = "playeruse";
2048 = "monstercross";
3072 = "impact";
4096 = "playerpush";
5120 = "missilecross";
6144 = "passuse";
7168 = "impact,missilecross";
8192 = "monsteractivate";
32768 = "blockeverything";
}
// LINEDEF TYPES
linedeftypes
{
@ -4793,6 +4819,27 @@ thingflags
16384 = "Frozen while inactive";
}
// Thing flags UDMF translation table
// This is needed for copy/paste and prefabs to work properly
// When the UDMF field name is prefixed with ! it is inverted
thingflagstranslation
{
1 = "skill1";
2 = "skill2";
4 = "skill3";
8 = "ambush";
16 = "dormant";
32 = "class1";
64 = "class2";
128 = "class3";
256 = "single";
512 = "coop";
1024 = "dm";
2048 = "translucent";
4096 = "invisible";
8192 = "friend";
16384 = "standing";
}
// THING FLAGS ERROR MASK
// Mask for the thing flags which indicates the options

View file

@ -316,6 +316,22 @@ linedefactivations
{
}
// Linedef flags UDMF translation table
// This is needed for copy/paste and prefabs to work properly
// When the UDMF field name is prefixed with ! it is inverted
linedefflagstranslation
{
1 = "blocking";
2 = "blockmonsters";
4 = "twosided";
8 = "dontpegtop";
16 = "dontpegbottom";
32 = "secret";
64 = "blocksound";
128 = "dontdraw";
256 = "mapped";
}
// LINEDEF TYPES
linedeftypes
{
@ -1237,6 +1253,18 @@ thingflags
16 = "Multiplayer";
}
// Thing flags UDMF translation table
// This is needed for copy/paste and prefabs to work properly
// When the UDMF field name is prefixed with ! it is inverted
thingflagstranslation
{
1 = "skill1";
2 = "skill2";
4 = "skill3";
8 = "ambush";
16 = "!single";
}
// THING FLAGS ERROR MASK
// Mask for the thing flags which indicates the options
// that make the same thing appear in the same modes

View file

@ -648,6 +648,7 @@
<None Include="Resources\Copy.png" />
<None Include="Resources\Cut.png" />
<None Include="Resources\Close.png" />
<Compile Include="Config\FlagTranslation.cs" />
<Compile Include="Editing\EditingManager.cs" />
<EmbeddedResource Include="Resources\Crosshair.png" />
<EmbeddedResource Include="Resources\CrosshairBusy.png" />

View 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 CodeImp.DoomBuilder.IO;
using CodeImp.DoomBuilder.Data;
using System.IO;
using System.Diagnostics;
using System.Windows.Forms;
#endregion
namespace CodeImp.DoomBuilder.Config
{
public class FlagTranslation : IComparable<FlagTranslation>
{
#region ================== Variables
private int flag;
private List<string> fields;
private List<bool> values;
#endregion
#region ================== Properties
public int Flag { get { return flag; } }
public List<string> Fields { get { return fields; } }
public List<bool> FieldValues { get { return values; } }
#endregion
#region ================== Constructor
// Constructor
public FlagTranslation(DictionaryEntry de)
{
// Initialize
this.fields = new List<string>();
this.values = new List<bool>();
// Set the flag
if(!int.TryParse(de.Key.ToString(), out flag))
General.WriteLogLine("WARNING: Invalid flag translation key in configuration (must be numeric)");
// Set the fields
string[] fieldstrings = de.Value.ToString().Split(',');
foreach(string f in fieldstrings)
{
string ft = f.Trim();
if(ft.StartsWith("!"))
{
fields.Add(ft.Substring(1).Trim());
values.Add(false);
}
else
{
fields.Add(ft);
values.Add(true);
}
}
}
#endregion
#region ================== Methods
// String representation
public override string ToString()
{
return flag.ToString();
}
// Comparer (highest first)
public int CompareTo(FlagTranslation other)
{
return other.flag - this.flag;
}
#endregion
}
}

View file

@ -81,6 +81,7 @@ namespace CodeImp.DoomBuilder.Config
private Dictionary<string, string> thingflags;
private List<ThingCategory> thingcategories;
private Dictionary<int, ThingTypeInfo> things;
private List<FlagTranslation> thingflagstranslation;
// Linedefs
private Dictionary<string, string> linedefflags;
@ -89,6 +90,7 @@ namespace CodeImp.DoomBuilder.Config
private List<LinedefActionCategory> actioncategories;
private List<LinedefActivateInfo> linedefactivates;
private List<GeneralizedCategory> genactioncategories;
private List<FlagTranslation> linedefflagstranslation;
// Sectors
private Dictionary<int, SectorEffectInfo> sectoreffects;
@ -150,6 +152,7 @@ namespace CodeImp.DoomBuilder.Config
public IDictionary<string, string> ThingFlags { get { return thingflags; } }
public List<ThingCategory> ThingCategories { get { return thingcategories; } }
public ICollection<ThingTypeInfo> Things { get { return things.Values; } }
public List<FlagTranslation> ThingFlagsTranslation { get { return thingflagstranslation; } }
// Linedefs
public IDictionary<string, string> LinedefFlags { get { return linedefflags; } }
@ -158,6 +161,7 @@ namespace CodeImp.DoomBuilder.Config
public List<LinedefActionCategory> ActionCategories { get { return actioncategories; } }
public List<LinedefActivateInfo> LinedefActivates { get { return linedefactivates; } }
public List<GeneralizedCategory> GenActionCategories { get { return genactioncategories; } }
public List<FlagTranslation> LinedefFlagsTranslation { get { return linedefflagstranslation; } }
// Sectors
public IDictionary<int, SectorEffectInfo> SectorEffects { get { return sectoreffects; } }
@ -206,6 +210,8 @@ namespace CodeImp.DoomBuilder.Config
this.texturesets = new List<DefinedTextureSet>();
this.makedoorargs = new int[Linedef.NUM_ARGS];
this.maplumps = new Dictionary<string, MapLumpInfo>();
this.thingflagstranslation = new List<FlagTranslation>();
this.linedefflagstranslation = new List<FlagTranslation>();
// Read general settings
configname = cfg.ReadSetting("game", "<unnamed game>");
@ -389,30 +395,15 @@ namespace CodeImp.DoomBuilder.Config
// Get linedef flags
dic = cfg.ReadSetting("linedefflags", new Hashtable());
foreach(DictionaryEntry de in dic)
{
/*
// Try paring the bit value
if(int.TryParse(de.Key.ToString(),
NumberStyles.AllowLeadingWhite | NumberStyles.AllowTrailingWhite,
CultureInfo.InvariantCulture, out bitvalue))
{
// Check for conflict and add to list
if((bitvalue & bitflagscheck) == 0)
linedefflags.Add(bitvalue, de.Value.ToString());
else
General.WriteLogLine("WARNING: Structure 'linedefflags' contains conflicting bit flag keys. Make sure all keys are unique integers and powers of 2!");
// Update bit flags checking value
bitflagscheck |= bitvalue;
}
else
{
General.WriteLogLine("WARNING: Structure 'linedefflags' contains invalid keys!");
}
*/
linedefflags.Add(de.Key.ToString(), de.Value.ToString());
}
// Get translations
dic = cfg.ReadSetting("linedefflagstranslation", new Hashtable());
foreach(DictionaryEntry de in dic)
linedefflagstranslation.Add(new FlagTranslation(de));
// Sort the translation flags, because they must be compared highest first!
linedefflagstranslation.Sort();
}
// Linedef actions and action categories
@ -584,6 +575,14 @@ namespace CodeImp.DoomBuilder.Config
dic = cfg.ReadSetting("thingflags", new Hashtable());
foreach(DictionaryEntry de in dic)
thingflags.Add(de.Key.ToString(), de.Value.ToString());
// Get translations
dic = cfg.ReadSetting("thingflagstranslation", new Hashtable());
foreach(DictionaryEntry de in dic)
thingflagstranslation.Add(new FlagTranslation(de));
// Sort the translation flags, because they must be compared highest first!
thingflagstranslation.Sort();
}
// Default thing flags

View file

@ -103,6 +103,9 @@ namespace CodeImp.DoomBuilder.Editing
// This links sidedefs that are not linked to a marked sector to a virtual sector
MapSet copyset = General.Map.Map.CloneMarked();
// Convert flags and activations to UDMF fields, if needed
if(!(General.Map.FormatInterface is UniversalMapSetIO)) copyset.TranslateToUDMF();
// Write data to stream
MemoryStream memstream = new MemoryStream();
UniversalStreamWriter writer = new UniversalStreamWriter();
@ -150,10 +153,13 @@ namespace CodeImp.DoomBuilder.Editing
UniversalStreamReader reader = new UniversalStreamReader();
reader.StrictChecking = false;
reader.Read(General.Map.Map, memstream);
// The new geometry is not marked, so invert the marks to get it marked
General.Map.Map.InvertAllMarks();
// Convert UDMF fields back to flags and activations, if needed
if(!(General.Map.FormatInterface is UniversalMapSetIO)) General.Map.Map.TranslateFromUDMF();
// Done
memstream.Dispose();
General.Editing.Mode.OnPasteEnd();

View file

@ -53,7 +53,7 @@ namespace CodeImp.DoomBuilder.IO
public bool SetKnownCustomTypes { get { return setknowncustomtypes; } set { setknowncustomtypes = value; } }
public bool StrictChecking { get { return strictchecking; } set { strictchecking = value; } }
#endregion
#region ================== Constructor / Disposer
@ -172,7 +172,12 @@ namespace CodeImp.DoomBuilder.IO
Dictionary<string, bool> stringflags = new Dictionary<string, bool>();
foreach(KeyValuePair<string, string> flag in General.Map.Config.ThingFlags)
stringflags[flag.Key] = GetCollectionEntry<bool>(c, flag.Key, false, false);
foreach(FlagTranslation ft in General.Map.Config.ThingFlagsTranslation)
{
foreach(string field in ft.Fields)
stringflags[field] = GetCollectionEntry<bool>(c, field, false, false);
}
// Create new item
Thing t = map.CreateThing();
t.Update(type, x, y, height, Angle2D.DegToRad(angledeg), stringflags, tag, special, args);
@ -214,11 +219,16 @@ namespace CodeImp.DoomBuilder.IO
Dictionary<string, bool> stringflags = new Dictionary<string, bool>();
foreach(KeyValuePair<string, string> flag in General.Map.Config.LinedefFlags)
stringflags[flag.Key] = GetCollectionEntry<bool>(lc, flag.Key, false, false);
foreach(FlagTranslation ft in General.Map.Config.LinedefFlagsTranslation)
{
foreach(string field in ft.Fields)
stringflags[field] = GetCollectionEntry<bool>(lc, field, false, false);
}
// Activations
foreach(LinedefActivateInfo activate in General.Map.Config.LinedefActivates)
stringflags[activate.Key] = GetCollectionEntry<bool>(lc, activate.Key, false, false);
// Create new item
Linedef l = map.CreateLinedef(vertexlink[v1], vertexlink[v2]);
l.Update(stringflags, 0, tag, special, args);

View file

@ -21,6 +21,7 @@ using System.Collections;
using System.Collections.Generic;
using System.Globalization;
using System.Text;
using CodeImp.DoomBuilder.Config;
using CodeImp.DoomBuilder.Geometry;
using CodeImp.DoomBuilder.Rendering;
using SlimDX.Direct3D9;
@ -337,6 +338,108 @@ namespace CodeImp.DoomBuilder.Map
if(back != null) back.Sector.UpdateNeeded = true;
}
// This translates the flags and activations into UDMF fields
internal void TranslateToUDMF()
{
// First make a single integer with all bits from activation and flags
int bits = activate;
int flagbit = 0;
foreach(KeyValuePair<string, bool> f in flags)
if(int.TryParse(f.Key, out flagbit) && f.Value) bits |= flagbit;
// Now make the new flags
flags.Clear();
foreach(FlagTranslation f in General.Map.Config.LinedefFlagsTranslation)
{
// Flag found in bits?
if((bits & f.Flag) == f.Flag)
{
// Add fields and remove bits
bits &= ~f.Flag;
for(int i = 0; i < f.Fields.Count; i++)
flags.Add(f.Fields[i], f.FieldValues[i]);
}
else
{
// Add fields with inverted value
for(int i = 0; i < f.Fields.Count; i++)
flags.Add(f.Fields[i], !f.FieldValues[i]);
}
}
}
// This translates UDMF fields back into the normal flags and activations
internal void TranslateFromUDMF()
{
// Make copy of the flags
Dictionary<string, bool> oldfields = new Dictionary<string, bool>(flags);
// Make the flags
flags.Clear();
foreach(KeyValuePair<string, string> f in General.Map.Config.LinedefFlags)
{
// Flag must be numeric
int flagbit = 0;
if(int.TryParse(f.Key, out flagbit))
{
foreach(FlagTranslation ft in General.Map.Config.LinedefFlagsTranslation)
{
if(ft.Flag == flagbit)
{
// Only set this flag when the fields match
bool fieldsmatch = true;
for(int i = 0; i < ft.Fields.Count; i++)
{
if(!oldfields.ContainsKey(ft.Fields[i]) || (oldfields[ft.Fields[i]] != ft.FieldValues[i]))
{
fieldsmatch = false;
break;
}
}
// Field match? Then add the flag.
if(fieldsmatch)
{
flags.Add(f.Key, true);
break;
}
}
}
}
}
// Make the activation
foreach(LinedefActivateInfo a in General.Map.Config.LinedefActivates)
{
bool foundactivation = false;
foreach(FlagTranslation ft in General.Map.Config.LinedefFlagsTranslation)
{
if(ft.Flag == a.Index)
{
// Only set this activation when the fields match
bool fieldsmatch = true;
for(int i = 0; i < ft.Fields.Count; i++)
{
if(!oldfields.ContainsKey(ft.Fields[i]) || (oldfields[ft.Fields[i]] != ft.FieldValues[i]))
{
fieldsmatch = false;
break;
}
}
// Field match? Then add the flag.
if(fieldsmatch)
{
activate = a.Index;
foundactivation = true;
break;
}
}
}
if(foundactivation) break;
}
}
#endregion
#region ================== Methods

View file

@ -2039,6 +2039,21 @@ namespace CodeImp.DoomBuilder.Map
{
// TODO: Make this happen
}
// This converts flags and activations to UDMF fields
internal void TranslateToUDMF()
{
foreach(Linedef l in linedefs) l.TranslateToUDMF();
foreach(Thing t in things) t.TranslateToUDMF();
}
// This converts UDMF fields back into flags and activations
// NOTE: Only converts the marked items
internal void TranslateFromUDMF()
{
foreach(Linedef l in linedefs) if(l.Marked) l.TranslateFromUDMF();
foreach(Thing t in things) if(t.Marked) t.TranslateFromUDMF();
}
// This removes unused vertices
public void RemoveUnusedVertices()

View file

@ -228,6 +228,77 @@ namespace CodeImp.DoomBuilder.Map
//sectorlistitem = sector.AttachThing(this);
}
}
// This translates the flags into UDMF fields
internal void TranslateToUDMF()
{
// First make a single integer with all flags
int bits = 0;
int flagbit = 0;
foreach(KeyValuePair<string, bool> f in flags)
if(int.TryParse(f.Key, out flagbit) && f.Value) bits |= flagbit;
// Now make the new flags
flags.Clear();
foreach(FlagTranslation f in General.Map.Config.ThingFlagsTranslation)
{
// Flag found in bits?
if((bits & f.Flag) == f.Flag)
{
// Add fields and remove bits
bits &= ~f.Flag;
for(int i = 0; i < f.Fields.Count; i++)
flags.Add(f.Fields[i], f.FieldValues[i]);
}
else
{
// Add fields with inverted value
for(int i = 0; i < f.Fields.Count; i++)
flags.Add(f.Fields[i], !f.FieldValues[i]);
}
}
}
// This translates UDMF fields back into the normal flags
internal void TranslateFromUDMF()
{
// Make copy of the flags
Dictionary<string, bool> oldfields = new Dictionary<string, bool>(flags);
// Make the flags
flags.Clear();
foreach(KeyValuePair<string, string> f in General.Map.Config.ThingFlags)
{
// Flag must be numeric
int flagbit = 0;
if(int.TryParse(f.Key, out flagbit))
{
foreach(FlagTranslation ft in General.Map.Config.ThingFlagsTranslation)
{
if(ft.Flag == flagbit)
{
// Only set this flag when the fields match
bool fieldsmatch = true;
for(int i = 0; i < ft.Fields.Count; i++)
{
if(!oldfields.ContainsKey(ft.Fields[i]) || (oldfields[ft.Fields[i]] != ft.FieldValues[i]))
{
fieldsmatch = false;
break;
}
}
// Field match? Then add the flag.
if(fieldsmatch)
{
flags.Add(f.Key, true);
break;
}
}
}
}
}
}
#endregion