From 94dce70ada9d79fe78ef06bc646ca0bfb208c805 Mon Sep 17 00:00:00 2001
From: MaxED <j.maxed@gmail.com>
Date: Tue, 27 Nov 2012 23:04:49 +0000
Subject: [PATCH] UDMF: vertical offsets of a vertex can now be edited in
 Vertex Edit form and are shown in Vertex Info panel. Bridge mode: when source
 sidedefs don't have upper/lower textures, their middle textures are used
 instead.

---
 Source/Core/Builder.csproj                    |   1 +
 .../Core/Controls/VertexInfoPanel.Designer.cs |  65 +++++++++-
 Source/Core/Controls/VertexInfoPanel.cs       |  20 +++
 Source/Core/Controls/VertexInfoPanel.resx     |   6 -
 Source/Core/GZBuilder/Tools/UDMFTools.cs      |  53 ++++++++
 .../Core/Windows/VertexEditForm.Designer.cs   | 122 ++++++++++++++----
 Source/Core/Windows/VertexEditForm.cs         |  32 ++++-
 Source/Core/Windows/VertexEditForm.resx       |  14 +-
 .../BuilderModes/ClassicModes/BridgeMode.cs   |  10 +-
 9 files changed, 279 insertions(+), 44 deletions(-)
 create mode 100644 Source/Core/GZBuilder/Tools/UDMFTools.cs

diff --git a/Source/Core/Builder.csproj b/Source/Core/Builder.csproj
index c61fd4e90..5045b7de7 100644
--- a/Source/Core/Builder.csproj
+++ b/Source/Core/Builder.csproj
@@ -727,6 +727,7 @@
     <Compile Include="GZBuilder\md3\GZModel.cs" />
     <Compile Include="GZBuilder\md3\ModelReader.cs" />
     <Compile Include="GZBuilder\GZDoom\AcsParserSE.cs" />
+    <Compile Include="GZBuilder\Tools\UDMFTools.cs" />
     <Compile Include="IO\DoomColormapReader.cs" />
     <Compile Include="Map\SelectionType.cs" />
     <Compile Include="Map\MapElementCollection.cs" />
diff --git a/Source/Core/Controls/VertexInfoPanel.Designer.cs b/Source/Core/Controls/VertexInfoPanel.Designer.cs
index 483f17142..603b90ebd 100644
--- a/Source/Core/Controls/VertexInfoPanel.Designer.cs
+++ b/Source/Core/Controls/VertexInfoPanel.Designer.cs
@@ -31,14 +31,20 @@ namespace CodeImp.DoomBuilder.Controls
 			System.Windows.Forms.Label label1;
 			this.vertexinfo = new System.Windows.Forms.GroupBox();
 			this.position = new System.Windows.Forms.Label();
+			this.labelCeilingOffset = new System.Windows.Forms.Label();
+			this.labelFloorOffset = new System.Windows.Forms.Label();
+			this.zceiling = new System.Windows.Forms.Label();
+			this.zfloor = new System.Windows.Forms.Label();
+			this.panelOffsets = new System.Windows.Forms.Panel();
 			label1 = new System.Windows.Forms.Label();
 			this.vertexinfo.SuspendLayout();
+			this.panelOffsets.SuspendLayout();
 			this.SuspendLayout();
 			// 
 			// label1
 			// 
 			label1.AutoSize = true;
-			label1.Location = new System.Drawing.Point(13, 34);
+			label1.Location = new System.Drawing.Point(13, 28);
 			label1.Name = "label1";
 			label1.Size = new System.Drawing.Size(47, 14);
 			label1.TabIndex = 2;
@@ -46,6 +52,7 @@ namespace CodeImp.DoomBuilder.Controls
 			// 
 			// vertexinfo
 			// 
+			this.vertexinfo.Controls.Add(this.panelOffsets);
 			this.vertexinfo.Controls.Add(this.position);
 			this.vertexinfo.Controls.Add(label1);
 			this.vertexinfo.Location = new System.Drawing.Point(0, 0);
@@ -58,12 +65,59 @@ namespace CodeImp.DoomBuilder.Controls
 			// position
 			// 
 			this.position.AutoSize = true;
