Added -strictpatches command line parameter to indicate strict patches loading for the WAD file loaded from command line

Added -resource command line parameter to specify additional resources for the WAD file loaded from command line (see cmdargs.txt for more information!)
This commit is contained in:
codeimp 2011-07-26 20:06:38 +00:00
parent 490d2d6024
commit f8905927c3
7 changed files with 173 additions and 17 deletions

View file

@ -4,6 +4,8 @@ Doom Builder 2 command-line arguments
Usage:
builder.exe [wadfile] [-map mapname] [-cfg configname] [-delaywindow] [-nopreferences]
[-strictpatches] [-resource wad|dir|pk3 [roottextures] [rootflats]
[strictpatches] [notest] resourcename]
==========================================================================================
@ -36,6 +38,38 @@ When this parameter is specified, Doom Builder will not load your preferences or
configuration settings and will use the default settings instead. You will not lose your
original settings, but when this parameter is specified your settings will not be saved.
- strictpatches
Specify this parameter to enforce strictly loading texture patches from between P_START
and P_END marker lumps only. This can solve lump name conflicts, but old WAD files do not
always adhere to this rule.
- resource
When -wadfile is specified, the -resource option can be used to add additional resources
that must be loaded along with the wad file. Note that these are added to the resources
which are automatically loaded due to the selection of a game configuration. You can
repeat this option for any number of resources you wish to add. As always, the last
specified resource will override any data in earlier specified resource. This parameter
has the following arguments:
wad|dir|pk3 Either 'wad', 'dir' or 'pk3' must be specified to indicate how this
resource must be loaded. This is the same as selecting the tabs in
the resource options dialog in Doom Builder. This is required.
roottextures This specifies that any images in the root directory of the resource
must be loaded as textures. This is optional and can only be
specified for directory resources.
rootflats This specifies that any images in the root directory of the resource
must be loaded as flats. This is optional and can only be
specified for directory resources.
strictpatches Set this for wad resources to load patches with strict rules to
solve lump name conflicts. Same as -strictpatches described above.
This is optional and can only be specified for wad resources.
notest Indicates that this resource will not be included in the parameters
for the game engine when testing the map. This is optional.
==========================================================================================
Examples:
@ -45,8 +79,14 @@ map-options dialog:
builder.exe "C:\Games\Doom\My Maps\Ubermegawad.wad"
This loads the file "Ubermegawad.wad" after Doom Builder is initialized and shows the
map MAP23 with the game configuration for Doom 2:
Same as the example above, but now without showing the map-options dialog and instead
immediately loads map MAP23 with the game configuration for Doom 2:
builder.exe "C:\Games\Doom\My Maps\Ubermegawad.wad" -map MAP23 -cfg "Doom2.cfg"
Same as the example above, but with added wad file resource and PK3 file resource:
builder.exe "C:\Games\Doom\My Maps\Ubermegawad.wad" -map MAP23 -cfg "Doom2.cfg"
-resource wad strictpatches "C:\Games\Doom\gothtextures.wad"
-resource pk3 "C:\Games\Doom\hardmonsters.pk3"

View file

