Added, Things mode, Visual mode: added the ability to specify minimum/maximum argument range hint shapes using special DECORATE comments and Game Configuration properties (loosely based on range finder patch by Xabis).

Updated documentation ("Game Configuration - Action Argument Settings" and "DECORATE keys" pages).
This commit is contained in:
MaxED 2017-01-06 15:59:41 +03:00
parent cd854779e8
commit 1c684f7213
5 changed files with 201 additions and 26 deletions

View file

@ -103,6 +103,27 @@ arg0
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 /> 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 /> 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> This property must be used in conjunction with the &quot;<b class="fat">renderstyle</b>&quot; property.</p>
<p><b class="fat">minrange</b> (integer) - <span class="red">GZDB only</span><br />
Allows to specify minimum range for the rendering shape.<br />
By default minimum range shapes will use Indication <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">minrangecolor</b> (integer) - <span class="red">GZDB only</span><br />
Allows to specify the color used when rendering the minimum range 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 minimum range shapes will use Indication <a href="w_preferences.html">editor color</a>.<br />
This property must be used in conjunction with &quot;<b class="fat">renderstyle</b>&quot; and &quot;<b class="fat">minrange</b>&quot; properties.</p>
<p><b class="fat">maxrange</b> (integer) - <span class="red">GZDB only</span><br />
Allows to specify maximum range for the rendering shape.<br />
By default maximum range shapes will use Indication <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">maxrangecolor</b> (integer) - <span class="red">GZDB only</span><br />
Allows to specify the color used when rendering the maximum range 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 maximum range shapes will use Indication <a href="w_preferences.html">editor color</a>.<br />
This property must be used in conjunction with &quot;<b class="fat">renderstyle</b>&quot; and &quot;<b class="fat">maxrange</b>&quot; properties.</p>
<p><b class="fat">flags</b> (structure or string) - <span class="red">GZDB only</span><br /> <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 /> 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 /> The value can be either a name of a predefined enum or an explicit definition.<br />

View file

