From 515df9c1e9601ec7a23e1b75b5076986e4ddadd7 Mon Sep 17 00:00:00 2001 From: spherallic Date: Mon, 19 Dec 2022 20:55:10 +0100 Subject: [PATCH] Add angle arrow setting for individual thing definitions --- Build/Configurations/SRB2-22.cfg | 16 ++++++++++++++++ Source/Core/Config/ThingCategory.cs | 14 ++++++++++---- Source/Core/Config/ThingTypeInfo.cs | 22 +++++++++++++++------- Source/Core/SRB2/LuaObjectParser.cs | 11 ++++++++++- Source/Core/SRB2/SOCObjectParser.cs | 15 ++++++++++++++- Source/Core/SRB2/SRB2Object.cs | 6 +++++- 6 files changed, 70 insertions(+), 14 deletions(-) diff --git a/Build/Configurations/SRB2-22.cfg b/Build/Configurations/SRB2-22.cfg index a1be723..1061e36 100644 --- a/Build/Configurations/SRB2-22.cfg +++ b/Build/Configurations/SRB2-22.cfg @@ -4230,6 +4230,7 @@ thingtypes sprite = "internal:capsule"; angletext = "Tag"; fixedrotation = 1; + tagthing = true; } 292 { @@ -4464,6 +4465,7 @@ thingtypes flags8text = "[8] Random (Weak)"; angletext = "Tag"; fixedrotation = 1; + tagthing = true; 400 { @@ -4596,6 +4598,7 @@ thingtypes flags1text = "[1] Run linedef executor on pop"; angletext = "Tag"; fixedrotation = 1; + tagthing = true; 431 { @@ -5090,6 +5093,7 @@ thingtypes fixedrotation = 1; parametertext = "Absolute?"; flagsvaluetext = "Absolute Z"; + tagthing = true; } 751 @@ -5140,6 +5144,7 @@ thingtypes height = 16; angletext = "Tag"; fixedrotation = 1; + tagthing = true; } 757 { @@ -5149,6 +5154,7 @@ thingtypes height = 16; angletext = "Tag"; fixedrotation = 1; + tagthing = true; } 758 { @@ -5161,6 +5167,7 @@ thingtypes sprite = "internal:polyanchor"; angletext = "Tag"; fixedrotation = 1; + tagthing = true; } 761 @@ -5169,6 +5176,7 @@ thingtypes sprite = "internal:polycenter"; angletext = "Tag"; fixedrotation = 1; + tagthing = true; } 762 @@ -5177,6 +5185,7 @@ thingtypes sprite = "internal:polycentercrush"; angletext = "Tag"; fixedrotation = 1; + tagthing = true; } 780 { @@ -5523,6 +5532,7 @@ thingtypes angletext = "Tag"; parametertext = "Spokes"; fixedrotation = 1; + tagthing = true; } 1105 { @@ -5535,6 +5545,7 @@ thingtypes angletext = "Tag"; parametertext = "Spokes"; fixedrotation = 1; + tagthing = true; } 1106 { @@ -5547,6 +5558,7 @@ thingtypes angletext = "Tag"; parametertext = "Spokes"; fixedrotation = 1; + tagthing = true; } 1107 { @@ -5558,6 +5570,7 @@ thingtypes angletext = "Tag"; parametertext = "Spokes"; fixedrotation = 1; + tagthing = true; } 1108 { @@ -5579,6 +5592,7 @@ thingtypes angletext = "Tag"; parametertext = "Spokes"; fixedrotation = 1; + tagthing = true; } 1110 { @@ -5590,6 +5604,7 @@ thingtypes angletext = "Tag"; parametertext = "Spokes"; fixedrotation = 1; + tagthing = true; } 1111 { @@ -5771,6 +5786,7 @@ thingtypes height = 16; angletext = "Tag"; fixedrotation = 1; + tagthing = true; } 1203 { diff --git a/Source/Core/Config/ThingCategory.cs b/Source/Core/Config/ThingCategory.cs index 06db6ac..d7894c3 100644 --- a/Source/Core/Config/ThingCategory.cs +++ b/Source/Core/Config/ThingCategory.cs @@ -66,9 +66,10 @@ namespace CodeImp.DoomBuilder.Config private readonly string angletext; private readonly string flagsvaluetext; private readonly string parametertext; + private readonly bool tagthing; - // Disposing - private bool isdisposed; + // Disposing + private bool isdisposed; //mxd. Validity private bool isinvalid; @@ -106,6 +107,7 @@ namespace CodeImp.DoomBuilder.Config public string AngleText { get { return angletext; } } public string FlagsValueText { get { return flagsvaluetext; } } public string ParameterText { get { return parametertext; } } + public bool IsTagThing { get { return tagthing; } } #endregion #region ================== Constructor / Disposer @@ -144,7 +146,8 @@ namespace CodeImp.DoomBuilder.Config this.angletext = parent.angletext; this.flagsvaluetext = parent.flagsvaluetext; this.parametertext = parent.parametertext; - this.flags = parent.flags; + this.tagthing = parent.tagthing; + this.flags = parent.flags; } // Set default properties else @@ -171,6 +174,7 @@ namespace CodeImp.DoomBuilder.Config this.angletext = "Angle"; this.flagsvaluetext = "Flags value"; this.parametertext = "Parameter"; + this.tagthing = false; this.flags = new Dictionary(); } @@ -195,7 +199,7 @@ namespace CodeImp.DoomBuilder.Config if(this.title == name) { string[] props = new[] { "sprite", "sort", "color", "alpha", "renderstyle", "arrow", "width", - "height", "hangs", "blocking", "error", "fixedsize", "fixedrotation", "absolutez", "spritescale" }; + "height", "hangs", "blocking", "error", "fixedsize", "fixedrotation", "absolutez", "spritescale", "tagthing" }; isinvalid = true; foreach(string prop in props) @@ -234,6 +238,7 @@ namespace CodeImp.DoomBuilder.Config this.angletext = cfg.ReadSetting("thingtypes." + name + ".angletext", parent.angletext); this.flagsvaluetext = cfg.ReadSetting("thingtypes." + name + ".flagsvaluetext", parent.flagsvaluetext); this.parametertext = cfg.ReadSetting("thingtypes." + name + ".parametertext", parent.parametertext); + this.tagthing = cfg.ReadSetting("thingtypes." + name + ".tagthing", parent.tagthing); } else { @@ -259,6 +264,7 @@ namespace CodeImp.DoomBuilder.Config this.angletext = cfg.ReadSetting("thingtypes." + name + ".angletext", "Angle"); this.flagsvaluetext = cfg.ReadSetting("thingtypes." + name + ".flagsvaluetext", "Flags value"); this.parametertext = cfg.ReadSetting("thingtypes." + name + ".parametertext", "Parameter"); + this.tagthing = cfg.ReadSetting("thingtypes." + name + ".tagthing", false); } // Safety diff --git a/Source/Core/Config/ThingTypeInfo.cs b/Source/Core/Config/ThingTypeInfo.cs index 3bd3ec9..3fd08b7 100644 --- a/Source/Core/Config/ThingTypeInfo.cs +++ b/Source/Core/Config/ThingTypeInfo.cs @@ -59,7 +59,8 @@ namespace CodeImp.DoomBuilder.Config private string renderstyle; //mxd private bool bright; //mxd private bool arrow; - private float radius; + private bool tagthing; + private float radius; private float height; private bool hangs; private int blocking; @@ -104,7 +105,8 @@ namespace CodeImp.DoomBuilder.Config public string RenderStyle { get { return renderstyle; } } //mxd public bool Bright { get { return bright; } } //mxd public bool Arrow { get { return arrow; } } - public float Radius { get { return radius; } } + public bool IsTagThing { get { return tagthing; } } + public float Radius { get { return radius; } } public float Height { get { return height; } } public bool Hangs { get { return hangs; } } public int Blocking { get { return blocking; } } @@ -154,7 +156,8 @@ namespace CodeImp.DoomBuilder.Config this.renderstyle = "normal"; //mxd this.bright = false; //mxd this.arrow = true; - this.radius = 10f; + this.tagthing = false; + this.radius = 10f; this.height = 20f; this.hangs = false; this.blocking = 0; @@ -260,7 +263,8 @@ namespace CodeImp.DoomBuilder.Config this.sprite = cat.Sprite; this.color = cat.Color; this.arrow = (cat.Arrow != 0); - this.alpha = cat.Alpha; //mxd + this.tagthing = (cat.IsTagThing); + this.alpha = cat.Alpha; //mxd this.alphabyte = (byte)(this.alpha * 255); //mxd this.renderstyle = cat.RenderStyle; //mxd this.radius = cat.Radius; @@ -318,6 +322,7 @@ namespace CodeImp.DoomBuilder.Config this.alphabyte = (byte)(this.alpha * 255); //mxd this.renderstyle = cat.RenderStyle; //mxd this.arrow = (cat.Arrow != 0); + this.tagthing = cat.IsTagThing; this.radius = cat.Radius; this.height = cat.Height; this.hangs = (cat.Hangs != 0); @@ -368,7 +373,8 @@ namespace CodeImp.DoomBuilder.Config this.alphabyte = (byte)(this.alpha * 255); //mxd this.renderstyle = cat.RenderStyle; //mxd this.arrow = (cat.Arrow != 0); - this.radius = cat.Radius; + this.tagthing = cat.IsTagThing; + this.radius = cat.Radius; this.height = cat.Height; this.hangs = (cat.Hangs != 0); this.blocking = cat.Blocking; @@ -417,7 +423,8 @@ namespace CodeImp.DoomBuilder.Config this.alpha = cat.Alpha; //mxd this.alphabyte = (byte)(this.alpha * 255); //mxd this.renderstyle = cat.RenderStyle; //mxd - this.arrow = (cat.Arrow != 0); + this.arrow = (cat.Arrow != 0) || o.arrow; + this.tagthing = o.tagthing; this.radius = o.radius; this.height = o.height; this.hangs = o.Hangs(); @@ -483,7 +490,8 @@ namespace CodeImp.DoomBuilder.Config this.renderstyle = other.renderstyle; //mxd this.bright = other.bright; //mxd this.arrow = other.arrow; - this.radius = other.radius; + this.tagthing = other.tagthing; + this.radius = other.radius; this.height = other.height; this.hangs = other.hangs; this.blocking = other.blocking; diff --git a/Source/Core/SRB2/LuaObjectParser.cs b/Source/Core/SRB2/LuaObjectParser.cs index ab73c0a..876f9f9 100644 --- a/Source/Core/SRB2/LuaObjectParser.cs +++ b/Source/Core/SRB2/LuaObjectParser.cs @@ -9,6 +9,7 @@ using CodeImp.DoomBuilder.Compilers; using CodeImp.DoomBuilder.Data; using CodeImp.DoomBuilder.ZDoom; using CodeImp.DoomBuilder.GZBuilder.Data; +using System.Windows.Forms; #endregion @@ -131,6 +132,8 @@ namespace CodeImp.DoomBuilder.SRB2 string angletext = ""; string parametertext = ""; string flagsvaluetext = ""; + bool arrow = false; + bool tagthing = false; SkipWhitespace(true); token = ReadToken(); @@ -203,6 +206,12 @@ namespace CodeImp.DoomBuilder.SRB2 token = ReadLine(); flagsvaluetext = ZDTextParser.StripQuotes(token); break; + case "$Arrow": + arrow = true; + break; + case "$TagThing": + tagthing = true; + break; case "doomednum": if (!ReadParameter(out token, out finished)) return false; if (!int.TryParse(token, NumberStyles.Integer, CultureInfo.InvariantCulture, out mapThingNum)) @@ -295,7 +304,7 @@ namespace CodeImp.DoomBuilder.SRB2 if (mapThingNum > 0) { SRB2Object o = new SRB2Object(name, sprite, category, states, mapThingNum, radius, height, flags, - newflags, angletext, parametertext, flagsvaluetext); + newflags, angletext, parametertext, flagsvaluetext, arrow, tagthing); if (objects.ContainsKey(objname)) objects[objname] = o; else diff --git a/Source/Core/SRB2/SOCObjectParser.cs b/Source/Core/SRB2/SOCObjectParser.cs index 66fa928..795eebd 100644 --- a/Source/Core/SRB2/SOCObjectParser.cs +++ b/Source/Core/SRB2/SOCObjectParser.cs @@ -9,6 +9,7 @@ using CodeImp.DoomBuilder.Compilers; using CodeImp.DoomBuilder.Data; using CodeImp.DoomBuilder.ZDoom; using CodeImp.DoomBuilder.GZBuilder.Data; +using System.Windows.Forms; #endregion @@ -183,6 +184,8 @@ namespace CodeImp.DoomBuilder.SRB2 string angletext = ""; string parametertext = ""; string flagsvaluetext = ""; + bool arrow = false; + bool tagthing = false; while (!streamreader.EndOfStream) { string line = streamreader.ReadLine(); @@ -233,6 +236,16 @@ namespace CodeImp.DoomBuilder.SRB2 flagsvaluetext = ZDTextParser.StripQuotes(line.Substring(17)); continue; } + if (line.StartsWith("#$Arrow")) + { + arrow = true; + continue; + } + if (line.StartsWith("#$TagThing")) + { + tagthing = true; + continue; + } if (line.StartsWith("#")) continue; line = RemoveComments(line); string[] tokens = line.Split(new char[] { '=' }); @@ -293,7 +306,7 @@ namespace CodeImp.DoomBuilder.SRB2 if (mapThingNum > 0) { SRB2Object o = new SRB2Object(name, sprite, category, states, mapThingNum, radius, height, flags, - newflags, angletext, parametertext, flagsvaluetext); + newflags, angletext, parametertext, flagsvaluetext, arrow, tagthing); if (objects.ContainsKey(objname)) objects[objname] = o; else diff --git a/Source/Core/SRB2/SRB2Object.cs b/Source/Core/SRB2/SRB2Object.cs index d4f9e08..fbc1ac7 100644 --- a/Source/Core/SRB2/SRB2Object.cs +++ b/Source/Core/SRB2/SRB2Object.cs @@ -47,6 +47,8 @@ namespace CodeImp.DoomBuilder.SRB2 public readonly string angletext; public readonly string parametertext; public readonly string flagsvaluetext; + public readonly bool arrow; + public readonly bool tagthing; #endregion @@ -54,7 +56,7 @@ namespace CodeImp.DoomBuilder.SRB2 // Constructor internal SRB2Object(string name, string sprite, string category, string[] states, int mapThingNum, int radius, int height, int flags, - Dictionary flagstext, string angletext, string parametertext, string flagsvaluetext) + Dictionary flagstext, string angletext, string parametertext, string flagsvaluetext, bool arrow, bool tagthing) { this.name = name; this.sprite = sprite; @@ -68,6 +70,8 @@ namespace CodeImp.DoomBuilder.SRB2 this.angletext = angletext; this.parametertext = parametertext; this.flagsvaluetext = flagsvaluetext; + this.arrow = arrow; + this.tagthing = tagthing; } #endregion