Skip to content

Commit

Permalink
Merge pull request #4299 from ColdAnkles/cover-vbl
Browse files Browse the repository at this point in the history
Cover VBL Addition
  • Loading branch information
cwisniew authored Nov 3, 2023
2 parents 67e2103 + 5c6c5bc commit d4961f7
Show file tree
Hide file tree
Showing 23 changed files with 211 additions and 13 deletions.
2 changes: 2 additions & 0 deletions src/main/java/net/rptools/maptool/client/AppStyle.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,11 @@ public class AppStyle {
public static Color topologyRemoveColor = new Color(255, 255, 255, 128);
public static Color hillVblColor = new Color(0, 255, 255, 128);
public static Color pitVblColor = new Color(104, 255, 0, 128);
public static Color coverVblColor = new Color(245, 0, 0, 128);
public static Color topologyTerrainColor = new Color(255, 0, 255, 128);
public static Color tokenTopologyColor = new Color(255, 255, 0, 128);
public static Color tokenHillVblColor = new Color(255, 136, 0, 128);
public static Color tokenPitVblColor = new Color(255, 0, 0, 128);
public static Color tokenCoverVblColor = new Color(245, 0, 0, 128);
public static Color tokenMblColor = new Color(255, 128, 255, 128);
}
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,14 @@
*
* <p>getPitVBL(jsonArray) :: Get the Pit VBL for a given area and return as array of points
*
* <p>drawCoverVBL(jsonArray) :: Takes an array of JSON Objects containing information to draw a
* Shape in Cover VBL
*
* <p>eraseCoverVBL(jsonArray) :: Takes an array of JSON Objects containing information to erase a
* Shape in Cover VBL
*
* <p>getCoverVBL(jsonArray) :: Get the Cover VBL for a given area and return as array of points
*
* <p>drawMBL(jsonArray) :: Takes an array of JSON Objects containing information to draw a Shape in
* MBL
*
Expand Down Expand Up @@ -101,6 +109,14 @@
* <p>transferPitVBL(direction[, delete][, tokenId] :: move or copy Pit VBL between token and Pit
* VBL layer
*
* <p>getTokenCoverVBL(tokenId) :: Get the Pit Cover attached to a token
*
* <p>setTokenCoverVBL(jsonArray, tokenId) :: Sets the token's Cover VBL to the information contains
* in the JSON Objects.
*
* <p>transferCoverVBL(direction[, delete][, tokenId] :: move or copy Cover VBL between token and
* Pit VBL layer
*
* <p>getTokenMBL(tokenId) :: Get the MBL attached to a token
*
* <p>setTokenMBL(jsonArray, tokenId) :: Sets the token's MBL to the information contains in the
Expand All @@ -127,20 +143,26 @@ private Topology_Functions() {
"drawPitVBL",
"erasePitVBL",
"getPitVBL",
"drawCoverVBL",
"eraseCoverVBL",
"getCoverVBL",
"drawMBL",
"eraseMBL",
"getMBL",
"getTokenVBL",
"getTokenHillVBL",
"getTokenPitVBL",
"getTokenCoverVBL",
"getTokenMBL",
"setTokenVBL",
"setTokenHillVBL",
"setTokenPitVBL",
"setTokenCoverVBL",
"setTokenMBL",
"transferVBL",
"transferHillVBL",
"transferPitVBL",
"transferCoverVBL",
"transferMBL");
}

Expand All @@ -160,22 +182,27 @@ public Object childEvaluate(
|| functionName.equalsIgnoreCase("eraseHillVBL")
|| functionName.equalsIgnoreCase("drawPitVBL")
|| functionName.equalsIgnoreCase("erasePitVBL")
|| functionName.equalsIgnoreCase("drawCoverVBL")
|| functionName.equalsIgnoreCase("eraseCoverVBL")
|| functionName.equalsIgnoreCase("drawMBL")
|| functionName.equalsIgnoreCase("eraseMBL")) {
childEvaluateDrawEraseTopology(functionName, parameters);
} else if (functionName.equalsIgnoreCase("getVBL")
|| functionName.equalsIgnoreCase("getHillVBL")
|| functionName.equalsIgnoreCase("getPitVBL")
|| functionName.equalsIgnoreCase("getCoverVBL")
|| functionName.equalsIgnoreCase("getMBL")) {
return childEvaluateGetTopology(functionName, parameters);
} else if (functionName.equalsIgnoreCase("getTokenVBL")
|| functionName.equalsIgnoreCase("getTokenHillVBL")
|| functionName.equalsIgnoreCase("getTokenPitVBL")
|| functionName.equalsIgnoreCase("getTokenCoverVBL")
|| functionName.equalsIgnoreCase("getTokenMBL")) {
return childEvaluateGetTokenTopology(resolver, functionName, parameters).toString();
} else if (functionName.equalsIgnoreCase("setTokenVBL")
|| functionName.equalsIgnoreCase("setTokenHillVBL")
|| functionName.equalsIgnoreCase("setTokenPitVBL")
|| functionName.equalsIgnoreCase("setTokenCoverVBL")
|| functionName.equalsIgnoreCase("setTokenMBL")) {
var results = childEvaluateSetTokenTopology(resolver, functionName, parameters);
if (results >= 0) {
Expand All @@ -184,6 +211,7 @@ public Object childEvaluate(
} else if (functionName.equalsIgnoreCase("transferVBL")
|| functionName.equalsIgnoreCase("transferHillVBL")
|| functionName.equalsIgnoreCase("transferPitVBL")
|| functionName.equalsIgnoreCase("transferCoverVBL")
|| functionName.equalsIgnoreCase("transferMBL")) {
childEvaluateTransferTopology(resolver, functionName, parameters);
} else {
Expand All @@ -210,6 +238,7 @@ private void childEvaluateDrawEraseTopology(String functionName, List<Object> pa
if (functionName.equalsIgnoreCase("eraseVBL")
|| functionName.equalsIgnoreCase("eraseHillVBL")
|| functionName.equalsIgnoreCase("erasePitVBL")
|| functionName.equalsIgnoreCase("eraseCoverVBL")
|| functionName.equalsIgnoreCase("eraseMBL")) {
erase = true;
}
Expand Down Expand Up @@ -244,6 +273,9 @@ private void childEvaluateDrawEraseTopology(String functionName, List<Object> pa
} else if (functionName.equalsIgnoreCase("drawPitVBL")
|| functionName.equalsIgnoreCase("erasePitVBL")) {
topologyType = Zone.TopologyType.PIT_VBL;
} else if (functionName.equalsIgnoreCase("drawCoverVBL")
|| functionName.equalsIgnoreCase("eraseCoverVBL")) {
topologyType = Zone.TopologyType.COVER_VBL;
} else {
topologyType = Zone.TopologyType.MBL;
}
Expand Down Expand Up @@ -273,6 +305,8 @@ private Object childEvaluateGetTopology(String functionName, List<Object> parame
topologyType = Zone.TopologyType.HILL_VBL;
} else if (functionName.equalsIgnoreCase("getPitVBL")) {
topologyType = Zone.TopologyType.PIT_VBL;
} else if (functionName.equalsIgnoreCase("getCoverVBL")) {
topologyType = Zone.TopologyType.COVER_VBL;
} else {
topologyType = Zone.TopologyType.MBL;
}
Expand Down Expand Up @@ -345,6 +379,8 @@ private JsonArray childEvaluateGetTokenTopology(
topologyType = Zone.TopologyType.HILL_VBL;
} else if (functionName.equalsIgnoreCase("getTokenPitVBL")) {
topologyType = Zone.TopologyType.PIT_VBL;
} else if (functionName.equalsIgnoreCase("getTokenCoverVBL")) {
topologyType = Zone.TopologyType.COVER_VBL;
} else {
topologyType = Zone.TopologyType.MBL;
}
Expand Down Expand Up @@ -392,6 +428,8 @@ private int childEvaluateSetTokenTopology(
topologyType = Zone.TopologyType.HILL_VBL;
} else if (functionName.equalsIgnoreCase("setTokenPitVBL")) {
topologyType = Zone.TopologyType.PIT_VBL;
} else if (functionName.equalsIgnoreCase("setTokenCoverVBL")) {
topologyType = Zone.TopologyType.COVER_VBL;
} else {
topologyType = Zone.TopologyType.MBL;
}
Expand Down Expand Up @@ -496,6 +534,8 @@ private void childEvaluateTransferTopology(
topologyType = Zone.TopologyType.HILL_VBL;
} else if (functionName.equalsIgnoreCase("transferPitVBL")) {
topologyType = Zone.TopologyType.PIT_VBL;
} else if (functionName.equalsIgnoreCase("transferCoverVBL")) {
topologyType = Zone.TopologyType.COVER_VBL;
} else {
topologyType = Zone.TopologyType.MBL;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,12 @@ public TopologyModeSelectionPanel() {
Icons.TOOLBAR_TOPOLOGY_TYPE_PIT_OFF,
"tools.topology_mode_selection.pit_vbl.tooltip",
initiallySelectedTypes);
createAndAddModeButton(
Zone.TopologyType.COVER_VBL,
Icons.TOOLBAR_TOPOLOGY_TYPE_COVER_ON,
Icons.TOOLBAR_TOPOLOGY_TYPE_COVER_OFF,
"tools.topology_mode_selection.cover_vbl.tooltip",
initiallySelectedTypes);
createAndAddModeButton(
Zone.TopologyType.MBL,
Icons.TOOLBAR_TOPOLOGY_TYPE_MBL_ON,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,8 @@ protected void paintTopologyOverlay(Graphics2D g, Drawable drawable, int penMode
g2.fill(getTokenTopology(Zone.TopologyType.HILL_VBL));
g2.setColor(AppStyle.tokenPitVblColor);
g2.fill(getTokenTopology(Zone.TopologyType.PIT_VBL));
g2.setColor(AppStyle.tokenCoverVblColor);
g2.fill(getTokenTopology(Zone.TopologyType.COVER_VBL));

g2.setColor(AppStyle.topologyTerrainColor);
g2.fill(zone.getTopology(Zone.TopologyType.MBL));
Expand All @@ -292,6 +294,9 @@ protected void paintTopologyOverlay(Graphics2D g, Drawable drawable, int penMode
g2.setColor(AppStyle.pitVblColor);
g2.fill(zone.getTopology(Zone.TopologyType.PIT_VBL));

g2.setColor(AppStyle.coverVblColor);
g2.fill(zone.getTopology(Zone.TopologyType.COVER_VBL));

g2.dispose();
}

Expand Down
2 changes: 2 additions & 0 deletions src/main/java/net/rptools/maptool/client/ui/theme/Icons.java
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,8 @@ public enum Icons {
TOOLBAR_TOPOLOGY_TYPE_MBL_ON,
TOOLBAR_TOPOLOGY_TYPE_PIT_OFF,
TOOLBAR_TOPOLOGY_TYPE_PIT_ON,
TOOLBAR_TOPOLOGY_TYPE_COVER_OFF,
TOOLBAR_TOPOLOGY_TYPE_COVER_ON,
TOOLBAR_TOPOLOGY_TYPE_VBL_OFF,
TOOLBAR_TOPOLOGY_TYPE_VBL_ON,
TOOLBAR_VOLUME_OFF,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,8 @@ public class RessourceManager {
put(Icons.TOOLBAR_TOPOLOGY_TYPE_MBL_ON, IMAGE_DIR + "tool/mbl-only.png");
put(Icons.TOOLBAR_TOPOLOGY_TYPE_PIT_OFF, IMAGE_DIR + "tool/pit-vbl-only-off.png");
put(Icons.TOOLBAR_TOPOLOGY_TYPE_PIT_ON, IMAGE_DIR + "tool/pit-vbl-only.png");
put(Icons.TOOLBAR_TOPOLOGY_TYPE_COVER_OFF, IMAGE_DIR + "tool/cover-vbl-only-off.png");
put(Icons.TOOLBAR_TOPOLOGY_TYPE_COVER_ON, IMAGE_DIR + "tool/cover-vbl-only.png");
put(Icons.TOOLBAR_TOPOLOGY_TYPE_VBL_OFF, IMAGE_DIR + "tool/wall-vbl-only-off.png");
put(Icons.TOOLBAR_TOPOLOGY_TYPE_VBL_ON, IMAGE_DIR + "tool/wall-vbl-only.png");
put(Icons.TOOLBAR_VOLUME_OFF, IMAGE_DIR + "audio/mute.png");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -412,6 +412,12 @@ public void bind(final Token token) {
.setSelectedIcon(RessourceManager.getBigIcon(Icons.TOOLBAR_TOPOLOGY_TYPE_PIT_ON));
getPitVblToggle().setIcon(RessourceManager.getBigIcon(Icons.TOOLBAR_TOPOLOGY_TYPE_PIT_ON));

getCoverVblToggle()
.setSelected(getTokenTopologyPanel().isTopologyTypeSelected(Zone.TopologyType.COVER_VBL));
getCoverVblToggle()
.setSelectedIcon(RessourceManager.getBigIcon(Icons.TOOLBAR_TOPOLOGY_TYPE_COVER_ON));
getCoverVblToggle().setIcon(RessourceManager.getBigIcon(Icons.TOOLBAR_TOPOLOGY_TYPE_COVER_ON));

getMblToggle()
.setSelected(getTokenTopologyPanel().isTopologyTypeSelected(Zone.TopologyType.MBL));
getMblToggle().setSelectedIcon(RessourceManager.getBigIcon(Icons.TOOLBAR_TOPOLOGY_TYPE_MBL_ON));
Expand Down Expand Up @@ -1082,6 +1088,10 @@ public JToggleButton getPitVblToggle() {
return (JToggleButton) getComponent("pitVblToggle");
}

public JToggleButton getCoverVblToggle() {
return (JToggleButton) getComponent("coverVblToggle");
}

public JToggleButton getMblToggle() {
return (JToggleButton) getComponent("mblToggle");
}
Expand Down Expand Up @@ -1285,6 +1295,13 @@ public void initTokenTopologyPanel() {
getTokenTopologyPanel()
.setTopologyTypeSelected(
Zone.TopologyType.PIT_VBL, ((AbstractButton) e.getSource()).isSelected()));
getCoverVblToggle()
.addActionListener(
e ->
getTokenTopologyPanel()
.setTopologyTypeSelected(
Zone.TopologyType.COVER_VBL,
((AbstractButton) e.getSource()).isSelected()));
getMblToggle()
.addActionListener(
e ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@
</component>
</children>
</grid>
<grid id="149c6" layout-manager="GridLayoutManager" row-count="1" column-count="4" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<grid id="149c6" layout-manager="GridLayoutManager" row-count="1" column-count="5" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<grid row="0" column="0" row-span="1" col-span="3" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
Expand All @@ -136,7 +136,7 @@
<children>
<component id="e4b0f" class="javax.swing.JToggleButton">
<constraints>
<grid row="0" column="3" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="0" indent="0" use-parent-layout="false"/>
<grid row="0" column="4" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<name value="mblToggle"/>
Expand Down Expand Up @@ -174,6 +174,16 @@
<toolTipText resource-bundle="net/rptools/maptool/language/i18n" key="EditTokenDialog.button.movepbltoggle.tooltip"/>
</properties>
</component>
<component id="2b7ed" class="javax.swing.JToggleButton">
<constraints>
<grid row="0" column="3" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<name value="coverVblToggle"/>
<text value=""/>
<toolTipText resource-bundle="net/rptools/maptool/language/i18n" key="EditTokenDialog.button.movecbltoggle.tooltip"/>
</properties>
</component>
</children>
</grid>
<component id="8d0a6" class="javax.swing.JCheckBox">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,11 @@ protected void paintComponent(Graphics g) {
g2d.fill(
atArea.createTransformedShape(
tokenTopologiesOptimized.getOrDefault(Zone.TopologyType.PIT_VBL, new Area())));

g2d.setColor(getTopologyColor(AppStyle.tokenCoverVblColor));
g2d.fill(
atArea.createTransformedShape(
tokenTopologiesOptimized.getOrDefault(Zone.TopologyType.COVER_VBL, new Area())));
}

// Draw the number of points generated
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,12 @@ public class FogUtil {
* @return the visible area.
*/
public static @Nonnull Area calculateVisibility(
Point origin, Area vision, AreaTree topology, AreaTree hillVbl, AreaTree pitVbl) {
Point origin,
Area vision,
AreaTree topology,
AreaTree hillVbl,
AreaTree pitVbl,
AreaTree coverVbl) {
// We could use the vision envelope instead, but vision geometry tends to be pretty simple.
final var visionGeometry = PreparedGeometryFactory.prepare(GeometryUtil.toJts(vision));

Expand All @@ -93,6 +98,7 @@ public class FogUtil {
topologyConsumers.add(acc -> acc.addWallBlocking(topology));
topologyConsumers.add(acc -> acc.addHillBlocking(hillVbl));
topologyConsumers.add(acc -> acc.addPitBlocking(pitVbl));
topologyConsumers.add(acc -> acc.addCoverBlocking(coverVbl));
for (final var consumer : topologyConsumers) {
final var accumulator =
new VisionBlockingAccumulator(geometryFactory, origin, visionGeometry);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ public class RenderPathWorker extends SwingWorker<Void, Void> {
private final Area tokenWallVbl;
private final Area tokenHillVbl;
private final Area tokenPitVbl;
private final Area tokenCoverVbl;
private final Area tokenMbl;

public RenderPathWorker(
Expand All @@ -42,6 +43,7 @@ public RenderPathWorker(
Area tokenWallVbl,
Area tokenHillVbl,
Area tokenPitVbl,
Area tokenCoverVbl,
Area tokenMbl,
ZoneRenderer zoneRenderer) {
this.walker = walker;
Expand All @@ -52,6 +54,7 @@ public RenderPathWorker(
this.tokenWallVbl = tokenWallVbl;
this.tokenHillVbl = tokenHillVbl;
this.tokenPitVbl = tokenPitVbl;
this.tokenCoverVbl = tokenCoverVbl;
this.tokenMbl = tokenMbl;
}

Expand All @@ -64,6 +67,7 @@ protected Void doInBackground() {
tokenWallVbl,
tokenHillVbl,
tokenPitVbl,
tokenCoverVbl,
tokenMbl);
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4196,6 +4196,7 @@ public void setOffset(int x, int y) {
token.getTransformedTopology(Zone.TopologyType.WALL_VBL),
token.getTransformedTopology(Zone.TopologyType.HILL_VBL),
token.getTransformedTopology(Zone.TopologyType.PIT_VBL),
token.getTransformedTopology(Zone.TopologyType.COVER_VBL),
token.getTransformedTopology(Zone.TopologyType.MBL),
ZoneRenderer.this);
renderPathThreadPool.execute(renderPathTask);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,8 @@ private List<ContributedLight> calculateLitAreaForLightSource(
lightSourceArea,
getTopologyTree(Zone.TopologyType.WALL_VBL),
getTopologyTree(Zone.TopologyType.HILL_VBL),
getTopologyTree(Zone.TopologyType.PIT_VBL));
getTopologyTree(Zone.TopologyType.PIT_VBL),
getTopologyTree(Zone.TopologyType.COVER_VBL));
if (lightSourceVisibleArea.isEmpty()) {
// Nothing illuminated for this source.
return Collections.emptyList();
Expand Down Expand Up @@ -590,7 +591,8 @@ private Area getTokenVisibleArea(@Nonnull Token token) {
visibleArea,
getTopologyTree(Zone.TopologyType.WALL_VBL),
getTopologyTree(Zone.TopologyType.HILL_VBL),
getTopologyTree(Zone.TopologyType.PIT_VBL));
getTopologyTree(Zone.TopologyType.PIT_VBL),
getTopologyTree(Zone.TopologyType.COVER_VBL));
tokenVisibleAreaCache.put(token.getId(), tokenVisibleArea);
}

Expand Down Expand Up @@ -668,7 +670,8 @@ public List<DrawableLight> getDrawableAuras() {
lightSourceArea,
getTopologyTree(Zone.TopologyType.WALL_VBL),
getTopologyTree(Zone.TopologyType.HILL_VBL),
getTopologyTree(Zone.TopologyType.PIT_VBL));
getTopologyTree(Zone.TopologyType.PIT_VBL),
getTopologyTree(Zone.TopologyType.COVER_VBL));

// This needs to be cached somehow
for (Light light : lightSource.getLightList()) {
Expand Down
Loading

0 comments on commit d4961f7

Please sign in to comment.