mirror of
https://github.com/cmclark00/mintris.git
synced 2025-05-18 02:25:21 +01:00
start adding theme support to full app.
This commit is contained in:
parent
ed7847ad70
commit
ae5ad1ed03
2 changed files with 46 additions and 0 deletions
|
@ -491,6 +491,7 @@ class MainActivity : AppCompatActivity() {
|
||||||
binding.gameOverContainer.visibility = View.GONE
|
binding.gameOverContainer.visibility = View.GONE
|
||||||
binding.pauseContainer.visibility = View.GONE
|
binding.pauseContainer.visibility = View.GONE
|
||||||
titleScreen.visibility = View.VISIBLE
|
titleScreen.visibility = View.VISIBLE
|
||||||
|
titleScreen.applyTheme(currentTheme)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -521,6 +522,11 @@ class MainActivity : AppCompatActivity() {
|
||||||
// Save the selected theme
|
// Save the selected theme
|
||||||
currentTheme = themeId
|
currentTheme = themeId
|
||||||
saveThemePreference(themeId)
|
saveThemePreference(themeId)
|
||||||
|
|
||||||
|
// Apply theme to title screen if it's visible
|
||||||
|
if (titleScreen.visibility == View.VISIBLE) {
|
||||||
|
titleScreen.applyTheme(themeId)
|
||||||
|
}
|
||||||
|
|
||||||
// Apply theme colors based on theme ID
|
// Apply theme colors based on theme ID
|
||||||
when (themeId) {
|
when (themeId) {
|
||||||
|
|
|
@ -12,6 +12,7 @@ import java.util.Random
|
||||||
import android.util.Log
|
import android.util.Log
|
||||||
import com.mintris.model.HighScoreManager
|
import com.mintris.model.HighScoreManager
|
||||||
import com.mintris.model.HighScore
|
import com.mintris.model.HighScore
|
||||||
|
import com.mintris.model.PlayerProgressionManager
|
||||||
import kotlin.math.abs
|
import kotlin.math.abs
|
||||||
import androidx.core.graphics.withTranslation
|
import androidx.core.graphics.withTranslation
|
||||||
import androidx.core.graphics.withScale
|
import androidx.core.graphics.withScale
|
||||||
|
@ -44,6 +45,9 @@ class TitleScreen @JvmOverloads constructor(
|
||||||
|
|
||||||
// Callback for when the user touches the screen
|
// Callback for when the user touches the screen
|
||||||
var onStartGame: (() -> Unit)? = null
|
var onStartGame: (() -> Unit)? = null
|
||||||
|
|
||||||
|
// Theme color
|
||||||
|
private var themeColor = Color.WHITE
|
||||||
|
|
||||||
// Define tetromino shapes (I, O, T, S, Z, J, L)
|
// Define tetromino shapes (I, O, T, S, Z, J, L)
|
||||||
private val tetrominoShapes = arrayOf(
|
private val tetrominoShapes = arrayOf(
|
||||||
|
@ -312,4 +316,40 @@ class TitleScreen @JvmOverloads constructor(
|
||||||
onStartGame?.invoke()
|
onStartGame?.invoke()
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Apply a theme to the title screen
|
||||||
|
*/
|
||||||
|
fun applyTheme(themeId: String) {
|
||||||
|
// Get theme color based on theme ID
|
||||||
|
themeColor = when (themeId) {
|
||||||
|
PlayerProgressionManager.THEME_CLASSIC -> Color.WHITE
|
||||||
|
PlayerProgressionManager.THEME_NEON -> Color.parseColor("#FF00FF")
|
||||||
|
PlayerProgressionManager.THEME_MONOCHROME -> Color.LTGRAY
|
||||||
|
PlayerProgressionManager.THEME_RETRO -> Color.parseColor("#FF5A5F")
|
||||||
|
PlayerProgressionManager.THEME_MINIMALIST -> Color.BLACK
|
||||||
|
PlayerProgressionManager.THEME_GALAXY -> Color.parseColor("#66FCF1")
|
||||||
|
else -> Color.WHITE
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update paint colors
|
||||||
|
titlePaint.color = themeColor
|
||||||
|
promptPaint.color = themeColor
|
||||||
|
highScorePaint.color = themeColor
|
||||||
|
paint.color = themeColor
|
||||||
|
glowPaint.color = themeColor
|
||||||
|
|
||||||
|
// Update background color
|
||||||
|
setBackgroundColor(when (themeId) {
|
||||||
|
PlayerProgressionManager.THEME_CLASSIC -> Color.BLACK
|
||||||
|
PlayerProgressionManager.THEME_NEON -> Color.parseColor("#0D0221")
|
||||||
|
PlayerProgressionManager.THEME_MONOCHROME -> Color.parseColor("#1A1A1A")
|
||||||
|
PlayerProgressionManager.THEME_RETRO -> Color.parseColor("#3F2832")
|
||||||
|
PlayerProgressionManager.THEME_MINIMALIST -> Color.WHITE
|
||||||
|
PlayerProgressionManager.THEME_GALAXY -> Color.parseColor("#0B0C10")
|
||||||
|
else -> Color.BLACK
|
||||||
|
})
|
||||||
|
|
||||||
|
invalidate()
|
||||||
|
}
|
||||||
}
|
}
|
Loading…
Add table
Add a link
Reference in a new issue