mirror of
https://github.com/cmclark00/mintris.git
synced 2025-05-18 17:35:21 +01:00
fix: theme colors and UI improvements
This commit is contained in:
parent
42b9bcfab4
commit
68e8cb160f
3 changed files with 124 additions and 78 deletions
|
@ -91,6 +91,14 @@ class MainActivity : AppCompatActivity() {
|
||||||
themeSelector = binding.themeSelector
|
themeSelector = binding.themeSelector
|
||||||
blockSkinSelector = binding.blockSkinSelector
|
blockSkinSelector = binding.blockSkinSelector
|
||||||
|
|
||||||
|
// Set up progression screen
|
||||||
|
progressionScreen = binding.progressionScreen
|
||||||
|
progressionScreen.visibility = View.GONE
|
||||||
|
progressionScreen.onContinue = {
|
||||||
|
progressionScreen.visibility = View.GONE
|
||||||
|
binding.gameOverContainer.visibility = View.VISIBLE
|
||||||
|
}
|
||||||
|
|
||||||
// Load and apply theme preference
|
// Load and apply theme preference
|
||||||
currentTheme = progressionManager.getSelectedTheme()
|
currentTheme = progressionManager.getSelectedTheme()
|
||||||
applyTheme(currentTheme)
|
applyTheme(currentTheme)
|
||||||
|
@ -109,14 +117,6 @@ class MainActivity : AppCompatActivity() {
|
||||||
gameView.setGameBoard(gameBoard)
|
gameView.setGameBoard(gameBoard)
|
||||||
gameView.setHaptics(gameHaptics)
|
gameView.setHaptics(gameHaptics)
|
||||||
|
|
||||||
// Set up progression screen
|
|
||||||
progressionScreen = binding.progressionScreen
|
|
||||||
progressionScreen.visibility = View.GONE
|
|
||||||
progressionScreen.onContinue = {
|
|
||||||
progressionScreen.visibility = View.GONE
|
|
||||||
binding.gameOverContainer.visibility = View.VISIBLE
|
|
||||||
}
|
|
||||||
|
|
||||||
// Set up theme selector
|
// Set up theme selector
|
||||||
themeSelector.onThemeSelected = { themeId: String ->
|
themeSelector.onThemeSelected = { themeId: String ->
|
||||||
// Apply the new theme
|
// Apply the new theme
|
||||||
|
@ -358,10 +358,7 @@ class MainActivity : AppCompatActivity() {
|
||||||
var showingHighScore = false
|
var showingHighScore = false
|
||||||
|
|
||||||
// Show progression screen first with XP animation
|
// Show progression screen first with XP animation
|
||||||
binding.gameOverContainer.visibility = View.GONE
|
showProgressionScreen(xpGained, newRewards)
|
||||||
progressionScreen.visibility = View.VISIBLE
|
|
||||||
progressionScreen.applyTheme(currentTheme)
|
|
||||||
progressionScreen.showProgress(progressionManager, xpGained, newRewards, currentTheme)
|
|
||||||
|
|
||||||
// Override the continue button behavior if high score needs to be shown
|
// Override the continue button behavior if high score needs to be shown
|
||||||
val originalOnContinue = progressionScreen.onContinue
|
val originalOnContinue = progressionScreen.onContinue
|
||||||
|
@ -593,63 +590,55 @@ class MainActivity : AppCompatActivity() {
|
||||||
* Apply a theme to the game
|
* Apply a theme to the game
|
||||||
*/
|
*/
|
||||||
private fun applyTheme(themeId: String) {
|
private fun applyTheme(themeId: String) {
|
||||||
// Only apply if the theme is unlocked
|
|
||||||
if (!progressionManager.isThemeUnlocked(themeId)) return
|
|
||||||
|
|
||||||
// Save the selected theme
|
|
||||||
currentTheme = themeId
|
currentTheme = themeId
|
||||||
progressionManager.setSelectedTheme(themeId)
|
val themeColor = when (themeId) {
|
||||||
|
PlayerProgressionManager.THEME_CLASSIC -> Color.WHITE
|
||||||
// Apply theme to title screen if it's visible
|
PlayerProgressionManager.THEME_NEON -> Color.parseColor("#FF00FF")
|
||||||
if (titleScreen.visibility == View.VISIBLE) {
|
PlayerProgressionManager.THEME_MONOCHROME -> Color.LTGRAY
|
||||||
titleScreen.applyTheme(themeId)
|
PlayerProgressionManager.THEME_RETRO -> Color.parseColor("#FF5A5F")
|
||||||
|
PlayerProgressionManager.THEME_MINIMALIST -> Color.BLACK
|
||||||
|
PlayerProgressionManager.THEME_GALAXY -> Color.parseColor("#66FCF1")
|
||||||
|
else -> Color.WHITE
|
||||||
}
|
}
|
||||||
|
|
||||||
// Apply theme colors based on theme ID
|
// Get background color for the theme
|
||||||
when (themeId) {
|
val backgroundColor = when (themeId) {
|
||||||
PlayerProgressionManager.THEME_CLASSIC -> {
|
PlayerProgressionManager.THEME_CLASSIC -> Color.BLACK
|
||||||
// Default black theme
|
PlayerProgressionManager.THEME_NEON -> Color.parseColor("#0D0221")
|
||||||
binding.root.setBackgroundColor(Color.BLACK)
|
PlayerProgressionManager.THEME_MONOCHROME -> Color.parseColor("#1A1A1A")
|
||||||
}
|
PlayerProgressionManager.THEME_RETRO -> Color.parseColor("#3F2832")
|
||||||
PlayerProgressionManager.THEME_NEON -> {
|
PlayerProgressionManager.THEME_MINIMALIST -> Color.WHITE
|
||||||
// Neon theme with dark purple background
|
PlayerProgressionManager.THEME_GALAXY -> Color.parseColor("#0B0C10")
|
||||||
binding.root.setBackgroundColor(Color.parseColor("#0D0221"))
|
else -> Color.BLACK
|
||||||
}
|
|
||||||
PlayerProgressionManager.THEME_MONOCHROME -> {
|
|
||||||
// Monochrome dark gray
|
|
||||||
binding.root.setBackgroundColor(Color.parseColor("#1A1A1A"))
|
|
||||||
}
|
|
||||||
PlayerProgressionManager.THEME_RETRO -> {
|
|
||||||
// Retro arcade theme
|
|
||||||
binding.root.setBackgroundColor(Color.parseColor("#3F2832"))
|
|
||||||
}
|
|
||||||
PlayerProgressionManager.THEME_MINIMALIST -> {
|
|
||||||
// Minimalist white theme
|
|
||||||
binding.root.setBackgroundColor(Color.WHITE)
|
|
||||||
|
|
||||||
// Update text colors for visibility
|
|
||||||
binding.scoreText.setTextColor(Color.BLACK)
|
|
||||||
binding.currentLevelText.setTextColor(Color.BLACK)
|
|
||||||
binding.linesText.setTextColor(Color.BLACK)
|
|
||||||
binding.comboText.setTextColor(Color.BLACK)
|
|
||||||
}
|
|
||||||
PlayerProgressionManager.THEME_GALAXY -> {
|
|
||||||
// Galaxy dark blue theme
|
|
||||||
binding.root.setBackgroundColor(Color.parseColor("#0B0C10"))
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Apply theme to progression screen if it's visible and initialized
|
// Apply background color to root view
|
||||||
if (::progressionScreen.isInitialized && progressionScreen.visibility == View.VISIBLE) {
|
binding.root.setBackgroundColor(backgroundColor)
|
||||||
|
|
||||||
|
// Apply theme color to title screen
|
||||||
|
titleScreen.setThemeColor(themeColor)
|
||||||
|
titleScreen.setBackgroundColor(backgroundColor)
|
||||||
|
|
||||||
|
// Apply theme color to game over screen
|
||||||
|
binding.gameOverContainer.setBackgroundColor(backgroundColor)
|
||||||
|
binding.gameOverText.setTextColor(themeColor)
|
||||||
|
binding.scoreText.setTextColor(themeColor)
|
||||||
|
binding.currentLevelText.setTextColor(themeColor)
|
||||||
|
binding.linesText.setTextColor(themeColor)
|
||||||
|
binding.comboText.setTextColor(themeColor)
|
||||||
|
binding.playAgainButton.setTextColor(themeColor)
|
||||||
|
binding.playAgainButton.setBackgroundResource(android.R.color.transparent)
|
||||||
|
binding.playAgainButton.setTextSize(24f)
|
||||||
|
|
||||||
|
// Apply theme to progression screen (it will handle its own colors)
|
||||||
progressionScreen.applyTheme(themeId)
|
progressionScreen.applyTheme(themeId)
|
||||||
}
|
|
||||||
|
|
||||||
// Apply theme color to the stats button
|
// Apply theme color to game view
|
||||||
val textColor = getThemeColor(currentTheme)
|
gameView.setThemeColor(themeColor)
|
||||||
binding.statsButton.setTextColor(textColor)
|
gameView.setBackgroundColor(backgroundColor)
|
||||||
|
|
||||||
// Update the game view to apply theme
|
// Save theme preference
|
||||||
gameView.invalidate()
|
progressionManager.setSelectedTheme(themeId)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -745,4 +734,16 @@ class MainActivity : AppCompatActivity() {
|
||||||
}
|
}
|
||||||
return super.onKeyDown(keyCode, event)
|
return super.onKeyDown(keyCode, event)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun showProgressionScreen(xpGained: Long, newRewards: List<String>) {
|
||||||
|
// Apply theme before showing the screen
|
||||||
|
progressionScreen.applyTheme(currentTheme)
|
||||||
|
|
||||||
|
// Show the progression screen
|
||||||
|
binding.gameOverContainer.visibility = View.GONE
|
||||||
|
progressionScreen.visibility = View.VISIBLE
|
||||||
|
|
||||||
|
// Display progression data
|
||||||
|
progressionScreen.showProgress(progressionManager, xpGained, newRewards, currentTheme)
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -153,6 +153,7 @@ class GameView @JvmOverloads constructor(
|
||||||
// Block skin
|
// Block skin
|
||||||
private var currentBlockSkin: String = "block_skin_1"
|
private var currentBlockSkin: String = "block_skin_1"
|
||||||
private val blockSkinPaints = mutableMapOf<String, Paint>()
|
private val blockSkinPaints = mutableMapOf<String, Paint>()
|
||||||
|
private var currentThemeColor = Color.WHITE
|
||||||
|
|
||||||
private enum class Direction {
|
private enum class Direction {
|
||||||
HORIZONTAL, VERTICAL
|
HORIZONTAL, VERTICAL
|
||||||
|
@ -1050,4 +1051,26 @@ class GameView @JvmOverloads constructor(
|
||||||
}
|
}
|
||||||
pulseAnimator?.start()
|
pulseAnimator?.start()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the theme color for the game view
|
||||||
|
*/
|
||||||
|
fun setThemeColor(color: Int) {
|
||||||
|
currentThemeColor = color
|
||||||
|
blockPaint.color = color
|
||||||
|
ghostBlockPaint.color = color
|
||||||
|
glowPaint.color = color
|
||||||
|
blockGlowPaint.color = color
|
||||||
|
borderGlowPaint.color = color
|
||||||
|
pulsePaint.color = color
|
||||||
|
invalidate()
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the background color for the game view
|
||||||
|
*/
|
||||||
|
override fun setBackgroundColor(color: Int) {
|
||||||
|
super.setBackgroundColor(color)
|
||||||
|
invalidate()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,8 +46,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
|
// Theme color and background color
|
||||||
private var themeColor = Color.WHITE
|
private var themeColor = Color.WHITE
|
||||||
|
private var backgroundColor = Color.BLACK
|
||||||
|
|
||||||
// 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(
|
||||||
|
@ -110,7 +111,7 @@ class TitleScreen @JvmOverloads constructor(
|
||||||
init {
|
init {
|
||||||
// Title text settings
|
// Title text settings
|
||||||
titlePaint.apply {
|
titlePaint.apply {
|
||||||
color = Color.WHITE
|
color = themeColor
|
||||||
textSize = 120f
|
textSize = 120f
|
||||||
textAlign = Paint.Align.CENTER
|
textAlign = Paint.Align.CENTER
|
||||||
typeface = Typeface.create(Typeface.SANS_SERIF, Typeface.BOLD)
|
typeface = Typeface.create(Typeface.SANS_SERIF, Typeface.BOLD)
|
||||||
|
@ -119,7 +120,7 @@ class TitleScreen @JvmOverloads constructor(
|
||||||
|
|
||||||
// "Touch to start" text settings
|
// "Touch to start" text settings
|
||||||
promptPaint.apply {
|
promptPaint.apply {
|
||||||
color = Color.WHITE
|
color = themeColor
|
||||||
textSize = 50f
|
textSize = 50f
|
||||||
textAlign = Paint.Align.CENTER
|
textAlign = Paint.Align.CENTER
|
||||||
typeface = Typeface.create(Typeface.SANS_SERIF, Typeface.NORMAL)
|
typeface = Typeface.create(Typeface.SANS_SERIF, Typeface.NORMAL)
|
||||||
|
@ -129,7 +130,7 @@ class TitleScreen @JvmOverloads constructor(
|
||||||
|
|
||||||
// High scores text settings
|
// High scores text settings
|
||||||
highScorePaint.apply {
|
highScorePaint.apply {
|
||||||
color = Color.WHITE
|
color = themeColor
|
||||||
textSize = 70f
|
textSize = 70f
|
||||||
textAlign = Paint.Align.LEFT // Changed to LEFT alignment
|
textAlign = Paint.Align.LEFT // Changed to LEFT alignment
|
||||||
typeface = Typeface.create(Typeface.MONOSPACE, Typeface.NORMAL) // Changed to monospace
|
typeface = Typeface.create(Typeface.MONOSPACE, Typeface.NORMAL) // Changed to monospace
|
||||||
|
@ -137,16 +138,16 @@ class TitleScreen @JvmOverloads constructor(
|
||||||
alpha = 200
|
alpha = 200
|
||||||
}
|
}
|
||||||
|
|
||||||
// General paint settings for tetrominos (white)
|
// General paint settings for tetrominos
|
||||||
paint.apply {
|
paint.apply {
|
||||||
color = Color.WHITE
|
color = themeColor
|
||||||
style = Paint.Style.FILL
|
style = Paint.Style.FILL
|
||||||
isAntiAlias = true
|
isAntiAlias = true
|
||||||
}
|
}
|
||||||
|
|
||||||
// Glow paint settings for tetrominos
|
// Glow paint settings for tetrominos
|
||||||
glowPaint.apply {
|
glowPaint.apply {
|
||||||
color = Color.WHITE
|
color = themeColor
|
||||||
style = Paint.Style.FILL
|
style = Paint.Style.FILL
|
||||||
isAntiAlias = true
|
isAntiAlias = true
|
||||||
alpha = 60
|
alpha = 60
|
||||||
|
@ -184,8 +185,8 @@ class TitleScreen @JvmOverloads constructor(
|
||||||
try {
|
try {
|
||||||
super.onDraw(canvas)
|
super.onDraw(canvas)
|
||||||
|
|
||||||
// Draw background
|
// Draw background using the current background color
|
||||||
canvas.drawColor(Color.BLACK)
|
canvas.drawColor(backgroundColor)
|
||||||
|
|
||||||
// Add any pending tetrominos
|
// Add any pending tetrominos
|
||||||
tetrominos.addAll(tetrominosToAdd)
|
tetrominos.addAll(tetrominosToAdd)
|
||||||
|
@ -340,7 +341,7 @@ class TitleScreen @JvmOverloads constructor(
|
||||||
glowPaint.color = themeColor
|
glowPaint.color = themeColor
|
||||||
|
|
||||||
// Update background color
|
// Update background color
|
||||||
setBackgroundColor(when (themeId) {
|
backgroundColor = when (themeId) {
|
||||||
PlayerProgressionManager.THEME_CLASSIC -> Color.BLACK
|
PlayerProgressionManager.THEME_CLASSIC -> Color.BLACK
|
||||||
PlayerProgressionManager.THEME_NEON -> Color.parseColor("#0D0221")
|
PlayerProgressionManager.THEME_NEON -> Color.parseColor("#0D0221")
|
||||||
PlayerProgressionManager.THEME_MONOCHROME -> Color.parseColor("#1A1A1A")
|
PlayerProgressionManager.THEME_MONOCHROME -> Color.parseColor("#1A1A1A")
|
||||||
|
@ -348,8 +349,29 @@ class TitleScreen @JvmOverloads constructor(
|
||||||
PlayerProgressionManager.THEME_MINIMALIST -> Color.WHITE
|
PlayerProgressionManager.THEME_MINIMALIST -> Color.WHITE
|
||||||
PlayerProgressionManager.THEME_GALAXY -> Color.parseColor("#0B0C10")
|
PlayerProgressionManager.THEME_GALAXY -> Color.parseColor("#0B0C10")
|
||||||
else -> Color.BLACK
|
else -> Color.BLACK
|
||||||
})
|
}
|
||||||
|
|
||||||
invalidate()
|
invalidate()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the theme color for the title screen
|
||||||
|
*/
|
||||||
|
fun setThemeColor(color: Int) {
|
||||||
|
themeColor = color
|
||||||
|
titlePaint.color = color
|
||||||
|
promptPaint.color = color
|
||||||
|
highScorePaint.color = color
|
||||||
|
paint.color = color
|
||||||
|
glowPaint.color = color
|
||||||
|
invalidate()
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the background color for the title screen
|
||||||
|
*/
|
||||||
|
override fun setBackgroundColor(color: Int) {
|
||||||
|
backgroundColor = color
|
||||||
|
invalidate()
|
||||||
|
}
|
||||||
}
|
}
|
Loading…
Add table
Add a link
Reference in a new issue