UltimateZoneBuilder/Source/Windows/ResourceOptionsForm.cs

212 lines
5.4 KiB
C#
Raw Normal View History

2007-06-16 19:53:51 +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
2007-06-14 23:31:57 +00:00
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using CodeImp.DoomBuilder.Map;
using System.IO;
2007-10-01 20:53:10 +00:00
using CodeImp.DoomBuilder.Data;
using CodeImp.DoomBuilder.Controls;
2007-06-14 23:31:57 +00:00
2007-06-16 19:53:51 +00:00
#endregion
namespace CodeImp.DoomBuilder.Windows
2007-06-14 23:31:57 +00:00
{
2008-01-02 21:49:43 +00:00
internal partial class ResourceOptionsForm : DelayedForm
2007-06-14 23:31:57 +00:00
{
// Variables
2007-10-01 20:53:10 +00:00
private DataLocation res;
2007-06-14 23:31:57 +00:00
// Properties
2007-10-01 20:53:10 +00:00
public DataLocation ResourceLocation { get { return res; } }
2007-06-14 23:31:57 +00:00
// Constructor
2007-10-01 20:53:10 +00:00
public ResourceOptionsForm(DataLocation settings, string caption)
2007-06-14 23:31:57 +00:00
{
// Initialize
InitializeComponent();
2007-06-15 10:18:03 +00:00
// Set caption
this.Text = caption;
2007-06-14 23:31:57 +00:00
// Apply settings from ResourceLocation
this.res = settings;
switch(res.type)
{
// Setup for WAD File
2007-10-01 20:53:10 +00:00
case DataLocation.RESOURCE_WAD:
2007-06-14 23:31:57 +00:00
wadlocation.Text = res.location;
strictpatches.Checked = res.option1;
2007-06-14 23:31:57 +00:00
break;
// Setup for Directory
2007-10-01 20:53:10 +00:00
case DataLocation.RESOURCE_DIRECTORY:
2007-06-14 23:31:57 +00:00
dirlocation.Text = res.location;
dir_textures.Checked = res.option1;
dir_flats.Checked = res.option2;
2007-06-14 23:31:57 +00:00
break;
2007-10-26 14:16:23 +00:00
// Setup for PK3 File
case DataLocation.RESOURCE_PK3:
pk3location.Text = res.location;
break;
2007-06-14 23:31:57 +00:00
}
2007-06-15 10:18:03 +00:00
// Select appropriate tab
tabs.SelectedIndex = res.type;
2007-06-14 23:31:57 +00:00
}
// OK clicked
private void apply_Click(object sender, EventArgs e)
{
// Apply settings to ResourceLocation
switch(tabs.SelectedIndex)
{
// Setup WAD File
2007-10-01 20:53:10 +00:00
case DataLocation.RESOURCE_WAD:
2007-06-14 23:31:57 +00:00
2007-10-26 14:16:23 +00:00
// Check if file is specified
2007-06-14 23:31:57 +00:00
if((wadlocation.Text.Length == 0) ||
(!File.Exists(wadlocation.Text)))
{
// No valid wad file specified
MessageBox.Show(this, "Please select a valid WAD File resource.", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Warning);
}
else
{
// Apply settings
2007-10-01 20:53:10 +00:00
res.type = DataLocation.RESOURCE_WAD;
2007-06-14 23:31:57 +00:00
res.location = wadlocation.Text;
res.option1 = strictpatches.Checked;
res.option2 = false;
2007-06-14 23:31:57 +00:00
// Done
this.DialogResult = DialogResult.OK;
2007-10-14 21:31:45 +00:00
this.Close();
2007-06-14 23:31:57 +00:00
}
break;
// Setup Directory
2007-10-01 20:53:10 +00:00
case DataLocation.RESOURCE_DIRECTORY:
2007-06-14 23:31:57 +00:00
// Check if directory is specified
if((dirlocation.Text.Length == 0) ||
(!Directory.Exists(dirlocation.Text)))
{
// No valid directory specified
MessageBox.Show(this, "Please select a valid directory resource.", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Warning);
}
else
{
// Apply settings
2007-10-01 20:53:10 +00:00
res.type = DataLocation.RESOURCE_DIRECTORY;
2007-06-14 23:31:57 +00:00
res.location = dirlocation.Text;
res.option1 = dir_textures.Checked;
res.option2 = dir_flats.Checked;
2007-06-14 23:31:57 +00:00
// Done
this.DialogResult = DialogResult.OK;
2007-10-14 21:31:45 +00:00
this.Close();
2007-06-14 23:31:57 +00:00
}
break;
2007-10-26 14:16:23 +00:00
// Setup PK3 File
case DataLocation.RESOURCE_PK3:
// Check if file is specified
if((pk3location.Text.Length == 0) ||
(!File.Exists(pk3location.Text)))
{
// No valid pk3 file specified
MessageBox.Show(this, "Please select a valid PK3 File resource.", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Warning);
}
else
{
// Apply settings
res.type = DataLocation.RESOURCE_PK3;
res.location = pk3location.Text;
res.option1 = false;
res.option2 = false;
2007-10-26 14:16:23 +00:00
// Done
this.DialogResult = DialogResult.OK;
this.Close();
}
break;
2007-06-14 23:31:57 +00:00
}
}
// Cancel clicked
private void cancel_Click(object sender, EventArgs e)
{
// Just hide
this.DialogResult = DialogResult.Cancel;
2007-10-14 21:31:45 +00:00
this.Close();
2007-06-14 23:31:57 +00:00
}
2007-06-15 10:18:03 +00:00
// Browse WAD File clicked
private void browsewad_Click(object sender, EventArgs e)
{
// Browse for WAD File
if(wadfiledialog.ShowDialog(this) == DialogResult.OK)
{
// Use this file
wadlocation.Text = wadfiledialog.FileName;
}
}
// Browse Directory clicked
private void browsedir_Click(object sender, EventArgs e)
{
// Browse for Directory
if(dirdialog.ShowDialog(this) == DialogResult.OK)
{
// Use this directory
dirlocation.Text = dirdialog.SelectedPath;
}
}
2007-10-26 14:16:23 +00:00
// Browse PK3 File clicked
private void browsepk3_Click(object sender, EventArgs e)
{
// Browse for PK3 File
if(pk3filedialog.ShowDialog(this) == DialogResult.OK)
{
// Use this file
pk3location.Text = pk3filedialog.FileName;
}
}
// Link clicked
private void link_Click(object sender, LinkLabelLinkClickedEventArgs e)
{
General.OpenWebsite((sender as LinkLabel).Text);
}
2009-04-05 19:29:27 +00:00
// Help
private void ResourceOptionsForm_HelpRequested(object sender, HelpEventArgs hlpevent)
{
General.ShowHelp("w_resourceoptions.html");
hlpevent.Handled = true;
}
2007-06-14 23:31:57 +00:00
}
}