DECORATE: added "$argN" special comment. It can be used to specify default argument names.

Updated documentation.
This commit is contained in:
MaxED 2015-02-04 18:02:03 +00:00
parent dc6076496a
commit e4d872536a
5 changed files with 64 additions and 37 deletions

View file

@ -54,7 +54,7 @@ pre
{
background: #f4f4f4;
color: #515151;
width: 500px;
width: 600px;
margin: 10px 0px 10px 20px;
font: 100% Courier New,Courier,sans-serif;
text-align: left;

View file

@ -18,7 +18,7 @@
<div id="contents">
<p>
Doom Builder 2 includes a DECORATE parser used to obtain relevant information (such as editor number, Radius, Height, Scale, and so on) from custom actors. Additional information can be conveyed with keys in the form of special comments inserted within an actor's declaration block:
Doom Builder 2 includes a DECORATE parser used to obtain relevant information (such as editor number, Radius, Height, Scale, and so on) from custom actors. Additional information can be conveyed with keys in the form of special comments inserted within an actor's declaration block:
<p><strong>//$Category &lt;category&gt;</strong><br />
Specifies in which category (Monsters, Weapons, etc.) it should be sorted. By default, a custom actor not identified in a configuration file will be put in the Decorate category.
<p> <strong>//$Sprite &lt;sprite&gt;</strong><br />
@ -29,14 +29,18 @@
<strong>//$Title &lt;title&gt;</strong><br />
Specifies which name to give to the actor. By default, a custom actor not identified in a configuration file will use the Tag property, and if not present, will default to the class name.<br />
<br />
<strong>//$ArgN &lt;name&gt;</strong> (GZDoom Builder only)<br />
Allows to override default argument names for this actor.<br />
<br />
<strong>//$Color &lt;color index&gt;</strong> (GZDoom Builder only)<br />
Allows to override category color for this actor. Possible values:
<ul>
<li>0 - Dark Gray;</li>
<li> 1 - Blue;</li>
<li> 2 - Green;</li>
<li> 3 - Cyan;</li>
<li> 4 - Red;</li>
<li>1 - Blue;</li>
<li>2 - Green;</li>
<li>3 - Cyan;</li>
<li>4 - Red;</li>
<li>5 - Magenta;</li>
<li>6 - Brown;</li>
<li>7 - Gray;</li>
@ -59,20 +63,23 @@
<pre>
Actor ChexShield : ResistanceRune replaces ResistanceRune 5104
{
//$Category powerups
//$Sprite ARMXA0
//$Title "Chex Shield"
//$Color 12
Height 44
Radius 26
Inventory.PickupMessage "Picked up the energized Chex armor!"
States
{
Spawn:
ARMX A 1
Loop
}
//$Category powerups
//$Sprite ARMXA0
//$Title "Chex Shield"
//$Arg0 "Respawn Delay"
//$Arg1 "Armor Ammount"
//$Color 12
Height 44
Radius 26
Inventory.PickupMessage "Picked up the energized Chex armor!"
States
{
Spawn:
ARMX A 1
Loop
}
}
</pre>
</p>

View file

@ -91,10 +91,19 @@ namespace CodeImp.DoomBuilder.Config
if (this.enumlist == null) this.enumlist = new EnumList(); //mxd
}
//mxd. Constructor for an argument info defined in DECORATE
internal ArgumentInfo(int argindex, string title)
{
this.used = true;
this.title = title;
this.type = 0;
this.enumlist = new EnumList();
this.defaultvalue = 0;
}
// Constructor for unknown argument info
internal ArgumentInfo(int argindex)
{
// Read
this.used = false;
this.title = "Argument " + (argindex + 1);
this.type = 0;

View file

@ -45,28 +45,26 @@ namespace CodeImp.DoomBuilder.Config
#region ================== Variables
// Properties
private int index;
private readonly int index;
private string title;
private string sprite;
private ActorStructure actor;
private readonly string classname; //mxd
private long spritelongname;
private int color;
private bool arrow;
private readonly bool arrow;
private float radius;
private float height;
private bool hangs;
private int blocking;
private int errorcheck;
private bool fixedsize;
private bool fixedrotation; //mxd
private ThingCategory category;
private ArgumentInfo[] args;
private bool isknown;
private bool absolutez;
private readonly bool fixedsize;
private readonly bool fixedrotation; //mxd
private readonly ThingCategory category;
private readonly ArgumentInfo[] args;
private readonly bool isknown;
private readonly bool absolutez;
private SizeF spritescale;
//mxd
private string classname;
#endregion
@ -284,9 +282,16 @@ namespace CodeImp.DoomBuilder.Config
color = (ci == 0 || ci > 19 ? 18 : ci) ;
}
//mxd. Custom argument titles?
for(int i = 0; i < args.Length; i++)
{
if(!actor.HasPropertyWithValue("$arg" + i)) continue;
string argtitle = actor.GetPropertyAllValues("$arg" + i);
args[i] = new ArgumentInfo(i, ZDTextParser.StripQuotes(argtitle));
}
// Remove doublequotes from title
if((title.Length > 2) && title.StartsWith("\"") && title.EndsWith("\""))
title = title.Substring(1, title.Length - 2);
title = ZDTextParser.StripQuotes(title); //mxd
// Set sprite
string suitablesprite = actor.FindSuitableSprite();

View file

@ -99,13 +99,13 @@ namespace CodeImp.DoomBuilder.ZDoom
}
// This returns true if the given character is whitespace
protected internal bool IsWhitespace(char c)
private bool IsWhitespace(char c)
{
return (whitespace.IndexOf(c) > -1);
}
// This returns true if the given character is a special token
protected internal bool IsSpecialToken(char c)
private bool IsSpecialToken(char c)
{
return (specialtokens.IndexOf(c) > -1);
}
@ -116,9 +116,15 @@ namespace CodeImp.DoomBuilder.ZDoom
if(s.Length > 0) return (specialtokens.IndexOf(s[0]) > -1);
return false;
}
//mxd. This removes beginning and ending quotes from a token
protected internal string StripTokenQuotes(string token)
{
return StripQuotes(token);
}
// This removes beginning and ending quotes from a token
protected internal string StripTokenQuotes(string token)
internal static string StripQuotes(string token)
{
// Remove first character, if it is a quote
if(!string.IsNullOrEmpty(token) && (token[0] == '"'))