Fixed UCI combo GUI type to support multiple predefined values
This commit is contained in:
parent
12422d3d31
commit
bd91e3125d
@ -1,5 +1,6 @@
|
|||||||
package dev.kske.chess.game;
|
package dev.kske.chess.game;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import dev.kske.chess.uci.UCIListener;
|
import dev.kske.chess.uci.UCIListener;
|
||||||
@ -86,7 +87,7 @@ class UCIPlayerListener implements UCIListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@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<String> var) {
|
||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package dev.kske.chess.uci;
|
package dev.kske.chess.uci;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -96,7 +97,7 @@ public interface UCIListener {
|
|||||||
* @param maxVal The maximum value of this parameter
|
* @param maxVal The maximum value of this parameter
|
||||||
* @param var A predefined 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<String> var);
|
||||||
|
|
||||||
public static enum GUIType {
|
public static enum GUIType {
|
||||||
CHECK, SPIN, COMBO, BUTTON, STRING
|
CHECK, SPIN, COMBO, BUTTON, STRING
|
||||||
|
@ -4,8 +4,10 @@ import java.io.BufferedReader;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.io.InputStreamReader;
|
import java.io.InputStreamReader;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import dev.kske.chess.uci.UCIListener.GUIType;
|
import dev.kske.chess.uci.UCIListener.GUIType;
|
||||||
@ -151,12 +153,12 @@ public class UCIReceiver implements Runnable {
|
|||||||
private void parseOption(String line) {
|
private void parseOption(String line) {
|
||||||
String[] tokens = line.split(" ");
|
String[] tokens = line.split(" ");
|
||||||
|
|
||||||
String name = "";
|
String name = "";
|
||||||
GUIType type = null;
|
GUIType type = null;
|
||||||
String defaultVal = null;
|
String defaultVal = null;
|
||||||
String minVal = null;
|
String minVal = null;
|
||||||
String maxVal = null;
|
String maxVal = null;
|
||||||
String var = null;
|
List<String> var = new ArrayList<>();
|
||||||
|
|
||||||
for (int i = 0; i < tokens.length; i++)
|
for (int i = 0; i < tokens.length; i++)
|
||||||
switch (tokens[i]) {
|
switch (tokens[i]) {
|
||||||
@ -176,7 +178,7 @@ public class UCIReceiver implements Runnable {
|
|||||||
maxVal = tokens[++i];
|
maxVal = tokens[++i];
|
||||||
break;
|
break;
|
||||||
case "var":
|
case "var":
|
||||||
var = tokens[++i];
|
var.add(tokens[++i]);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
System.err.printf("Unknown parameter '%s' for command 'option' found!%n", tokens[i]);
|
System.err.printf("Unknown parameter '%s' for command 'option' found!%n", tokens[i]);
|
||||||
|
Reference in New Issue
Block a user