Added, DECORATE: added "//$ArgNRenderStyle" special comment. It allows to specify a rendering shape to display the value of given argument. Supported values are "circle" and "rectangle".

Added, DECORATE: added "//$ArgNRenderColor" special comment. It allows to specify a color used by the rendering shape.
Updated documentation.
This commit is contained in:
MaxED 2016-07-14 12:42:16 +00:00
parent 662725090b
commit 9a6d3ea84c
6 changed files with 203 additions and 34 deletions

View file

@ -91,7 +91,19 @@ arg0
</pre>
Enums can be also set in <a href="gc_decoratekeys.html#argenum">DECORATE</a>.<br />
<p><b class="fat">flags</b> (structure or string) - <span class="red">GZDB only</span><br />
<p><b class="fat">renderstyle</b> (string) - <span class="red">GZDB only</span><br />
Allows to specify a rendering shape to display the value of this argument. Supported values are:<br />
<ul>
<li>&quot;<strong>Rectangle</strong>&quot;. The argument value is used as rectangle size.</li>
<li>&quot;<strong>Circle</strong>&quot;. The argument value is used as circle radius.</li>
</ul>
Rendering shapes can be toggled using "<strong><a href="gzdb/features/general/rendering_toolbar.html">Toggle Event Lines</a></strong>" action/menu button.<br />
Currently rendering shapes are supported only for Thing arguments.<br />Currently rendering shapes are shown only in Classic modes.</p>
<p><b class="fat">rendercolor</b> (integer) - <span class="red">GZDB only</span><br />
Allows to specify a color used by rendering shape. Supported values are hex color (like &quot;<strong>FF0000</strong>&quot;), HTML-formatted hex color (like &quot;<strong>#F00</strong>&quot; or &quot;<strong>#FF0000</strong>&quot;) or color name (like &quot;<strong>Red</strong>&quot;).<br />
By default rendering shapes will use Event line <a href="w_preferences.html">editor color</a>.<br />
This property must be used in conjunction with the &quot;<b class="fat">renderstyle</b>&quot; property.</p>
<p><b class="fat">flags</b> (structure or string) - <span class="red">GZDB only</span><br />
Provides a list of predefined bit flag values to display for this argument. Used only when argument <strong>type</strong> is 26.<br />
The value can be either a name of a predefined enum or an explicit definition.<br />
<strong>Example:</strong>

View file

@ -48,21 +48,39 @@
Allows to override default argument names for this actor.<br />
<br />
<strong><a name="argdefault" id="argdefault"></a>//$ArgNDefault &lt;integer&gt;</strong> - <span class="red">GZDB only</span>.<br />
Allows to set the default value for this argument. This property can only be used in conjunction with &quot;<strong>//$ArgN</strong>&quot; property.<br />
Allows to set the default value for this argument. This property must be used in conjunction with the &quot;<strong>//$ArgN</strong>&quot; property.<br />
<br />
<strong><a name="argtooltip" id="argtooltip"></a>//$ArgNTooltip &lt;text&gt;</strong> - <span class="red">GZDB only</span>.<br />
Allows to specify a tooltip text displayed for this argument. Newline character (&quot;\n&quot;) can be used to format the text. This property can only be used in conjunction with &quot;<strong>//$ArgN</strong>&quot; property.<br />
Allows to specify a tooltip text displayed for this argument. Newline character (&quot;\n&quot;) can be used to format the text. This property must be used in conjunction with the &quot;<strong>//$ArgN</strong>&quot; property.<br />
Argument tooltips can be also set for <a href="gc_argumentsettings.html#argtooltip">things and linedefs</a> in a Game Configuration.<br />
<br />
<strong><a name="argtype" id="argtype"></a>//$ArgNType &lt;integer&gt;</strong> - <span class="red">GZDB only</span>.<br />
Allows to specify an <a href="gc_argumentsettings.html#argtype">argument type</a> for this argument. This property can only be used in conjunction with &quot;<strong>//$ArgN</strong>&quot; property.<br />
Allows to specify an <a href="gc_argumentsettings.html#argtype">argument type</a> for this argument. This property must be used in conjunction with the &quot;<strong>//$ArgN</strong>&quot; property.<br />
<br />
<strong><a name="argenum" id="argenum"></a>//$ArgNEnum &lt;string or structure&gt;</strong> - <span class="red">GZDB only</span>.<br />
Allows to specify an enum for this argument. This can be either a name of an enum defined in the Game Configuration, or an explicit enum definition. This property can only be used in conjunction with &quot;<strong>//$ArgN</strong>&quot; property.<br />
<br />
<strong><a name="color" id="color"></a>//$Color &lt;color index&gt;</strong> - <span class="red">GZDB only</span>.<br />
Allows to override category color for this actor. Possible values are:
<ul>
<strong><a name="argrenderstyle" id="argrenderstyle"></a>//$ArgNRenderStyle &lt;string&gt;</strong> - <span class="red">GZDB only</span>.<br />
Allows to specify a rendering shape to display the value of this argument. Supported values are:<br />
<ul>
<li>&quot;<strong>Rectangle</strong>&quot;. The argument value is used as rectangle size.</li>
<li>&quot;<strong>Circle</strong>&quot;. The argument value is used as circle radius.</li>
</ul>
Rendering shapes can be toggled using &quot;<strong><a href="gzdb/features/general/rendering_toolbar.html">Toggle Event Lines</a></strong>&quot; action/menu button.<br />
Currently rendering shapes are shown only in Classic modes.<br />
This property must be used in conjunction with the &quot;<strong>//$ArgN</strong>&quot; property.<br />
<br />
<strong><a name="argrendercolor" id="argrendercolor"></a>//$ArgNRenderColor &lt;integer&gt;</strong> - <span class="red">GZDB only</span>.<br />
Allows to specify a color used by rendering shape. Supported values are hex color (like &quot;<strong>FF0000</strong>&quot;), HTML-formatted hex color (like &quot;<strong>#F00</strong>&quot; or &quot;<strong>#FF0000</strong>&quot;) or color name (like &quot;<strong>Red</strong>&quot;).<br />
By default rendering shapes will use Event line <a href="w_preferences.html">editor color</a>.<br />
This property must be used in conjunction with &quot;<strong>//$ArgN</strong>&quot; and &quot;<strong>//$ArgNRenderStyle</strong>&quot; properties.<br />
<br />
<strong><a name="argenum" id="argenum"></a>//$ArgNEnum &lt;string or structure&gt;</strong> - <span class="red">GZDB only</span>.<br />
Allows to specify an enum for this argument. This can be either a name of an enum defined in the Game Configuration, or an explicit enum definition. This property must be used in conjunction with the &quot;<strong>//$ArgN</strong>&quot; property.<br />
<br />
<strong><a name="color" id="color"></a>//$Color &lt;color index&gt;</strong> - <span class="red">GZDB only</span>.<br />
Allows to override category color for this actor. Possible values are:
<ul>
<li>&nbsp;&nbsp;0 - <span style="color:#696969">&#9608;</span> Dark Gray;</li>
<li>&nbsp;&nbsp;1 - <span style="color:#4169E1">&#9608;</span> Blue;</li>
<li>&nbsp;&nbsp;2 - <span style="color:#228B22">&#9608;</span> Green;</li>
@ -117,6 +135,8 @@ Actor ChexShield : ResistanceRune replaces ResistanceRune 5104
//$Arg3 "Radius"
//$Arg3Type 23
//$Arg3Default 32
//$Arg3RenderStyle &quot;Circle&quot;
//$Arg3RenderColor #ff00ff
//$Arg4 "Height"
//$Arg4Type 24
@ -142,7 +162,7 @@ actor SuperGiantImpBall : DoomImpBall
Damage 30
}
</pre>
<br /><br />
<br /><br />
<span class="big">Category definitions (GZDB only):</span><br />
<br />
Thing categories can be defined in DECORATE using <strong>#region</strong> / <strong>#endregion</strong> blocks. Region name is used as thing category title. &quot;<strong>//$Category</strong>&quot; actor block definition overrides these. Additional information can be conveyed with keys in the form of special comments inserted within <strong>#region</strong> / <strong>#endregion</strong> block (these keys replicate Game Configuration <a href="gc_thingsettings.html#catdefs">thing category properties</a> with a slightly different syntax):<br />
@ -163,7 +183,6 @@ Thing categories can be defined in DECORATE using <strong>#region</strong> / <st
<b class="fat">//$Error</b> (integer) [0 .. 2]<br />
Sets the stuck things error checking mode to use on this thing. <br />
Possible values are:
<ul>
<li>0 - Don't check this thing.</li>
<li>1 - Check if the thing is outside of map geometry.</li>

View file

@ -21,7 +21,9 @@ using System.Collections;
using System.Collections.Generic;
using System.Globalization;
using CodeImp.DoomBuilder.IO;
using CodeImp.DoomBuilder.Rendering;
using CodeImp.DoomBuilder.Types;
using CodeImp.DoomBuilder.ZDoom;
#endregion
@ -31,6 +33,19 @@ namespace CodeImp.DoomBuilder.Config
{
#region ================== Constants
private const int HELPER_SHAPE_ALPHA = 192; //mxd
#endregion
#region ================== Enums (mxd)
public enum ArgumentRenderStyle
{
NONE,
CIRCLE,
RECTANGLE,
}
#endregion
#region ================== Variables
@ -43,6 +58,8 @@ namespace CodeImp.DoomBuilder.Config
private EnumList flagslist; //mxd
private readonly object defaultvalue; //mxd
private readonly HashSet<string> targetclasses; //mxd
private readonly ArgumentRenderStyle renderstyle; //mxd
private readonly PixelColor rendercolor; //mxd
#endregion
@ -56,6 +73,8 @@ namespace CodeImp.DoomBuilder.Config
public EnumList Enum { get { return enumlist; } internal set { enumlist = value; } }
public EnumList Flags { get { return flagslist; } internal set { flagslist = value; } } //mxd
public object DefaultValue { get { return defaultvalue; } } //mxd
public ArgumentRenderStyle RenderStyle { get { return renderstyle; } } //mxd
public PixelColor RenderColor { get { return rendercolor; } } //mxd
#endregion
@ -72,6 +91,44 @@ namespace CodeImp.DoomBuilder.Config
this.type = cfg.ReadSetting(argspath + ".arg" + istr + ".type", 0);
this.defaultvalue = cfg.ReadSetting(argspath + ".arg" + istr + ".default", 0); //mxd
//mxd. Get rendering hint settings
string renderstyle = cfg.ReadSetting(argspath + ".arg" + istr + ".renderstyle", string.Empty);
switch(renderstyle.ToLowerInvariant())
{
case "circle":
this.renderstyle = ArgumentRenderStyle.CIRCLE;
break;
case "rectangle":
this.renderstyle = ArgumentRenderStyle.RECTANGLE;
break;
default:
this.renderstyle = ArgumentRenderStyle.NONE;
if(!string.IsNullOrEmpty(renderstyle))
General.ErrorLogger.Add(ErrorType.Error, "\"" + argspath + ".arg" + istr + "\": action argument \"" + this.title + "\" has unknown renderstyle \"" + renderstyle + "\"!");
break;
}
if(this.renderstyle != ArgumentRenderStyle.NONE)
{
string rendercolor = cfg.ReadSetting(argspath + ".arg" + istr + ".rendercolor", string.Empty);
if(!string.IsNullOrEmpty(rendercolor))
{
if(!ZDTextParser.GetColorFromString(rendercolor, ref this.rendercolor))
{
General.ErrorLogger.Add(ErrorType.Error, "\"" + argspath + ".arg" + istr + "\": action argument \"" + this.title + "\": unable to get rendercolor from value \"" + rendercolor + "\"!");
this.rendercolor = General.Colors.InfoLine.WithAlpha(HELPER_SHAPE_ALPHA);
}
else
{
this.rendercolor.a = HELPER_SHAPE_ALPHA;
}
}
else
{
this.rendercolor = General.Colors.InfoLine.WithAlpha(HELPER_SHAPE_ALPHA);
}
}
//mxd. Check for TargetClass?
this.targetclasses = new HashSet<string>(StringComparer.InvariantCultureIgnoreCase);
if(this.type == (int)UniversalType.ThingTag)
@ -138,7 +195,8 @@ namespace CodeImp.DoomBuilder.Config
}
//mxd. Constructor for an argument info defined in DECORATE
internal ArgumentInfo(string actorname, string argtitle, string tooltip, int type, int defaultvalue, string enumstr, IDictionary<string, EnumList> enums)
internal ArgumentInfo(string actorname, string argtitle, string tooltip, string renderstyle, string rendercolor,
int type, int defaultvalue, string enumstr, IDictionary<string, EnumList> enums)
{
this.used = true;
this.title = argtitle;
@ -146,6 +204,38 @@ namespace CodeImp.DoomBuilder.Config
this.defaultvalue = defaultvalue;
this.flagslist = new EnumList(); //mxd
// Get rendering hint settings
switch(renderstyle.ToLowerInvariant())
{
case "circle": this.renderstyle = ArgumentRenderStyle.CIRCLE; break;
case "rectangle": this.renderstyle = ArgumentRenderStyle.RECTANGLE; break;
default:
this.renderstyle = ArgumentRenderStyle.NONE;
if(!string.IsNullOrEmpty(renderstyle))
General.ErrorLogger.Add(ErrorType.Error, actorname + ": action argument \"" + argtitle + "\" has unknown renderstyle \"" + renderstyle + "\"!");
break;
}
if(this.renderstyle != ArgumentRenderStyle.NONE)
{
if(!string.IsNullOrEmpty(rendercolor))
{
if(!ZDTextParser.GetColorFromString(rendercolor, ref this.rendercolor))
{
General.ErrorLogger.Add(ErrorType.Error, actorname + ": action argument \"" + argtitle + "\": unable to get rendercolor from value \"" + rendercolor + "\"!");
this.rendercolor = General.Colors.InfoLine.WithAlpha(HELPER_SHAPE_ALPHA);
}
else
{
this.rendercolor.a = HELPER_SHAPE_ALPHA;
}
}
else
{
this.rendercolor = General.Colors.InfoLine.WithAlpha(HELPER_SHAPE_ALPHA);
}
}
// Get argument type
if(System.Enum.IsDefined(typeof(UniversalType), type))
{

View file

@ -443,7 +443,9 @@ namespace CodeImp.DoomBuilder.Config
int argtype = actor.GetPropertyValueInt("$arg" + i + "type", 0);
int defaultvalue = actor.GetPropertyValueInt("$arg" + i + "default", 0);
string argenum = ZDTextParser.StripQuotes(actor.GetPropertyAllValues("$arg" + i + "enum"));
args[i] = new ArgumentInfo(title, argtitle, argtooltip, argtype, defaultvalue, argenum, General.Map.Config.Enums);
string argrenderstyle = ZDTextParser.StripQuotes(actor.GetPropertyAllValues("$arg" + i + "renderstyle"));
string argrendercolor = ZDTextParser.StripQuotes(actor.GetPropertyAllValues("$arg" + i + "rendercolor"));
args[i] = new ArgumentInfo(title, argtitle, argtooltip, argrenderstyle, argrendercolor, argtype, defaultvalue, argenum, General.Map.Config.Enums);
}
//mxd. Some SLADE compatibility

View file

@ -1,7 +1,9 @@
using System.Collections.Generic;
using System;
using System.Collections.Generic;
using CodeImp.DoomBuilder.Config;
using CodeImp.DoomBuilder.Map;
using CodeImp.DoomBuilder.Geometry;
using CodeImp.DoomBuilder.Rendering;
using CodeImp.DoomBuilder.VisualModes;
namespace CodeImp.DoomBuilder.GZBuilder.Data
@ -71,6 +73,39 @@ namespace CodeImp.DoomBuilder.GZBuilder.Data
}
}
public static IEnumerable<Line3D> MakeCircleLines(Vector2D pos, PixelColor color, float radius, int numsides)
{
List<Line3D> result = new List<Line3D>(numsides);
Vector2D start = new Vector2D(pos.x, pos.y + radius);
float anglestep = Angle2D.PI2 / numsides;
for(int i = 1; i < numsides + 1; i++)
{
Vector2D end = pos + new Vector2D((float)Math.Sin(anglestep * i) * radius, (float)Math.Cos(anglestep * i) * radius);
result.Add(new Line3D(start, end, color, false));
start = end;
}
return result;
}
public static IEnumerable<Line3D> MakeRectangleLines(Vector2D pos, PixelColor color, float size)
{
float halfsize = size / 2;
Vector2D tl = new Vector2D(pos.x - halfsize, pos.y - halfsize);
Vector2D tr = new Vector2D(pos.x + halfsize, pos.y - halfsize);
Vector2D bl = new Vector2D(pos.x - halfsize, pos.y + halfsize);
Vector2D br = new Vector2D(pos.x + halfsize, pos.y + halfsize);
return new List<Line3D>
{
new Line3D(tl, tr, color, false),
new Line3D(tr, br, color, false),
new Line3D(bl, br, color, false),
new Line3D(bl, tl, color, false),
};
}
public static List<Line3D> GetThingLinks(IEnumerable<Thing> things) { return GetThingLinks(things, null); }
public static List<Line3D> GetThingLinks(IEnumerable<Thing> things, VisualBlockMap blockmap)
{
@ -367,6 +402,34 @@ namespace CodeImp.DoomBuilder.GZBuilder.Data
}
}
// Process arg helpers
const int numsides = 24;
foreach(Thing t in General.Map.ThingsFilter.VisibleThings)
{
if(t.Action != 0) continue;
ThingTypeInfo tti = General.Map.Data.GetThingInfoEx(t.Type);
if(tti == null) continue;
for(int i = 0; i < t.Args.Length; i++)
{
if(t.Args[i] != 0 && tti.Args[i].RenderStyle != ArgumentInfo.ArgumentRenderStyle.NONE)
{
switch(tti.Args[i].RenderStyle)
{
case ArgumentInfo.ArgumentRenderStyle.CIRCLE:
lines.AddRange(MakeCircleLines(t.Position, tti.Args[i].RenderColor, t.Args[i], numsides));
break;
case ArgumentInfo.ArgumentRenderStyle.RECTANGLE:
lines.AddRange(MakeRectangleLines(t.Position, tti.Args[i].RenderColor, t.Args[i]));
break;
default: throw new NotImplementedException("Unknown ArgumentRenderStyle");
}
}
}
}
return lines;
}

