From da9a1af21a0debdef5534daa88c0bd0349514a26 Mon Sep 17 00:00:00 2001 From: codeimp Date: Sun, 30 Sep 2007 20:07:14 +0000 Subject: [PATCH] miauw. --- Source/Interface/MapOptionsForm.Designer.cs | 21 +-- Source/Interface/MapOptionsForm.cs | 22 +++- Source/Interface/MapOptionsForm.resx | 36 ++++++ .../Interface/OpenMapOptionsForm.Designer.cs | 2 + Source/Interface/OpenMapOptionsForm.cs | 122 ++++++++++-------- Source/Interface/ResourceListEditor.cs | 2 +- 6 files changed, 138 insertions(+), 67 deletions(-) diff --git a/Source/Interface/MapOptionsForm.Designer.cs b/Source/Interface/MapOptionsForm.Designer.cs index 3a2fc1b6..6b8821e8 100644 --- a/Source/Interface/MapOptionsForm.Designer.cs +++ b/Source/Interface/MapOptionsForm.Designer.cs @@ -105,7 +105,18 @@ namespace CodeImp.DoomBuilder.Interface this.config.Location = new System.Drawing.Point(129, 31); this.config.Name = "config"; this.config.Size = new System.Drawing.Size(213, 22); + this.config.Sorted = true; 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 // @@ -145,20 +156,12 @@ namespace CodeImp.DoomBuilder.Interface // // resourcelocations // + this.resourcelocations.DialogOffset = new System.Drawing.Point(40, 20); this.resourcelocations.Location = new System.Drawing.Point(15, 28); this.resourcelocations.Name = "resourcelocations"; this.resourcelocations.Size = new System.Drawing.Size(336, 130); 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 // this.AcceptButton = this.apply; diff --git a/Source/Interface/MapOptionsForm.cs b/Source/Interface/MapOptionsForm.cs index daeae8fd..3cfa29bc 100644 --- a/Source/Interface/MapOptionsForm.cs +++ b/Source/Interface/MapOptionsForm.cs @@ -40,6 +40,8 @@ namespace CodeImp.DoomBuilder.Interface // Constructor public MapOptionsForm(MapOptions options) { + int index; + // Initialize InitializeComponent(); @@ -50,13 +52,13 @@ namespace CodeImp.DoomBuilder.Interface for(int i = 0; i < General.Configs.Count; i++) { // Add config name to list - config.Items.Add(General.Configs[i].Name); + index = config.Items.Add(General.Configs[i]); // Is this configuration currently selected? if(string.Compare(General.Configs[i].Filename, options.ConfigFile, true) == 0) { // 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.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); + } + } } } \ No newline at end of file diff --git a/Source/Interface/MapOptionsForm.resx b/Source/Interface/MapOptionsForm.resx index 17bdcd9f..c49b3d93 100644 --- a/Source/Interface/MapOptionsForm.resx +++ b/Source/Interface/MapOptionsForm.resx @@ -117,19 +117,55 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + True + False + + True + False + + True + False False + + True + + + True + + + True + + + True + False + + True + + + True + + + True + + + True + + + True + \ No newline at end of file diff --git a/Source/Interface/OpenMapOptionsForm.Designer.cs b/Source/Interface/OpenMapOptionsForm.Designer.cs index 31dbb44b..d2b2d9bc 100644 --- a/Source/Interface/OpenMapOptionsForm.Designer.cs +++ b/Source/Interface/OpenMapOptionsForm.Designer.cs @@ -91,6 +91,7 @@ namespace CodeImp.DoomBuilder.Interface // // resourcelocations // + this.resourcelocations.DialogOffset = new System.Drawing.Point(40, 20); this.resourcelocations.Location = new System.Drawing.Point(14, 26); this.resourcelocations.Name = "resourcelocations"; 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.Name = "config"; this.config.Size = new System.Drawing.Size(213, 22); + this.config.Sorted = true; this.config.TabIndex = 15; this.config.SelectedIndexChanged += new System.EventHandler(this.config_SelectedIndexChanged); // diff --git a/Source/Interface/OpenMapOptionsForm.cs b/Source/Interface/OpenMapOptionsForm.cs index f7d99374..fce72545 100644 --- a/Source/Interface/OpenMapOptionsForm.cs +++ b/Source/Interface/OpenMapOptionsForm.cs @@ -59,6 +59,7 @@ namespace CodeImp.DoomBuilder.Interface { string dbsfile; string gameconfig; + int index; // Busy Cursor.Current = Cursors.WaitCursor; @@ -91,13 +92,13 @@ namespace CodeImp.DoomBuilder.Interface for(int i = 0; i < General.Configs.Count; i++) { // 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? if(General.Configs[i].Filename == gameconfig) { // 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) { List mapnames; + ConfigurationInfo ci; Configuration cfg; IDictionary maplumpnames; int scanindex, checkoffset; int lumpsfound, lumpsrequired = 0; string lumpname, selectedname = ""; - // Keep selected name, if any - if(mapslist.SelectedItems.Count > 0) - selectedname = mapslist.SelectedItems[0].Text; + // Anything selected? + if(config.SelectedIndex > -1) + { + // Keep selected name, if any + if(mapslist.SelectedItems.Count > 0) + selectedname = mapslist.SelectedItems[0].Text; - // Make an array for the map names - mapnames = new List(); - - // 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 - if(cfg.ReadSetting("maplumpnames." + ml.Key + ".required", false)) lumpsrequired++; - } - - // Go for all the lumps in the wad - for(scanindex = 0; scanindex < (wadfile.Lumps.Count - 1); scanindex++) - { - // Make sure this lump is not part of the map - if(!maplumpnames.Contains(wadfile.Lumps[scanindex].Name)) + // Make an array for the map names + mapnames = new List(); + + // Get selected configuration info + 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 - lumpsfound = 0; - checkoffset = 1; + // Read lump setting and count it + if(cfg.ReadSetting("maplumpnames." + ml.Key + ".required", false)) lumpsrequired++; + } - // Continue while still within bounds and lumps are still recognized - while(((scanindex + checkoffset) < wadfile.Lumps.Count) && - maplumpnames.Contains(wadfile.Lumps[scanindex + checkoffset].Name)) + // Go for all the lumps in the wad + for(scanindex = 0; scanindex < (wadfile.Lumps.Count - 1); scanindex++) + { + // 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 - lumpname = wadfile.Lumps[scanindex + checkoffset].Name; - if(cfg.ReadSetting("maplumpnames." + lumpname + ".required", false)) lumpsfound++; + // Reset check + lumpsfound = 0; + checkoffset = 1; - // Check the next lump - checkoffset++; + // Continue while still within bounds and lumps are still recognized + 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 - mapslist.Items.Clear(); - mapslist.Items.AddRange(mapnames.ToArray()); - mapslist.Sort(); - // Go for all items in the list - foreach(ListViewItem item in mapslist.Items) - { - // Was this item previously selected? - if(item.Text == selectedname) + // Clear the list and add the new map names + mapslist.Items.Clear(); + mapslist.Items.AddRange(mapnames.ToArray()); + mapslist.Sort(); + + // Go for all items in the list + foreach(ListViewItem item in mapslist.Items) { - // Select it again - item.Selected = true; - break; + // Was this item previously selected? + if(item.Text == selectedname) + { + // Select it again + item.Selected = true; + break; + } } + + // Show configuration resources + resourcelocations.FixedResourceLocationList(ci.Resources); } } diff --git a/Source/Interface/ResourceListEditor.cs b/Source/Interface/ResourceListEditor.cs index b2a7d371..a3bf4f7c 100644 --- a/Source/Interface/ResourceListEditor.cs +++ b/Source/Interface/ResourceListEditor.cs @@ -63,7 +63,7 @@ namespace CodeImp.DoomBuilder.Interface } // 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 resourceitems.Items.Insert(0, new ListViewItem(list[i].location));