@ -26,7 +26,7 @@ using System.Text;
namespace CodeImp.DoomBuilder.Data
{
internal struct DataLocation : IComparable<DataLocation>, IComparable, IEquatable<DataLocation>
public struct DataLocation : IComparable<DataLocation>, IComparable, IEquatable<DataLocation>
{
// Constants
public const int RESOURCE_WAD = 0;

View file

@ -28,7 +28,7 @@ using System.Collections.Specialized;
namespace CodeImp.DoomBuilder.Data
{
internal sealed class DataLocationList : List<DataLocation>
public sealed class DataLocationList : List<DataLocation>
{
#region ================== Constructors
@ -36,9 +36,14 @@ namespace CodeImp.DoomBuilder.Data
public DataLocationList()
{
}
// This makes a copy of a list
public DataLocationList(IEnumerable<DataLocation> list) : base(list)
{
}
// This creates a list from a configuration structure
public DataLocationList(Configuration cfg, string path)
internal DataLocationList(Configuration cfg, string path)
{
IDictionary resinfo, rlinfo;
DataLocation res;
@ -81,7 +86,7 @@ namespace CodeImp.DoomBuilder.Data
}
// This writes the list to configuration
public void WriteToConfig(Configuration cfg, string path)
internal void WriteToConfig(Configuration cfg, string path)
{
IDictionary resinfo, rlinfo;

View file

@ -24,6 +24,7 @@ using System.Text;
using System.Windows.Forms;
using System.IO;
using System.Reflection;
using CodeImp.DoomBuilder.Data;
using CodeImp.DoomBuilder.Windows;
using CodeImp.DoomBuilder.IO;
using CodeImp.DoomBuilder.Map;
@ -181,6 +182,8 @@ namespace CodeImp.DoomBuilder
private static string autoloadfile = null;
private static string autoloadmap = null;
private static string autoloadconfig = null;
private static bool autoloadstrictpatches = false;
private static DataLocationList autoloadresources = null;
private static bool delaymainwindow;
private static bool nosettings;
@ -213,6 +216,8 @@ namespace CodeImp.DoomBuilder
public static string AutoLoadFile { get { return autoloadfile; } }
public static string AutoLoadMap { get { return autoloadmap; } }
public static string AutoLoadConfig { get { return autoloadconfig; } }
public static bool AutoLoadStrictPatches { get { return autoloadstrictpatches; } }
public static DataLocationList AutoLoadResources { get { return new DataLocationList(autoloadresources); } }
public static bool DelayMainWindow { get { return delaymainwindow; } }
public static bool NoSettings { get { return nosettings; } }
public static EditingManager Editing { get { return editing; } }
@ -723,6 +728,8 @@ namespace CodeImp.DoomBuilder
// This parses the command line arguments
private static void ParseCommandLineArgs(string[] args)
{
autoloadresources = new DataLocationList();
// Keep a copy
cmdargs = args;
@ -760,6 +767,85 @@ namespace CodeImp.DoomBuilder
// Store next arg as config filename information
autoloadconfig = argslist.Dequeue();
}
// Strict patches rules?
else if(string.Compare(curarg, "-STRICTPATCHES", true) == 0)
{
autoloadstrictpatches = true;
}
// Resource?
else if(string.Compare(curarg, "-RESOURCE", true) == 0)
{
DataLocation dl = new DataLocation();
// Parse resource type
string resourcetype = argslist.Dequeue();
if(string.Compare(resourcetype, "WAD", true) == 0)
dl.type = DataLocation.RESOURCE_WAD;
else if(string.Compare(resourcetype, "DIR", true) == 0)
dl.type = DataLocation.RESOURCE_DIRECTORY;
else if(string.Compare(resourcetype, "PK3", true) == 0)
dl.type = DataLocation.RESOURCE_PK3;
else
{
General.WriteLogLine("Unexpected resource type \"" + resourcetype + "\" in program parameters. Expected \"wad\", \"dir\" or \"pk3\".");
break;
}
// We continue parsing args until an existing filename is found
// all other arguments must be one of the optional keywords.
while(string.IsNullOrEmpty(dl.location))
{
curarg = argslist.Dequeue();
if((string.Compare(curarg, "ROOTTEXTURES", true) == 0) &&
(dl.type == DataLocation.RESOURCE_DIRECTORY))
{
// Load images in the root directory of the resource as textures
dl.option1 = true;
}
else if((string.Compare(curarg, "ROOTFLATS", true) == 0) &&
(dl.type == DataLocation.RESOURCE_DIRECTORY))
{
// Load images in the root directory of the resource as flats
dl.option2 = true;
}
else if((string.Compare(curarg, "STRICTPATCHES", true) == 0) &&
(dl.type == DataLocation.RESOURCE_WAD))
{
// Use strict rules for patches
dl.option1 = true;
}
else if(string.Compare(curarg, "NOTEST", true) == 0)
{
// Exclude this resource from testing parameters
dl.notfortesting = true;
}
else
{
// This must be an existing file, or it is an invalid argument
if(dl.type == DataLocation.RESOURCE_DIRECTORY)
{
if(Directory.Exists(curarg))
dl.location = curarg;
}
else
{
if(File.Exists(curarg))
dl.location = curarg;
}
if(string.IsNullOrEmpty(dl.location))
{
General.WriteLogLine("Unexpected argument \"" + curarg + "\" in program parameters. Expected a valid resource option or a resource filename.");
break;
}
}
}
// Add resource to list
if(!string.IsNullOrEmpty(dl.location))
autoloadresources.Add(dl);
}
// Every other arg
else
{
@ -1011,14 +1097,14 @@ namespace CodeImp.DoomBuilder
mainwindow.Update();
// Open map file
OpenMapFile(openfile.FileName);
OpenMapFile(openfile.FileName, null);
}
openfile.Dispose();
}
// This opens the specified file
internal static void OpenMapFile(string filename)
internal static void OpenMapFile(string filename, MapOptions options)
{
OpenMapOptionsForm openmapwindow;
@ -1029,7 +1115,11 @@ namespace CodeImp.DoomBuilder
if(General.AskSaveMap())
{
// Open map options dialog
openmapwindow = new OpenMapOptionsForm(filename);
if(options != null)
openmapwindow = new OpenMapOptionsForm(filename, options);
else
openmapwindow = new OpenMapOptionsForm(filename);
if(openmapwindow.ShowDialog(mainwindow) == DialogResult.OK)
OpenMapFileWithOptions(filename, openmapwindow.Options);
}

View file

@ -433,6 +433,12 @@ namespace CodeImp.DoomBuilder.Windows
// Set map name and other options
options = new MapOptions(mapsettings, General.AutoLoadMap);
// Set resource data locations
options.CopyResources(General.AutoLoadResources);
// Set strict patches
options.StrictPatches = General.AutoLoadStrictPatches;
// Set configuration file (constructor already does this, but we want this info from the cmd args if possible)
options.ConfigFile = General.AutoLoadConfig;
if(options.ConfigFile == null) options.ConfigFile = mapsettings.ReadSetting("gameconfig", "");
@ -448,7 +454,7 @@ namespace CodeImp.DoomBuilder.Windows
if(showdialog)
{
// Show open dialog
General.OpenMapFile(General.AutoLoadFile);
General.OpenMapFile(General.AutoLoadFile, options);
}
else
{
@ -2056,7 +2062,7 @@ namespace CodeImp.DoomBuilder.Windows
ToolStripItem item = (sender as ToolStripItem);
// Open this file
General.OpenMapFile(item.Tag.ToString());
General.OpenMapFile(item.Tag.ToString(), null);
}
#endregion

View file

@ -55,7 +55,18 @@ namespace CodeImp.DoomBuilder.Windows
InitializeComponent();
this.Text = "Open Map from " + Path.GetFileName(filepathname);
this.filepathname = filepathname;
this.options = new MapOptions();
this.options = null;
}
// Constructor
public OpenMapOptionsForm(string filepathname, MapOptions options)
{
// Initialize
InitializeComponent();
this.Text = "Open Map from " + Path.GetFileName(filepathname);
this.filepathname = filepathname;
this.options = options;
datalocations.EditResourceLocationList(options.Resources);
}
// This loads the settings and attempt to find a suitable config
@ -102,10 +113,16 @@ namespace CodeImp.DoomBuilder.Windows
mapsettings = new Configuration(true);
// Check strict patches box
strictpatches.Checked = mapsettings.ReadSetting("strictpatches", false);
if(options != null)
strictpatches.Checked = options.StrictPatches;
else
strictpatches.Checked = mapsettings.ReadSetting("strictpatches", false);
// Check what game configuration is preferred
gameconfig = mapsettings.ReadSetting("gameconfig", "");
if(options != null)
gameconfig = options.ConfigFile;
else
gameconfig = mapsettings.ReadSetting("gameconfig", "");
// Go for all configurations
for(int i = 0; i < General.Configs.Count; i++)

View file

@ -414,8 +414,6 @@ namespace CodeImp.DoomBuilder.Windows
this.fieldslist.TypeColumnVisible = true;
this.fieldslist.TypeColumnWidth = 100;
this.fieldslist.ValueColumnVisible = true;
this.fieldslist.OnFieldUndefined += new CodeImp.DoomBuilder.Controls.FieldsEditorControl.SingleFieldNameEvent(this.fieldslist_OnFieldUndefined);
this.fieldslist.OnFieldDeleted += new CodeImp.DoomBuilder.Controls.FieldsEditorControl.SingleFieldNameEvent(this.fieldslist_OnFieldDeleted);
//
// flatSelectorControl2
//