Skip to content

Commit

Permalink
Merge pull request #287 from Ka-zam/next
Browse files Browse the repository at this point in the history
Enhancement: Window size and maximization
  • Loading branch information
featurecat authored Jun 11, 2018
2 parents c44af77 + fffefb5 commit 795b073
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
2 changes: 2 additions & 0 deletions lizzie.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
java -jar -Dsun.java2d.opengl=true ./target/lizzie-0.5-shaded.jar 2>/dev/null &

7 changes: 5 additions & 2 deletions src/main/java/featurecat/lizzie/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ public class Config {
public boolean showNextMoves = true;
public boolean showSubBoard = true;
public boolean largeSubBoard = false;

public boolean startMaximized = true;

public JSONObject config;
public JSONObject leelazConfig;
public JSONObject uiConfig;
Expand Down Expand Up @@ -141,6 +142,7 @@ public Config() throws IOException {
showSubBoard = uiConfig.getBoolean("show-subboard");
largeSubBoard = uiConfig.getBoolean("large-subboard");
handicapInsteadOfWinrate = uiConfig.getBoolean("handicap-instead-of-winrate");
startMaximized = uiConfig.getBoolean("window-maximized");
}

// Modifies config by adding in values from default_config that are missing.
Expand Down Expand Up @@ -196,7 +198,6 @@ public boolean showLargeSubBoard() {
return showSubBoard && largeSubBoard;
}


/**
* Scans the current directory as well as the current PATH to find a reasonable default leelaz binary.
*
Expand Down Expand Up @@ -259,6 +260,8 @@ private JSONObject createDefaultConfig() {
ui.put("confirm-exit", false);
ui.put("handicap-instead-of-winrate",false);
ui.put("board-size", 19);
ui.put("window-size", new JSONArray("[1024, 768]"));
ui.put("window-maximized", false);

config.put("ui", ui);
return config;
Expand Down
10 changes: 7 additions & 3 deletions src/main/java/featurecat/lizzie/gui/LizzieFrame.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import featurecat.lizzie.rules.GIBParser;
import featurecat.lizzie.rules.SGFParser;
import org.json.JSONObject;
import org.json.JSONArray;

import javax.swing.*;
import javax.swing.filechooser.FileNameExtensionFilter;
Expand Down Expand Up @@ -112,11 +113,14 @@ public LizzieFrame() {
variationTree = new VariationTree();
winrateGraph = new WinrateGraph();

// on 1080p screens in Windows, this is a good width/height. removing a default size causes problems in Linux
setSize(657, 687);
setMinimumSize( new Dimension(640,480) );
setLocationRelativeTo(null); // start centered
setExtendedState(Frame.MAXIMIZED_BOTH); // start maximized
JSONArray windowSize = Lizzie.config.uiConfig.getJSONArray("window-size");
setSize(windowSize.getInt(0), windowSize.getInt(1)); // use config file window size

if (Lizzie.config.startMaximized) {
setExtendedState(Frame.MAXIMIZED_BOTH); // start maximized
}

setVisible(true);

Expand Down

0 comments on commit 795b073

Please sign in to comment.