Skip to content

Commit

Permalink
Adjust setTitle & get weight name
Browse files Browse the repository at this point in the history
  • Loading branch information
zsalch authored and zsalch committed Oct 3, 2018
1 parent b7ae8dc commit b472225
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 24 deletions.
26 changes: 11 additions & 15 deletions src/main/java/featurecat/lizzie/analysis/Leelaz.java
Original file line number Diff line number Diff line change
Expand Up @@ -130,20 +130,16 @@ public void startEngine(String engineCommand) throws IOException {
commands = Arrays.asList(engineCommand.split(" "));

// get weight name
if (commands != null) {
int weightIndex = commands.indexOf("--weights");
if (weightIndex > -1) {
currentWeight = commands.get(weightIndex+1);
} else {
weightIndex = commands.indexOf("-w");
if (weightIndex > -1) {
currentWeight = commands.get(weightIndex+1);
}
}
if (currentWeight != null) {
String[] names = currentWeight.split("[\\\\|/]");
if (names != null && names.length > 1) {
currentWeight = names[names.length - 1];
if (engineCommand != null) {
Pattern wPattern = Pattern.compile("(?s).*?(--weights |-w )([^ ]+)(?s).*");
Matcher wMatcher = wPattern.matcher(engineCommand);
if (wMatcher.matches()) {
currentWeight = wMatcher.group(2);
if (currentWeight != null) {
String[] names = currentWeight.split("[\\\\|/]");
if (names != null && names.length > 1) {
currentWeight = names[names.length - 1];
}
}
}
}
Expand Down Expand Up @@ -286,7 +282,7 @@ else if (line.equals("\n")) {
// Clear switching prompt
switching = false;
// Display engine command in the title
if (Lizzie.frame != null) Lizzie.frame.setEngineTitle(this.engineCommand);
if (Lizzie.frame != null) Lizzie.frame.updateTitle();
if (isResponseUpToDate()) {
// This should not be stale data when the command number match
parseInfo(line.substring(5));
Expand Down
18 changes: 9 additions & 9 deletions src/main/java/featurecat/lizzie/gui/LizzieFrame.java
Original file line number Diff line number Diff line change
Expand Up @@ -894,15 +894,15 @@ public void toggleCoordinates() {
}

public void setPlayers(String whitePlayer, String blackPlayer) {
// Display engine command in title
this.playerTitle = String.format("%s (%s [W] vs %s [B])", DEFAULT_TITLE,
whitePlayer, blackPlayer);
setTitle(this.playerTitle + (Lizzie.leelaz.engineCommand() != null ? " - " + Lizzie.leelaz.engineCommand() : ""));
this.playerTitle = String.format("(%s [W] vs %s [B])", whitePlayer, blackPlayer);
this.updateTitle();
}

public void setEngineTitle(String engineCommand) {
// Display engine command in title
setTitle((this.playerTitle != null ? this.playerTitle + " - " : "") + engineCommand);
public void updateTitle() {
StringBuilder sb = new StringBuilder(DEFAULT_TITLE);
sb.append(this.playerTitle != null ? " " + this.playerTitle.trim() : "");
sb.append(Lizzie.leelaz.engineCommand() != null ? " [" + Lizzie.leelaz.engineCommand() + "]" : "");
setTitle(sb.toString());
}

private void setDisplayedBranchLength(int n) {
Expand All @@ -924,8 +924,8 @@ public boolean incrementDisplayedBranchLength(int n) {
}

public void resetTitle() {
// Display engine command in title
setTitle(DEFAULT_TITLE + (Lizzie.leelaz.engineCommand() != null ? " - " + Lizzie.leelaz.engineCommand() : ""));
this.playerTitle = null;
this.updateTitle();
}

public void copySgf() {
Expand Down

0 comments on commit b472225

Please sign in to comment.