/** * Highlight two squares on the chessboard, erasing previous highlight, if any. Use the highlight * square colors per-square color, if set, or just the global highlight block otherwise. * * @param from square index of the first square * @param to square index of the second square */ void highlightSquares(int from, int to) { if (boardStyle.getHighlightStyle() == HighlightStyle.NONE) { return; } // erase the old highlight, if any if (fromSquare >= 0 || toSquare >= 0) { if (boardStyle.getHighlightStyle() == HighlightStyle.LINE) { drawHighlightLine(fromSquare, toSquare, false); } else { paintBoardSquare(fromSquare, null); paintBoardSquare(toSquare, null); } } fromSquare = from; toSquare = to; // draw the new highlight if (from >= 0 || to >= 0) { if (boardStyle.getHighlightStyle() == HighlightStyle.LINE) { drawHighlightLine(fromSquare, toSquare, true); } else { highlightBoardSquare(fromSquare); highlightBoardSquare(toSquare); } } }
private void highlightBoardSquare(int row, int col) { Cuboid sq = getSquare(row, col); MaterialData squareHighlightColor = boardStyle.getHighlightMaterial(col + (row % 2) % 2 == 1); switch (boardStyle.getHighlightStyle()) { case EDGES: sq.getFace(CuboidDirection.East).fill(squareHighlightColor); sq.getFace(CuboidDirection.North).fill(squareHighlightColor); sq.getFace(CuboidDirection.West).fill(squareHighlightColor); sq.getFace(CuboidDirection.South).fill(squareHighlightColor); break; case CORNERS: for (Block b : sq.corners()) { b.setTypeIdAndData( squareHighlightColor.getItemTypeId(), squareHighlightColor.getData(), false); } break; case CHECKERED: case CHEQUERED: for (Block b : sq) { if ((b.getLocation().getBlockX() - b.getLocation().getBlockZ()) % 2 == 0) { b.setTypeIdAndData( squareHighlightColor.getItemTypeId(), squareHighlightColor.getData(), false); } } break; default: break; } if (ChessCraft.getInstance().getDynmapIntegration() != null) { ChessCraft.getInstance().getDynmapIntegration().triggerUpdate(sq); } }
private void highlightBoardSquare(int row, int col, boolean highlight) { if (!highlight) { paintBoardSquare(row, col, null); } else { Cuboid sq = getSquare(row, col); MaterialWithData squareHighlightColor = boardStyle.getHighlightMaterial(col + (row % 2) % 2 == 1); switch (boardStyle.getHighlightStyle()) { case EDGES: sq.getFace(CuboidDirection.East).fill(squareHighlightColor); sq.getFace(CuboidDirection.North).fill(squareHighlightColor); sq.getFace(CuboidDirection.West).fill(squareHighlightColor); sq.getFace(CuboidDirection.South).fill(squareHighlightColor); break; case CORNERS: for (Block b : sq.corners()) { squareHighlightColor.applyToBlock(b); } break; case CHECKERED: case CHEQUERED: for (Block b : sq) { if ((b.getLocation().getBlockX() - b.getLocation().getBlockZ()) % 2 == 0) { squareHighlightColor.applyToBlock(b.getLocation().getBlock()); } } break; } } }