2020-06-01 19:57:17 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.ComponentModel;
|
|
|
|
|
using System.Data;
|
|
|
|
|
using System.Drawing;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using System.Windows.Forms;
|
|
|
|
|
using CodeImp.DoomBuilder.Windows;
|
|
|
|
|
using CodeImp.DoomBuilder.Controls;
|
|
|
|
|
using CodeImp.DoomBuilder.Editing;
|
|
|
|
|
using CodeImp.DoomBuilder.Geometry;
|
|
|
|
|
|
2020-06-03 21:34:22 +00:00
|
|
|
|
namespace CodeImp.DoomBuilder.BuilderModes
|
2020-06-01 19:57:17 +00:00
|
|
|
|
{
|
2020-06-03 21:34:22 +00:00
|
|
|
|
internal partial class SlopeArchForm : DelayedForm
|
2020-06-01 19:57:17 +00:00
|
|
|
|
{
|
|
|
|
|
private EditMode mode;
|
|
|
|
|
private double originaltheta;
|
|
|
|
|
private double originaloffset;
|
2020-06-03 21:34:22 +00:00
|
|
|
|
private double originalscale;
|
|
|
|
|
private double originalheightoffset;
|
|
|
|
|
private SlopeArcher slopearcher;
|
|
|
|
|
public event EventHandler UpdateChangedObjects;
|
2020-06-05 16:37:48 +00:00
|
|
|
|
bool updating;
|
2020-06-01 19:57:17 +00:00
|
|
|
|
|
2020-06-03 21:34:22 +00:00
|
|
|
|
internal SlopeArchForm(EditMode mode, SlopeArcher slopearcher)
|
2020-06-01 19:57:17 +00:00
|
|
|
|
{
|
|
|
|
|
InitializeComponent();
|
|
|
|
|
|
|
|
|
|
this.mode = mode;
|
2020-06-03 21:34:22 +00:00
|
|
|
|
this.slopearcher = slopearcher;
|
2020-06-01 19:57:17 +00:00
|
|
|
|
|
2020-06-03 21:34:22 +00:00
|
|
|
|
originaltheta = Angle2D.RadToDeg(this.slopearcher.Theta);
|
|
|
|
|
originaloffset = Angle2D.RadToDeg(this.slopearcher.OffsetAngle);
|
|
|
|
|
originalscale = this.slopearcher.Scale;
|
|
|
|
|
originalheightoffset = this.slopearcher.HeightOffset;
|
2020-06-01 19:57:17 +00:00
|
|
|
|
|
|
|
|
|
theta.Text = originaltheta.ToString();
|
|
|
|
|
offset.Text = originaloffset.ToString();
|
2020-06-03 21:34:22 +00:00
|
|
|
|
scale.Text = (originalscale * 100.0).ToString();
|
|
|
|
|
heightoffset.Text = originalheightoffset.ToString();
|
2020-06-05 16:37:48 +00:00
|
|
|
|
|
|
|
|
|
updating = false;
|
2020-06-01 19:57:17 +00:00
|
|
|
|
}
|
|
|
|
|
|
2020-06-05 16:37:48 +00:00
|
|
|
|
private void UpdateArch()
|
2020-06-01 19:57:17 +00:00
|
|
|
|
{
|
|
|
|
|
double t = theta.GetResultFloat(originaltheta);
|
|
|
|
|
double o = offset.GetResultFloat(originaloffset);
|
2020-06-03 21:34:22 +00:00
|
|
|
|
double s = scale.GetResultFloat(originalscale * 100.0) / 100.0;
|
2020-06-01 19:57:17 +00:00
|
|
|
|
|
|
|
|
|
if (t > 180.0)
|
|
|
|
|
theta.Text = "180";
|
|
|
|
|
|
|
|
|
|
if (t + o > 180.0 || t + o < 0.0)
|
|
|
|
|
return;
|
|
|
|
|
|
2020-06-03 21:34:22 +00:00
|
|
|
|
if(!up.Checked)
|
|
|
|
|
s *= -1.0;
|
|
|
|
|
|
|
|
|
|
slopearcher.Theta = Angle2D.DegToRad(t);
|
|
|
|
|
slopearcher.OffsetAngle = Angle2D.DegToRad(o);
|
|
|
|
|
slopearcher.Scale = s;
|
|
|
|
|
slopearcher.HeightOffset = heightoffset.GetResultFloat(originalheightoffset);
|
|
|
|
|
|
|
|
|
|
slopearcher.ApplySlope();
|
|
|
|
|
|
|
|
|
|
UpdateChangedObjects?.Invoke(this, EventArgs.Empty);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void SlopeArchForm_Shown(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
slopearcher.ApplySlope();
|
|
|
|
|
UpdateChangedObjects?.Invoke(this, EventArgs.Empty);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void halfcircle_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
2020-06-05 16:37:48 +00:00
|
|
|
|
updating = true;
|
|
|
|
|
|
2020-06-03 21:34:22 +00:00
|
|
|
|
theta.Text = "180";
|
|
|
|
|
offset.Text = "0";
|
2020-06-05 16:37:48 +00:00
|
|
|
|
|
|
|
|
|
UpdateArch();
|
|
|
|
|
|
|
|
|
|
updating = false;
|
2020-06-03 21:34:22 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void quartercircleleft_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
2020-06-05 16:37:48 +00:00
|
|
|
|
updating = true;
|
|
|
|
|
|
2020-06-03 21:34:22 +00:00
|
|
|
|
theta.Text = "90";
|
|
|
|
|
offset.Text = "90";
|
2020-06-05 16:37:48 +00:00
|
|
|
|
|
|
|
|
|
UpdateArch();
|
|
|
|
|
|
|
|
|
|
updating = false;
|
2020-06-03 21:34:22 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void quartercircleright_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
2020-06-05 16:37:48 +00:00
|
|
|
|
updating = true;
|
|
|
|
|
|
2020-06-03 21:34:22 +00:00
|
|
|
|
theta.Text = "90";
|
|
|
|
|
offset.Text = "0";
|
2020-06-05 16:37:48 +00:00
|
|
|
|
|
|
|
|
|
UpdateArch();
|
|
|
|
|
|
|
|
|
|
updating = false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void theta_WhenTextChanged(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (updating)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
updating = true;
|
|
|
|
|
|
|
|
|
|
double t = theta.GetResultFloat(originaltheta);
|
|
|
|
|
|
2020-06-06 09:51:09 +00:00
|
|
|
|
if (t <= 0.0)
|
|
|
|
|
{
|
|
|
|
|
t = 1.0;
|
|
|
|
|
theta.Text = "1";
|
|
|
|
|
}
|
|
|
|
|
|
2020-06-05 16:37:48 +00:00
|
|
|
|
if (t > 180.0)
|
2020-06-06 09:51:09 +00:00
|
|
|
|
{
|
2020-06-05 16:37:48 +00:00
|
|
|
|
t = 180.0;
|
2020-06-06 09:51:09 +00:00
|
|
|
|
theta.Text = "180";
|
|
|
|
|
}
|
2020-06-05 16:37:48 +00:00
|
|
|
|
|
|
|
|
|
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();
|
2020-06-03 21:34:22 +00:00
|
|
|
|
}
|
|
|
|
|
|
2020-06-05 16:37:48 +00:00
|
|
|
|
private void heightoffset_WhenTextChanged(object sender, EventArgs e)
|
2020-06-03 21:34:22 +00:00
|
|
|
|
{
|
2020-06-05 16:37:48 +00:00
|
|
|
|
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;
|
2020-06-01 19:57:17 +00:00
|
|
|
|
|
2020-06-05 16:37:48 +00:00
|
|
|
|
UpdateArch();
|
2020-06-01 19:57:17 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|