diff --git a/CHANGE_LOG.md b/CHANGE_LOG.md index d788602bd7..49a78d407a 100644 --- a/CHANGE_LOG.md +++ b/CHANGE_LOG.md @@ -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 diff --git a/src/main/java/net/rptools/maptool/client/ui/campaignproperties/CampaignPropertiesDialog.java b/src/main/java/net/rptools/maptool/client/ui/campaignproperties/CampaignPropertiesDialog.java index 75ab014d97..a3a918aa74 100644 --- a/src/main/java/net/rptools/maptool/client/ui/campaignproperties/CampaignPropertiesDialog.java +++ b/src/main/java/net/rptools/maptool/client/ui/campaignproperties/CampaignPropertiesDialog.java @@ -302,8 +302,20 @@ private String updateSightPanel(Map 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'); } @@ -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 { @@ -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"; @@ -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); diff --git a/src/main/resources/net/rptools/maptool/client/ui/forms/campaignPropertiesDialog.xml b/src/main/resources/net/rptools/maptool/client/ui/forms/campaignPropertiesDialog.xml index df46ee5468..09137051dd 100644 --- a/src/main/resources/net/rptools/maptool/client/ui/forms/campaignPropertiesDialog.xml +++ b/src/main/resources/net/rptools/maptool/client/ui/forms/campaignPropertiesDialog.xml @@ -1078,7 +1078,7 @@ 1013 - <html><b>Format:</b> &nbsp&nbsp&nbsp;Name : options <p><p> 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).<p><p> <b> Options:</b> <p><p> shape - shape may be circle, square, or cone<br> distance=y - Distance is the range at which this vision type ends. Can be a decimal value. Ex: distance=10<br> scale - An optional keyword that adds the token's footprint (size) to the distance so vision starts at token's edge vs the token's center<br> 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<br> 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<br> x# - Maginifier, multiplies each light source radius by this value. Can be a decimal value. Ex: x2<br> 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<br> + <html><b>Format:</b> &nbsp&nbsp&nbsp;Name : options <p><p> 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).<p><p> <b> Options:</b> <p><p> shape - shape may be circle, square, or cone<br> distance=y - Distance is the range at which this vision type ends. Can be a decimal value. Ex: distance=10<br> scale - An optional keyword that adds the token's footprint (size) to the distance so vision starts at token's edge vs the token's center<br> 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<br> 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<br> x# - Maginifier, multiplies each light source radius by this value. Can be a decimal value. Ex: x2<br> 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<br> fill