Skip to content

Commit

Permalink
Allow user turn on/off border, default is off
Browse files Browse the repository at this point in the history
  • Loading branch information
zsalch committed Nov 4, 2018
1 parent bfa2720 commit b0055ec
Show file tree
Hide file tree
Showing 5 changed files with 80 additions and 57 deletions.
2 changes: 2 additions & 0 deletions src/main/java/featurecat/lizzie/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

public class Config {

public boolean showBorder = false;
public boolean showMoveNumber = false;
public boolean showWinrate = true;
public boolean largeWinrate = false;
Expand Down Expand Up @@ -138,6 +139,7 @@ public Config() throws IOException {

theme = new Theme(uiConfig);

showBorder = uiConfig.optBoolean("show-border", false);
showMoveNumber = uiConfig.getBoolean("show-move-number");
showStatus = uiConfig.getBoolean("show-status");
showBranch = uiConfig.getBoolean("show-leelaz-variation");
Expand Down
26 changes: 15 additions & 11 deletions src/main/java/featurecat/lizzie/gui/BoardRenderer.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ public class BoardRenderer {

private int x, y;
private int boardLength;
private int shadowRadius;

private JSONObject uiConfig, uiPersist;
private int scaledMargin, availableLength, squareLength, stoneRadius;
Expand Down Expand Up @@ -690,7 +691,6 @@ private void drawWoodenBoard(Graphics2D g) {
cachedBoardImage = Lizzie.config.theme.board();
}

int shadowRadius = (int) (boardLength * MARGIN / 6);
drawTextureImage(
g,
cachedBoardImage,
Expand All @@ -699,15 +699,16 @@ private void drawWoodenBoard(Graphics2D g) {
boardLength + 4 * shadowRadius,
boardLength + 4 * shadowRadius);

g.setStroke(new BasicStroke(shadowRadius * 2));

// draw border
g.setColor(new Color(0, 0, 0, 50));
g.drawRect(
x - shadowRadius,
y - shadowRadius,
boardLength + 2 * shadowRadius,
boardLength + 2 * shadowRadius);
if (Lizzie.config.showBorder) {
g.setStroke(new BasicStroke(shadowRadius * 2));
// draw border
g.setColor(new Color(0, 0, 0, 50));
g.drawRect(
x - shadowRadius,
y - shadowRadius,
boardLength + 2 * shadowRadius,
boardLength + 2 * shadowRadius);
}
g.setStroke(new BasicStroke(1));

} else {
Expand Down Expand Up @@ -1119,7 +1120,10 @@ public Point getLocation() {
* @param boardLength the boardLength of the board
*/
public void setBoardLength(int boardLength) {
this.boardLength = boardLength;
this.shadowRadius = Lizzie.config.showBorder ? (int) (boardLength * MARGIN / 6) : 0;
this.boardLength = boardLength - 4 * shadowRadius;
this.x = x + 2 * shadowRadius;
this.y = y + 2 * shadowRadius;
}

/**
Expand Down
69 changes: 39 additions & 30 deletions src/main/java/featurecat/lizzie/gui/LizzieFrame.java
Original file line number Diff line number Diff line change
Expand Up @@ -722,21 +722,23 @@ private void drawCommandString(Graphics2D g) {

Font font = new Font(Lizzie.config.fontName, Font.PLAIN, (int) (maxSize * 0.03));
String commandString = resourceBundle.getString("LizzieFrame.prompt.showControlsHint");
int strokeRadius = 2;
int strokeRadius = Lizzie.config.showBorder ? 2 : 0;

int showCommandsHeight = (int) (font.getSize() * 1.1);
int showCommandsWidth = g.getFontMetrics(font).stringWidth(commandString) + 4 * strokeRadius;
int showCommandsX = this.getInsets().left;
int showCommandsY = getHeight() - showCommandsHeight - this.getInsets().bottom;
g.setColor(new Color(0, 0, 0, 130));
g.fillRect(showCommandsX, showCommandsY, showCommandsWidth, showCommandsHeight);
g.setStroke(new BasicStroke(2 * strokeRadius));
g.setColor(new Color(0, 0, 0, 60));
g.drawRect(
showCommandsX + strokeRadius,
showCommandsY + strokeRadius,
showCommandsWidth - 2 * strokeRadius,
showCommandsHeight - 2 * strokeRadius);
if (Lizzie.config.showBorder) {
g.setStroke(new BasicStroke(2 * strokeRadius));
g.setColor(new Color(0, 0, 0, 60));
g.drawRect(
showCommandsX + strokeRadius,
showCommandsY + strokeRadius,
showCommandsWidth - 2 * strokeRadius,
showCommandsHeight - 2 * strokeRadius);
}
g.setStroke(new BasicStroke(1));

g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
Expand Down Expand Up @@ -781,17 +783,19 @@ private void drawMoveStatistics(Graphics2D g, int posX, int posY, int width, int
g.fillRect(posX, posY, width, height);

// border. does not include bottom edge
int strokeRadius = 3;
g.setStroke(new BasicStroke(2 * strokeRadius));
int strokeRadius = Lizzie.config.showBorder ? 3 : 1;
g.setStroke(new BasicStroke(strokeRadius == 1 ? strokeRadius : 2 * strokeRadius));
g.drawLine(
posX + strokeRadius, posY + strokeRadius,
posX - strokeRadius + width, posY + strokeRadius);
g.drawLine(
posX + strokeRadius, posY + 3 * strokeRadius,
posX + strokeRadius, posY - strokeRadius + height);
g.drawLine(
posX - strokeRadius + width, posY + 3 * strokeRadius,
posX - strokeRadius + width, posY - strokeRadius + height);
if (Lizzie.config.showBorder) {
g.drawLine(
posX + strokeRadius, posY + 3 * strokeRadius,
posX + strokeRadius, posY - strokeRadius + height);
g.drawLine(
posX - strokeRadius + width, posY + 3 * strokeRadius,
posX - strokeRadius + width, posY - strokeRadius + height);
}

// resize the box now so it's inside the border
posX += 2 * strokeRadius;
Expand Down Expand Up @@ -874,20 +878,25 @@ private void drawCaptured(Graphics2D g, int posX, int posY, int width, int heigh
g.fillRect(posX, posY, width, height);

// border. does not include bottom edge
int strokeRadius = 3;
g.setStroke(new BasicStroke(2 * strokeRadius));
g.drawLine(
posX + strokeRadius, posY + strokeRadius, posX - strokeRadius + width, posY + strokeRadius);
g.drawLine(
posX + strokeRadius,
posY + 3 * strokeRadius,
posX + strokeRadius,
posY - strokeRadius + height);
g.drawLine(
posX - strokeRadius + width,
posY + 3 * strokeRadius,
posX - strokeRadius + width,
posY - strokeRadius + height);
int strokeRadius = Lizzie.config.showBorder ? 3 : 1;
g.setStroke(new BasicStroke(strokeRadius == 1 ? strokeRadius : 2 * strokeRadius));
if (Lizzie.config.showBorder) {
g.drawLine(
posX + strokeRadius,
posY + strokeRadius,
posX - strokeRadius + width,
posY + strokeRadius);
g.drawLine(
posX + strokeRadius,
posY + 3 * strokeRadius,
posX + strokeRadius,
posY - strokeRadius + height);
g.drawLine(
posX - strokeRadius + width,
posY + 3 * strokeRadius,
posX - strokeRadius + width,
posY - strokeRadius + height);
}

// Draw middle line
g.drawLine(
Expand Down
20 changes: 11 additions & 9 deletions src/main/java/featurecat/lizzie/gui/VariationTree.java
Original file line number Diff line number Diff line change
Expand Up @@ -137,19 +137,21 @@ public void draw(Graphics2D g, int posx, int posy, int width, int height) {
YSPACING = (Lizzie.config.showLargeSubBoard() ? 20 : 30);
XSPACING = YSPACING;

int strokeRadius = Lizzie.config.showBorder ? 2 : 0;
// Draw background
g.setColor(new Color(0, 0, 0, 60));
g.fillRect(posx, posy, width, height);

// draw edge of panel
int strokeRadius = 2;
g.setStroke(new BasicStroke(2 * strokeRadius));
g.drawLine(
posx + strokeRadius,
posy + strokeRadius,
posx + strokeRadius,
posy - strokeRadius + height);
g.setStroke(new BasicStroke(1));
if (Lizzie.config.showBorder) {
// draw edge of panel
g.setStroke(new BasicStroke(2 * strokeRadius));
g.drawLine(
posx + strokeRadius,
posy + strokeRadius,
posx + strokeRadius,
posy - strokeRadius + height);
g.setStroke(new BasicStroke(1));
}

int middleY = posy + height / 2;
int xoffset = 30;
Expand Down
20 changes: 13 additions & 7 deletions src/main/java/featurecat/lizzie/gui/WinrateGraph.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,20 @@ public void draw(Graphics2D g, int posx, int posy, int width, int height) {
g.fillRect(posx, posy, width, height);

// draw border
int strokeRadius = 3;
g.setStroke(new BasicStroke(2 * strokeRadius));
int strokeRadius = Lizzie.config.showBorder ? 3 : 1;
g.setStroke(new BasicStroke(strokeRadius == 1 ? strokeRadius : 2 * strokeRadius));
g.setPaint(borderGradient);
g.drawRect(
posx + strokeRadius,
posy + strokeRadius,
width - 2 * strokeRadius,
height - 2 * strokeRadius);
if (Lizzie.config.showBorder) {
g.drawRect(
posx + strokeRadius,
posy + strokeRadius,
width - 2 * strokeRadius,
height - 2 * strokeRadius);
} else {
g.drawLine(
posx + strokeRadius, posy + strokeRadius,
posx - strokeRadius + width, posy + strokeRadius);
}

g.setPaint(original);

Expand Down

0 comments on commit b0055ec

Please sign in to comment.