@ -73,6 +73,29 @@
This property must be used in conjunction with &quot;<strong>//$ArgN</strong>&quot; and &quot;<strong>//$ArgNRenderStyle</strong>&quot; properties.<br /> This property must be used in conjunction with &quot;<strong>//$ArgN</strong>&quot; and &quot;<strong>//$ArgNRenderStyle</strong>&quot; properties.<br />
<br /> <br />
<strong><a name="argminrange" id="argminrange"></a>//$ArgNMinRange &lt;integer&gt;</strong> - <span class="red">GZDB only</span>.<br />
Allows to specify minimum range for the rendering shape. <br />
By default minimum range shapes will use Indication <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="argminrangecolor" id="argminrangecolor"></a>//$ArgNMinRangeColor &lt;integer&gt;</strong> - <span class="red">GZDB only</span>.<br />
Allows to specify the color used when rendering the minimum range 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 minimum range shapes will use Indication <a href="w_preferences.html">editor color</a>.<br />
This property must be used in conjunction with &quot;<strong>//$ArgN</strong>&quot;, &quot;<strong>//$ArgNRenderStyle</strong>&quot; and &quot;<strong>//$ArgNMinRange</strong>&quot; properties.<br />
<br />
<strong><a name="argmaxrange" id="argmaxrange"></a>//$ArgNMaxRange &lt;integer&gt;</strong> - <span class="red">GZDB only</span>.<br />
Allows to specify maximum range for the rendering shape. <br />
By default maximum range shapes will use Indication <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="argmaxrangecolor" id="argmaxrangecolor"></a>//$ArgNMaxRangeColor &lt;integer&gt;</strong> - <span class="red">GZDB only</span>.<br />
Allows to specify the color used when rendering the maximum range 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 maximum range shapes will use Indication <a href="w_preferences.html">editor color</a>.<br />
This property must be used in conjunction with &quot;<strong>//$ArgN</strong>&quot;, &quot;<strong>//$ArgNRenderStyle</strong>&quot; and &quot;<strong>//$ArgNMaxRange</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 /> <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 /> 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 />
@ -136,15 +159,21 @@ Actor ChexShield : ResistanceRune replaces ResistanceRune 5104
//$Arg3Default 32 //$Arg3Default 32
//$Arg3RenderStyle &quot;Circle&quot; //$Arg3RenderStyle &quot;Circle&quot;
//$Arg3RenderColor #ff00ff //$Arg3RenderColor #ff00ff
//$Arg3MinRange 32
//$Arg3MaxRange 512
//$Arg3MinRangeColor #0000ff
//$Arg3MaxRangeColor #ff0000
//$Arg4 "Height" //$Arg4 "Height"
//$Arg4Type 24 //$Arg4Type 24
//$Arg4Default 64 //$Arg4Default 64
Height 44 Height 44
Radius 26 Radius 26
RenderStyle None RenderStyle None
Inventory.PickupMessage "Picked up the energized Chex armor!" Inventory.PickupMessage "Picked up the energized Chex armor!"
States States
{ {

View file

@ -34,6 +34,7 @@ namespace CodeImp.DoomBuilder.Config
#region ================== Constants #region ================== Constants
private const int HELPER_SHAPE_ALPHA = 192; //mxd private const int HELPER_SHAPE_ALPHA = 192; //mxd
private const int RANGE_SHAPE_ALPHA = 96; //mxd
#endregion #endregion
@ -60,6 +61,10 @@ namespace CodeImp.DoomBuilder.Config
private readonly HashSet<string> targetclasses; //mxd private readonly HashSet<string> targetclasses; //mxd
private readonly ArgumentRenderStyle renderstyle; //mxd private readonly ArgumentRenderStyle renderstyle; //mxd
private readonly PixelColor rendercolor; //mxd private readonly PixelColor rendercolor; //mxd
private readonly PixelColor minrangecolor; //mxd
private readonly PixelColor maxrangecolor; //mxd
private readonly int minrange; //mxd
private readonly int maxrange; //mxd
#endregion #endregion
@ -75,6 +80,10 @@ namespace CodeImp.DoomBuilder.Config
public object DefaultValue { get { return defaultvalue; } } //mxd public object DefaultValue { get { return defaultvalue; } } //mxd
public ArgumentRenderStyle RenderStyle { get { return renderstyle; } } //mxd public ArgumentRenderStyle RenderStyle { get { return renderstyle; } } //mxd
public PixelColor RenderColor { get { return rendercolor; } } //mxd public PixelColor RenderColor { get { return rendercolor; } } //mxd
public PixelColor MinRangeColor { get { return minrangecolor; } } //mxd
public PixelColor MaxRangeColor { get { return maxrangecolor; } } //mxd
public int MinRange { get { return minrange; } } //mxd
public int MaxRange { get { return maxrange; } } //mxd
#endregion #endregion
@ -110,22 +119,54 @@ namespace CodeImp.DoomBuilder.Config
if(this.renderstyle != ArgumentRenderStyle.NONE) if(this.renderstyle != ArgumentRenderStyle.NONE)
{ {
// Get rendercolor
string rendercolor = cfg.ReadSetting(argspath + ".arg" + istr + ".rendercolor", string.Empty); string rendercolor = cfg.ReadSetting(argspath + ".arg" + istr + ".rendercolor", string.Empty);
if(!string.IsNullOrEmpty(rendercolor)) this.rendercolor = General.Colors.InfoLine;
if(!string.IsNullOrEmpty(rendercolor) && !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.a = HELPER_SHAPE_ALPHA;
// Get minrange settings
string minrange = cfg.ReadSetting(argspath + ".arg" + istr + ".minrange", string.Empty);
if(int.TryParse(minrange, NumberStyles.Integer, CultureInfo.InvariantCulture, out this.minrange) && this.minrange > 0f)
{ {
if(!ZDTextParser.GetColorFromString(rendercolor, ref this.rendercolor)) // Get minrangecolor
{ string minrangecolor = cfg.ReadSetting(argspath + ".arg" + istr + ".minrangecolor", string.Empty);
General.ErrorLogger.Add(ErrorType.Error, "\"" + argspath + ".arg" + istr + "\": action argument \"" + this.title + "\": unable to get rendercolor from value \"" + rendercolor + "\"!"); this.minrangecolor = General.Colors.Indication;
this.rendercolor = General.Colors.InfoLine.WithAlpha(HELPER_SHAPE_ALPHA);
} if(!string.IsNullOrEmpty(minrangecolor) && !ZDTextParser.GetColorFromString(minrangecolor, ref this.minrangecolor))
else General.ErrorLogger.Add(ErrorType.Error, "\"" + argspath + ".arg" + istr + "\": action argument \"" + this.title + "\": unable to get minrangecolor from value \"" + minrangecolor + "\"!");
{
this.rendercolor.a = HELPER_SHAPE_ALPHA; this.minrangecolor.a = RANGE_SHAPE_ALPHA;
}
} }
else
// Get maxrange settings
string maxrange = cfg.ReadSetting(argspath + ".arg" + istr + ".maxrange", string.Empty);
if(int.TryParse(maxrange, NumberStyles.Integer, CultureInfo.InvariantCulture, out this.maxrange) && this.maxrange > 0f)
{ {
this.rendercolor = General.Colors.InfoLine.WithAlpha(HELPER_SHAPE_ALPHA); // Get minrangecolor
string maxrangecolor = cfg.ReadSetting(argspath + ".arg" + istr + ".maxrangecolor", string.Empty);
this.maxrangecolor = General.Colors.Indication;
if(!string.IsNullOrEmpty(maxrangecolor) && !ZDTextParser.GetColorFromString(maxrangecolor, ref this.maxrangecolor))
General.ErrorLogger.Add(ErrorType.Error, "\"" + argspath + ".arg" + istr + "\": action argument \"" + this.title + "\": unable to get maxrangecolor from value \"" + maxrangecolor + "\"!");
this.maxrangecolor.a = RANGE_SHAPE_ALPHA;
}
// Update tooltip?
if(this.minrange > 0f || this.maxrange > 0f)
{
if(!string.IsNullOrEmpty(this.tooltip)) this.tooltip += Environment.NewLine;
if(this.minrange > 0f && this.maxrange > 0f)
this.tooltip += "Range: " + this.minrange + " - " + this.maxrange;
else if(this.minrange > 0f)
this.tooltip += "Minimum range: " + this.minrange;
else
this.tooltip += "Maximum range: " + this.maxrange;
} }
} }
@ -196,6 +237,7 @@ namespace CodeImp.DoomBuilder.Config
//mxd. Constructor for an argument info defined in DECORATE //mxd. Constructor for an argument info defined in DECORATE
internal ArgumentInfo(string actorname, string argtitle, string tooltip, string renderstyle, string rendercolor, internal ArgumentInfo(string actorname, string argtitle, string tooltip, string renderstyle, string rendercolor,
string minrange, string minrangecolor, string maxrange, string maxrangecolor,
int type, int defaultvalue, string enumstr, IDictionary<string, EnumList> enums) int type, int defaultvalue, string enumstr, IDictionary<string, EnumList> enums)
{ {
this.used = true; this.used = true;
@ -218,21 +260,49 @@ namespace CodeImp.DoomBuilder.Config
if(this.renderstyle != ArgumentRenderStyle.NONE) if(this.renderstyle != ArgumentRenderStyle.NONE)
{ {
if(!string.IsNullOrEmpty(rendercolor)) // Get rendercolor
this.rendercolor = General.Colors.InfoLine;
if(!string.IsNullOrEmpty(rendercolor) && !ZDTextParser.GetColorFromString(rendercolor, ref this.rendercolor))
General.ErrorLogger.Add(ErrorType.Error, actorname + ": action argument \"" + argtitle + "\": unable to get rendercolor from value \"" + rendercolor + "\"!");
this.rendercolor.a = HELPER_SHAPE_ALPHA;
// Get minrange settings
if(int.TryParse(minrange, NumberStyles.Integer, CultureInfo.InvariantCulture, out this.minrange) && this.minrange > 0f)
{ {
if(!ZDTextParser.GetColorFromString(rendercolor, ref this.rendercolor)) // Get minrangecolor
{ this.minrangecolor = General.Colors.Indication;
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); if(!string.IsNullOrEmpty(minrangecolor) && !ZDTextParser.GetColorFromString(minrangecolor, ref this.minrangecolor))
} General.ErrorLogger.Add(ErrorType.Error, actorname + ": action argument \"" + this.title + "\": unable to get minrangecolor from value \"" + minrangecolor + "\"!");
else
{ this.minrangecolor.a = RANGE_SHAPE_ALPHA;
this.rendercolor.a = HELPER_SHAPE_ALPHA;
}
} }
else
// Get maxrange settings
if(int.TryParse(maxrange, NumberStyles.Integer, CultureInfo.InvariantCulture, out this.maxrange) && this.maxrange > 0f)
{ {
this.rendercolor = General.Colors.InfoLine.WithAlpha(HELPER_SHAPE_ALPHA); // Get minrangecolor
this.maxrangecolor = General.Colors.Indication;
if(!string.IsNullOrEmpty(maxrangecolor) && !ZDTextParser.GetColorFromString(maxrangecolor, ref this.maxrangecolor))
General.ErrorLogger.Add(ErrorType.Error, actorname + ": action argument \"" + this.title + "\": unable to get maxrangecolor from value \"" + maxrangecolor + "\"!");
this.maxrangecolor.a = RANGE_SHAPE_ALPHA;
}
// Update tooltip?
if(this.minrange > 0f || this.maxrange > 0f)
{
if(!string.IsNullOrEmpty(this.tooltip)) this.tooltip += Environment.NewLine + Environment.NewLine;
if(this.minrange > 0f && this.maxrange > 0f)
this.tooltip += "Expected range: " + this.minrange + " - " + this.maxrange;
else if(this.minrange > 0f)
this.tooltip += "Minimum: " + this.minrange;
else
this.tooltip += "Maximum: " + this.maxrange;
} }
} }

View file

@ -477,8 +477,23 @@ namespace CodeImp.DoomBuilder.Config
int defaultvalue = actor.GetPropertyValueInt("$arg" + i + "default", 0); int defaultvalue = actor.GetPropertyValueInt("$arg" + i + "default", 0);
string argenum = ZDTextParser.StripQuotes(actor.GetPropertyAllValues("$arg" + i + "enum")); string argenum = ZDTextParser.StripQuotes(actor.GetPropertyAllValues("$arg" + i + "enum"));
string argrenderstyle = ZDTextParser.StripQuotes(actor.GetPropertyAllValues("$arg" + i + "renderstyle")); string argrenderstyle = ZDTextParser.StripQuotes(actor.GetPropertyAllValues("$arg" + i + "renderstyle"));
string argrendercolor = ZDTextParser.StripQuotes(actor.GetPropertyAllValues("$arg" + i + "rendercolor")); string argrendercolor, minrange, maxrange, minrangecolor, maxrangecolor;
args[i] = new ArgumentInfo(title, argtitle, argtooltip, argrenderstyle, argrendercolor, argtype, defaultvalue, argenum, General.Map.Config.Enums); if(!string.IsNullOrEmpty(argrenderstyle))
{
argrendercolor = ZDTextParser.StripQuotes(actor.GetPropertyAllValues("$arg" + i + "rendercolor"));
minrange = ZDTextParser.StripQuotes(actor.GetPropertyAllValues("$arg" + i + "minrange"));
minrangecolor = ZDTextParser.StripQuotes(actor.GetPropertyAllValues("$arg" + i + "minrangecolor"));
maxrange = ZDTextParser.StripQuotes(actor.GetPropertyAllValues("$arg" + i + "maxrange"));
maxrangecolor = ZDTextParser.StripQuotes(actor.GetPropertyAllValues("$arg" + i + "maxrangecolor"));
}
else
{
argrendercolor = string.Empty; minrange = string.Empty; maxrange = string.Empty; minrangecolor = string.Empty; maxrangecolor = string.Empty;
}
args[i] = new ArgumentInfo(title, argtitle, argtooltip, argrenderstyle, argrendercolor,
minrange, minrangecolor, maxrange, maxrangecolor,
argtype, defaultvalue, argenum, General.Map.Config.Enums);
} }
//mxd. Some SLADE compatibility //mxd. Some SLADE compatibility

View file

@ -1081,6 +1081,9 @@ namespace CodeImp.DoomBuilder.BuilderModes
// Update ambient sound radii // Update ambient sound radii
ambientsoundshapes = GetAmbientSoundShapes(General.Map.Map.Things); ambientsoundshapes = GetAmbientSoundShapes(General.Map.Map.Things);
// Update argument range shapes
persistenteventlines.AddRange(GetArgumentRangeShapes(General.Map.Map.Things));
} }
//mxd //mxd
@ -1219,6 +1222,43 @@ namespace CodeImp.DoomBuilder.BuilderModes
return circles; return circles;
} }
private List<Line3D> GetArgumentRangeShapes(IEnumerable<Thing> things)
{
List<Line3D> lines = new List<Line3D>();
const int numsides = 24;
foreach(Thing t in things)
{
ThingTypeInfo info = General.Map.Data.GetThingInfoEx(t.Type);
if(info == null) continue;
// Process argument based range finders
for(int i = 0; i < t.Args.Length; i++)
{
if(t.Args[i] == 0) continue; // Avoid visual noise
var a = info.Args[i];
switch(a.RenderStyle)
{
case ArgumentInfo.ArgumentRenderStyle.CIRCLE:
if(a.MinRange > 0) lines.AddRange(LinksCollector.MakeCircleLines(t.Position, a.MinRangeColor, a.MinRange, numsides));
if(a.MaxRange > 0) lines.AddRange(LinksCollector.MakeCircleLines(t.Position, a.MaxRangeColor, a.MaxRange, numsides));
break;
case ArgumentInfo.ArgumentRenderStyle.RECTANGLE:
if(a.MinRange > 0) lines.AddRange(LinksCollector.MakeRectangleLines(t.Position, a.MinRangeColor, a.MinRange));
if(a.MaxRange > 0) lines.AddRange(LinksCollector.MakeRectangleLines(t.Position, a.MaxRangeColor, a.MaxRange));
break;
case ArgumentInfo.ArgumentRenderStyle.NONE:break;
default: throw new NotImplementedException("Unknown ArgumentRenderStyle");
}
}
}
return lines;
}
#endregion #endregion
#region ================== Actions #region ================== Actions