diff --git a/DroidFish/res/values/strings.xml b/DroidFish/res/values/strings.xml index 28572cc..c635540 100644 --- a/DroidFish/res/values/strings.xml +++ b/DroidFish/res/values/strings.xml @@ -205,6 +205,7 @@ you are not actively using the program.\ Stockfish CuckooChess Select Engine + Engine Options Set options Configure Network Engine Create Network Engine @@ -638,6 +639,7 @@ you are not actively using the program.\ @string/toggle_blind_mode @string/load_last_file @string/select_engine + @string/engine_options @@ -652,5 +654,6 @@ you are not actively using the program.\ blindMode loadLastFile selectEngine + engineOptions diff --git a/DroidFish/res/xml/preferences.xml b/DroidFish/res/xml/preferences.xml index f5ad12b..26931b9 100644 --- a/DroidFish/res/xml/preferences.xml +++ b/DroidFish/res/xml/preferences.xml @@ -389,7 +389,7 @@ android:title="@string/prefs_button_action_2_title" android:entryValues="@array/button_action_values" android:entries="@array/button_action_texts" - android:defaultValue=""> + android:defaultValue="engineOptions"> lst = new ArrayList(); List actions = new ArrayList(); lst.add(getString(R.string.select_engine)); actions.add(SELECT_ENGINE); - if (ctrl.computerIdle()) { - UCIOptions uciOpts = ctrl.getUCIOptions(); - if (uciOpts != null) { - boolean visible = false; - for (String name : uciOpts.getOptionNames()) - if (uciOpts.getOption(name).visible) { - visible = true; - break; - } - if (visible) { - lst.add(getString(R.string.set_engine_options)); - actions.add(SET_ENGINE_OPTIONS); - } - } + if (canSetEngineOptions()) { + lst.add(getString(R.string.set_engine_options)); + actions.add(SET_ENGINE_OPTIONS); } lst.add(getString(R.string.configure_network_engine)); actions.add(CONFIG_NET_ENGINE); final List finalActions = actions; @@ -2852,15 +2850,9 @@ public class DroidFish extends Activity implements GUIInterface { removeDialog(SELECT_ENGINE_DIALOG); showDialog(SELECT_ENGINE_DIALOG); break; - case SET_ENGINE_OPTIONS: { - Intent i = new Intent(DroidFish.this, EditOptions.class); - UCIOptions uciOpts = ctrl.getUCIOptions(); - if (uciOpts != null) { - i.putExtra("org.petero.droidfish.ucioptions", uciOpts); - startActivityForResult(i, RESULT_EDITOPTIONS); - } + case SET_ENGINE_OPTIONS: + setEngineOptions(); break; - } case CONFIG_NET_ENGINE: removeDialog(NETWORK_ENGINE_DIALOG); showDialog(NETWORK_ENGINE_DIALOG); @@ -2872,6 +2864,29 @@ public class DroidFish extends Activity implements GUIInterface { return alert; } + /** Return true if engine UCI options can be set now. */ + private final boolean canSetEngineOptions() { + if (!ctrl.computerIdle()) + return false; + UCIOptions uciOpts = ctrl.getUCIOptions(); + if (uciOpts == null) + return false; + for (String name : uciOpts.getOptionNames()) + if (uciOpts.getOption(name).visible) + return true; + return false; + } + + /** Start activity to set engine options. */ + private final void setEngineOptions() { + Intent i = new Intent(DroidFish.this, EditOptions.class); + UCIOptions uciOpts = ctrl.getUCIOptions(); + if (uciOpts != null) { + i.putExtra("org.petero.droidfish.ucioptions", uciOpts); + startActivityForResult(i, RESULT_EDITOPTIONS); + } + } + private final Dialog networkEngineDialog() { String[] fileNames = findFilesInDirectory(engineDir, new FileNameFilter() { @Override