Skip to content

Commit

Permalink
Merge pull request #334 from oliver-szymanski/personal-lights-color-332
Browse files Browse the repository at this point in the history
Fix #332 Allow multiple and setting of color for personal lights
  • Loading branch information
cwisniew authored Mar 22, 2019
2 parents 7cf4f93 + ca6a078 commit 332e640
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 8 deletions.
3 changes: 3 additions & 0 deletions CHANGE_LOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,11 @@ A new shift+ctrl+spacebar command along with a new pointer image is now availabl
* [#237][i237] - Added support to use shift-enter to insert newlines into the command entry box (also known as the chat entry box)
* [#239][i239] - MapToolScriptTokenMaker now handles function names with . notation and dynamically pulls in all functions names. TokenMakerMaker no longer needs to be ran upon changes to MTScript.
* [#240][i240] - Macro Editor now has Auto-Completion for macro functions! A brief description and summary can be displayed (these will be added as time permits)
* [#332][i332] - Allow to set color for personal lights in campaign Sight types
* [#324][i324] - fix output of getViewPort. This might break existing macro using workaround to interpret the broken result before the fix.
* [#326][i326] - defineFunction with open edit window

[i332]: https://github.com/RPTools/maptool/issues/332
[i324]: https://github.com/RPTools/maptool/issues/324
[i326]: https://github.com/RPTools/maptool/issues/326
[i210]: https://github.com/RPTools/maptool/issues/210
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -302,8 +302,20 @@ private String updateSightPanel(Map<String, SightType> sightTypeMap) {
if (sight.getPersonalLightSource() != null) {
LightSource source = sight.getPersonalLightSource();

double range = source.getMaxRange();
builder.append("r").append(StringUtil.formatDecimal(range)).append(' ');
if (source.getLightList() != null) {
for (Light light : source.getLightList()) {
double range = light.getRadius();

builder.append("r").append(StringUtil.formatDecimal(range));

if (light.getPaint() != null && light.getPaint() instanceof DrawableColorPaint) {
Color color = (Color) light.getPaint().getPaint();
builder.append(toHex(color));
}

builder.append(' ');
}
}
}
builder.append('\n');
}
Expand Down Expand Up @@ -470,6 +482,7 @@ private void commitSightMap(final String text) {
int offset = 0;
double pLightRange = 0;

personalLight = new LightSource();
for (String arg : args) {
assert arg.length() > 0; // The split() uses "one or more spaces", removing empty strings
try {
Expand All @@ -484,14 +497,32 @@ private void commitSightMap(final String text) {
continue;
}
try {

if (arg.startsWith("x")) {
toBeParsed = arg.substring(1); // Used in the catch block, below
errmsg = "msg.error.mtprops.sight.multiplier"; // (ditto)
magnifier = StringUtil.parseDecimal(toBeParsed);
} else if (arg.startsWith("r")) { // XXX Why not "r=#" instead of "r#"??
Color personalLightColor = null;
toBeParsed = arg.substring(1);

split = toBeParsed.indexOf("#");
if (split > 0) {
String colorString = toBeParsed.substring(split); // Keep the '#'
toBeParsed = toBeParsed.substring(0, split);
personalLightColor = Color.decode(colorString);
}

errmsg = "msg.error.mtprops.sight.range";
pLightRange = StringUtil.parseDecimal(toBeParsed);

if (personalLight == null) {
personalLight = new LightSource();
}
DrawableColorPaint personalLightPaint =
personalLightColor != null ? new DrawableColorPaint(personalLightColor) : null;
personalLight.add(new Light(shape, 0, pLightRange, arc, personalLightPaint));
personalLight.setScaleWithToken(scaleWithToken);
} else if (arg.startsWith("arc=") && arg.length() > 4) {
toBeParsed = arg.substring(4);
errmsg = "msg.error.mtprops.sight.arc";
Expand All @@ -516,11 +547,6 @@ private void commitSightMap(final String text) {
errlog.add(I18N.getText(errmsg, reader.getLineNumber(), toBeParsed));
}
}
if (pLightRange > 0) {
personalLight = new LightSource();
personalLight.add(new Light(shape, 0, pLightRange, arc, null));
personalLight.setScaleWithToken(scaleWithToken);
}
SightType sight =
new SightType(label, magnifier, personalLight, shape, arc, scaleWithToken);
sight.setDistance(range);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1078,7 +1078,7 @@
</at>
<at name="name"></at>
<at name="width">1013</at>
<at name="text">&lt;html&gt;&lt;b&gt;Format:&lt;/b&gt; &amp;nbsp&amp;nbsp&amp;nbsp;Name : options &lt;p&gt;&lt;p&gt; Each sight type can have zero or more options, use spaces between each option. Having zero options implies using defaults for all values (e.g. Normal vision).&lt;p&gt;&lt;p&gt; &lt;b&gt; Options:&lt;/b&gt; &lt;p&gt;&lt;p&gt; shape - shape may be circle, square, or cone&lt;br&gt; distance=y - Distance is the range at which this vision type ends. Can be a decimal value. Ex: distance=10&lt;br&gt; scale - An optional keyword that adds the token&apos;s footprint (size) to the distance so vision starts at token&apos;s edge vs the token&apos;s center&lt;br&gt; arc=y - When used with the cone shape, it signifies how large a field of vision the token has. Can be an interger value. Ex: arc=120&lt;br&gt; offset=y - When used with the cone shape, it signifies how much offest the cone begins from the center of the tokens facing. Can be an interger value. Ex: offset=120&lt;br&gt; x# - Maginifier, multiplies each light source radius by this value. Can be a decimal value. Ex: x2&lt;br&gt; r# - Range of personal light. The token will have a light source centered on them that only they can see with a radius of this value. Ex: r60&lt;br&gt; </at>
<at name="text">&lt;html&gt;&lt;b&gt;Format:&lt;/b&gt; &amp;nbsp&amp;nbsp&amp;nbsp;Name : options &lt;p&gt;&lt;p&gt; Each sight type can have zero or more options, use spaces between each option. Having zero options implies using defaults for all values (e.g. Normal vision).&lt;p&gt;&lt;p&gt; &lt;b&gt; Options:&lt;/b&gt; &lt;p&gt;&lt;p&gt; shape - shape may be circle, square, or cone&lt;br&gt; distance=y - Distance is the range at which this vision type ends. Can be a decimal value. Ex: distance=10&lt;br&gt; scale - An optional keyword that adds the token&apos;s footprint (size) to the distance so vision starts at token&apos;s edge vs the token&apos;s center&lt;br&gt; arc=y - When used with the cone shape, it signifies how large a field of vision the token has. Can be an interger value. Ex: arc=120&lt;br&gt; offset=y - When used with the cone shape, it signifies how much offest the cone begins from the center of the tokens facing. Can be an interger value. Ex: offset=120&lt;br&gt; x# - Maginifier, multiplies each light source radius by this value. Can be a decimal value. Ex: x2&lt;br&gt; r# - Range of personal light. You can define multiple personal lights per sight type. Can have an optional #rrggbb hex color component appended to it as per typical CSS rules. The token will have a light source centered on them that only they can see with a radius of this value. Ex: r60&lt;br&gt; </at>
<at name="fill">
<object classname="com.jeta.forms.store.properties.effects.PaintProperty">
<at name="name">fill</at>
Expand Down

0 comments on commit 332e640

Please sign in to comment.