From 817cb2a7a4a9fe08bbc14c01605754ce2a805e5b Mon Sep 17 00:00:00 2001 From: MaxED <j.maxed@gmail.com> Date: Fri, 19 Apr 2013 11:35:56 +0000 Subject: [PATCH] DECORATE: When an actor inherits from an actor, defined in Game configuration, values from Game configuration are used if an actor doesn't define them. UDMF Controls plugin: changes made using plugin were not properly undoable. --- Source/Core/ZDoom/ActorStructure.cs | 40 ++++++++++++++++--- Source/Core/ZDoom/StateStructure.cs | 6 +++ .../UMDFControls/Windows/UDMFControlsForm.cs | 2 + 3 files changed, 43 insertions(+), 5 deletions(-) diff --git a/Source/Core/ZDoom/ActorStructure.cs b/Source/Core/ZDoom/ActorStructure.cs index 6ac44bb9f..268c435fb 100644 --- a/Source/Core/ZDoom/ActorStructure.cs +++ b/Source/Core/ZDoom/ActorStructure.cs @@ -18,6 +18,7 @@ using System.Collections.Generic; using System.Globalization; +using CodeImp.DoomBuilder.Config; #endregion @@ -42,7 +43,6 @@ namespace CodeImp.DoomBuilder.ZDoom // Inheriting private ActorStructure baseclass; private bool skipsuper; - private bool haveBaseClass;//mxd // Flags private Dictionary<string, bool> flags; @@ -79,6 +79,7 @@ namespace CodeImp.DoomBuilder.ZDoom props = new Dictionary<string, List<string>>(); states = new Dictionary<string, StateStructure>(); userVars = new List<string>();//mxd + bool haveBaseClass = false;//mxd // Always define a game property, but default to 0 values props["game"] = new List<string>(); @@ -165,10 +166,6 @@ namespace CodeImp.DoomBuilder.ZDoom return; } } - - //mxd. Check if baseclass is valid - if (haveBaseClass && doomednum > -1 && baseclass == null) - General.ErrorLogger.Add(ErrorType.Warning, "Unable to find the DECORATE class '" + inheritclass + "' to inherit from, while parsing '" + classname + ":" + doomednum +"'"); // Now parse the contents of actor structure string previoustoken = ""; @@ -360,6 +357,39 @@ namespace CodeImp.DoomBuilder.ZDoom // Keep token previoustoken = token; } + + //mxd. Check if baseclass is valid + if(haveBaseClass && doomednum > -1 && baseclass == null) { + //check if this class inherits from a class defined in game configuration + Dictionary<int, ThingTypeInfo> things = General.Map.Config.GetThingTypes(); + inheritclass = inheritclass.ToLowerInvariant(); + + foreach(KeyValuePair<int, ThingTypeInfo> ti in things) { + if(ti.Value.ClassName == inheritclass) { + //states + if(states.Count == 0 && !string.IsNullOrEmpty(ti.Value.Sprite)) + states.Add("spawn", new StateStructure(ti.Value.Sprite.Substring(0, 4))); + + //flags + if(ti.Value.Hangs && !flags.ContainsKey("spawnceiling")) + flags["spawnceiling"] = true; + + if(ti.Value.Blocking > 0 && !flags.ContainsKey("solid")) + flags["solid"] = true; + + //properties + if(!props.ContainsKey("height")) + props["height"] = new List<string>() { ti.Value.Height.ToString() }; + + if(!props.ContainsKey("radius")) + props["radius"] = new List<string>() { ti.Value.Radius.ToString() }; + + return; + } + } + + General.ErrorLogger.Add(ErrorType.Warning, "Unable to find the DECORATE class '" + inheritclass + "' to inherit from, while parsing '" + classname + ":" + doomednum + "'"); + } } // Disposer diff --git a/Source/Core/ZDoom/StateStructure.cs b/Source/Core/ZDoom/StateStructure.cs index 354107e78..b5bbd771c 100644 --- a/Source/Core/ZDoom/StateStructure.cs +++ b/Source/Core/ZDoom/StateStructure.cs @@ -155,6 +155,12 @@ namespace CodeImp.DoomBuilder.ZDoom } } + //mxd + internal StateStructure(string spriteName) { + this.gotostate = null; + this.sprites = new List<string>() { spriteName }; + } + #endregion #region ================== Methods diff --git a/Source/Plugins/UMDFControls/Windows/UDMFControlsForm.cs b/Source/Plugins/UMDFControls/Windows/UDMFControlsForm.cs index 7d37be97a..4ac34f61f 100644 --- a/Source/Plugins/UMDFControls/Windows/UDMFControlsForm.cs +++ b/Source/Plugins/UMDFControls/Windows/UDMFControlsForm.cs @@ -216,6 +216,8 @@ namespace CodeImp.DoomBuilder.UDMFControls } private void setDefaultUniversalProperties(UniFields fields, List<UniversalFieldInfo> defaultFields) { + fields.BeforeFieldsChange(); + foreach (UniversalFieldInfo info in defaultFields) { if (!fields.ContainsKey(info.Name)) fields.Add(info.Name, new UniValue(info.Type, (UniversalType)info.Type == UniversalType.Integer ? (object)Convert.ToInt32(info.Default, CultureInfo.InvariantCulture) : info.Default)); -- GitLab