Esempio n. 1
0
        // Constructor to load from Doom Builder Map Settings Configuration
        internal MapOptions(Configuration cfg, string mapname)
        {
            IDictionary  resinfo;
            DataLocation res;

            // Initialize
            this.previousname  = "";
            this.currentname   = mapname;
            this.strictpatches = General.Int2Bool(cfg.ReadSetting("strictpatches", 0));
            this.configfile    = cfg.ReadSetting("gameconfig", "");
            this.resources     = new DataLocationList();
            this.mapconfig     = new Configuration(true);
            this.scriptfiles   = new List <string>();

            // Read map configuration
            this.mapconfig.Root = cfg.ReadSetting("maps." + mapname, new Hashtable());

            // Resources
            IDictionary reslist = this.mapconfig.ReadSetting("resources", new Hashtable());

            foreach (DictionaryEntry mp in reslist)
            {
                // Item is a structure?
                if (mp.Value is IDictionary)
                {
                    // Create resource
                    resinfo = (IDictionary)mp.Value;
                    res     = new DataLocation();

                    // Copy information from Configuration to ResourceLocation
                    if (resinfo.Contains("type") && (resinfo["type"] is int))
                    {
                        res.type = (int)resinfo["type"];
                    }
                    if (resinfo.Contains("location") && (resinfo["location"] is string))
                    {
                        res.location = (string)resinfo["location"];
                    }
                    if (resinfo.Contains("textures") && (resinfo["textures"] is bool))
                    {
                        res.option1 = (bool)resinfo["textures"];
                    }
                    if (resinfo.Contains("flats") && (resinfo["flats"] is bool))
                    {
                        res.option2 = (bool)resinfo["flats"];
                    }

                    // Add resource
                    AddResource(res);
                }
            }

            // Scripts
            IDictionary scplist = this.mapconfig.ReadSetting("scripts", new Hashtable());

            foreach (DictionaryEntry mp in scplist)
            {
                scriptfiles.Add(mp.Value.ToString());
            }
        }
Esempio n. 2
0
        // This will show a fixed list
        public void FixedResourceLocationList(DataLocationList list)
        {
            // Start editing list
            resourceitems.BeginUpdate();

            // Go for all items
            for (int i = resourceitems.Items.Count - 1; i >= 0; i--)
            {
                // Remove item if fixed
                if (resourceitems.Items[i].ForeColor != SystemColors.WindowText)
                {
                    resourceitems.Items.RemoveAt(i);
                }
            }

            // Go for all items
            for (int i = list.Count - 1; i >= 0; i--)
            {
                // Add item as fixed
                resourceitems.Items.Insert(0, new ListViewItem(list[i].location));
                resourceitems.Items[0].Tag        = list[i];
                resourceitems.Items[0].ImageIndex = GetIconIndex(list[i].type, true);

                // Set disabled
                resourceitems.Items[0].ForeColor = SystemColors.GrayText;
            }

            // Done
            resourceitems.EndUpdate();
        }
        // Constructor
        public ResourceListEditor()
        {
            // Initialize
            InitializeComponent();
            ResizeColumnHeader();

            if (General.Actions != null)
            {
                // Get key shortcuts (mxd)
                copyactionkey         = General.Actions.GetActionByName("builder_copyselection").ShortcutKey;
                cutactionkey          = General.Actions.GetActionByName("builder_cutselection").ShortcutKey;
                pasteactionkey        = General.Actions.GetActionByName("builder_pasteselection").ShortcutKey;
                pastespecialactionkey = General.Actions.GetActionByName("builder_pasteselectionspecial").ShortcutKey;
                deleteactionkey       = General.Actions.GetActionByName("builder_deleteitem").ShortcutKey;

                // Set displayed shortcuts (mxd)
                copyresources.ShortcutKeyDisplayString    = Actions.Action.GetShortcutKeyDesc(copyactionkey);
                cutresources.ShortcutKeyDisplayString     = Actions.Action.GetShortcutKeyDesc(cutactionkey);
                pasteresources.ShortcutKeyDisplayString   = Actions.Action.GetShortcutKeyDesc(pasteactionkey);
                replaceresources.ShortcutKeyDisplayString = Actions.Action.GetShortcutKeyDesc(pastespecialactionkey);
                removeresources.ShortcutKeyDisplayString  = Actions.Action.GetShortcutKeyDesc(deleteactionkey);
            }

            // Start with a clear list
            resourceitems.Items.Clear();
            copiedresources = new DataLocationList();             //mxd
        }