View file

@ -1115,31 +1115,14 @@ namespace CodeImp.DoomBuilder.BuilderModes
// Add lines if visible
const int numsides = 24;
if(primaryradius > 0) circles.AddRange(MakeCircleLines(t.Position, color, primaryradius, numsides));
if(secondaryradius > 0) circles.AddRange(MakeCircleLines(t.Position, color, secondaryradius, numsides));
if(primaryradius > 0) circles.AddRange(LinksCollector.MakeCircleLines(t.Position, color, primaryradius, numsides));
if(secondaryradius > 0) circles.AddRange(LinksCollector.MakeCircleLines(t.Position, color, secondaryradius, numsides));
}
// Done
return circles;
}
//mxd
private static IEnumerable<Line3D> MakeCircleLines(Vector2D pos, PixelColor color, float radius, int numsides)
{
List<Line3D> result = new List<Line3D>(numsides);
Vector2D start = new Vector2D(pos.x, pos.y + radius);
float anglestep = Angle2D.PI2 / numsides;
for(int i = 1; i < numsides + 1; i++)
{
Vector2D end = pos + new Vector2D((float)Math.Sin(anglestep * i) * radius, (float)Math.Cos(anglestep * i) * radius);
result.Add(new Line3D(start, end, color, false));
start = end;
}
return result;
}
#endregion
#region ================== Actions