diff --git a/Build/Configurations/Includes/Boom_generalized.cfg b/Build/Configurations/Includes/Boom_generalized.cfg index 78e3491b..04070a46 100644 --- a/Build/Configurations/Includes/Boom_generalized.cfg +++ b/Build/Configurations/Includes/Boom_generalized.cfg @@ -17,9 +17,9 @@ gen_sectortypes damage { 0 = "None"; - 32 = "Damage 5 per second"; - 64 = "Damage 10 per second"; - 96 = "Damage 20 per second"; + 32 = "5 per second"; + 64 = "10 per second"; + 96 = "20 per second"; } secret diff --git a/Source/Core/Config/GameConfiguration.cs b/Source/Core/Config/GameConfiguration.cs index 5d788486..d8785bdd 100644 --- a/Source/Core/Config/GameConfiguration.cs +++ b/Source/Core/Config/GameConfiguration.cs @@ -876,6 +876,43 @@ namespace CodeImp.DoomBuilder.Config // Not generalized return null; } + + //mxd + public static bool IsGeneralizedSectorEffect(int effect, IEnumerable options) + { + if (effect == 0) return false; + foreach (GeneralizedOption option in options) + { + foreach(GeneralizedBit bit in option.Bits) + { + if(bit.Index > 0 && (effect & bit.Index) == bit.Index) return true; + } + } + + return false; + } + + //mxd + public string GetGeneralizedSectorEffectName(int effect) + { + if (effect == 0) return "None"; + string title = "Unknown"; + int matches = 0; + + foreach(GeneralizedOption option in geneffectoptions) + { + foreach(GeneralizedBit bit in option.Bits) + { + if(bit.Index > 0 && (effect & bit.Index) == bit.Index) + { + title = option.Name + ": " + bit.Title; + matches++; + } + } + } + + return (matches > 1 ? "Generalized (" + matches + " effects)" : title); + } // This checks if a specific edit mode class is listed public bool IsEditModeSpecified(string classname) @@ -916,6 +953,10 @@ namespace CodeImp.DoomBuilder.Config else if(effect == 0) { return new SectorEffectInfo(0, "None", true, false); + } + else if(IsGeneralizedSectorEffect(effect, geneffectoptions)) //mxd + { + return new SectorEffectInfo(effect, GetGeneralizedSectorEffectName(effect), true, true); } else { diff --git a/Source/Core/Controls/ActionSelectorControl.cs b/Source/Core/Controls/ActionSelectorControl.cs index 20857006..b56232ee 100644 --- a/Source/Core/Controls/ActionSelectorControl.cs +++ b/Source/Core/Controls/ActionSelectorControl.cs @@ -33,6 +33,7 @@ namespace CodeImp.DoomBuilder.Controls // Variables private List generalizedcategories; + private List generalizedoptions; //mxd private bool controlpressed; // Constants @@ -42,6 +43,7 @@ namespace CodeImp.DoomBuilder.Controls public bool Empty { get { return (number.Text.Length == 0); } set { if(value) number.Text = ""; } } public int Value { get { return GetValue(); } set { number.Text = value.ToString(); } } public List GeneralizedCategories { get { return generalizedcategories; } set { generalizedcategories = value; } } + public List GeneralizedOptions { get { return generalizedoptions; } set { generalizedoptions = value; } } //mxd // Constructor public ActionSelectorControl() @@ -122,6 +124,8 @@ namespace CodeImp.DoomBuilder.Controls displayname = "None"; else if((generalizedcategories != null) && GameConfiguration.IsGeneralized(intnumber, generalizedcategories)) displayname = "Generalized (" + General.Map.Config.GetGeneralizedActionCategory(intnumber) + ")"; + else if((generalizedoptions != null) && GameConfiguration.IsGeneralizedSectorEffect(intnumber, generalizedoptions)) //mxd + displayname = General.Map.Config.GetGeneralizedSectorEffectName(intnumber); //mxd else displayname = "Unknown"; } diff --git a/Source/Core/Controls/SectorInfoPanel.cs b/Source/Core/Controls/SectorInfoPanel.cs index 6e7b67f7..639d1526 100644 --- a/Source/Core/Controls/SectorInfoPanel.cs +++ b/Source/Core/Controls/SectorInfoPanel.cs @@ -42,17 +42,10 @@ namespace CodeImp.DoomBuilder.Controls // This shows the info public void ShowInfo(Sector s) { - string effectinfo; - int sheight = s.CeilHeight - s.FloorHeight; // Lookup effect description in config - if(General.Map.Config.SectorEffects.ContainsKey(s.Effect)) - effectinfo = General.Map.Config.SectorEffects[s.Effect].ToString(); - else if(s.Effect == 0) - effectinfo = s.Effect + " - Normal"; - else - effectinfo = s.Effect + " - Unknown"; + string effectinfo = s.Effect + " - " + General.Map.Config.GetSectorEffectInfo(s.Effect).Title; //mxd // Sector info sectorinfo.Text = " Sector " + s.Index + " (" + (s.Sidedefs == null ? "no" : s.Sidedefs.Count.ToString()) + " sidedefs)"; //mxd diff --git a/Source/Core/Controls/SectorSlopeControl.cs b/Source/Core/Controls/SectorSlopeControl.cs index 6ea4ffb6..191f78fa 100644 --- a/Source/Core/Controls/SectorSlopeControl.cs +++ b/Source/Core/Controls/SectorSlopeControl.cs @@ -19,8 +19,11 @@ namespace CodeImp.DoomBuilder.Controls #region ================== Events - public event EventHandler OnValuesChanged; + public event EventHandler OnAnglesChanged; public event EventHandler OnUseLineAnglesChanged; + public event EventHandler OnOffsetChanged; + public event EventHandler OnPivotModeChanged; + public event EventHandler OnResetClicked; #endregion @@ -51,24 +54,31 @@ namespace CodeImp.DoomBuilder.Controls #region ================== Methods public void SetValues(float anglexy, float anglez, float offset, bool first) { - //update values + blockUpdate = true; + + //dbg + //if(first) Console.WriteLine("First: anglexy=" + anglexy + "; anglez=" + anglez + "; offset=" + offset); + if (first) { + // Set values this.anglexy = anglexy; this.anglez = anglez; this.offset = offset; - - //dbg - //Console.WriteLine("SetValues: anglexy=" + this.anglexy + "; anglez=" + this.anglez + "; offset=" + this.offset + "[first time]"); } else { - //dbg - //Console.WriteLine("SetValues: this.anglexy=" + this.anglexy + "; anglexy = " + anglexy + "; this.anglez=" + this.anglez + "; anglez = " + anglez + "; this.offset=" + this.offset + "; offset = " + offset + "[before]"); - + // Or update values if(!float.IsNaN(this.anglexy) && this.anglexy != anglexy) this.anglexy = float.NaN; if(!float.IsNaN(this.anglez) && this.anglez != anglez) this.anglez = float.NaN; if(!float.IsNaN(this.offset) && this.offset != offset) this.offset = float.NaN; + } - //dbg - //Console.WriteLine("SetValues: this.anglexy=" + this.anglexy + "; anglexy = " + anglexy + "; this.anglez=" + this.anglez + "; anglez = " + anglez + "; this.offset=" + this.offset + "; offset = " + offset + "[after]"); + blockUpdate = false; + } + + public void SetOffset(float offset, bool first) { + if(first) { + this.offset = offset; + } else { + if(!float.IsNaN(this.offset) && this.offset != offset) this.offset = float.NaN; } } @@ -88,7 +98,6 @@ namespace CodeImp.DoomBuilder.Controls angletrackbar.Value = 0; } else { //clamp value to [-85 .. 85] - //anglez = General.Clamp((anglez + 90) % 90 - 90, angletrackbar.Minimum, angletrackbar.Maximum); anglez = General.Clamp(anglez, angletrackbar.Minimum, angletrackbar.Maximum); slopeangle.Text = anglez.ToString(); @@ -96,15 +105,16 @@ namespace CodeImp.DoomBuilder.Controls angletrackbar.Value = (int)General.Clamp(anglez, angletrackbar.Minimum, angletrackbar.Maximum); } - slopeoffset.Text = float.IsNaN(offset) ? "" : offset.ToString(); + slopeoffset.Text = (float.IsNaN(offset) ? "" : offset.ToString()); blockUpdate = false; } - /*public void ClearOffset() { - offset = float.NaN; - slopeoffset.Text = string.Empty; - }*/ + public void UpdateOffset() { + blockUpdate = true; + slopeoffset.Text = (float.IsNaN(offset) ? "" : offset.ToString()); + blockUpdate = false; + } #endregion @@ -117,7 +127,7 @@ namespace CodeImp.DoomBuilder.Controls anglexy = General.ClampAngle(sloperotation.GetResultFloat(0f)); rotationcontrol.Angle = (int)Math.Round(anglexy + 90); - if(OnValuesChanged != null) OnValuesChanged(this, EventArgs.Empty); + if(OnAnglesChanged != null) OnAnglesChanged(this, EventArgs.Empty); blockUpdate = false; } @@ -128,7 +138,7 @@ namespace CodeImp.DoomBuilder.Controls anglexy = General.ClampAngle(rotationcontrol.Angle - 90); sloperotation.Text = anglexy.ToString(); - if(OnValuesChanged != null) OnValuesChanged(this, EventArgs.Empty); + if(OnAnglesChanged != null) OnAnglesChanged(this, EventArgs.Empty); blockUpdate = false; } @@ -139,7 +149,7 @@ namespace CodeImp.DoomBuilder.Controls anglez = General.Clamp((int)Math.Round(slopeangle.GetResultFloat(0f)), angletrackbar.Minimum, angletrackbar.Maximum); angletrackbar.Value = (int)anglez; - if(OnValuesChanged != null) OnValuesChanged(this, EventArgs.Empty); + if(OnAnglesChanged != null) OnAnglesChanged(this, EventArgs.Empty); blockUpdate = false; } @@ -150,13 +160,13 @@ namespace CodeImp.DoomBuilder.Controls slopeangle.Text = angletrackbar.Value.ToString(); anglez = angletrackbar.Value; - if(OnValuesChanged != null) OnValuesChanged(this, EventArgs.Empty); + if(OnAnglesChanged != null) OnAnglesChanged(this, EventArgs.Empty); blockUpdate = false; } private void slopeoffset_WhenTextChanged(object sender, EventArgs e) { offset = slopeoffset.GetResultFloat(0f); - if(OnValuesChanged != null) OnValuesChanged(this, EventArgs.Empty); + if(OnOffsetChanged != null) OnOffsetChanged(this, EventArgs.Empty); } private void reset_Click(object sender, EventArgs e) { @@ -171,13 +181,15 @@ namespace CodeImp.DoomBuilder.Controls anglez = 0f; offset = 0f; - if (OnValuesChanged != null) OnValuesChanged(this, EventArgs.Empty); + if(OnResetClicked != null) OnResetClicked(this, EventArgs.Empty); blockUpdate = false; } private void pivotmodeselector_SelectedIndexChanged(object sender, EventArgs e) { - if(blockUpdate) return; pivotmode = (SlopePivotMode)pivotmodeselector.SelectedIndex; + + if(blockUpdate) return; + if (OnPivotModeChanged != null) OnPivotModeChanged(this, EventArgs.Empty); } private void SectorSlopeControl_Load(object sender, EventArgs e) { diff --git a/Source/Core/IO/UniversalStreamWriter.cs b/Source/Core/IO/UniversalStreamWriter.cs index f0e93a9d..d761e0c1 100644 --- a/Source/Core/IO/UniversalStreamWriter.cs +++ b/Source/Core/IO/UniversalStreamWriter.cs @@ -276,7 +276,8 @@ namespace CodeImp.DoomBuilder.IO coll.Add("floorplane_a", Math.Round(s.FloorSlope.x, 3)); coll.Add("floorplane_b", Math.Round(s.FloorSlope.y, 3)); coll.Add("floorplane_c", Math.Round(s.FloorSlope.z, 3)); - coll.Add("floorplane_d", Math.Round(s.FloorSlopeOffset, 3)); + coll.Add("floorplane_d", + (float.IsNaN(s.FloorSlopeOffset) ? 0f : Math.Round(s.FloorSlopeOffset, 3))); } if (s.CeilingSlope.GetLengthSq() > 0) @@ -284,7 +285,8 @@ namespace CodeImp.DoomBuilder.IO coll.Add("ceilingplane_a", Math.Round(s.CeilingSlope.x, 3)); coll.Add("ceilingplane_b", Math.Round(s.CeilingSlope.y, 3)); coll.Add("ceilingplane_c", Math.Round(s.CeilingSlope.z, 3)); - coll.Add("ceilingplane_d", Math.Round(s.CeilingSlopeOffset, 3)); + coll.Add("ceilingplane_d", + (float.IsNaN(s.CeilingSlopeOffset) ? 0f : Math.Round(s.CeilingSlopeOffset, 3))); } //mxd. Flags diff --git a/Source/Core/Windows/SectorEditForm.cs b/Source/Core/Windows/SectorEditForm.cs index cfa209b1..7c5d5a49 100644 --- a/Source/Core/Windows/SectorEditForm.cs +++ b/Source/Core/Windows/SectorEditForm.cs @@ -78,6 +78,7 @@ namespace CodeImp.DoomBuilder.Windows } // Fill effects list + effect.GeneralizedOptions = General.Map.Config.GenEffectOptions; //mxd effect.AddInfo(General.Map.Config.SortedSectorEffects.ToArray()); // Initialize image selectors diff --git a/Source/Core/Windows/SectorEditFormUDMF.Designer.cs b/Source/Core/Windows/SectorEditFormUDMF.Designer.cs index 2a772a52..f0c64071 100644 --- a/Source/Core/Windows/SectorEditFormUDMF.Designer.cs +++ b/Source/Core/Windows/SectorEditFormUDMF.Designer.cs @@ -484,7 +484,8 @@ // // floorAngleControl // - this.floorAngleControl.Angle = 0; + this.floorAngleControl.Angle = 90; + this.floorAngleControl.AngleOffset = 90; this.floorAngleControl.Location = new System.Drawing.Point(186, 132); this.floorAngleControl.Name = "floorAngleControl"; this.floorAngleControl.Size = new System.Drawing.Size(44, 44); @@ -680,7 +681,8 @@ // // ceilAngleControl // - this.ceilAngleControl.Angle = 0; + this.ceilAngleControl.Angle = 90; + this.ceilAngleControl.AngleOffset = 90; this.ceilAngleControl.Location = new System.Drawing.Point(186, 132); this.ceilAngleControl.Name = "ceilAngleControl"; this.ceilAngleControl.Size = new System.Drawing.Size(44, 44); @@ -867,8 +869,11 @@ this.floorslopecontrol.Size = new System.Drawing.Size(431, 178); this.floorslopecontrol.TabIndex = 0; this.floorslopecontrol.UseLineAngles = false; - this.floorslopecontrol.OnValuesChanged += new System.EventHandler(this.floorslopecontrol_OnValuesChanged); this.floorslopecontrol.OnUseLineAnglesChanged += new System.EventHandler(this.floorslopecontrol_OnUseLineAnglesChanged); + this.floorslopecontrol.OnResetClicked += new System.EventHandler(this.floorslopecontrol_OnResetClicked); + this.floorslopecontrol.OnAnglesChanged += new System.EventHandler(this.floorslopecontrol_OnAnglesChanged); + this.floorslopecontrol.OnOffsetChanged += new System.EventHandler(this.floorslopecontrol_OnOffsetChanged); + this.floorslopecontrol.OnPivotModeChanged += new System.EventHandler(this.floorslopecontrol_OnPivotModeChanged); // // groupBox4 // @@ -887,8 +892,11 @@ this.ceilingslopecontrol.Size = new System.Drawing.Size(431, 178); this.ceilingslopecontrol.TabIndex = 1; this.ceilingslopecontrol.UseLineAngles = false; - this.ceilingslopecontrol.OnValuesChanged += new System.EventHandler(this.ceilingslopecontrol_OnValuesChanged); this.ceilingslopecontrol.OnUseLineAnglesChanged += new System.EventHandler(this.ceilingslopecontrol_OnUseLineAnglesChanged); + this.ceilingslopecontrol.OnResetClicked += new System.EventHandler(this.ceilingslopecontrol_OnResetClicked); + this.ceilingslopecontrol.OnAnglesChanged += new System.EventHandler(this.ceilingslopecontrol_OnAnglesChanged); + this.ceilingslopecontrol.OnOffsetChanged += new System.EventHandler(this.ceilingslopecontrol_OnOffsetChanged); + this.ceilingslopecontrol.OnPivotModeChanged += new System.EventHandler(this.ceilingslopecontrol_OnPivotModeChanged); // // tabcustom // diff --git a/Source/Core/Windows/SectorEditFormUDMF.cs b/Source/Core/Windows/SectorEditFormUDMF.cs index f310ed82..412cacd5 100644 --- a/Source/Core/Windows/SectorEditFormUDMF.cs +++ b/Source/Core/Windows/SectorEditFormUDMF.cs @@ -88,6 +88,9 @@ namespace CodeImp.DoomBuilder.Windows public readonly float CeilingSlopeAngleZ; public readonly float CeilingSlopeOffset; + public float VirtualFloorSlopeOffset; + public float VirtualCeilingSlopeOffset; + public SectorProperties(Sector s) { Brightness = s.Brightness; FloorHeight = s.FloorHeight; @@ -121,22 +124,24 @@ namespace CodeImp.DoomBuilder.Windows //UDMF slopes if (s.FloorSlope.GetLengthSq() > 0) { - FloorSlopeAngleXY = (float)Math.Round(Angle2D.RadToDeg(s.FloorSlope.GetAngleXY()), 3); - FloorSlopeAngleZ = (float)Math.Round(Angle2D.RadToDeg(s.FloorSlope.GetAngleZ()), 3); + FloorSlopeAngleXY = (float)Math.Round(Angle2D.RadToDeg(s.FloorSlope.GetAngleXY()), 1); + FloorSlopeAngleZ = (float)Math.Round(Angle2D.RadToDeg(s.FloorSlope.GetAngleZ()), 1); } else { FloorSlopeAngleXY = 0; FloorSlopeAngleZ = 0; } - FloorSlopeOffset = s.FloorSlopeOffset; + FloorSlopeOffset = float.IsNaN(s.FloorSlopeOffset) ? -s.FloorHeight : s.FloorSlopeOffset; + VirtualFloorSlopeOffset = FloorSlopeOffset; if (s.CeilingSlope.GetLengthSq() > 0) { - CeilingSlopeAngleXY = (float)Math.Round(Angle2D.RadToDeg(s.CeilingSlope.GetAngleXY()), 3); - CeilingSlopeAngleZ = (float)Math.Round(Angle2D.RadToDeg(s.CeilingSlope.GetAngleZ()), 3); + CeilingSlopeAngleXY = (float)Math.Round(Angle2D.RadToDeg(s.CeilingSlope.GetAngleXY()), 1); + CeilingSlopeAngleZ = (float)Math.Round(Angle2D.RadToDeg(s.CeilingSlope.GetAngleZ()), 1); } else { CeilingSlopeAngleXY = 0; CeilingSlopeAngleZ = 0; } - CeilingSlopeOffset = s.CeilingSlopeOffset; + CeilingSlopeOffset = float.IsNaN(s.CeilingSlopeOffset) ? -s.CeilHeight : s.CeilingSlopeOffset; + VirtualCeilingSlopeOffset = CeilingSlopeOffset; } } @@ -169,6 +174,7 @@ namespace CodeImp.DoomBuilder.Windows } // Fill effects list + effect.GeneralizedOptions = General.Map.Config.GenEffectOptions; //mxd effect.AddInfo(General.Map.Config.SortedSectorEffects.ToArray()); // Initialize custom fields editor @@ -285,19 +291,7 @@ namespace CodeImp.DoomBuilder.Windows lightColor.SetValueFrom(sc.Fields); //Slopes - if (sc.CeilingSlope.GetLengthSq() > 0) { - ceilingslopecontrol.SetValues((float) Math.Round(Angle2D.RadToDeg(sc.CeilingSlope.GetAngleXY()), 3), - (float) -Math.Round(Angle2D.RadToDeg(sc.CeilingSlope.GetAngleZ()) + 90, 3), -sc.CeilingSlopeOffset, true); - } else { - ceilingslopecontrol.SetValues(0f, 0f, -sc.CeilingSlopeOffset, true); - } - - if (sc.FloorSlope.GetLengthSq() > 0) { - floorslopecontrol.SetValues((float) Math.Round(Angle2D.RadToDeg(sc.FloorSlope.GetAngleXY()), 3), - (float) Math.Round(Angle2D.RadToDeg(sc.FloorSlope.GetAngleZ()) + 90, 3), -sc.FloorSlopeOffset, true); - } else { - floorslopecontrol.SetValues(0f, 0f, -sc.FloorSlopeOffset, true); - } + SetupSlopes(sc, true); // Action tagSelector.Setup(UniversalType.SectorTag); //mxd @@ -401,8 +395,7 @@ namespace CodeImp.DoomBuilder.Windows lightColor.SetValueFrom(s.Fields); //Slopes - ceilingslopecontrol.SetValues(sp.CeilingSlopeAngleXY, -(sp.CeilingSlopeAngleZ + 90), sp.CeilingSlopeOffset, false); - floorslopecontrol.SetValues(sp.FloorSlopeAngleXY, sp.FloorSlopeAngleZ + 90, -sp.FloorSlopeOffset, false); + SetupSlopes(s, false); // Action if(s.Tag != sc.Tag) tagSelector.ClearTag(); //mxd @@ -621,7 +614,7 @@ namespace CodeImp.DoomBuilder.Windows #endregion - #region mxd. Sector Realtime events + #region ================== Sector Realtime events (mxd) private void ceilingheight_WhenTextChanged(object sender, EventArgs e) { if(blockupdate) return; @@ -796,7 +789,7 @@ namespace CodeImp.DoomBuilder.Windows #endregion - #region mxd. Ceiling/Floor realtime events + #region ================== Ceiling/Floor realtime events (mxd) private void ceilOffsets_OnValuesChanged(object sender, EventArgs e) { if(blockupdate) return; @@ -968,14 +961,119 @@ namespace CodeImp.DoomBuilder.Windows #endregion - #region mxd. Slopes realtime events + #region ================== Slope Utility (mxd) - private void ceilingslopecontrol_OnValuesChanged(object sender, EventArgs e) + 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); + if (anglexy == 180.0f) { + anglexy = 0; + anglez = -anglez; + } + ceilingslopecontrol.SetValues(anglexy, anglez, (float)Math.Round(-s.CeilingSlopeOffset, 1), 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 anglez = (float)(Math.Round(Angle2D.RadToDeg(s.FloorSlope.GetAngleZ()) - 90, 1)); + if (anglexy == 180.0f) { + anglexy = 0; + anglez = -anglez; + } + floorslopecontrol.SetValues(anglexy, anglez, (float)Math.Round(-s.FloorSlopeOffset, 1), 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) { + case SlopePivotMode.GLOBAL: //rotate around the center of selection + //TODO: translate offset from virtual to real + + return validoffset; + + case SlopePivotMode.LOCAL: //rotate around sector's bounding box center + //TODO: translate offset from virtual to real + //Vector3D pivot = floor + + return validoffset; + + case SlopePivotMode.ORIGIN: //rotate around world origin (0, 0) + return validoffset; + + default: + throw new NotImplementedException("SectorEditFormUDMF.SetSlopeOffset: Got unknown SlopePivotMode (" + (int)mode + ")"); + } + } + + #endregion + + #region ================== Slopes realtime events (mxd) + + private void ceilingslopecontrol_OnAnglesChanged(object sender, EventArgs e) { if(blockupdate) return; - float anglexy, anglez; - int i = 0; //Set or restore values foreach(Sector s in sectors) @@ -988,77 +1086,104 @@ namespace CodeImp.DoomBuilder.Windows } else { s.CeilingSlopeOffset = s.CeilHeight; }*/ - - s.CeilingSlope = Vector3D.FromAngleXYZ(Angle2D.DegToRad(anglexy) + Angle2D.PI, Angle2D.DegToRad(-anglez)); - s.CeilingSlopeOffset = SetSlopeOffset(s, -ceilingslopecontrol.Offset, ceilingslopecontrol.PivotMode, false); + if (anglexy == 0 && anglez == 90) { + s.CeilingSlope = new Vector3D(); + } else { + s.CeilingSlope = Vector3D.FromAngleXYZ(Angle2D.DegToRad(anglexy) + Angle2D.PI, Angle2D.DegToRad(-anglez)); + } + s.CeilingSlopeOffset = GetSlopeOffset(s, ceilingslopecontrol.Offset, ceilingslopecontrol.PivotMode, false); s.UpdateNeeded = true; - i++; } General.Map.IsChanged = true; if(OnValuesChanged != null) OnValuesChanged(this, EventArgs.Empty); } - private void floorslopecontrol_OnValuesChanged(object sender, EventArgs e) + private void floorslopecontrol_OnAnglesChanged(object sender, EventArgs e) { if(blockupdate) return; - float anglexy, anglez; - int i = 0; //Set or restore values foreach(Sector s in sectors) { anglexy = (float.IsNaN(floorslopecontrol.AngleXY) ? sectorprops[s].FloorSlopeAngleXY : floorslopecontrol.AngleXY); anglez = (float.IsNaN(floorslopecontrol.AngleZ) ? sectorprops[s].FloorSlopeAngleZ : floorslopecontrol.AngleZ + 90); - s.FloorSlope = Vector3D.FromAngleXYZ(Angle2D.DegToRad(anglexy) + Angle2D.PI, Angle2D.DegToRad(anglez)); - s.FloorSlopeOffset = SetSlopeOffset(s, -floorslopecontrol.Offset, floorslopecontrol.PivotMode, true); + if(anglexy == 0 && anglez == 90) { + s.FloorSlope = new Vector3D(); + } else { + s.FloorSlope = Vector3D.FromAngleXYZ(Angle2D.DegToRad(anglexy) + Angle2D.PI, Angle2D.DegToRad(anglez)); + } + s.FloorSlopeOffset = GetSlopeOffset(s, -floorslopecontrol.Offset, floorslopecontrol.PivotMode, true); s.UpdateNeeded = true; - i++; } General.Map.IsChanged = true; if(OnValuesChanged != null) OnValuesChanged(this, EventArgs.Empty); } - private float SetSlopeOffset(Sector target, float offset, SlopePivotMode mode, bool floor) + private void ceilingslopecontrol_OnPivotModeChanged(object sender, EventArgs e) { - float validoffset; - 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 - validoffset = (floor ? target.FloorHeight : target.CeilHeight); - } - else - { - //restore initial value - validoffset = storedoffset; - } - } - else - { - //use current value - validoffset = offset; + //TODO: update offsets to match current PivotMode + + + //TODO: update Offset value + + + } + + private void floorslopecontrol_OnPivotModeChanged(object sender, EventArgs e) + { + //TODO: update offsets to match current PivotMode + + + //TODO: update Offset value + + + } + + private void ceilingslopecontrol_OnOffsetChanged(object sender, EventArgs e) + { + if(blockupdate) return; + foreach(Sector s in sectors) { + s.CeilingSlopeOffset = GetSlopeOffset(s, ceilingslopecontrol.Offset, ceilingslopecontrol.PivotMode, false); + s.UpdateNeeded = true; } - - switch(mode) { - case SlopePivotMode.GLOBAL: //rotate around the center of selection - //TODO: implement! - return validoffset; + General.Map.IsChanged = true; + if(OnValuesChanged != null) OnValuesChanged(this, EventArgs.Empty); + } - case SlopePivotMode.LOCAL: //rotate around sector's bounding box center - //TODO: implement! - return validoffset; - - case SlopePivotMode.ORIGIN: //rotate around world origin (0, 0) - return validoffset; - - default: - throw new NotImplementedException("SectorEditFormUDMF.SetSlopeOffset: Got unknown SlopePivotMode (" + (int)mode + ")"); + private void floorslopecontrol_OnOffsetChanged(object sender, EventArgs e) + { + if(blockupdate) return; + foreach(Sector s in sectors) { + 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) + { + foreach(Sector s in sectors) { + s.CeilingSlope = new Vector3D(); + s.CeilingSlopeOffset = float.NaN; + s.UpdateNeeded = true; + } + General.Map.IsChanged = true; + if(OnValuesChanged != null) OnValuesChanged(this, EventArgs.Empty); + } + + private void floorslopecontrol_OnResetClicked(object sender, EventArgs e) + { + foreach(Sector s in sectors) { + s.FloorSlope = new Vector3D(); + s.FloorSlopeOffset = float.NaN; + s.UpdateNeeded = true; + } + General.Map.IsChanged = true; + if(OnValuesChanged != null) OnValuesChanged(this, EventArgs.Empty); } private void ceilingslopecontrol_OnUseLineAnglesChanged(object sender, EventArgs e) diff --git a/Source/Core/Windows/SectorEditFormUDMF.resx b/Source/Core/Windows/SectorEditFormUDMF.resx index 90add833..53aec627 100644 --- a/Source/Core/Windows/SectorEditFormUDMF.resx +++ b/Source/Core/Windows/SectorEditFormUDMF.resx @@ -138,21 +138,6 @@ False - - False - - - False - - - False - - - False - - - False - False @@ -162,12 +147,6 @@ False - - False - - - False - True @@ -177,7 +156,4 @@ True - - True - \ No newline at end of file diff --git a/Source/Plugins/BuilderModes/ClassicModes/SectorsMode.cs b/Source/Plugins/BuilderModes/ClassicModes/SectorsMode.cs index 8be424b6..9b4b866c 100644 --- a/Source/Plugins/BuilderModes/ClassicModes/SectorsMode.cs +++ b/Source/Plugins/BuilderModes/ClassicModes/SectorsMode.cs @@ -247,11 +247,12 @@ namespace CodeImp.DoomBuilder.BuilderModes result[1] = "E" + s.Effect; } } else { + string effect = s.Effect + " - " + General.Map.Config.GetGeneralizedSectorEffectName(s.Effect); if(s.Tag != 0) { - result[0] = "Tag " + s.Tag + ", Effect " + s.Effect; + result[0] = "Tag " + s.Tag + ", Effect " + effect; result[1] = "T" + s.Tag + " " + "E" + s.Effect; } else { - result[0] = "Effect " + s.Effect; + result[0] = "Effect " + effect; result[1] = "E" + s.Effect; } }