-			this.position.Location = new System.Drawing.Point(66, 34);
+			this.position.Location = new System.Drawing.Point(66, 28);
 			this.position.Name = "position";
 			this.position.Size = new System.Drawing.Size(25, 14);
 			this.position.TabIndex = 3;
 			this.position.Text = "0, 0";
 			// 
+			// labelCeilingOffset
+			// 
+			this.labelCeilingOffset.AutoSize = true;
+			this.labelCeilingOffset.Location = new System.Drawing.Point(7, 3);
+			this.labelCeilingOffset.Name = "labelCeilingOffset";
+			this.labelCeilingOffset.Size = new System.Drawing.Size(73, 14);
+			this.labelCeilingOffset.TabIndex = 4;
+			this.labelCeilingOffset.Text = "Ceiling offset:";
+			// 
+			// labelFloorOffset
+			// 
+			this.labelFloorOffset.AutoSize = true;
+			this.labelFloorOffset.Location = new System.Drawing.Point(14, 26);
+			this.labelFloorOffset.Name = "labelFloorOffset";
+			this.labelFloorOffset.Size = new System.Drawing.Size(66, 14);
+			this.labelFloorOffset.TabIndex = 5;
+			this.labelFloorOffset.Text = "Floor offset:";
+			// 
+			// zceiling
+			// 
+			this.zceiling.AutoSize = true;
+			this.zceiling.Location = new System.Drawing.Point(86, 3);
+			this.zceiling.Name = "zceiling";
+			this.zceiling.Size = new System.Drawing.Size(29, 14);
+			this.zceiling.TabIndex = 6;
+			this.zceiling.Text = "-512";
+			// 
+			// zfloor
+			// 
+			this.zfloor.AutoSize = true;
+			this.zfloor.Location = new System.Drawing.Point(86, 26);
+			this.zfloor.Name = "zfloor";
+			this.zfloor.Size = new System.Drawing.Size(29, 14);
+			this.zfloor.TabIndex = 7;
+			this.zfloor.Text = "-512";
+			// 
+			// panelOffsets
+			// 
+			this.panelOffsets.Controls.Add(this.zfloor);
+			this.panelOffsets.Controls.Add(this.labelCeilingOffset);
+			this.panelOffsets.Controls.Add(this.zceiling);
+			this.panelOffsets.Controls.Add(this.labelFloorOffset);
+			this.panelOffsets.Location = new System.Drawing.Point(6, 49);
+			this.panelOffsets.Name = "panelOffsets";
+			this.panelOffsets.Size = new System.Drawing.Size(151, 46);
+			this.panelOffsets.TabIndex = 1;
+			// 
 			// VertexInfoPanel
 			// 
 			this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F);
@@ -76,6 +130,8 @@ namespace CodeImp.DoomBuilder.Controls
 			this.Size = new System.Drawing.Size(393, 100);
 			this.vertexinfo.ResumeLayout(false);
 			this.vertexinfo.PerformLayout();
+			this.panelOffsets.ResumeLayout(false);
+			this.panelOffsets.PerformLayout();
 			this.ResumeLayout(false);
 
 		}
@@ -84,6 +140,11 @@ namespace CodeImp.DoomBuilder.Controls
 
 		private System.Windows.Forms.Label position;
 		private System.Windows.Forms.GroupBox vertexinfo;
+		private System.Windows.Forms.Label zfloor;
+		private System.Windows.Forms.Label zceiling;
+		private System.Windows.Forms.Panel panelOffsets;
+		private System.Windows.Forms.Label labelCeilingOffset;
+		private System.Windows.Forms.Label labelFloorOffset;
 
 	}
 }
diff --git a/Source/Core/Controls/VertexInfoPanel.cs b/Source/Core/Controls/VertexInfoPanel.cs
index 25f727910..b7a6ca254 100644
--- a/Source/Core/Controls/VertexInfoPanel.cs
+++ b/Source/Core/Controls/VertexInfoPanel.cs
@@ -26,6 +26,7 @@ using Microsoft.Win32;
 using System.Diagnostics;
 using CodeImp.DoomBuilder.Data;
 using CodeImp.DoomBuilder.Map;
+using CodeImp.DoomBuilder.GZBuilder.Tools;
 
 #endregion
 
