From 3ab5c83f3bc25e0b2531b60746b34f434934a1f1 Mon Sep 17 00:00:00 2001 From: codeimp Date: Mon, 19 Mar 2012 21:31:10 +0000 Subject: [PATCH] Added option in user preferences for manual line split behavior. --- .../BuilderModes/ClassicModes/LinedefsMode.cs | 1 + .../BuilderModes/ClassicModes/VerticesMode.cs | 9 ++- .../BuilderModes/General/BuilderPlug.cs | 38 +++++++++++++ .../Interface/PreferencesForm.Designer.cs | 55 ++++++++++++++----- .../BuilderModes/Interface/PreferencesForm.cs | 2 + .../Interface/PreferencesForm.resx | 6 ++ 6 files changed, 97 insertions(+), 14 deletions(-) diff --git a/Source/Plugins/BuilderModes/ClassicModes/LinedefsMode.cs b/Source/Plugins/BuilderModes/ClassicModes/LinedefsMode.cs index 66a29718..ff22f52d 100644 --- a/Source/Plugins/BuilderModes/ClassicModes/LinedefsMode.cs +++ b/Source/Plugins/BuilderModes/ClassicModes/LinedefsMode.cs @@ -760,6 +760,7 @@ namespace CodeImp.DoomBuilder.BuilderModes General.Map.UndoRedo.WithdrawUndo(); break; } + BuilderPlug.Me.AdjustSplitCoordinates(ld, sld); } // Update cache values diff --git a/Source/Plugins/BuilderModes/ClassicModes/VerticesMode.cs b/Source/Plugins/BuilderModes/ClassicModes/VerticesMode.cs index cb10aae0..22443931 100644 --- a/Source/Plugins/BuilderModes/ClassicModes/VerticesMode.cs +++ b/Source/Plugins/BuilderModes/ClassicModes/VerticesMode.cs @@ -325,6 +325,7 @@ namespace CodeImp.DoomBuilder.BuilderModes General.Map.UndoRedo.WithdrawUndo(); return; } + BuilderPlug.Me.AdjustSplitCoordinates(l, sld); // Update General.Map.Map.Update(); @@ -642,7 +643,13 @@ namespace CodeImp.DoomBuilder.BuilderModes if(snaptonearest && (l != null)) { General.Interface.DisplayStatus(StatusType.Action, "Split a linedef."); - l.Split(v); + Linedef sld = l.Split(v); + if(sld == null) + { + General.Map.UndoRedo.WithdrawUndo(); + return; + } + BuilderPlug.Me.AdjustSplitCoordinates(l, sld); } else { diff --git a/Source/Plugins/BuilderModes/General/BuilderPlug.cs b/Source/Plugins/BuilderModes/General/BuilderPlug.cs index c091cef5..90c002b0 100644 --- a/Source/Plugins/BuilderModes/General/BuilderPlug.cs +++ b/Source/Plugins/BuilderModes/General/BuilderPlug.cs @@ -79,6 +79,7 @@ namespace CodeImp.DoomBuilder.BuilderModes private int showvisualthings; // 0 = none, 1 = sprite only, 2 = sprite caged private bool usegravity; private int changeheightbysidedef; // 0 = nothing, 1 = change ceiling, 2 = change floor + private int splitlinebehavior; // 0 = adjust texcoords, 1 = copy texcoords, 2 = reset texcoords private bool editnewthing; private bool editnewsector; private bool additiveselect; @@ -122,6 +123,7 @@ namespace CodeImp.DoomBuilder.BuilderModes public int ShowVisualThings { get { return showvisualthings; } set { showvisualthings = value; } } public bool UseGravity { get { return usegravity; } set { usegravity = value; } } public int ChangeHeightBySidedef { get { return changeheightbysidedef; } } + public int SplitLineBehavior { get { return splitlinebehavior; } } public bool EditNewThing { get { return editnewthing; } } public bool EditNewSector { get { return editnewsector; } } public bool AdditiveSelect { get { return additiveselect; } } @@ -211,6 +213,7 @@ namespace CodeImp.DoomBuilder.BuilderModes private void LoadSettings() { changeheightbysidedef = General.Settings.ReadPluginSetting("changeheightbysidedef", 0); + splitlinebehavior = General.Settings.ReadPluginSetting("splitlinebehavior", 0); editnewthing = General.Settings.ReadPluginSetting("editnewthing", true); editnewsector = General.Settings.ReadPluginSetting("editnewsector", false); additiveselect = General.Settings.ReadPluginSetting("additiveselect", false); @@ -352,6 +355,41 @@ namespace CodeImp.DoomBuilder.BuilderModes #endregion #region ================== Tools + + // This adjusts texture coordinates for splitted lines according to the user preferences + public void AdjustSplitCoordinates(Linedef oldline, Linedef newline) + { + // Copy X and Y coordinates + if(splitlinebehavior == 1) + { + if((oldline.Front != null) && (newline.Front != null)) + { + newline.Front.OffsetX = oldline.Front.OffsetX; + newline.Front.OffsetY = oldline.Front.OffsetY; + } + + if((oldline.Back != null) && (newline.Back != null)) + { + newline.Back.OffsetX = oldline.Back.OffsetX; + newline.Back.OffsetY = oldline.Back.OffsetY; + } + } + // Reset X coordinate, copy Y coordinate + else if(splitlinebehavior == 2) + { + if((oldline.Front != null) && (newline.Front != null)) + { + newline.Front.OffsetX = 0; + newline.Front.OffsetY = oldline.Front.OffsetY; + } + + if((oldline.Back != null) && (newline.Back != null)) + { + newline.Back.OffsetX = 0; + newline.Back.OffsetY = oldline.Back.OffsetY; + } + } + } // This finds all class types that inherits from the given type public Type[] FindClasses(Type t) diff --git a/Source/Plugins/BuilderModes/Interface/PreferencesForm.Designer.cs b/Source/Plugins/BuilderModes/Interface/PreferencesForm.Designer.cs index cbf25e32..f1a33919 100644 --- a/Source/Plugins/BuilderModes/Interface/PreferencesForm.Designer.cs +++ b/Source/Plugins/BuilderModes/Interface/PreferencesForm.Designer.cs @@ -31,6 +31,7 @@ namespace CodeImp.DoomBuilder.BuilderModes this.tabs = new System.Windows.Forms.TabControl(); this.taboptions = new System.Windows.Forms.TabPage(); this.groupBox3 = new System.Windows.Forms.GroupBox(); + this.autodragonpaste = new System.Windows.Forms.CheckBox(); this.visualmodeclearselection = new System.Windows.Forms.CheckBox(); this.autoclearselection = new System.Windows.Forms.CheckBox(); this.editnewthing = new System.Windows.Forms.CheckBox(); @@ -52,7 +53,8 @@ namespace CodeImp.DoomBuilder.BuilderModes this.groupBox1 = new System.Windows.Forms.GroupBox(); this.label1 = new System.Windows.Forms.Label(); this.heightbysidedef = new System.Windows.Forms.ComboBox(); - this.autodragonpaste = new System.Windows.Forms.CheckBox(); + this.label10 = new System.Windows.Forms.Label(); + this.splitbehavior = new System.Windows.Forms.ComboBox(); this.tabs.SuspendLayout(); this.taboptions.SuspendLayout(); this.groupBox3.SuspendLayout(); @@ -95,13 +97,23 @@ namespace CodeImp.DoomBuilder.BuilderModes this.groupBox3.Controls.Add(this.editnewthing); this.groupBox3.Controls.Add(this.editnewsector); this.groupBox3.Controls.Add(this.additiveselect); - this.groupBox3.Location = new System.Drawing.Point(308, 90); + this.groupBox3.Location = new System.Drawing.Point(308, 129); this.groupBox3.Name = "groupBox3"; this.groupBox3.Size = new System.Drawing.Size(332, 200); this.groupBox3.TabIndex = 18; this.groupBox3.TabStop = false; this.groupBox3.Text = " Options "; // + // autodragonpaste + // + this.autodragonpaste.AutoSize = true; + this.autodragonpaste.Location = new System.Drawing.Point(23, 163); + this.autodragonpaste.Name = "autodragonpaste"; + this.autodragonpaste.Size = new System.Drawing.Size(205, 18); + this.autodragonpaste.TabIndex = 6; + this.autodragonpaste.Text = "Drag selection automatically on paste"; + this.autodragonpaste.UseVisualStyleBackColor = true; + // // visualmodeclearselection // this.visualmodeclearselection.AutoSize = true; @@ -166,7 +178,7 @@ namespace CodeImp.DoomBuilder.BuilderModes this.groupBox2.Controls.Add(this.label6); this.groupBox2.Controls.Add(this.label4); this.groupBox2.Controls.Add(this.label7); - this.groupBox2.Location = new System.Drawing.Point(6, 90); + this.groupBox2.Location = new System.Drawing.Point(6, 129); this.groupBox2.Name = "groupBox2"; this.groupBox2.Size = new System.Drawing.Size(292, 200); this.groupBox2.TabIndex = 17; @@ -299,11 +311,13 @@ namespace CodeImp.DoomBuilder.BuilderModes // // groupBox1 // + this.groupBox1.Controls.Add(this.splitbehavior); + this.groupBox1.Controls.Add(this.label10); this.groupBox1.Controls.Add(this.label1); this.groupBox1.Controls.Add(this.heightbysidedef); this.groupBox1.Location = new System.Drawing.Point(6, 6); this.groupBox1.Name = "groupBox1"; - this.groupBox1.Size = new System.Drawing.Size(634, 78); + this.groupBox1.Size = new System.Drawing.Size(634, 117); this.groupBox1.TabIndex = 16; this.groupBox1.TabStop = false; this.groupBox1.Text = " Behavior "; @@ -329,18 +343,31 @@ namespace CodeImp.DoomBuilder.BuilderModes "Change both floor and ceiling height"}); this.heightbysidedef.Location = new System.Drawing.Point(364, 32); this.heightbysidedef.Name = "heightbysidedef"; - this.heightbysidedef.Size = new System.Drawing.Size(199, 22); + this.heightbysidedef.Size = new System.Drawing.Size(217, 22); this.heightbysidedef.TabIndex = 0; // - // autodragonpaste + // label10 // - this.autodragonpaste.AutoSize = true; - this.autodragonpaste.Location = new System.Drawing.Point(23, 163); - this.autodragonpaste.Name = "autodragonpaste"; - this.autodragonpaste.Size = new System.Drawing.Size(205, 18); - this.autodragonpaste.TabIndex = 6; - this.autodragonpaste.Text = "Drag selection automatically on paste"; - this.autodragonpaste.UseVisualStyleBackColor = true; + this.label10.AutoSize = true; + this.label10.Location = new System.Drawing.Point(178, 71); + this.label10.Name = "label10"; + this.label10.Size = new System.Drawing.Size(166, 14); + this.label10.TabIndex = 1; + this.label10.Text = "When splitting a linedef manually:"; + this.label10.TextAlign = System.Drawing.ContentAlignment.TopRight; + // + // splitbehavior + // + this.splitbehavior.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.splitbehavior.FormattingEnabled = true; + this.splitbehavior.Items.AddRange(new object[] { + "Interpolate texture coordinates", + "Duplicate texture coordinates", + "Reset X coordinate, duplicate Y coordinate"}); + this.splitbehavior.Location = new System.Drawing.Point(364, 68); + this.splitbehavior.Name = "splitbehavior"; + this.splitbehavior.Size = new System.Drawing.Size(217, 22); + this.splitbehavior.TabIndex = 2; // // PreferencesForm // @@ -393,5 +420,7 @@ namespace CodeImp.DoomBuilder.BuilderModes private CodeImp.DoomBuilder.Controls.ButtonsNumericTextbox highlightthingsrange; private CodeImp.DoomBuilder.Controls.ButtonsNumericTextbox highlightrange; private System.Windows.Forms.CheckBox autodragonpaste; + private System.Windows.Forms.ComboBox splitbehavior; + private System.Windows.Forms.Label label10; } } \ No newline at end of file diff --git a/Source/Plugins/BuilderModes/Interface/PreferencesForm.cs b/Source/Plugins/BuilderModes/Interface/PreferencesForm.cs index 16236b2d..f689d2d1 100644 --- a/Source/Plugins/BuilderModes/Interface/PreferencesForm.cs +++ b/Source/Plugins/BuilderModes/Interface/PreferencesForm.cs @@ -57,6 +57,7 @@ namespace CodeImp.DoomBuilder.BuilderModes // Apply current settings to interface heightbysidedef.SelectedIndex = General.Settings.ReadPluginSetting("changeheightbysidedef", 0); + splitbehavior.SelectedIndex = General.Settings.ReadPluginSetting("splitlinebehavior", 0); editnewthing.Checked = General.Settings.ReadPluginSetting("editnewthing", true); editnewsector.Checked = General.Settings.ReadPluginSetting("editnewsector", false); additiveselect.Checked = General.Settings.ReadPluginSetting("additiveselect", false); @@ -78,6 +79,7 @@ namespace CodeImp.DoomBuilder.BuilderModes { // Write preferred settings General.Settings.WritePluginSetting("changeheightbysidedef", heightbysidedef.SelectedIndex); + General.Settings.WritePluginSetting("splitlinebehavior", splitbehavior.SelectedIndex); General.Settings.WritePluginSetting("editnewthing", editnewthing.Checked); General.Settings.WritePluginSetting("editnewsector", editnewsector.Checked); General.Settings.WritePluginSetting("additiveselect", additiveselect.Checked); diff --git a/Source/Plugins/BuilderModes/Interface/PreferencesForm.resx b/Source/Plugins/BuilderModes/Interface/PreferencesForm.resx index 7bf2ce3e..01aa36cb 100644 --- a/Source/Plugins/BuilderModes/Interface/PreferencesForm.resx +++ b/Source/Plugins/BuilderModes/Interface/PreferencesForm.resx @@ -186,6 +186,12 @@ True + + True + + + True + True