Esempio n. 4
0
 // This applies settings from an object
 public void Apply(ConfigurationInfo ci)
 {
     this.name            = ci.name;
     this.filename        = ci.filename;
     this.settingskey     = ci.settingskey;
     this.nodebuildersave = ci.nodebuildersave;
     this.nodebuildertest = ci.nodebuildertest;
     this.resources       = new DataLocationList();
     this.resources.AddRange(ci.resources);
     this.testprogram      = ci.testprogram;
     this.testparameters   = ci.testparameters;
     this.testshortpaths   = ci.testshortpaths;
     this.customparameters = ci.customparameters;
     this.testskill        = ci.testskill;
     this.startmode        = ci.startmode;
     this.texturesets      = new List <DefinedTextureSet>();
     foreach (DefinedTextureSet s in ci.texturesets)
     {
         this.texturesets.Add(s.Copy());
     }
     this.thingsfilters = new List <ThingsFilter>();
     foreach (ThingsFilter f in ci.thingsfilters)
     {
         this.thingsfilters.Add(new ThingsFilter(f));
     }
     this.editmodes = new Dictionary <string, bool>(ci.editmodes);
 }
Esempio n. 5
0
        // Constructor
        public ConfigurationInfo(Configuration cfg, string filename)
        {
            // Initialize
            this.filename    = filename;
            this.settingskey = Path.GetFileNameWithoutExtension(filename).ToLower();

            // Load settings from game configuration
            this.name            = cfg.ReadSetting("game", "<unnamed game>");
            this.defaultlumpname = cfg.ReadSetting("defaultlumpname", "");

            // Load settings from program configuration
            this.nodebuildersave  = General.Settings.ReadSetting("configurations." + settingskey + ".nodebuildersave", MISSING_NODEBUILDER);
            this.nodebuildertest  = General.Settings.ReadSetting("configurations." + settingskey + ".nodebuildertest", MISSING_NODEBUILDER);
            this.testprogram      = General.Settings.ReadSetting("configurations." + settingskey + ".testprogram", "");
            this.testparameters   = General.Settings.ReadSetting("configurations." + settingskey + ".testparameters", "");
            this.testshortpaths   = General.Settings.ReadSetting("configurations." + settingskey + ".testshortpaths", false);
            this.customparameters = General.Settings.ReadSetting("configurations." + settingskey + ".customparameters", false);
            this.testskill        = General.Settings.ReadSetting("configurations." + settingskey + ".testskill", 3);
            this.resources        = new DataLocationList(General.Settings.Config, "configurations." + settingskey + ".resources");
            this.startmode        = General.Settings.ReadSetting("configurations." + settingskey + ".startmode", "VerticesMode");

            // Make list of things filters
            thingsfilters = new List <ThingsFilter>();
            IDictionary cfgfilters = General.Settings.ReadSetting("configurations." + settingskey + ".thingsfilters", new Hashtable());

            foreach (DictionaryEntry de in cfgfilters)
            {
                thingsfilters.Add(new ThingsFilter(General.Settings.Config, "configurations." + settingskey + ".thingsfilters." + de.Key));
            }

            // Make list of texture sets
            texturesets = new List <DefinedTextureSet>();
            IDictionary sets = General.Settings.ReadSetting("configurations." + settingskey + ".texturesets", new Hashtable());

            foreach (DictionaryEntry de in sets)
            {
                texturesets.Add(new DefinedTextureSet(General.Settings.Config, "configurations." + settingskey + ".texturesets." + de.Key));
            }

            // Make list of edit modes
            this.editmodes = new Dictionary <string, bool>();
            IDictionary modes = General.Settings.ReadSetting("configurations." + settingskey + ".editmodes", new Hashtable());

            foreach (DictionaryEntry de in modes)
            {
                if (de.Key.ToString().StartsWith(MODE_ENABLED_KEY))
                {
                    editmodes.Add(de.Value.ToString(), true);
                }
                else if (de.Key.ToString().StartsWith(MODE_DISABLED_KEY))
                {
                    editmodes.Add(de.Value.ToString(), false);
                }
            }
        }
Esempio n. 6
0
 // Constructor
 internal MapOptions()
 {
     // Initialize
     this.previousname  = "";
     this.currentname   = "";
     this.configfile    = "";
     this.strictpatches = false;
     this.resources     = new DataLocationList();
     this.mapconfig     = new Configuration(true);
     this.scriptfiles   = new List <string>();
 }
Esempio n. 7
0
        // 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();
        }
