From bce35fc9509c8c43431ef1ad9cfe688e978ba8b6 Mon Sep 17 00:00:00 2001 From: CyB3RC0nN0R Date: Sat, 20 Jul 2019 06:48:42 +0200 Subject: [PATCH] Fixed UCI combo GUI type to support multiple predefined values --- src/dev/kske/chess/game/UCIPlayerListener.java | 3 ++- src/dev/kske/chess/uci/UCIListener.java | 3 ++- src/dev/kske/chess/uci/UCIReceiver.java | 16 +++++++++------- 3 files changed, 13 insertions(+), 9 deletions(-) diff --git a/src/dev/kske/chess/game/UCIPlayerListener.java b/src/dev/kske/chess/game/UCIPlayerListener.java index 6dcfae0..7d17457 100644 --- a/src/dev/kske/chess/game/UCIPlayerListener.java +++ b/src/dev/kske/chess/game/UCIPlayerListener.java @@ -1,5 +1,6 @@ package dev.kske.chess.game; +import java.util.List; import java.util.Map; import dev.kske.chess.uci.UCIListener; @@ -86,7 +87,7 @@ class UCIPlayerListener implements UCIListener { } @Override - public void onOption(String name, GUIType type, String defaultVal, String minVal, String maxVal, String var) { + public void onOption(String name, GUIType type, String defaultVal, String minVal, String maxVal, List var) { // TODO Auto-generated method stub } diff --git a/src/dev/kske/chess/uci/UCIListener.java b/src/dev/kske/chess/uci/UCIListener.java index c7cd17d..60e0361 100644 --- a/src/dev/kske/chess/uci/UCIListener.java +++ b/src/dev/kske/chess/uci/UCIListener.java @@ -1,5 +1,6 @@ package dev.kske.chess.uci; +import java.util.List; import java.util.Map; /** @@ -96,7 +97,7 @@ public interface UCIListener { * @param maxVal The maximum value of this parameter * @param var A predefined value of this parameter */ - void onOption(String name, GUIType type, String defaultVal, String minVal, String maxVal, String var); + void onOption(String name, GUIType type, String defaultVal, String minVal, String maxVal, List var); public static enum GUIType { CHECK, SPIN, COMBO, BUTTON, STRING diff --git a/src/dev/kske/chess/uci/UCIReceiver.java b/src/dev/kske/chess/uci/UCIReceiver.java index c9c013b..138d329 100644 --- a/src/dev/kske/chess/uci/UCIReceiver.java +++ b/src/dev/kske/chess/uci/UCIReceiver.java @@ -4,8 +4,10 @@ import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; +import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; +import java.util.List; import java.util.Map; import dev.kske.chess.uci.UCIListener.GUIType; @@ -151,12 +153,12 @@ public class UCIReceiver implements Runnable { private void parseOption(String line) { String[] tokens = line.split(" "); - String name = ""; - GUIType type = null; - String defaultVal = null; - String minVal = null; - String maxVal = null; - String var = null; + String name = ""; + GUIType type = null; + String defaultVal = null; + String minVal = null; + String maxVal = null; + List var = new ArrayList<>(); for (int i = 0; i < tokens.length; i++) switch (tokens[i]) { @@ -176,7 +178,7 @@ public class UCIReceiver implements Runnable { maxVal = tokens[++i]; break; case "var": - var = tokens[++i]; + var.add(tokens[++i]); break; default: System.err.printf("Unknown parameter '%s' for command 'option' found!%n", tokens[i]);