Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

next: New theme yasnaya by ParmuzinAlexander #420

Merged
merged 4 commits into from
Nov 8, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 10 additions & 7 deletions src/main/java/featurecat/lizzie/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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;
}
Expand All @@ -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;
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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;
}
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 @@ -696,7 +697,6 @@ private void drawWoodenBoard(Graphics2D g) {
cachedBoardImage = Lizzie.config.theme.board();
}

int shadowRadius = (int) (boardLength * MARGIN / 6);
drawTextureImage(
g,
cachedBoardImage,
Expand All @@ -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 {
Expand Down Expand Up @@ -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;
}

/**
Expand Down
94 changes: 53 additions & 41 deletions src/main/java/featurecat/lizzie/gui/LizzieFrame.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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(
Expand All @@ -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(
Expand Down Expand Up @@ -941,21 +944,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 @@ -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;
Expand Down Expand Up @@ -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(
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 @@ -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;
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 @@ -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);

Expand Down
Binary file added theme/yasnaya/background2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added theme/yasnaya/black1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added theme/yasnaya/board7.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
18 changes: 18 additions & 0 deletions theme/yasnaya/theme.txt
Original file line number Diff line number Diff line change
@@ -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]]
}
Binary file added theme/yasnaya/white1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.