Esempio n. 8
0
        // Map name selected
        private void mapslist_ItemSelectionChanged(object sender, ListViewItemSelectionChangedEventArgs e)
        {
            DataLocationList locations;
            DataLocationList listedlocations;

            // Map previously selected?
            if ((selectedmapname != null) && (selectedmapname != ""))
            {
                // Get locations from previous selected map settings
                locations       = new DataLocationList(mapsettings, "maps." + selectedmapname + ".resources");
                listedlocations = datalocations.GetResources();

                // Remove data locations that this map has in its config
                foreach (DataLocation dl in locations)
                {
                    listedlocations.Remove(dl);
                }

                // Set new data locations
                datalocations.EditResourceLocationList(listedlocations);

                // Done
                selectedmapname = null;
            }

            // Anything selected?
            if (mapslist.SelectedItems.Count > 0)
            {
                // Get the map name
                selectedmapname = mapslist.SelectedItems[0].Text;
                options         = new MapOptions(mapsettings, selectedmapname);

                // Get locations from previous selected map settings
                locations       = new DataLocationList(mapsettings, "maps." + selectedmapname + ".resources");
                listedlocations = datalocations.GetResources();

                // Add data locations that this map has in its config
                foreach (DataLocation dl in locations)
                {
                    if (!listedlocations.Contains(dl))
                    {
                        listedlocations.Add(dl);
                    }
                }

                // Set new data locations
                datalocations.EditResourceLocationList(listedlocations);
            }
        }
        // This will show a fixed list
        public void FixedResourceLocationList(DataLocationList list)
        {
            // Start editing list
            resourceitems.BeginUpdate();

            //mxd
            HashSet <DataLocation> currentitems = new HashSet <DataLocation>();

            // Go for all items
            for (int i = resourceitems.Items.Count - 1; i >= 0; i--)
            {
                // Remove item if not fixed
                if (resourceitems.Items[i].ForeColor != SystemColors.WindowText)
                {
                    resourceitems.Items.RemoveAt(i);
                }
                else
                {
                    currentitems.Add((DataLocation)resourceitems.Items[i].Tag);                     //mxd
                }
            }

            // Go for all items
            for (int i = list.Count - 1; i >= 0; i--)
            {
                if (currentitems.Contains(list[i]))
                {
                    continue;                              //mxd
                }
                currentitems.Add(list[i]);                 //mxd

                // Add item as fixed
                resourceitems.Items.Insert(0, new ListViewItem(list[i].location));
                resourceitems.Items[0].Tag        = list[i];
                resourceitems.Items[0].ImageIndex = GetIconIndex(list[i].type, true);

                // Set disabled
                resourceitems.Items[0].ForeColor = SystemColors.GrayText;

                // Validate path (mxd)
                resourceitems.Items[0].BackColor = (list[i].IsValid() ? resourceitems.BackColor : Color.MistyRose);
            }

            // Done
            resourceitems.EndUpdate();
        }
Esempio n. 10
0
        // Returns a list of the resources
        public DataLocationList GetResources()
        {
            DataLocationList list = new DataLocationList();

            // Go for all items
            for (int i = 0; i < resourceitems.Items.Count; i++)
            {
                // Item not grayed?
                if (resourceitems.Items[i].ForeColor == SystemColors.WindowText)
                {
                    // Add item to list
                    list.Add((DataLocation)resourceitems.Items[i].Tag);
                }
            }

            // Return result
            return(list);
        }
Esempio n. 11
0
        // This applies settings from an object
        internal void Apply(ConfigurationInfo ci)
        {
            this.name               = ci.name;
            this.filename           = ci.filename;
            this.settingskey        = ci.settingskey;
            this.nodebuildersave    = ci.nodebuildersave;
            this.nodebuildertest    = ci.nodebuildertest;
            this.formatinterface    = ci.formatinterface;          //mxd
            this.currentEngineIndex = ci.currentEngineIndex;       //mxd
            this.resources          = new DataLocationList(ci.resources);

            //mxd
            this.testEngines = new List <EngineInfo>();
            foreach (EngineInfo info in ci.testEngines)
            {
                testEngines.Add(new EngineInfo(info));
            }
            if (this.currentEngineIndex >= testEngines.Count)
            {
                this.currentEngineIndex = Math.Max(0, testEngines.Count - 1);
            }
            this.linedefColorPresets = new LinedefColorPreset[ci.linedefColorPresets.Length];
            for (int i = 0; i < ci.linedefColorPresets.Length; i++)
            {
                this.linedefColorPresets[i] = new LinedefColorPreset(ci.linedefColorPresets[i]);
            }

            this.startmode   = ci.startmode;
            this.config      = ci.config;        //mxd
            this.enabled     = ci.enabled;       //mxd
            this.changed     = ci.changed;
            this.texturesets = new List <DefinedTextureSet>();
            foreach (DefinedTextureSet s in ci.texturesets)
            {
                this.texturesets.Add(s.Copy());
            }
            this.thingsfilters = new List <ThingsFilter>();
            foreach (ThingsFilter f in ci.thingsfilters)
            {
                this.thingsfilters.Add(new ThingsFilter(f));
            }
            this.editmodes = new Dictionary <string, bool>(ci.editmodes);
        }
Esempio n. 12
0
        // Constructor
        internal MapOptions()
        {
            // Initialize
            this.previousname   = "";
            this.currentname    = "";
            this.configfile     = "";
            this.strictpatches  = false;
            this.resources      = new DataLocationList();
            this.mapconfig      = new Configuration(true);
            this.scriptsettings = new Dictionary <string, ScriptDocumentSettings>(StringComparer.OrdinalIgnoreCase); //mxd
            this.scriptcompiler = "";                                                                                //mxd
            this.tagLabels      = new Dictionary <int, string>();                                                    //mxd
            this.viewposition   = new Vector2D(float.NaN, float.NaN);                                                //mxd
            this.viewscale      = float.NaN;                                                                         //mxd

            //mxd. Sector drawing options
            this.custombrightness = 196;
            this.customceilheight = 128;
        }
