Enhance landscape support: Add click handlers for theme and block skin selectors, improve UI layout in landscape mode

This commit is contained in:
Corey 2025-03-31 03:46:05 -04:00
parent 94e8d313c2
commit b481fb4e80
8 changed files with 1042 additions and 42 deletions

View file

@ -133,6 +133,19 @@ class MainActivity : AppCompatActivity() {
}
}
// Set up landscape mode theme selector if available
val inPauseThemeSelector = findViewById<ThemeSelector>(R.id.inPauseThemeSelector)
inPauseThemeSelector?.onThemeSelected = { themeId: String ->
// Apply the new theme
applyTheme(themeId)
// Provide haptic feedback
gameHaptics.vibrateForPieceLock()
// Refresh the pause menu
showPauseMenu()
}
// Set up block skin selector
blockSkinSelector.onBlockSkinSelected = { skinId: String ->
// Apply the new block skin
@ -145,6 +158,19 @@ class MainActivity : AppCompatActivity() {
gameHaptics.vibrateForPieceLock()
}
// Set up landscape mode block skin selector if available
val inPauseBlockSkinSelector = findViewById<BlockSkinSelector>(R.id.inPauseBlockSkinSelector)
inPauseBlockSkinSelector?.onBlockSkinSelected = { skinId: String ->
// Apply the new block skin
gameView.setBlockSkin(skinId)
// Save the selection
progressionManager.setSelectedBlockSkin(skinId)
// Provide haptic feedback
gameHaptics.vibrateForPieceLock()
}
// Set up title screen
titleScreen.onStartGame = {
titleScreen.visibility = View.GONE
@ -437,8 +463,8 @@ class MainActivity : AppCompatActivity() {
binding.resumeButton.visibility = View.GONE
// Update level badge
binding.pauseLevelBadge.setLevel(progressionManager.getPlayerLevel())
binding.pauseLevelBadge.setThemeColor(getThemeColor(currentTheme))
binding.pauseLevelBadge?.setLevel(progressionManager.getPlayerLevel())
binding.pauseLevelBadge?.setThemeColor(getThemeColor(currentTheme))
// Get theme color
val textColor = getThemeColor(currentTheme)
@ -461,26 +487,41 @@ class MainActivity : AppCompatActivity() {
binding.resumeButton.setTextColor(textColor)
binding.highScoresButton.setTextColor(textColor)
binding.statsButton.setTextColor(textColor)
binding.pauseLevelText.setTextColor(textColor)
binding.pauseLevelText?.setTextColor(textColor)
binding.pauseLevelUpButton.setTextColor(textColor)
binding.pauseLevelDownButton.setTextColor(textColor)
binding.settingsButton.setTextColor(textColor)
binding.musicToggle.setColorFilter(textColor)
// Apply theme colors to text elements
binding.settingsTitle.setTextColor(textColor)
binding.settingsTitle?.setTextColor(textColor)
binding.selectLevelText.setTextColor(textColor)
binding.musicText.setTextColor(textColor)
// Update theme selector
// Update theme selector - handle both standard and landscape versions
updateThemeSelector()
// Update block skin selector
// Handle landscape mode theme selectors (using null-safe calls)
val inPauseThemeSelector = findViewById<ThemeSelector>(R.id.inPauseThemeSelector)
inPauseThemeSelector?.updateThemes(
unlockedThemes = progressionManager.getUnlockedThemes(),
currentTheme = currentTheme
)
// Update block skin selector - handle both standard and landscape versions
blockSkinSelector.updateBlockSkins(
progressionManager.getUnlockedBlocks(),
gameView.getCurrentBlockSkin(),
progressionManager.getPlayerLevel()
)
// Handle landscape mode block skin selectors (using null-safe calls)
val inPauseBlockSkinSelector = findViewById<BlockSkinSelector>(R.id.inPauseBlockSkinSelector)
inPauseBlockSkinSelector?.updateBlockSkins(
progressionManager.getUnlockedBlocks(),
gameView.getCurrentBlockSkin(),
progressionManager.getPlayerLevel()
)
}
/**