Sector Edit Form (Doom/Hexen): it was possible to set negative Brightness.

Sector Edit Form (UDMF): sector brightness value was processed incorrectly when relative value was entered.
Internal: added "ButtonStepsWrapAround" property to ButtonsNumericTextbox.
Internal, SectorEditFormUDMF: more changes to Slopes tab. Still not operational...
This commit is contained in:
MaxED 2014-09-15 08:15:22 +00:00
parent f9cedc23a0
commit 71a3f1c733
8 changed files with 76 additions and 87 deletions

View file

@ -41,6 +41,7 @@ namespace CodeImp.DoomBuilder.Controls
private StepsList steps;
private int stepsize = 1;
private float stepsizeFloat = 1.0f; //mxd
private bool wrapsteps; //mxd
#endregion
@ -54,7 +55,8 @@ namespace CodeImp.DoomBuilder.Controls
override public string Text { get { return textbox.Text; } set { textbox.Text = value; } }
internal NumericTextbox Textbox { get { return textbox; } }
public StepsList StepValues { get { return steps; } set { steps = value; } }
public bool ButtonStepsWrapAround { get { return wrapsteps; } set { wrapsteps = value; } }
#endregion
#region ================== Constructor / Disposer
@ -111,9 +113,9 @@ namespace CodeImp.DoomBuilder.Controls
if(steps != null)
{
if(buttons.Value < 0)
textbox.Text = steps.GetNextHigher(textbox.GetResult(0)).ToString();
textbox.Text = steps.GetNextHigherWrap(textbox.GetResult(0), wrapsteps).ToString(); //mxd
else if(buttons.Value > 0)
textbox.Text = steps.GetNextLower(textbox.GetResult(0)).ToString();
textbox.Text = steps.GetNextLowerWrap(textbox.GetResult(0), wrapsteps).ToString(); //mxd
}
else if(textbox.AllowDecimal)
{

View file

@ -193,7 +193,8 @@ namespace CodeImp.DoomBuilder.Controls
public bool CheckIsRelative()
{
// Prefixed with ++, --, * or /?
return (this.Text.StartsWith("++") || this.Text.StartsWith("--") || this.Text.StartsWith("*") || this.Text.StartsWith("/")); //mxd
return ( (this.Text.Length > 2 && (this.Text.StartsWith("++") || this.Text.StartsWith("--"))) ||
(this.Text.Length > 1 && (this.Text.StartsWith("*") || this.Text.StartsWith("/"))) ); //mxd
}
// This determines the result value

View file

@ -54,11 +54,6 @@ namespace CodeImp.DoomBuilder.Controls
#region ================== Methods
public void SetValues(float anglexy, float anglez, float offset, bool first) {
blockUpdate = true;
//dbg
//if(first) Console.WriteLine("First: anglexy=" + anglexy + "; anglez=" + anglez + "; offset=" + offset);
if (first) {
// Set values
this.anglexy = anglexy;
@ -70,8 +65,6 @@ namespace CodeImp.DoomBuilder.Controls
if(!float.IsNaN(this.anglez) && this.anglez != anglez) this.anglez = float.NaN;
if(!float.IsNaN(this.offset) && this.offset != offset) this.offset = float.NaN;
}
blockUpdate = false;
}
public void SetOffset(float offset, bool first) {
@ -197,6 +190,7 @@ namespace CodeImp.DoomBuilder.Controls
}
private void cbuselineangles_CheckedChanged(object sender, EventArgs e) {
sloperotation.ButtonStepsWrapAround = cbuselineangles.Checked;
if(blockUpdate) return;
if(OnUseLineAnglesChanged != null) OnUseLineAnglesChanged(this, EventArgs.Empty);
}

View file

@ -65,14 +65,32 @@ namespace CodeImp.DoomBuilder
return base[low];
}
//mxd. This returns a step higher, or lowest step if level is already the highest possible value
public int GetNextHigherWrap(int level, bool wraparound)
{
int result = GetNextHigher(level);
if(!wraparound) return result;
return (result == level ? this[0] : result);
}
//mxd. This returns a step lower, or highest step if level is already the lowest possible value
public int GetNextLowerWrap(int level, bool wraparound)
{
int result = GetNextLower(level);
if(!wraparound) return result;
return (result == level ? this[this.Count - 1] : result);
}
//mxd. This returns a step higher for UDMF relative light range (-255..255)
public int GetNextHigher(int level, bool absolute) {
public int GetNextHigher(int level, bool absolute)
{
if(absolute || level >= 0) return GetNextHigher(level);
return -GetNextLower(Math.Abs(level));
}
//mxd. This returns a step lower for UDMF relative light range (-255..255)
public int GetNextLower(int level, bool absolute) {
public int GetNextLower(int level, bool absolute)
{
if(absolute || level > 0) return GetNextLower(level);
return -GetNextHigher(Math.Abs(level));
}

View file

@ -160,12 +160,12 @@ namespace CodeImp.DoomBuilder.Windows
//
groupfloorceiling.BackColor = System.Drawing.Color.Transparent;
groupfloorceiling.Controls.Add(label7);
groupfloorceiling.Controls.Add(label5);
groupfloorceiling.Controls.Add(label6);
groupfloorceiling.Controls.Add(this.heightoffset);
groupfloorceiling.Controls.Add(this.brightness);
groupfloorceiling.Controls.Add(this.ceilingheight);
groupfloorceiling.Controls.Add(label6);
groupfloorceiling.Controls.Add(label9);
groupfloorceiling.Controls.Add(label5);
groupfloorceiling.Controls.Add(label2);
groupfloorceiling.Controls.Add(this.sectorheightlabel);
groupfloorceiling.Controls.Add(label4);
@ -199,6 +199,7 @@ namespace CodeImp.DoomBuilder.Windows
this.heightoffset.AllowRelative = false;
this.heightoffset.ButtonStep = 8;
this.heightoffset.ButtonStepFloat = 1F;
this.heightoffset.ButtonStepsWrapAround = false;
this.heightoffset.Location = new System.Drawing.Point(99, 95);
this.heightoffset.Name = "heightoffset";
this.heightoffset.Size = new System.Drawing.Size(88, 24);
@ -209,10 +210,11 @@ namespace CodeImp.DoomBuilder.Windows
// brightness
//
this.brightness.AllowDecimal = false;
this.brightness.AllowNegative = true;
this.brightness.AllowNegative = false;
this.brightness.AllowRelative = true;
this.brightness.ButtonStep = 8;
this.brightness.ButtonStepFloat = 1F;
this.brightness.ButtonStepsWrapAround = false;
this.brightness.Location = new System.Drawing.Point(99, 154);
this.brightness.Name = "brightness";
this.brightness.Size = new System.Drawing.Size(73, 24);
@ -227,6 +229,7 @@ namespace CodeImp.DoomBuilder.Windows
this.ceilingheight.AllowRelative = true;
this.ceilingheight.ButtonStep = 8;
this.ceilingheight.ButtonStepFloat = 1F;
this.ceilingheight.ButtonStepsWrapAround = false;
this.ceilingheight.Location = new System.Drawing.Point(99, 35);
this.ceilingheight.Name = "ceilingheight";
this.ceilingheight.Size = new System.Drawing.Size(88, 24);
@ -311,6 +314,7 @@ namespace CodeImp.DoomBuilder.Windows
this.floorheight.AllowRelative = true;
this.floorheight.ButtonStep = 8;
this.floorheight.ButtonStepFloat = 1F;
this.floorheight.ButtonStepsWrapAround = false;
this.floorheight.Location = new System.Drawing.Point(99, 65);
this.floorheight.Name = "floorheight";
this.floorheight.Size = new System.Drawing.Size(88, 24);

View file

@ -135,9 +135,6 @@
<metadata name="label8.GenerateMember" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>False</value>
</metadata>
<metadata name="label8.GenerateMember" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>False</value>
</metadata>
<metadata name="label9.GenerateMember" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>False</value>
</metadata>
@ -150,10 +147,10 @@
<metadata name="tooltip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
<metadata name="label6.GenerateMember" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<metadata name="label5.GenerateMember" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>False</value>
</metadata>
<metadata name="label5.GenerateMember" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<metadata name="label6.GenerateMember" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>False</value>
</metadata>
<metadata name="label2.GenerateMember" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">

View file

@ -190,10 +190,11 @@
// brightness
//
this.brightness.AllowDecimal = false;
this.brightness.AllowNegative = true;
this.brightness.AllowNegative = false;
this.brightness.AllowRelative = true;
this.brightness.ButtonStep = 8;
this.brightness.ButtonStepFloat = 1F;
this.brightness.ButtonStepsWrapAround = false;
this.brightness.Location = new System.Drawing.Point(125, 84);
this.brightness.Name = "brightness";
this.brightness.Size = new System.Drawing.Size(81, 24);
@ -208,6 +209,7 @@
this.desaturation.AllowRelative = false;
this.desaturation.ButtonStep = 1;
this.desaturation.ButtonStepFloat = 0.1F;
this.desaturation.ButtonStepsWrapAround = false;
this.desaturation.Location = new System.Drawing.Point(125, 142);
this.desaturation.Name = "desaturation";
this.desaturation.Size = new System.Drawing.Size(81, 24);
@ -255,6 +257,7 @@
this.gravity.AllowRelative = true;
this.gravity.ButtonStep = 1;
this.gravity.ButtonStepFloat = 0.1F;
this.gravity.ButtonStepsWrapAround = false;
this.gravity.Location = new System.Drawing.Point(125, 112);
this.gravity.Name = "gravity";
this.gravity.Size = new System.Drawing.Size(81, 24);
@ -310,10 +313,10 @@
groupfloorceiling.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
groupfloorceiling.Controls.Add(label15);
groupfloorceiling.Controls.Add(this.heightoffset);
groupfloorceiling.Controls.Add(this.ceilingheight);
groupfloorceiling.Controls.Add(label6);
groupfloorceiling.Controls.Add(label5);
groupfloorceiling.Controls.Add(this.heightoffset);
groupfloorceiling.Controls.Add(this.ceilingheight);
groupfloorceiling.Controls.Add(this.sectorheightlabel);
groupfloorceiling.Controls.Add(this.sectorheight);
groupfloorceiling.Controls.Add(this.floorheight);
@ -343,6 +346,7 @@
this.heightoffset.AllowRelative = false;
this.heightoffset.ButtonStep = 8;
this.heightoffset.ButtonStepFloat = 1F;
this.heightoffset.ButtonStepsWrapAround = false;
this.heightoffset.Location = new System.Drawing.Point(89, 79);
this.heightoffset.Name = "heightoffset";
this.heightoffset.Size = new System.Drawing.Size(88, 24);
@ -357,6 +361,7 @@
this.ceilingheight.AllowRelative = true;
this.ceilingheight.ButtonStep = 8;
this.ceilingheight.ButtonStepFloat = 1F;
this.ceilingheight.ButtonStepsWrapAround = false;
this.ceilingheight.Location = new System.Drawing.Point(89, 19);
this.ceilingheight.Name = "ceilingheight";
this.ceilingheight.Size = new System.Drawing.Size(88, 24);
@ -413,6 +418,7 @@
this.floorheight.AllowRelative = true;
this.floorheight.ButtonStep = 8;
this.floorheight.ButtonStepFloat = 1F;
this.floorheight.ButtonStepsWrapAround = false;
this.floorheight.Location = new System.Drawing.Point(89, 49);
this.floorheight.Name = "floorheight";
this.floorheight.Size = new System.Drawing.Size(88, 24);
@ -524,7 +530,7 @@
//
// floorAngleControl
//
this.floorAngleControl.Angle = -270;
this.floorAngleControl.Angle = -540;
this.floorAngleControl.AngleOffset = 90;
this.floorAngleControl.Location = new System.Drawing.Point(186, 132);
this.floorAngleControl.Name = "floorAngleControl";
@ -559,6 +565,7 @@
this.floorAlpha.AllowRelative = false;
this.floorAlpha.ButtonStep = 1;
this.floorAlpha.ButtonStepFloat = 0.1F;
this.floorAlpha.ButtonStepsWrapAround = false;
this.floorAlpha.Location = new System.Drawing.Point(118, 173);
this.floorAlpha.Name = "floorAlpha";
this.floorAlpha.Size = new System.Drawing.Size(62, 24);
@ -583,6 +590,7 @@
this.floorRotation.AllowRelative = true;
this.floorRotation.ButtonStep = 5;
this.floorRotation.ButtonStepFloat = 1F;
this.floorRotation.ButtonStepsWrapAround = false;
this.floorRotation.Location = new System.Drawing.Point(118, 143);
this.floorRotation.Name = "floorRotation";
this.floorRotation.Size = new System.Drawing.Size(62, 24);
@ -619,6 +627,7 @@
this.floorBrightness.AllowRelative = true;
this.floorBrightness.ButtonStep = 16;
this.floorBrightness.ButtonStepFloat = 1F;
this.floorBrightness.ButtonStepsWrapAround = false;
this.floorBrightness.Location = new System.Drawing.Point(118, 113);
this.floorBrightness.Name = "floorBrightness";
this.floorBrightness.Size = new System.Drawing.Size(62, 24);
@ -721,7 +730,7 @@
//
// ceilAngleControl
//
this.ceilAngleControl.Angle = -270;
this.ceilAngleControl.Angle = -540;
this.ceilAngleControl.AngleOffset = 90;
this.ceilAngleControl.Location = new System.Drawing.Point(186, 132);
this.ceilAngleControl.Name = "ceilAngleControl";
@ -756,6 +765,7 @@
this.ceilAlpha.AllowRelative = false;
this.ceilAlpha.ButtonStep = 1;
this.ceilAlpha.ButtonStepFloat = 0.1F;
this.ceilAlpha.ButtonStepsWrapAround = false;
this.ceilAlpha.Location = new System.Drawing.Point(118, 173);
this.ceilAlpha.Name = "ceilAlpha";
this.ceilAlpha.Size = new System.Drawing.Size(62, 24);
@ -780,6 +790,7 @@
this.ceilRotation.AllowRelative = true;
this.ceilRotation.ButtonStep = 5;
this.ceilRotation.ButtonStepFloat = 1F;
this.ceilRotation.ButtonStepsWrapAround = false;
this.ceilRotation.Location = new System.Drawing.Point(118, 143);
this.ceilRotation.Name = "ceilRotation";
this.ceilRotation.Size = new System.Drawing.Size(62, 24);
@ -817,6 +828,7 @@
this.ceilBrightness.AllowRelative = true;
this.ceilBrightness.ButtonStep = 16;
this.ceilBrightness.ButtonStepFloat = 1F;
this.ceilBrightness.ButtonStepsWrapAround = false;
this.ceilBrightness.Location = new System.Drawing.Point(118, 113);
this.ceilBrightness.Name = "ceilBrightness";
this.ceilBrightness.Size = new System.Drawing.Size(62, 24);

View file

@ -646,10 +646,12 @@ namespace CodeImp.DoomBuilder.Windows
}
private void cbUseCeilLineAngles_CheckedChanged(object sender, EventArgs e) {
ceilRotation.ButtonStepsWrapAround = cbUseCeilLineAngles.Checked;
ceilRotation.StepValues = (cbUseCeilLineAngles.Checked ? anglesteps : null);
}
private void cbUseFloorLineAngles_CheckedChanged(object sender, EventArgs e) {
floorRotation.ButtonStepsWrapAround = cbUseFloorLineAngles.Checked;
floorRotation.StepValues = (cbUseFloorLineAngles.Checked ? anglesteps : null);
}
@ -700,14 +702,6 @@ namespace CodeImp.DoomBuilder.Windows
s.Brightness = sectorprops[s].Brightness;
//update values
} else {
//clamp value?
int val = brightness.GetResult(0);
int clampedVal = General.Clamp(val, 0, 255);
if(val != clampedVal) {
brightness.Text = clampedVal.ToString();
return;
}
foreach(Sector s in sectors)
s.Brightness = General.Clamp(brightness.GetResult(sectorprops[s].Brightness), General.Map.FormatInterface.MinBrightness, General.Map.FormatInterface.MaxBrightness);
}
@ -1002,85 +996,45 @@ namespace CodeImp.DoomBuilder.Windows
private void SetupSlopes(Sector s, bool first) {
if(s.CeilingSlope.GetLengthSq() > 0) {
float anglexy = (float) Math.Round(Angle2D.RadToDeg(s.CeilingSlope.GetAngleXY()), 1);
float anglez = (float)(Math.Round(-Angle2D.RadToDeg(s.CeilingSlope.GetAngleZ()) + 90, 1) % 90 + 90);
float anglexy = (float)Math.Round(Angle2D.RadToDeg(s.CeilingSlope.GetAngleXY()), 1);
float anglez = (float)(270 - Math.Round(Angle2D.RadToDeg(s.CeilingSlope.GetAngleZ()), 1));
float offset = (float)Math.Round(GetSlopeOffset(s, s.CeilingSlopeOffset, ceilingslopecontrol.PivotMode, false), 1);
if (anglexy == 180.0f) {
anglexy = 0;
anglez = -anglez;
}
ceilingslopecontrol.SetValues(anglexy, anglez, (float)Math.Round(-s.CeilingSlopeOffset, 1), first);
ceilingslopecontrol.SetValues(anglexy, anglez, offset, first);
} else {
ceilingslopecontrol.SetValues(0f, 0f, s.CeilHeight, first);
}
if(s.FloorSlope.GetLengthSq() > 0) {
//dbg
Console.WriteLine("1 anglez=" + Angle2D.RadToDeg(s.FloorSlope.GetAngleZ()));
Console.WriteLine("2 anglez=" + Math.Round(Angle2D.RadToDeg(s.FloorSlope.GetAngleZ()) - 90, 1));
Console.WriteLine("3 anglez=" + (float)(Math.Round(Angle2D.RadToDeg(s.FloorSlope.GetAngleZ()) - 90, 1) % 90));
float anglexy = (float) Math.Round(Angle2D.RadToDeg(s.FloorSlope.GetAngleXY()), 1);
float anglexy = (float)Math.Round(Angle2D.RadToDeg(s.FloorSlope.GetAngleXY()), 1);
float anglez = (float)(Math.Round(Angle2D.RadToDeg(s.FloorSlope.GetAngleZ()) - 90, 1));
float offset = (float)Math.Round(GetSlopeOffset(s, -s.FloorSlopeOffset, floorslopecontrol.PivotMode, true), 1);
if (anglexy == 180.0f) {
anglexy = 0;
anglez = -anglez;
}
floorslopecontrol.SetValues(anglexy, anglez, (float)Math.Round(-s.FloorSlopeOffset, 1), first);
floorslopecontrol.SetValues(anglexy, anglez, offset, first);
} else {
//dbg
Console.WriteLine("Default anglez=" + Angle2D.RadToDeg(s.FloorSlope.GetAngleZ()));
floorslopecontrol.SetValues(0f, 0f, s.FloorHeight, first);
}
}
/*private float GetSlopeOffset(Sector target, float offset, bool floor) {
//float offset = (float)Math.Round((floor ? target.FloorSlopeOffset : target.CeilingSlopeOffset), 1);
if(float.IsNaN(offset)) {
float storedoffset = (floor ? sectorprops[target].FloorSlopeOffset : sectorprops[target].CeilingSlopeOffset);
if(float.IsNaN(storedoffset)) {
//return an offset based on sector's floor/ceiling height
return (floor ? target.FloorHeight : target.CeilHeight);
} else {
//restore initial value
return storedoffset;
}
} else {
//use current value
return offset;
}
}*/
private float GetSlopeOffset(Sector target, float offset, SlopePivotMode mode, bool floor) {
float validoffset;
if (mode == SlopePivotMode.ORIGIN) {
if (float.IsNaN(offset)) {
//float storedoffset = (floor ? sectorprops[target].FloorSlopeOffset : sectorprops[target].CeilingSlopeOffset);
validoffset = (floor ? sectorprops[target].FloorSlopeOffset : sectorprops[target].CeilingSlopeOffset);
/*if(float.IsNaN(storedoffset)) {
//return an offset based on sector's floor/ceiling height
validoffset = (floor ? target.FloorHeight : target.CeilHeight);
} else {
//restore initial value
validoffset = storedoffset;
}*/
//dbg
if(!floor) Console.WriteLine("1: validoffset=" + validoffset);
} else {
//use current value
validoffset = offset;
//dbg
if(!floor) Console.WriteLine("2: validoffset=" + validoffset);
}
} else {
//use virtual value
validoffset = (floor ? sectorprops[target].VirtualFloorSlopeOffset : sectorprops[target].VirtualCeilingSlopeOffset);
//dbg
if(!floor) Console.WriteLine("3: validoffset=" + validoffset);
}
switch(mode) {
@ -1117,12 +1071,6 @@ namespace CodeImp.DoomBuilder.Windows
{
anglexy = (float.IsNaN(ceilingslopecontrol.AngleXY) ? sectorprops[s].CeilingSlopeAngleXY : ceilingslopecontrol.AngleXY);
anglez = (float.IsNaN(ceilingslopecontrol.AngleZ) ? sectorprops[s].CeilingSlopeAngleZ : ceilingslopecontrol.AngleZ + 90);
/*if (s.CeilingSlope.GetLengthSq() > 0) {
s.CeilingSlopeOffset = SetSlopeOffset(ceilingslopecontrol.Offset, sectorprops[i].CeilingSlopeOffset, i);
} else {
s.CeilingSlopeOffset = s.CeilHeight;
}*/
if (anglexy == 0 && anglez == 90) {
s.CeilingSlope = new Vector3D();
} else {
@ -1197,28 +1145,41 @@ namespace CodeImp.DoomBuilder.Windows
s.FloorSlopeOffset = GetSlopeOffset(s, -floorslopecontrol.Offset, floorslopecontrol.PivotMode, true);
s.UpdateNeeded = true;
}
General.Map.IsChanged = true;
if(OnValuesChanged != null) OnValuesChanged(this, EventArgs.Empty);
}
private void ceilingslopecontrol_OnResetClicked(object sender, EventArgs e)
{
ceilingslopecontrol.SetOffset(General.GetByIndex(sectors, 0).CeilHeight, true);
foreach(Sector s in sectors) {
s.CeilingSlope = new Vector3D();
s.CeilingSlopeOffset = float.NaN;
s.UpdateNeeded = true;
ceilingslopecontrol.SetOffset(s.CeilHeight, false);
}
ceilingslopecontrol.UpdateOffset();
General.Map.IsChanged = true;
if(OnValuesChanged != null) OnValuesChanged(this, EventArgs.Empty);
}
private void floorslopecontrol_OnResetClicked(object sender, EventArgs e)
{
floorslopecontrol.SetOffset(General.GetByIndex(sectors, 0).FloorHeight, true);
foreach(Sector s in sectors) {
s.FloorSlope = new Vector3D();
s.FloorSlopeOffset = float.NaN;
s.UpdateNeeded = true;
floorslopecontrol.SetOffset(s.FloorHeight, false);
}
floorslopecontrol.UpdateOffset();
General.Map.IsChanged = true;
if(OnValuesChanged != null) OnValuesChanged(this, EventArgs.Empty);
}