Android: Add "Default Values" button for overlay seekbars

This commit is contained in:
Ryan Meredith 2020-10-20 11:59:57 -04:00
parent cc5802ba04
commit 69adfe0218
2 changed files with 23 additions and 18 deletions

View File

@ -874,6 +874,11 @@ public final class EmulationActivity extends AppCompatActivity
IntSetting.MAIN_CONTROL_SCALE.setInt(mSettings, seekbar.getProgress());
mEmulationFragment.refreshInputOverlay();
});
builder.setNeutralButton(R.string.default_values, (dialogInterface, i) ->
{
IntSetting.MAIN_CONTROL_SCALE.delete(mSettings);
mEmulationFragment.refreshInputOverlay();
});
builder.show();
}
@ -966,8 +971,11 @@ public final class EmulationActivity extends AppCompatActivity
private void setIRSensitivity()
{
int ir_pitch = Integer.parseInt(
mPreferences.getString(SettingsFile.KEY_WIIBIND_IR_PITCH + mSelectedGameId, "15"));
// IR settings always get saved per-game since WiimoteNew.ini is wiped upon reinstall.
File file = SettingsFile.getCustomGameSettingsFile(mSelectedGameId);
IniFile ini = new IniFile(file);
int ir_pitch = ini.getInt(Settings.SECTION_CONTROLS, SettingsFile.KEY_WIIBIND_IR_PITCH, 15);
LayoutInflater inflater = LayoutInflater.from(this);
View view = inflater.inflate(R.layout.dialog_ir_sensitivity, null);
@ -999,8 +1007,7 @@ public final class EmulationActivity extends AppCompatActivity
}
});
int ir_yaw = Integer.parseInt(
mPreferences.getString(SettingsFile.KEY_WIIBIND_IR_YAW + mSelectedGameId, "15"));
int ir_yaw = ini.getInt(Settings.SECTION_CONTROLS, SettingsFile.KEY_WIIBIND_IR_YAW, 15);
TextView text_slider_value_yaw = view.findViewById(R.id.text_ir_yaw);
TextView units_yaw = view.findViewById(R.id.text_ir_yaw_units);
@ -1030,9 +1037,8 @@ public final class EmulationActivity extends AppCompatActivity
});
int ir_vertical_offset = Integer.parseInt(
mPreferences.getString(SettingsFile.KEY_WIIBIND_IR_VERTICAL_OFFSET + mSelectedGameId,
"10"));
int ir_vertical_offset =
ini.getInt(Settings.SECTION_CONTROLS, SettingsFile.KEY_WIIBIND_IR_VERTICAL_OFFSET, 10);
TextView text_slider_value_vertical_offset = view.findViewById(R.id.text_ir_vertical_offset);
TextView units_vertical_offset = view.findViewById(R.id.text_ir_vertical_offset_units);
@ -1066,8 +1072,6 @@ public final class EmulationActivity extends AppCompatActivity
builder.setView(view);
builder.setPositiveButton(R.string.ok, (dialogInterface, i) ->
{
File file = SettingsFile.getCustomGameSettingsFile(mSelectedGameId);
IniFile ini = new IniFile(file);
ini.setString(Settings.SECTION_CONTROLS, SettingsFile.KEY_WIIBIND_IR_PITCH,
text_slider_value_pitch.getText().toString());
ini.setString(Settings.SECTION_CONTROLS, SettingsFile.KEY_WIIBIND_IR_YAW,
@ -1077,20 +1081,20 @@ public final class EmulationActivity extends AppCompatActivity
ini.save(file);
NativeLibrary.ReloadWiimoteConfig();
SharedPreferences.Editor editor = mPreferences.edit();
editor.putString(SettingsFile.KEY_WIIBIND_IR_PITCH + mSelectedGameId,
text_slider_value_pitch.getText().toString());
editor.putString(SettingsFile.KEY_WIIBIND_IR_YAW + mSelectedGameId,
text_slider_value_yaw.getText().toString());
editor.putString(SettingsFile.KEY_WIIBIND_IR_VERTICAL_OFFSET + mSelectedGameId,
text_slider_value_vertical_offset.getText().toString());
editor.apply();
});
builder.setNegativeButton(R.string.cancel, (dialogInterface, i) ->
{
// Do nothing
});
builder.setNeutralButton(R.string.default_values, (dialogInterface, i) ->
{
ini.deleteKey(Settings.SECTION_CONTROLS, SettingsFile.KEY_WIIBIND_IR_PITCH);
ini.deleteKey(Settings.SECTION_CONTROLS, SettingsFile.KEY_WIIBIND_IR_YAW);
ini.deleteKey(Settings.SECTION_CONTROLS, SettingsFile.KEY_WIIBIND_IR_VERTICAL_OFFSET);
ini.save(file);
NativeLibrary.ReloadWiimoteConfig();
});
builder.show();
}

View File

@ -435,6 +435,7 @@ It can efficiently compress both junk data and encrypted Wii data.
<string name="pitch">Total Pitch</string>
<string name="yaw">Total Yaw</string>
<string name="vertical_offset">Vertical Offset</string>
<string name="default_values">Default Values</string>
<string name="slider_setting_value">%1$d%2$s</string>
<string name="disc_number">Disc %1$d</string>
<string name="disabled_gc_overlay_notice">GameCube Controller 1 is set to \"None\"</string>