From f93a13c1f2250ef1439eb2b3d4ddc499257fdb2c Mon Sep 17 00:00:00 2001 From: biwa <6475593+biwa@users.noreply.github.com> Date: Fri, 5 Jun 2020 18:37:48 +0200 Subject: [PATCH] Fixed base heights for 3D floors Improved handling of changing input boxes in slope arching form --- .../Interface/SlopeArchForm.Designer.cs | 13 ++- .../BuilderModes/Interface/SlopeArchForm.cs | 81 ++++++++++++++++++- .../BuilderModes/VisualModes/SlopeArcher.cs | 7 +- 3 files changed, 91 insertions(+), 10 deletions(-) diff --git a/Source/Plugins/BuilderModes/Interface/SlopeArchForm.Designer.cs b/Source/Plugins/BuilderModes/Interface/SlopeArchForm.Designer.cs index 8b114e8ec..8ef8ecac9 100644 --- a/Source/Plugins/BuilderModes/Interface/SlopeArchForm.Designer.cs +++ b/Source/Plugins/BuilderModes/Interface/SlopeArchForm.Designer.cs @@ -62,7 +62,7 @@ this.theta.Size = new System.Drawing.Size(63, 24); this.theta.StepValues = null; this.theta.TabIndex = 18; - this.theta.WhenTextChanged += new System.EventHandler(this.UpdateArch); + this.theta.WhenTextChanged += new System.EventHandler(this.theta_WhenTextChanged); // // label1 // @@ -72,7 +72,6 @@ this.label1.Size = new System.Drawing.Size(37, 13); this.label1.TabIndex = 19; this.label1.Text = "Angle:"; - this.label1.Click += new System.EventHandler(this.label1_Click); // // offset // @@ -91,7 +90,7 @@ this.offset.Size = new System.Drawing.Size(63, 24); this.offset.StepValues = null; this.offset.TabIndex = 20; - this.offset.WhenTextChanged += new System.EventHandler(this.UpdateArch); + this.offset.WhenTextChanged += new System.EventHandler(this.offset_WhenTextChanged); // // label2 // @@ -133,7 +132,7 @@ this.up.TabStop = true; this.up.Text = "Up"; this.up.UseVisualStyleBackColor = true; - this.up.CheckedChanged += new System.EventHandler(this.UpdateArch); + this.up.CheckedChanged += new System.EventHandler(this.up_CheckedChanged); // // down // @@ -144,7 +143,7 @@ this.down.TabIndex = 25; this.down.Text = "Down"; this.down.UseVisualStyleBackColor = true; - this.down.CheckedChanged += new System.EventHandler(this.UpdateArch); + this.down.CheckedChanged += new System.EventHandler(this.down_CheckedChanged); // // scale // @@ -163,7 +162,7 @@ this.scale.Size = new System.Drawing.Size(63, 24); this.scale.StepValues = null; this.scale.TabIndex = 26; - this.scale.WhenTextChanged += new System.EventHandler(this.UpdateArch); + this.scale.WhenTextChanged += new System.EventHandler(this.scale_WhenTextChanged); // // label3 // @@ -221,7 +220,7 @@ this.heightoffset.Size = new System.Drawing.Size(63, 24); this.heightoffset.StepValues = null; this.heightoffset.TabIndex = 31; - this.heightoffset.WhenTextChanged += new System.EventHandler(this.UpdateArch); + this.heightoffset.WhenTextChanged += new System.EventHandler(this.heightoffset_WhenTextChanged); // // label4 // diff --git a/Source/Plugins/BuilderModes/Interface/SlopeArchForm.cs b/Source/Plugins/BuilderModes/Interface/SlopeArchForm.cs index 6a0e4643c..d789eecdb 100644 --- a/Source/Plugins/BuilderModes/Interface/SlopeArchForm.cs +++ b/Source/Plugins/BuilderModes/Interface/SlopeArchForm.cs @@ -23,6 +23,7 @@ namespace CodeImp.DoomBuilder.BuilderModes private double originalheightoffset; private SlopeArcher slopearcher; public event EventHandler UpdateChangedObjects; + bool updating; internal SlopeArchForm(EditMode mode, SlopeArcher slopearcher) { @@ -40,9 +41,11 @@ namespace CodeImp.DoomBuilder.BuilderModes offset.Text = originaloffset.ToString(); scale.Text = (originalscale * 100.0).ToString(); heightoffset.Text = originalheightoffset.ToString(); + + updating = false; } - private void UpdateArch(object sender, EventArgs e) + private void UpdateArch() { double t = theta.GetResultFloat(originaltheta); double o = offset.GetResultFloat(originaloffset); @@ -75,25 +78,99 @@ namespace CodeImp.DoomBuilder.BuilderModes private void halfcircle_Click(object sender, EventArgs e) { + updating = true; + theta.Text = "180"; offset.Text = "0"; + + UpdateArch(); + + updating = false; } private void quartercircleleft_Click(object sender, EventArgs e) { + updating = true; + theta.Text = "90"; offset.Text = "90"; + + UpdateArch(); + + updating = false; } private void quartercircleright_Click(object sender, EventArgs e) { + updating = true; + theta.Text = "90"; offset.Text = "0"; + + UpdateArch(); + + updating = false; + } + + private void theta_WhenTextChanged(object sender, EventArgs e) + { + if (updating) + return; + + updating = true; + + double t = theta.GetResultFloat(originaltheta); + + if (t > 180.0) + t = 180.0; + + double o = (180 - t) / 2.0; + + offset.Text = o.ToString(); + + UpdateArch(); + + updating = false; + } + + private void offset_WhenTextChanged(object sender, EventArgs e) + { + if (updating) + return; + + UpdateArch(); + } + + private void scale_WhenTextChanged(object sender, EventArgs e) + { + if (updating) + return; + + UpdateArch(); } - private void label1_Click(object sender, EventArgs e) + private void heightoffset_WhenTextChanged(object sender, EventArgs e) { + if (updating) + return; + + UpdateArch(); + } + + private void up_CheckedChanged(object sender, EventArgs e) + { + if (updating) + return; + + UpdateArch(); + } + + private void down_CheckedChanged(object sender, EventArgs e) + { + if (updating) + return; + UpdateArch(); } } } diff --git a/Source/Plugins/BuilderModes/VisualModes/SlopeArcher.cs b/Source/Plugins/BuilderModes/VisualModes/SlopeArcher.cs index bc6615766..e53007df0 100644 --- a/Source/Plugins/BuilderModes/VisualModes/SlopeArcher.cs +++ b/Source/Plugins/BuilderModes/VisualModes/SlopeArcher.cs @@ -45,7 +45,12 @@ namespace CodeImp.DoomBuilder.BuilderModes handleline = new Line2D(handle1.GetCenterPoint(), handle2.GetCenterPoint()); length = handleline.GetLength(); - baseheight = handle1.Level.type == SectorLevelType.Ceiling ? handle1.Level.sector.CeilHeight : handle1.Level.sector.FloorHeight; + if (handle1.Level.type == SectorLevelType.Ceiling) + baseheight = handle1.Level.extrafloor ? handle1.Level.sector.FloorHeight : handle1.Level.sector.CeilHeight; + else + baseheight = handle1.Level.extrafloor ? handle1.Level.sector.CeilHeight : handle1.Level.sector.FloorHeight; + + //baseheight = handle1.Level.type == SectorLevelType.Ceiling ? handle1.Level.sector.CeilHeight : handle1.Level.sector.FloorHeight; baseheightoffset = 0.0; } -- GitLab