@@ -47,6 +48,25 @@ namespace CodeImp.DoomBuilder.Controls
 			vertexinfo.Text = " Vertex " + v.Index + " ";
 			position.Text = v.Position.x.ToString("0.##") + ", " + v.Position.y.ToString("0.##");
 			
+			//mxd. Height offsets
+			if(General.Map.UDMF) {
+				float zc = UDMFTools.GetFloat(v.Fields, "zceiling", 0);
+				float zf = UDMFTools.GetFloat(v.Fields, "zfloor", 0);
+
+				zceiling.Enabled = (zc != 0);
+				labelCeilingOffset.Enabled = zceiling.Enabled;
+
+				zfloor.Enabled = (zf != 0);
+				labelFloorOffset.Enabled = zfloor.Enabled;
+
+				zceiling.Text = zc.ToString("0.##");
+				zfloor.Text = zf.ToString("0.##");
+
+				panelOffsets.Visible = true;
+			} else {
+				panelOffsets.Visible = false;
+			}
+
 			// Show the whole thing
 			this.Show();
 			this.Update();
diff --git a/Source/Core/Controls/VertexInfoPanel.resx b/Source/Core/Controls/VertexInfoPanel.resx
index d3c04f5a3..523500d15 100644
--- a/Source/Core/Controls/VertexInfoPanel.resx
+++ b/Source/Core/Controls/VertexInfoPanel.resx
@@ -117,18 +117,12 @@
   <resheader name="writer">
     <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
   </resheader>
-  <metadata name="label1.Locked" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
-    <value>True</value>
-  </metadata>
   <metadata name="label1.GenerateMember" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
     <value>False</value>
   </metadata>
   <metadata name="vertexinfo.Locked" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
     <value>True</value>
   </metadata>
-  <metadata name="position.Locked" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
-    <value>True</value>
-  </metadata>
   <metadata name="$this.Locked" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
     <value>True</value>
   </metadata>
diff --git a/Source/Core/GZBuilder/Tools/UDMFTools.cs b/Source/Core/GZBuilder/Tools/UDMFTools.cs
new file mode 100644
index 000000000..045b1aaeb
--- /dev/null
+++ b/Source/Core/GZBuilder/Tools/UDMFTools.cs
@@ -0,0 +1,53 @@
+using System;
+using CodeImp.DoomBuilder.Map;
+using CodeImp.DoomBuilder.Types;
+
+namespace CodeImp.DoomBuilder.GZBuilder.Tools
+{
+	public static class UDMFTools
+	{
+		//float
+		public static float GetFloat(UniFields fields, string key, float defaultValue) {
+			if(fields != null && fields.ContainsKey(key))
+				return (float)fields[key].Value;
+			return defaultValue;
+		}
+
+		public static void SetFloat(UniFields fields, string key, float value, float defaultValue, bool prepareUndo) {
+			if(fields == null) return;
+
+			if(prepareUndo)	fields.BeforeFieldsChange();
+
+			if(value != defaultValue) {
+				if(!fields.ContainsKey(key))
+					fields.Add(key, new UniValue(UniversalType.Float, value));
+				else
+					fields[key].Value = value;
+			} else if(fields.ContainsKey(key)) { //don't save default value
+				fields.Remove(key);
+			}
+		}
+
+		//int
+		public static int GetInteger(UniFields fields, string key, int defaultValue) {
+			if(fields != null && fields.ContainsKey(key))
+				return (int)fields[key].Value;
+			return defaultValue;
+		}
+
+		public static void SetInteger(UniFields fields, string key, int value, int defaultValue, bool prepareUndo) {
+			if(fields == null) return;
+
+			if(prepareUndo)	fields.BeforeFieldsChange();
+
+			if(value != defaultValue) {
+				if(!fields.ContainsKey(key))
+					fields.Add(key, new UniValue(UniversalType.Integer, value));
+				else
+					fields[key].Value = value;
+			} else if(fields.ContainsKey(key)) { //don't save default value
+				fields.Remove(key);
+			}
+		}
+	}
+}
diff --git a/Source/Core/Windows/VertexEditForm.Designer.cs b/Source/Core/Windows/VertexEditForm.Designer.cs
index 6bfa74f83..19f6e19dd 100644
--- a/Source/Core/Windows/VertexEditForm.Designer.cs
+++ b/Source/Core/Windows/VertexEditForm.Designer.cs
@@ -29,23 +29,31 @@ namespace CodeImp.DoomBuilder.Windows
 		private void InitializeComponent()
 		{
 			System.Windows.Forms.TabPage tabproperties;
+			System.Windows.Forms.Label label3;
+			System.Windows.Forms.Label label2;
 			System.Windows.Forms.Label label1;
 			System.Windows.Forms.Label label6;
 			this.groupposition = new System.Windows.Forms.GroupBox();
+			this.zfloor = new CodeImp.DoomBuilder.Controls.ButtonsNumericTextbox();
+			this.zceiling = new CodeImp.DoomBuilder.Controls.ButtonsNumericTextbox();
+			this.positiony = new CodeImp.DoomBuilder.Controls.ButtonsNumericTextbox();
+			this.positionx = new CodeImp.DoomBuilder.Controls.ButtonsNumericTextbox();
 			this.tabs = new System.Windows.Forms.TabControl();
 			this.tabcustom = new System.Windows.Forms.TabPage();
 			this.fieldslist = new CodeImp.DoomBuilder.Controls.FieldsEditorControl();
 			this.cancel = new System.Windows.Forms.Button();
 			this.apply = new System.Windows.Forms.Button();
-			this.positionx = new CodeImp.DoomBuilder.Controls.ButtonsNumericTextbox();
-			this.positiony = new CodeImp.DoomBuilder.Controls.ButtonsNumericTextbox();
+			this.panelHeightControls = new System.Windows.Forms.Panel();
 			tabproperties = new System.Windows.Forms.TabPage();
+			label3 = new System.Windows.Forms.Label();
+			label2 = new System.Windows.Forms.Label();
 			label1 = new System.Windows.Forms.Label();
 			label6 = new System.Windows.Forms.Label();
 			tabproperties.SuspendLayout();
 			this.groupposition.SuspendLayout();
 			this.tabs.SuspendLayout();
 			this.tabcustom.SuspendLayout();
+			this.panelHeightControls.SuspendLayout();
 			this.SuspendLayout();
 			// 
 			// tabproperties
@@ -65,6 +73,7 @@ namespace CodeImp.DoomBuilder.Windows
 			this.groupposition.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
 						| System.Windows.Forms.AnchorStyles.Left)
 						| System.Windows.Forms.AnchorStyles.Right)));
