From d1fb7ea58b987fe1e8013986c3166d67e74bc391 Mon Sep 17 00:00:00 2001 From: german77 Date: Sun, 30 Apr 2023 20:13:20 -0600 Subject: [PATCH] android: Add dedicated show overlay checkbox --- .../yuzu_emu/fragments/EmulationFragment.kt | 30 +++++++++++++++---- .../main/res/menu/menu_overlay_options.xml | 5 ++++ .../app/src/main/res/values/strings.xml | 1 + 3 files changed, 30 insertions(+), 6 deletions(-) diff --git a/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/EmulationFragment.kt b/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/EmulationFragment.kt index 8e94fd1dbc..daa704565a 100644 --- a/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/EmulationFragment.kt +++ b/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/EmulationFragment.kt @@ -3,6 +3,7 @@ package org.yuzu.yuzu_emu.fragments +import android.app.AlertDialog import android.content.Context import android.content.SharedPreferences import android.graphics.Color @@ -222,8 +223,10 @@ class EmulationFragment : Fragment(), SurfaceHolder.Callback { 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_show_overlay).isChecked = EmulationMenuSettings.showOverlay popup.setOnMenuItemClickListener { when (it.itemId) { @@ -241,7 +244,7 @@ class EmulationFragment : Fragment(), SurfaceHolder.Callback { optionsArray[i] = preferences.getBoolean("buttonToggle$i", i < 13) } - MaterialAlertDialogBuilder(requireContext()) + val dialog = MaterialAlertDialogBuilder(requireContext()) .setTitle(R.string.emulation_toggle_controls) .setMultiChoiceItems( R.array.gamepadButtons, @@ -254,12 +257,27 @@ class EmulationFragment : Fragment(), SurfaceHolder.Callback { .setPositiveButton(android.R.string.ok) { _, _ -> refreshInputOverlay() } - .setNeutralButton(R.string.emulation_toggle_all) { _, _ -> - EmulationMenuSettings.showOverlay = !EmulationMenuSettings.showOverlay - refreshInputOverlay() - } + .setNeutralButton(R.string.emulation_toggle_all) { _, _ -> } .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 } R.id.menu_rel_stick_center -> { diff --git a/src/android/app/src/main/res/menu/menu_overlay_options.xml b/src/android/app/src/main/res/menu/menu_overlay_options.xml index 36c710f143..17ba5496d6 100644 --- a/src/android/app/src/main/res/menu/menu_overlay_options.xml +++ b/src/android/app/src/main/res/menu/menu_overlay_options.xml @@ -9,6 +9,11 @@ android:id="@+id/menu_toggle_controls" android:title="@string/emulation_toggle_controls" /> + + Toggle Controls Relative Stick Center DPad Slide + Show Overlay Toggle All Adjust Scale Reset Overlay