Esempio n. 13
0
        //mxd
        private static void AddResourcesFrom(string path, DataLocationType type, DataLocationList addto)
        {
            string pattern;

            switch (type)
            {
            case DataLocationType.RESOURCE_ART: pattern = "*.art"; break;

            case DataLocationType.RESOURCE_GRP: pattern = "*.grp"; break;

            default: throw new NotSupportedException("Unsupported DataLocationType!");
            }

            string[] files = Directory.GetFiles(path, pattern);
            foreach (string file in files)
            {
                addto.Add(new DataLocation(type, file));
            }
        }
        // Returns a list of the resources
        public DataLocationList GetResources()
        {
            DataLocationList list = new DataLocationList();

            // Go for all items
            for (int i = 0; i < resourceitems.Items.Count; i++)
            {
                // Item not grayed?
                if (resourceitems.Items[i].ForeColor == SystemColors.WindowText)
                {
                    // Add item to list
                    DataLocation dl = (DataLocation)resourceitems.Items[i].Tag;
                    if (!list.Contains(dl))
                    {
                        list.Add(dl);                                        //mxd. Duplicates check
                    }
                }
            }

            // Return result
            return(list);
        }
Esempio n. 15
0
        //mxd
        private DataLocationList CreateResourcesList()
        {
            DataLocationList list = new DataLocationList();

            // Add resources from engine location
            string enginepath = Path.GetDirectoryName(General.Map.ConfigSettings.TestProgram);

            if (!string.IsNullOrEmpty(enginepath))
            {
                AddResourcesFrom(enginepath, DataLocationType.RESOURCE_GRP, list);
                AddResourcesFrom(enginepath, DataLocationType.RESOURCE_ART, list);
            }

            // Add resources from map location if it differs from engine location
            if (!string.IsNullOrEmpty(filepath) && filepath != enginepath)
            {
                AddResourcesFrom(filepath, DataLocationType.RESOURCE_GRP, list);
                AddResourcesFrom(filepath, DataLocationType.RESOURCE_ART, list);
            }

            return(list);
        }
        // This will edit the given list
        public void EditResourceLocationList(DataLocationList list)
        {
            // Start editing list
            resourceitems.BeginUpdate();

            // Scroll to top
            if (resourceitems.Items.Count > 0)
            {
                resourceitems.TopItem = resourceitems.Items[0];
            }

            // Go for all items
            for (int i = resourceitems.Items.Count - 1; i >= 0; i--)
            {
                // Remove item unless fixed
                if (resourceitems.Items[i].ForeColor == SystemColors.WindowText)
                {
                    resourceitems.Items.RemoveAt(i);
                }
            }

            // Go for all items
            foreach (DataLocation dl in list)
            {
                // Add item
                AddItem(dl);
            }

            // Done
            resourceitems.EndUpdate();
            ResizeColumnHeader();

            // Raise content changed event
            if (OnContentChanged != null)
            {
                OnContentChanged();
            }
        }
Esempio n. 17
0
        //mxd. Not all properties should be pasted
        internal void PasteFrom(ConfigurationInfo source)
        {
            nodebuildersave    = source.nodebuildersave;
            nodebuildertest    = source.nodebuildertest;
            currentEngineIndex = source.currentEngineIndex;
            resources          = new DataLocationList(source.resources);

            testEngines = new List <EngineInfo>();
            foreach (EngineInfo info in source.testEngines)
            {
                testEngines.Add(new EngineInfo(info));
            }
            if (currentEngineIndex >= testEngines.Count)
            {
                currentEngineIndex = Math.Max(0, testEngines.Count - 1);
            }
            linedefColorPresets = new LinedefColorPreset[source.linedefColorPresets.Length];
            for (int i = 0; i < source.linedefColorPresets.Length; i++)
            {
                linedefColorPresets[i] = new LinedefColorPreset(source.linedefColorPresets[i]);
            }

            startmode   = source.startmode;
            changed     = true;
            texturesets = new List <DefinedTextureSet>();
            foreach (DefinedTextureSet s in source.texturesets)
            {
                texturesets.Add(s.Copy());
            }
            thingsfilters = new List <ThingsFilter>();
            foreach (ThingsFilter f in source.thingsfilters)
            {
                thingsfilters.Add(new ThingsFilter(f));
            }
            editmodes = new Dictionary <string, bool>(source.editmodes);
        }
Esempio n. 18
0
        // Constructor
        internal ConfigurationInfo(Configuration cfg, string filename)
        {
            // Initialize
            this.filename    = filename;
            this.config      = cfg;        //mxd
            this.settingskey = Path.GetFileNameWithoutExtension(filename).ToLower();

            // Load settings from game configuration
            this.name            = config.ReadSetting("game", "<unnamed game>");
            this.defaultlumpname = config.ReadSetting("defaultlumpname", "");

            // Load settings from program configuration
            this.nodebuildersave       = General.Settings.ReadSetting("configurations." + settingskey + ".nodebuildersave", MISSING_NODEBUILDER);
            this.nodebuildertest       = General.Settings.ReadSetting("configurations." + settingskey + ".nodebuildertest", MISSING_NODEBUILDER);
            this.formatinterface       = config.ReadSetting("formatinterface", "").ToLowerInvariant(); //mxd
            this.defaultscriptcompiler = cfg.ReadSetting("defaultscriptcompiler", "");                 //mxd
            this.resources             = new DataLocationList(General.Settings.Config, "configurations." + settingskey + ".resources");
            this.startmode             = General.Settings.ReadSetting("configurations." + settingskey + ".startmode", "VerticesMode");
            this.enabled = General.Settings.ReadSetting("configurations." + settingskey + ".enabled", config.ReadSetting("enabledbydefault", false));             //mxd

            //mxd. Read test engines
            testEngines = new List <EngineInfo>();
            IDictionary list = General.Settings.ReadSetting("configurations." + settingskey + ".engines", new ListDictionary());

            currentEngineIndex = Math.Max(0, General.Settings.ReadSetting("configurations." + settingskey + ".currentengineindex", 0));

            // No engine list found? Use old engine properties
            if (list.Count == 0)
            {
                EngineInfo info = new EngineInfo();
                info.TestProgram      = General.Settings.ReadSetting("configurations." + settingskey + ".testprogram", "");
                info.TestProgramName  = General.Settings.ReadSetting("configurations." + settingskey + ".testprogramname", EngineInfo.DEFAULT_ENGINE_NAME);
                info.TestParameters   = General.Settings.ReadSetting("configurations." + settingskey + ".testparameters", "");
                info.TestShortPaths   = General.Settings.ReadSetting("configurations." + settingskey + ".testshortpaths", false);
                info.CustomParameters = General.Settings.ReadSetting("configurations." + settingskey + ".customparameters", false);
                info.TestSkill        = General.Settings.ReadSetting("configurations." + settingskey + ".testskill", 3);
                testEngines.Add(info);
                currentEngineIndex = 0;
            }
            else
            {
                //read engines settings from config
                foreach (DictionaryEntry de in list)
                {
                    string     path = "configurations." + settingskey + ".engines." + de.Key;
                    EngineInfo info = new EngineInfo();
                    info.TestProgram      = General.Settings.ReadSetting(path + ".testprogram", "");
                    info.TestProgramName  = General.Settings.ReadSetting(path + ".testprogramname", EngineInfo.DEFAULT_ENGINE_NAME);
                    info.TestParameters   = General.Settings.ReadSetting(path + ".testparameters", "");
                    info.TestShortPaths   = General.Settings.ReadSetting(path + ".testshortpaths", false);
                    info.CustomParameters = General.Settings.ReadSetting(path + ".customparameters", false);
                    info.TestSkill        = General.Settings.ReadSetting(path + ".testskill", 3);
                    testEngines.Add(info);
                }

                if (currentEngineIndex >= testEngines.Count)
                {
                    currentEngineIndex = 0;
                }
            }

            //mxd. read custom linedef colors
            List <LinedefColorPreset> colorPresets = new List <LinedefColorPreset>();

            list = General.Settings.ReadSetting("configurations." + settingskey + ".linedefcolorpresets", new ListDictionary());

            //no presets? add "classic" ones then.
            if (list.Count == 0)
            {
                colorPresets.Add(new LinedefColorPreset("Any action", PixelColor.FromColor(System.Drawing.Color.PaleGreen), -1, 0, new List <string>(), new List <string>(), true));
            }
            else
            {
                //read custom linedef colors from config
                foreach (DictionaryEntry de in list)
                {
                    string        path          = "configurations." + settingskey + ".linedefcolorpresets." + de.Key;
                    string        presetname    = General.Settings.ReadSetting(path + ".name", "Unnamed");
                    bool          presetenabled = General.Settings.ReadSetting(path + ".enabled", true);
                    PixelColor    color         = PixelColor.FromInt(General.Settings.ReadSetting(path + ".color", -1));
                    int           action        = General.Settings.ReadSetting(path + ".action", 0);
                    int           activation    = General.Settings.ReadSetting(path + ".activation", 0);
                    List <string> flags         = new List <string>();
                    flags.AddRange(General.Settings.ReadSetting(path + ".flags", "").Split(LINEDEF_COLOR_PRESET_FLAGS_SEPARATOR, StringSplitOptions.RemoveEmptyEntries));
                    List <string> restrictedFlags = new List <string>();
                    restrictedFlags.AddRange(General.Settings.ReadSetting(path + ".restrictedflags", "").Split(LINEDEF_COLOR_PRESET_FLAGS_SEPARATOR, StringSplitOptions.RemoveEmptyEntries));
                    LinedefColorPreset preset = new LinedefColorPreset(presetname, color, action, activation, flags, restrictedFlags, presetenabled);
                    colorPresets.Add(preset);
                }
            }
            linedefColorPresets = colorPresets.ToArray();

            // Make list of things filters
            thingsfilters = new List <ThingsFilter>();
            IDictionary cfgfilters = General.Settings.ReadSetting("configurations." + settingskey + ".thingsfilters", new Hashtable());

            foreach (DictionaryEntry de in cfgfilters)
            {
                thingsfilters.Add(new ThingsFilter(General.Settings.Config, "configurations." + settingskey + ".thingsfilters." + de.Key));
            }

            // Make list of texture sets
            texturesets = new List <DefinedTextureSet>();
            IDictionary sets = General.Settings.ReadSetting("configurations." + settingskey + ".texturesets", new Hashtable());

            foreach (DictionaryEntry de in sets)
            {
                texturesets.Add(new DefinedTextureSet(General.Settings.Config, "configurations." + settingskey + ".texturesets." + de.Key));
            }

            // Make list of edit modes
            this.editmodes = new Dictionary <string, bool>(StringComparer.Ordinal);
            IDictionary modes = General.Settings.ReadSetting("configurations." + settingskey + ".editmodes", new Hashtable());

            foreach (DictionaryEntry de in modes)
            {
                if (de.Key.ToString().StartsWith(MODE_ENABLED_KEY))
                {
                    editmodes.Add(de.Value.ToString(), true);
                }
                else if (de.Key.ToString().StartsWith(MODE_DISABLED_KEY))
                {
                    editmodes.Add(de.Value.ToString(), false);
                }
            }
        }
