2007-09-25 05:57:42 +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 Microsoft.Win32;
|
|
|
|
using System.Diagnostics;
|
2008-05-29 11:34:01 +00:00
|
|
|
using CodeImp.DoomBuilder.Actions;
|
2007-10-09 20:47:08 +00:00
|
|
|
using CodeImp.DoomBuilder.Data;
|
2007-10-21 18:06:10 +00:00
|
|
|
using CodeImp.DoomBuilder.Config;
|
2008-05-23 06:00:37 +00:00
|
|
|
using System.IO;
|
2008-05-29 11:54:45 +00:00
|
|
|
using CodeImp.DoomBuilder.Controls;
|
2007-09-25 05:57:42 +00:00
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
2008-05-29 11:54:45 +00:00
|
|
|
namespace CodeImp.DoomBuilder.Windows
|
2007-09-25 05:57:42 +00:00
|
|
|
{
|
2008-01-02 21:49:43 +00:00
|
|
|
internal partial class ConfigForm : DelayedForm
|
2007-09-25 05:57:42 +00:00
|
|
|
{
|
|
|
|
// Constructor
|
|
|
|
public ConfigForm()
|
|
|
|
{
|
2007-10-09 20:47:08 +00:00
|
|
|
ListViewItem lvi;
|
2007-09-29 15:43:59 +00:00
|
|
|
|
2007-09-25 05:57:42 +00:00
|
|
|
// Initialize
|
|
|
|
InitializeComponent();
|
2007-09-27 22:55:03 +00:00
|
|
|
|
2007-10-09 20:47:08 +00:00
|
|
|
// Make list column header full width
|
|
|
|
columnname.Width = listconfigs.ClientRectangle.Width - SystemInformation.VerticalScrollBarWidth - 2;
|
2007-09-30 19:37:57 +00:00
|
|
|
|
2007-09-27 22:55:03 +00:00
|
|
|
// Fill list of configurations
|
|
|
|
foreach(ConfigurationInfo ci in General.Configs)
|
|
|
|
{
|
|
|
|
// Add a copy
|
2007-10-09 20:47:08 +00:00
|
|
|
lvi = listconfigs.Items.Add(ci.Name);
|
|
|
|
lvi.Tag = ci.Clone();
|
2008-05-23 06:00:37 +00:00
|
|
|
|
|
|
|
// This is the current configuration?
|
|
|
|
if((General.Map != null) && (General.Map.ConfigSettings.Filename == ci.Filename))
|
|
|
|
lvi.Selected = true;
|
2007-09-30 19:37:57 +00:00
|
|
|
}
|
|
|
|
|
2007-10-09 20:47:08 +00:00
|
|
|
// TODO: Save and test nodebuilders are allowed to be empty
|
2007-09-30 19:37:57 +00:00
|
|
|
|
2007-10-09 20:47:08 +00:00
|
|
|
// Fill comboboxes with nodebuilders
|
|
|
|
nodebuildersave.Items.AddRange(General.Nodebuilders.ToArray());
|
|
|
|
nodebuildertest.Items.AddRange(General.Nodebuilders.ToArray());
|
2008-05-23 06:00:37 +00:00
|
|
|
|
|
|
|
// Check if a map is loaded
|
|
|
|
if(General.Map != null)
|
|
|
|
{
|
|
|
|
// Show parameters example result
|
|
|
|
labelresult.Visible = true;
|
|
|
|
testresult.Visible = true;
|
|
|
|
noresultlabel.Visible = false;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// Cannot show parameters example result
|
|
|
|
labelresult.Visible = false;
|
|
|
|
testresult.Visible = false;
|
|
|
|
noresultlabel.Visible = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// This shows a specific page
|
|
|
|
public void ShowTab(int index)
|
|
|
|
{
|
|
|
|
tabs.SelectedIndex = index;
|
2007-09-30 19:37:57 +00:00
|
|
|
}
|
|
|
|
|
2007-09-28 08:56:18 +00:00
|
|
|
// Configuration item selected
|
|
|
|
private void listconfigs_SelectedIndexChanged(object sender, EventArgs e)
|
|
|
|
{
|
2007-09-29 15:43:59 +00:00
|
|
|
ConfigurationInfo ci;
|
|
|
|
NodebuilderInfo ni;
|
2007-09-28 08:56:18 +00:00
|
|
|
|
2007-09-29 15:43:59 +00:00
|
|
|
// Item selected?
|
2007-10-09 20:47:08 +00:00
|
|
|
if(listconfigs.SelectedItems.Count > 0)
|
2007-09-29 15:43:59 +00:00
|
|
|
{
|
|
|
|
// Enable panels
|
2007-10-09 20:47:08 +00:00
|
|
|
tabs.Enabled = true;
|
|
|
|
|
2007-09-29 15:43:59 +00:00
|
|
|
// Get config info of selected item
|
2007-10-09 20:47:08 +00:00
|
|
|
ci = listconfigs.SelectedItems[0].Tag as ConfigurationInfo;
|
2007-09-29 15:43:59 +00:00
|
|
|
|
|
|
|
// Fill resources list
|
2007-10-01 20:53:10 +00:00
|
|
|
configdata.EditResourceLocationList(ci.Resources);
|
2007-09-29 15:43:59 +00:00
|
|
|
|
2007-10-09 20:47:08 +00:00
|
|
|
// Go for all nodebuilder save items
|
|
|
|
nodebuildersave.SelectedIndex = -1;
|
|
|
|
for(int i = 0; i < nodebuildersave.Items.Count; i++)
|
|
|
|
{
|
|
|
|
// Get item
|
|
|
|
ni = nodebuildersave.Items[i] as NodebuilderInfo;
|
|
|
|
|
|
|
|
// Item matches configuration setting?
|
2007-10-10 09:05:53 +00:00
|
|
|
if(string.Compare(ni.Name, ci.NodebuilderSave, false) == 0)
|
2007-10-09 20:47:08 +00:00
|
|
|
{
|
|
|
|
// Select this item
|
|
|
|
nodebuildersave.SelectedIndex = i;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Go for all nodebuilder save items
|
|
|
|
nodebuildertest.SelectedIndex = -1;
|
|
|
|
for(int i = 0; i < nodebuildertest.Items.Count; i++)
|
2007-09-29 15:43:59 +00:00
|
|
|
{
|
|
|
|
// Get item
|
2007-10-09 20:47:08 +00:00
|
|
|
ni = nodebuildertest.Items[i] as NodebuilderInfo;
|
|
|
|
|
|
|
|
// Item matches configuration setting?
|
2007-10-10 09:05:53 +00:00
|
|
|
if(string.Compare(ni.Name, ci.NodebuilderTest, false) == 0)
|
2007-10-09 20:47:08 +00:00
|
|
|
{
|
|
|
|
// Select this item
|
|
|
|
nodebuildertest.SelectedIndex = i;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2007-09-29 15:43:59 +00:00
|
|
|
|
|
|
|
// Set test application and parameters
|
|
|
|
testapplication.Text = ci.TestProgram;
|
|
|
|
testparameters.Text = ci.TestParameters;
|
|
|
|
}
|
2007-10-09 20:47:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Key released
|
|
|
|
private void listconfigs_KeyUp(object sender, KeyEventArgs e)
|
|
|
|
{
|
|
|
|
// Nothing selected?
|
|
|
|
if(listconfigs.SelectedItems.Count == 0)
|
2007-09-29 15:43:59 +00:00
|
|
|
{
|
|
|
|
// Disable panels
|
2007-10-09 20:47:08 +00:00
|
|
|
configdata.FixedResourceLocationList(new DataLocationList());
|
|
|
|
configdata.EditResourceLocationList(new DataLocationList());
|
|
|
|
nodebuildersave.SelectedIndex = -1;
|
|
|
|
nodebuildertest.SelectedIndex = -1;
|
|
|
|
testapplication.Text = "";
|
|
|
|
testparameters.Text = "";
|
|
|
|
tabs.Enabled = false;
|
2007-09-29 15:43:59 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-10-09 20:47:08 +00:00
|
|
|
// Mouse released
|
|
|
|
private void listconfigs_MouseUp(object sender, MouseEventArgs e)
|
|
|
|
{
|
|
|
|
listconfigs_KeyUp(sender, new KeyEventArgs(Keys.None));
|
|
|
|
}
|
|
|
|
|
2007-09-29 15:43:59 +00:00
|
|
|
// Resource locations changed
|
|
|
|
private void resourcelocations_OnContentChanged()
|
|
|
|
{
|
|
|
|
ConfigurationInfo ci;
|
|
|
|
|
2007-10-09 20:47:08 +00:00
|
|
|
// Leave when no configuration selected
|
|
|
|
if(listconfigs.SelectedItems.Count == 0) return;
|
|
|
|
|
2007-09-29 15:43:59 +00:00
|
|
|
// Apply to selected configuration
|
2007-10-09 20:47:08 +00:00
|
|
|
ci = listconfigs.SelectedItems[0].Tag as ConfigurationInfo;
|
2007-09-29 15:43:59 +00:00
|
|
|
ci.Resources.Clear();
|
2007-10-01 20:53:10 +00:00
|
|
|
ci.Resources.AddRange(configdata.GetResources());
|
2007-09-29 15:43:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Nodebuilder selection changed
|
2007-10-09 20:47:08 +00:00
|
|
|
private void nodebuildersave_SelectedIndexChanged(object sender, EventArgs e)
|
2007-09-29 15:43:59 +00:00
|
|
|
{
|
|
|
|
ConfigurationInfo ci;
|
|
|
|
|
2007-10-09 20:47:08 +00:00
|
|
|
// Leave when no configuration selected
|
|
|
|
if(listconfigs.SelectedItems.Count == 0) return;
|
|
|
|
|
2007-09-29 15:43:59 +00:00
|
|
|
// Apply to selected configuration
|
2007-10-09 20:47:08 +00:00
|
|
|
ci = listconfigs.SelectedItems[0].Tag as ConfigurationInfo;
|
|
|
|
if(nodebuildersave.SelectedItem != null)
|
2007-10-10 09:05:53 +00:00
|
|
|
ci.NodebuilderSave = (nodebuildersave.SelectedItem as NodebuilderInfo).Name;
|
2007-09-29 15:43:59 +00:00
|
|
|
}
|
|
|
|
|
2007-10-09 20:47:08 +00:00
|
|
|
// Nodebuilder selection changed
|
|
|
|
private void nodebuildertest_SelectedIndexChanged(object sender, EventArgs e)
|
2007-09-29 15:43:59 +00:00
|
|
|
{
|
|
|
|
ConfigurationInfo ci;
|
|
|
|
|
2007-10-09 20:47:08 +00:00
|
|
|
// Leave when no configuration selected
|
|
|
|
if(listconfigs.SelectedItems.Count == 0) return;
|
|
|
|
|
2007-09-29 15:43:59 +00:00
|
|
|
// Apply to selected configuration
|
2007-10-09 20:47:08 +00:00
|
|
|
ci = listconfigs.SelectedItems[0].Tag as ConfigurationInfo;
|
|
|
|
if(nodebuildertest.SelectedItem != null)
|
2007-10-10 09:05:53 +00:00
|
|
|
ci.NodebuilderTest = (nodebuildertest.SelectedItem as NodebuilderInfo).Name;
|
2007-09-29 15:43:59 +00:00
|
|
|
}
|
2007-10-09 20:47:08 +00:00
|
|
|
|
2007-09-29 15:43:59 +00:00
|
|
|
// Test application changed
|
|
|
|
private void testapplication_TextChanged(object sender, EventArgs e)
|
|
|
|
{
|
|
|
|
ConfigurationInfo ci;
|
|
|
|
|
2007-10-09 20:47:08 +00:00
|
|
|
// Leave when no configuration selected
|
|
|
|
if(listconfigs.SelectedItems.Count == 0) return;
|
|
|
|
|
2007-09-29 15:43:59 +00:00
|
|
|
// Apply to selected configuration
|
2007-10-09 20:47:08 +00:00
|
|
|
ci = listconfigs.SelectedItems[0].Tag as ConfigurationInfo;
|
2007-09-29 15:43:59 +00:00
|
|
|
ci.TestProgram = testapplication.Text;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Test parameters changed
|
|
|
|
private void testparameters_TextChanged(object sender, EventArgs e)
|
|
|
|
{
|
|
|
|
ConfigurationInfo ci;
|
|
|
|
|
2007-10-09 20:47:08 +00:00
|
|
|
// Leave when no configuration selected
|
|
|
|
if(listconfigs.SelectedItems.Count == 0) return;
|
|
|
|
|
2007-09-29 15:43:59 +00:00
|
|
|
// Apply to selected configuration
|
2007-10-09 20:47:08 +00:00
|
|
|
ci = listconfigs.SelectedItems[0].Tag as ConfigurationInfo;
|
2007-09-29 15:43:59 +00:00
|
|
|
ci.TestParameters = testparameters.Text;
|
2008-05-23 06:00:37 +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);
|
|
|
|
}
|
2007-09-29 15:43:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// OK clicked
|
|
|
|
private void apply_Click(object sender, EventArgs e)
|
|
|
|
{
|
2007-10-09 20:47:08 +00:00
|
|
|
ConfigurationInfo ci;
|
2007-09-30 19:37:57 +00:00
|
|
|
|
2007-09-29 15:43:59 +00:00
|
|
|
// Apply configuration items
|
2007-10-09 20:47:08 +00:00
|
|
|
foreach(ListViewItem lvi in listconfigs.Items)
|
2007-09-29 15:43:59 +00:00
|
|
|
{
|
2007-10-09 20:47:08 +00:00
|
|
|
// Get configuration item
|
|
|
|
ci = lvi.Tag as ConfigurationInfo;
|
|
|
|
|
2007-09-29 15:43:59 +00:00
|
|
|
// Find same configuration info in originals
|
|
|
|
foreach(ConfigurationInfo oci in General.Configs)
|
|
|
|
{
|
|
|
|
// Apply settings when they match
|
|
|
|
if(string.Compare(ci.Filename, oci.Filename) == 0) oci.Apply(ci);
|
|
|
|
}
|
|
|
|
}
|
2007-09-30 19:37:57 +00:00
|
|
|
|
2007-09-29 15:43:59 +00:00
|
|
|
// Close
|
|
|
|
this.DialogResult = DialogResult.OK;
|
2007-10-14 21:31:45 +00:00
|
|
|
this.Close();
|
2007-09-29 15:43:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Cancel clicked
|
|
|
|
private void cancel_Click(object sender, EventArgs e)
|
|
|
|
{
|
|
|
|
// Close
|
|
|
|
this.DialogResult = DialogResult.Cancel;
|
2007-10-14 21:31:45 +00:00
|
|
|
this.Close();
|
2007-09-25 05:57:42 +00:00
|
|
|
}
|
2007-09-28 08:56:18 +00:00
|
|
|
|
2008-05-23 06:00:37 +00:00
|
|
|
// Browse test program
|
|
|
|
private void browsetestprogram_Click(object sender, EventArgs e)
|
2007-10-09 20:47:08 +00:00
|
|
|
{
|
2008-05-23 06:00:37 +00:00
|
|
|
// 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;
|
|
|
|
}
|
2007-10-09 20:47:08 +00:00
|
|
|
}
|
2007-09-25 05:57:42 +00:00
|
|
|
}
|
|
|
|
}
|