feat: add B button support for exiting customization menu

This commit is contained in:
cmclark00 2025-03-31 16:10:44 -04:00
parent 419cd8cbdb
commit 0b78bf7833

View file

@ -528,16 +528,23 @@ class MainActivity : AppCompatActivity(),
binding.customizationContainer.visibility = View.VISIBLE
binding.pauseContainer.visibility = View.GONE
// Update theme colors
val themeColors = ThemeManager.getThemeColors()
binding.customizationContainer.setBackgroundColor(themeColors.background)
// Get theme colors
val themeColor = getThemeColor(currentTheme)
val backgroundColor = getThemeBackgroundColor(currentTheme)
// Apply background color to customization container
binding.customizationContainer.setBackgroundColor(backgroundColor)
// Update level badge
binding.customizationLevelBadge.setLevel(progressionManager.getPlayerLevel())
binding.customizationLevelBadge.setThemeColor(themeColors.accent)
binding.customizationLevelBadge.setThemeColor(themeColor)
// Apply theme colors to text
binding.customizationTitle.setTextColor(themeColors.text.toInt())
// Apply theme colors to text and buttons
binding.customizationTitle.setTextColor(themeColor)
binding.customizationBackButton.setTextColor(themeColor)
// Apply theme colors to all text views in the container
applyThemeColorToTextViews(binding.customizationContainer, themeColor)
// Update theme and block skin selectors
binding.customizationThemeSelector.updateThemes(
@ -1204,7 +1211,7 @@ class MainActivity : AppCompatActivity(),
// If not handled as gamepad, handle as regular key event
// Handle back button
if (keyCode == KeyEvent.KEYCODE_BACK) {
if (keyCode == KeyEvent.KEYCODE_BACK || keyCode == KeyEvent.KEYCODE_BUTTON_B) {
// Handle back button press as a pause action during gameplay
if (gameView.visibility == View.VISIBLE && !gameView.isPaused && !gameView.isGameOver()) {
gameView.pause()
@ -1217,6 +1224,10 @@ class MainActivity : AppCompatActivity(),
// If pause menu is showing, handle as a resume
resumeGame()
return true // Consume the event
} else if (binding.customizationContainer.visibility == View.VISIBLE) {
// If customization menu is showing, hide it
hideCustomizationMenu()
return true // Consume the event
} else if (binding.gameOverContainer.visibility == View.VISIBLE) {
// If game over is showing, go back to title
hideGameOver()
@ -1259,7 +1270,10 @@ class MainActivity : AppCompatActivity(),
*/
override fun onPauseRequested() {
runOnUiThread {
if (gameView.visibility == View.VISIBLE && !gameView.isPaused && !gameView.isGameOver()) {
if (binding.customizationContainer.visibility == View.VISIBLE) {
// If customization menu is showing, hide it
hideCustomizationMenu()
} else if (gameView.visibility == View.VISIBLE && !gameView.isPaused && !gameView.isGameOver()) {
gameView.pause()
gameMusic.pause()
showPauseMenu()