Esempio n. 19
0
 // This copies resources from a list
 internal void CopyResources(DataLocationList fromlist)
 {
     // Clear this list
     resources.Clear();
     resources.AddRange(fromlist);
 }
Esempio n. 20
0
        // Constructor to load from Doom Builder Map Settings Configuration
        internal MapOptions(Configuration cfg, string mapname, bool longtexturenamessupported)
        {
            // Initialize
            this.previousname   = "";
            this.currentname    = mapname;
            this.strictpatches  = General.Int2Bool(cfg.ReadSetting("strictpatches", 0));
            this.configfile     = cfg.ReadSetting("gameconfig", "");
            this.resources      = new DataLocationList();
            this.mapconfig      = new Configuration(true);
            this.scriptsettings = new Dictionary <string, ScriptDocumentSettings>(StringComparer.OrdinalIgnoreCase);            //mxd

            // Read map configuration
            this.mapconfig.Root = cfg.ReadSetting("maps." + mapname, new Hashtable());

            //mxd. Read Tag Labels
            this.tagLabels = new Dictionary <int, string>();
            ListDictionary tagLabelsData = (ListDictionary)this.mapconfig.ReadSetting("taglabels", new ListDictionary());

            foreach (DictionaryEntry tagLabelsEntry in tagLabelsData)
            {
                int    tag   = 0;
                string label = string.Empty;

                foreach (DictionaryEntry entry in (ListDictionary)tagLabelsEntry.Value)
                {
                    switch ((string)entry.Key)
                    {
                    case "tag": tag = (int)entry.Value; break;

                    case "label": label = (string)entry.Value; break;
                    }
                }

                if (tag != 0 && !string.IsNullOrEmpty(label))
                {
                    tagLabels.Add(tag, label);
                }
            }

            //mxd. Script compiler
            scriptcompiler = this.mapconfig.ReadSetting("scriptcompiler", string.Empty);

            //mxd. Read Sector drawing options
            defaultfloortexture  = this.mapconfig.ReadSetting("defaultfloortexture", string.Empty);
            defaultceiltexture   = this.mapconfig.ReadSetting("defaultceiltexture", string.Empty);
            defaulttoptexture    = this.mapconfig.ReadSetting("defaulttoptexture", string.Empty);
            defaultwalltexture   = this.mapconfig.ReadSetting("defaultwalltexture", string.Empty);
            defaultbottomtexture = this.mapconfig.ReadSetting("defaultbottomtexture", string.Empty);
            custombrightness     = General.Clamp(this.mapconfig.ReadSetting("custombrightness", 196), 0, 255);
            customfloorheight    = this.mapconfig.ReadSetting("customfloorheight", 0);
            customceilheight     = this.mapconfig.ReadSetting("customceilheight", 128);

            //mxd. Read Sector drawing overrides
            overridefloortexture  = this.mapconfig.ReadSetting("overridefloortexture", false);
            overrideceiltexture   = this.mapconfig.ReadSetting("overrideceiltexture", false);
            overridetoptexture    = this.mapconfig.ReadSetting("overridetoptexture", false);
            overridemiddletexture = this.mapconfig.ReadSetting("overridemiddletexture", false);
            overridebottomtexture = this.mapconfig.ReadSetting("overridebottomtexture", false);
            overridefloorheight   = this.mapconfig.ReadSetting("overridefloorheight", false);
            overrideceilheight    = this.mapconfig.ReadSetting("overrideceilheight", false);
            overridebrightness    = this.mapconfig.ReadSetting("overridebrightness", false);

            //mxd
            uselongtexturenames        = longtexturenamessupported && this.mapconfig.ReadSetting("uselongtexturenames", false);
            useresourcesinreadonlymode = this.mapconfig.ReadSetting("useresourcesinreadonlymode", false);

            //mxd. Position and scale
            float vpx = this.mapconfig.ReadSetting("viewpositionx", float.NaN);
            float vpy = this.mapconfig.ReadSetting("viewpositiony", float.NaN);

            if (!float.IsNaN(vpx) && !float.IsNaN(vpy))
            {
                viewposition = new Vector2D(vpx, vpy);
            }
            viewscale = this.mapconfig.ReadSetting("viewscale", float.NaN);

            // Resources
            IDictionary reslist = this.mapconfig.ReadSetting("resources", new Hashtable());

            foreach (DictionaryEntry mp in reslist)
            {
                // Item is a structure?
                IDictionary resinfo = mp.Value as IDictionary;
                if (resinfo != null)
                {
                    // Create resource
                    DataLocation res = new DataLocation();

                    // Copy information from Configuration to ResourceLocation
                    if (resinfo.Contains("type") && (resinfo["type"] is int))
                    {
                        res.type = (int)resinfo["type"];
                    }
                    if (resinfo.Contains("location") && (resinfo["location"] is string))
                    {
                        res.location = (string)resinfo["location"];
                    }
                    if (resinfo.Contains("textures") && (resinfo["textures"] is bool))
                    {
                        res.option1 = (bool)resinfo["textures"];
                    }
                    if (resinfo.Contains("flats") && (resinfo["flats"] is bool))
                    {
                        res.option2 = (bool)resinfo["flats"];
                    }

                    // Add resource
                    AddResource(res);
                }
            }

            //mxd. Read script documents settings
            IDictionary sflist = this.mapconfig.ReadSetting("scriptdocuments", new Hashtable());

            foreach (DictionaryEntry mp in sflist)
            {
                // Item is a structure?
                IDictionary scfinfo = mp.Value as IDictionary;
                if (scfinfo != null)
                {
                    ScriptDocumentSettings settings = ReadScriptDocumentSettings(scfinfo);
                    if (!string.IsNullOrEmpty(settings.Filename))
                    {
                        scriptsettings[settings.Filename] = settings;
                    }
                }
            }
        }
