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: Fixed display issues #398

Closed
wants to merge 2 commits into from
Closed
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
63 changes: 59 additions & 4 deletions src/main/java/featurecat/lizzie/Config.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package featurecat.lizzie;

import featurecat.lizzie.theme.Theme;
import java.awt.Color;
import java.io.*;
import java.nio.file.Files;
import java.nio.file.Paths;
Expand All @@ -13,9 +15,12 @@ public class Config {

public boolean showMoveNumber = false;
public boolean showWinrate = true;
public boolean largeWinrate = false;
public boolean showBlunderBar = true;
public boolean weightedBlunderBarHeight = false;
public boolean dynamicWinrateGraphWidth = false;
public boolean showVariationGraph = true;
public boolean showComment = false;
public int commentFontSize = 0;
public boolean showComment = true;
public boolean showRawBoard = false;
public boolean showCaptured = true;
public boolean handicapInsteadOfWinrate = false;
Expand All @@ -37,6 +42,21 @@ public class Config {
private String configFilename = "config.txt";
private String persistFilename = "persist";

public Theme theme;
public float winrateStrokeWidth = 3;
public int minimumBlunderBarWidth = 3;
public int shadowSize = 100;
public String fontName = null;
public String uiFontName = null;
public String winrateFontName = null;
public int commentFontSize = 0;
public Color commentFontColor = null;
public Color commentBackgroundColor = null;
public Color winrateLineColor = null;
public Color winrateMissLineColor = null;
public Color blunderBarColor = null;
public boolean solidStoneIndicator = false;

private JSONObject loadAndMergeConfig(
JSONObject defaultCfg, String fileName, boolean needValidation) throws IOException {
File file = new File(fileName);
Expand Down Expand Up @@ -127,13 +147,18 @@ public Config() throws IOException {
leelazConfig = config.getJSONObject("leelaz");
uiConfig = config.getJSONObject("ui");

theme = new Theme(uiConfig);

showMoveNumber = uiConfig.getBoolean("show-move-number");
showStatus = uiConfig.getBoolean("show-status");
showBranch = uiConfig.getBoolean("show-leelaz-variation");
showWinrate = uiConfig.getBoolean("show-winrate");
largeWinrate = uiConfig.optBoolean("large-winrate", false);
showBlunderBar = uiConfig.optBoolean("show-blunder-bar", true);
weightedBlunderBarHeight = uiConfig.optBoolean("weighted-blunder-bar-height", false);
dynamicWinrateGraphWidth = uiConfig.optBoolean("dynamic-winrate-graph-width", false);
showVariationGraph = uiConfig.getBoolean("show-variation-graph");
showComment = uiConfig.optBoolean("show-comment", false);
commentFontSize = uiConfig.optInt("comment-font-size", 0);
showComment = uiConfig.optBoolean("show-comment", true);
showCaptured = uiConfig.getBoolean("show-captured");
showBestMoves = uiConfig.getBoolean("show-best-moves");
showNextMoves = uiConfig.getBoolean("show-next-moves");
Expand All @@ -142,6 +167,20 @@ public Config() throws IOException {
handicapInsteadOfWinrate = uiConfig.getBoolean("handicap-instead-of-winrate");
startMaximized = uiConfig.getBoolean("window-maximized");
showDynamicKomi = uiConfig.getBoolean("show-dynamic-komi");

winrateStrokeWidth = theme.winrateStrokeWidth();
minimumBlunderBarWidth = theme.minimumBlunderBarWidth();
shadowSize = theme.shadowSize();
fontName = theme.fontName();
uiFontName = theme.uiFontName();
winrateFontName = theme.winrateFontName();
commentFontSize = theme.commentFontSize();
commentFontColor = theme.commentFontColor();
commentBackgroundColor = theme.commentBackgroundColor();
winrateLineColor = theme.winrateLineColor();
winrateMissLineColor = theme.winrateMissLineColor();
blunderBarColor = theme.blunderBarColor();
solidStoneIndicator = theme.solidStoneIndicator();
}

// Modifies config by adding in values from default_config that are missing.
Expand Down Expand Up @@ -181,6 +220,10 @@ public void toggleShowWinrate() {
this.showWinrate = !this.showWinrate;
}

public void toggleLargeWinrate() {
this.largeWinrate = !this.largeWinrate;
}

public void toggleShowVariationGraph() {
this.showVariationGraph = !this.showVariationGraph;
}
Expand Down Expand Up @@ -209,6 +252,10 @@ public boolean showLargeSubBoard() {
return showSubBoard && largeSubBoard;
}

public boolean showLargeWinrate() {
return showWinrate && largeWinrate;
}

/**
* Scans the current directory as well as the current PATH to find a reasonable default leelaz
* binary.
Expand Down Expand Up @@ -265,6 +312,14 @@ private JSONObject createDefaultConfig() {
ui.put("show-status", true);
ui.put("show-leelaz-variation", true);
ui.put("show-winrate", true);
ui.put("large-winrate", false);
ui.put("winrate-stroke-width", 3);
ui.put("show-blunder-bar", true);
ui.put("minimum-blunder-bar-width", 3);
ui.put("weighted-blunder-bar-height", false);
ui.put("dynamic-winrate-graph-width", false);
ui.put("show-comment", true);
ui.put("comment-font-size", 0);
ui.put("show-variation-graph", true);
ui.put("show-captured", true);
ui.put("show-best-moves", true);
Expand Down
Loading