mirror of
https://github.com/cmclark00/mintris.git
synced 2025-05-17 23:45:22 +01:00
Hide control panels in landscape mode when title screen is visible
This commit is contained in:
parent
212e52aea8
commit
ff1a0edd2f
2 changed files with 28 additions and 14 deletions
|
@ -357,6 +357,12 @@ class MainActivity : AppCompatActivity(),
|
||||||
binding.gameControlsContainer.visibility = View.GONE
|
binding.gameControlsContainer.visibility = View.GONE
|
||||||
titleScreen.visibility = View.VISIBLE
|
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
|
// Set up pause button to show settings menu
|
||||||
binding.pauseButton.setOnClickListener {
|
binding.pauseButton.setOnClickListener {
|
||||||
gameHaptics.performHapticFeedback(it, HapticFeedbackConstants.VIRTUAL_KEY)
|
gameHaptics.performHapticFeedback(it, HapticFeedbackConstants.VIRTUAL_KEY)
|
||||||
|
@ -1132,6 +1138,20 @@ class MainActivity : AppCompatActivity(),
|
||||||
// Check for already connected gamepads
|
// Check for already connected gamepads
|
||||||
checkGamepadConnections()
|
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 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) {
|
if (titleScreen.visibility == View.GONE && gameView.visibility == View.VISIBLE && binding.gameOverContainer.visibility == View.GONE && binding.pauseContainer.visibility == View.GONE) {
|
||||||
resumeGame()
|
resumeGame()
|
||||||
|
|
|
@ -297,8 +297,6 @@ class TitleScreen @JvmOverloads constructor(
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onTouchEvent(event: MotionEvent): Boolean {
|
override fun onTouchEvent(event: MotionEvent): Boolean {
|
||||||
val isLandscape = resources.configuration.orientation == android.content.res.Configuration.ORIENTATION_LANDSCAPE
|
|
||||||
|
|
||||||
when (event.action) {
|
when (event.action) {
|
||||||
MotionEvent.ACTION_DOWN -> {
|
MotionEvent.ACTION_DOWN -> {
|
||||||
startX = event.x
|
startX = event.x
|
||||||
|
@ -308,22 +306,18 @@ class TitleScreen @JvmOverloads constructor(
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
MotionEvent.ACTION_MOVE -> {
|
MotionEvent.ACTION_MOVE -> {
|
||||||
// Skip tetromino movement in landscape mode
|
val deltaX = event.x - lastTouchX
|
||||||
if (!isLandscape) {
|
val deltaY = event.y - lastTouchY
|
||||||
val deltaX = event.x - lastTouchX
|
|
||||||
val deltaY = event.y - lastTouchY
|
|
||||||
|
|
||||||
// Update tetromino positions
|
// Update tetromino positions
|
||||||
for (tetromino in tetrominos) {
|
for (tetromino in tetrominos) {
|
||||||
tetromino.x += deltaX * 0.5f
|
tetromino.x += deltaX * 0.5f
|
||||||
tetromino.y += deltaY * 0.5f
|
tetromino.y += deltaY * 0.5f
|
||||||
}
|
|
||||||
|
|
||||||
invalidate()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
lastTouchX = event.x
|
lastTouchX = event.x
|
||||||
lastTouchY = event.y
|
lastTouchY = event.y
|
||||||
|
invalidate()
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
MotionEvent.ACTION_UP -> {
|
MotionEvent.ACTION_UP -> {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue