Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
Hiraoka committed Oct 24, 2020
2 parents 65bcdbd + 05f02f2 commit fe85c29
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 17 deletions.
35 changes: 19 additions & 16 deletions src/main/java/featurecat/lizzie/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -322,28 +322,28 @@ public void toggleShowBranch() {
}

public void toggleShowCaptured() {
this.showCaptured = !this.showCaptured;
this.showCaptured = toggleUIConfig("show-captured");
}

public void toggleShowWinrate() {
this.showWinrate = !this.showWinrate;
this.showWinrate = toggleUIConfig("show-winrate");
}

public void toggleLargeWinrate() {
this.largeSubBoard = false;
this.largeWinrate = !this.largeWinrate;
this.largeSubBoard = setUIConfigBoolean("large-subboard", false);
this.largeWinrate = toggleUIConfig("large-winrate");
}

public void toggleShowLcbWinrate() {
this.showLcbWinrate = !this.showLcbWinrate;
}

public void toggleShowVariationGraph() {
this.showVariationGraph = !this.showVariationGraph;
this.showVariationGraph = toggleUIConfig("show-variation-graph");
}

public void toggleShowComment() {
this.showComment = !this.showComment;
this.showComment = toggleUIConfig("show-comment");
}

public void toggleShowCommentNodeColor() {
Expand All @@ -363,8 +363,8 @@ public void toggleHandicapInsteadOfWinrate() {
}

public void toggleLargeSubBoard() {
this.largeWinrate = false;
this.largeSubBoard = !this.largeSubBoard;
this.largeWinrate = setUIConfigBoolean("large-winrate", false);
this.largeSubBoard = toggleUIConfig("large-subboard");
}

public void toggleCoordinates() {
Expand All @@ -376,7 +376,7 @@ public void toggleEvaluationColoring() {
}

public void toggleShowSubBoard() {
showSubBoard = !showSubBoard;
showSubBoard = toggleUIConfig("show-subboard");
}

public void toggleShowPolicy() {
Expand Down Expand Up @@ -424,13 +424,16 @@ public void toggleKataGoEstimateBlend() {
}

public void toggleShowStatus() {
this.showStatus = !this.showStatus;
Lizzie.config.uiConfig.put("show-status", showStatus);
try {
Lizzie.config.save();
} catch (IOException e) {
e.printStackTrace();
}
this.showStatus = toggleUIConfig("show-status");
}

private boolean toggleUIConfig(String key) {
return setUIConfigBoolean(key, !uiConfig.getBoolean(key));
}

private boolean setUIConfigBoolean(String key, boolean value) {
uiConfig.put(key, value);
return value;
}

public boolean showLargeSubBoard() {
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/featurecat/lizzie/Lizzie.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public static void main(String[] args) throws IOException {
config = new Config();
frame = config.panelUI ? new LizzieMain() : new LizzieFrame();
gtpConsole = new GtpConsolePane(frame);
gtpConsole.setVisible(config.leelazConfig.optBoolean("print-comms", false));
gtpConsole.setVisible(config.persistedUi.optBoolean("gtp-console-opened", false));
initializeEngineManager();
}

Expand Down Expand Up @@ -89,6 +89,7 @@ public static void shutdown() {
board.autosaveToMemory();

try {
config.save();
config.persist();
} catch (IOException e) {
e.printStackTrace(); // Failed to save config
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/featurecat/lizzie/util/WindowPosition.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ public static JSONObject create(JSONObject ui) {

ui.put("window-maximized", false);
ui.put("toolbar-position", "South");
ui.put("gtp-console-opened", false);

return ui;
}
Expand All @@ -52,6 +53,7 @@ public static JSONObject save(JSONObject ui) {
ui.put("window-maximized", windowIsMaximized);
ui.put("toolbar-position", Lizzie.config.toolbarPosition);
ui.put("board-position-proportion", Lizzie.frame.boardPositionProportion);
ui.put("gtp-console-opened", Lizzie.gtpConsole.isVisible());

JSONArray mainPos = new JSONArray();
if (!windowIsMaximized) {
Expand Down

0 comments on commit fe85c29

Please sign in to comment.