This commit is contained in:
codeimp 2007-09-30 20:07:14 +00:00
parent fc2685a0b5
commit da9a1af21a
6 changed files with 138 additions and 67 deletions

View file

@ -105,7 +105,18 @@ namespace CodeImp.DoomBuilder.Interface
this.config.Location = new System.Drawing.Point(129, 31); this.config.Location = new System.Drawing.Point(129, 31);
this.config.Name = "config"; this.config.Name = "config";
this.config.Size = new System.Drawing.Size(213, 22); this.config.Size = new System.Drawing.Size(213, 22);
this.config.Sorted = true;
this.config.TabIndex = 6; this.config.TabIndex = 6;
this.config.SelectedIndexChanged += new System.EventHandler(this.config_SelectedIndexChanged);
//
// label4
//
label4.Location = new System.Drawing.Point(15, 161);
label4.Name = "label4";
label4.Size = new System.Drawing.Size(336, 34);
label4.TabIndex = 17;
label4.Text = "Drag items to change order (lower items override higher items). Grayed items are " +
"loaded according to the game configuration.";
// //
// apply // apply
// //
@ -145,20 +156,12 @@ namespace CodeImp.DoomBuilder.Interface
// //
// resourcelocations // resourcelocations
// //
this.resourcelocations.DialogOffset = new System.Drawing.Point(40, 20);
this.resourcelocations.Location = new System.Drawing.Point(15, 28); this.resourcelocations.Location = new System.Drawing.Point(15, 28);
this.resourcelocations.Name = "resourcelocations"; this.resourcelocations.Name = "resourcelocations";
this.resourcelocations.Size = new System.Drawing.Size(336, 130); this.resourcelocations.Size = new System.Drawing.Size(336, 130);
this.resourcelocations.TabIndex = 18; this.resourcelocations.TabIndex = 18;
// //
// label4
//
label4.Location = new System.Drawing.Point(15, 161);
label4.Name = "label4";
label4.Size = new System.Drawing.Size(336, 34);
label4.TabIndex = 17;
label4.Text = "Drag items to change order (lower items override higher items). Grayed items are " +
"loaded according to the game configuration.";
//
// MapOptionsForm // MapOptionsForm
// //
this.AcceptButton = this.apply; this.AcceptButton = this.apply;

View file

@ -40,6 +40,8 @@ namespace CodeImp.DoomBuilder.Interface
// Constructor // Constructor
public MapOptionsForm(MapOptions options) public MapOptionsForm(MapOptions options)
{ {
int index;
// Initialize // Initialize
InitializeComponent(); InitializeComponent();
@ -50,13 +52,13 @@ namespace CodeImp.DoomBuilder.Interface
for(int i = 0; i < General.Configs.Count; i++) for(int i = 0; i < General.Configs.Count; i++)
{ {
// Add config name to list // Add config name to list
config.Items.Add(General.Configs[i].Name); index = config.Items.Add(General.Configs[i]);
// Is this configuration currently selected? // Is this configuration currently selected?
if(string.Compare(General.Configs[i].Filename, options.ConfigFile, true) == 0) if(string.Compare(General.Configs[i].Filename, options.ConfigFile, true) == 0)
{ {
// Select this item // Select this item
config.SelectedIndex = config.Items.Count - 1; config.SelectedIndex = index;
} }
} }
@ -106,5 +108,21 @@ namespace CodeImp.DoomBuilder.Interface
this.DialogResult = DialogResult.Cancel; this.DialogResult = DialogResult.Cancel;
this.Hide(); this.Hide();
} }
// Game configuration chosen
private void config_SelectedIndexChanged(object sender, EventArgs e)
{
ConfigurationInfo ci;
// Anything selected?
if(config.SelectedIndex > -1)
{
// Get the info
ci = (ConfigurationInfo)config.SelectedItem;
// Show resources
resourcelocations.FixedResourceLocationList(ci.Resources);
}
}
} }
} }

View file