Esempio n. 21
0
        // This takes the unconverted parameters (with placeholders) and converts it
        // to parameters with full paths, names and numbers where placeholders were put.
        // The tempfile must be the full path and filename to the PWAD file to test.
        public string ConvertParameters(string parameters, int skill, bool shortpaths)
        {
            string       outp = parameters;
            DataLocation iwadloc;
            string       p_wp = "", p_wf = "";
            string       p_ap = "", p_apq = "";
            string       p_l1 = "", p_l2 = "";
            string       p_nm = "";
            string       f    = tempwad;

            // Make short path if needed
            if (shortpaths)
            {
                f = General.GetShortFilePath(f);
            }

            // Find the first IWAD file
            if (General.Map.Data.FindFirstIWAD(out iwadloc))
            {
                // %WP and %WF result in IWAD file
                p_wp = iwadloc.location;
                p_wf = Path.GetFileName(p_wp);
                if (shortpaths)
                {
                    p_wp = General.GetShortFilePath(p_wp);
                    p_wf = General.GetShortFilePath(p_wf);
                }
            }

            // Make a list of all data locations, including map location
            DataLocation     maplocation = new DataLocation(DataLocation.RESOURCE_WAD, General.Map.FilePathName, false, false, false);
            DataLocationList locations   = new DataLocationList();

            locations.AddRange(General.Map.ConfigSettings.Resources);
            locations.AddRange(General.Map.Options.Resources);
            locations.Add(maplocation);

            // Go for all data locations
            foreach (DataLocation dl in locations)
            {
                // Location not the IWAD file?
                if ((dl.type != DataLocation.RESOURCE_WAD) || (dl.location != iwadloc.location))
                {
                    // Location not included?
                    if (!dl.notfortesting)
                    {
                        // Add to string of files
                        if (shortpaths)
                        {
                            p_ap  += General.GetShortFilePath(dl.location) + " ";
                            p_apq += "\"" + General.GetShortFilePath(dl.location) + "\" ";
                        }
                        else
                        {
                            p_ap  += dl.location + " ";
                            p_apq += "\"" + dl.location + "\" ";
                        }
                    }
                }
            }

            // Trim last space from resource file locations
            p_ap  = p_ap.TrimEnd(' ');
            p_apq = p_apq.TrimEnd(' ');

            // Try finding the L1 and L2 numbers from the map name
            string numstr = "";
            bool   first  = true;

            foreach (char c in General.Map.Options.CurrentName)
            {
                // Character is a number?
                if (NUMBERS.IndexOf(c) > -1)
                {
                    // Include it
                    numstr += c;
                }
                else
                {
                    // Store the number if we found one
                    if (numstr.Length > 0)
                    {
                        int num = 0;
                        int.TryParse(numstr, out num);
                        if (first)
                        {
                            p_l1 = num.ToString();
                        }
                        else
                        {
                            p_l2 = num.ToString();
                        }
                        numstr = "";
                        first  = false;
                    }
                }
            }

            // Store the number if we found one
            if (numstr.Length > 0)
            {
                int num = 0;
                int.TryParse(numstr, out num);
                if (first)
                {
                    p_l1 = num.ToString();
                }
                else
                {
                    p_l2 = num.ToString();
                }
            }

            // No monsters?
            if (!General.Settings.TestMonsters)
            {
                p_nm = "-nomonsters";
            }

            // Make sure all our placeholders are in uppercase
            outp = outp.Replace("%f", "%F");
            outp = outp.Replace("%wp", "%WP");
            outp = outp.Replace("%wf", "%WF");
            outp = outp.Replace("%wP", "%WP");
            outp = outp.Replace("%wF", "%WF");
            outp = outp.Replace("%Wp", "%WP");
            outp = outp.Replace("%Wf", "%WF");
            outp = outp.Replace("%l1", "%L1");
            outp = outp.Replace("%l2", "%L2");
            outp = outp.Replace("%l", "%L");
            outp = outp.Replace("%ap", "%AP");
            outp = outp.Replace("%aP", "%AP");
            outp = outp.Replace("%Ap", "%AP");
            outp = outp.Replace("%s", "%S");
            outp = outp.Replace("%nM", "%NM");
            outp = outp.Replace("%Nm", "%NM");
            outp = outp.Replace("%nm", "%NM");

            // Replace placeholders with actual values
            outp = outp.Replace("%F", f);
            outp = outp.Replace("%WP", p_wp);
            outp = outp.Replace("%WF", p_wf);
            outp = outp.Replace("%L1", p_l1);
            outp = outp.Replace("%L2", p_l2);
            outp = outp.Replace("%L", General.Map.Options.CurrentName);
            outp = outp.Replace("\"%AP\"", p_apq);
            outp = outp.Replace("%AP", p_ap);
            outp = outp.Replace("%S", skill.ToString());
            outp = outp.Replace("%NM", p_nm);

            // Return result
            return(outp);
        }
