UltimateZoneBuilder/Source/Plugins/BuilderModes/Interface/SlopeArchForm.cs

186 lines
3.6 KiB
C#
Raw Normal View History

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;
namespace CodeImp.DoomBuilder.BuilderModes
2020-06-01 19:57:17 +00:00
{
internal partial class SlopeArchForm : DelayedForm
2020-06-01 19:57:17 +00:00
{
private EditMode mode;
private double originaltheta;
private double originaloffset;
private double originalscale;
private double originalheightoffset;
private SlopeArcher slopearcher;
public event EventHandler UpdateChangedObjects;
bool updating;
2020-06-01 19:57:17 +00:00
internal SlopeArchForm(EditMode mode, SlopeArcher slopearcher)
2020-06-01 19:57:17 +00:00
{
InitializeComponent();
this.mode = mode;
this.slopearcher = slopearcher;
2020-06-01 19:57:17 +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();
scale.Text = (originalscale * 100.0).ToString();
heightoffset.Text = originalheightoffset.ToString();
updating = false;
2020-06-01 19:57:17 +00:00
}
private void UpdateArch()
2020-06-01 19:57:17 +00:00
{
double t = theta.GetResultFloat(originaltheta);
double o = offset.GetResultFloat(originaloffset);
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;
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)
{
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 <= 0.0)
{
t = 1.0;
theta.Text = "1";
}
if (t > 180.0)
{
t = 180.0;
theta.Text = "180";
}
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 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;
2020-06-01 19:57:17 +00:00
UpdateArch();
2020-06-01 19:57:17 +00:00
}
}
}