+			this.groupposition.Controls.Add(this.panelHeightControls);
 			this.groupposition.Controls.Add(this.positiony);
 			this.groupposition.Controls.Add(this.positionx);
 			this.groupposition.Controls.Add(label1);
@@ -76,12 +85,78 @@ namespace CodeImp.DoomBuilder.Windows
 			this.groupposition.TabStop = false;
 			this.groupposition.Text = " Position ";
 			// 
+			// zfloor
+			// 
+			this.zfloor.AllowDecimal = false;
+			this.zfloor.AllowNegative = true;
+			this.zfloor.AllowRelative = true;
+			this.zfloor.ButtonStep = 1;
+			this.zfloor.Location = new System.Drawing.Point(188, 32);
+			this.zfloor.Name = "zfloor";
+			this.zfloor.Size = new System.Drawing.Size(120, 24);
+			this.zfloor.StepValues = null;
+			this.zfloor.TabIndex = 29;
+			// 
+			// zceiling
+			// 
+			this.zceiling.AllowDecimal = false;
+			this.zceiling.AllowNegative = true;
+			this.zceiling.AllowRelative = true;
+			this.zceiling.ButtonStep = 1;
+			this.zceiling.Location = new System.Drawing.Point(188, 0);
+			this.zceiling.Name = "zceiling";
+			this.zceiling.Size = new System.Drawing.Size(120, 24);
+			this.zceiling.StepValues = null;
+			this.zceiling.TabIndex = 28;
+			// 
+			// label3
+			// 
+			label3.AutoSize = true;
+			label3.Location = new System.Drawing.Point(63, 5);
+			label3.Name = "label3";
+			label3.Size = new System.Drawing.Size(118, 14);
+			label3.TabIndex = 27;
+			label3.Text = "Absolute ceiling height:";
+			// 
+			// label2
+			// 
+			label2.AutoSize = true;
+			label2.Location = new System.Drawing.Point(71, 37);
+			label2.Name = "label2";
+			label2.Size = new System.Drawing.Size(110, 14);
+			label2.TabIndex = 26;
+			label2.Text = "Absolute floor height:";
+			// 
+			// positiony
+			// 
+			this.positiony.AllowDecimal = false;
+			this.positiony.AllowNegative = true;
+			this.positiony.AllowRelative = true;
+			this.positiony.ButtonStep = 1;
+			this.positiony.Location = new System.Drawing.Point(236, 34);
+			this.positiony.Name = "positiony";
+			this.positiony.Size = new System.Drawing.Size(120, 24);
+			this.positiony.StepValues = null;
+			this.positiony.TabIndex = 25;
+			// 
+			// positionx
+			// 
+			this.positionx.AllowDecimal = false;
+			this.positionx.AllowNegative = true;
+			this.positionx.AllowRelative = true;
+			this.positionx.ButtonStep = 1;
+			this.positionx.Location = new System.Drawing.Point(68, 34);
+			this.positionx.Name = "positionx";
+			this.positionx.Size = new System.Drawing.Size(120, 24);
+			this.positionx.StepValues = null;
+			this.positionx.TabIndex = 24;
+			// 
 			// label1
 			// 
 			label1.AutoSize = true;
 			label1.Location = new System.Drawing.Point(212, 39);
 			label1.Name = "label1";
