mirror of
https://git.do.srb2.org/STJr/UltimateZoneBuilder.git
synced 2024-11-22 20:02:48 +00:00
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:
parent
cd854779e8
commit
1c684f7213
5 changed files with 201 additions and 26 deletions
|
@ -103,6 +103,27 @@ arg0
|
|||
Allows to specify a color used by rendering shape. Supported values are hex color (like "<strong>FF0000</strong>"), HTML-formatted hex color (like "<strong>#F00</strong>" or "<strong>#FF0000</strong>") or color name (like "<strong>Red</strong>").<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 "<b class="fat">renderstyle</b>" 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 "<b class="fat">renderstyle</b>" 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 "<strong>FF0000</strong>"), HTML-formatted hex color (like "<strong>#F00</strong>" or "<strong>#FF0000</strong>") or color name (like "<strong>Red</strong>").<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 "<b class="fat">renderstyle</b>" and "<b class="fat">minrange</b>" 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 "<b class="fat">renderstyle</b>" 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 "<strong>FF0000</strong>"), HTML-formatted hex color (like "<strong>#F00</strong>" or "<strong>#FF0000</strong>") or color name (like "<strong>Red</strong>").<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 "<b class="fat">renderstyle</b>" and "<b class="fat">maxrange</b>" properties.</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 />
|
||||
|
|
|
@ -73,6 +73,29 @@
|
|||
This property must be used in conjunction with "<strong>//$ArgN</strong>" and "<strong>//$ArgNRenderStyle</strong>" properties.<br />
|
||||
<br />
|
||||
|
||||
<strong><a name="argminrange" id="argminrange"></a>//$ArgNMinRange <integer></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 "<strong>//$ArgN</strong>" and "<strong>//$ArgNRenderStyle</strong>" properties.<br />
|
||||
<br />
|
||||
|
||||
<strong><a name="argminrangecolor" id="argminrangecolor"></a>//$ArgNMinRangeColor <integer></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 "<strong>FF0000</strong>"), HTML-formatted hex color (like "<strong>#F00</strong>" or "<strong>#FF0000</strong>") or color name (like "<strong>Red</strong>").<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 "<strong>//$ArgN</strong>", "<strong>//$ArgNRenderStyle</strong>" and "<strong>//$ArgNMinRange</strong>" properties.<br />
|
||||
<br />
|
||||
|
||||
<strong><a name="argmaxrange" id="argmaxrange"></a>//$ArgNMaxRange <integer></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 "<strong>//$ArgN</strong>" and "<strong>//$ArgNRenderStyle</strong>" properties.<br />
|
||||
<br />
|
||||
|
||||
<strong><a name="argmaxrangecolor" id="argmaxrangecolor"></a>//$ArgNMaxRangeColor <integer></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 "<strong>FF0000</strong>"), HTML-formatted hex color (like "<strong>#F00</strong>" or "<strong>#FF0000</strong>") or color name (like "<strong>Red</strong>").<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 "<strong>//$ArgN</strong>", "<strong>//$ArgNRenderStyle</strong>" and "<strong>//$ArgNMaxRange</strong>" properties.<br />
|
||||
<br />
|
||||
|
||||
<strong><a name="argenum" id="argenum"></a>//$ArgNEnum <string or structure></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 "<strong>//$ArgN</strong>" property.<br />
|
||||
|
@ -136,15 +159,21 @@ Actor ChexShield : ResistanceRune replaces ResistanceRune 5104
|
|||
//$Arg3Default 32
|
||||
//$Arg3RenderStyle "Circle"
|
||||
//$Arg3RenderColor #ff00ff
|
||||
//$Arg3MinRange 32
|
||||
//$Arg3MaxRange 512
|
||||
//$Arg3MinRangeColor #0000ff
|
||||
//$Arg3MaxRangeColor #ff0000
|
||||
|
||||
//$Arg4 "Height"
|
||||
//$Arg4Type 24
|
||||
//$Arg4Default 64
|
||||
|
||||
|
||||
Height 44
|
||||
Radius 26
|
||||
RenderStyle None
|
||||
Inventory.PickupMessage "Picked up the energized Chex armor!"
|
||||
|
||||
|
||||
States
|
||||
{
|
||||
|
|
|
@ -34,6 +34,7 @@ namespace CodeImp.DoomBuilder.Config
|
|||
#region ================== Constants
|
||||
|
||||
private const int HELPER_SHAPE_ALPHA = 192; //mxd
|
||||
private const int RANGE_SHAPE_ALPHA = 96; //mxd
|
||||
|
||||
#endregion
|
||||
|
||||
|
@ -60,6 +61,10 @@ namespace CodeImp.DoomBuilder.Config
|
|||
private readonly HashSet<string> targetclasses; //mxd
|
||||
private readonly ArgumentRenderStyle renderstyle; //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
|
||||
|
||||
|
@ -75,6 +80,10 @@ namespace CodeImp.DoomBuilder.Config
|
|||
public object DefaultValue { get { return defaultvalue; } } //mxd
|
||||
public ArgumentRenderStyle RenderStyle { get { return renderstyle; } } //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
|
||||
|
||||
|
@ -110,22 +119,54 @@ namespace CodeImp.DoomBuilder.Config
|
|||
|
||||
if(this.renderstyle != ArgumentRenderStyle.NONE)
|
||||
{
|
||||
// Get rendercolor
|
||||
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))
|
||||
{
|
||||
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;
|
||||
}
|
||||
// Get minrangecolor
|
||||
string minrangecolor = cfg.ReadSetting(argspath + ".arg" + istr + ".minrangecolor", string.Empty);
|
||||
this.minrangecolor = General.Colors.Indication;
|
||||
|
||||
if(!string.IsNullOrEmpty(minrangecolor) && !ZDTextParser.GetColorFromString(minrangecolor, ref this.minrangecolor))
|
||||
General.ErrorLogger.Add(ErrorType.Error, "\"" + argspath + ".arg" + istr + "\": action argument \"" + this.title + "\": unable to get minrangecolor from value \"" + minrangecolor + "\"!");
|
||||
|
||||
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
|
||||
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)
|
||||
{
|
||||
this.used = true;
|
||||
|
@ -218,21 +260,49 @@ namespace CodeImp.DoomBuilder.Config
|
|||
|
||||
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))
|
||||
{
|
||||
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;
|
||||
}
|
||||
// Get minrangecolor
|
||||
this.minrangecolor = General.Colors.Indication;
|
||||
|
||||
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 + "\"!");
|
||||
|
||||
this.minrangecolor.a = RANGE_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;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -477,8 +477,23 @@ namespace CodeImp.DoomBuilder.Config
|
|||
int defaultvalue = actor.GetPropertyValueInt("$arg" + i + "default", 0);
|
||||
string argenum = ZDTextParser.StripQuotes(actor.GetPropertyAllValues("$arg" + i + "enum"));
|
||||
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);
|
||||
string argrendercolor, minrange, maxrange, minrangecolor, maxrangecolor;
|
||||
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
|
||||
|
|
|
@ -1081,6 +1081,9 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
|
||||
// Update ambient sound radii
|
||||
ambientsoundshapes = GetAmbientSoundShapes(General.Map.Map.Things);
|
||||
|
||||
// Update argument range shapes
|
||||
persistenteventlines.AddRange(GetArgumentRangeShapes(General.Map.Map.Things));
|
||||
}
|
||||
|
||||
//mxd
|
||||
|
@ -1219,6 +1222,43 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
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
|
||||
|
||||
#region ================== Actions
|
||||
|
|
Loading…
Reference in a new issue