@ -117,19 +117,55 @@
<resheader name="writer"> <resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader> </resheader>
<metadata name="label3.Locked" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="label3.GenerateMember" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> <metadata name="label3.GenerateMember" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>False</value> <value>False</value>
</metadata> </metadata>
<metadata name="label2.Locked" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="label2.GenerateMember" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> <metadata name="label2.GenerateMember" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>False</value> <value>False</value>
</metadata> </metadata>
<metadata name="label1.Locked" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="label1.GenerateMember" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> <metadata name="label1.GenerateMember" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>False</value> <value>False</value>
</metadata> </metadata>
<metadata name="panelsettings.GenerateMember" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> <metadata name="panelsettings.GenerateMember" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>False</value> <value>False</value>
</metadata> </metadata>
<metadata name="panelsettings.Locked" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="levelname.Locked" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="config.Locked" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="label4.Locked" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="label4.GenerateMember" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> <metadata name="label4.GenerateMember" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>False</value> <value>False</value>
</metadata> </metadata>
<metadata name="apply.Locked" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="cancel.Locked" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="panelres.Locked" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="resourcelocations.Locked" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="$this.Locked" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
</root> </root>

View file

@ -91,6 +91,7 @@ namespace CodeImp.DoomBuilder.Interface
// //
// resourcelocations // resourcelocations
// //
this.resourcelocations.DialogOffset = new System.Drawing.Point(40, 20);
this.resourcelocations.Location = new System.Drawing.Point(14, 26); this.resourcelocations.Location = new System.Drawing.Point(14, 26);
this.resourcelocations.Name = "resourcelocations"; this.resourcelocations.Name = "resourcelocations";
this.resourcelocations.Size = new System.Drawing.Size(336, 127); this.resourcelocations.Size = new System.Drawing.Size(336, 127);
@ -126,6 +127,7 @@ namespace CodeImp.DoomBuilder.Interface
this.config.Location = new System.Drawing.Point(141, 21); this.config.Location = new System.Drawing.Point(141, 21);
this.config.Name = "config"; this.config.Name = "config";
this.config.Size = new System.Drawing.Size(213, 22); this.config.Size = new System.Drawing.Size(213, 22);
this.config.Sorted = true;
this.config.TabIndex = 15; this.config.TabIndex = 15;
this.config.SelectedIndexChanged += new System.EventHandler(this.config_SelectedIndexChanged); this.config.SelectedIndexChanged += new System.EventHandler(this.config_SelectedIndexChanged);
// //

View file

