2009-04-19 18:07:22 +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 ;
2014-12-16 09:01:52 +00:00
using System.Drawing ;
using System.IO ;
2009-04-19 18:07:22 +00:00
using System.Windows.Forms ;
using CodeImp.DoomBuilder.Config ;
2014-12-16 09:01:52 +00:00
using CodeImp.DoomBuilder.Data ;
2009-04-19 18:07:22 +00:00
using CodeImp.DoomBuilder.Editing ;
2012-11-02 23:11:38 +00:00
using CodeImp.DoomBuilder.GZBuilder.Data ;
2009-04-19 18:07:22 +00:00
#endregion
namespace CodeImp.DoomBuilder.Windows
{
internal partial class ConfigForm : DelayedForm
{
// Variables
private GameConfiguration gameconfig ;
private ConfigurationInfo configinfo ;
private List < DefinedTextureSet > copiedsets ;
2014-02-18 14:04:14 +00:00
private bool preventchanges ;
private bool reloadresources ;
2009-05-13 22:46:03 +00:00
2014-07-16 13:40:42 +00:00
//mxd. "Copy/Paste" stuff
private ConfigurationInfo configinfocopy ;
2009-05-13 22:46:03 +00:00
// Properties
public bool ReloadResources { get { return reloadresources ; } }
2009-04-19 18:07:22 +00:00
// Constructor
public ConfigForm ( )
{
ListViewItem lvi ;
// Initialize
InitializeComponent ( ) ;
// Make list column header full width
columnname . Width = listconfigs . ClientRectangle . Width - SystemInformation . VerticalScrollBarWidth - 2 ;
// Fill list of configurations
foreach ( ConfigurationInfo ci in General . Configs )
{
// Add a copy
lvi = listconfigs . Items . Add ( ci . Name ) ;
lvi . Tag = ci . Clone ( ) ;
2014-02-18 14:04:14 +00:00
lvi . Checked = ci . Enabled ; //mxd
lvi . ForeColor = ( ci . Enabled ? SystemColors . WindowText : SystemColors . InactiveCaptionText ) ; //mxd
2009-04-19 18:07:22 +00:00
// This is the current configuration?
if ( ( General . Map ! = null ) & & ( General . Map . ConfigSettings . Filename = = ci . Filename ) )
lvi . Selected = true ;
}
// No skill
skill . Value = 0 ;
// Nodebuilders are allowed to be empty
nodebuildersave . Items . Add ( new NodebuilderInfo ( ) ) ;
nodebuildertest . Items . Add ( new NodebuilderInfo ( ) ) ;
// Fill comboboxes with nodebuilders
nodebuildersave . Items . AddRange ( General . Nodebuilders . ToArray ( ) ) ;
nodebuildertest . Items . AddRange ( General . Nodebuilders . ToArray ( ) ) ;
// Fill list of editing modes
foreach ( EditModeInfo emi in General . Editing . ModesInfo )
{
// Is this mode selectable by the user?
if ( emi . IsOptional )
{
lvi = listmodes . Items . Add ( emi . Attributes . DisplayName ) ;
lvi . Tag = emi ;
lvi . SubItems . Add ( emi . Plugin . Plug . Name ) ;
2014-09-08 13:09:14 +00:00
lvi . UseItemStyleForSubItems = true ; //mxd
2009-04-19 18:07:22 +00:00
}
}
2014-02-18 14:04:14 +00:00
//mxd
listconfigs . ItemChecked + = listconfigs_ItemChecked ;
listconfigs . SelectedIndexChanged + = listconfigs_SelectedIndexChanged ;
//mxd. Trigger change to update the right panel...
listconfigs_MouseUp ( this , new MouseEventArgs ( MouseButtons . None , 0 , 0 , 0 , 0 ) ) ;
2009-04-19 18:07:22 +00:00
}
// This shows a specific page
public void ShowTab ( int index )
{
tabs . SelectedIndex = index ;
}
// Configuration item selected
private void listconfigs_SelectedIndexChanged ( object sender , EventArgs e )
{
// Item selected?
if ( listconfigs . SelectedItems . Count > 0 )
{
// Enable panels
tabs . Enabled = true ;
2009-05-13 22:46:03 +00:00
preventchanges = true ;
2012-11-02 23:11:38 +00:00
//mxd. Store current engine name
2013-09-12 09:51:56 +00:00
if ( configinfo ! = null & & ! String . IsNullOrEmpty ( cbEngineSelector . Text ) )
2012-11-02 23:11:38 +00:00
configinfo . TestProgramName = cbEngineSelector . Text ;
2009-04-19 18:07:22 +00:00
// Get config info of selected item
configinfo = listconfigs . SelectedItems [ 0 ] . Tag as ConfigurationInfo ;
2014-02-18 14:04:14 +00:00
//mxd. Load the game configuration
gameconfig = new GameConfiguration ( configinfo . Configuration ) ;
2009-04-19 18:07:22 +00:00
// Set defaults
configinfo . ApplyDefaults ( gameconfig ) ;
// Fill resources list
configdata . EditResourceLocationList ( configinfo . Resources ) ;
// Go for all nodebuilder save items
nodebuildersave . SelectedIndex = - 1 ;
for ( int i = 0 ; i < nodebuildersave . Items . Count ; i + + )
{
// Get item
2015-10-26 11:58:33 +00:00
NodebuilderInfo ni = nodebuildersave . Items [ i ] as NodebuilderInfo ;
2009-04-19 18:07:22 +00:00
// Item matches configuration setting?
2015-10-26 11:58:33 +00:00
if ( String . CompareOrdinal ( ni . Name , configinfo . NodebuilderSave ) = = 0 )
2009-04-19 18:07:22 +00:00
{
// Select this item
nodebuildersave . SelectedIndex = i ;
break ;
}
}
// Go for all nodebuilder test items
nodebuildertest . SelectedIndex = - 1 ;
for ( int i = 0 ; i < nodebuildertest . Items . Count ; i + + )
{
// Get item
2015-10-26 11:58:33 +00:00
NodebuilderInfo ni = nodebuildertest . Items [ i ] as NodebuilderInfo ;
2009-04-19 18:07:22 +00:00
// Item matches configuration setting?
2015-10-26 11:58:33 +00:00
if ( String . CompareOrdinal ( ni . Name , configinfo . NodebuilderTest ) = = 0 )
2009-04-19 18:07:22 +00:00
{
// Select this item
nodebuildertest . SelectedIndex = i ;
break ;
}
}
// Fill skills list
skill . ClearInfo ( ) ;
skill . AddInfo ( gameconfig . Skills . ToArray ( ) ) ;
2012-11-02 23:11:38 +00:00
2013-03-18 13:52:27 +00:00
//mxd. Fill engines list
cbEngineSelector . Items . Clear ( ) ;
2012-11-02 23:11:38 +00:00
foreach ( EngineInfo info in configinfo . TestEngines )
cbEngineSelector . Items . Add ( info . TestProgramName ) ;
2013-03-18 13:52:27 +00:00
cbEngineSelector . SelectedIndex = configinfo . CurrentEngineIndex ;
2012-11-02 23:11:38 +00:00
btnRemoveEngine . Enabled = configinfo . TestEngines . Count > 1 ;
2009-04-19 18:07:22 +00:00
// Fill texture sets list
listtextures . Items . Clear ( ) ;
foreach ( DefinedTextureSet ts in configinfo . TextureSets )
{
ListViewItem item = listtextures . Items . Add ( ts . Name ) ;
item . Tag = ts ;
item . ImageIndex = 0 ;
}
listtextures . Sort ( ) ;
// Go for all the editing modes in the list
foreach ( ListViewItem lvi in listmodes . Items )
{
EditModeInfo emi = ( lvi . Tag as EditModeInfo ) ;
2014-09-08 13:09:14 +00:00
//mxd. Disable item if the mode does not support current map format
2015-12-28 15:01:53 +00:00
if ( emi . Attributes . SupportedMapFormats ! = null & &
2014-09-08 13:09:14 +00:00
Array . IndexOf ( emi . Attributes . SupportedMapFormats , gameconfig . FormatInterface ) = = - 1 )
{
lvi . Text = emi . Attributes . DisplayName + " (map format not supported)" ;
lvi . ForeColor = SystemColors . GrayText ;
lvi . BackColor = SystemColors . InactiveBorder ;
lvi . Checked = false ;
}
else
{
lvi . Text = emi . Attributes . DisplayName ;
lvi . ForeColor = SystemColors . WindowText ;
lvi . BackColor = SystemColors . Window ;
lvi . Checked = ( configinfo . EditModes . ContainsKey ( emi . Type . FullName ) & & configinfo . EditModes [ emi . Type . FullName ] ) ;
}
2009-04-19 18:07:22 +00:00
}
2014-09-08 13:09:14 +00:00
// Update listmodes columns width (mxd)
listmodes . AutoResizeColumns ( ColumnHeaderAutoResizeStyle . ColumnContent ) ;
2009-07-09 15:15:49 +00:00
// Fill start modes
RefillStartModes ( ) ;
2009-05-13 22:46:03 +00:00
// Done
preventchanges = false ;
2009-04-19 18:07:22 +00:00
}
}
// Key released
private void listconfigs_KeyUp ( object sender , KeyEventArgs e )
{
// Nothing selected?
if ( listconfigs . SelectedItems . Count = = 0 )
{
// Disable panels
gameconfig = null ;
configinfo = null ;
configdata . FixedResourceLocationList ( new DataLocationList ( ) ) ;
configdata . EditResourceLocationList ( new DataLocationList ( ) ) ;
nodebuildersave . SelectedIndex = - 1 ;
nodebuildertest . SelectedIndex = - 1 ;
testapplication . Text = "" ;
testparameters . Text = "" ;
shortpaths . Checked = false ;
skill . Value = 0 ;
skill . ClearInfo ( ) ;
customparameters . Checked = false ;
tabs . Enabled = false ;
listtextures . Items . Clear ( ) ;
}
}
// Mouse released
private void listconfigs_MouseUp ( object sender , MouseEventArgs e )
{
listconfigs_KeyUp ( sender , new KeyEventArgs ( Keys . None ) ) ;
}
2014-02-18 14:04:14 +00:00
//mxd
2014-05-20 09:09:28 +00:00
private void listconfigs_ItemChecked ( object sender , ItemCheckedEventArgs e )
{
2014-02-18 14:04:14 +00:00
e . Item . ForeColor = ( e . Item . Checked ? SystemColors . WindowText : SystemColors . InactiveCaptionText ) ;
}
2009-04-19 18:07:22 +00:00
// Resource locations changed
private void resourcelocations_OnContentChanged ( )
{
// Leave when no configuration selected
if ( configinfo = = null ) return ;
// Apply to selected configuration
configinfo . Resources . Clear ( ) ;
configinfo . Resources . AddRange ( configdata . GetResources ( ) ) ;
2009-05-13 22:46:03 +00:00
if ( ! preventchanges ) reloadresources = true ;
2009-04-19 18:07:22 +00:00
}
// Nodebuilder selection changed
private void nodebuildersave_SelectedIndexChanged ( object sender , EventArgs e )
{
2015-05-26 21:08:12 +00:00
// Leave during setup or when no configuration selected
if ( preventchanges | | configinfo = = null | | nodebuildersave . SelectedItem = = null ) return ;
2009-04-19 18:07:22 +00:00
// Apply to selected configuration
2015-05-26 21:08:12 +00:00
configinfo . NodebuilderSave = ( nodebuildersave . SelectedItem as NodebuilderInfo ) . Name ;
configinfo . Changed = true ; //mxd
2009-04-19 18:07:22 +00:00
}
// Nodebuilder selection changed
private void nodebuildertest_SelectedIndexChanged ( object sender , EventArgs e )
{
2015-05-26 21:08:12 +00:00
// Leave during setup or when no configuration selected
if ( preventchanges | | configinfo = = null | | nodebuildertest . SelectedItem = = null ) return ;
2009-04-19 18:07:22 +00:00
// Apply to selected configuration
2015-05-26 21:08:12 +00:00
configinfo . NodebuilderTest = ( nodebuildertest . SelectedItem as NodebuilderInfo ) . Name ;
configinfo . Changed = true ; //mxd
2009-04-19 18:07:22 +00:00
}
// Test application changed
private void testapplication_TextChanged ( object sender , EventArgs e )
{
2015-03-24 14:21:38 +00:00
// Leave during setup or when no configuration is selected
if ( preventchanges | | configinfo = = null ) return ;
2009-04-19 18:07:22 +00:00
// Apply to selected configuration
2013-09-11 09:47:53 +00:00
configinfo . TestProgram = testapplication . Text ;
2015-03-24 14:21:38 +00:00
//mxd. User entered engine name before picking the engine?
if ( cbEngineSelector . SelectedIndex = = - 1 )
{
ApplyTestEngineNameChange ( ) ;
}
2015-10-23 12:01:27 +00:00
// Update engine name
2015-03-24 14:21:38 +00:00
else
{
2015-10-23 12:01:27 +00:00
// Use engine directory name?
string enginename = Path . GetDirectoryName ( configinfo . TestProgram ) ;
if ( ! string . IsNullOrEmpty ( enginename ) )
{
int pos = enginename . LastIndexOf ( Path . DirectorySeparatorChar ) ;
if ( pos ! = - 1 ) enginename = enginename . Substring ( pos + 1 ) ;
}
// Use engine filename
else
{
enginename = Path . GetFileNameWithoutExtension ( configinfo . TestProgram ) ;
}
configinfo . TestProgramName = enginename ;
cbEngineSelector . Items [ cbEngineSelector . SelectedIndex ] = enginename ;
2015-03-24 14:21:38 +00:00
}
2015-05-26 21:08:12 +00:00
configinfo . Changed = true ; //mxd
2009-04-19 18:07:22 +00:00
}
// Test parameters changed
private void testparameters_TextChanged ( object sender , EventArgs e )
{
// Leave when no configuration selected
2015-05-26 21:08:12 +00:00
if ( preventchanges | | configinfo = = null ) return ;
2009-04-19 18:07:22 +00:00
// Apply to selected configuration
configinfo = listconfigs . SelectedItems [ 0 ] . Tag as ConfigurationInfo ;
2013-09-11 09:47:53 +00:00
configinfo . TestParameters = testparameters . Text ;
2015-05-26 21:08:12 +00:00
configinfo . Changed = true ; //mxd
2009-04-19 18:07:22 +00:00
// Show example result
CreateParametersExample ( ) ;
}
// This creates a new parameters example
private void CreateParametersExample ( )
{
// Map loaded?
if ( General . Map ! = null )
{
// Make converted parameters
testresult . Text = General . Map . Launcher . ConvertParameters ( testparameters . Text , skill . Value , shortpaths . Checked ) ;
}
}
2014-09-08 21:26:30 +00:00
//mxd
private void ApplyTestEngineNameChange ( )
{
int index = ( int ) cbEngineSelector . Tag ;
2014-12-03 23:15:26 +00:00
if ( index ! = - 1 & & cbEngineSelector . Text ! = cbEngineSelector . Items [ index ] . ToString ( ) )
{
2014-09-08 21:26:30 +00:00
cbEngineSelector . Items [ index ] = cbEngineSelector . Text ;
configinfo . TestProgramName = cbEngineSelector . Text ;
configinfo . Changed = true ; //mxd
}
}
2009-04-19 18:07:22 +00:00
// OK clicked
private void apply_Click ( object sender , EventArgs e )
{
ConfigurationInfo ci ;
2014-02-19 09:55:05 +00:00
2014-12-16 09:01:52 +00:00
//mxd. Check resources
2015-12-28 15:01:53 +00:00
for ( int i = 0 ; i < listconfigs . Items . Count ; i + + )
2014-12-16 09:01:52 +00:00
{
// Get configuration item
ci = listconfigs . Items [ i ] . Tag as ConfigurationInfo ;
2014-12-22 21:36:49 +00:00
if ( ! ci . Resources . IsValid ( ) )
2014-12-16 09:01:52 +00:00
{
2016-03-08 20:41:06 +00:00
MessageBox . Show ( this , "At least one resource doesn't exist in \"" + ci . Name + "\" game configuration!" , Application . ProductName , MessageBoxButtons . OK , MessageBoxIcon . Warning ) ;
2014-12-22 21:36:49 +00:00
tabs . SelectedTab = tabresources ;
listconfigs . Focus ( ) ;
listconfigs . Items [ i ] . Selected = true ;
return ;
2014-12-16 09:01:52 +00:00
}
}
2014-09-08 21:26:30 +00:00
//mxd. Apply changes of current test engine name, if there are any
//TODO: move engine selector stuff into separate component!
if ( configinfo ! = null ) ApplyTestEngineNameChange ( ) ;
2014-02-19 09:55:05 +00:00
//mxd. Apply configuration items. They should be in the same order, riiiight?
2014-12-03 23:15:26 +00:00
for ( int i = 0 ; i < listconfigs . Items . Count ; i + + )
{
2009-04-19 18:07:22 +00:00
// Get configuration item
2014-02-19 09:55:05 +00:00
ci = listconfigs . Items [ i ] . Tag as ConfigurationInfo ;
ci . Enabled = listconfigs . Items [ i ] . Checked ;
2014-02-18 14:04:14 +00:00
2014-02-19 09:55:05 +00:00
// Apply settings
General . Configs [ i ] . Enabled = ci . Enabled ;
if ( ci . Changed ) General . Configs [ i ] . Apply ( ci ) ;
2009-04-19 18:07:22 +00:00
}
// Close
this . DialogResult = DialogResult . OK ;
this . Close ( ) ;
}
// Cancel clicked
private void cancel_Click ( object sender , EventArgs e )
{
// Close
this . DialogResult = DialogResult . Cancel ;
this . Close ( ) ;
}
// Browse test program
private void browsetestprogram_Click ( object sender , EventArgs e )
{
// Set initial directory
if ( testapplication . Text . Length > 0 )
{
try { testprogramdialog . InitialDirectory = Path . GetDirectoryName ( testapplication . Text ) ; }
catch ( Exception ) { }
}
// Browse for test program
if ( testprogramdialog . ShowDialog ( ) = = DialogResult . OK )
{
// Apply
testapplication . Text = testprogramdialog . FileName ;
}
}
// Customize parameters (un)checked
private void customparameters_CheckedChanged ( object sender , EventArgs e )
{
// Leave when no configuration selected
if ( configinfo = = null ) return ;
// Apply to selected configuration
configinfo . CustomParameters = customparameters . Checked ;
2014-02-18 14:04:14 +00:00
configinfo . Changed = true ; //mxd
2009-04-19 18:07:22 +00:00
// Update interface
labelparameters . Visible = customparameters . Checked ;
testparameters . Visible = customparameters . Checked ;
shortpaths . Visible = customparameters . Checked ;
// Check if a map is loaded
if ( General . Map ! = null )
{
// Show parameters example result
labelresult . Visible = customparameters . Checked ;
testresult . Visible = customparameters . Checked ;
noresultlabel . Visible = false ;
}
else
{
// Cannot show parameters example result
labelresult . Visible = false ;
testresult . Visible = false ;
noresultlabel . Visible = customparameters . Checked ;
}
}
// Use short paths changed
private void shortpaths_CheckedChanged ( object sender , EventArgs e )
{
// Leave when no configuration selected
if ( configinfo = = null ) return ;
// Apply to selected configuration
configinfo . TestShortPaths = shortpaths . Checked ;
2014-02-18 14:04:14 +00:00
configinfo . Changed = true ; //mxd
2009-04-19 18:07:22 +00:00
CreateParametersExample ( ) ;
}
// Skill changes
private void skill_ValueChanges ( object sender , EventArgs e )
{
// Leave when no configuration selected
if ( configinfo = = null ) return ;
// Apply to selected configuration
configinfo . TestSkill = skill . Value ;
2014-02-18 14:04:14 +00:00
configinfo . Changed = true ; //mxd
2009-04-19 18:07:22 +00:00
CreateParametersExample ( ) ;
}
// Make new texture set
private void addtextureset_Click ( object sender , EventArgs e )
{
DefinedTextureSet s = new DefinedTextureSet ( "New Texture Set" ) ;
TextureSetForm form = new TextureSetForm ( ) ;
form . Setup ( s ) ;
if ( form . ShowDialog ( this ) = = DialogResult . OK )
{
// Add to texture sets
configinfo . TextureSets . Add ( s ) ;
2014-02-18 14:04:14 +00:00
configinfo . Changed = true ; //mxd
2009-04-19 18:07:22 +00:00
ListViewItem item = listtextures . Items . Add ( s . Name ) ;
item . Tag = s ;
item . ImageIndex = 0 ;
listtextures . Sort ( ) ;
2009-05-13 22:46:03 +00:00
reloadresources = true ;
2009-04-19 18:07:22 +00:00
}
}
// Edit texture set
private void edittextureset_Click ( object sender , EventArgs e )
{
// Texture Set selected?
if ( listtextures . SelectedItems . Count > 0 )
{
DefinedTextureSet s = ( listtextures . SelectedItems [ 0 ] . Tag as DefinedTextureSet ) ;
TextureSetForm form = new TextureSetForm ( ) ;
form . Setup ( s ) ;
form . ShowDialog ( this ) ;
listtextures . SelectedItems [ 0 ] . Text = s . Name ;
listtextures . Sort ( ) ;
2009-05-13 22:46:03 +00:00
reloadresources = true ;
2009-04-19 18:07:22 +00:00
}
}
// Remove texture set
private void removetextureset_Click ( object sender , EventArgs e )
{
// Texture Set selected?
while ( listtextures . SelectedItems . Count > 0 )
{
// Remove from config info and list
DefinedTextureSet s = ( listtextures . SelectedItems [ 0 ] . Tag as DefinedTextureSet ) ;
configinfo . TextureSets . Remove ( s ) ;
2014-02-18 14:04:14 +00:00
configinfo . Changed = true ; //mxd
2009-04-19 18:07:22 +00:00
listtextures . SelectedItems [ 0 ] . Remove ( ) ;
2009-05-13 22:46:03 +00:00
reloadresources = true ;
2009-04-19 18:07:22 +00:00
}
}
// Texture Set selected/deselected
private void listtextures_SelectedIndexChanged ( object sender , EventArgs e )
{
edittextureset . Enabled = ( listtextures . SelectedItems . Count > 0 ) ;
removetextureset . Enabled = ( listtextures . SelectedItems . Count > 0 ) ;
copytexturesets . Enabled = ( listtextures . SelectedItems . Count > 0 ) ;
}
// Doubleclicking a texture set
private void listtextures_DoubleClick ( object sender , EventArgs e )
{
edittextureset_Click ( sender , e ) ;
}
// Copy selected texture sets
private void copytexturesets_Click ( object sender , EventArgs e )
{
// Make copies
copiedsets = new List < DefinedTextureSet > ( ) ;
foreach ( ListViewItem item in listtextures . SelectedItems )
{
DefinedTextureSet s = ( item . Tag as DefinedTextureSet ) ;
copiedsets . Add ( s . Copy ( ) ) ;
}
// Enable button
pastetexturesets . Enabled = true ;
}
// Paste copied texture sets
private void pastetexturesets_Click ( object sender , EventArgs e )
{
if ( copiedsets ! = null )
{
// Add copies
foreach ( DefinedTextureSet ts in copiedsets )
{
DefinedTextureSet s = ts . Copy ( ) ;
ListViewItem item = listtextures . Items . Add ( s . Name ) ;
item . Tag = s ;
item . ImageIndex = 0 ;
configinfo . TextureSets . Add ( s ) ;
}
listtextures . Sort ( ) ;
2009-05-13 22:46:03 +00:00
reloadresources = true ;
2014-02-18 14:04:14 +00:00
configinfo . Changed = true ; //mxd
2009-04-19 18:07:22 +00:00
}
}
// This will add the default sets from game configuration
private void restoretexturesets_Click ( object sender , EventArgs e )
{
// Ask nicely first
if ( MessageBox . Show ( this , "This will add the default Texture Sets from the Game Configuration. Do you want to continue?" ,
"Add Default Sets" , MessageBoxButtons . YesNo , MessageBoxIcon . Question ) = = DialogResult . Yes )
{
// Add copies
foreach ( DefinedTextureSet ts in gameconfig . TextureSets )
{
DefinedTextureSet s = ts . Copy ( ) ;
ListViewItem item = listtextures . Items . Add ( s . Name ) ;
item . Tag = s ;
item . ImageIndex = 0 ;
configinfo . TextureSets . Add ( s ) ;
}
listtextures . Sort ( ) ;
2009-05-13 22:46:03 +00:00
reloadresources = true ;
2014-02-18 14:04:14 +00:00
configinfo . Changed = true ; //mxd
2009-04-19 18:07:22 +00:00
}
}
// This is called when an editing mode item is checked or unchecked
private void listmodes_ItemChecked ( object sender , ItemCheckedEventArgs e )
{
2014-01-08 09:46:57 +00:00
if ( preventchanges ) return ; //mxd
2009-04-19 18:07:22 +00:00
// Leave when no configuration selected
if ( configinfo = = null ) return ;
2014-09-08 13:09:14 +00:00
// mxd. Not the best way to detect a disabled item, but we will go with that...
if ( e . Item . ForeColor = = SystemColors . GrayText ) e . Item . Checked = false ;
2009-04-19 18:07:22 +00:00
// Apply changes
EditModeInfo emi = ( e . Item . Tag as EditModeInfo ) ;
bool currentstate = ( configinfo . EditModes . ContainsKey ( emi . Type . FullName ) & & configinfo . EditModes [ emi . Type . FullName ] ) ;
if ( e . Item . Checked & & ! currentstate )
{
// Add
configinfo . EditModes [ emi . Type . FullName ] = true ;
2014-02-18 14:04:14 +00:00
configinfo . Changed = true ; //mxd
2009-04-19 18:07:22 +00:00
}
else if ( ! e . Item . Checked & & currentstate )
{
// Remove
configinfo . EditModes [ emi . Type . FullName ] = false ;
2014-02-18 14:04:14 +00:00
configinfo . Changed = true ; //mxd
2009-04-19 18:07:22 +00:00
}
2009-07-09 15:15:49 +00:00
preventchanges = true ;
RefillStartModes ( ) ;
preventchanges = false ;
2009-04-19 18:07:22 +00:00
}
// Help requested
private void ConfigForm_HelpRequested ( object sender , HelpEventArgs hlpevent )
{
General . ShowHelp ( "w_gameconfigurations.html" ) ;
hlpevent . Handled = true ;
}
2009-07-09 15:15:49 +00:00
// This refills the start mode cobobox
private void RefillStartModes ( )
{
// Refill the startmode combobox
startmode . Items . Clear ( ) ;
foreach ( ListViewItem item in listmodes . Items )
{
if ( item . Checked )
{
EditModeInfo emi = ( item . Tag as EditModeInfo ) ;
if ( emi . Attributes . SafeStartMode )
{
int newindex = startmode . Items . Add ( emi ) ;
if ( emi . Type . Name = = configinfo . StartMode ) startmode . SelectedIndex = newindex ;
}
}
}
// Select the first in the combobox if none are selected
if ( ( startmode . SelectedItem = = null ) & & ( startmode . Items . Count > 0 ) )
{
startmode . SelectedIndex = 0 ;
EditModeInfo emi = ( startmode . SelectedItem as EditModeInfo ) ;
configinfo . StartMode = emi . Type . Name ;
2014-02-18 14:04:14 +00:00
configinfo . Changed = true ; //mxd
2009-07-09 15:15:49 +00:00
}
}
// Start mode combobox changed
private void startmode_SelectedIndexChanged ( object sender , EventArgs e )
{
if ( preventchanges | | ( configinfo = = null ) ) return ;
// Apply start mode
if ( startmode . SelectedItem ! = null )
{
EditModeInfo emi = ( startmode . SelectedItem as EditModeInfo ) ;
configinfo . StartMode = emi . Type . Name ;
2014-02-18 14:04:14 +00:00
configinfo . Changed = true ; //mxd
2009-07-09 15:15:49 +00:00
}
}
2012-11-02 23:11:38 +00:00
2013-09-11 09:47:53 +00:00
//mxd
2014-12-03 23:15:26 +00:00
private void btnNewEngine_Click ( object sender , EventArgs e )
{
2015-03-24 14:21:38 +00:00
preventchanges = true ;
2013-09-11 09:47:53 +00:00
EngineInfo newInfo = new EngineInfo ( ) ;
newInfo . TestSkill = ( int ) Math . Ceiling ( gameconfig . Skills . Count / 2f ) ; //set Medium skill level
configinfo . TestEngines . Add ( newInfo ) ;
2015-10-23 12:01:27 +00:00
configinfo . Changed = true ;
2013-09-11 09:47:53 +00:00
//store current engine name
2012-11-02 23:11:38 +00:00
if ( ! String . IsNullOrEmpty ( cbEngineSelector . Text ) )
configinfo . TestProgramName = cbEngineSelector . Text ;
//refresh engines list
2013-09-11 09:47:53 +00:00
cbEngineSelector . Items . Clear ( ) ;
2012-11-02 23:11:38 +00:00
foreach ( EngineInfo info in configinfo . TestEngines )
cbEngineSelector . Items . Add ( info . TestProgramName ) ;
2013-09-11 09:47:53 +00:00
cbEngineSelector . SelectedIndex = configinfo . TestEngines . Count - 1 ;
btnRemoveEngine . Enabled = true ;
2015-03-24 14:21:38 +00:00
preventchanges = false ;
2015-10-23 12:01:27 +00:00
// Open engine browser
browsetestprogram_Click ( this , EventArgs . Empty ) ;
2013-09-11 09:47:53 +00:00
}
2012-11-02 23:11:38 +00:00
2013-09-11 09:47:53 +00:00
//mxd
2014-12-03 23:15:26 +00:00
private void btnRemoveEngine_Click ( object sender , EventArgs e )
{
2015-03-24 14:21:38 +00:00
preventchanges = true ;
2013-09-11 09:47:53 +00:00
//remove params
int index = cbEngineSelector . SelectedIndex ;
2013-06-14 11:40:18 +00:00
cbEngineSelector . SelectedIndex = - 1 ;
2013-09-11 09:47:53 +00:00
configinfo . TestEngines . RemoveAt ( index ) ;
2014-02-18 14:04:14 +00:00
configinfo . Changed = true ; //mxd
2013-09-11 09:47:53 +00:00
//refresh engines list
cbEngineSelector . Items . Clear ( ) ;
2012-11-02 23:11:38 +00:00
foreach ( EngineInfo info in configinfo . TestEngines )
cbEngineSelector . Items . Add ( info . TestProgramName ) ;
2013-09-12 09:51:56 +00:00
2015-12-28 15:01:53 +00:00
if ( index > = configinfo . TestEngines . Count )
2013-09-11 09:47:53 +00:00
index = configinfo . TestEngines . Count - 1 ;
2012-11-02 23:11:38 +00:00
2013-09-11 09:47:53 +00:00
cbEngineSelector . SelectedIndex = index ;
2012-11-02 23:11:38 +00:00
2015-12-28 15:01:53 +00:00
if ( configinfo . TestEngines . Count < 2 )
2013-09-11 09:47:53 +00:00
btnRemoveEngine . Enabled = false ;
2015-03-24 14:21:38 +00:00
preventchanges = false ;
2013-09-11 09:47:53 +00:00
}
2012-11-02 23:11:38 +00:00
2013-09-11 09:47:53 +00:00
//mxd
2014-12-03 23:15:26 +00:00
private void cbEngineSelector_SelectedIndexChanged ( object sender , EventArgs e )
{
2013-06-14 11:40:18 +00:00
if ( cbEngineSelector . SelectedIndex = = - 1 ) return ;
//set new values
2013-09-11 09:47:53 +00:00
configinfo . CurrentEngineIndex = cbEngineSelector . SelectedIndex ;
2014-02-18 14:04:14 +00:00
configinfo . Changed = true ; //mxd
2012-11-02 23:11:38 +00:00
cbEngineSelector . Tag = cbEngineSelector . SelectedIndex ; //store for later use
2013-09-11 09:47:53 +00:00
// Set test application and parameters
2015-12-28 15:01:53 +00:00
if ( ! configinfo . CustomParameters )
2013-09-11 09:47:53 +00:00
{
configinfo . TestParameters = gameconfig . TestParameters ;
configinfo . TestShortPaths = gameconfig . TestShortPaths ;
}
2012-11-02 23:11:38 +00:00
configinfo . TestProgramName = cbEngineSelector . Text ;
2013-09-11 09:47:53 +00:00
testapplication . Text = configinfo . TestProgram ;
testparameters . Text = configinfo . TestParameters ;
shortpaths . Checked = configinfo . TestShortPaths ;
int skilllevel = configinfo . TestSkill ;
skill . Value = skilllevel - 1 ; //mxd. WHY???
skill . Value = skilllevel ;
customparameters . Checked = configinfo . CustomParameters ;
}
2012-11-02 23:11:38 +00:00
//mxd
2014-12-03 23:15:26 +00:00
private void cbEngineSelector_DropDown ( object sender , EventArgs e )
{
2014-09-08 21:26:30 +00:00
ApplyTestEngineNameChange ( ) ;
2012-11-02 23:11:38 +00:00
}
2013-03-18 13:52:27 +00:00
2014-03-05 09:21:28 +00:00
//mxd
2014-12-03 23:15:26 +00:00
private void ConfigForm_Shown ( object sender , EventArgs e )
{
2015-12-28 15:01:53 +00:00
if ( listconfigs . SelectedItems . Count > 0 ) listconfigs . SelectedItems [ 0 ] . EnsureVisible ( ) ;
2014-03-05 09:21:28 +00:00
}
2014-07-16 13:40:42 +00:00
#region = = = = = = = = = = = = = Copy / Paste context menu ( mxd )
private void copypastemenu_Opening ( object sender , System . ComponentModel . CancelEventArgs e )
{
2015-12-28 15:01:53 +00:00
if ( listconfigs . SelectedIndices . Count < 1 )
2014-07-16 13:40:42 +00:00
{
e . Cancel = true ;
return ;
}
ConfigurationInfo current = listconfigs . SelectedItems [ 0 ] . Tag as ConfigurationInfo ;
bool havecopiedconfig = configinfocopy ! = null ;
bool formatinterfacesmatch = havecopiedconfig & & current . FormatInterface = = configinfocopy . FormatInterface ;
pasteall . Enabled = formatinterfacesmatch ;
Game Configurations: added Vanilla Strife, Vanilla Heretic and Vanilla Hexen game configurations.
Added "makedoorceil" game configuration property. Works the same way as "makedoortrack" and "makedoordoor", but for ceilings of door sectors.
Changed, Game configurations: the editor no longer tries to load DECORATE/MODELDEF/VOXELDEF/GLDEFS/REVERBS lumps when "decorategames" setting is not specified / is set to empty string.
Changed, General interface: "Tools -> Reload MODELDEF/VOXELDEF" and "Tools -> Reload GLDEFS" menu items are no longer shown when current game configuration doesn't support DECORATE.
Fixed a crash when pasting linedef/thing properties in Hexen map format.
Fixed, Visual mode: Visual Thing resources were not fully unloaded when resetting D3D device leading to crash when switching to the editor from a DX-using game engine (like ZDoom) running in fullscreen.
Fixed: in some cases, when current game configuration supported multiple script compilers, it was possible to open/create a map or change map options without selecting any script compiler.
Fixed, New Map Options window: default map name was not updated when switching game configurations.
Fixed: copied map element properties were not reset after switching to another map.
Fixed: stored textures for "Make Door" action were not reset after switching to another map.
Fixed, Game Configurations window: currently selected test engine name was not updated when pasting test engines from another configuration.
Fixed, Game Configurations: all "Heretic in Doom map format" configurations were using Doom sector effects list.
Fixed, Game Configurations: all "Strife in Doom map format" configurations were using Doom sector effects list.
2015-10-21 13:35:42 +00:00
pasteengines . Enabled = ( havecopiedconfig & & configinfocopy . TestEngines . Count > 0 ) ;
pasteresources . Enabled = ( havecopiedconfig & & configinfocopy . Resources . Count > 0 ) ;
pastecolorpresets . Enabled = ( formatinterfacesmatch & & configinfocopy . LinedefColorPresets . Length > 0 ) ;
2014-07-16 13:40:42 +00:00
}
private void copyall_Click ( object sender , EventArgs e )
{
if ( listconfigs . SelectedIndices . Count < 1 ) return ;
ConfigurationInfo current = listconfigs . SelectedItems [ 0 ] . Tag as ConfigurationInfo ;
configinfocopy = current . Clone ( ) ;
//display info
2016-03-08 20:41:06 +00:00
General . Interface . DisplayStatus ( StatusType . Info , "Copied \"" + configinfocopy . Name + "\" game configuration" ) ;
2014-07-16 13:40:42 +00:00
}
private void pasteall_Click ( object sender , EventArgs e )
{
if ( listconfigs . SelectedIndices . Count < 1 ) return ;
//get current configinfo
ConfigurationInfo current = listconfigs . SelectedItems [ 0 ] . Tag as ConfigurationInfo ;
current . PasteFrom ( configinfocopy ) ;
//update display
Game Configurations: added Vanilla Strife, Vanilla Heretic and Vanilla Hexen game configurations.
Added "makedoorceil" game configuration property. Works the same way as "makedoortrack" and "makedoordoor", but for ceilings of door sectors.
Changed, Game configurations: the editor no longer tries to load DECORATE/MODELDEF/VOXELDEF/GLDEFS/REVERBS lumps when "decorategames" setting is not specified / is set to empty string.
Changed, General interface: "Tools -> Reload MODELDEF/VOXELDEF" and "Tools -> Reload GLDEFS" menu items are no longer shown when current game configuration doesn't support DECORATE.
Fixed a crash when pasting linedef/thing properties in Hexen map format.
Fixed, Visual mode: Visual Thing resources were not fully unloaded when resetting D3D device leading to crash when switching to the editor from a DX-using game engine (like ZDoom) running in fullscreen.
Fixed: in some cases, when current game configuration supported multiple script compilers, it was possible to open/create a map or change map options without selecting any script compiler.
Fixed, New Map Options window: default map name was not updated when switching game configurations.
Fixed: copied map element properties were not reset after switching to another map.
Fixed: stored textures for "Make Door" action were not reset after switching to another map.
Fixed, Game Configurations window: currently selected test engine name was not updated when pasting test engines from another configuration.
Fixed, Game Configurations: all "Heretic in Doom map format" configurations were using Doom sector effects list.
Fixed, Game Configurations: all "Strife in Doom map format" configurations were using Doom sector effects list.
2015-10-21 13:35:42 +00:00
cbEngineSelector . Text = string . Empty ; // Otherwise current text from cbEngineSelector will override the pasted one
2014-07-16 13:40:42 +00:00
listconfigs_SelectedIndexChanged ( listconfigs , EventArgs . Empty ) ;
2016-03-08 20:41:06 +00:00
General . Interface . DisplayStatus ( StatusType . Info , "Pasted game configuration from \"" + configinfocopy . Name + "\"" ) ;
2014-07-16 13:40:42 +00:00
}
private void pasteresources_Click ( object sender , EventArgs e )
{
if ( listconfigs . SelectedIndices . Count < 1 ) return ;
//get current configinfo
ConfigurationInfo current = listconfigs . SelectedItems [ 0 ] . Tag as ConfigurationInfo ;
current . PasteResourcesFrom ( configinfocopy ) ;
//update display
listconfigs_SelectedIndexChanged ( listconfigs , EventArgs . Empty ) ;
2016-03-08 20:41:06 +00:00
General . Interface . DisplayStatus ( StatusType . Info , "Pasted resources from \"" + configinfocopy . Name + "\"" ) ;
2014-07-16 13:40:42 +00:00
}
private void pasteengines_Click ( object sender , EventArgs e )
{
if ( listconfigs . SelectedIndices . Count < 1 ) return ;
//get current configinfo
ConfigurationInfo current = listconfigs . SelectedItems [ 0 ] . Tag as ConfigurationInfo ;
current . PasteTestEnginesFrom ( configinfocopy ) ;
//update display
Game Configurations: added Vanilla Strife, Vanilla Heretic and Vanilla Hexen game configurations.
Added "makedoorceil" game configuration property. Works the same way as "makedoortrack" and "makedoordoor", but for ceilings of door sectors.
Changed, Game configurations: the editor no longer tries to load DECORATE/MODELDEF/VOXELDEF/GLDEFS/REVERBS lumps when "decorategames" setting is not specified / is set to empty string.
Changed, General interface: "Tools -> Reload MODELDEF/VOXELDEF" and "Tools -> Reload GLDEFS" menu items are no longer shown when current game configuration doesn't support DECORATE.
Fixed a crash when pasting linedef/thing properties in Hexen map format.
Fixed, Visual mode: Visual Thing resources were not fully unloaded when resetting D3D device leading to crash when switching to the editor from a DX-using game engine (like ZDoom) running in fullscreen.
Fixed: in some cases, when current game configuration supported multiple script compilers, it was possible to open/create a map or change map options without selecting any script compiler.
Fixed, New Map Options window: default map name was not updated when switching game configurations.
Fixed: copied map element properties were not reset after switching to another map.
Fixed: stored textures for "Make Door" action were not reset after switching to another map.
Fixed, Game Configurations window: currently selected test engine name was not updated when pasting test engines from another configuration.
Fixed, Game Configurations: all "Heretic in Doom map format" configurations were using Doom sector effects list.
Fixed, Game Configurations: all "Strife in Doom map format" configurations were using Doom sector effects list.
2015-10-21 13:35:42 +00:00
cbEngineSelector . Text = string . Empty ; // Otherwise current text from cbEngineSelector will override the pasted one
2014-07-16 13:40:42 +00:00
listconfigs_SelectedIndexChanged ( listconfigs , EventArgs . Empty ) ;
2016-03-08 20:41:06 +00:00
General . Interface . DisplayStatus ( StatusType . Info , "Pasted engines list from \"" + configinfocopy . Name + "\"" ) ;
2014-07-16 13:40:42 +00:00
}
private void pastecolorpresets_Click ( object sender , EventArgs e )
{
if ( listconfigs . SelectedIndices . Count < 1 ) return ;
//get current configinfo
ConfigurationInfo current = listconfigs . SelectedItems [ 0 ] . Tag as ConfigurationInfo ;
current . PasteColorPresetsFrom ( configinfocopy ) ;
//update display
listconfigs_SelectedIndexChanged ( listconfigs , EventArgs . Empty ) ;
2016-03-08 20:41:06 +00:00
General . Interface . DisplayStatus ( StatusType . Info , "Pasted color presets from \"" + configinfocopy . Name + "\"" ) ;
2014-07-16 13:40:42 +00:00
}
#endregion
2009-04-19 18:07:22 +00:00
}
}