mirror of
https://git.suyu.dev/suyu/suyu.git
synced 2024-11-26 16:52:46 +01:00
android: Add dedicated show overlay checkbox
This commit is contained in:
parent
912bf6a0c6
commit
d1fb7ea58b
3 changed files with 30 additions and 6 deletions
|
@ -3,6 +3,7 @@
|
||||||
|
|
||||||
package org.yuzu.yuzu_emu.fragments
|
package org.yuzu.yuzu_emu.fragments
|
||||||
|
|
||||||
|
import android.app.AlertDialog
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.content.SharedPreferences
|
import android.content.SharedPreferences
|
||||||
import android.graphics.Color
|
import android.graphics.Color
|
||||||
|
@ -222,8 +223,10 @@ class EmulationFragment : Fragment(), SurfaceHolder.Callback {
|
||||||
|
|
||||||
popup.menuInflater.inflate(R.menu.menu_overlay_options, popup.menu)
|
popup.menuInflater.inflate(R.menu.menu_overlay_options, popup.menu)
|
||||||
|
|
||||||
popup.menu.findItem(R.id.menu_rel_stick_center).isChecked = EmulationMenuSettings.joystickRelCenter
|
popup.menu.findItem(R.id.menu_rel_stick_center).isChecked =
|
||||||
|
EmulationMenuSettings.joystickRelCenter
|
||||||
popup.menu.findItem(R.id.menu_dpad_slide).isChecked = EmulationMenuSettings.dpadSlide
|
popup.menu.findItem(R.id.menu_dpad_slide).isChecked = EmulationMenuSettings.dpadSlide
|
||||||
|
popup.menu.findItem(R.id.menu_show_overlay).isChecked = EmulationMenuSettings.showOverlay
|
||||||
|
|
||||||
popup.setOnMenuItemClickListener {
|
popup.setOnMenuItemClickListener {
|
||||||
when (it.itemId) {
|
when (it.itemId) {
|
||||||
|
@ -241,7 +244,7 @@ class EmulationFragment : Fragment(), SurfaceHolder.Callback {
|
||||||
optionsArray[i] = preferences.getBoolean("buttonToggle$i", i < 13)
|
optionsArray[i] = preferences.getBoolean("buttonToggle$i", i < 13)
|
||||||
}
|
}
|
||||||
|
|
||||||
MaterialAlertDialogBuilder(requireContext())
|
val dialog = MaterialAlertDialogBuilder(requireContext())
|
||||||
.setTitle(R.string.emulation_toggle_controls)
|
.setTitle(R.string.emulation_toggle_controls)
|
||||||
.setMultiChoiceItems(
|
.setMultiChoiceItems(
|
||||||
R.array.gamepadButtons,
|
R.array.gamepadButtons,
|
||||||
|
@ -254,12 +257,27 @@ class EmulationFragment : Fragment(), SurfaceHolder.Callback {
|
||||||
.setPositiveButton(android.R.string.ok) { _, _ ->
|
.setPositiveButton(android.R.string.ok) { _, _ ->
|
||||||
refreshInputOverlay()
|
refreshInputOverlay()
|
||||||
}
|
}
|
||||||
.setNeutralButton(R.string.emulation_toggle_all) { _, _ ->
|
.setNeutralButton(R.string.emulation_toggle_all) { _, _ -> }
|
||||||
EmulationMenuSettings.showOverlay = !EmulationMenuSettings.showOverlay
|
|
||||||
refreshInputOverlay()
|
|
||||||
}
|
|
||||||
.show()
|
.show()
|
||||||
|
|
||||||
|
// Override normal behaviour so the dialog doesn't close
|
||||||
|
dialog.getButton(AlertDialog.BUTTON_NEUTRAL)
|
||||||
|
.setOnClickListener {
|
||||||
|
val isChecked = !optionsArray[0];
|
||||||
|
for (i in 0..14) {
|
||||||
|
optionsArray[i] = isChecked;
|
||||||
|
dialog.listView.setItemChecked(i, isChecked)
|
||||||
|
preferences.edit()
|
||||||
|
.putBoolean("buttonToggle$i", isChecked)
|
||||||
|
.apply()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
true
|
||||||
|
}
|
||||||
|
R.id.menu_show_overlay -> {
|
||||||
|
it.isChecked = !it.isChecked
|
||||||
|
EmulationMenuSettings.showOverlay = it.isChecked
|
||||||
|
refreshInputOverlay()
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
R.id.menu_rel_stick_center -> {
|
R.id.menu_rel_stick_center -> {
|
||||||
|
|
|
@ -9,6 +9,11 @@
|
||||||
android:id="@+id/menu_toggle_controls"
|
android:id="@+id/menu_toggle_controls"
|
||||||
android:title="@string/emulation_toggle_controls" />
|
android:title="@string/emulation_toggle_controls" />
|
||||||
|
|
||||||
|
<item
|
||||||
|
android:id="@+id/menu_show_overlay"
|
||||||
|
android:title="@string/emulation_show_overlay"
|
||||||
|
android:checkable="true" />
|
||||||
|
|
||||||
<item
|
<item
|
||||||
android:id="@+id/menu_rel_stick_center"
|
android:id="@+id/menu_rel_stick_center"
|
||||||
android:title="@string/emulation_rel_stick_center"
|
android:title="@string/emulation_rel_stick_center"
|
||||||
|
|
|
@ -139,6 +139,7 @@
|
||||||
<string name="emulation_toggle_controls">Toggle Controls</string>
|
<string name="emulation_toggle_controls">Toggle Controls</string>
|
||||||
<string name="emulation_rel_stick_center">Relative Stick Center</string>
|
<string name="emulation_rel_stick_center">Relative Stick Center</string>
|
||||||
<string name="emulation_dpad_slide">DPad Slide</string>
|
<string name="emulation_dpad_slide">DPad Slide</string>
|
||||||
|
<string name="emulation_show_overlay">Show Overlay</string>
|
||||||
<string name="emulation_toggle_all">Toggle All</string>
|
<string name="emulation_toggle_all">Toggle All</string>
|
||||||
<string name="emulation_control_scale">Adjust Scale</string>
|
<string name="emulation_control_scale">Adjust Scale</string>
|
||||||
<string name="emulation_touch_overlay_reset">Reset Overlay</string>
|
<string name="emulation_touch_overlay_reset">Reset Overlay</string>
|
||||||
|
|
Loading…
Reference in a new issue