From 85b8b4158089bd1f52e8e02d1edb59aa13812a25 Mon Sep 17 00:00:00 2001 From: biwa <6475593+biwa@users.noreply.github.com> Date: Mon, 22 Mar 2021 10:41:21 +0100 Subject: [PATCH] Map Analysis Mode: checking for missing activation flags (UDMF) now finds linedef that are missing an actual activation flag, not only lines without any flags in that group. Fixes #288 Linedef Editing Form (UDMF): now only missing required activation flags are marked red --- .../Configurations/Includes/Eternity_misc.cfg | 18 +++++++++-- Build/Configurations/Includes/UDMF_misc.cfg | 12 ++++++-- Build/Configurations/Includes/ZDoom_misc.cfg | 30 +++++++++++++++---- Source/Core/Config/GameConfiguration.cs | 15 ++++++++-- Source/Core/Config/LinedefActivateInfo.cs | 5 +++- .../Core/Windows/LinedefColorPresetsForm.cs | 2 +- Source/Core/Windows/LinedefEditFormUDMF.cs | 11 +++++-- .../ErrorChecks/CheckMissingActivations.cs | 4 +-- 8 files changed, 79 insertions(+), 18 deletions(-) diff --git a/Build/Configurations/Includes/Eternity_misc.cfg b/Build/Configurations/Includes/Eternity_misc.cfg index 76f472439..e725508f1 100755 --- a/Build/Configurations/Includes/Eternity_misc.cfg +++ b/Build/Configurations/Includes/Eternity_misc.cfg @@ -393,7 +393,11 @@ linedefflags_udmf linedefactivations_udmf { - repeatspecial = "Repeatable action"; + repeatspecial + { + name = "Repeatable action"; + istrigger = false; + } playeruse = "When player presses use"; playercross = "When player walks over"; playerpush = "When player bumps"; @@ -405,8 +409,16 @@ linedefactivations_udmf polycross = "When polyobject moves over"; impact = "On projectile impact"; // checkswitchrange = "Switch height check"; - passuse = "Pass use on"; - firstsideonly = "Front side only"; + passuse + { + name = "Pass use on"; + istrigger = false; + } + firstsideonly + { + name = "Front side only"; + istrigger = false; + } // playeruseback = "Player can use from back side"; } diff --git a/Build/Configurations/Includes/UDMF_misc.cfg b/Build/Configurations/Includes/UDMF_misc.cfg index acf495d04..589cb9dc0 100755 --- a/Build/Configurations/Includes/UDMF_misc.cfg +++ b/Build/Configurations/Includes/UDMF_misc.cfg @@ -110,8 +110,16 @@ linedefactivations playerpush = "When player bumps"; monsterpush = "When monsters bumps"; missilecross = "When projectile crosses"; - repeatspecial = "Repeatable action"; - passuse = "Pass use on"; + repeatspecial + { + name = "Repeatable action"; + istrigger = false; + } + passuse + { + name = "Pass use on"; + istrigger = false; + } } sidedefflags diff --git a/Build/Configurations/Includes/ZDoom_misc.cfg b/Build/Configurations/Includes/ZDoom_misc.cfg index 86e2a1c27..e295ff43e 100755 --- a/Build/Configurations/Includes/ZDoom_misc.cfg +++ b/Build/Configurations/Includes/ZDoom_misc.cfg @@ -56,7 +56,11 @@ linedefflags_udmf linedefactivations_udmf { - repeatspecial = "Repeatable action"; + repeatspecial + { + name = "Repeatable action"; + istrigger = false; + } playeruse = "When player presses use"; playercross = "When player walks over"; playerpush = "When player bumps"; @@ -66,10 +70,26 @@ linedefactivations_udmf anycross = "Any crossing non-missile activates"; missilecross = "When projectile crosses"; impact = "On projectile impact"; - checkswitchrange = "Switch height check"; - passuse = "Pass use on"; - firstsideonly = "Front side only"; - playeruseback = "Player can use from back side"; + checkswitchrange + { + name = "Switch height check"; + istrigger = false; + } + passuse + { + name = "Pass use on"; + istrigger = false; + } + firstsideonly + { + name = "Front side only"; + istrigger = false; + } + playeruseback + { + name = "Player can use from back side"; + istrigger = false; + } } diff --git a/Source/Core/Config/GameConfiguration.cs b/Source/Core/Config/GameConfiguration.cs index f4ac1788e..d27fee75c 100755 --- a/Source/Core/Config/GameConfiguration.cs +++ b/Source/Core/Config/GameConfiguration.cs @@ -19,6 +19,7 @@ using System; using System.Collections; using System.Collections.Generic; +using System.Collections.Specialized; using System.Globalization; using System.Linq; using System.Reflection; @@ -745,8 +746,18 @@ namespace CodeImp.DoomBuilder.Config IDictionary dic = cfg.ReadSetting("linedefactivations", new Hashtable()); foreach(DictionaryEntry de in dic) { - // Add to the list - linedefactivates.Add(new LinedefActivateInfo(de.Key.ToString(), de.Value.ToString())); + // If the value is a dictionary read the values from that + if (de.Value is ICollection) + { + string name = cfg.ReadSetting("linedefactivations." + de.Key.ToString() + ".name", de.Key.ToString()); + bool istrigger = cfg.ReadSetting("linedefactivations." + de.Key.ToString() + ".istrigger", true); + linedefactivates.Add(new LinedefActivateInfo(de.Key.ToString(), name, istrigger)); + } + else + { + // Add to the list + linedefactivates.Add(new LinedefActivateInfo(de.Key.ToString(), de.Value.ToString(), true)); + } } //mxd. Sort only when activations are numeric diff --git a/Source/Core/Config/LinedefActivateInfo.cs b/Source/Core/Config/LinedefActivateInfo.cs index 32c3f251d..d456deaf6 100755 --- a/Source/Core/Config/LinedefActivateInfo.cs +++ b/Source/Core/Config/LinedefActivateInfo.cs @@ -34,6 +34,7 @@ namespace CodeImp.DoomBuilder.Config private int intkey; private string key; private string title; + private bool istrigger; #endregion @@ -42,17 +43,19 @@ namespace CodeImp.DoomBuilder.Config public int Index { get { return intkey; } } public string Key { get { return key; } } public string Title { get { return title; } } + public bool IsTrigger { get { return istrigger; } } #endregion #region ================== Constructor / Disposer // Constructor - internal LinedefActivateInfo(string key, string title) + internal LinedefActivateInfo(string key, string title, bool istrigger) { // Initialize this.key = key; this.title = title; + this.istrigger = istrigger; // Try parsing key as int for comparison if(!int.TryParse(key, out intkey)) intkey = 0; diff --git a/Source/Core/Windows/LinedefColorPresetsForm.cs b/Source/Core/Windows/LinedefColorPresetsForm.cs index 60f4cfb7b..4d95315b0 100755 --- a/Source/Core/Windows/LinedefColorPresetsForm.cs +++ b/Source/Core/Windows/LinedefColorPresetsForm.cs @@ -99,7 +99,7 @@ namespace CodeImp.DoomBuilder.Windows if(activations.Count > 0) { - activations.Insert(0, new LinedefActivateInfo("-1", "Any activation")); + activations.Insert(0, new LinedefActivateInfo("-1", "Any activation", true)); if(General.Map.UDMF) { diff --git a/Source/Core/Windows/LinedefEditFormUDMF.cs b/Source/Core/Windows/LinedefEditFormUDMF.cs index ad1e0fde9..5f9a87c3d 100755 --- a/Source/Core/Windows/LinedefEditFormUDMF.cs +++ b/Source/Core/Windows/LinedefEditFormUDMF.cs @@ -617,7 +617,8 @@ namespace CodeImp.DoomBuilder.Windows bool haveactivationflag = false; foreach(CheckBox c in udmfactivates.Checkboxes) { - if(c.CheckState != CheckState.Unchecked) + LinedefActivateInfo ai = (c.Tag as LinedefActivateInfo); + if(ai.IsTrigger && c.CheckState != CheckState.Unchecked) { haveactivationflag = true; break; @@ -625,7 +626,13 @@ namespace CodeImp.DoomBuilder.Windows } missingactivation.Visible = !haveactivationflag; - activationGroup.ForeColor = (!haveactivationflag ? Color.DarkRed : SystemColors.ControlText); + + foreach (CheckBox c in udmfactivates.Checkboxes) + { + LinedefActivateInfo ai = (c.Tag as LinedefActivateInfo); + if (ai.IsTrigger) + c.ForeColor = (!haveactivationflag ? Color.DarkRed : SystemColors.ControlText); + } } else { diff --git a/Source/Plugins/BuilderModes/ErrorChecks/CheckMissingActivations.cs b/Source/Plugins/BuilderModes/ErrorChecks/CheckMissingActivations.cs index 70630a58e..979b864e9 100644 --- a/Source/Plugins/BuilderModes/ErrorChecks/CheckMissingActivations.cs +++ b/Source/Plugins/BuilderModes/ErrorChecks/CheckMissingActivations.cs @@ -31,7 +31,7 @@ namespace CodeImp.DoomBuilder.BuilderModes return; } - // Go for all vertices + // Go for all linedefs foreach (Linedef l in General.Map.Map.Linedefs) { int action = l.Action; @@ -43,7 +43,7 @@ namespace CodeImp.DoomBuilder.BuilderModes { foreach (LinedefActivateInfo ai in General.Map.Config.LinedefActivates) { - if (flags.ContainsKey(ai.Key) && flags[ai.Key] == true) + if (flags.ContainsKey(ai.Key) && flags[ai.Key] == true && ai.IsTrigger) { hasActivation = true; break; -- GitLab