diff --git a/Build/Configurations/Includes/ZDoom_linedefs.cfg b/Build/Configurations/Includes/ZDoom_linedefs.cfg index 13105f66a1dc3282691b2a1e19e94d536da11b8a..f490230c363760b4b30578f9643ead8b9e4c4868 100644 --- a/Build/Configurations/Includes/ZDoom_linedefs.cfg +++ b/Build/Configurations/Includes/ZDoom_linedefs.cfg @@ -1995,10 +1995,10 @@ zdoom } arg2 { - title = "Reverse Delay (tics)"; + title = "Reverse Delay (octics)"; type = 11; - enum = "delay_tics"; - default = 35; + enum = "delay_octics"; + default = 24; } arg3 { diff --git a/Build/Configurations/Includes/ZDoom_misc.cfg b/Build/Configurations/Includes/ZDoom_misc.cfg index 65568678e4a7a50c06626a5138141a82f934c804..f5fcc7589d79ffd57abcbef1c75ef0883d57b040 100644 --- a/Build/Configurations/Includes/ZDoom_misc.cfg +++ b/Build/Configurations/Includes/ZDoom_misc.cfg @@ -831,6 +831,21 @@ enums 315 = "315: 9 Seconds"; 350 = "350: 10 Seconds"; } + + delay_octics + { + 0 = "0: No delay"; + 8 = "8: 1 Second"; + 16 = "16: 2 Seconds"; + 24 = "24: 3 Seconds"; + 32 = "32: 4 Seconds"; + 40 = "40: 5 Seconds"; + 48 = "48: 6 Seconds"; + 56 = "56: 7 Seconds"; + 64 = "64: 8 Seconds"; + 72 = "72: 9 Seconds"; + 80 = "80: 10 Seconds"; + } delay_seconds { diff --git a/Source/Core/Config/GameConfiguration.cs b/Source/Core/Config/GameConfiguration.cs index c1a195628ad1bebdeca7288aa29aa42f6405c2b5..04c6beea6b86065d407b66989c7aca691867e8d7 100644 --- a/Source/Core/Config/GameConfiguration.cs +++ b/Source/Core/Config/GameConfiguration.cs @@ -542,16 +542,20 @@ namespace CodeImp.DoomBuilder.Config IDictionary dic = cfg.ReadSetting("universalfields." + elementname, new Hashtable()); foreach(DictionaryEntry de in dic) { +#if !DEBUG try { +#endif // Read the field info and add to list - UniversalFieldInfo uf = new UniversalFieldInfo(elementname, de.Key.ToString(), cfg, enums); + UniversalFieldInfo uf = new UniversalFieldInfo(elementname, de.Key.ToString(), this.Name, cfg, enums); list.Add(uf); +#if !DEBUG } catch(Exception) { General.ErrorLogger.Add(ErrorType.Warning, "Unable to read universal field definition \"universalfields." + elementname + "." + de.Key + "\" from game configuration \"" + this.Name + "\""); } +#endif } // Return result diff --git a/Source/Core/Config/UniversalFieldInfo.cs b/Source/Core/Config/UniversalFieldInfo.cs index da96162391df5d9e31cc13e6e726bf3f47defac0..bb12cd8fc086b2c451537264c533c7270899491e 100644 --- a/Source/Core/Config/UniversalFieldInfo.cs +++ b/Source/Core/Config/UniversalFieldInfo.cs @@ -20,6 +20,7 @@ using System; using System.Collections; using System.Collections.Generic; using CodeImp.DoomBuilder.IO; +using CodeImp.DoomBuilder.Types; #endregion @@ -53,7 +54,7 @@ namespace CodeImp.DoomBuilder.Config #region ================== Constructor / Disposer // Constructor - internal UniversalFieldInfo(string path, string name, Configuration cfg, IDictionary<string, EnumList> enums) + internal UniversalFieldInfo(string path, string name, string configname, Configuration cfg, IDictionary<string, EnumList> enums) { string setting = "universalfields." + path + "." + name; @@ -61,8 +62,26 @@ namespace CodeImp.DoomBuilder.Config this.name = name.ToLowerInvariant(); // Read type - this.type = cfg.ReadSetting(setting + ".type", 0); + this.type = cfg.ReadSetting(setting + ".type", int.MinValue); this.defaultvalue = cfg.ReadSettingObject(setting + ".default", null); + + //mxd. Check type + if(this.type == int.MinValue) + { + General.ErrorLogger.Add(ErrorType.Warning, "No type is defined for universal field \"" + name + "\" defined in \"" + configname + "\". Integer type will be used."); + this.type = (int)UniversalType.Integer; + } + + TypeHandler th = General.Types.GetFieldHandler(this); + if(th is NullHandler) + { + General.ErrorLogger.Add(ErrorType.Warning, "Universal field \"" + name + "\" defined in \"" + configname + "\" has unknown type " + this.type + ". String type will be used instead."); + this.type = (int)UniversalType.String; + if(this.defaultvalue == null) this.defaultvalue = ""; + } + + //mxd. Default value is missing? Get it from typehandler + if(this.defaultvalue == null) this.defaultvalue = th.GetDefaultValue(); // Read enum object enumsetting = cfg.ReadSettingObject(setting + ".enum", null); diff --git a/Source/Core/Types/LinedefTagHandler.cs b/Source/Core/Types/LinedefTagHandler.cs index b9050b8452b9980621572724e9d9a7e27795b995..640aec58ffda41648c91170b3607c8b28f4faa17 100644 --- a/Source/Core/Types/LinedefTagHandler.cs +++ b/Source/Core/Types/LinedefTagHandler.cs @@ -27,32 +27,35 @@ namespace CodeImp.DoomBuilder.Types [TypeHandler(UniversalType.LinedefTag, "Linedef Tag", true)] internal class LinedefTagHandler : SectorTagHandler { - #region ================== Setup + #region ================== Setup (mxd) protected override EnumList CreateEnumList() { - //collect tags + // Collect tags List<int> tags = new List<int>(); HashSet<int> tagshash = new HashSet<int>(); EnumList taglist = new EnumList(); - foreach(Linedef l in General.Map.Map.Linedefs) + if(General.Map.Map != null) { - if(l.Tag == 0 || tagshash.IsSupersetOf(l.Tags)) continue; - tags.AddRange(l.Tags); - foreach(int i in l.Tags) tagshash.Add(i); - } + foreach(Linedef l in General.Map.Map.Linedefs) + { + if(l.Tag == 0 || tagshash.IsSupersetOf(l.Tags)) continue; + tags.AddRange(l.Tags); + foreach(int i in l.Tags) tagshash.Add(i); + } - //now sort them in descending order - tags.Sort((a, b) => -1 * a.CompareTo(b)); + // Now sort them in descending order + tags.Sort((a, b) => -1 * a.CompareTo(b)); - //create enum items - foreach(int tag in tags) - { - if(General.Map.Options.TagLabels.ContainsKey(tag)) //tag labels - taglist.Add(new EnumItem(tag.ToString(), General.Map.Options.TagLabels[tag])); - else - taglist.Add(new EnumItem(tag.ToString(), tag.ToString())); + // Create enum items + foreach(int tag in tags) + { + if(General.Map.Options.TagLabels.ContainsKey(tag)) // Tag labels + taglist.Add(new EnumItem(tag.ToString(), General.Map.Options.TagLabels[tag])); + else + taglist.Add(new EnumItem(tag.ToString(), tag.ToString())); + } } return taglist; diff --git a/Source/Core/Types/SectorTagHandler.cs b/Source/Core/Types/SectorTagHandler.cs index 0a73afaa2db411451febc01d936ad2e1400e80f7..c9392206109ea8824806efc068dbb0fa657562b3 100644 --- a/Source/Core/Types/SectorTagHandler.cs +++ b/Source/Core/Types/SectorTagHandler.cs @@ -71,28 +71,31 @@ namespace CodeImp.DoomBuilder.Types //mxd protected virtual EnumList CreateEnumList() { - //collect tags + // Collect tags List<int> tags = new List<int>(); HashSet<int> tagshash = new HashSet<int>(); EnumList taglist = new EnumList(); - foreach(Sector s in General.Map.Map.Sectors) + if(General.Map.Map != null) { - if(s.Tag == 0 || tagshash.IsSupersetOf(s.Tags)) continue; - tags.AddRange(s.Tags); - foreach(int i in s.Tags) tagshash.Add(i); - } + foreach(Sector s in General.Map.Map.Sectors) + { + if(s.Tag == 0 || tagshash.IsSupersetOf(s.Tags)) continue; + tags.AddRange(s.Tags); + foreach(int i in s.Tags) tagshash.Add(i); + } - //now sort them in descending order - tags.Sort((a, b) => -1 * a.CompareTo(b)); + // Now sort them in descending order + tags.Sort((a, b) => -1 * a.CompareTo(b)); - //create enum items - foreach(int tag in tags) - { - if(General.Map.Options.TagLabels.ContainsKey(tag)) //tag labels - taglist.Add(new EnumItem(tag.ToString(), tag + ": " + General.Map.Options.TagLabels[tag])); - else - taglist.Add(new EnumItem(tag.ToString(), tag.ToString())); + // Create enum items + foreach(int tag in tags) + { + if(General.Map.Options.TagLabels.ContainsKey(tag)) // Tag labels + taglist.Add(new EnumItem(tag.ToString(), tag + ": " + General.Map.Options.TagLabels[tag])); + else + taglist.Add(new EnumItem(tag.ToString(), tag.ToString())); + } } return taglist; diff --git a/Source/Core/Types/ThingTagHandler.cs b/Source/Core/Types/ThingTagHandler.cs index b5e814b4d8b12c4d87e761f2263b1d5834d8e4e1..0b83788fa41a6866f8493ece5e9f16972f1771c4 100644 --- a/Source/Core/Types/ThingTagHandler.cs +++ b/Source/Core/Types/ThingTagHandler.cs @@ -27,7 +27,7 @@ namespace CodeImp.DoomBuilder.Types [TypeHandler(UniversalType.ThingTag, "Thing Tag", true)] internal class ThingTagHandler : SectorTagHandler { - #region ================== Setup + #region ================== Setup (mxd) protected override EnumList CreateEnumList() { @@ -35,30 +35,34 @@ namespace CodeImp.DoomBuilder.Types List<int> tags = new List<int>(); EnumList taglist = new EnumList(); - foreach(Thing t in General.Map.Map.Things) + if(General.Map.Map != null) { - if(t.Tag == 0 || tags.Contains(t.Tag)) continue; - - // Check target class? - if(arginfo.TargetClasses.Count > 0) + foreach(Thing t in General.Map.Map.Things) { - ThingTypeInfo info = General.Map.Data.GetThingInfoEx(t.Type); - if(info != null && !arginfo.TargetClasses.Contains(info.ClassName)) continue; - } + if(t.Tag == 0 || tags.Contains(t.Tag)) continue; - tags.Add(t.Tag); - } + // Check target class? + if(arginfo.TargetClasses.Count > 0) + { + ThingTypeInfo info = General.Map.Data.GetThingInfoEx(t.Type); + if(info != null && !arginfo.TargetClasses.Contains(info.ClassName)) + continue; + } + + tags.Add(t.Tag); + } - // Now sort them in descending order - tags.Sort((a, b) => -1 * a.CompareTo(b)); + // Now sort them in descending order + tags.Sort((a, b) => -1 * a.CompareTo(b)); - // Create enum items - foreach(int tag in tags) - { - if(General.Map.Options.TagLabels.ContainsKey(tag)) // Tag labels - taglist.Add(new EnumItem(tag.ToString(), General.Map.Options.TagLabels[tag])); - else - taglist.Add(new EnumItem(tag.ToString(), tag.ToString())); + // Create enum items + foreach(int tag in tags) + { + if(General.Map.Options.TagLabels.ContainsKey(tag)) // Tag labels + taglist.Add(new EnumItem(tag.ToString(), General.Map.Options.TagLabels[tag])); + else + taglist.Add(new EnumItem(tag.ToString(), tag.ToString())); + } } return taglist; diff --git a/Source/Core/Windows/ConfigForm.cs b/Source/Core/Windows/ConfigForm.cs index f4099c21e7521dc5d79133deadca5d182ab311c8..267d079eb108ee7034e79b28798065096283b777 100644 --- a/Source/Core/Windows/ConfigForm.cs +++ b/Source/Core/Windows/ConfigForm.cs @@ -839,13 +839,18 @@ namespace CodeImp.DoomBuilder.Windows { if(listconfigs.SelectedIndices.Count < 1) return; - //get current configinfo + // Get current configinfo ConfigurationInfo current = listconfigs.SelectedItems[0].Tag as ConfigurationInfo; current.PasteFrom(configinfocopy); - //update display + // Update display cbEngineSelector.Text = string.Empty; // Otherwise current text from cbEngineSelector will override the pasted one listconfigs_SelectedIndexChanged(listconfigs, EventArgs.Empty); + + // Resources need reloading? + if(General.Map != null && General.Map.ConfigSettings.Name == current.Name) + reloadresources = true; + General.Interface.DisplayStatus(StatusType.Info, "Pasted game configuration from \"" + configinfocopy.Name + "\""); } @@ -853,12 +858,17 @@ namespace CodeImp.DoomBuilder.Windows { if(listconfigs.SelectedIndices.Count < 1) return; - //get current configinfo + // Get current configinfo ConfigurationInfo current = listconfigs.SelectedItems[0].Tag as ConfigurationInfo; current.PasteResourcesFrom(configinfocopy); - //update display + // Update display listconfigs_SelectedIndexChanged(listconfigs, EventArgs.Empty); + + // Resources need reloading? + if(General.Map != null && General.Map.ConfigSettings.Name == current.Name) + reloadresources = true; + General.Interface.DisplayStatus(StatusType.Info, "Pasted resources from \"" + configinfocopy.Name + "\""); } @@ -866,11 +876,11 @@ namespace CodeImp.DoomBuilder.Windows { if(listconfigs.SelectedIndices.Count < 1) return; - //get current configinfo + // Get current configinfo ConfigurationInfo current = listconfigs.SelectedItems[0].Tag as ConfigurationInfo; current.PasteTestEnginesFrom(configinfocopy); - //update display + // Update display cbEngineSelector.Text = string.Empty; // Otherwise current text from cbEngineSelector will override the pasted one listconfigs_SelectedIndexChanged(listconfigs, EventArgs.Empty); General.Interface.DisplayStatus(StatusType.Info, "Pasted engines list from \"" + configinfocopy.Name + "\""); @@ -880,11 +890,11 @@ namespace CodeImp.DoomBuilder.Windows { if(listconfigs.SelectedIndices.Count < 1) return; - //get current configinfo + // Get current configinfo ConfigurationInfo current = listconfigs.SelectedItems[0].Tag as ConfigurationInfo; current.PasteColorPresetsFrom(configinfocopy); - //update display + // Update display listconfigs_SelectedIndexChanged(listconfigs, EventArgs.Empty); General.Interface.DisplayStatus(StatusType.Info, "Pasted color presets from \"" + configinfocopy.Name + "\""); }