diff --git a/src/main/java/featurecat/lizzie/Config.java b/src/main/java/featurecat/lizzie/Config.java index bd3abf7d4..52ef54957 100644 --- a/src/main/java/featurecat/lizzie/Config.java +++ b/src/main/java/featurecat/lizzie/Config.java @@ -15,6 +15,7 @@ public class Config { + public boolean showBorder = false; public boolean showMoveNumber = false; public int onlyLastMoveNumber = 0; // 0: Do not show; -1: Show all move number; other: Show last move number @@ -71,7 +72,7 @@ public class Config { public boolean appendWinrateToComment = false; private JSONObject loadAndMergeConfig( - JSONObject defaultCfg, String fileName, boolean needValidation) throws IOException { + JSONObject defaultCfg, String fileName, boolean needValidation) throws IOException { File file = new File(fileName); if (!file.canRead()) { System.err.printf("Creating config file %s\n", fileName); @@ -129,7 +130,7 @@ private boolean validateAndCorrectSettings(JSONObject config) { // Checks for startup directory. It should exist and should be a directory. String engineStartLocation = getBestDefaultLeelazPath(); if (!(Files.exists(Paths.get(engineStartLocation)) - && Files.isDirectory(Paths.get(engineStartLocation)))) { + && Files.isDirectory(Paths.get(engineStartLocation)))) { leelaz.put("engine-start-location", "."); madeCorrections = true; } @@ -151,6 +152,7 @@ public Config() throws IOException { theme = new Theme(uiConfig); + showBorder = uiConfig.optBoolean("show-border", false); showMoveNumber = uiConfig.getBoolean("show-move-number"); onlyLastMoveNumber = uiConfig.optInt("only-last-move-number"); allowMoveNumber = showMoveNumber ? (onlyLastMoveNumber > 0 ? onlyLastMoveNumber : -1) : 0; @@ -223,7 +225,7 @@ public boolean mergeDefaults(JSONObject config, JSONObject defaultsConfig) { public void toggleShowMoveNumber() { if (this.onlyLastMoveNumber > 0) { allowMoveNumber = - (allowMoveNumber == -1 ? onlyLastMoveNumber : (allowMoveNumber == 0 ? -1 : 0)); + (allowMoveNumber == -1 ? onlyLastMoveNumber : (allowMoveNumber == 0 ? -1 : 0)); } else { allowMoveNumber = (allowMoveNumber == 0 ? -1 : 0); } @@ -316,10 +318,10 @@ private JSONObject createDefaultConfig() { JSONObject leelaz = new JSONObject(); leelaz.put("network-file", "network.gz"); leelaz.put( - "engine-command", - String.format( - "%s --gtp --lagbuffer 0 --weights %%network-file", - getBestDefaultLeelazPath())); + "engine-command", + String.format( + "%s --gtp --lagbuffer 0 --weights %%network-file", + getBestDefaultLeelazPath())); leelaz.put("engine-start-location", "."); leelaz.put("max-analyze-time-minutes", 5); leelaz.put("max-game-thinking-time-seconds", 2); @@ -364,6 +366,7 @@ private JSONObject createDefaultConfig() { ui.put("window-maximized", false); ui.put("show-dynamic-komi", true); ui.put("min-playout-ratio-for-stats", 0.0); + ui.put("theme", "default"); config.put("ui", ui); return config; } diff --git a/src/main/java/featurecat/lizzie/gui/BoardRenderer.java b/src/main/java/featurecat/lizzie/gui/BoardRenderer.java index aae0e3087..40afacea3 100644 --- a/src/main/java/featurecat/lizzie/gui/BoardRenderer.java +++ b/src/main/java/featurecat/lizzie/gui/BoardRenderer.java @@ -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; @@ -696,7 +697,6 @@ private void drawWoodenBoard(Graphics2D g) { cachedBoardImage = Lizzie.config.theme.board(); } - int shadowRadius = (int) (boardLength * MARGIN / 6); drawTextureImage( g, cachedBoardImage, @@ -705,15 +705,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 { @@ -1107,7 +1108,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; } /** diff --git a/src/main/java/featurecat/lizzie/gui/LizzieFrame.java b/src/main/java/featurecat/lizzie/gui/LizzieFrame.java index c99075fe0..30c423bda 100644 --- a/src/main/java/featurecat/lizzie/gui/LizzieFrame.java +++ b/src/main/java/featurecat/lizzie/gui/LizzieFrame.java @@ -876,7 +876,8 @@ void drawControls() { Graphics2D g = cachedImage.createGraphics(); int maxSize = min(getWidth(), getHeight()); - Font font = new Font(Lizzie.config.fontName, Font.PLAIN, (int) (maxSize * 0.03)); + int fontSize = (int) (maxSize * min(0.034, 0.86 / commandsToShow.size())); + Font font = new Font(Lizzie.config.fontName, Font.PLAIN, fontSize); g.setFont(font); FontMetrics metrics = g.getFontMetrics(font); @@ -887,7 +888,8 @@ void drawControls() { int boxHeight = min(commandsToShow.size() * lineHeight, getHeight()); int commandsX = min(getWidth() / 2 - boxWidth / 2, getWidth()); - int commandsY = min(getHeight() / 2 - boxHeight / 2, getHeight()); + int top = this.getInsets().top; + int commandsY = top + min((getHeight() - top) / 2 - boxHeight / 2, getHeight() - top); BufferedImage result = new BufferedImage(boxWidth, boxHeight, TYPE_INT_ARGB); filter10.filter( @@ -896,15 +898,16 @@ void drawControls() { g.setColor(new Color(0, 0, 0, 130)); g.fillRect(commandsX, commandsY, boxWidth, boxHeight); - int strokeRadius = 2; - g.setStroke(new BasicStroke(2 * strokeRadius)); - g.setColor(new Color(0, 0, 0, 60)); - g.drawRect( - commandsX + strokeRadius, - commandsY + strokeRadius, - boxWidth - 2 * strokeRadius, - boxHeight - 2 * strokeRadius); - + int strokeRadius = Lizzie.config.showBorder ? 2 : 1; + g.setStroke(new BasicStroke(strokeRadius == 1 ? strokeRadius : 2 * strokeRadius)); + if (Lizzie.config.showBorder) { + g.setColor(new Color(0, 0, 0, 60)); + g.drawRect( + commandsX + strokeRadius, + commandsY + strokeRadius, + boxWidth - 2 * strokeRadius, + boxHeight - 2 * strokeRadius); + } int verticalLineX = (int) (commandsX + boxWidth * 0.3); g.setColor(new Color(0, 0, 0, 60)); g.drawLine( @@ -941,7 +944,7 @@ 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; @@ -949,13 +952,15 @@ private void drawCommandString(Graphics2D g) { 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); @@ -1000,17 +1005,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; @@ -1093,20 +1100,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( diff --git a/src/main/java/featurecat/lizzie/gui/VariationTree.java b/src/main/java/featurecat/lizzie/gui/VariationTree.java index 4f67f5783..cadb624b6 100644 --- a/src/main/java/featurecat/lizzie/gui/VariationTree.java +++ b/src/main/java/featurecat/lizzie/gui/VariationTree.java @@ -200,19 +200,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; diff --git a/src/main/java/featurecat/lizzie/gui/WinrateGraph.java b/src/main/java/featurecat/lizzie/gui/WinrateGraph.java index a2804626c..5ec7bb4bf 100644 --- a/src/main/java/featurecat/lizzie/gui/WinrateGraph.java +++ b/src/main/java/featurecat/lizzie/gui/WinrateGraph.java @@ -38,14 +38,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); diff --git a/theme/yasnaya/background2.png b/theme/yasnaya/background2.png new file mode 100644 index 000000000..b28dd3d45 Binary files /dev/null and b/theme/yasnaya/background2.png differ diff --git a/theme/yasnaya/black1.png b/theme/yasnaya/black1.png new file mode 100644 index 000000000..ca3c50963 Binary files /dev/null and b/theme/yasnaya/black1.png differ diff --git a/theme/yasnaya/board7.jpg b/theme/yasnaya/board7.jpg new file mode 100644 index 000000000..653ec8101 Binary files /dev/null and b/theme/yasnaya/board7.jpg differ diff --git a/theme/yasnaya/theme.txt b/theme/yasnaya/theme.txt new file mode 100644 index 000000000..3e73b3f35 --- /dev/null +++ b/theme/yasnaya/theme.txt @@ -0,0 +1,18 @@ +{ + "background-image" : "background2.png", + "board-image" : "board7.jpg", + "black-stone-image" : "black1.png", + "white-stone-image" : "white1.png", + "shadow-size": 55, + "solid-stone-indicator": true, + "winrate-stroke-width": 2, + "minimum-blunder-bar-width": 3, + "comment-background-color": [0, 0, 0, 200], + "comment-font-color": [255, 255, 255, 200], + "comment-node-color": [0, 0, 255, 200], + "winrate-line-color": [0, 255, 0, 200], + "winrate-miss-line-color": [0, 0, 255, 200], + "blunder-bar-color": [255, 0, 0, 200], + "blunder-winrate-thresholds":[-30,-20,-10,-5,5,10], + "blunder-node-colors":[[255,0,0,200],[0,255,0,200],[0,0,255],[255,255,0],[0,255,255],[255,0,255]] +} \ No newline at end of file diff --git a/theme/yasnaya/white1.png b/theme/yasnaya/white1.png new file mode 100644 index 000000000..e85338e96 Binary files /dev/null and b/theme/yasnaya/white1.png differ