Sidedef texture offsets are now translated when pasting map elements from UDMF to non-UDMF maps.

Fixed: certain UDMF-only properties were not cleared when pasting map elements from UDMF to non-UDMF maps.
Fixed a bug introduced in r2043: helper objects were not updated in some cases.
This commit is contained in:
MaxED 2014-09-16 20:26:42 +00:00
parent 145e92eaf0
commit 2d9c439325
6 changed files with 66 additions and 9 deletions

View file

@ -438,6 +438,10 @@ namespace CodeImp.DoomBuilder.Map
// This translates UDMF fields back into the normal flags and activations // This translates UDMF fields back into the normal flags and activations
internal void TranslateFromUDMF() internal void TranslateFromUDMF()
{ {
//mxd. Clear UDMF-related properties
this.Fields.Clear();
ExtraFloorFlag = false;
// Make copy of the flags // Make copy of the flags
Dictionary<string, bool> oldfields = new Dictionary<string, bool>(flags); Dictionary<string, bool> oldfields = new Dictionary<string, bool>(flags);

View file

@ -3199,6 +3199,8 @@ namespace CodeImp.DoomBuilder.Map
internal void TranslateFromUDMF() internal void TranslateFromUDMF()
{ {
foreach(Linedef l in linedefs) if(l.Marked) l.TranslateFromUDMF(); foreach(Linedef l in linedefs) if(l.Marked) l.TranslateFromUDMF();
foreach(Sidedef s in sidedefs) if(s.Marked) s.TranslateFromUDMF(); //mxd
foreach(Sector s in sectors) if(s.Marked) s.TranslateFromUDMF(); //mxd
foreach(Thing t in things) if(t.Marked) t.TranslateFromUDMF(); foreach(Thing t in things) if(t.Marked) t.TranslateFromUDMF();
} }

View file

@ -432,6 +432,22 @@ namespace CodeImp.DoomBuilder.Map
if(selecteditem.List != null) selecteditem.List.Remove(selecteditem); if(selecteditem.List != null) selecteditem.List.Remove(selecteditem);
selecteditem = null; selecteditem = null;
} }
// This removes UDMF stuff
internal void TranslateFromUDMF()
{
// Clear UDMF-related properties
this.Fields.Clear();
this.Flags.Clear();
hasFogColor = false;
useOutsideFog = false;
// Reset Slopes
floorslope = new Vector3D();
flooroffset = 0;
ceilslope = new Vector3D();
ceiloffset = 0;
}
#endregion #endregion

View file

