diff --git a/Source/BuilderModes/BuilderModes.csproj b/Source/BuilderModes/BuilderModes.csproj index c99e7931..353ae41b 100644 --- a/Source/BuilderModes/BuilderModes.csproj +++ b/Source/BuilderModes/BuilderModes.csproj @@ -99,7 +99,7 @@ True Resources.resx - + @@ -110,7 +110,7 @@ - + Form diff --git a/Source/BuilderModes/ClassicModes/BrightnessMode.cs b/Source/BuilderModes/ClassicModes/BrightnessMode.cs index 798a5359..be8bbb5b 100644 --- a/Source/BuilderModes/ClassicModes/BrightnessMode.cs +++ b/Source/BuilderModes/ClassicModes/BrightnessMode.cs @@ -40,10 +40,10 @@ namespace CodeImp.DoomBuilder.BuilderModes { [EditMode(DisplayName = "Brightness Mode", SwitchAction = "brightnessmode", - ButtonDesc = "Brightness Mode", ButtonImage = "BrightnessMode.png", ButtonOrder = int.MinValue + 201, - AllowCopyPaste = false)] + AllowCopyPaste = false, + UseByDefault = true)] public sealed class BrightnessMode : BaseClassicMode { diff --git a/Source/BuilderModes/ClassicModes/DrawGeometryMode.cs b/Source/BuilderModes/ClassicModes/DrawGeometryMode.cs index 3dc33d74..8b33d7f3 100644 --- a/Source/BuilderModes/ClassicModes/DrawGeometryMode.cs +++ b/Source/BuilderModes/ClassicModes/DrawGeometryMode.cs @@ -37,9 +37,11 @@ using CodeImp.DoomBuilder.Actions; namespace CodeImp.DoomBuilder.BuilderModes { - [EditMode(DisplayName = "Drawing", + [EditMode(DisplayName = "Drawing Mode", SwitchAction = "drawlinesmode", - Volatile = true)] + Volatile = true, + UseByDefault = true, + Optional = false)] public class DrawGeometryMode : BaseClassicMode { diff --git a/Source/BuilderModes/ClassicModes/EditSelectionMode.cs b/Source/BuilderModes/ClassicModes/EditSelectionMode.cs index f19eb046..97e83538 100644 --- a/Source/BuilderModes/ClassicModes/EditSelectionMode.cs +++ b/Source/BuilderModes/ClassicModes/EditSelectionMode.cs @@ -39,9 +39,11 @@ using System.Drawing; namespace CodeImp.DoomBuilder.BuilderModes { - [EditMode(DisplayName = "Edit Selection", + [EditMode(DisplayName = "Edit Selection Mode", SwitchAction = "editselectionmode", // Action name used to switch to this mode - Volatile = true)] + Volatile = true, + UseByDefault = true, + Optional = false)] public class EditSelectionMode : BaseClassicMode { diff --git a/Source/BuilderModes/ClassicModes/ErrorCheckMode.cs b/Source/BuilderModes/ClassicModes/ErrorCheckMode.cs index 469d39fb..054f5072 100644 --- a/Source/BuilderModes/ClassicModes/ErrorCheckMode.cs +++ b/Source/BuilderModes/ClassicModes/ErrorCheckMode.cs @@ -36,9 +36,10 @@ using CodeImp.DoomBuilder.Editing; namespace CodeImp.DoomBuilder.BuilderModes { - [EditMode(DisplayName = "Map Analysis", + [EditMode(DisplayName = "Map Analysis Mode", SwitchAction = "errorcheckmode", - Volatile = true)] + Volatile = true, + UseByDefault = true)] public sealed class ErrorCheckMode : BaseClassicMode { diff --git a/Source/BuilderModes/ClassicModes/FindReplaceMode.cs b/Source/BuilderModes/ClassicModes/FindReplaceMode.cs index 075ee0ad..956243ee 100644 --- a/Source/BuilderModes/ClassicModes/FindReplaceMode.cs +++ b/Source/BuilderModes/ClassicModes/FindReplaceMode.cs @@ -36,9 +36,10 @@ using CodeImp.DoomBuilder.Editing; namespace CodeImp.DoomBuilder.BuilderModes { - [EditMode(DisplayName = "Find & Replace", + [EditMode(DisplayName = "Find & Replace Mode", SwitchAction = "findmode", - Volatile = true)] + Volatile = true, + UseByDefault = true)] public sealed class FindReplaceMode : BaseClassicMode { diff --git a/Source/BuilderModes/ClassicModes/LinedefsMode.cs b/Source/BuilderModes/ClassicModes/LinedefsMode.cs index ee1b4c4e..75e717d5 100644 --- a/Source/BuilderModes/ClassicModes/LinedefsMode.cs +++ b/Source/BuilderModes/ClassicModes/LinedefsMode.cs @@ -38,11 +38,11 @@ using CodeImp.DoomBuilder.Config; namespace CodeImp.DoomBuilder.BuilderModes { - [EditMode(DisplayName = "Linedefs", + [EditMode(DisplayName = "Linedefs Mode", SwitchAction = "linedefsmode", // Action name used to switch to this mode - ButtonDesc = "Linedefs Mode", // Description on the button in toolbar/menu ButtonImage = "LinesMode.png", // Image resource name for the button - ButtonOrder = int.MinValue + 100)] // Position of the button (lower is more to the left) + ButtonOrder = int.MinValue + 100, // Position of the button (lower is more to the left) + UseByDefault = true)] public class LinedefsMode : BaseClassicMode { diff --git a/Source/BuilderModes/ClassicModes/MakeSectorMode.cs b/Source/BuilderModes/ClassicModes/MakeSectorMode.cs index a647f37f..b8ad61b0 100644 --- a/Source/BuilderModes/ClassicModes/MakeSectorMode.cs +++ b/Source/BuilderModes/ClassicModes/MakeSectorMode.cs @@ -37,11 +37,11 @@ using CodeImp.DoomBuilder.Actions; namespace CodeImp.DoomBuilder.BuilderModes { - [EditMode(DisplayName = "Make Sectors", + [EditMode(DisplayName = "Make Sectors Mode", SwitchAction = "makesectormode", - ButtonDesc = "Make Sectors Mode", // Description on the button in toolbar/menu ButtonImage = "NewSector2.png", // Image resource name for the button - ButtonOrder = int.MinValue + 202)] // Position of the button (lower is more to the left) + ButtonOrder = int.MinValue + 202, // Position of the button (lower is more to the left) + UseByDefault = true)] public class MakeSectorMode : BaseClassicMode { diff --git a/Source/BuilderModes/ClassicModes/SectorsMode.cs b/Source/BuilderModes/ClassicModes/SectorsMode.cs index 3d53e5cf..00d60b6d 100644 --- a/Source/BuilderModes/ClassicModes/SectorsMode.cs +++ b/Source/BuilderModes/ClassicModes/SectorsMode.cs @@ -39,11 +39,11 @@ using CodeImp.DoomBuilder.BuilderModes.Interface; namespace CodeImp.DoomBuilder.BuilderModes { - [EditMode(DisplayName = "Sectors", + [EditMode(DisplayName = "Sectors Mode", SwitchAction = "sectorsmode", // Action name used to switch to this mode - ButtonDesc = "Sectors Mode", // Description on the button in toolbar/menu ButtonImage = "SectorsMode.png", // Image resource name for the button - ButtonOrder = int.MinValue + 200)] // Position of the button (lower is more to the left) + ButtonOrder = int.MinValue + 200, // Position of the button (lower is more to the left) + UseByDefault = true)] public class SectorsMode : BaseClassicMode { diff --git a/Source/BuilderModes/ClassicModes/ThingsMode.cs b/Source/BuilderModes/ClassicModes/ThingsMode.cs index adc78cee..1cb40d4c 100644 --- a/Source/BuilderModes/ClassicModes/ThingsMode.cs +++ b/Source/BuilderModes/ClassicModes/ThingsMode.cs @@ -38,11 +38,11 @@ using CodeImp.DoomBuilder.Types; namespace CodeImp.DoomBuilder.BuilderModes { - [EditMode(DisplayName = "Things", + [EditMode(DisplayName = "Things Mode", SwitchAction = "thingsmode", // Action name used to switch to this mode - ButtonDesc = "Things Mode", // Description on the button in toolbar/menu ButtonImage = "ThingsMode.png", // Image resource name for the button - ButtonOrder = int.MinValue + 300)] // Position of the button (lower is more to the left) + ButtonOrder = int.MinValue + 300, // Position of the button (lower is more to the left) + UseByDefault = true)] public class ThingsMode : BaseClassicMode { diff --git a/Source/BuilderModes/ClassicModes/VerticesMode.cs b/Source/BuilderModes/ClassicModes/VerticesMode.cs index dccfa5a3..86e59744 100644 --- a/Source/BuilderModes/ClassicModes/VerticesMode.cs +++ b/Source/BuilderModes/ClassicModes/VerticesMode.cs @@ -36,11 +36,11 @@ using CodeImp.DoomBuilder.Actions; namespace CodeImp.DoomBuilder.BuilderModes { - [EditMode(DisplayName = "Vertices", + [EditMode(DisplayName = "Vertices Mode", SwitchAction = "verticesmode", // Action name used to switch to this mode - ButtonDesc = "Vertices Mode", // Description on the button in toolbar/menu ButtonImage = "VerticesMode.png", // Image resource name for the button - ButtonOrder = int.MinValue + 0)] // Position of the button (lower is more to the left) + ButtonOrder = int.MinValue + 0, // Position of the button (lower is more to the left) + UseByDefault = true)] public class VerticesMode : BaseClassicMode { diff --git a/Source/BuilderModes/Testing/TriangulatorMode.cs b/Source/BuilderModes/Testing/TriangulatorMode.cs index e0601d4e..006bf7b2 100644 --- a/Source/BuilderModes/Testing/TriangulatorMode.cs +++ b/Source/BuilderModes/Testing/TriangulatorMode.cs @@ -39,8 +39,8 @@ namespace CodeImp.DoomBuilder.BuilderModes.Editing { #if DEBUG - [EditMode(SwitchAction = "triangulatormode", // Action name used to switch to this mode - ButtonDesc = "Triangulator Mode", // Description on the button in toolbar/menu + [EditMode(DisplayName = "Triangulator Mode", + SwitchAction = "triangulatormode", // Action name used to switch to this mode ButtonImage = "TriangulatorMode.png", // Image resource name for the button ButtonOrder = int.MaxValue)] // Position of the button (lower is more to the left) diff --git a/Source/BuilderModes/Testing/WAuthorMode.cs b/Source/BuilderModes/Testing/WAuthorMode.cs index c8281058..5dd46101 100644 --- a/Source/BuilderModes/Testing/WAuthorMode.cs +++ b/Source/BuilderModes/Testing/WAuthorMode.cs @@ -36,8 +36,10 @@ using CodeImp.DoomBuilder.Actions; namespace CodeImp.DoomBuilder.BuilderModes.Editing { - [EditMode(SwitchAction = "wauthormode", - ButtonDesc = "WadAuthor Mode", + #if DEBUG + + [EditMode(DisplayName = "WadAuthor Mode", + SwitchAction = "wauthormode", ButtonImage = "WAuthor.png", ButtonOrder = int.MinValue + 4)] @@ -385,4 +387,6 @@ namespace CodeImp.DoomBuilder.BuilderModes.Editing #endregion } + + #endif } diff --git a/Source/BuilderModes/VisualModes/BaseVisualMode.cs b/Source/BuilderModes/VisualModes/BaseVisualMode.cs index 2e28e6cf..0f8aee36 100644 --- a/Source/BuilderModes/VisualModes/BaseVisualMode.cs +++ b/Source/BuilderModes/VisualModes/BaseVisualMode.cs @@ -39,9 +39,9 @@ namespace CodeImp.DoomBuilder.BuilderModes { [EditMode(DisplayName = "Visual Mode", SwitchAction = "visualmode", // Action name used to switch to this mode - ButtonDesc = "Visual Mode", // Description on the button in toolbar/menu ButtonImage = "VisualMode.png", // Image resource name for the button - ButtonOrder = 0)] // Position of the button (lower is more to the left) + ButtonOrder = 0, // Position of the button (lower is more to the left) + UseByDefault = true)] public class BaseVisualMode : VisualMode { diff --git a/Source/Config/ConfigurationInfo.cs b/Source/Config/ConfigurationInfo.cs index 4de97086..b8d6a890 100644 --- a/Source/Config/ConfigurationInfo.cs +++ b/Source/Config/ConfigurationInfo.cs @@ -25,6 +25,7 @@ using CodeImp.DoomBuilder.IO; using CodeImp.DoomBuilder.Data; using System.IO; using CodeImp.DoomBuilder.Editing; +using System.Collections.Specialized; #endregion @@ -32,6 +33,13 @@ namespace CodeImp.DoomBuilder.Config { internal class ConfigurationInfo : IComparable { + #region ================== Constants + + private const string MODE_DISABLED_KEY = "disabled"; + private const string MODE_ENABLED_KEY = "enabled"; + + #endregion + #region ================== Variables private string name; @@ -47,7 +55,7 @@ namespace CodeImp.DoomBuilder.Config private int testskill; private List thingsfilters; private List texturesets; - private List editmodes; + private Dictionary editmodes; #endregion @@ -65,7 +73,7 @@ namespace CodeImp.DoomBuilder.Config public bool CustomParameters { get { return customparameters; } set { customparameters = value; } } internal ICollection ThingsFilters { get { return thingsfilters; } } public List TextureSets { get { return texturesets; } } - internal List EditModes { get { return editmodes; } } + internal Dictionary EditModes { get { return editmodes; } } #endregion @@ -108,11 +116,14 @@ namespace CodeImp.DoomBuilder.Config } // Make list of edit modes - this.editmodes = new List(); + this.editmodes = new Dictionary(); IDictionary modes = General.Settings.ReadSetting("configurations." + settingskey + ".editmodes", new Hashtable()); foreach(DictionaryEntry de in modes) { - editmodes.Add(de.Value.ToString()); + 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); } } @@ -159,10 +170,18 @@ namespace CodeImp.DoomBuilder.Config } // Write filters to configuration - for(int i = 0; i < editmodes.Count; i++) + ListDictionary modeslist = new ListDictionary(); + int index = 0; + foreach(KeyValuePair em in editmodes) { - General.Settings.WriteSetting("configurations." + settingskey + ".editmodes.mode" + i.ToString(CultureInfo.InvariantCulture), editmodes[i]); + if(em.Value) + modeslist.Add(MODE_ENABLED_KEY + index.ToString(CultureInfo.InvariantCulture), em.Key); + else + modeslist.Add(MODE_DISABLED_KEY + index.ToString(CultureInfo.InvariantCulture), em.Key); + + index++; } + General.Settings.WriteSetting("configurations." + settingskey + ".editmodes", modeslist); } // String representation @@ -188,7 +207,7 @@ namespace CodeImp.DoomBuilder.Config ci.testskill = this.testskill; ci.texturesets = new List(); foreach(DefinedTextureSet s in this.texturesets) ci.texturesets.Add(s.Copy()); - ci.editmodes = new List(this.editmodes); + ci.editmodes = new Dictionary(this.editmodes); return ci; } @@ -208,20 +227,36 @@ namespace CodeImp.DoomBuilder.Config this.testskill = ci.testskill; this.texturesets = new List(); foreach(DefinedTextureSet s in ci.texturesets) this.texturesets.Add(s.Copy()); - this.editmodes = new List(ci.editmodes); + this.editmodes = new Dictionary(ci.editmodes); } // This applies the defaults - public void ApplyDefaults() + public void ApplyDefaults(GameConfiguration gameconfig) { - // No texture sets? - if(texturesets.Count == 0) + // We can only apply texture set defaults when the game configuration is specified + if(gameconfig != null) { - // Copy the default texture sets from the game configuration - foreach(DefinedTextureSet s in General.Map.Config.TextureSets) + // No texture sets? + if(texturesets.Count == 0) { - // Add a copy to our list - texturesets.Add(s.Copy()); + // Copy the default texture sets from the game configuration + foreach(DefinedTextureSet s in gameconfig.TextureSets) + { + // Add a copy to our list + texturesets.Add(s.Copy()); + } + } + } + + // Go for all available editing modes + foreach(EditModeInfo info in General.Editing.ModesInfo) + { + // Is this a mode thats is optional? + if(info.IsOptional) + { + // Add if not listed yet + if(!editmodes.ContainsKey(info.Type.FullName)) + editmodes.Add(info.Type.FullName, info.Attributes.UseByDefault); } } } diff --git a/Source/Editing/EditModeAttribute.cs b/Source/Editing/EditModeAttribute.cs index d18c0b94..a6918e12 100644 --- a/Source/Editing/EditModeAttribute.cs +++ b/Source/Editing/EditModeAttribute.cs @@ -39,12 +39,12 @@ namespace CodeImp.DoomBuilder.Editing // Properties private string switchaction = null; private string buttonimage = null; - private string buttondesc = null; private int buttonorder = 0; - private bool optional = false; + private bool optional = true; private bool isvolatile = false; private string displayname = ""; private bool allowcopypaste = true; + private bool usebydefault = false; #endregion @@ -63,11 +63,6 @@ namespace CodeImp.DoomBuilder.Editing /// public string ButtonImage { get { return buttonimage; } set { buttonimage = value; } } - /// - /// Toolbar button and menu item description of this mode. - /// - public string ButtonDesc { get { return buttondesc; } set { buttondesc = value; } } - /// /// Sorting number for the order of buttons on the toolbar. Buttons with /// lower values will be more to the left than buttons with higher values. @@ -80,6 +75,13 @@ namespace CodeImp.DoomBuilder.Editing /// public bool Optional { get { return optional; } set { optional = value; } } + /// + /// Set this to true to select this editing mode for use in all game configurations + /// by default. This only applies the first time and can still be changed by the user. + /// THIS OPTION MAY BE INTRUSIVE TO THE USER, USE WITH GREAT CARE! + /// + public bool UseByDefault { get { return usebydefault; } set { usebydefault = value; } } + /// /// When set to true, this mode is cancelled when core actions like /// undo and save are performed. The editing mode should then return to @@ -88,8 +90,8 @@ namespace CodeImp.DoomBuilder.Editing public bool Volatile { get { return isvolatile; } set { isvolatile = value; } } /// - /// Name to display on the button information bar when no specific element - /// information is displayed. + /// Name to display in the game configuration editing modes list and on the + /// information bar when the mode is currently active. /// public string DisplayName { get { return displayname; } set { displayname = value; } } diff --git a/Source/Editing/EditModeInfo.cs b/Source/Editing/EditModeInfo.cs index 41b9edf9..c8d7fc9b 100644 --- a/Source/Editing/EditModeInfo.cs +++ b/Source/Editing/EditModeInfo.cs @@ -61,6 +61,7 @@ namespace CodeImp.DoomBuilder.Editing public Plugin Plugin { get { return plugin; } } public Type Type { get { return type; } } + public bool IsOptional { get { return ((switchactionattr != null) || (buttonimage != null)) && attribs.Optional; } } public BeginActionAttribute SwitchAction { get { return switchactionattr; } } public Image ButtonImage { get { return buttonimage; } } public string ButtonDesc { get { return buttondesc; } } @@ -78,14 +79,18 @@ namespace CodeImp.DoomBuilder.Editing this.type = type; this.attribs = attr; + // Make switch action info + if((attribs.SwitchAction != null) && (attribs.SwitchAction.Length > 0)) + switchactionattr = new BeginActionAttribute(attribs.SwitchAction); + // Make button info - if((attr.ButtonImage != null) && (attr.ButtonDesc != null)) + if(attr.ButtonImage != null) { buttonimagestream = plugin.GetResourceStream(attr.ButtonImage); if(buttonimagestream != null) { buttonimage = Image.FromStream(buttonimagestream); - buttondesc = attr.ButtonDesc; + buttondesc = attr.DisplayName; buttonorder = attr.ButtonOrder; } } @@ -113,13 +118,9 @@ namespace CodeImp.DoomBuilder.Editing // This binds the action to switch to this editing mode public void BindSwitchAction() { - // Make switch action info - if((switchactiondel == null) && (attribs.SwitchAction != null) && (attribs.SwitchAction.Length > 0)) + if((switchactiondel == null) && (switchactionattr != null)) { - switchactionattr = new BeginActionAttribute(attribs.SwitchAction); switchactiondel = new ActionDelegate(UserSwitchToMode); - - // Bind switch action General.Actions.BindBeginDelegate(plugin.Assembly, switchactiondel, switchactionattr); } } diff --git a/Source/Editing/EditingManager.cs b/Source/Editing/EditingManager.cs index 74139bab..f6b89ed6 100644 --- a/Source/Editing/EditingManager.cs +++ b/Source/Editing/EditingManager.cs @@ -153,7 +153,10 @@ namespace CodeImp.DoomBuilder.Editing { foreach(EditModeInfo emi in allmodes) { - if(General.Map.ConfigSettings.EditModes.Contains(emi.Type.FullName)) + // Include the mode when it is listed and enabled + // Also include the mode when it is not optional + if( (General.Map.ConfigSettings.EditModes.ContainsKey(emi.Type.FullName) && + General.Map.ConfigSettings.EditModes[emi.Type.FullName]) || !emi.IsOptional ) { // Add the mode to be used and bind switch action usedmodes.Add(emi); @@ -188,11 +191,34 @@ namespace CodeImp.DoomBuilder.Editing { EditMode oldmode = mode; - // Log info - if(newmode != null) - General.WriteLogLine("Switching edit mode to " + newmode.GetType().Name + "..."); + if(nextmode != null) + { + // Verify that this mode is usable + bool allowuse = false; + foreach(EditModeInfo emi in usedmodes) + { + if(emi.Type.FullName == nextmode.GetType().FullName) + { + allowuse = true; + break; + } + } + + if(!allowuse) + { + General.Interface.MessageBeep(MessageBeepType.Error); + General.WriteLogLine("Attempt to switch to an invalid edit mode " + nextmode.GetType().Name + "!"); + return false; + } + else + { + General.WriteLogLine("Switching edit mode to " + nextmode.GetType().Name + "..."); + } + } else + { General.WriteLogLine("Stopping edit mode..."); + } // Remember previous mode newmode = nextmode; diff --git a/Source/General/General.cs b/Source/General/General.cs index 2d5145bb..10ba4077 100644 --- a/Source/General/General.cs +++ b/Source/General/General.cs @@ -599,15 +599,20 @@ namespace CodeImp.DoomBuilder plugins = new PluginManager(); plugins.LoadAllPlugins(); - // Now that all settings have been combined (core & plugins) apply the defaults - General.WriteLogLine("Applying configuration settings..."); - actions.ApplyDefaultShortcutKeys(); - mainwindow.ApplyShortcutKeys(); - // Load game configurations General.WriteLogLine("Loading game configurations..."); LoadAllGameConfigurations(); + // Create editing modes + General.WriteLogLine("Creating editing modes manager..."); + editing = new EditingManager(); + + // Now that all settings have been combined (core & plugins) apply the defaults + General.WriteLogLine("Applying configuration settings..."); + actions.ApplyDefaultShortcutKeys(); + mainwindow.ApplyShortcutKeys(); + foreach(ConfigurationInfo info in configs) info.ApplyDefaults(null); + // Load compiler configurations General.WriteLogLine("Loading compiler configurations..."); LoadAllCompilerConfigurations(); @@ -632,10 +637,6 @@ namespace CodeImp.DoomBuilder General.WriteLogLine("Creating types manager..."); types = new TypesManager(); - // Create editing modes - General.WriteLogLine("Creating editing modes manager..."); - editing = new EditingManager(); - // Do auto map loading when window is delayed if(delaymainwindow) mainwindow.PerformAutoMapLoading(); diff --git a/Source/General/MapManager.cs b/Source/General/MapManager.cs index b41a4823..e59c969f 100644 --- a/Source/General/MapManager.cs +++ b/Source/General/MapManager.cs @@ -234,7 +234,7 @@ namespace CodeImp.DoomBuilder General.WriteLogLine("Loading game configuration..."); configinfo = General.GetConfigurationInfo(options.ConfigFile); config = new GameConfiguration(General.LoadGameConfiguration(options.ConfigFile)); - configinfo.ApplyDefaults(); + configinfo.ApplyDefaults(config); General.Editing.UpdateCurrentEditModes(); // Create map data @@ -306,7 +306,7 @@ namespace CodeImp.DoomBuilder General.WriteLogLine("Loading game configuration..."); configinfo = General.GetConfigurationInfo(options.ConfigFile); config = new GameConfiguration(General.LoadGameConfiguration(options.ConfigFile)); - configinfo.ApplyDefaults(); + configinfo.ApplyDefaults(config); General.Editing.UpdateCurrentEditModes(); // Create map data @@ -1314,7 +1314,7 @@ namespace CodeImp.DoomBuilder General.WriteLogLine("Loading game configuration..."); configinfo = General.GetConfigurationInfo(options.ConfigFile); config = new GameConfiguration(General.LoadGameConfiguration(options.ConfigFile)); - configinfo.ApplyDefaults(); + configinfo.ApplyDefaults(config); General.Editing.UpdateCurrentEditModes(); // Setup new map format IO diff --git a/Source/Windows/ConfigForm.Designer.cs b/Source/Windows/ConfigForm.Designer.cs index 812c6612..3817f806 100644 --- a/Source/Windows/ConfigForm.Designer.cs +++ b/Source/Windows/ConfigForm.Designer.cs @@ -566,11 +566,11 @@ namespace CodeImp.DoomBuilder.Windows this.colmodeplugin}); this.listmodes.FullRowSelect = true; this.listmodes.HeaderStyle = System.Windows.Forms.ColumnHeaderStyle.Nonclickable; - this.listmodes.Location = new System.Drawing.Point(15, 76); + this.listmodes.Location = new System.Drawing.Point(15, 70); this.listmodes.MultiSelect = false; this.listmodes.Name = "listmodes"; this.listmodes.ShowGroups = false; - this.listmodes.Size = new System.Drawing.Size(442, 226); + this.listmodes.Size = new System.Drawing.Size(442, 233); this.listmodes.Sorting = System.Windows.Forms.SortOrder.Ascending; this.listmodes.TabIndex = 26; this.listmodes.UseCompatibleStateImageBehavior = false; diff --git a/Source/Windows/ConfigForm.cs b/Source/Windows/ConfigForm.cs index 3183c55d..1a0ef083 100644 --- a/Source/Windows/ConfigForm.cs +++ b/Source/Windows/ConfigForm.cs @@ -78,7 +78,7 @@ namespace CodeImp.DoomBuilder.Windows foreach(EditModeInfo emi in General.Editing.ModesInfo) { // Is this mode selectable by the user? - if(emi.ButtonImage != null) + if(emi.IsOptional) { lvi = listmodes.Items.Add(emi.Attributes.DisplayName); lvi.Tag = emi; @@ -109,6 +109,9 @@ namespace CodeImp.DoomBuilder.Windows // Load the game configuration gameconfig = new GameConfiguration(General.LoadGameConfiguration(configinfo.Filename)); + + // Set defaults + configinfo.ApplyDefaults(gameconfig); // Fill resources list configdata.EditResourceLocationList(configinfo.Resources); @@ -172,7 +175,7 @@ namespace CodeImp.DoomBuilder.Windows foreach(ListViewItem lvi in listmodes.Items) { EditModeInfo emi = (lvi.Tag as EditModeInfo); - lvi.Checked = configinfo.EditModes.Contains(emi.Type.FullName); + lvi.Checked = (configinfo.EditModes.ContainsKey(emi.Type.FullName) && configinfo.EditModes[emi.Type.FullName]); } } } @@ -486,16 +489,16 @@ namespace CodeImp.DoomBuilder.Windows // Apply changes EditModeInfo emi = (e.Item.Tag as EditModeInfo); - bool currentstate = configinfo.EditModes.Contains(emi.Type.FullName); + bool currentstate = (configinfo.EditModes.ContainsKey(emi.Type.FullName) && configinfo.EditModes[emi.Type.FullName]); if(e.Item.Checked && !currentstate) { // Add - configinfo.EditModes.Add(emi.Type.FullName); + configinfo.EditModes[emi.Type.FullName] = true; } else if(!e.Item.Checked && currentstate) { // Remove - configinfo.EditModes.Remove(emi.Type.FullName); + configinfo.EditModes[emi.Type.FullName] = false; } } }