mirror of
https://github.com/peterosterlund2/droidfish.git
synced 2025-12-12 17:12:40 +01:00
DroidFish: Implemented function to reset all UCI options to default values.
This commit is contained in:
@@ -34,5 +34,12 @@
|
|||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_weight="1">
|
android:layout_weight="1">
|
||||||
</Button>
|
</Button>
|
||||||
|
<Button
|
||||||
|
android:text="@string/reset"
|
||||||
|
android:id="@+id/eo_reset"
|
||||||
|
android:layout_width="fill_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1">
|
||||||
|
</Button>
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|||||||
@@ -33,5 +33,12 @@
|
|||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_weight="1">
|
android:layout_weight="1">
|
||||||
</Button>
|
</Button>
|
||||||
|
<Button
|
||||||
|
android:text="@string/reset"
|
||||||
|
android:id="@+id/eo_reset"
|
||||||
|
android:layout_width="fill_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1">
|
||||||
|
</Button>
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|||||||
@@ -130,6 +130,7 @@ you are not actively using the program.\
|
|||||||
<string name="toggle_large_buttons">Toggle Large Buttons</string>
|
<string name="toggle_large_buttons">Toggle Large Buttons</string>
|
||||||
<string name="toggle_blind_mode">Toggle Blindfold Mode</string>
|
<string name="toggle_blind_mode">Toggle Blindfold Mode</string>
|
||||||
<string name="cancel">Cancel</string>
|
<string name="cancel">Cancel</string>
|
||||||
|
<string name="reset">Reset</string>
|
||||||
<string name="yes">Yes</string>
|
<string name="yes">Yes</string>
|
||||||
<string name="no">No</string>
|
<string name="no">No</string>
|
||||||
<string name="move_number">Move number:</string>
|
<string name="move_number">Move number:</string>
|
||||||
|
|||||||
@@ -93,7 +93,9 @@ public class EditOptions extends Activity {
|
|||||||
LinearLayout content = (LinearLayout)findViewById(R.id.eo_content);
|
LinearLayout content = (LinearLayout)findViewById(R.id.eo_content);
|
||||||
Button okButton = (Button)findViewById(R.id.eo_ok);
|
Button okButton = (Button)findViewById(R.id.eo_ok);
|
||||||
Button cancelButton = (Button)findViewById(R.id.eo_cancel);
|
Button cancelButton = (Button)findViewById(R.id.eo_cancel);
|
||||||
|
Button resetButton = (Button)findViewById(R.id.eo_reset);
|
||||||
|
|
||||||
|
if (uciOpts != null) {
|
||||||
for (String name : uciOpts.getOptionNames()) {
|
for (String name : uciOpts.getOptionNames()) {
|
||||||
UCIOptions.OptionBase o = uciOpts.getOption(name);
|
UCIOptions.OptionBase o = uciOpts.getOption(name);
|
||||||
if (!o.visible)
|
if (!o.visible)
|
||||||
@@ -204,6 +206,7 @@ public class EditOptions extends Activity {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
okButton.setOnClickListener(new OnClickListener() {
|
okButton.setOnClickListener(new OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
@@ -218,6 +221,47 @@ public class EditOptions extends Activity {
|
|||||||
finish();
|
finish();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
resetButton.setOnClickListener(new OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
if (uciOpts != null) {
|
||||||
|
boolean modified = false;
|
||||||
|
for (String name : uciOpts.getOptionNames()) {
|
||||||
|
UCIOptions.OptionBase o = uciOpts.getOption(name);
|
||||||
|
if (!o.visible)
|
||||||
|
continue;
|
||||||
|
switch (o.type) {
|
||||||
|
case CHECK: {
|
||||||
|
UCIOptions.CheckOption co = (UCIOptions.CheckOption)o;
|
||||||
|
if (co.set(co.defaultValue))
|
||||||
|
modified = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case SPIN: {
|
||||||
|
UCIOptions.SpinOption so = (UCIOptions.SpinOption)o;
|
||||||
|
if (so.set(so.defaultValue))
|
||||||
|
modified = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case COMBO: {
|
||||||
|
UCIOptions.ComboOption co = (UCIOptions.ComboOption)o;
|
||||||
|
if (co.set(co.defaultValue))
|
||||||
|
modified = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case STRING: {
|
||||||
|
UCIOptions.StringOption so = (UCIOptions.StringOption)o;
|
||||||
|
if (so.set(so.defaultValue))
|
||||||
|
modified = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (modified)
|
||||||
|
initUI();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private final void sendBackResult() {
|
private final void sendBackResult() {
|
||||||
|
|||||||
Reference in New Issue
Block a user