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()); IntSetting.MAIN_CONTROL_SCALE.setInt(mSettings, seekbar.getProgress());
mEmulationFragment.refreshInputOverlay(); mEmulationFragment.refreshInputOverlay();
}); });
builder.setNeutralButton(R.string.default_values, (dialogInterface, i) ->
{
IntSetting.MAIN_CONTROL_SCALE.delete(mSettings);
mEmulationFragment.refreshInputOverlay();
});
builder.show(); builder.show();
} }
@ -966,8 +971,11 @@ public final class EmulationActivity extends AppCompatActivity
private void setIRSensitivity() private void setIRSensitivity()
{ {
int ir_pitch = Integer.parseInt( // IR settings always get saved per-game since WiimoteNew.ini is wiped upon reinstall.
mPreferences.getString(SettingsFile.KEY_WIIBIND_IR_PITCH + mSelectedGameId, "15")); 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); LayoutInflater inflater = LayoutInflater.from(this);
View view = inflater.inflate(R.layout.dialog_ir_sensitivity, null); 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( int ir_yaw = ini.getInt(Settings.SECTION_CONTROLS, SettingsFile.KEY_WIIBIND_IR_YAW, 15);
mPreferences.getString(SettingsFile.KEY_WIIBIND_IR_YAW + mSelectedGameId, "15"));
TextView text_slider_value_yaw = view.findViewById(R.id.text_ir_yaw); TextView text_slider_value_yaw = view.findViewById(R.id.text_ir_yaw);
TextView units_yaw = view.findViewById(R.id.text_ir_yaw_units); 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( int ir_vertical_offset =
mPreferences.getString(SettingsFile.KEY_WIIBIND_IR_VERTICAL_OFFSET + mSelectedGameId, ini.getInt(Settings.SECTION_CONTROLS, SettingsFile.KEY_WIIBIND_IR_VERTICAL_OFFSET, 10);
"10"));
TextView text_slider_value_vertical_offset = view.findViewById(R.id.text_ir_vertical_offset); 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); 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.setView(view);
builder.setPositiveButton(R.string.ok, (dialogInterface, i) -> 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, ini.setString(Settings.SECTION_CONTROLS, SettingsFile.KEY_WIIBIND_IR_PITCH,
text_slider_value_pitch.getText().toString()); text_slider_value_pitch.getText().toString());
ini.setString(Settings.SECTION_CONTROLS, SettingsFile.KEY_WIIBIND_IR_YAW, ini.setString(Settings.SECTION_CONTROLS, SettingsFile.KEY_WIIBIND_IR_YAW,
@ -1077,20 +1081,20 @@ public final class EmulationActivity extends AppCompatActivity
ini.save(file); ini.save(file);
NativeLibrary.ReloadWiimoteConfig(); 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) -> builder.setNegativeButton(R.string.cancel, (dialogInterface, i) ->
{ {
// Do nothing // 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(); 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="pitch">Total Pitch</string>
<string name="yaw">Total Yaw</string> <string name="yaw">Total Yaw</string>
<string name="vertical_offset">Vertical Offset</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="slider_setting_value">%1$d%2$s</string>
<string name="disc_number">Disc %1$d</string> <string name="disc_number">Disc %1$d</string>
<string name="disabled_gc_overlay_notice">GameCube Controller 1 is set to \"None\"</string> <string name="disabled_gc_overlay_notice">GameCube Controller 1 is set to \"None\"</string>