DroidFish: Clarified that not all engine options work for all engines. Display the current engine in the program title bar.

This commit is contained in:
Peter Osterlund
2012-01-07 08:19:14 +00:00
parent 441b6bc59a
commit 42a71b0ec5
4 changed files with 35 additions and 7 deletions

View File

@@ -443,10 +443,11 @@ you are not actively using the program.\
<string name="prefs_autoSwapSides_summary">Automatically swap sides when new game started. Also overrides Flip Board setting</string> <string name="prefs_autoSwapSides_summary">Automatically swap sides when new game started. Also overrides Flip Board setting</string>
<string name="prefs_engine_settings">Engine Settings</string> <string name="prefs_engine_settings">Engine Settings</string>
<string name="prefs_strength_title">Strength</string> <string name="prefs_strength_title">Strength</string>
<string name="prefs_strength_summary">Only supported by internal engines</string>
<string name="prefs_ponderMode_title">Pondering</string> <string name="prefs_ponderMode_title">Pondering</string>
<string name="prefs_ponderMode_summary">Let engine think while waiting for opponent\'s move</string> <string name="prefs_ponderMode_summary">Let engine think while waiting for opponent\'s move. Supported by most engines.</string>
<string name="prefs_threads_title">Threads</string> <string name="prefs_threads_title">Threads</string>
<string name="prefs_threads_summary">Number of engine threads (CPU cores) to use</string> <string name="prefs_threads_summary">Number of engine threads (CPU cores) to use. Not supported by all engines.</string>
<string name="prefs_time_control">Time Control</string> <string name="prefs_time_control">Time Control</string>
<string name="prefs_movesPerSession_title">Moves</string> <string name="prefs_movesPerSession_title">Moves</string>
<string name="prefs_movesPerSession_summary">Number of moves between time controls</string> <string name="prefs_movesPerSession_summary">Number of moves between time controls</string>

View File

@@ -20,8 +20,9 @@
android:title="@string/prefs_engine_settings"> android:title="@string/prefs_engine_settings">
<org.petero.droidfish.SeekBarPreference <org.petero.droidfish.SeekBarPreference
android:key="strength" android:key="strength"
android:defaultValue="1000" android:title="@string/prefs_strength_title"
android:title="@string/prefs_strength_title"> android:summary="@string/prefs_strength_summary"
android:defaultValue="1000">
</org.petero.droidfish.SeekBarPreference> </org.petero.droidfish.SeekBarPreference>
<CheckBoxPreference <CheckBoxPreference
android:key="ponderMode" android:key="ponderMode"

View File

@@ -643,10 +643,19 @@ public class DroidFish extends Activity implements GUIInterface {
private final void setEngineStrength(String engine, int strength) { private final void setEngineStrength(String engine, int strength) {
ctrl.setEngineStrength(engine, strength); ctrl.setEngineStrength(engine, strength);
if (strength < 1000) { if (engine.contains("/")) {
titleText.setText(String.format("%s: %d%%", getString(R.string.app_name), strength / 10)); int idx = engine.lastIndexOf('/');
String eName = engine.substring(idx + 1);
titleText.setText(eName);
} else { } else {
titleText.setText(getString(R.string.app_name)); String eName = getString((engine == "cuckoochess") ?
R.string.cuckoochess_engine :
R.string.stockfish_engine);
if (strength < 1000) {
titleText.setText(String.format("%s:%d%%", eName, strength / 10));
} else {
titleText.setText(eName);
}
} }
} }

View File

@@ -94,11 +94,28 @@ public class SeekBarPreference extends Preference
lp.gravity = Gravity.RIGHT; lp.gravity = Gravity.RIGHT;
bar.setLayoutParams(lp); bar.setLayoutParams(lp);
CharSequence summaryCharSeq = getSummary();
boolean haveSummary = (summaryCharSeq != null) && (summaryCharSeq.length() > 0);
TextView summary = null;
if (haveSummary) {
summary = new TextView(getContext());
summary.setText(getSummary());
// summary.setTextAppearance(getContext(), android.R.style.TextAppearance_Large);
summary.setGravity(Gravity.LEFT);
lp = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT,
LinearLayout.LayoutParams.WRAP_CONTENT);
lp.gravity = Gravity.LEFT;
lp.weight = 1.0f;
summary.setLayoutParams(lp);
}
LinearLayout layout = new LinearLayout(getContext()); LinearLayout layout = new LinearLayout(getContext());
layout.setPadding(25, 5, 25, 5); layout.setPadding(25, 5, 25, 5);
layout.setOrientation(LinearLayout.VERTICAL); layout.setOrientation(LinearLayout.VERTICAL);
layout.addView(row1); layout.addView(row1);
layout.addView(bar); layout.addView(bar);
if (summary != null)
layout.addView(summary);
layout.setId(android.R.id.widget_frame); layout.setId(android.R.id.widget_frame);
currValBox.setOnClickListener(new OnClickListener() { currValBox.setOnClickListener(new OnClickListener() {