-			label1.Size = new System.Drawing.Size(18, 14);
+			label1.Size = new System.Drawing.Size(17, 14);
 			label1.TabIndex = 23;
 			label1.Text = "Y:";
 			// 
@@ -124,16 +199,23 @@ namespace CodeImp.DoomBuilder.Windows
 			// 
 			// fieldslist
 			// 
+			this.fieldslist.AllowInsert = true;
 			this.fieldslist.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
 						| System.Windows.Forms.AnchorStyles.Left)
 						| System.Windows.Forms.AnchorStyles.Right)));
+			this.fieldslist.AutoInsertUserPrefix = true;
 			this.fieldslist.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
 			this.fieldslist.Font = new System.Drawing.Font("Arial", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
 			this.fieldslist.Location = new System.Drawing.Point(11, 11);
 			this.fieldslist.Margin = new System.Windows.Forms.Padding(8);
 			this.fieldslist.Name = "fieldslist";
+			this.fieldslist.PropertyColumnVisible = true;
+			this.fieldslist.PropertyColumnWidth = 150;
 			this.fieldslist.Size = new System.Drawing.Size(406, 187);
 			this.fieldslist.TabIndex = 2;
+			this.fieldslist.TypeColumnVisible = true;
+			this.fieldslist.TypeColumnWidth = 100;
+			this.fieldslist.ValueColumnVisible = true;
 			// 
 			// cancel
 			// 
@@ -158,27 +240,16 @@ namespace CodeImp.DoomBuilder.Windows
 			this.apply.UseVisualStyleBackColor = true;
 			this.apply.Click += new System.EventHandler(this.apply_Click);
 			// 
-			// positionx
+			// panelHeightControls
 			// 
-			this.positionx.AllowDecimal = false;
-			this.positionx.AllowNegative = true;
-			this.positionx.AllowRelative = true;
-			this.positionx.ButtonStep = 1;
-			this.positionx.Location = new System.Drawing.Point(68, 34);
-			this.positionx.Name = "positionx";
-			this.positionx.Size = new System.Drawing.Size(120, 24);
-			this.positionx.TabIndex = 24;
-			// 
-			// positiony
-			// 
-			this.positiony.AllowDecimal = false;
-			this.positiony.AllowNegative = true;
-			this.positiony.AllowRelative = true;
-			this.positiony.ButtonStep = 1;
-			this.positiony.Location = new System.Drawing.Point(236, 34);
-			this.positiony.Name = "positiony";
-			this.positiony.Size = new System.Drawing.Size(120, 24);
-			this.positiony.TabIndex = 25;
+			this.panelHeightControls.Controls.Add(this.zceiling);
+			this.panelHeightControls.Controls.Add(this.zfloor);
+			this.panelHeightControls.Controls.Add(label2);
+			this.panelHeightControls.Controls.Add(label3);
+			this.panelHeightControls.Location = new System.Drawing.Point(48, 73);
+			this.panelHeightControls.Name = "panelHeightControls";
+			this.panelHeightControls.Size = new System.Drawing.Size(308, 100);
+			this.panelHeightControls.TabIndex = 30;
 			// 
 			// VertexEditForm
 			// 
@@ -204,6 +275,8 @@ namespace CodeImp.DoomBuilder.Windows
 			this.groupposition.PerformLayout();
 			this.tabs.ResumeLayout(false);
 			this.tabcustom.ResumeLayout(false);
+			this.panelHeightControls.ResumeLayout(false);
+			this.panelHeightControls.PerformLayout();
 			this.ResumeLayout(false);
 
 		}