@ -64,12 +64,12 @@ namespace CodeImp.DoomBuilder.Map
#region ================== Properties #region ================== Properties
public MapSet Map { get { return map; } } public MapSet Map { get { return map; } }
public bool IsFront { get { return (linedef != null) ? (this == linedef.Front) : false; } } public bool IsFront { get { return (linedef != null) && (this == linedef.Front); } }
public Linedef Line { get { return linedef; } } public Linedef Line { get { return linedef; } }
public Sidedef Other { get { if(this == linedef.Front) return linedef.Back; else return linedef.Front; } } public Sidedef Other { get { return (this == linedef.Front ? linedef.Back : linedef.Front); } }
public Sector Sector { get { return sector; } } public Sector Sector { get { return sector; } }
internal Dictionary<string, bool> Flags { get { return flags; } } //mxd internal Dictionary<string, bool> Flags { get { return flags; } } //mxd
public float Angle { get { if(IsFront) return linedef.Angle; else return Angle2D.Normalized(linedef.Angle + Angle2D.PI); } } public float Angle { get { return (IsFront ? linedef.Angle : Angle2D.Normalized(linedef.Angle + Angle2D.PI)); } }
public int OffsetX { get { return offsetx; } set { BeforePropsChange(); offsetx = value; } } public int OffsetX { get { return offsetx; } set { BeforePropsChange(); offsetx = value; } }
public int OffsetY { get { return offsety; } set { BeforePropsChange(); offsety = value; } } public int OffsetY { get { return offsety; } set { BeforePropsChange(); offsety = value; } }
public string HighTexture { get { return texnamehigh; } } public string HighTexture { get { return texnamehigh; } }
@ -263,6 +263,31 @@ namespace CodeImp.DoomBuilder.Map
{ {
linedef = ld; linedef = ld;
} }
//mxd. This translates UDMF fields back into the normal flags and activations
internal void TranslateFromUDMF()
{
// Try to translate UDMF texture offsets to regular ones
if (longtexnamemid != MapSet.EmptyLongName && MiddleRequired())
{
offsetx += (int)UDMFTools.GetFloat(this.Fields, "offsetx_mid");
offsety += (int)UDMFTools.GetFloat(this.Fields, "offsety_mid");
}
else if (longtexnamehigh != MapSet.EmptyLongName && HighRequired())
{
offsetx += (int)UDMFTools.GetFloat(this.Fields, "offsetx_top");
offsety += (int)UDMFTools.GetFloat(this.Fields, "offsety_top");
}
else if (longtexnamelow != MapSet.EmptyLongName && LowRequired())
{
offsetx += (int)UDMFTools.GetFloat(this.Fields, "offsetx_bottom");
offsety += (int)UDMFTools.GetFloat(this.Fields, "offsety_bottom");
}
// Clear UDMF-related properties
this.Fields.Clear();
this.Flags.Clear();
}
#endregion #endregion
@ -583,8 +608,8 @@ namespace CodeImp.DoomBuilder.Map
this.Fields.BeforeFieldsChange(); this.Fields.BeforeFieldsChange();
//top //top
if(LongHighTexture != MapSet.EmptyLongName && General.Map.Data.GetFlatExists(HighTexture)) { if(longtexnamehigh != MapSet.EmptyLongName && General.Map.Data.GetFlatExists(texnamehigh)) {
ImageData texture = General.Map.Data.GetFlatImage(HighTexture); ImageData texture = General.Map.Data.GetFlatImage(texnamehigh);
float scaleTop = Fields.GetValue("scalex_top", 1.0f); float scaleTop = Fields.GetValue("scalex_top", 1.0f);
float value = Fields.GetValue("offsetx_top", 0f); float value = Fields.GetValue("offsetx_top", 0f);
@ -593,8 +618,8 @@ namespace CodeImp.DoomBuilder.Map
} }
//middle //middle
if(LongMiddleTexture != MapSet.EmptyLongName && General.Map.Data.GetFlatExists(MiddleTexture)) { if(longtexnamemid != MapSet.EmptyLongName && General.Map.Data.GetFlatExists(texnamemid)) {
ImageData texture = General.Map.Data.GetFlatImage(MiddleTexture); ImageData texture = General.Map.Data.GetFlatImage(texnamemid);
float scaleMid = Fields.GetValue("scalex_mid", 1.0f); float scaleMid = Fields.GetValue("scalex_mid", 1.0f);
float value = Fields.GetValue("offsetx_mid", 0f); float value = Fields.GetValue("offsetx_mid", 0f);
@ -603,8 +628,8 @@ namespace CodeImp.DoomBuilder.Map
} }
//bottom //bottom
if(LongLowTexture != MapSet.EmptyLongName && General.Map.Data.GetFlatExists(LowTexture)) { if(longtexnamelow != MapSet.EmptyLongName && General.Map.Data.GetFlatExists(texnamelow)) {
ImageData texture = General.Map.Data.GetFlatImage(LowTexture); ImageData texture = General.Map.Data.GetFlatImage(texnamelow);
float scaleLow = Fields.GetValue("scalex_bottom", 1.0f); float scaleLow = Fields.GetValue("scalex_bottom", 1.0f);
float value = Fields.GetValue("offsetx_bottom", 0f); float value = Fields.GetValue("offsetx_bottom", 0f);

View file

@ -293,6 +293,15 @@ namespace CodeImp.DoomBuilder.Map
// This translates UDMF fields back into the normal flags // This translates UDMF fields back into the normal flags
internal void TranslateFromUDMF() internal void TranslateFromUDMF()
{ {
//mxd. Clear UDMF-related properties
this.Fields.Clear();
scaleX = 1.0f;
scaleY = 1.0f;
pitch = 0;
pitchrad = 0;
roll = 0;
rollrad = 0;
// Make copy of the flags // Make copy of the flags
Dictionary<string, bool> oldfields = new Dictionary<string, bool>(flags); Dictionary<string, bool> oldfields = new Dictionary<string, bool>(flags);

View file

@ -124,6 +124,7 @@ namespace CodeImp.DoomBuilder.Rendering
// Initialize // Initialize
CreateProjection(); CreateProjection();
CreateMatrices2D(); CreateMatrices2D();
SetupHelperObjects(); //mxd
SetupTextures(); SetupTextures();
renderthingcages = true; renderthingcages = true;
showselection = true; showselection = true;