2007-12-26 00:31:32 +00:00
#region = = = = = = = = = = = = = = = = = = Copyright ( c ) 2007 Pascal vd Heiden
/ *
* Copyright ( c ) 2007 Pascal vd Heiden , www . codeimp . com
* This program is released under GNU General Public License
*
* This program is distributed in the hope that it will be useful ,
* but WITHOUT ANY WARRANTY ; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
* GNU General Public License for more details .
*
* /
#endregion
#region = = = = = = = = = = = = = = = = = = Namespaces
using System ;
using System.Collections.Generic ;
using System.ComponentModel ;
using System.Drawing ;
using System.Text ;
using System.Windows.Forms ;
using CodeImp.DoomBuilder.Map ;
using CodeImp.DoomBuilder.Data ;
using CodeImp.DoomBuilder.IO ;
using System.IO ;
using CodeImp.DoomBuilder.Config ;
2007-12-27 01:24:11 +00:00
using CodeImp.DoomBuilder.Editing ;
2008-05-29 11:54:45 +00:00
using CodeImp.DoomBuilder.Controls ;
2007-12-26 00:31:32 +00:00
#endregion
2008-05-29 11:54:45 +00:00
namespace CodeImp.DoomBuilder.Windows
2007-12-26 00:31:32 +00:00
{
2008-01-02 21:49:43 +00:00
internal partial class LinedefEditForm : DelayedForm
2007-12-26 00:31:32 +00:00
{
// Variables
private ICollection < Linedef > lines ;
// Constructor
public LinedefEditForm ( )
{
// Initialize
InitializeComponent ( ) ;
2007-12-29 15:50:16 +00:00
// Fill flags list
2008-05-31 19:31:45 +00:00
foreach ( KeyValuePair < string , string > lf in General . Map . Config . LinedefFlags )
flags . Add ( lf . Value , lf . Key ) ;
2007-12-26 00:31:32 +00:00
2007-12-29 15:50:16 +00:00
// Fill actions list
2008-02-22 17:11:29 +00:00
action . GeneralizedCategories = General . Map . Config . GenActionCategories ;
2007-12-26 00:31:32 +00:00
action . AddInfo ( General . Map . Config . SortedLinedefActions . ToArray ( ) ) ;
2007-12-27 01:24:11 +00:00
2007-12-29 15:50:16 +00:00
// Fill activations list
activation . Items . AddRange ( General . Map . Config . LinedefActivates . ToArray ( ) ) ;
2008-05-31 19:31:45 +00:00
foreach ( LinedefActivateInfo ai in General . Map . Config . LinedefActivates ) udmfactivates . Add ( ai . Title , ai ) ;
2007-12-29 15:50:16 +00:00
2008-01-25 19:12:34 +00:00
// Fill universal fields list
fieldslist . ListFixedFields ( General . Map . Config . LinedefFields ) ;
2007-12-27 01:24:11 +00:00
// Initialize image selectors
fronthigh . Initialize ( ) ;
frontmid . Initialize ( ) ;
frontlow . Initialize ( ) ;
backhigh . Initialize ( ) ;
backmid . Initialize ( ) ;
backlow . Initialize ( ) ;
2007-12-29 15:50:16 +00:00
2008-05-30 22:14:12 +00:00
// Initialize custom fields editor
2008-06-02 04:55:51 +00:00
fieldslist . Setup ( "linedef" ) ;
2008-05-30 22:14:12 +00:00
2009-04-08 19:11:40 +00:00
// Mixed activations? (UDMF)
if ( General . Map . FormatInterface . HasMixedActivations )
2008-05-31 19:31:45 +00:00
udmfpanel . Visible = true ;
2009-04-08 19:11:40 +00:00
else if ( General . Map . FormatInterface . HasPresetActivations )
2008-05-31 19:31:45 +00:00
hexenpanel . Visible = true ;
2009-04-08 19:11:40 +00:00
// Action arguments?
if ( General . Map . FormatInterface . HasActionArgs )
2008-05-31 19:31:45 +00:00
argspanel . Visible = true ;
2009-04-08 19:11:40 +00:00
// Custom fields?
if ( ! General . Map . FormatInterface . HasCustomFields )
tabs . TabPages . Remove ( tabcustom ) ;
// Arrange panels
2009-04-09 05:49:04 +00:00
if ( General . Map . FormatInterface . HasPresetActivations )
2009-04-08 19:11:40 +00:00
{
2008-05-31 19:31:45 +00:00
actiongroup . Height = 210 ;
this . Height = 510 ;
}
2009-04-09 05:49:04 +00:00
else if ( ! General . Map . FormatInterface . HasMixedActivations & &
! General . Map . FormatInterface . HasActionArgs & &
! General . Map . FormatInterface . HasPresetActivations )
2008-05-31 19:31:45 +00:00
{
actiongroup . Height = 68 ;
this . Height = 470 ;
}
2009-04-08 19:11:40 +00:00
// Tag?
if ( General . Map . FormatInterface . HasLinedefTag )
2008-05-31 19:31:45 +00:00
{
// Match position after the action group
idgroup . Top = actiongroup . Bottom + actiongroup . Margin . Bottom + idgroup . Margin . Top ;
}
else
{
idgroup . Visible = false ;
}
2007-12-26 00:31:32 +00:00
}
2009-04-08 19:11:40 +00:00
2007-12-26 00:31:32 +00:00
// This sets up the form to edit the given lines
public void Setup ( ICollection < Linedef > lines )
{
2007-12-29 15:50:16 +00:00
LinedefActivateInfo sai ;
2007-12-27 01:24:11 +00:00
Linedef fl ;
2007-12-26 00:31:32 +00:00
// Keep this list
this . lines = lines ;
2007-12-29 17:10:49 +00:00
if ( lines . Count > 1 ) this . Text = "Edit Linedefs (" + lines . Count + ")" ;
2007-12-27 01:24:11 +00:00
////////////////////////////////////////////////////////////////////////
// Set all options to the first linedef properties
////////////////////////////////////////////////////////////////////////
// Get first line
2009-01-04 09:54:15 +00:00
fl = General . GetByIndex ( lines , 0 ) ;
2007-12-27 01:24:11 +00:00
// Flags
2007-12-26 00:31:32 +00:00
foreach ( CheckBox c in flags . Checkboxes )
2008-06-01 20:25:46 +00:00
if ( fl . Flags . ContainsKey ( c . Tag . ToString ( ) ) ) c . Checked = fl . Flags [ c . Tag . ToString ( ) ] ;
2007-12-27 01:24:11 +00:00
2007-12-29 15:50:16 +00:00
// Activations
foreach ( LinedefActivateInfo ai in activation . Items )
2008-05-31 19:31:45 +00:00
if ( ( fl . Activate & ai . Index ) = = ai . Index ) activation . SelectedItem = ai ;
// UDMF Activations
foreach ( CheckBox c in udmfactivates . Checkboxes )
{
LinedefActivateInfo ai = ( c . Tag as LinedefActivateInfo ) ;
2008-06-01 20:25:46 +00:00
if ( fl . Flags . ContainsKey ( ai . Key ) ) c . Checked = fl . Flags [ ai . Key ] ;
2008-05-31 19:31:45 +00:00
}
2007-12-29 15:50:16 +00:00
// Action/tags
2007-12-27 01:24:11 +00:00
action . Value = fl . Action ;
tag . Text = fl . Tag . ToString ( ) ;
2008-05-29 21:09:43 +00:00
arg0 . SetValue ( fl . Args [ 0 ] ) ;
arg1 . SetValue ( fl . Args [ 1 ] ) ;
arg2 . SetValue ( fl . Args [ 2 ] ) ;
arg3 . SetValue ( fl . Args [ 3 ] ) ;
2008-05-29 10:17:26 +00:00
arg4 . SetValue ( fl . Args [ 4 ] ) ;
2007-12-29 15:50:16 +00:00
2007-12-27 01:24:11 +00:00
// Front side and back side checkboxes
frontside . Checked = ( fl . Front ! = null ) ;
backside . Checked = ( fl . Back ! = null ) ;
// Front settings
if ( fl . Front ! = null )
2007-12-26 00:31:32 +00:00
{
2007-12-27 01:24:11 +00:00
fronthigh . TextureName = fl . Front . HighTexture ;
frontmid . TextureName = fl . Front . MiddleTexture ;
frontlow . TextureName = fl . Front . LowTexture ;
2009-01-23 13:58:47 +00:00
fronthigh . Required = fl . Front . HighRequired ( ) ;
frontmid . Required = fl . Front . MiddleRequired ( ) ;
frontlow . Required = fl . Front . LowRequired ( ) ;
2009-03-10 06:46:02 +00:00
frontsector . Text = fl . Map . GetIndexForSector ( fl . Front . Sector ) . ToString ( ) ;
2007-12-27 01:24:11 +00:00
frontoffsetx . Text = fl . Front . OffsetX . ToString ( ) ;
frontoffsety . Text = fl . Front . OffsetY . ToString ( ) ;
}
// Back settings
if ( fl . Back ! = null )
{
backhigh . TextureName = fl . Back . HighTexture ;
backmid . TextureName = fl . Back . MiddleTexture ;
backlow . TextureName = fl . Back . LowTexture ;
2009-01-23 13:58:47 +00:00
backhigh . Required = fl . Back . HighRequired ( ) ;
backmid . Required = fl . Back . MiddleRequired ( ) ;
backlow . Required = fl . Back . LowRequired ( ) ;
2009-03-10 06:46:02 +00:00
backsector . Text = fl . Map . GetIndexForSector ( fl . Back . Sector ) . ToString ( ) ;
2007-12-27 01:24:11 +00:00
backoffsetx . Text = fl . Back . OffsetX . ToString ( ) ;
backoffsety . Text = fl . Back . OffsetY . ToString ( ) ;
}
2008-05-30 22:14:12 +00:00
// Custom fields
fieldslist . SetValues ( fl . Fields , true ) ;
2007-12-27 01:24:11 +00:00
////////////////////////////////////////////////////////////////////////
// Now go for all lines and change the options when a setting is different
////////////////////////////////////////////////////////////////////////
// Go for all lines
foreach ( Linedef l in lines )
{
// Flags
foreach ( CheckBox c in flags . Checkboxes )
2007-12-26 00:31:32 +00:00
{
2008-06-01 20:25:46 +00:00
if ( l . Flags . ContainsKey ( c . Tag . ToString ( ) ) )
2007-12-27 01:24:11 +00:00
{
2008-06-01 20:25:46 +00:00
if ( l . Flags [ c . Tag . ToString ( ) ] ! = c . Checked )
{
c . ThreeState = true ;
c . CheckState = CheckState . Indeterminate ;
}
2007-12-27 01:24:11 +00:00
}
}
2007-12-29 15:50:16 +00:00
// Activations
if ( activation . Items . Count > 0 )
{
sai = ( activation . Items [ 0 ] as LinedefActivateInfo ) ;
foreach ( LinedefActivateInfo ai in activation . Items )
2008-05-31 19:31:45 +00:00
if ( ( l . Activate & ai . Index ) = = ai . Index ) sai = ai ;
2007-12-29 15:50:16 +00:00
if ( sai ! = activation . SelectedItem ) activation . SelectedIndex = - 1 ;
}
2008-05-31 19:31:45 +00:00
// UDMF Activations
foreach ( CheckBox c in udmfactivates . Checkboxes )
{
LinedefActivateInfo ai = ( c . Tag as LinedefActivateInfo ) ;
2008-06-01 20:25:46 +00:00
if ( l . Flags . ContainsKey ( ai . Key ) )
2008-05-31 19:31:45 +00:00
{
2008-06-01 20:25:46 +00:00
if ( c . Checked ! = l . Flags [ ai . Key ] )
{
c . ThreeState = true ;
c . CheckState = CheckState . Indeterminate ;
}
2008-05-31 19:31:45 +00:00
}
}
2007-12-29 15:50:16 +00:00
// Action/tags
2007-12-27 01:24:11 +00:00
if ( l . Action ! = action . Value ) action . Empty = true ;
if ( l . Tag . ToString ( ) ! = tag . Text ) tag . Text = "" ;
2008-05-29 21:09:43 +00:00
if ( l . Args [ 0 ] ! = arg0 . GetResult ( - 1 ) ) arg0 . ClearValue ( ) ;
if ( l . Args [ 1 ] ! = arg1 . GetResult ( - 1 ) ) arg1 . ClearValue ( ) ;
if ( l . Args [ 2 ] ! = arg2 . GetResult ( - 1 ) ) arg2 . ClearValue ( ) ;
if ( l . Args [ 3 ] ! = arg3 . GetResult ( - 1 ) ) arg3 . ClearValue ( ) ;
if ( l . Args [ 4 ] ! = arg4 . GetResult ( - 1 ) ) arg4 . ClearValue ( ) ;
2007-12-27 01:24:11 +00:00
// Front side checkbox
if ( ( l . Front ! = null ) ! = frontside . Checked )
{
frontside . ThreeState = true ;
frontside . CheckState = CheckState . Indeterminate ;
frontside . AutoCheck = false ;
}
// Back side checkbox
if ( ( l . Back ! = null ) ! = backside . Checked )
{
backside . ThreeState = true ;
backside . CheckState = CheckState . Indeterminate ;
backside . AutoCheck = false ;
}
// Front settings
if ( l . Front ! = null )
{
if ( fronthigh . TextureName ! = l . Front . HighTexture ) fronthigh . TextureName = "" ;
if ( frontmid . TextureName ! = l . Front . MiddleTexture ) frontmid . TextureName = "" ;
if ( frontlow . TextureName ! = l . Front . LowTexture ) frontlow . TextureName = "" ;
2009-01-23 13:58:47 +00:00
if ( fronthigh . Required ! = l . Front . HighRequired ( ) ) fronthigh . Required = false ;
if ( frontmid . Required ! = l . Front . MiddleRequired ( ) ) frontmid . Required = false ;
if ( frontlow . Required ! = l . Front . LowRequired ( ) ) frontlow . Required = false ;
2009-03-10 06:46:02 +00:00
if ( frontsector . Text ! = l . Map . GetIndexForSector ( l . Front . Sector ) . ToString ( ) ) frontsector . Text = "" ;
2007-12-27 01:24:11 +00:00
if ( frontoffsetx . Text ! = l . Front . OffsetX . ToString ( ) ) frontoffsetx . Text = "" ;
if ( frontoffsety . Text ! = l . Front . OffsetY . ToString ( ) ) frontoffsety . Text = "" ;
2009-04-08 20:49:35 +00:00
if ( General . Map . FormatInterface . HasCustomFields ) customfrontbutton . Visible = true ;
2007-12-27 01:24:11 +00:00
}
// Back settings
if ( l . Back ! = null )
{
if ( backhigh . TextureName ! = l . Back . HighTexture ) backhigh . TextureName = "" ;
if ( backmid . TextureName ! = l . Back . MiddleTexture ) backmid . TextureName = "" ;
if ( backlow . TextureName ! = l . Back . LowTexture ) backlow . TextureName = "" ;
2009-01-23 13:58:47 +00:00
if ( backhigh . Required ! = l . Back . HighRequired ( ) ) backhigh . Required = false ;
if ( backmid . Required ! = l . Back . MiddleRequired ( ) ) backmid . Required = false ;
if ( backlow . Required ! = l . Back . LowRequired ( ) ) backlow . Required = false ;
2009-03-10 06:46:02 +00:00
if ( backsector . Text ! = l . Map . GetIndexForSector ( l . Back . Sector ) . ToString ( ) ) backsector . Text = "" ;
2007-12-27 01:24:11 +00:00
if ( backoffsetx . Text ! = l . Back . OffsetX . ToString ( ) ) backoffsetx . Text = "" ;
if ( backoffsety . Text ! = l . Back . OffsetY . ToString ( ) ) backoffsety . Text = "" ;
2009-04-08 20:49:35 +00:00
if ( General . Map . FormatInterface . HasCustomFields ) custombackbutton . Visible = true ;
2007-12-26 00:31:32 +00:00
}
2008-05-30 22:14:12 +00:00
// Custom fields
fieldslist . SetValues ( l . Fields , false ) ;
2007-12-26 00:31:32 +00:00
}
2009-01-23 13:58:47 +00:00
// Refresh controls so that they show their image
backhigh . Refresh ( ) ;
backmid . Refresh ( ) ;
backlow . Refresh ( ) ;
fronthigh . Refresh ( ) ;
frontmid . Refresh ( ) ;
frontlow . Refresh ( ) ;
2007-12-27 01:24:11 +00:00
}
// Front side (un)checked
private void frontside_CheckStateChanged ( object sender , EventArgs e )
{
// Enable/disable panel
// NOTE: Also enabled when checkbox is grayed!
frontgroup . Enabled = ( frontside . CheckState ! = CheckState . Unchecked ) ;
}
2007-12-26 00:31:32 +00:00
2007-12-27 01:24:11 +00:00
// Back side (un)checked
private void backside_CheckStateChanged ( object sender , EventArgs e )
{
// Enable/disable panel
// NOTE: Also enabled when checkbox is grayed!
backgroup . Enabled = ( backside . CheckState ! = CheckState . Unchecked ) ;
}
2007-12-26 00:31:32 +00:00
2007-12-27 01:24:11 +00:00
// This selects all text in a textbox
private void SelectAllText ( object sender , EventArgs e )
{
( sender as TextBox ) . SelectAll ( ) ;
}
// Apply clicked
private void apply_Click ( object sender , EventArgs e )
{
string undodesc = "linedef" ;
Sector s ;
int index ;
2009-04-08 19:11:40 +00:00
// Verify the tag
if ( General . Map . FormatInterface . HasLinedefTag & & ( ( tag . GetResult ( 0 ) < 0 ) | | ( tag . GetResult ( 0 ) > General . Map . FormatInterface . HighestTag ) ) )
{
General . ShowWarningMessage ( "Linedef tag must be between 0 and " + General . Map . FormatInterface . HighestTag + "." , MessageBoxButtons . OK ) ;
return ;
}
// Verify the action
if ( ( action . Value < 0 ) | | ( action . Value > General . Map . FormatInterface . HighestAction ) )
{
General . ShowWarningMessage ( "Linedef action must be between 0 and " + General . Map . FormatInterface . HighestAction + "." , MessageBoxButtons . OK ) ;
return ;
}
// Verify texture offsets
if ( ( backoffsetx . GetResult ( 0 ) < General . Map . FormatInterface . MinTextureOffset ) | | ( backoffsetx . GetResult ( 0 ) > General . Map . FormatInterface . MaxTextureOffset ) | |
( backoffsety . GetResult ( 0 ) < General . Map . FormatInterface . MinTextureOffset ) | | ( backoffsety . GetResult ( 0 ) > General . Map . FormatInterface . MaxTextureOffset ) | |
( frontoffsetx . GetResult ( 0 ) < General . Map . FormatInterface . MinTextureOffset ) | | ( frontoffsetx . GetResult ( 0 ) > General . Map . FormatInterface . MaxTextureOffset ) | |
( frontoffsety . GetResult ( 0 ) < General . Map . FormatInterface . MinTextureOffset ) | | ( frontoffsety . GetResult ( 0 ) > General . Map . FormatInterface . MaxTextureOffset ) )
{
General . ShowWarningMessage ( "Texture offset must be between " + General . Map . FormatInterface . MinTextureOffset + " and " + General . Map . FormatInterface . HighestAction + "." , MessageBoxButtons . OK ) ;
return ;
}
2007-12-27 01:24:11 +00:00
// Make undo
if ( lines . Count > 1 ) undodesc = lines . Count + " linedefs" ;
2008-12-24 18:27:13 +00:00
General . Map . UndoRedo . CreateUndo ( "Edit " + undodesc ) ;
2009-02-25 14:52:36 +00:00
2007-12-27 01:24:11 +00:00
// Go for all the lines
2007-12-26 00:31:32 +00:00
foreach ( Linedef l in lines )
{
2007-12-27 01:24:11 +00:00
// Apply all flags
foreach ( CheckBox c in flags . Checkboxes )
{
2008-05-31 19:31:45 +00:00
if ( c . CheckState = = CheckState . Checked ) l . Flags [ c . Tag . ToString ( ) ] = true ;
else if ( c . CheckState = = CheckState . Unchecked ) l . Flags [ c . Tag . ToString ( ) ] = false ;
2007-12-27 01:24:11 +00:00
}
2007-12-29 15:50:16 +00:00
// Apply chosen activation flag
if ( activation . SelectedIndex > - 1 )
2008-05-31 19:31:45 +00:00
l . Activate = ( activation . SelectedItem as LinedefActivateInfo ) . Index ;
// UDMF activations
foreach ( CheckBox c in udmfactivates . Checkboxes )
{
LinedefActivateInfo ai = ( c . Tag as LinedefActivateInfo ) ;
if ( c . CheckState = = CheckState . Checked ) l . Flags [ ai . Key ] = true ;
else if ( c . CheckState = = CheckState . Unchecked ) l . Flags [ ai . Key ] = false ;
}
2007-12-29 15:50:16 +00:00
// Action/tags
2009-04-08 19:11:40 +00:00
l . Tag = General . Clamp ( tag . GetResult ( l . Tag ) , 0 , General . Map . FormatInterface . HighestTag ) ;
2009-02-25 14:52:36 +00:00
if ( ! action . Empty ) l . Action = action . Value ;
if ( l . Action ! = 0 )
{
l . Args [ 0 ] = arg0 . GetResult ( l . Args [ 0 ] ) ;
l . Args [ 1 ] = arg1 . GetResult ( l . Args [ 1 ] ) ;
l . Args [ 2 ] = arg2 . GetResult ( l . Args [ 2 ] ) ;
l . Args [ 3 ] = arg3 . GetResult ( l . Args [ 3 ] ) ;
l . Args [ 4 ] = arg4 . GetResult ( l . Args [ 4 ] ) ;
}
else
{
l . Args [ 0 ] = 0 ;
l . Args [ 1 ] = 0 ;
l . Args [ 2 ] = 0 ;
l . Args [ 3 ] = 0 ;
l . Args [ 4 ] = 0 ;
}
2007-12-27 01:24:11 +00:00
// Remove front side?
if ( ( l . Front ! = null ) & & ( frontside . CheckState = = CheckState . Unchecked ) )
{
l . Front . Dispose ( ) ;
}
// Create or modify front side?
2007-12-29 15:50:16 +00:00
else if ( frontside . CheckState = = CheckState . Checked )
2007-12-27 01:24:11 +00:00
{
// Make sure we have a valid sector (make a new one if needed)
2009-03-10 06:46:02 +00:00
if ( l . Front ! = null ) index = l . Map . GetIndexForSector ( l . Front . Sector ) ; else index = - 1 ;
2007-12-27 01:24:11 +00:00
s = General . Map . Map . GetSectorByIndex ( frontsector . GetResult ( index ) ) ;
if ( s = = null ) s = General . Map . Map . CreateSector ( ) ;
// Create new sidedef?
if ( l . Front = = null ) General . Map . Map . CreateSidedef ( l , true , s ) ;
// Change sector?
if ( l . Front . Sector ! = s ) l . Front . ChangeSector ( s ) ;
// Apply settings
2009-04-08 19:11:40 +00:00
l . Front . OffsetX = General . Clamp ( frontoffsetx . GetResult ( l . Front . OffsetX ) , General . Map . FormatInterface . MinTextureOffset , General . Map . FormatInterface . MaxTextureOffset ) ;
l . Front . OffsetY = General . Clamp ( frontoffsety . GetResult ( l . Front . OffsetY ) , General . Map . FormatInterface . MinTextureOffset , General . Map . FormatInterface . MaxTextureOffset ) ;
2007-12-27 01:24:11 +00:00
l . Front . SetTextureHigh ( fronthigh . GetResult ( l . Front . HighTexture ) ) ;
l . Front . SetTextureMid ( frontmid . GetResult ( l . Front . MiddleTexture ) ) ;
l . Front . SetTextureLow ( frontlow . GetResult ( l . Front . LowTexture ) ) ;
}
// Remove back side?
if ( ( l . Back ! = null ) & & ( backside . CheckState = = CheckState . Unchecked ) )
{
l . Back . Dispose ( ) ;
}
// Create or modify back side?
2007-12-29 15:50:16 +00:00
else if ( backside . CheckState = = CheckState . Checked )
2007-12-27 01:24:11 +00:00
{
// Make sure we have a valid sector (make a new one if needed)
2009-03-10 06:46:02 +00:00
if ( l . Back ! = null ) index = l . Map . GetIndexForSector ( l . Back . Sector ) ; else index = - 1 ;
2007-12-27 01:24:11 +00:00
s = General . Map . Map . GetSectorByIndex ( backsector . GetResult ( index ) ) ;
if ( s = = null ) s = General . Map . Map . CreateSector ( ) ;
// Create new sidedef?
if ( l . Back = = null ) General . Map . Map . CreateSidedef ( l , false , s ) ;
// Change sector?
if ( l . Back . Sector ! = s ) l . Back . ChangeSector ( s ) ;
// Apply settings
2009-04-08 19:11:40 +00:00
l . Back . OffsetX = General . Clamp ( backoffsetx . GetResult ( l . Back . OffsetX ) , General . Map . FormatInterface . MinTextureOffset , General . Map . FormatInterface . MaxTextureOffset ) ;
l . Back . OffsetY = General . Clamp ( backoffsety . GetResult ( l . Back . OffsetY ) , General . Map . FormatInterface . MinTextureOffset , General . Map . FormatInterface . MaxTextureOffset ) ;
2007-12-27 01:24:11 +00:00
l . Back . SetTextureHigh ( backhigh . GetResult ( l . Back . HighTexture ) ) ;
l . Back . SetTextureMid ( backmid . GetResult ( l . Back . MiddleTexture ) ) ;
l . Back . SetTextureLow ( backlow . GetResult ( l . Back . LowTexture ) ) ;
}
2008-05-30 22:14:12 +00:00
// Custom fields
fieldslist . Apply ( l . Fields ) ;
2007-12-26 00:31:32 +00:00
}
2007-12-27 01:24:11 +00:00
2008-09-28 21:20:56 +00:00
// Update the used textures
General . Map . Data . UpdateUsedTextures ( ) ;
2007-12-27 01:24:11 +00:00
// Done
2008-05-18 11:56:45 +00:00
General . Map . IsChanged = true ;
2007-12-27 01:24:11 +00:00
this . DialogResult = DialogResult . OK ;
this . Close ( ) ;
}
// Cancel clicked
private void cancel_Click ( object sender , EventArgs e )
{
// Be gone
this . DialogResult = DialogResult . Cancel ;
this . Close ( ) ;
}
// This finds a new (unused) tag
private void newtag_Click ( object sender , EventArgs e )
{
tag . Text = General . Map . Map . GetNewTag ( ) . ToString ( ) ;
2007-12-26 00:31:32 +00:00
}
2007-12-29 15:50:16 +00:00
// Action changes
private void action_ValueChanges ( object sender , EventArgs e )
{
int showaction = 0 ;
// Only when line type is known
if ( General . Map . Config . LinedefActions . ContainsKey ( action . Value ) ) showaction = action . Value ;
// Change the argument descriptions
2008-05-29 16:44:20 +00:00
arg0label . Text = General . Map . Config . LinedefActions [ showaction ] . Args [ 0 ] . Title + ":" ;
arg1label . Text = General . Map . Config . LinedefActions [ showaction ] . Args [ 1 ] . Title + ":" ;
arg2label . Text = General . Map . Config . LinedefActions [ showaction ] . Args [ 2 ] . Title + ":" ;
arg3label . Text = General . Map . Config . LinedefActions [ showaction ] . Args [ 3 ] . Title + ":" ;
arg4label . Text = General . Map . Config . LinedefActions [ showaction ] . Args [ 4 ] . Title + ":" ;
arg0label . Enabled = General . Map . Config . LinedefActions [ showaction ] . Args [ 0 ] . Used ;
arg1label . Enabled = General . Map . Config . LinedefActions [ showaction ] . Args [ 1 ] . Used ;
arg2label . Enabled = General . Map . Config . LinedefActions [ showaction ] . Args [ 2 ] . Used ;
arg3label . Enabled = General . Map . Config . LinedefActions [ showaction ] . Args [ 3 ] . Used ;
arg4label . Enabled = General . Map . Config . LinedefActions [ showaction ] . Args [ 4 ] . Used ;
2007-12-29 15:50:16 +00:00
if ( arg0label . Enabled ) arg0 . ForeColor = SystemColors . WindowText ; else arg0 . ForeColor = SystemColors . GrayText ;
if ( arg1label . Enabled ) arg1 . ForeColor = SystemColors . WindowText ; else arg1 . ForeColor = SystemColors . GrayText ;
if ( arg2label . Enabled ) arg2 . ForeColor = SystemColors . WindowText ; else arg2 . ForeColor = SystemColors . GrayText ;
if ( arg3label . Enabled ) arg3 . ForeColor = SystemColors . WindowText ; else arg3 . ForeColor = SystemColors . GrayText ;
if ( arg4label . Enabled ) arg4 . ForeColor = SystemColors . WindowText ; else arg4 . ForeColor = SystemColors . GrayText ;
2008-05-29 21:09:43 +00:00
arg0 . Setup ( General . Map . Config . LinedefActions [ showaction ] . Args [ 0 ] ) ;
arg1 . Setup ( General . Map . Config . LinedefActions [ showaction ] . Args [ 1 ] ) ;
arg2 . Setup ( General . Map . Config . LinedefActions [ showaction ] . Args [ 2 ] ) ;
arg3 . Setup ( General . Map . Config . LinedefActions [ showaction ] . Args [ 3 ] ) ;
arg4 . Setup ( General . Map . Config . LinedefActions [ showaction ] . Args [ 4 ] ) ;
2007-12-29 15:50:16 +00:00
}
// Browse Action clicked
private void browseaction_Click ( object sender , EventArgs e )
{
action . Value = ActionBrowserForm . BrowseAction ( this , action . Value ) ;
}
2008-06-01 20:25:46 +00:00
// Custom fields on front sides
private void customfrontbutton_Click ( object sender , EventArgs e )
{
// Make collection of front sides
List < MapElement > sides = new List < MapElement > ( lines . Count ) ;
foreach ( Linedef l in lines ) if ( l . Front ! = null ) sides . Add ( l . Front ) ;
// Edit these
2008-06-02 04:55:51 +00:00
CustomFieldsForm . ShowDialog ( this , "Front side custom fields" , "sidedef" , sides , General . Map . Config . SidedefFields ) ;
2008-06-01 20:25:46 +00:00
}
// Custom fields on back sides
private void custombackbutton_Click ( object sender , EventArgs e )
{
// Make collection of back sides
List < MapElement > sides = new List < MapElement > ( lines . Count ) ;
foreach ( Linedef l in lines ) if ( l . Back ! = null ) sides . Add ( l . Back ) ;
// Edit these
2008-06-02 04:55:51 +00:00
CustomFieldsForm . ShowDialog ( this , "Back side custom fields" , "sidedef" , sides , General . Map . Config . SidedefFields ) ;
2008-06-01 20:25:46 +00:00
}
2009-04-05 19:29:27 +00:00
// Help!
private void LinedefEditForm_HelpRequested ( object sender , HelpEventArgs hlpevent )
{
General . ShowHelp ( "w_linedefedit.html" ) ;
hlpevent . Handled = true ;
}
2007-12-26 00:31:32 +00:00
}
}