2014-10-17 11:55:08 +00:00
#region = = = = = = = = = = = = = = = = = = Namespaces
using System ;
2013-06-25 12:35:13 +00:00
using System.Collections.Generic ;
2013-11-21 10:53:11 +00:00
using System.Drawing ;
2013-06-25 12:35:13 +00:00
using System.Windows.Forms ;
2014-10-17 11:55:08 +00:00
using CodeImp.DoomBuilder.Controls ;
using CodeImp.DoomBuilder.Geometry ;
2013-11-21 10:53:11 +00:00
using CodeImp.DoomBuilder.GZBuilder.Tools ;
2013-06-25 12:35:13 +00:00
using CodeImp.DoomBuilder.Map ;
using CodeImp.DoomBuilder.Types ;
2014-10-17 11:55:08 +00:00
#endregion
2013-06-25 12:35:13 +00:00
namespace CodeImp.DoomBuilder.Windows
{
2013-07-10 08:59:17 +00:00
internal partial class SectorEditFormUDMF : DelayedForm
2013-06-25 12:35:13 +00:00
{
2013-07-09 13:13:00 +00:00
#region = = = = = = = = = = = = = = = = = = Events
public event EventHandler OnValuesChanged ; //mxd
#endregion
#region = = = = = = = = = = = = = = = = = = Variables
2013-06-25 12:35:13 +00:00
private ICollection < Sector > sectors ;
2014-08-25 11:15:19 +00:00
private Dictionary < Sector , SectorProperties > sectorprops ; //mxd
private bool blockupdate ; //mxd
private StepsList anglesteps ; //mxd
2014-12-04 10:06:44 +00:00
private readonly string [ ] renderstyles ; //mxd
2013-07-19 15:30:58 +00:00
2013-11-21 10:53:11 +00:00
//mxd. Persistent settings
2013-07-19 15:30:58 +00:00
private static bool linkCeilingScale ;
private static bool linkFloorScale ;
2013-08-12 10:15:08 +00:00
private static bool useFloorLineAngles ;
private static bool useCeilLineAngles ;
2014-08-25 11:15:19 +00:00
private static bool useFloorSlopeLineAngles ;
private static bool useCeilSlopeLineAngles ;
2014-10-17 11:55:08 +00:00
private static SlopePivotMode ceilpivotmode = SlopePivotMode . LOCAL ;
private static SlopePivotMode floorpivotmode = SlopePivotMode . LOCAL ;
2013-07-19 15:30:58 +00:00
2013-11-21 10:53:11 +00:00
//mxd. Window setup stuff
private static Point location = Point . Empty ;
2014-08-25 11:15:19 +00:00
private static int activetab ;
2014-08-05 08:22:49 +00:00
//mxd. Slope pivots
2014-10-17 11:55:08 +00:00
private Vector2D globalslopepivot ;
private Dictionary < Sector , Vector2D > slopepivots ;
2014-08-25 11:15:19 +00:00
#endregion
#region = = = = = = = = = = = = = = = = = = Structs
2014-08-05 08:22:49 +00:00
2013-07-19 15:30:58 +00:00
private struct SectorProperties //mxd
{
2014-05-05 14:24:57 +00:00
public readonly int Brightness ;
public readonly int FloorHeight ;
public readonly int CeilHeight ;
public readonly string FloorTexture ;
public readonly string CeilTexture ;
2013-07-19 15:30:58 +00:00
//UDMF stuff
2014-05-05 14:24:57 +00:00
public readonly int LightColor ;
public readonly int FadeColor ;
2013-07-19 15:30:58 +00:00
//public float Desaturation;
//UDMF Ceiling
2014-05-05 14:24:57 +00:00
public readonly float CeilOffsetX ;
public readonly float CeilOffsetY ;
public readonly float CeilScaleX ;
public readonly float CeilScaleY ;
2013-07-19 15:30:58 +00:00
//public float CeilAlpha;
2014-05-05 14:24:57 +00:00
public readonly float CeilRotation ;
public readonly int CeilBrightness ;
public readonly bool CeilLightAbsoulte ;
2013-07-19 15:30:58 +00:00
//UDMF Floor
2014-05-05 14:24:57 +00:00
public readonly float FloorOffsetX ;
public readonly float FloorOffsetY ;
public readonly float FloorScaleX ;
public readonly float FloorScaleY ;
2013-07-19 15:30:58 +00:00
//public float FloorAlpha;
2014-05-05 14:24:57 +00:00
public readonly float FloorRotation ;
public readonly int FloorBrightness ;
public readonly bool FloorLightAbsoulte ;
2013-07-19 15:30:58 +00:00
2014-08-25 11:15:19 +00:00
//UDMF slopes. Angles are in degrees
2014-10-17 11:55:08 +00:00
public readonly Vector3D FloorSlope ;
public readonly Vector3D CeilSlope ;
2014-08-25 11:15:19 +00:00
public readonly float FloorSlopeAngleXY ;
public readonly float FloorSlopeAngleZ ;
2014-08-05 08:22:49 +00:00
public readonly float FloorSlopeOffset ;
2014-10-17 11:55:08 +00:00
public readonly float CeilSlopeAngleXY ;
public readonly float CeilSlopeAngleZ ;
public readonly float CeilSlopeOffset ;
2014-08-05 08:22:49 +00:00
2014-10-17 11:55:08 +00:00
public SectorProperties ( Sector s )
{
2013-07-19 15:30:58 +00:00
Brightness = s . Brightness ;
FloorHeight = s . FloorHeight ;
CeilHeight = s . CeilHeight ;
FloorTexture = s . FloorTexture ;
CeilTexture = s . CeilTexture ;
//UDMF stuff
LightColor = UDMFTools . GetInteger ( s . Fields , "lightcolor" , 16777215 ) ;
FadeColor = UDMFTools . GetInteger ( s . Fields , "fadecolor" , 0 ) ;
//UDMF Ceiling
CeilOffsetX = UDMFTools . GetFloat ( s . Fields , "xpanningceiling" , 0f ) ;
CeilOffsetY = UDMFTools . GetFloat ( s . Fields , "ypanningceiling" , 0f ) ;
CeilScaleX = UDMFTools . GetFloat ( s . Fields , "xscaleceiling" , 1.0f ) ;
CeilScaleY = UDMFTools . GetFloat ( s . Fields , "yscaleceiling" , 1.0f ) ;
//CeilAlpha = UDMFTools.GetFloat(s.Fields, "alphaceiling", 1.0f);
CeilRotation = s . Fields . GetValue ( "rotationceiling" , 0.0f ) ;
CeilBrightness = s . Fields . GetValue ( "lightceiling" , 0 ) ;
CeilLightAbsoulte = s . Fields . GetValue ( "lightceilingabsolute" , false ) ;
//UDMF Floor
FloorOffsetX = UDMFTools . GetFloat ( s . Fields , "xpanningfloor" , 0f ) ;
FloorOffsetY = UDMFTools . GetFloat ( s . Fields , "ypanningfloor" , 0f ) ;
FloorScaleX = UDMFTools . GetFloat ( s . Fields , "xscalefloor" , 1.0f ) ;
FloorScaleY = UDMFTools . GetFloat ( s . Fields , "yscalefloor" , 1.0f ) ;
//FloorAlpha = UDMFTools.GetFloat(s.Fields, "alphafloor", 1.0f);
FloorRotation = s . Fields . GetValue ( "rotationfloor" , 0.0f ) ;
FloorBrightness = s . Fields . GetValue ( "lightfloor" , 0 ) ;
FloorLightAbsoulte = s . Fields . GetValue ( "lightfloorabsolute" , false ) ;
2014-08-05 08:22:49 +00:00
2014-08-25 11:15:19 +00:00
//UDMF slopes
2014-10-17 11:55:08 +00:00
if ( s . FloorSlope . GetLengthSq ( ) > 0 )
{
FloorSlopeAngleXY = General . ClampAngle ( ( float ) Math . Round ( Angle2D . RadToDeg ( s . FloorSlope . GetAngleXY ( ) ) - 180 , 1 ) ) ;
FloorSlopeAngleZ = - ( float ) Math . Round ( Angle2D . RadToDeg ( s . FloorSlope . GetAngleZ ( ) ) - 90 , 1 ) ;
FloorSlopeOffset = ( float . IsNaN ( s . FloorSlopeOffset ) ? s . FloorHeight : s . FloorSlopeOffset ) ;
}
else
{
2014-08-25 11:15:19 +00:00
FloorSlopeAngleXY = 0 ;
FloorSlopeAngleZ = 0 ;
2014-10-17 11:55:08 +00:00
FloorSlopeOffset = - s . FloorHeight ;
2014-08-25 11:15:19 +00:00
}
2014-10-17 11:55:08 +00:00
FloorSlope = s . FloorSlope ;
if ( s . CeilSlope . GetLengthSq ( ) > 0 )
{
CeilSlopeAngleXY = General . ClampAngle ( ( float ) Math . Round ( Angle2D . RadToDeg ( s . CeilSlope . GetAngleXY ( ) ) - 180 , 1 ) ) ;
CeilSlopeAngleZ = - ( float ) Math . Round ( 270 - Angle2D . RadToDeg ( s . CeilSlope . GetAngleZ ( ) ) , 1 ) ;
CeilSlopeOffset = ( float . IsNaN ( s . CeilSlopeOffset ) ? s . CeilHeight : s . CeilSlopeOffset ) ;
}
else
{
CeilSlopeAngleXY = 0 ;
CeilSlopeAngleZ = 0 ;
CeilSlopeOffset = s . CeilHeight ;
2014-08-25 11:15:19 +00:00
}
2014-10-17 11:55:08 +00:00
CeilSlope = s . CeilSlope ;
2013-07-19 15:30:58 +00:00
}
}
2013-07-09 13:13:00 +00:00
#endregion
#region = = = = = = = = = = = = = = = = = = Constructor
2014-10-17 11:55:08 +00:00
public SectorEditFormUDMF ( )
{
2013-06-25 12:35:13 +00:00
InitializeComponent ( ) ;
2013-11-21 10:53:11 +00:00
//mxd. Widow setup
2014-10-17 11:55:08 +00:00
if ( location ! = Point . Empty )
{
2013-11-21 10:53:11 +00:00
this . StartPosition = FormStartPosition . Manual ;
this . Location = location ;
2014-08-25 11:15:19 +00:00
if ( activetab > 0 ) tabs . SelectTab ( activetab ) ;
2013-11-21 10:53:11 +00:00
}
2013-07-10 08:59:17 +00:00
// Fill flags list
foreach ( KeyValuePair < string , string > lf in General . Map . Config . SectorFlags )
flags . Add ( lf . Value , lf . Key ) ;
2014-12-04 10:06:44 +00:00
flags . Enabled = General . Map . Config . SectorFlags . Count > 0 ;
2013-07-10 08:59:17 +00:00
2014-12-04 10:06:44 +00:00
// Setup renderstyles
renderstyles = new string [ General . Map . Config . SectorRenderStyles . Count ] ;
General . Map . Config . SectorRenderStyles . Keys . CopyTo ( renderstyles , 0 ) ;
floorRenderStyle . Enabled = ( General . Map . Config . SectorRenderStyles . Count > 0 ) ;
labelfloorrenderstyle . Enabled = ( General . Map . Config . SectorRenderStyles . Count > 0 ) ;
ceilRenderStyle . Enabled = ( General . Map . Config . SectorRenderStyles . Count > 0 ) ;
labelceilrenderstyle . Enabled = ( General . Map . Config . SectorRenderStyles . Count > 0 ) ;
// Fill renderstyles
2014-10-17 11:55:08 +00:00
foreach ( KeyValuePair < string , string > lf in General . Map . Config . SectorRenderStyles )
{
2014-05-05 14:24:57 +00:00
floorRenderStyle . Items . Add ( lf . Value ) ;
ceilRenderStyle . Items . Add ( lf . Value ) ;
}
2013-06-25 12:35:13 +00:00
// Fill effects list
2014-09-04 12:34:26 +00:00
effect . GeneralizedOptions = General . Map . Config . GenEffectOptions ; //mxd
2013-06-25 12:35:13 +00:00
effect . AddInfo ( General . Map . Config . SortedSectorEffects . ToArray ( ) ) ;
2013-08-08 11:04:13 +00:00
// Initialize custom fields editor
fieldslist . Setup ( "sector" ) ;
2013-06-25 12:35:13 +00:00
// Fill universal fields list
fieldslist . ListFixedFields ( General . Map . Config . SectorFields ) ;
// Initialize image selectors
floortex . Initialize ( ) ;
ceilingtex . Initialize ( ) ;
// Set steps for brightness field
brightness . StepValues = General . Map . Config . BrightnessLevels ;
2013-07-19 15:30:58 +00:00
// Value linking
ceilScale . LinkValues = linkCeilingScale ;
floorScale . LinkValues = linkFloorScale ;
2013-08-12 10:15:08 +00:00
cbUseCeilLineAngles . Checked = useCeilLineAngles ;
cbUseFloorLineAngles . Checked = useFloorLineAngles ;
2014-08-05 08:22:49 +00:00
2014-08-25 11:15:19 +00:00
floorslopecontrol . UseLineAngles = useFloorSlopeLineAngles ;
ceilingslopecontrol . UseLineAngles = useCeilSlopeLineAngles ;
2014-10-17 11:55:08 +00:00
floorslopecontrol . PivotMode = floorpivotmode ;
ceilingslopecontrol . PivotMode = ceilpivotmode ;
2013-06-25 12:35:13 +00:00
}
2013-07-09 13:13:00 +00:00
#endregion
#region = = = = = = = = = = = = = = = = = = Methods
2013-06-25 12:35:13 +00:00
// This sets up the form to edit the given sectors
2014-10-17 11:55:08 +00:00
public void Setup ( ICollection < Sector > sectors )
{
2014-08-25 11:15:19 +00:00
blockupdate = true ; //mxd
2013-06-25 12:35:13 +00:00
// Keep this list
this . sectors = sectors ;
if ( sectors . Count > 1 ) this . Text = "Edit Sectors (" + sectors . Count + ")" ;
2014-08-25 11:15:19 +00:00
sectorprops = new Dictionary < Sector , SectorProperties > ( sectors . Count ) ; //mxd
2013-07-19 15:30:58 +00:00
//mxd. Make undo
string undodesc = "sector" ;
if ( sectors . Count > 1 ) undodesc = sectors . Count + " sectors" ;
General . Map . UndoRedo . CreateUndo ( "Edit " + undodesc ) ;
2013-06-25 12:35:13 +00:00
2014-09-13 21:57:56 +00:00
//mxd. Set default height offset
heightoffset . Text = "0" ;
2014-10-17 11:55:08 +00:00
CreateHelperProps ( sectors ) ; //mxd
2013-06-25 12:35:13 +00:00
////////////////////////////////////////////////////////////////////////
// Set all options to the first sector properties
////////////////////////////////////////////////////////////////////////
// Get first sector
2013-07-19 15:30:58 +00:00
Sector sc = General . GetByIndex ( sectors , 0 ) ;
2013-06-25 12:35:13 +00:00
2013-07-10 08:59:17 +00:00
// Flags
foreach ( CheckBox c in flags . Checkboxes )
if ( sc . Flags . ContainsKey ( c . Tag . ToString ( ) ) ) c . Checked = sc . Flags [ c . Tag . ToString ( ) ] ;
2013-06-25 12:35:13 +00:00
// Effects
effect . Value = sc . Effect ;
brightness . Text = sc . Brightness . ToString ( ) ;
// Floor/ceiling
floorheight . Text = sc . FloorHeight . ToString ( ) ;
ceilingheight . Text = sc . CeilHeight . ToString ( ) ;
floortex . TextureName = sc . FloorTexture ;
ceilingtex . TextureName = sc . CeilTexture ;
//UDMF stuff
//Texture offsets
2013-07-19 15:30:58 +00:00
ceilOffsets . SetValuesFrom ( sc . Fields , true ) ;
floorOffsets . SetValuesFrom ( sc . Fields , true ) ;
2013-06-25 12:35:13 +00:00
//Texture scale
2013-07-19 15:30:58 +00:00
ceilScale . SetValuesFrom ( sc . Fields , true ) ;
floorScale . SetValuesFrom ( sc . Fields , true ) ;
2013-06-25 12:35:13 +00:00
//Texture rotation
float ceilAngle = sc . Fields . GetValue ( "rotationceiling" , 0.0f ) ;
float floorAngle = sc . Fields . GetValue ( "rotationfloor" , 0.0f ) ;
ceilRotation . Text = ceilAngle . ToString ( ) ;
floorRotation . Text = floorAngle . ToString ( ) ;
ceilAngleControl . Angle = General . ClampAngle ( 360 - ( int ) ceilAngle ) ;
floorAngleControl . Angle = General . ClampAngle ( 360 - ( int ) floorAngle ) ;
//Texture brightness
ceilBrightness . Text = sc . Fields . GetValue ( "lightceiling" , 0 ) . ToString ( ) ;
floorBrightness . Text = sc . Fields . GetValue ( "lightfloor" , 0 ) . ToString ( ) ;
2013-07-19 15:30:58 +00:00
ceilLightAbsolute . Checked = sc . Fields . GetValue ( "lightceilingabsolute" , false ) ;
floorLightAbsolute . Checked = sc . Fields . GetValue ( "lightfloorabsolute" , false ) ;
2013-06-25 12:35:13 +00:00
//Alpha
ceilAlpha . Text = General . Clamp ( sc . Fields . GetValue ( "alphaceiling" , 1.0f ) , 0f , 1f ) . ToString ( ) ;
floorAlpha . Text = General . Clamp ( sc . Fields . GetValue ( "alphafloor" , 1.0f ) , 0f , 1f ) . ToString ( ) ;
//Render style
2014-12-04 10:06:44 +00:00
ceilRenderStyle . SelectedIndex = Array . IndexOf ( renderstyles , sc . Fields . GetValue ( "renderstyleceiling" , "translucent" ) ) ;
floorRenderStyle . SelectedIndex = Array . IndexOf ( renderstyles , sc . Fields . GetValue ( "renderstylefloor" , "translucent" ) ) ;
2013-06-25 12:35:13 +00:00
//Misc
soundSequence . Text = sc . Fields . GetValue ( "soundsequence" , string . Empty ) ;
gravity . Text = sc . Fields . GetValue ( "gravity" , 1.0f ) . ToString ( ) ;
desaturation . Text = General . Clamp ( sc . Fields . GetValue ( "desaturation" , 0.0f ) , 0f , 1f ) . ToString ( ) ;
//Sector colors
fadeColor . SetValueFrom ( sc . Fields ) ;
lightColor . SetValueFrom ( sc . Fields ) ;
2014-08-05 08:22:49 +00:00
//Slopes
2014-10-17 11:55:08 +00:00
SetupFloorSlope ( sc , true ) ;
SetupCeilingSlope ( sc , true ) ;
2014-08-05 08:22:49 +00:00
2013-06-25 12:35:13 +00:00
// Action
2013-08-28 08:29:06 +00:00
tagSelector . Setup ( UniversalType . SectorTag ) ; //mxd
2013-06-25 12:35:13 +00:00
tagSelector . SetTag ( sc . Tag ) ; //mxd
// Custom fields
fieldslist . SetValues ( sc . Fields , true ) ;
2014-08-25 11:15:19 +00:00
anglesteps = new StepsList ( ) ;
2013-08-12 10:15:08 +00:00
2013-06-25 12:35:13 +00:00
////////////////////////////////////////////////////////////////////////
// Now go for all sectors and change the options when a setting is different
////////////////////////////////////////////////////////////////////////
// Go for all sectors
2014-10-17 11:55:08 +00:00
foreach ( Sector s in sectors )
{
2013-07-10 08:59:17 +00:00
// Flags
2014-10-17 11:55:08 +00:00
foreach ( CheckBox c in flags . Checkboxes )
{
2014-08-05 08:22:49 +00:00
if ( c . CheckState = = CheckState . Indeterminate ) continue ; //mxd
2014-10-17 11:55:08 +00:00
if ( s . IsFlagSet ( c . Tag . ToString ( ) ) ! = c . Checked )
{
2014-08-05 08:22:49 +00:00
c . ThreeState = true ;
c . CheckState = CheckState . Indeterminate ;
2013-07-10 08:59:17 +00:00
}
}
2013-06-25 12:35:13 +00:00
// Effects
if ( s . Effect ! = effect . Value ) effect . Empty = true ;
if ( s . Brightness . ToString ( ) ! = brightness . Text ) brightness . Text = "" ;
// Floor/Ceiling
if ( s . FloorHeight . ToString ( ) ! = floorheight . Text ) floorheight . Text = "" ;
if ( s . CeilHeight . ToString ( ) ! = ceilingheight . Text ) ceilingheight . Text = "" ;
2014-10-17 11:55:08 +00:00
if ( s . FloorTexture ! = floortex . TextureName )
{
2014-03-05 09:21:28 +00:00
floortex . MultipleTextures = true ; //mxd
floortex . TextureName = "" ;
}
2014-10-17 11:55:08 +00:00
if ( s . CeilTexture ! = ceilingtex . TextureName )
{
2014-03-05 09:21:28 +00:00
ceilingtex . MultipleTextures = true ; //mxd
ceilingtex . TextureName = "" ;
}
2013-06-25 12:35:13 +00:00
//mxd. UDMF stuff
//Texture offsets
2013-07-19 15:30:58 +00:00
ceilOffsets . SetValuesFrom ( s . Fields , false ) ;
floorOffsets . SetValuesFrom ( s . Fields , false ) ;
2013-06-25 12:35:13 +00:00
//Texture scale
2013-07-19 15:30:58 +00:00
ceilScale . SetValuesFrom ( s . Fields , false ) ;
floorScale . SetValuesFrom ( s . Fields , false ) ;
2013-06-25 12:35:13 +00:00
//Texture rotation
2014-10-17 11:55:08 +00:00
if ( s . Fields . GetValue ( "rotationceiling" , 0.0f ) . ToString ( ) ! = ceilRotation . Text )
{
2013-06-25 12:35:13 +00:00
ceilRotation . Text = "" ;
2014-10-17 11:55:08 +00:00
ceilAngleControl . Angle = GZBuilder . Controls . AngleControl . NO_ANGLE ;
2013-06-25 12:35:13 +00:00
}
2014-10-17 11:55:08 +00:00
if ( s . Fields . GetValue ( "rotationfloor" , 0.0f ) . ToString ( ) ! = floorRotation . Text )
{
2013-06-25 12:35:13 +00:00
floorRotation . Text = "" ;
2014-10-17 11:55:08 +00:00
floorAngleControl . Angle = GZBuilder . Controls . AngleControl . NO_ANGLE ;
2013-06-25 12:35:13 +00:00
}
//Texture brightness
if ( s . Fields . GetValue ( "lightceiling" , 0 ) . ToString ( ) ! = ceilBrightness . Text ) ceilBrightness . Text = "" ;
2013-08-08 11:04:13 +00:00
if ( s . Fields . GetValue ( "lightfloor" , 0 ) . ToString ( ) ! = floorBrightness . Text ) floorBrightness . Text = "" ;
2013-07-19 15:30:58 +00:00
2014-10-17 11:55:08 +00:00
if ( s . Fields . GetValue ( "lightceilingabsolute" , false ) ! = ceilLightAbsolute . Checked )
{
2013-07-19 15:30:58 +00:00
ceilLightAbsolute . ThreeState = true ;
ceilLightAbsolute . CheckState = CheckState . Indeterminate ;
}
2014-10-17 11:55:08 +00:00
if ( s . Fields . GetValue ( "lightfloorabsolute" , false ) ! = floorLightAbsolute . Checked )
{
2013-07-19 15:30:58 +00:00
floorLightAbsolute . ThreeState = true ;
floorLightAbsolute . CheckState = CheckState . Indeterminate ;
}
2013-06-25 12:35:13 +00:00
//Alpha
if ( s . Fields . GetValue ( "alphaceiling" , 1.0f ) . ToString ( ) ! = ceilAlpha . Text ) ceilAlpha . Text = "" ;
if ( s . Fields . GetValue ( "alphafloor" , 1.0f ) . ToString ( ) ! = floorAlpha . Text ) floorAlpha . Text = "" ;
//Render style
2014-12-04 10:06:44 +00:00
if ( ceilRenderStyle . SelectedIndex > - 1 & & ceilRenderStyle . SelectedIndex ! = Array . IndexOf ( renderstyles , s . Fields . GetValue ( "renderstyleceiling" , "translucent" ) ) )
ceilRenderStyle . SelectedIndex = - 1 ;
if ( floorRenderStyle . SelectedIndex > - 1 & & floorRenderStyle . SelectedIndex ! = Array . IndexOf ( renderstyles , s . Fields . GetValue ( "renderstylefloor" , "translucent" ) ) )
floorRenderStyle . SelectedIndex = - 1 ;
2013-06-25 12:35:13 +00:00
//Misc
if ( s . Fields . GetValue ( "soundsequence" , string . Empty ) ! = soundSequence . Text ) soundSequence . Text = "" ;
if ( s . Fields . GetValue ( "gravity" , 1.0f ) . ToString ( ) ! = gravity . Text ) gravity . Text = "" ;
if ( s . Fields . GetValue ( "desaturation" , 0.0f ) . ToString ( ) ! = desaturation . Text ) desaturation . Text = "" ;
//Sector colors
fadeColor . SetValueFrom ( s . Fields ) ;
lightColor . SetValueFrom ( s . Fields ) ;
2014-08-05 08:22:49 +00:00
//Slopes
2014-10-17 11:55:08 +00:00
SetupFloorSlope ( s , false ) ;
SetupCeilingSlope ( s , false ) ;
2014-08-05 08:22:49 +00:00
2013-06-25 12:35:13 +00:00
// Action
if ( s . Tag ! = sc . Tag ) tagSelector . ClearTag ( ) ; //mxd
// Custom fields
2013-07-19 15:30:58 +00:00
s . Fields . BeforeFieldsChange ( ) ; //mxd
2013-06-25 12:35:13 +00:00
fieldslist . SetValues ( s . Fields , false ) ;
2013-07-19 15:30:58 +00:00
2013-08-12 10:15:08 +00:00
//mxd. Angle steps
int angle ;
2014-10-17 11:55:08 +00:00
foreach ( Sidedef side in s . Sidedefs )
{
2013-08-12 10:15:08 +00:00
if ( side . Line . Front ! = null & & side . Index = = side . Line . Front . Index )
angle = General . ClampAngle ( 270 - side . Line . AngleDeg ) ;
else
angle = General . ClampAngle ( 90 - side . Line . AngleDeg ) ;
2014-08-25 11:15:19 +00:00
if ( ! anglesteps . Contains ( angle ) ) anglesteps . Add ( angle ) ;
2013-08-12 10:15:08 +00:00
}
2014-08-05 08:22:49 +00:00
}
2014-08-11 08:35:39 +00:00
//mxd. Update slope controls
ceilingslopecontrol . UpdateControls ( ) ;
floorslopecontrol . UpdateControls ( ) ;
2013-06-25 12:35:13 +00:00
// Show sector height
UpdateSectorHeight ( ) ;
2013-07-19 15:30:58 +00:00
2013-08-12 10:15:08 +00:00
//mxd. Angle steps
2014-08-25 11:15:19 +00:00
anglesteps . Sort ( ) ;
if ( useCeilLineAngles ) ceilRotation . StepValues = anglesteps ;
if ( useFloorLineAngles ) floorRotation . StepValues = anglesteps ;
if ( useCeilSlopeLineAngles ) ceilingslopecontrol . StepValues = anglesteps ;
if ( useFloorSlopeLineAngles ) floorslopecontrol . StepValues = anglesteps ;
2013-08-12 10:15:08 +00:00
2014-08-25 11:15:19 +00:00
blockupdate = false ; //mxd
2014-08-11 08:35:39 +00:00
}
2014-10-17 11:55:08 +00:00
// mxd
private void CreateHelperProps ( ICollection < Sector > sectors )
{
slopepivots = new Dictionary < Sector , Vector2D > ( sectors . Count ) ;
foreach ( Sector s in sectors )
{
Vector2D pivot = new Vector2D ( s . BBox . X + s . BBox . Width / 2 , s . BBox . Y + s . BBox . Height / 2 ) ;
globalslopepivot + = pivot ;
slopepivots . Add ( s , pivot ) ;
//mxd. Store initial properties
sectorprops . Add ( s , new SectorProperties ( s ) ) ;
}
globalslopepivot / = sectors . Count ;
}
2013-06-25 12:35:13 +00:00
// This updates the sector height field
2014-10-17 11:55:08 +00:00
private void UpdateSectorHeight ( )
{
2014-08-25 11:15:19 +00:00
int delta = int . MinValue ;
2013-06-25 12:35:13 +00:00
// Check all selected sectors
2014-10-17 11:55:08 +00:00
foreach ( Sector s in sectors )
{
if ( delta = = int . MinValue )
{
2013-06-25 12:35:13 +00:00
// First sector in list
delta = s . CeilHeight - s . FloorHeight ;
2014-10-17 11:55:08 +00:00
}
else if ( delta ! = ( s . CeilHeight - s . FloorHeight ) )
{
2013-08-12 10:15:08 +00:00
// We can't show heights because the delta
// heights for the sectors is different
2014-08-25 11:15:19 +00:00
delta = int . MinValue ;
2013-08-12 10:15:08 +00:00
break ;
2013-06-25 12:35:13 +00:00
}
}
2014-10-17 11:55:08 +00:00
if ( delta ! = int . MinValue )
{
2014-08-25 11:15:19 +00:00
sectorheight . Text = delta . ToString ( ) ;
2013-06-25 12:35:13 +00:00
sectorheight . Visible = true ;
sectorheightlabel . Visible = true ;
2014-10-17 11:55:08 +00:00
}
else
{
2013-06-25 12:35:13 +00:00
sectorheight . Visible = false ;
sectorheightlabel . Visible = false ;
}
}
2014-09-13 21:57:56 +00:00
//mxd
private void UpdateCeilingHeight ( )
{
int offset = heightoffset . GetResult ( 0 ) ;
//restore values
if ( string . IsNullOrEmpty ( ceilingheight . Text ) )
{
2014-10-17 11:55:08 +00:00
foreach ( Sector s in sectors )
{
2014-09-13 21:57:56 +00:00
s . CeilHeight = sectorprops [ s ] . CeilHeight + offset ;
2014-10-17 11:55:08 +00:00
SynchCeilSlopeOffsetToHeight ( s ) ;
}
2014-09-13 21:57:56 +00:00
}
else //update values
{
2014-10-17 11:55:08 +00:00
foreach ( Sector s in sectors )
{
2014-09-13 21:57:56 +00:00
s . CeilHeight = ceilingheight . GetResult ( sectorprops [ s ] . CeilHeight ) + offset ;
2014-10-17 11:55:08 +00:00
SynchCeilSlopeOffsetToHeight ( s ) ;
}
2014-09-13 21:57:56 +00:00
}
}
//mxd
private void UpdateFloorHeight ( )
{
int offset = heightoffset . GetResult ( 0 ) ;
//restore values
if ( string . IsNullOrEmpty ( floorheight . Text ) )
{
2014-10-17 11:55:08 +00:00
foreach ( Sector s in sectors )
{
2014-09-13 21:57:56 +00:00
s . FloorHeight = sectorprops [ s ] . FloorHeight + offset ;
2014-10-17 11:55:08 +00:00
SynchFloorSlopeOffsetToHeight ( s ) ;
}
2014-09-13 21:57:56 +00:00
}
else //update values
{
2014-10-17 11:55:08 +00:00
foreach ( Sector s in sectors )
{
2014-09-13 21:57:56 +00:00
s . FloorHeight = floorheight . GetResult ( sectorprops [ s ] . FloorHeight ) + offset ;
2014-10-17 11:55:08 +00:00
SynchFloorSlopeOffsetToHeight ( s ) ;
}
2014-09-13 21:57:56 +00:00
}
}
2014-10-17 11:55:08 +00:00
//mxd
private void SynchCeilSlopeOffsetToHeight ( Sector s )
{
Vector3D center = GetSectorCenter ( s , s . CeilHeight , SlopePivotMode . LOCAL ) ;
Plane p = new Plane ( center , s . CeilSlope . GetAngleXY ( ) - Angle2D . PIHALF , s . CeilSlope . GetAngleZ ( ) , false ) ;
s . CeilSlopeOffset = p . Offset ;
}
//mxd
private void SynchFloorSlopeOffsetToHeight ( Sector s )
{
Vector3D center = GetSectorCenter ( s , s . FloorHeight , SlopePivotMode . LOCAL ) ;
Plane p = new Plane ( center , s . FloorSlope . GetAngleXY ( ) + Angle2D . PIHALF , - s . FloorSlope . GetAngleZ ( ) , true ) ;
s . FloorSlopeOffset = p . Offset ;
}
2013-07-09 13:13:00 +00:00
#endregion
#region = = = = = = = = = = = = = = = = = = Events
2014-10-17 11:55:08 +00:00
private void apply_Click ( object sender , EventArgs e )
{
2013-06-25 12:35:13 +00:00
// Verify the tag
tagSelector . ValidateTag ( ) ; //mxd
2014-10-17 11:55:08 +00:00
if ( ( tagSelector . GetTag ( 0 ) < General . Map . FormatInterface . MinTag ) | | ( tagSelector . GetTag ( 0 ) > General . Map . FormatInterface . MaxTag ) )
{
2013-06-25 12:35:13 +00:00
General . ShowWarningMessage ( "Sector tag must be between " + General . Map . FormatInterface . MinTag + " and " + General . Map . FormatInterface . MaxTag + "." , MessageBoxButtons . OK ) ;
return ;
}
// Verify the effect
2014-10-17 11:55:08 +00:00
if ( ( effect . Value < General . Map . FormatInterface . MinEffect ) | | ( effect . Value > General . Map . FormatInterface . MaxEffect ) )
{
2013-06-25 12:35:13 +00:00
General . ShowWarningMessage ( "Sector effect must be between " + General . Map . FormatInterface . MinEffect + " and " + General . Map . FormatInterface . MaxEffect + "." , MessageBoxButtons . OK ) ;
return ;
}
2014-05-05 14:24:57 +00:00
//mxd
string [ ] rskeys = null ;
2014-10-17 11:55:08 +00:00
if ( General . Map . Config . SectorRenderStyles . Count > 0 )
{
2014-05-05 14:24:57 +00:00
rskeys = new string [ General . Map . Config . SectorRenderStyles . Count ] ;
General . Map . Config . SectorRenderStyles . Keys . CopyTo ( rskeys , 0 ) ;
}
2013-06-25 12:35:13 +00:00
// Go for all sectors
2014-08-05 11:03:55 +00:00
int tagoffset = 0 ; //mxd
2014-10-17 11:55:08 +00:00
foreach ( Sector s in sectors )
{
2013-07-10 08:59:17 +00:00
// Apply all flags
2014-10-17 11:55:08 +00:00
foreach ( CheckBox c in flags . Checkboxes )
{
2013-07-10 08:59:17 +00:00
if ( c . CheckState = = CheckState . Checked ) s . SetFlag ( c . Tag . ToString ( ) , true ) ;
else if ( c . CheckState = = CheckState . Unchecked ) s . SetFlag ( c . Tag . ToString ( ) , false ) ;
}
2013-06-25 12:35:13 +00:00
// Effects
if ( ! effect . Empty ) s . Effect = effect . Value ;
s . Brightness = General . Clamp ( brightness . GetResult ( s . Brightness ) , General . Map . FormatInterface . MinBrightness , General . Map . FormatInterface . MaxBrightness ) ;
// Action
2014-08-11 08:35:39 +00:00
s . Tag = General . Clamp ( tagSelector . GetSmartTag ( s . Tag , tagoffset + + ) , General . Map . FormatInterface . MinTag , General . Map . FormatInterface . MaxTag ) ; //mxd
2013-06-25 12:35:13 +00:00
2014-10-17 11:55:08 +00:00
// Fields
2013-08-08 11:04:13 +00:00
fieldslist . Apply ( s . Fields ) ;
2014-10-17 11:55:08 +00:00
// Alpha
if ( ! string . IsNullOrEmpty ( ceilAlpha . Text ) )
{
2013-07-19 15:30:58 +00:00
float ceilAlphaVal = General . Clamp ( ceilAlpha . GetResultFloat ( s . Fields . GetValue ( "alphaceiling" , 1.0f ) ) , 0f , 1f ) ;
2013-08-10 11:28:51 +00:00
UDMFTools . SetFloat ( s . Fields , "alphaceiling" , ceilAlphaVal , 1.0f ) ;
2013-06-25 12:35:13 +00:00
}
2014-10-17 11:55:08 +00:00
if ( ! string . IsNullOrEmpty ( floorAlpha . Text ) )
{
2013-07-19 15:30:58 +00:00
float floorAlphaVal = General . Clamp ( floorAlpha . GetResultFloat ( s . Fields . GetValue ( "alphafloor" , 1.0f ) ) , 0f , 1f ) ;
2013-08-10 11:28:51 +00:00
UDMFTools . SetFloat ( s . Fields , "alphafloor" , floorAlphaVal , 1.0f ) ;
2013-06-25 12:35:13 +00:00
}
//renderstyle
2014-10-17 11:55:08 +00:00
if ( rskeys ! = null )
{
if ( ceilRenderStyle . SelectedIndex > - 1 )
{
2014-05-05 14:24:57 +00:00
UDMFTools . SetString ( s . Fields , "renderstyleceiling" , rskeys [ ceilRenderStyle . SelectedIndex ] , "translucent" ) ;
}
2014-10-17 11:55:08 +00:00
if ( floorRenderStyle . SelectedIndex > - 1 )
{
2014-05-05 14:24:57 +00:00
UDMFTools . SetString ( s . Fields , "renderstylefloor" , rskeys [ floorRenderStyle . SelectedIndex ] , "translucent" ) ;
}
2013-06-25 12:35:13 +00:00
}
2014-10-17 11:55:08 +00:00
// Misc
if ( soundSequence . Text ! = "" )
s . Fields [ "soundsequence" ] = new UniValue ( UniversalType . String , soundSequence . Text ) ;
if ( gravity . Text ! = "" )
2013-08-10 11:28:51 +00:00
UDMFTools . SetFloat ( s . Fields , "gravity" , gravity . GetResultFloat ( s . Fields . GetValue ( "gravity" , 1.0f ) ) , 1.0f ) ;
2014-10-17 11:55:08 +00:00
if ( desaturation . Text ! = "" )
{
2013-07-19 15:30:58 +00:00
float val = General . Clamp ( desaturation . GetResultFloat ( s . Fields . GetValue ( "desaturation" , 0f ) ) , 0f , 1f ) ;
2013-08-10 11:28:51 +00:00
UDMFTools . SetFloat ( s . Fields , "desaturation" , val , 0f ) ;
2013-06-25 12:35:13 +00:00
}
2014-10-17 11:55:08 +00:00
// Clear horizontal slopes
if ( ( float ) Math . Round ( Angle2D . RadToDeg ( s . FloorSlope . GetAngleZ ( ) ) , 3 ) = = 90f )
{
s . FloorSlope = new Vector3D ( ) ;
s . FloorSlopeOffset = float . NaN ;
}
if ( ( float ) Math . Round ( Angle2D . RadToDeg ( s . CeilSlope . GetAngleZ ( ) ) , 3 ) = = 270f )
{
s . CeilSlope = new Vector3D ( ) ;
s . CeilSlopeOffset = float . NaN ;
}
2013-06-25 12:35:13 +00:00
}
// Update the used textures
General . Map . Data . UpdateUsedTextures ( ) ;
2013-07-19 15:30:58 +00:00
// Store value linking
linkCeilingScale = ceilScale . LinkValues ;
linkFloorScale = floorScale . LinkValues ;
2013-08-12 10:15:08 +00:00
useCeilLineAngles = cbUseCeilLineAngles . Checked ;
useFloorLineAngles = cbUseFloorLineAngles . Checked ;
2014-08-25 11:15:19 +00:00
useCeilSlopeLineAngles = ceilingslopecontrol . UseLineAngles ;
useFloorSlopeLineAngles = floorslopecontrol . UseLineAngles ;
2014-10-17 11:55:08 +00:00
floorpivotmode = floorslopecontrol . PivotMode ;
ceilpivotmode = ceilingslopecontrol . PivotMode ;
2013-07-19 15:30:58 +00:00
2013-06-25 12:35:13 +00:00
// Done
General . Map . IsChanged = true ;
2013-07-19 15:30:58 +00:00
if ( OnValuesChanged ! = null ) OnValuesChanged ( this , EventArgs . Empty ) ; //mxd
2013-06-25 12:35:13 +00:00
this . DialogResult = DialogResult . OK ;
this . Close ( ) ;
}
2014-10-17 11:55:08 +00:00
private void cancel_Click ( object sender , EventArgs e )
{
2013-07-19 15:30:58 +00:00
//mxd. Let's pretend nothing of this really happened...
General . Map . UndoRedo . WithdrawUndo ( ) ;
2013-06-25 12:35:13 +00:00
// Be gone
this . DialogResult = DialogResult . Cancel ;
this . Close ( ) ;
}
2014-10-17 11:55:08 +00:00
private void browseeffect_Click ( object sender , EventArgs e )
{
2013-06-25 12:35:13 +00:00
effect . Value = EffectBrowserForm . BrowseEffect ( this , effect . Value ) ;
}
2013-11-21 10:53:11 +00:00
//mxd
2014-10-17 11:55:08 +00:00
private void SectorEditFormUDMF_FormClosing ( object sender , FormClosingEventArgs e )
{
2013-11-21 10:53:11 +00:00
location = this . Location ;
2014-08-25 11:15:19 +00:00
activetab = tabs . SelectedIndex ;
2013-11-21 10:53:11 +00:00
}
2014-10-17 11:55:08 +00:00
private void SectorEditFormUDMF_HelpRequested ( object sender , HelpEventArgs hlpevent )
{
2013-06-25 12:35:13 +00:00
General . ShowHelp ( "w_sectoredit.html" ) ;
hlpevent . Handled = true ;
}
2014-10-17 11:55:08 +00:00
private void tabcustom_MouseEnter ( object sender , EventArgs e )
{
2013-06-25 12:35:13 +00:00
fieldslist . Focus ( ) ;
}
2014-10-17 11:55:08 +00:00
private void ceilAngleControl_AngleChanged ( )
{
2013-06-25 12:35:13 +00:00
ceilRotation . Text = ( General . ClampAngle ( 360 - ceilAngleControl . Angle ) ) . ToString ( ) ;
}
2014-10-17 11:55:08 +00:00
private void floorAngleControl_AngleChanged ( )
{
2013-06-25 12:35:13 +00:00
floorRotation . Text = ( General . ClampAngle ( 360 - floorAngleControl . Angle ) ) . ToString ( ) ;
}
2014-10-17 11:55:08 +00:00
private void cbUseCeilLineAngles_CheckedChanged ( object sender , EventArgs e )
{
2014-09-15 08:15:22 +00:00
ceilRotation . ButtonStepsWrapAround = cbUseCeilLineAngles . Checked ;
2014-08-25 11:15:19 +00:00
ceilRotation . StepValues = ( cbUseCeilLineAngles . Checked ? anglesteps : null ) ;
2013-08-12 10:15:08 +00:00
}
2014-10-17 11:55:08 +00:00
private void cbUseFloorLineAngles_CheckedChanged ( object sender , EventArgs e )
{
2014-09-15 08:15:22 +00:00
floorRotation . ButtonStepsWrapAround = cbUseFloorLineAngles . Checked ;
2014-08-25 11:15:19 +00:00
floorRotation . StepValues = ( cbUseFloorLineAngles . Checked ? anglesteps : null ) ;
2013-08-12 10:15:08 +00:00
}
2013-07-19 15:30:58 +00:00
#endregion
2014-09-04 12:34:26 +00:00
#region = = = = = = = = = = = = = = = = = = Sector Realtime events ( mxd )
2013-07-19 15:30:58 +00:00
2014-09-13 21:57:56 +00:00
private void ceilingheight_WhenTextChanged ( object sender , EventArgs e )
{
2014-08-25 11:15:19 +00:00
if ( blockupdate ) return ;
2013-07-19 15:30:58 +00:00
2014-09-13 21:57:56 +00:00
UpdateCeilingHeight ( ) ;
2013-09-17 08:21:12 +00:00
UpdateSectorHeight ( ) ;
2013-07-19 15:30:58 +00:00
General . Map . IsChanged = true ;
if ( OnValuesChanged ! = null ) OnValuesChanged ( this , EventArgs . Empty ) ;
}
2014-09-13 21:57:56 +00:00
private void floorheight_WhenTextChanged ( object sender , EventArgs e )
{
2014-08-25 11:15:19 +00:00
if ( blockupdate ) return ;
2013-07-19 15:30:58 +00:00
2014-09-13 21:57:56 +00:00
UpdateFloorHeight ( ) ;
2013-09-17 08:21:12 +00:00
UpdateSectorHeight ( ) ;
2013-07-19 15:30:58 +00:00
General . Map . IsChanged = true ;
if ( OnValuesChanged ! = null ) OnValuesChanged ( this , EventArgs . Empty ) ;
}
2014-09-13 21:57:56 +00:00
private void heightoffset_WhenTextChanged ( object sender , EventArgs e )
{
if ( blockupdate ) return ;
UpdateFloorHeight ( ) ;
UpdateCeilingHeight ( ) ;
UpdateSectorHeight ( ) ;
General . Map . IsChanged = true ;
if ( OnValuesChanged ! = null ) OnValuesChanged ( this , EventArgs . Empty ) ;
}
2014-12-03 23:15:26 +00:00
private void brightness_WhenTextChanged ( object sender , EventArgs e )
{
2014-08-25 11:15:19 +00:00
if ( blockupdate ) return ;
2013-07-19 15:30:58 +00:00
//restore values
2014-10-17 11:55:08 +00:00
if ( string . IsNullOrEmpty ( brightness . Text ) )
{
2013-07-19 15:30:58 +00:00
foreach ( Sector s in sectors )
2014-08-25 11:15:19 +00:00
s . Brightness = sectorprops [ s ] . Brightness ;
2014-10-17 11:55:08 +00:00
}
else //update values
{
2013-07-19 15:30:58 +00:00
foreach ( Sector s in sectors )
2014-08-25 11:15:19 +00:00
s . Brightness = General . Clamp ( brightness . GetResult ( sectorprops [ s ] . Brightness ) , General . Map . FormatInterface . MinBrightness , General . Map . FormatInterface . MaxBrightness ) ;
2013-07-19 15:30:58 +00:00
}
General . Map . IsChanged = true ;
if ( OnValuesChanged ! = null ) OnValuesChanged ( this , EventArgs . Empty ) ;
}
2014-10-17 11:55:08 +00:00
private void ceilingtex_OnValueChanged ( object sender , EventArgs e )
{
2014-08-25 11:15:19 +00:00
if ( blockupdate ) return ;
2013-07-19 15:30:58 +00:00
//restore values
2014-10-17 11:55:08 +00:00
if ( string . IsNullOrEmpty ( ceilingtex . TextureName ) )
{
2013-07-19 15:30:58 +00:00
foreach ( Sector s in sectors )
2014-08-25 11:15:19 +00:00
s . SetCeilTexture ( sectorprops [ s ] . CeilTexture ) ;
2014-10-17 11:55:08 +00:00
}
else //update values
{
2013-07-19 15:30:58 +00:00
foreach ( Sector s in sectors )
s . SetCeilTexture ( ceilingtex . GetResult ( s . CeilTexture ) ) ;
}
// Update the used textures
General . Map . Data . UpdateUsedTextures ( ) ;
General . Map . IsChanged = true ;
if ( OnValuesChanged ! = null ) OnValuesChanged ( this , EventArgs . Empty ) ;
}
2014-10-17 11:55:08 +00:00
private void floortex_OnValueChanged ( object sender , EventArgs e )
{
2014-08-25 11:15:19 +00:00
if ( blockupdate ) return ;
2013-07-19 15:30:58 +00:00
//restore values
2014-10-17 11:55:08 +00:00
if ( string . IsNullOrEmpty ( floortex . TextureName ) )
{
2013-07-19 15:30:58 +00:00
foreach ( Sector s in sectors )
2014-08-25 11:15:19 +00:00
s . SetFloorTexture ( sectorprops [ s ] . FloorTexture ) ;
2014-10-17 11:55:08 +00:00
}
else //update values
{
2013-07-19 15:30:58 +00:00
foreach ( Sector s in sectors )
s . SetFloorTexture ( floortex . GetResult ( s . FloorTexture ) ) ;
}
// Update the used textures
General . Map . Data . UpdateUsedTextures ( ) ;
General . Map . IsChanged = true ;
if ( OnValuesChanged ! = null ) OnValuesChanged ( this , EventArgs . Empty ) ;
}
2014-10-17 11:55:08 +00:00
private void floorRotation_WhenTextChanged ( object sender , EventArgs e )
{
2014-08-25 11:15:19 +00:00
if ( blockupdate ) return ;
2013-07-19 15:30:58 +00:00
//restore values
2014-10-17 11:55:08 +00:00
if ( string . IsNullOrEmpty ( floorRotation . Text ) )
{
floorAngleControl . Angle = GZBuilder . Controls . AngleControl . NO_ANGLE ;
foreach ( Sector s in sectors )
{
2014-08-25 11:15:19 +00:00
UDMFTools . SetFloat ( s . Fields , "rotationfloor" , sectorprops [ s ] . FloorRotation , 0f ) ;
2013-07-19 15:30:58 +00:00
s . UpdateNeeded = true ;
}
2014-10-17 11:55:08 +00:00
}
else //update values
{
floorAngleControl . Angle = ( int ) General . ClampAngle ( 360 - floorRotation . GetResultFloat ( 0 ) ) ;
foreach ( Sector s in sectors )
{
2014-08-25 11:15:19 +00:00
UDMFTools . SetFloat ( s . Fields , "rotationfloor" , floorRotation . GetResultFloat ( sectorprops [ s ] . FloorRotation ) , 0f ) ;
2013-07-19 15:30:58 +00:00
s . UpdateNeeded = true ;
}
}
General . Map . IsChanged = true ;
if ( OnValuesChanged ! = null ) OnValuesChanged ( this , EventArgs . Empty ) ;
2013-06-25 12:35:13 +00:00
}
2014-10-17 11:55:08 +00:00
private void ceilRotation_WhenTextChanged ( object sender , EventArgs e )
{
2014-08-25 11:15:19 +00:00
if ( blockupdate ) return ;
2013-07-19 15:30:58 +00:00
//restore values
2014-10-17 11:55:08 +00:00
if ( string . IsNullOrEmpty ( ceilRotation . Text ) )
{
ceilAngleControl . Angle = GZBuilder . Controls . AngleControl . NO_ANGLE ;
foreach ( Sector s in sectors )
{
2014-08-25 11:15:19 +00:00
UDMFTools . SetFloat ( s . Fields , "rotationceiling" , sectorprops [ s ] . CeilRotation , 0f ) ;
2013-07-19 15:30:58 +00:00
s . UpdateNeeded = true ;
}
2014-10-17 11:55:08 +00:00
}
else //update values
{
ceilAngleControl . Angle = ( int ) General . ClampAngle ( 360 - ceilRotation . GetResultFloat ( 0 ) ) ;
foreach ( Sector s in sectors )
{
2014-08-25 11:15:19 +00:00
UDMFTools . SetFloat ( s . Fields , "rotationceiling" , ceilRotation . GetResultFloat ( sectorprops [ s ] . CeilRotation ) , 0f ) ;
2013-07-19 15:30:58 +00:00
s . UpdateNeeded = true ;
}
}
General . Map . IsChanged = true ;
if ( OnValuesChanged ! = null ) OnValuesChanged ( this , EventArgs . Empty ) ;
}
2014-10-17 11:55:08 +00:00
private void lightColor_OnValueChanged ( object sender , EventArgs e )
{
2014-08-25 11:15:19 +00:00
if ( blockupdate ) return ;
2013-07-19 15:30:58 +00:00
2014-10-17 11:55:08 +00:00
foreach ( Sector s in sectors )
{
2014-08-25 11:15:19 +00:00
lightColor . ApplyTo ( s . Fields , sectorprops [ s ] . LightColor ) ;
2013-07-19 15:30:58 +00:00
s . UpdateNeeded = true ;
}
General . Map . IsChanged = true ;
if ( OnValuesChanged ! = null ) OnValuesChanged ( this , EventArgs . Empty ) ;
}
2014-10-17 11:55:08 +00:00
private void fadeColor_OnValueChanged ( object sender , EventArgs e )
{
2014-08-25 11:15:19 +00:00
if ( blockupdate ) return ;
2013-07-19 15:30:58 +00:00
2014-10-17 11:55:08 +00:00
foreach ( Sector s in sectors )
{
2014-08-25 11:15:19 +00:00
fadeColor . ApplyTo ( s . Fields , sectorprops [ s ] . FadeColor ) ;
2013-07-19 15:30:58 +00:00
s . UpdateNeeded = true ;
}
General . Map . IsChanged = true ;
if ( OnValuesChanged ! = null ) OnValuesChanged ( this , EventArgs . Empty ) ;
}
#endregion
2014-09-04 12:34:26 +00:00
#region = = = = = = = = = = = = = = = = = = Ceiling / Floor realtime events ( mxd )
2013-07-19 15:30:58 +00:00
2014-10-17 11:55:08 +00:00
private void ceilOffsets_OnValuesChanged ( object sender , EventArgs e )
{
2014-08-25 11:15:19 +00:00
if ( blockupdate ) return ;
2013-07-19 15:30:58 +00:00
2014-10-17 11:55:08 +00:00
foreach ( Sector s in sectors )
{
2014-08-25 11:15:19 +00:00
ceilOffsets . ApplyTo ( s . Fields , General . Map . FormatInterface . MinTextureOffset , General . Map . FormatInterface . MaxTextureOffset , sectorprops [ s ] . CeilOffsetX , sectorprops [ s ] . CeilOffsetY ) ;
2013-07-19 15:30:58 +00:00
s . UpdateNeeded = true ;
}
General . Map . IsChanged = true ;
if ( OnValuesChanged ! = null ) OnValuesChanged ( this , EventArgs . Empty ) ;
}
2014-10-17 11:55:08 +00:00
private void floorOffsets_OnValuesChanged ( object sender , EventArgs e )
{
2014-08-25 11:15:19 +00:00
if ( blockupdate ) return ;
2013-07-19 15:30:58 +00:00
2014-10-17 11:55:08 +00:00
foreach ( Sector s in sectors )
{
2014-08-25 11:15:19 +00:00
floorOffsets . ApplyTo ( s . Fields , General . Map . FormatInterface . MinTextureOffset , General . Map . FormatInterface . MaxTextureOffset , sectorprops [ s ] . FloorOffsetX , sectorprops [ s ] . FloorOffsetY ) ;
2013-07-19 15:30:58 +00:00
s . UpdateNeeded = true ;
}
General . Map . IsChanged = true ;
if ( OnValuesChanged ! = null ) OnValuesChanged ( this , EventArgs . Empty ) ;
}
2014-10-17 11:55:08 +00:00
private void ceilScale_OnValuesChanged ( object sender , EventArgs e )
{
2014-08-25 11:15:19 +00:00
if ( blockupdate ) return ;
2013-07-19 15:30:58 +00:00
2014-10-17 11:55:08 +00:00
foreach ( Sector s in sectors )
{
2014-08-25 11:15:19 +00:00
ceilScale . ApplyTo ( s . Fields , General . Map . FormatInterface . MinTextureOffset , General . Map . FormatInterface . MaxTextureOffset , sectorprops [ s ] . CeilScaleX , sectorprops [ s ] . CeilScaleY ) ;
2013-07-19 15:30:58 +00:00
s . UpdateNeeded = true ;
}
General . Map . IsChanged = true ;
if ( OnValuesChanged ! = null ) OnValuesChanged ( this , EventArgs . Empty ) ;
}
2014-10-17 11:55:08 +00:00
private void floorScale_OnValuesChanged ( object sender , EventArgs e )
{
2014-08-25 11:15:19 +00:00
if ( blockupdate ) return ;
2013-07-19 15:30:58 +00:00
2014-10-17 11:55:08 +00:00
foreach ( Sector s in sectors )
{
2014-08-25 11:15:19 +00:00
floorScale . ApplyTo ( s . Fields , General . Map . FormatInterface . MinTextureOffset , General . Map . FormatInterface . MaxTextureOffset , sectorprops [ s ] . FloorScaleX , sectorprops [ s ] . FloorScaleY ) ;
2013-07-19 15:30:58 +00:00
s . UpdateNeeded = true ;
}
General . Map . IsChanged = true ;
if ( OnValuesChanged ! = null ) OnValuesChanged ( this , EventArgs . Empty ) ;
}
2014-10-17 11:55:08 +00:00
private void ceilBrightness_WhenTextChanged ( object sender , EventArgs e )
{
2014-08-25 11:15:19 +00:00
if ( blockupdate ) return ;
2013-07-19 15:30:58 +00:00
//restore values
2014-10-17 11:55:08 +00:00
if ( string . IsNullOrEmpty ( ceilBrightness . Text ) )
{
foreach ( Sector s in sectors )
{
2014-08-25 11:15:19 +00:00
UDMFTools . SetInteger ( s . Fields , "lightceiling" , sectorprops [ s ] . CeilBrightness , 0 ) ;
2013-07-19 15:30:58 +00:00
s . UpdateNeeded = true ;
}
2014-10-17 11:55:08 +00:00
}
else //update values
{
foreach ( Sector s in sectors )
{
2013-07-19 15:30:58 +00:00
bool absolute = false ;
2014-10-17 11:55:08 +00:00
if ( ceilLightAbsolute . CheckState = = CheckState . Indeterminate )
{
2013-07-19 15:30:58 +00:00
absolute = s . Fields . GetValue ( "lightceilingabsolute" , false ) ;
2014-10-17 11:55:08 +00:00
}
else if ( ceilLightAbsolute . CheckState = = CheckState . Checked )
{
2013-07-19 15:30:58 +00:00
absolute = true ;
}
2014-08-25 11:15:19 +00:00
int value = General . Clamp ( ceilBrightness . GetResult ( sectorprops [ s ] . CeilBrightness ) , ( absolute ? 0 : - 255 ) , 255 ) ;
2013-08-10 11:28:51 +00:00
UDMFTools . SetInteger ( s . Fields , "lightceiling" , value , 0 ) ;
2013-07-19 15:30:58 +00:00
s . UpdateNeeded = true ;
}
}
General . Map . IsChanged = true ;
if ( OnValuesChanged ! = null ) OnValuesChanged ( this , EventArgs . Empty ) ;
}
2014-10-17 11:55:08 +00:00
private void floorBrightness_WhenTextChanged ( object sender , EventArgs e )
{
2014-08-25 11:15:19 +00:00
if ( blockupdate ) return ;
2013-07-19 15:30:58 +00:00
//restore values
2014-10-17 11:55:08 +00:00
if ( string . IsNullOrEmpty ( floorBrightness . Text ) )
{
foreach ( Sector s in sectors )
{
2014-08-25 11:15:19 +00:00
UDMFTools . SetInteger ( s . Fields , "lightfloor" , sectorprops [ s ] . FloorBrightness , 0 ) ;
2013-07-19 15:30:58 +00:00
s . UpdateNeeded = true ;
}
2014-10-17 11:55:08 +00:00
}
else //update values
{
foreach ( Sector s in sectors )
{
2013-07-19 15:30:58 +00:00
bool absolute = false ;
2014-10-17 11:55:08 +00:00
if ( floorLightAbsolute . CheckState = = CheckState . Indeterminate )
{
2013-07-19 15:30:58 +00:00
absolute = s . Fields . GetValue ( "lightfloorabsolute" , false ) ;
2014-10-17 11:55:08 +00:00
}
else if ( floorLightAbsolute . CheckState = = CheckState . Checked )
{
2013-07-19 15:30:58 +00:00
absolute = true ;
}
2014-08-25 11:15:19 +00:00
int value = General . Clamp ( floorBrightness . GetResult ( sectorprops [ s ] . FloorBrightness ) , ( absolute ? 0 : - 255 ) , 255 ) ;
2013-08-10 11:28:51 +00:00
UDMFTools . SetInteger ( s . Fields , "lightfloor" , value , 0 ) ;
2013-07-19 15:30:58 +00:00
s . UpdateNeeded = true ;
}
}
General . Map . IsChanged = true ;
if ( OnValuesChanged ! = null ) OnValuesChanged ( this , EventArgs . Empty ) ;
}
2014-10-17 11:55:08 +00:00
private void ceilLightAbsolute_CheckedChanged ( object sender , EventArgs e )
{
2014-08-25 11:15:19 +00:00
if ( blockupdate ) return ;
2013-07-19 15:30:58 +00:00
2014-10-17 11:55:08 +00:00
if ( ceilLightAbsolute . Checked )
{
foreach ( Sector s in sectors )
{
2013-07-19 15:30:58 +00:00
s . Fields [ "lightceilingabsolute" ] = new UniValue ( UniversalType . Boolean , true ) ;
s . UpdateNeeded = true ;
}
2014-10-17 11:55:08 +00:00
}
else if ( ceilLightAbsolute . CheckState = = CheckState . Indeterminate )
{
foreach ( Sector s in sectors )
{
if ( sectorprops [ s ] . CeilLightAbsoulte )
{
2013-07-19 15:30:58 +00:00
s . Fields [ "lightceilingabsolute" ] = new UniValue ( UniversalType . Boolean , true ) ;
s . UpdateNeeded = true ;
2014-10-17 11:55:08 +00:00
}
else if ( s . Fields . ContainsKey ( "lightceilingabsolute" ) )
{
2013-07-19 15:30:58 +00:00
s . Fields . Remove ( "lightceilingabsolute" ) ;
s . UpdateNeeded = true ;
}
}
2014-10-17 11:55:08 +00:00
}
else
{
foreach ( Sector s in sectors )
{
if ( s . Fields . ContainsKey ( "lightceilingabsolute" ) )
{
2013-07-19 15:30:58 +00:00
s . Fields . Remove ( "lightceilingabsolute" ) ;
s . UpdateNeeded = true ;
}
}
}
General . Map . IsChanged = true ;
if ( OnValuesChanged ! = null ) OnValuesChanged ( this , EventArgs . Empty ) ;
}
2014-10-17 11:55:08 +00:00
private void floorLightAbsolute_CheckedChanged ( object sender , EventArgs e )
{
2014-08-25 11:15:19 +00:00
if ( blockupdate ) return ;
2013-07-19 15:30:58 +00:00
2014-10-17 11:55:08 +00:00
if ( floorLightAbsolute . Checked )
{
foreach ( Sector s in sectors )
{
2013-07-19 15:30:58 +00:00
s . Fields [ "lightfloorabsolute" ] = new UniValue ( UniversalType . Boolean , true ) ;
s . UpdateNeeded = true ;
}
2014-10-17 11:55:08 +00:00
}
else if ( floorLightAbsolute . CheckState = = CheckState . Indeterminate )
{
foreach ( Sector s in sectors )
{
if ( sectorprops [ s ] . FloorLightAbsoulte )
{
2013-07-19 15:30:58 +00:00
s . Fields [ "lightfloorabsolute" ] = new UniValue ( UniversalType . Boolean , true ) ;
s . UpdateNeeded = true ;
2014-10-17 11:55:08 +00:00
}
else if ( s . Fields . ContainsKey ( "lightfloorabsolute" ) )
{
2013-07-19 15:30:58 +00:00
s . Fields . Remove ( "lightfloorabsolute" ) ;
s . UpdateNeeded = true ;
}
}
2014-10-17 11:55:08 +00:00
}
else
{
foreach ( Sector s in sectors )
{
if ( s . Fields . ContainsKey ( "lightfloorabsolute" ) )
{
2013-07-19 15:30:58 +00:00
s . Fields . Remove ( "lightfloorabsolute" ) ;
s . UpdateNeeded = true ;
}
}
}
General . Map . IsChanged = true ;
if ( OnValuesChanged ! = null ) OnValuesChanged ( this , EventArgs . Empty ) ;
2013-06-25 12:35:13 +00:00
}
2013-07-09 13:13:00 +00:00
#endregion
2013-07-19 15:30:58 +00:00
2014-09-04 12:34:26 +00:00
#region = = = = = = = = = = = = = = = = = = Slope Utility ( mxd )
2014-10-17 11:55:08 +00:00
private void SetupFloorSlope ( Sector s , bool first )
{
if ( s . FloorSlope . GetLengthSq ( ) > 0 )
{
float anglexy = General . ClampAngle ( ( float ) Math . Round ( Angle2D . RadToDeg ( s . FloorSlope . GetAngleXY ( ) ) - 180 , 1 ) ) ;
float anglez = - ( float ) Math . Round ( Angle2D . RadToDeg ( s . FloorSlope . GetAngleZ ( ) ) - 90 , 1 ) ;
float offset = ( float ) Math . Round ( GetVirtualSlopeOffset ( s , floorslopecontrol . PivotMode , true ) , 1 ) ;
2014-09-04 12:34:26 +00:00
2014-10-17 11:55:08 +00:00
if ( anglexy > = 180 & & anglez < 0 )
{
anglexy - = 180 ;
2014-09-04 12:34:26 +00:00
anglez = - anglez ;
}
2014-10-17 11:55:08 +00:00
2014-09-15 08:15:22 +00:00
floorslopecontrol . SetValues ( anglexy , anglez , offset , first ) ;
2014-10-17 11:55:08 +00:00
}
else
{
2014-09-04 12:34:26 +00:00
floorslopecontrol . SetValues ( 0f , 0f , s . FloorHeight , first ) ;
}
}
2014-10-17 11:55:08 +00:00
private void SetupCeilingSlope ( Sector s , bool first )
{
if ( s . CeilSlope . GetLengthSq ( ) > 0 )
{
float anglexy = General . ClampAngle ( ( float ) Math . Round ( Angle2D . RadToDeg ( s . CeilSlope . GetAngleXY ( ) ) - 180 , 1 ) ) ;
float anglez = - ( float ) ( 270 - Math . Round ( Angle2D . RadToDeg ( s . CeilSlope . GetAngleZ ( ) ) , 1 ) ) ;
float offset = ( float ) Math . Round ( GetVirtualSlopeOffset ( s , ceilingslopecontrol . PivotMode , false ) , 1 ) ;
2014-09-04 12:34:26 +00:00
2014-10-17 11:55:08 +00:00
if ( anglexy > = 180 & & anglez < 0 )
{
anglexy - = 180 ;
anglez = - anglez ;
2014-09-04 12:34:26 +00:00
}
2014-10-17 11:55:08 +00:00
ceilingslopecontrol . SetValues ( anglexy , anglez , offset , first ) ;
}
else
{
ceilingslopecontrol . SetValues ( 0f , 0f , s . CeilHeight , first ) ;
2014-09-04 12:34:26 +00:00
}
2014-10-17 11:55:08 +00:00
}
// Gets the offset to be displayed in a SectorSlopeControl
private float GetVirtualSlopeOffset ( Sector s , SlopePivotMode mode , bool floor )
{
float offset = ( floor ? s . FloorSlopeOffset : s . CeilSlopeOffset ) ;
if ( float . IsNaN ( offset ) )
{
offset = ( floor ? s . FloorHeight : s . CeilHeight ) ;
}
Vector3D normal = ( floor ? s . FloorSlope : s . CeilSlope ) ;
if ( normal . GetLengthSq ( ) > 0 )
{
Vector3D center = GetSectorCenter ( s , 0 , mode ) ;
Plane p = new Plane ( normal , offset ) ;
return p . GetZ ( center ) ;
}
return offset ;
}
2014-09-04 12:34:26 +00:00
2014-10-17 11:55:08 +00:00
// Gets the offset to be displayed in a SectorSlopeControl
private float GetInitialVirtualSlopeOffset ( Sector s , SlopePivotMode mode , bool floor )
{
float offset = ( floor ? sectorprops [ s ] . FloorSlopeOffset : sectorprops [ s ] . CeilSlopeOffset ) ;
Vector3D normal = ( floor ? sectorprops [ s ] . FloorSlope : sectorprops [ s ] . CeilSlope ) ;
if ( normal . GetLengthSq ( ) > 0 )
{
Vector3D center = GetSectorCenter ( s , 0 , mode ) ;
Plane p = new Plane ( normal , offset ) ;
return p . GetZ ( center ) ;
}
2014-09-04 12:34:26 +00:00
2014-10-17 11:55:08 +00:00
return offset ;
}
2014-09-04 12:34:26 +00:00
2014-10-17 11:55:08 +00:00
private Vector3D GetSectorCenter ( Sector s , float offset , SlopePivotMode mode )
{
switch ( mode )
{
case SlopePivotMode . GLOBAL : //translate from the center of selection
return new Vector3D ( globalslopepivot , offset ) ;
2014-09-04 12:34:26 +00:00
2014-10-17 11:55:08 +00:00
case SlopePivotMode . LOCAL : //translate from sector's bounding box center
return new Vector3D ( slopepivots [ s ] , offset ) ;
2014-09-04 12:34:26 +00:00
2014-10-17 11:55:08 +00:00
case SlopePivotMode . ORIGIN : //don't translate
return new Vector3D ( 0 , 0 , offset ) ;
2014-09-04 12:34:26 +00:00
default :
2014-10-17 11:55:08 +00:00
throw new NotImplementedException ( "SectorEditFormUDMF.GetSectorCenter: Got unknown SlopePivotMode (" + ( int ) mode + ")" ) ;
2014-09-04 12:34:26 +00:00
}
}
#endregion
#region = = = = = = = = = = = = = = = = = = Slopes realtime events ( mxd )
2014-08-05 08:22:49 +00:00
2014-09-04 12:34:26 +00:00
private void ceilingslopecontrol_OnAnglesChanged ( object sender , EventArgs e )
2014-08-25 11:15:19 +00:00
{
if ( blockupdate ) return ;
float anglexy , anglez ;
2014-08-05 08:22:49 +00:00
2014-08-25 11:15:19 +00:00
//Set or restore values
foreach ( Sector s in sectors )
{
2014-10-17 11:55:08 +00:00
anglexy = General . ClampAngle ( ceilingslopecontrol . GetAngleXY ( sectorprops [ s ] . CeilSlopeAngleXY ) + 270 ) ; //90
anglez = - ( ceilingslopecontrol . GetAngleZ ( sectorprops [ s ] . CeilSlopeAngleZ ) + 90 ) ;
float virtualoffset = GetInitialVirtualSlopeOffset ( s , ceilingslopecontrol . PivotMode , false ) ;
Vector3D center = GetSectorCenter ( s , ceilingslopecontrol . GetOffset ( virtualoffset ) , ceilingslopecontrol . PivotMode ) ;
Plane p = new Plane ( center , Angle2D . DegToRad ( anglexy ) , Angle2D . DegToRad ( anglez ) , false ) ;
s . CeilSlope = p . Normal ;
s . CeilSlopeOffset = p . Offset ;
s . CeilHeight = ( int ) Math . Round ( p . GetZ ( center . x , center . y ) ) ;
2014-08-25 11:15:19 +00:00
s . UpdateNeeded = true ;
2014-08-05 08:22:49 +00:00
}
General . Map . IsChanged = true ;
2014-08-25 11:15:19 +00:00
if ( OnValuesChanged ! = null ) OnValuesChanged ( this , EventArgs . Empty ) ;
2014-08-05 08:22:49 +00:00
}
2014-09-04 12:34:26 +00:00
private void floorslopecontrol_OnAnglesChanged ( object sender , EventArgs e )
2014-08-25 11:15:19 +00:00
{
if ( blockupdate ) return ;
float anglexy , anglez ;
2014-08-05 08:22:49 +00:00
2014-08-25 11:15:19 +00:00
//Set or restore values
foreach ( Sector s in sectors )
{
2014-10-17 11:55:08 +00:00
anglexy = General . ClampAngle ( floorslopecontrol . GetAngleXY ( sectorprops [ s ] . FloorSlopeAngleXY ) + 90 ) ;
anglez = - ( floorslopecontrol . GetAngleZ ( sectorprops [ s ] . FloorSlopeAngleZ ) + 90 ) ;
float virtualoffset = GetInitialVirtualSlopeOffset ( s , floorslopecontrol . PivotMode , true ) ;
Vector3D center = GetSectorCenter ( s , floorslopecontrol . GetOffset ( virtualoffset ) , floorslopecontrol . PivotMode ) ;
Plane p = new Plane ( center , Angle2D . DegToRad ( anglexy ) , Angle2D . DegToRad ( anglez ) , true ) ;
s . FloorSlope = p . Normal ;
s . FloorSlopeOffset = p . Offset ;
s . FloorHeight = ( int ) Math . Round ( p . GetZ ( center . x , center . y ) ) ;
2014-08-25 11:15:19 +00:00
s . UpdateNeeded = true ;
2014-08-05 08:22:49 +00:00
}
General . Map . IsChanged = true ;
2014-08-25 11:15:19 +00:00
if ( OnValuesChanged ! = null ) OnValuesChanged ( this , EventArgs . Empty ) ;
2014-08-11 08:35:39 +00:00
}
2014-10-17 11:55:08 +00:00
// Update displayed ceiling offset value
2014-09-04 12:34:26 +00:00
private void ceilingslopecontrol_OnPivotModeChanged ( object sender , EventArgs e )
2014-08-11 08:35:39 +00:00
{
2014-10-17 11:55:08 +00:00
bool first = true ;
foreach ( Sector s in sectors )
{
SetupCeilingSlope ( s , first ) ;
first = false ;
2014-08-05 08:22:49 +00:00
}
2014-09-04 12:34:26 +00:00
}
2014-08-05 08:22:49 +00:00
2014-10-17 11:55:08 +00:00
// Update displayed floor offset value
private void floorslopecontrol_OnPivotModeChanged ( object sender , EventArgs e )
2014-09-04 12:34:26 +00:00
{
2014-10-17 11:55:08 +00:00
bool first = true ;
foreach ( Sector s in sectors )
{
SetupFloorSlope ( s , first ) ;
first = false ;
2014-09-04 12:34:26 +00:00
}
}
2014-08-05 08:22:49 +00:00
2014-09-04 12:34:26 +00:00
private void ceilingslopecontrol_OnResetClicked ( object sender , EventArgs e )
{
2014-09-15 08:15:22 +00:00
ceilingslopecontrol . SetOffset ( General . GetByIndex ( sectors , 0 ) . CeilHeight , true ) ;
2014-10-17 11:55:08 +00:00
foreach ( Sector s in sectors )
{
s . CeilSlope = new Vector3D ( ) ;
s . CeilSlopeOffset = float . NaN ;
s . CeilHeight = ceilingheight . GetResult ( sectorprops [ s ] . CeilHeight ) ;
2014-09-04 12:34:26 +00:00
s . UpdateNeeded = true ;
2014-09-15 08:15:22 +00:00
ceilingslopecontrol . SetOffset ( s . CeilHeight , false ) ;
2014-09-04 12:34:26 +00:00
}
2014-09-15 08:15:22 +00:00
ceilingslopecontrol . UpdateOffset ( ) ;
2014-09-04 12:34:26 +00:00
General . Map . IsChanged = true ;
if ( OnValuesChanged ! = null ) OnValuesChanged ( this , EventArgs . Empty ) ;
}
2014-08-05 08:22:49 +00:00
2014-09-04 12:34:26 +00:00
private void floorslopecontrol_OnResetClicked ( object sender , EventArgs e )
{
2014-09-15 08:15:22 +00:00
floorslopecontrol . SetOffset ( General . GetByIndex ( sectors , 0 ) . FloorHeight , true ) ;
2014-10-17 11:55:08 +00:00
foreach ( Sector s in sectors )
{
2014-09-04 12:34:26 +00:00
s . FloorSlope = new Vector3D ( ) ;
s . FloorSlopeOffset = float . NaN ;
2014-10-17 11:55:08 +00:00
s . FloorHeight = floorheight . GetResult ( sectorprops [ s ] . FloorHeight ) ;
2014-09-04 12:34:26 +00:00
s . UpdateNeeded = true ;
2014-09-15 08:15:22 +00:00
floorslopecontrol . SetOffset ( s . FloorHeight , false ) ;
2014-08-05 08:22:49 +00:00
}
2014-09-15 08:15:22 +00:00
floorslopecontrol . UpdateOffset ( ) ;
2014-09-04 12:34:26 +00:00
General . Map . IsChanged = true ;
if ( OnValuesChanged ! = null ) OnValuesChanged ( this , EventArgs . Empty ) ;
2014-08-25 11:15:19 +00:00
}
2014-08-05 08:22:49 +00:00
2014-08-25 11:15:19 +00:00
private void ceilingslopecontrol_OnUseLineAnglesChanged ( object sender , EventArgs e )
{
ceilingslopecontrol . StepValues = ( ceilingslopecontrol . UseLineAngles ? anglesteps : null ) ;
}
2014-08-05 08:22:49 +00:00
2014-08-25 11:15:19 +00:00
private void floorslopecontrol_OnUseLineAnglesChanged ( object sender , EventArgs e )
{
floorslopecontrol . StepValues = ( floorslopecontrol . UseLineAngles ? anglesteps : null ) ;
}
2014-08-05 08:22:49 +00:00
#endregion
2013-06-25 12:35:13 +00:00
}
}