Proper labels are now displayed for generalized sector effects.

Internal, Edit Sectors form: more changes to "Slopes" tab logic. It's still incomplete...
This commit is contained in:
MaxED 2014-09-04 12:34:26 +00:00
parent daf8c44327
commit f596b88376
11 changed files with 300 additions and 137 deletions

View file

@ -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

View file

@ -876,6 +876,43 @@ namespace CodeImp.DoomBuilder.Config
// Not generalized
return null;
}
//mxd
public static bool IsGeneralizedSectorEffect(int effect, IEnumerable<GeneralizedOption> 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
{

View file

@ -33,6 +33,7 @@ namespace CodeImp.DoomBuilder.Controls
// Variables
private List<GeneralizedCategory> generalizedcategories;
private List<GeneralizedOption> 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<GeneralizedCategory> GeneralizedCategories { get { return generalizedcategories; } set { generalizedcategories = value; } }
public List<GeneralizedOption> 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";
}

View file

@ -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

View file

@ -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) {

View file

@ -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

View file

@ -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

View file

@ -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
//

View file

@ -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)

View file

@ -138,21 +138,6 @@
<metadata name="label8.GenerateMember" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>False</value>
</metadata>
<metadata name="label14.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>
<metadata name="label13.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">
<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="groupfloorceiling.GenerateMember" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>False</value>
</metadata>
@ -162,12 +147,6 @@
<metadata name="label5.GenerateMember" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>False</value>
</metadata>
<metadata name="label6.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">
<value>False</value>
</metadata>
<metadata name="tabproperties.Locked" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
@ -177,7 +156,4 @@
<metadata name="fieldslist.Locked" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="fieldslist.Locked" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
</root>

View file

@ -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;
}
}