// Disposer public override void Dispose() { // Not already disposed? if (!isdisposed) { Logger.WriteLogLine("Closing WAD resource '" + location.location + "'"); // Clean up file.Dispose(); // Done base.Dispose(); } }
// OK clicked private void apply_Click(object sender, EventArgs e) { // Configuration selected? if (config.SelectedIndex == -1) { // Select a configuration! MessageBox.Show(this, "Please select a game configuration to use for editing your map.", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Warning); config.Focus(); return; } // Collect information ConfigurationInfo configinfo = General.Configs[config.SelectedIndex]; DataLocationList locations = datalocations.GetResources(); // No map selected? if (mapslist.SelectedItems.Count == 0) { // Choose a map! MessageBox.Show(this, "Please select a map to load for editing.", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Warning); mapslist.Focus(); return; } // Check if we should warn the user for missing resources if ((wadfile.Type != WAD.TYPE_IWAD) && (locations.Count == 0) && (configinfo.Resources.Count == 0)) { if (MessageBox.Show(this, "You are about to load a map without selecting any resources. Textures, flats and " + "sprites may not be shown correctly or may not show up at all. Do you want to continue?", Application.ProductName, MessageBoxButtons.YesNo, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button2) == DialogResult.No) { return; } } // Apply changes options.ClearResources(); options.ConfigFile = configinfo.Filename; options.CurrentName = mapslist.SelectedItems[0].Text; options.StrictPatches = strictpatches.Checked; options.CopyResources(locations); // ano General.Settings.WriteSetting("lastopenedgameconfig", options.ConfigFile); // Hide window wadfile.Dispose(); this.DialogResult = DialogResult.OK; this.Close(); }
// This loads the settings and attempt to find a suitable config private void LoadSettings() { string dbsfile; string gameconfig; int index; // Busy Cursor.Current = Cursors.WaitCursor; // Check if the file exists if (!File.Exists(filepathname)) { // WAD file does not exist MessageBox.Show(this, "Could not open the WAD file: The file does not exist.", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error); this.DialogResult = DialogResult.Cancel; this.Close(); return; } try { // Open the WAD file wadfile = new WAD(filepathname, true); } catch (Exception) { // Unable to open WAD file (or its config) MessageBox.Show(this, "Could not open the WAD file for reading. Please make sure the file you selected is valid and is not in use by any other application.", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error); if (wadfile != null) { wadfile.Dispose(); } this.DialogResult = DialogResult.Cancel; this.Close(); return; } // Open the Map Settings configuration dbsfile = filepathname.Substring(0, filepathname.Length - 4) + ".dbs"; if (File.Exists(dbsfile)) { try { mapsettings = new Configuration(dbsfile, true); } catch (Exception) { mapsettings = new Configuration(true); } } else { mapsettings = new Configuration(true); } // Check strict patches box if (options != null) { strictpatches.Checked = options.StrictPatches; } else { strictpatches.Checked = mapsettings.ReadSetting("strictpatches", false); } // Check what game configuration is preferred if (options != null) { gameconfig = options.ConfigFile; } else { gameconfig = mapsettings.ReadSetting("gameconfig", ""); } // Go for all configurations for (int i = 0; i < General.Configs.Count; i++) { // Add config name to list index = config.Items.Add(General.Configs[i]); // This is the preferred game configuration? if (General.Configs[i].Filename == gameconfig) { // Select this item config.SelectedIndex = index; } } // Still no configuration selected? if (config.SelectedIndex == -1) { // Then go for all configurations to find a suitable one for (int i = 0; i < General.Configs.Count; i++) { // Check if a resource location is set for this configuration if (General.Configs[i].Resources.Count > 0) { // Match the wad against this configuration if (MatchConfiguration(General.Configs[i].Filename, wadfile)) { // Select this item config.SelectedIndex = i; break; } } } } // Done Cursor.Current = Cursors.Default; }
// OK clicked private void apply_Click(object sender, EventArgs e) { Configuration newcfg; WAD sourcewad; bool conflictingname; // Configuration selected? if (config.SelectedIndex == -1) { // Select a configuration! MessageBox.Show(this, "Please select a game configuration to use for editing your map.", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Warning); config.Focus(); return; } // Level name empty? if (levelname.Text.Length == 0) { // Enter a level name! MessageBox.Show(this, "Please enter a level name for your map.", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Warning); levelname.Focus(); return; } // Collect information ConfigurationInfo configinfo = General.Configs[config.SelectedIndex]; DataLocationList locations = datalocations.GetResources(); // When making a new map, check if we should warn the user for missing resources if (newmap && (locations.Count == 0) && (configinfo.Resources.Count == 0)) { if (MessageBox.Show(this, "You are about to make a map without selecting any resources. Textures, flats and " + "sprites may not be shown correctly or may not show up at all. Do you want to continue?", Application.ProductName, MessageBoxButtons.YesNo, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button2) == DialogResult.No) { return; } } // Next checks are only for maps that are already opened if (!newmap) { // Now we check if the map name the user has given does already exist in the source WAD file // We have to warn the user about that, because it would create a level name conflict in the WAD // Level name changed and the map exists in a source wad? if ((levelname.Text != options.CurrentName) && (General.Map != null) && (General.Map.FilePathName != "") && File.Exists(General.Map.FilePathName)) { // Open the source wad file to check for conflicting name sourcewad = new WAD(General.Map.FilePathName, true); conflictingname = (sourcewad.FindLumpIndex(levelname.Text) > -1); sourcewad.Dispose(); // Names conflict? if (conflictingname) { // Show warning! if (General.ShowWarningMessage("The map name \"" + levelname.Text + "\" is already in use by another map or data lump in the source WAD file. Saving your map with this name will cause conflicting data lumps in the WAD file. Do you want to continue?", MessageBoxButtons.YesNo, MessageBoxDefaultButton.Button2) == DialogResult.No) { return; } } } // When the user changed the configuration to one that has a different read/write interface, // we have to warn the user that the map may not be compatible. // Configuration changed? if ((options.ConfigFile != "") && (General.Configs[config.SelectedIndex].Filename != options.ConfigFile)) { // Load the new cfg file newcfg = General.LoadGameConfiguration(General.Configs[config.SelectedIndex].Filename); if (newcfg == null) { return; } // Check if the config uses a different IO interface if (newcfg.ReadSetting("formatinterface", "") != General.Map.Config.FormatInterface) { // Warn the user about IO interface change if (General.ShowWarningMessage("The game configuration you selected uses a different file format than your current map. Because your map was not designed for this format it may cause the map to work incorrectly in the game. Do you want to continue?", MessageBoxButtons.YesNo, MessageBoxDefaultButton.Button2) == DialogResult.No) { // Reset to old configuration for (int i = 0; i < config.Items.Count; i++) { // Is this configuration the old config? if (string.Compare(General.Configs[i].Filename, options.ConfigFile, true) == 0) { // Select this item config.SelectedIndex = i; } } return; } } } } // Apply changes options.ClearResources(); options.ConfigFile = General.Configs[config.SelectedIndex].Filename; options.CurrentName = levelname.Text.Trim().ToUpper(); options.StrictPatches = strictpatches.Checked; options.CopyResources(datalocations.GetResources()); // Reset default drawing textures General.Settings.DefaultTexture = null; General.Settings.DefaultFloorTexture = null; General.Settings.DefaultCeilingTexture = null; // Hide window this.DialogResult = DialogResult.OK; this.Close(); }
// This loads the settings and attempt to find a suitable config private void LoadSettings() { string gameconfig; int index; // Busy Cursor.Current = Cursors.WaitCursor; // Check if the file exists if (!File.Exists(filepathname)) { // WAD file does not exist MessageBox.Show(this, "Could not open the WAD file: The file does not exist.", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error); this.DialogResult = DialogResult.Cancel; this.Close(); return; } try { // Open the WAD file wadfile = new WAD(filepathname, true); } catch (Exception) { // Unable to open WAD file (or its config) MessageBox.Show(this, "Could not open the WAD file for reading. Please make sure the file you selected is valid and is not in use by any other application.", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error); if (wadfile != null) { wadfile.Dispose(); } this.DialogResult = DialogResult.Cancel; this.Close(); return; } // Open the Map Settings configuration string dbsfile = filepathname.Substring(0, filepathname.Length - 4) + ".dbs"; if (File.Exists(dbsfile)) { try { mapsettings = new Configuration(dbsfile, true); } catch (Exception) { mapsettings = new Configuration(true); } } else { mapsettings = new Configuration(true); } // Check strict patches box, check what game configuration is preferred if (options != null) { strictpatches.Checked = options.StrictPatches; gameconfig = options.ConfigFile; } else { strictpatches.Checked = mapsettings.ReadSetting("strictpatches", false); gameconfig = mapsettings.ReadSetting("gameconfig", ""); } //mxd. Fill script compilers list foreach (KeyValuePair <string, ScriptConfiguration> group in General.CompiledScriptConfigs) { scriptcompiler.Items.Add(group.Value); } // Go for all configurations foreach (ConfigurationInfo info in General.Configs) { // Add config name to list index = config.Items.Add(info); // Select this item if (info.Filename == gameconfig) { config.SelectedIndex = index; } } // Still no configuration selected? if (config.SelectedIndex == -1) { //mxd. Then go for all ENABLED configurations with resources to find a suitable one foreach (ConfigurationInfo info in General.Configs) { // Check if a resource location is set for this configuration, if so, match the wad against this configuration if (info.Enabled && info.Resources.Count > 0 && MatchConfiguration(info.Configuration, wadfile)) { //mxd. Already added? index = config.Items.IndexOf(info); // Select or add and select this item config.SelectedIndex = (index != -1 ? index : config.Items.Add(info)); break; } } } //mxd. Still no configuration selected? if (config.SelectedIndex == -1) { // Then go for all DISABLED configurations with resources to find a suitable one foreach (ConfigurationInfo info in General.Configs) { // Check if a resource location is set for this configuration, if so, match the wad against this configuration if (!info.Enabled && info.Resources.Count > 0 && MatchConfiguration(info.Configuration, wadfile)) { //mxd. Already added? index = config.Items.IndexOf(info); // Select or add and select this item config.SelectedIndex = (index != -1 ? index : config.Items.Add(info)); break; } } } //mxd. Still no configuration selected? if (config.SelectedIndex == -1) { //mxd. Then go for all ENABLED configurations without resources to find a suitable one foreach (ConfigurationInfo info in General.Configs) { // Check if a resource location is not set for this configuration, if so, match the wad against this configuration if (info.Enabled && info.Resources.Count == 0 && MatchConfiguration(info.Configuration, wadfile)) { //mxd. Already added? index = config.Items.IndexOf(info); // Select or add and select this item config.SelectedIndex = (index != -1 ? index : config.Items.Add(info)); break; } } } //mxd. Still no configuration selected? if (config.SelectedIndex == -1) { // Then go for all DISABLED configurations without resources to find a suitable one foreach (ConfigurationInfo info in General.Configs) { // Check if a resource location is not set for this configuration, if so, match the wad against this configuration if (!info.Enabled && info.Resources.Count == 0 && MatchConfiguration(info.Configuration, wadfile)) { //mxd. Already added? index = config.Items.IndexOf(info); // Select or add and select this item config.SelectedIndex = (index != -1 ? index : config.Items.Add(info)); break; } } } // [ZZ] dispose of wadfile wadfile.Dispose(); //mxd. Bail out if still no dice... if (config.SelectedIndex == -1 || mapslist.Items.Count == 0) { General.ShowWarningMessage("Unable to find maps using any game configuration.\nDoes this wad contain any maps at all?..", MessageBoxButtons.OK); cancel_Click(this, EventArgs.Empty); } else { // Show the window this.Opacity = 1; } // Done Cursor.Current = Cursors.Default; }
// OK clicked private void apply_Click(object sender, EventArgs e) { // Configuration selected? if (config.SelectedIndex == -1) { // Select a configuration! MessageBox.Show(this, "Please select a game configuration to use for editing your map.", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Warning); config.Focus(); return; } //mxd. Script configuration selected? if (scriptcompiler.Enabled && scriptcompiler.SelectedIndex == -1) { // Select a configuration! MessageBox.Show(this, "Please select a script type to use for editing your map.", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Warning); scriptcompiler.Focus(); return; } // Collect information ConfigurationInfo configinfo = (config.SelectedItem as ConfigurationInfo); //mxd DataLocationList locations = datalocations.GetResources(); // Resources are valid? (mxd) if (!datalocations.ResourcesAreValid()) { MessageBox.Show(this, "Cannot open map: at least one resource doesn't exist!", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Warning); datalocations.Focus(); return; } // No map selected? if (mapslist.SelectedItems.Count == 0) { // Choose a map! MessageBox.Show(this, "Please select a map to load for editing.", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Warning); mapslist.Focus(); return; } //mxd. We cant't deal with this... We just can't... if (!configinfo.ValidateMapName(mapslist.SelectedItems[0].Text.ToUpperInvariant())) { // Choose a different map! MessageBox.Show(this, "Selected map name conflicts with a lump name defined for current map format.\nPlease rename the map and try again.", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Warning); mapslist.Focus(); return; } // Check if we should warn the user for missing resources if ((!wadfile.IsIWAD) && (locations.Count == 0) && (configinfo.Resources.Count == 0)) { if (MessageBox.Show(this, "You are about to load a map without selecting any resources. Textures, flats and " + "sprites may not be shown correctly or may not show up at all. Do you want to continue?", Application.ProductName, MessageBoxButtons.YesNo, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button2) == DialogResult.No) { return; } } // Apply changes options.ClearResources(); options.ConfigFile = configinfo.Filename; options.CurrentName = mapslist.SelectedItems[0].Text; options.StrictPatches = strictpatches.Checked; options.CopyResources(locations); //mxd. Store script compiler if (scriptcompiler.Enabled) { ScriptConfiguration scriptcfg = scriptcompiler.SelectedItem as ScriptConfiguration; foreach (KeyValuePair <string, ScriptConfiguration> group in General.CompiledScriptConfigs) { if (group.Value == scriptcfg) { options.ScriptCompiler = group.Key; break; } } } //mxd. Use long texture names? if (longtexturenames.Enabled) { options.UseLongTextureNames = longtexturenames.Checked; } //mxd. Resource usage options.UseResourcesInReadonlyMode = readonlyresources.Checked; // Hide window wadfile.Dispose(); this.DialogResult = DialogResult.OK; this.Close(); }
private void LoadSettings() { // Check if the file exists if (!File.Exists(filepathname)) { // WAD file does not exist MessageBox.Show(this, "Could not open the WAD file. The file does not exist.", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error); this.DialogResult = DialogResult.Cancel; this.Close(); return; } // Busy Cursor.Current = Cursors.WaitCursor; WAD wadfile; try { // Open the WAD file wadfile = new WAD(filepathname, true); } catch (Exception) { // Unable to open WAD file (or its config) MessageBox.Show(this, "Could not open the WAD file for reading. Please make sure the file you selected is valid and is not in use by any other application.", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error); this.DialogResult = DialogResult.Cancel; this.Close(); return; } // Make an array for the map names List <ListViewItem> mapnames = new List <ListViewItem>(); // Open the Map Settings configuration string dbsfile = filepathname.Substring(0, filepathname.Length - 4) + ".dbs"; if (File.Exists(dbsfile)) { try { mapsettings = new Configuration(dbsfile, true); } catch (Exception) { mapsettings = new Configuration(true); } } else { mapsettings = new Configuration(true); } //mxd. Get Proper configuration ConfigurationInfo ci = General.GetConfigurationInfo(options.ConfigFile); // Get the map lump names IDictionary maplumpnames = ci.Configuration.ReadSetting("maplumpnames", new Hashtable()); // Count how many required lumps we have to find int lumpsrequired = 0; foreach (DictionaryEntry ml in maplumpnames) { // Ignore the map header (it will not be found because the name is different) if (ml.Key.ToString() != MapManager.CONFIG_MAP_HEADER) { // Read lump setting and count it if (ci.Configuration.ReadSetting("maplumpnames." + ml.Key + ".required", false)) { lumpsrequired++; } } } // Go for all the lumps in the wad for (int 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)) { // Reset check int lumpsfound = 0; int checkoffset = 1; // 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 string lumpname = wadfile.Lumps[scanindex + checkoffset].Name; if (ci.Configuration.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)); } } } wadfile.Dispose(); // Clear the list and add the new map names mapslist.BeginUpdate(); mapslist.Items.Clear(); mapslist.Items.AddRange(mapnames.ToArray()); mapslist.Sort(); //select current map foreach (ListViewItem item in mapslist.Items) { // Was this item previously selected? if (item.Text == options.LevelName) { // Select it again item.Selected = true; item.EnsureVisible(); break; } } mapslist.EndUpdate(); // Do some focus managing if (mapslist.SelectedItems.Count > 0) { mapslist.FocusedItem = mapslist.SelectedItems[0]; } // Done Cursor.Current = Cursors.Default; }
// OK clicked private void apply_Click(object sender, EventArgs e) { // Configuration selected? if (config.SelectedIndex == -1) { // Select a configuration! MessageBox.Show(this, "Please select a game configuration to use for editing your map.", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Warning); config.Focus(); return; } //mxd. Script configuration selected? if (scriptcompiler.Enabled && scriptcompiler.SelectedIndex == -1) { // Select a configuration! MessageBox.Show(this, "Please select a script type to use for editing your map.", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Warning); scriptcompiler.Focus(); return; } // Level name empty? if (levelname.Text.Length == 0) { // Enter a level name! MessageBox.Show(this, "Please enter a level name for your map.", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Warning); levelname.Focus(); return; } // Collect information ConfigurationInfo configinfo = config.SelectedItem as ConfigurationInfo; //mxd DataLocationList locations = datalocations.GetResources(); //mxd. Level name will f**k things up horribly? if (!configinfo.ValidateMapName(levelname.Text.ToUpperInvariant())) { // Enter a different level name! MessageBox.Show(this, "Chosen map name conflicts with a lump name defined for current map format.\n", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Warning); levelname.Focus(); return; } // Resources are valid? (mxd) if (!datalocations.ResourcesAreValid()) { MessageBox.Show(this, "Cannot " + (newmap ? "create map" : "change map settings") + ": at least one resource doesn't exist!", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Warning); datalocations.Focus(); return; } // When making a new map, check if we should warn the user for missing resources if (newmap) { General.Settings.LastUsedConfigName = configinfo.Name; //mxd if ((locations.Count == 0) && (configinfo.Resources.Count == 0) && MessageBox.Show(this, "You are about to make a map without selecting any resources. Textures, flats and " + "sprites may not be shown correctly or may not show up at all. Do you want to continue?", Application.ProductName, MessageBoxButtons.YesNo, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button2) == DialogResult.No) { return; } } // Next checks are only for maps that are already opened if (!newmap) { // Now we check if the map name the user has given does already exist in the source WAD file // We have to warn the user about that, because it would create a level name conflict in the WAD // Level name changed and the map exists in a source wad? if ((levelname.Text != options.CurrentName) && (General.Map != null) && (!string.IsNullOrEmpty(General.Map.FilePathName)) && File.Exists(General.Map.FilePathName)) { // Open the source wad file to check for conflicting name WAD sourcewad = new WAD(General.Map.FilePathName, true); bool conflictingname = (sourcewad.FindLumpIndex(levelname.Text) > -1); sourcewad.Dispose(); // Names conflict? if (conflictingname) { // Show warning! if (General.ShowWarningMessage("The map name \"" + levelname.Text + "\" is already in use by another map or data lump in the source WAD file. Saving your map with this name will cause conflicting data lumps in the WAD file. Do you want to continue?", MessageBoxButtons.YesNo, MessageBoxDefaultButton.Button2) == DialogResult.No) { return; } } } //mxd. If the map was never saved and it's name was changed, update filename if ((levelname.Text != options.CurrentName) && (General.Map != null) && (string.IsNullOrEmpty(General.Map.FilePathName))) { General.Map.FileTitle = levelname.Text + ".wad"; } // When the user changed the configuration to one that has a different read/write interface, // we have to warn the user that the map may not be compatible. // Configuration changed? if ((options.ConfigFile != "") && (configinfo.Filename != options.ConfigFile)) { // Check if the config uses a different IO interface if (configinfo.Configuration.ReadSetting("formatinterface", "") != General.Map.Config.FormatInterface) { // Warn the user about IO interface change if (General.ShowWarningMessage("The game configuration you selected uses a different file format than your current map. Because your map was not designed for this format it may cause the map to work incorrectly in the game. Do you want to continue?", MessageBoxButtons.YesNo, MessageBoxDefaultButton.Button2) == DialogResult.No) { // Reset to old configuration for (int i = 0; i < config.Items.Count; i++) { // Is this configuration the old config? if (string.Compare((config.Items[i] as ConfigurationInfo).Filename, options.ConfigFile, true) == 0) { // Select this item config.SelectedIndex = i; } } return; } //mxd. Otherwise map data won't be saved if a user decides to save the map right after converting to new map format General.Map.IsChanged = true; } } } // Apply changes options.ClearResources(); options.ConfigFile = (config.SelectedItem as ConfigurationInfo).Filename; //mxd options.CurrentName = levelname.Text.Trim().ToUpper(); options.StrictPatches = strictpatches.Checked; options.CopyResources(datalocations.GetResources()); //mxd. Store script compiler if (scriptcompiler.Enabled) { ScriptConfiguration scriptcfg = scriptcompiler.SelectedItem as ScriptConfiguration; foreach (KeyValuePair <string, ScriptConfiguration> group in General.CompiledScriptConfigs) { if (group.Value == scriptcfg) { options.ScriptCompiler = group.Key; break; } } } //mxd. Use long texture names? if (longtexturenames.Enabled) { options.UseLongTextureNames = longtexturenames.Checked; } //mxd. Resource usage options.UseResourcesInReadonlyMode = readonlyresources.Checked; // Hide window this.DialogResult = DialogResult.OK; this.Close(); }
// This loads the settings and attempt to find a suitable config private void LoadSettings() { string dbsfile; string gameconfig; int index; // Busy Cursor.Current = Cursors.WaitCursor; // Check if the file exists if (!File.Exists(filepathname)) { // WAD file does not exist MessageBox.Show(this, "Could not open the WAD file: The file does not exist.", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error); this.DialogResult = DialogResult.Cancel; this.Close(); return; } try { // Open the WAD file wadfile = new WAD(filepathname, true); } catch (Exception) { // Unable to open WAD file (or its config) MessageBox.Show(this, "Could not open the WAD file for reading. Please make sure the file you selected is valid and is not in use by any other application.", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error); if (wadfile != null) { wadfile.Dispose(); } this.DialogResult = DialogResult.Cancel; this.Close(); return; } // Open the Map Settings configuration dbsfile = filepathname.Substring(0, filepathname.Length - 4) + ".dbs"; if (File.Exists(dbsfile)) { try { mapsettings = new Configuration(dbsfile, true); } catch (Exception) { mapsettings = new Configuration(true); } } else { mapsettings = new Configuration(true); } // Check strict patches box if (options != null) { strictpatches.Checked = options.StrictPatches; } else { strictpatches.Checked = mapsettings.ReadSetting("strictpatches", false); } // Check what game configuration is preferred if (options != null) { gameconfig = options.ConfigFile; } else { gameconfig = mapsettings.ReadSetting("gameconfig", ""); } int best_index = -1; for (int i = 0; i < General.Configs.Count; i++) { // Add config name to list index = config.Items.Add(General.Configs[i]); // This is the preferred game configuration? if (General.Configs[i].Filename == gameconfig) { best_index = i; } } if (best_index >= 0 && MatchConfiguration(General.Configs[best_index], wadfile) <= -80) { best_index = -1; } if (best_index < 0) { // ano - try to default to last used if we've got nothing if (string.IsNullOrEmpty(gameconfig)) { gameconfig = General.Settings.ReadSetting("lastopenedgameconfig", "EE_DoomUDMF.cfg"); } for (int i = 0; i < General.Configs.Count; i++) { if (General.Configs[i].Filename == gameconfig) { best_index = i; } } if (best_index >= 0 && MatchConfiguration(General.Configs[best_index], wadfile) <= -20) { best_index = -1; } } if (best_index < 0) { int best_score = int.MinValue; for (int i = 0; i < General.Configs.Count; i++) { // Match the wad against this configuration int new_score = MatchConfiguration(General.Configs[i], wadfile); if (new_score > best_score) { best_index = i; best_score = new_score; } } } if (best_index >= 0) { config.SelectedIndex = best_index; } // Done Cursor.Current = Cursors.Default; }