@ -59,6 +59,7 @@ namespace CodeImp.DoomBuilder.Interface
{ {
string dbsfile; string dbsfile;
string gameconfig; string gameconfig;
int index;
// Busy // Busy
Cursor.Current = Cursors.WaitCursor; Cursor.Current = Cursors.WaitCursor;
@ -91,13 +92,13 @@ namespace CodeImp.DoomBuilder.Interface
for(int i = 0; i < General.Configs.Count; i++) for(int i = 0; i < General.Configs.Count; i++)
{ {
// Add config name to list // Add config name to list
config.Items.Add(General.Configs[i].Name); index = config.Items.Add(General.Configs[i]);
// This is the preferred game configuration? // This is the preferred game configuration?
if(General.Configs[i].Filename == gameconfig) if(General.Configs[i].Filename == gameconfig)
{ {
// Select this item // Select this item
config.SelectedIndex = i; config.SelectedIndex = index;
} }
} }
@ -178,75 +179,86 @@ namespace CodeImp.DoomBuilder.Interface
private void config_SelectedIndexChanged(object sender, EventArgs e) private void config_SelectedIndexChanged(object sender, EventArgs e)
{ {
List<ListViewItem> mapnames; List<ListViewItem> mapnames;
ConfigurationInfo ci;
Configuration cfg; Configuration cfg;
IDictionary maplumpnames; IDictionary maplumpnames;
int scanindex, checkoffset; int scanindex, checkoffset;
int lumpsfound, lumpsrequired = 0; int lumpsfound, lumpsrequired = 0;
string lumpname, selectedname = ""; string lumpname, selectedname = "";
// Keep selected name, if any // Anything selected?
if(mapslist.SelectedItems.Count > 0) if(config.SelectedIndex > -1)
selectedname = mapslist.SelectedItems[0].Text;
// Make an array for the map names
mapnames = new List<ListViewItem>();
// Load this configuration
cfg = General.LoadGameConfiguration(General.Configs[config.SelectedIndex].Filename);
// Get the map lump names
maplumpnames = cfg.ReadSetting("maplumpnames", new Hashtable());
// Count how many required lumps we have to find
foreach(DictionaryEntry ml in maplumpnames)
{ {
// Read lump setting and count it // Keep selected name, if any
if(cfg.ReadSetting("maplumpnames." + ml.Key + ".required", false)) lumpsrequired++; if(mapslist.SelectedItems.Count > 0)
} selectedname = mapslist.SelectedItems[0].Text;
// Go for all the lumps in the wad // Make an array for the map names
for(scanindex = 0; scanindex < (wadfile.Lumps.Count - 1); scanindex++) mapnames = new List<ListViewItem>();
{
// Make sure this lump is not part of the map // Get selected configuration info
if(!maplumpnames.Contains(wadfile.Lumps[scanindex].Name)) ci = (ConfigurationInfo)config.SelectedItem;
// Load this configuration
cfg = General.LoadGameConfiguration(ci.Filename);
// Get the map lump names
maplumpnames = cfg.ReadSetting("maplumpnames", new Hashtable());
// Count how many required lumps we have to find
foreach(DictionaryEntry ml in maplumpnames)
{ {
// Reset check // Read lump setting and count it
lumpsfound = 0; if(cfg.ReadSetting("maplumpnames." + ml.Key + ".required", false)) lumpsrequired++;
checkoffset = 1; }
// Continue while still within bounds and lumps are still recognized // Go for all the lumps in the wad
while(((scanindex + checkoffset) < wadfile.Lumps.Count) && for(scanindex = 0; scanindex < (wadfile.Lumps.Count - 1); scanindex++)
maplumpnames.Contains(wadfile.Lumps[scanindex + checkoffset].Name)) {
// Make sure this lump is not part of the map
if(!maplumpnames.Contains(wadfile.Lumps[scanindex].Name))
{ {
// Count the lump when it is marked as required // Reset check
lumpname = wadfile.Lumps[scanindex + checkoffset].Name; lumpsfound = 0;
if(cfg.ReadSetting("maplumpnames." + lumpname + ".required", false)) lumpsfound++; checkoffset = 1;
// Check the next lump // Continue while still within bounds and lumps are still recognized
checkoffset++; while(((scanindex + checkoffset) < wadfile.Lumps.Count) &&
maplumpnames.Contains(wadfile.Lumps[scanindex + checkoffset].Name))
{
// Count the lump when it is marked as required
lumpname = wadfile.Lumps[scanindex + checkoffset].Name;
if(cfg.ReadSetting("maplumpnames." + lumpname + ".required", false)) lumpsfound++;
// Check the next lump
checkoffset++;
}
// Map found? Then add it to the list
if(lumpsfound >= lumpsrequired)
mapnames.Add(new ListViewItem(wadfile.Lumps[scanindex].Name));
} }
// Map found? Then add it to the list
if(lumpsfound >= lumpsrequired)
mapnames.Add(new ListViewItem(wadfile.Lumps[scanindex].Name));
} }
}
// Clear the list and add the new map names // Clear the list and add the new map names
mapslist.Items.Clear(); mapslist.Items.Clear();
mapslist.Items.AddRange(mapnames.ToArray()); mapslist.Items.AddRange(mapnames.ToArray());
mapslist.Sort(); mapslist.Sort();
// Go for all items in the list // Go for all items in the list
foreach(ListViewItem item in mapslist.Items) foreach(ListViewItem item in mapslist.Items)
{
// Was this item previously selected?
if(item.Text == selectedname)
{ {
// Select it again // Was this item previously selected?
item.Selected = true; if(item.Text == selectedname)
break; {
// Select it again
item.Selected = true;
break;
}
} }
// Show configuration resources
resourcelocations.FixedResourceLocationList(ci.Resources);
} }
} }

View file

@ -63,7 +63,7 @@ namespace CodeImp.DoomBuilder.Interface
} }
// Go for all items // Go for all items
for(int i = list.Count; i >= 0; i--) for(int i = list.Count - 1; i >= 0; i--)
{ {
// Add item as fixed // Add item as fixed
resourceitems.Items.Insert(0, new ListViewItem(list[i].location)); resourceitems.Items.Insert(0, new ListViewItem(list[i].location));