@@ -218,5 +291,8 @@ namespace CodeImp.DoomBuilder.Windows
 		private System.Windows.Forms.GroupBox groupposition;
 		private CodeImp.DoomBuilder.Controls.ButtonsNumericTextbox positiony;
 		private CodeImp.DoomBuilder.Controls.ButtonsNumericTextbox positionx;
+		private CodeImp.DoomBuilder.Controls.ButtonsNumericTextbox zfloor;
+		private CodeImp.DoomBuilder.Controls.ButtonsNumericTextbox zceiling;
+		private System.Windows.Forms.Panel panelHeightControls;
 	}
 }
\ No newline at end of file
diff --git a/Source/Core/Windows/VertexEditForm.cs b/Source/Core/Windows/VertexEditForm.cs
index da7e3640b..e758d2618 100644
--- a/Source/Core/Windows/VertexEditForm.cs
+++ b/Source/Core/Windows/VertexEditForm.cs
@@ -30,6 +30,7 @@ using System.IO;
 using CodeImp.DoomBuilder.Config;
 using CodeImp.DoomBuilder.Editing;
 using CodeImp.DoomBuilder.Controls;
+using CodeImp.DoomBuilder.GZBuilder.Tools;
 
 #endregion
 
@@ -70,8 +71,14 @@ namespace CodeImp.DoomBuilder.Windows
 			{
 				positionx.AllowDecimal = true;
 				positiony.AllowDecimal = true;
+
+				//mxd
+				zceiling.AllowDecimal = true;
+				zfloor.AllowDecimal = true;
 			}
 
+			if(!General.Map.UDMF) panelHeightControls.Visible = false;
+
 			// Initialize custom fields editor
 			fieldslist.Setup("vertex");
 		}
@@ -115,6 +122,19 @@ namespace CodeImp.DoomBuilder.Windows
 				// Custom fields
 				fieldslist.SetValues(v.Fields, false);
 			}
+
+			//mxd. Height offsets
+			if(General.Map.UDMF) {
+				zceiling.Text = UDMFTools.GetFloat(vc.Fields, "zceiling", 0).ToString();
+				zfloor.Text = UDMFTools.GetFloat(vc.Fields, "zfloor", 0).ToString();
+
+				foreach(Vertex v in vertices) {
+					if(zceiling.Text != UDMFTools.GetFloat(v.Fields, "zceiling", 0).ToString())
+						zceiling.Text = "";
+					if(zfloor.Text != UDMFTools.GetFloat(v.Fields, "zfloor", 0).ToString())
+						zfloor.Text = "";
+				}
+			}
 		}
 		
 		#endregion
@@ -146,10 +166,20 @@ namespace CodeImp.DoomBuilder.Windows
 				p.x = General.Clamp(positionx.GetResultFloat(v.Position.x), (float)General.Map.FormatInterface.MinCoordinate, (float)General.Map.FormatInterface.MaxCoordinate);
 				p.y = General.Clamp(positiony.GetResultFloat(v.Position.y), (float)General.Map.FormatInterface.MinCoordinate, (float)General.Map.FormatInterface.MaxCoordinate);
 				v.Move(p);
-				
+
 				// Custom fields
 				fieldslist.Apply(v.Fields);
 			}
+
+			//mxd. Height offsets
+			if(General.Map.UDMF) {
+				foreach(Vertex v in vertices) {
+					float oldCeil = UDMFTools.GetFloat(v.Fields, "zceiling", 0);
+					UDMFTools.SetFloat(v.Fields, "zceiling", zceiling.GetResultFloat(oldCeil), 0, false);
+					float oldFloor = UDMFTools.GetFloat(v.Fields, "zfloor", 0);
+					UDMFTools.SetFloat(v.Fields, "zfloor", zfloor.GetResultFloat(oldFloor), 0, false);
+				}
+			}
 			
 			// Done
 			General.Map.IsChanged = true;