Esempio n. 22
0
        // 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();
        }
        // Map name selected
        private void mapslist_ItemSelectionChanged(object sender, ListViewItemSelectionChangedEventArgs e)
        {
            if (!e.IsSelected)
            {
                return;                           //mxd. Don't want to trigger this twice
            }
            DataLocationList locations;
            DataLocationList listedlocations;
            string           scriptconfig = string.Empty;   //mxd

            // Map previously selected?
            if (!string.IsNullOrEmpty(selectedmapname))
            {
                // Get locations from previous selected map settings
                locations       = new DataLocationList(mapsettings, "maps." + selectedmapname + ".resources");
                listedlocations = datalocations.GetResources();

                // Remove data locations that this map has in its config
                foreach (DataLocation dl in locations)
                {
                    listedlocations.Remove(dl);
                }

                // Set new data locations
                datalocations.EditResourceLocationList(listedlocations);

                // Done
                selectedmapname = null;
            }

            // Anything selected?
            if (mapslist.SelectedItems.Count > 0)
            {
                // Get the map name
                selectedmapname = mapslist.SelectedItems[0].Text;
                options         = new MapOptions(mapsettings, selectedmapname, longtexturenames.Enabled);

                // Get locations from previous selected map settings
                locations       = new DataLocationList(mapsettings, "maps." + selectedmapname + ".resources");
                listedlocations = datalocations.GetResources();

                // Add data locations that this map has in its config
                foreach (DataLocation dl in locations)
                {
                    if (!listedlocations.Contains(dl))
                    {
                        listedlocations.Add(dl);
                    }
                }

                // Set new data locations
                datalocations.EditResourceLocationList(listedlocations);

                //mxd. Select script compiler
                ConfigurationInfo info = config.SelectedItem as ConfigurationInfo;
                if (info != null)
                {
                    if (!string.IsNullOrEmpty(options.ScriptCompiler) && General.CompiledScriptConfigs.ContainsKey(options.ScriptCompiler))
                    {
                        scriptconfig = options.ScriptCompiler;
                    }
                    else if (!string.IsNullOrEmpty(info.DefaultScriptCompiler) && General.CompiledScriptConfigs.ContainsKey(info.DefaultScriptCompiler))
                    {
                        scriptconfig = info.DefaultScriptCompiler;
                    }
                }
            }

            //mxd. Select proper script compiler
            if (!string.IsNullOrEmpty(scriptconfig))
            {
                scriptcompiler.Enabled      = true;
                scriptcompiler.SelectedItem = General.CompiledScriptConfigs[scriptconfig];
                scriptcompilerlabel.Enabled = true;
            }
            else
            {
                scriptcompiler.Enabled       = false;
                scriptcompiler.SelectedIndex = -1;
                scriptcompilerlabel.Enabled  = false;
            }
        }
        // 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();
        }
Esempio n. 25
0
 //mxd
 internal void PasteResourcesFrom(ConfigurationInfo source)
 {
     resources = new DataLocationList(source.resources);
     changed   = true;
 }
Esempio n. 26
0
        // 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();
        }