Hide control panels in landscape mode when title screen is visible

This commit is contained in:
cmclark00 2025-04-01 23:50:47 -04:00
parent 212e52aea8
commit ff1a0edd2f
2 changed files with 28 additions and 14 deletions

View file

@ -357,6 +357,12 @@ class MainActivity : AppCompatActivity(),
binding.gameControlsContainer.visibility = View.GONE
titleScreen.visibility = View.VISIBLE
// Hide landscape control panels if in landscape mode and title screen is visible
if (resources.configuration.orientation == android.content.res.Configuration.ORIENTATION_LANDSCAPE) {
binding.leftControlsPanel?.visibility = View.GONE
binding.rightControlsPanel?.visibility = View.GONE
}
// Set up pause button to show settings menu
binding.pauseButton.setOnClickListener {
gameHaptics.performHapticFeedback(it, HapticFeedbackConstants.VIRTUAL_KEY)
@ -1132,6 +1138,20 @@ class MainActivity : AppCompatActivity(),
// Check for already connected gamepads
checkGamepadConnections()
// Update visibility of control panels in landscape orientation based on title screen visibility
if (resources.configuration.orientation == android.content.res.Configuration.ORIENTATION_LANDSCAPE) {
if (titleScreen.visibility == View.VISIBLE) {
// Hide control panels when title screen is visible
binding.leftControlsPanel?.visibility = View.GONE
binding.rightControlsPanel?.visibility = View.GONE
} else if (gameView.visibility == View.VISIBLE && binding.gameOverContainer.visibility == View.GONE
&& binding.pauseContainer.visibility == View.GONE) {
// Show control panels when game is active
binding.leftControlsPanel?.visibility = View.VISIBLE
binding.rightControlsPanel?.visibility = View.VISIBLE
}
}
// If we're on the title screen, don't auto-resume the game
if (titleScreen.visibility == View.GONE && gameView.visibility == View.VISIBLE && binding.gameOverContainer.visibility == View.GONE && binding.pauseContainer.visibility == View.GONE) {
resumeGame()