diff --git a/Source/Core/Windows/VertexEditForm.resx b/Source/Core/Windows/VertexEditForm.resx
index a40e5b9f0..2c1cbc9af 100644
--- a/Source/Core/Windows/VertexEditForm.resx
+++ b/Source/Core/Windows/VertexEditForm.resx
@@ -126,11 +126,11 @@
   <metadata name="groupposition.Locked" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
     <value>True</value>
   </metadata>
-  <metadata name="positiony.Locked" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
-    <value>True</value>
+  <metadata name="label2.GenerateMember" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+    <value>False</value>
   </metadata>
-  <metadata name="positionx.Locked" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
-    <value>True</value>
+  <metadata name="label3.GenerateMember" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+    <value>False</value>
   </metadata>
   <metadata name="label1.Locked" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
     <value>True</value>
@@ -138,9 +138,6 @@
   <metadata name="label1.GenerateMember" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
     <value>False</value>
   </metadata>
-  <metadata name="label6.Locked" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
-    <value>True</value>
-  </metadata>
   <metadata name="label6.GenerateMember" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
     <value>False</value>
   </metadata>
@@ -153,6 +150,9 @@
   <metadata name="fieldslist.Locked" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
     <value>True</value>
   </metadata>
+  <metadata name="fieldslist.Locked" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+    <value>True</value>
+  </metadata>
   <metadata name="cancel.Locked" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
     <value>True</value>
   </metadata>
diff --git a/Source/Plugins/BuilderModes/ClassicModes/BridgeMode.cs b/Source/Plugins/BuilderModes/ClassicModes/BridgeMode.cs
index 80b06284f..5e2a6851f 100644
--- a/Source/Plugins/BuilderModes/ClassicModes/BridgeMode.cs
+++ b/Source/Plugins/BuilderModes/ClassicModes/BridgeMode.cs
@@ -233,7 +233,7 @@ namespace CodeImp.DoomBuilder.BuilderModes.ClassicModes {
                         foreach (Sector s in newSectors[i][c]) {
                             foreach(Sidedef sd in s.Sidedefs){
                                 if (sd.LowRequired())
-                                    sd.SetTextureLow(sectorProps[i][c].LowTexture);
+									sd.SetTextureLow(sectorProps[i][c].LowTexture);
                                 if (sd.HighRequired())
                                     sd.SetTextureHigh(sectorProps[i][c].HighTexture);    
                             }
@@ -823,14 +823,14 @@ namespace CodeImp.DoomBuilder.BuilderModes.ClassicModes {
                 SectorProperties.CeilingHeight = ld.Back.Sector.CeilHeight;
                 SectorProperties.FloorHeight = ld.Back.Sector.FloorHeight;
                 SectorProperties.Brightness = ld.Back.Sector.Brightness;
-                SectorProperties.HighTexture = ld.Back.HighTexture;
-                SectorProperties.LowTexture = ld.Back.LowTexture;
+				SectorProperties.HighTexture = ld.Back.HighTexture != "-" ? ld.Back.HighTexture : ld.Back.MiddleTexture;
+				SectorProperties.LowTexture = ld.Back.LowTexture != "-" ? ld.Back.LowTexture : ld.Back.MiddleTexture;
             }else if(ld.Front != null){
                 SectorProperties.CeilingHeight = ld.Front.Sector.CeilHeight;
                 SectorProperties.FloorHeight = ld.Front.Sector.FloorHeight;
                 SectorProperties.Brightness = ld.Front.Sector.Brightness;
-                SectorProperties.HighTexture = ld.Front.HighTexture;
-                SectorProperties.LowTexture = ld.Front.LowTexture;
+				SectorProperties.HighTexture = ld.Front.HighTexture != "-" ? ld.Front.HighTexture : ld.Front.MiddleTexture;
+				SectorProperties.LowTexture = ld.Front.LowTexture != "-" ? ld.Front.LowTexture : ld.Front.MiddleTexture;
             }else{
                 SectorProperties.CeilingHeight = 128;
                 SectorProperties.FloorHeight = 0;
-- 
GitLab