Allow changing string argument properties via Lua

This commit is contained in:
spherallic 2023-09-19 19:06:32 +02:00
parent 76f6483829
commit 4aa373aba8
3 changed files with 47 additions and 4 deletions

View file

@ -396,6 +396,22 @@ namespace CodeImp.DoomBuilder.Config
if(this.enumlist == null) this.enumlist = new EnumList(); 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 // Constructor for unknown argument info
internal ArgumentInfo(int argindex, bool isstringarg) internal ArgumentInfo(int argindex, bool isstringarg)

View file

@ -582,6 +582,14 @@ namespace CodeImp.DoomBuilder.Config
args[i] = arg; 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 //mxd. Some SLADE compatibility
if (actor.HasProperty("$angled")) if (actor.HasProperty("$angled"))
{ {

View file

@ -62,9 +62,10 @@ namespace CodeImp.DoomBuilder.ZDoom
// [ZZ] direct ArgumentInfos (from game configuration), or own ArgumentInfos (from props) // [ZZ] direct ArgumentInfos (from game configuration), or own ArgumentInfos (from props)
internal ArgumentInfo[] args = new ArgumentInfo[Thing.NUM_ARGS]; internal ArgumentInfo[] args = new ArgumentInfo[Thing.NUM_ARGS];
internal ArgumentInfo[] stringargs = new ArgumentInfo[Thing.NUM_STRING_ARGS];
// States // States
internal Dictionary<string, StateStructure> states; internal Dictionary<string, StateStructure> states;
#endregion #endregion
@ -411,6 +412,13 @@ namespace CodeImp.DoomBuilder.ZDoom
args[i] = new ArgumentInfo(this, i); args[i] = new ArgumentInfo(this, i);
else args[i] = null; 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) public ArgumentInfo GetArgumentInfo(int idx)
@ -423,8 +431,19 @@ namespace CodeImp.DoomBuilder.ZDoom
if (baseclass != null) if (baseclass != null)
return baseclass.GetArgumentInfo(idx); return baseclass.GetArgumentInfo(idx);
return null; 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 #endregion
} }
} }