From 130101a2270129118a26dcd830093149aa23f037 Mon Sep 17 00:00:00 2001 From: MascaraSnake Date: Fri, 16 Sep 2016 23:07:18 +0200 Subject: [PATCH] Thing angles outside of 0-359 are now preserved when copypasting or placing new Things --- Source/Core/Config/ProgramConfiguration.cs | 4 ++-- Source/Core/Windows/ThingEditForm.cs | 2 +- Source/Core/Windows/ThingEditFormUDMF.cs | 2 +- .../ClassicModes/EditSelectionMode.cs | 19 +++++++++++-------- 4 files changed, 15 insertions(+), 12 deletions(-) diff --git a/Source/Core/Config/ProgramConfiguration.cs b/Source/Core/Config/ProgramConfiguration.cs index 237f954..7797cc7 100644 --- a/Source/Core/Config/ProgramConfiguration.cs +++ b/Source/Core/Config/ProgramConfiguration.cs @@ -141,7 +141,7 @@ namespace CodeImp.DoomBuilder.Config private int defaultfloorheight; private int defaultceilheight; private int defaultthingtype = 1; - private float defaultthingangle; + private int defaultthingangle; private List defaultthingflags; #endregion @@ -251,7 +251,7 @@ namespace CodeImp.DoomBuilder.Config public int DefaultCeilingHeight { get { return defaultceilheight; } set { defaultceilheight = value; } } public int DefaultThingType { get { return defaultthingtype; } set { defaultthingtype = value; } } - public float DefaultThingAngle { get { return defaultthingangle; } set { defaultthingangle = value; } } + public int DefaultThingAngle { get { return defaultthingangle; } set { defaultthingangle = value; } } #endregion diff --git a/Source/Core/Windows/ThingEditForm.cs b/Source/Core/Windows/ThingEditForm.cs index 05033fb..ff116e7 100644 --- a/Source/Core/Windows/ThingEditForm.cs +++ b/Source/Core/Windows/ThingEditForm.cs @@ -439,7 +439,7 @@ namespace CodeImp.DoomBuilder.Windows foreach(CheckBox c in flags.Checkboxes) if(c.CheckState == CheckState.Checked) defaultflags.Add(c.Tag.ToString()); General.Settings.DefaultThingType = thingtype.GetResult(General.Settings.DefaultThingType); - General.Settings.DefaultThingAngle = Angle2D.DegToRad((float)angle.GetResult((int)Angle2D.RadToDeg(General.Settings.DefaultThingAngle) - 90) + 90); + General.Settings.DefaultThingAngle = angle.GetResult(General.Settings.DefaultThingAngle); General.Settings.SetDefaultThingFlags(defaultflags); // Done diff --git a/Source/Core/Windows/ThingEditFormUDMF.cs b/Source/Core/Windows/ThingEditFormUDMF.cs index f60ddfa..dfc1ca4 100644 --- a/Source/Core/Windows/ThingEditFormUDMF.cs +++ b/Source/Core/Windows/ThingEditFormUDMF.cs @@ -505,7 +505,7 @@ namespace CodeImp.DoomBuilder.Windows if(c.CheckState == CheckState.Checked) defaultflags.Add(c.Tag.ToString()); } General.Settings.DefaultThingType = thingtype.GetResult(General.Settings.DefaultThingType); - General.Settings.DefaultThingAngle = Angle2D.DegToRad((float)angle.GetResult((int)Angle2D.RadToDeg(General.Settings.DefaultThingAngle) - 90) + 90); + General.Settings.DefaultThingAngle = angle.GetResult(General.Settings.DefaultThingAngle); General.Settings.SetDefaultThingFlags(defaultflags); // Store value linking diff --git a/Source/Plugins/BuilderModes/ClassicModes/EditSelectionMode.cs b/Source/Plugins/BuilderModes/ClassicModes/EditSelectionMode.cs index 27809db..19578bc 100644 --- a/Source/Plugins/BuilderModes/ClassicModes/EditSelectionMode.cs +++ b/Source/Plugins/BuilderModes/ClassicModes/EditSelectionMode.cs @@ -158,7 +158,8 @@ namespace CodeImp.DoomBuilder.BuilderModes private List vertexpos; private List thingpos; private List thingangle; - private ICollection unselectedvertices; + private List thingangledoom; + private ICollection unselectedvertices; private ICollection unselectedlines; // Modification @@ -731,7 +732,7 @@ namespace CodeImp.DoomBuilder.BuilderModes private void UpdateGeometry() { float[] newthingangle = thingangle.ToArray(); - int index; + int index; // Flip things horizontally if(size.x < 0.0f) @@ -834,7 +835,7 @@ namespace CodeImp.DoomBuilder.BuilderModes index = 0; foreach(Thing t in selectedthings) { - if(!fixedrotationthingtypes.Contains(t.SRB2Type)) //mxd. Polyobject Anchors, I hate you! + if(!fixedrotationthingtypes.Contains(t.SRB2Type) && newthingangle[index] != thingangle[index]) //mxd. Polyobject Anchors, I hate you! t.Rotate(Angle2D.Normalized(newthingangle[index])); index++; } @@ -1093,7 +1094,8 @@ namespace CodeImp.DoomBuilder.BuilderModes vertexpos = new List(selectedvertices.Count); thingpos = new List(selectedthings.Count); thingangle = new List(selectedthings.Count); - fixedrotationthingtypes = new List(); //mxd + thingangledoom = new List(selectedthings.Count); + fixedrotationthingtypes = new List(); //mxd // A selection must be made! if((selectedvertices.Count > 0) || (selectedthings.Count > 0)) @@ -1135,7 +1137,8 @@ namespace CodeImp.DoomBuilder.BuilderModes // Keep original coordinates thingpos.Add(t.Position); thingangle.Add(t.Angle); - } + thingangledoom.Add(t.AngleDoom); + } // Calculate size size = right - offset; @@ -1243,7 +1246,7 @@ namespace CodeImp.DoomBuilder.BuilderModes index = 0; foreach(Thing t in selectedthings) { - t.Rotate(thingangle[index]); + t.Rotate(thingangledoom[index]); t.Move(thingpos[index++]); } @@ -1305,7 +1308,7 @@ namespace CodeImp.DoomBuilder.BuilderModes index = 0; foreach(Thing t in selectedthings) { - t.Rotate(thingangle[index]); + t.Rotate(thingangledoom[index]); t.Move(thingpos[index++]); } @@ -1333,7 +1336,7 @@ namespace CodeImp.DoomBuilder.BuilderModes index = 0; foreach(Thing t in selectedthings) { - t.Rotate(thingangle[index]); + t.Rotate(thingangledoom[index]); t.Move(thingpos[index++]); }