From 4aa373aba84cbb2602cc060ff601c014c7762396 Mon Sep 17 00:00:00 2001 From: spherallic Date: Tue, 19 Sep 2023 19:06:32 +0200 Subject: [PATCH] Allow changing string argument properties via Lua --- Source/Core/Config/ArgumentInfo.cs | 16 ++++++++++++++++ Source/Core/Config/ThingTypeInfo.cs | 8 ++++++++ Source/Core/ZDoom/ActorStructure.cs | 27 +++++++++++++++++++++++---- 3 files changed, 47 insertions(+), 4 deletions(-) diff --git a/Source/Core/Config/ArgumentInfo.cs b/Source/Core/Config/ArgumentInfo.cs index 0fe017c8..454f0168 100755 --- a/Source/Core/Config/ArgumentInfo.cs +++ b/Source/Core/Config/ArgumentInfo.cs @@ -396,6 +396,22 @@ namespace CodeImp.DoomBuilder.Config if(this.enumlist == null) this.enumlist = new EnumList(); } + internal ArgumentInfo(ActorStructure actor, int i, bool stringarg) + { + if (!actor.HasPropertyWithValue("$stringarg" + i)) + { + used = false; + return; + } + + string argtitle = ZDTextParser.StripQuotes(actor.GetPropertyAllValues("$stringarg" + i)); + string tooltip = ZDTextParser.StripQuotes(actor.GetPropertyAllValues("$stringarg" + i + "tooltip").Replace("\\n", Environment.NewLine)); + + this.used = true; + this.title = argtitle; + this.tooltip = tooltip; + + } // Constructor for unknown argument info internal ArgumentInfo(int argindex, bool isstringarg) diff --git a/Source/Core/Config/ThingTypeInfo.cs b/Source/Core/Config/ThingTypeInfo.cs index 06f2f2ca..4017cb4c 100755 --- a/Source/Core/Config/ThingTypeInfo.cs +++ b/Source/Core/Config/ThingTypeInfo.cs @@ -582,6 +582,14 @@ namespace CodeImp.DoomBuilder.Config args[i] = arg; } + //sphere: Custom string argument titles? + for (int i = 0; i < stringargs.Length; i++) + { + ArgumentInfo arg = actor.GetStringArgumentInfo(i); + if (arg != null) + stringargs[i] = arg; + } + //mxd. Some SLADE compatibility if (actor.HasProperty("$angled")) { diff --git a/Source/Core/ZDoom/ActorStructure.cs b/Source/Core/ZDoom/ActorStructure.cs index abd14ad2..5a62030c 100755 --- a/Source/Core/ZDoom/ActorStructure.cs +++ b/Source/Core/ZDoom/ActorStructure.cs @@ -62,9 +62,10 @@ namespace CodeImp.DoomBuilder.ZDoom // [ZZ] direct ArgumentInfos (from game configuration), or own ArgumentInfos (from props) internal ArgumentInfo[] args = new ArgumentInfo[Thing.NUM_ARGS]; + internal ArgumentInfo[] stringargs = new ArgumentInfo[Thing.NUM_STRING_ARGS]; - // States - internal Dictionary states; + // States + internal Dictionary states; #endregion @@ -411,6 +412,13 @@ namespace CodeImp.DoomBuilder.ZDoom args[i] = new ArgumentInfo(this, i); else args[i] = null; } + + for (int i = 0; i < Thing.NUM_STRING_ARGS; i++) + { + if (HasProperty("$stringarg" + i)) + stringargs[i] = new ArgumentInfo(this, i, true); + else stringargs[i] = null; + } } public ArgumentInfo GetArgumentInfo(int idx) @@ -423,8 +431,19 @@ namespace CodeImp.DoomBuilder.ZDoom if (baseclass != null) return baseclass.GetArgumentInfo(idx); return null; - } - + } + public ArgumentInfo GetStringArgumentInfo(int idx) + { + if (stringargs[idx] != null) + return stringargs[idx]; + // if we have $clearargs, don't inherit anything! + if (props.ContainsKey("$clearargs")) + return null; + if (baseclass != null) + return baseclass.GetStringArgumentInfo(idx); + return null; + } + #endregion } }