diff --git a/app/src/main/java/com/mintris/MainActivity.kt b/app/src/main/java/com/mintris/MainActivity.kt index d1d2b61..ce1e986 100644 --- a/app/src/main/java/com/mintris/MainActivity.kt +++ b/app/src/main/java/com/mintris/MainActivity.kt @@ -322,26 +322,26 @@ class MainActivity : AppCompatActivity() { // Show progression screen first with XP animation binding.gameOverContainer.visibility = View.GONE progressionScreen.visibility = View.VISIBLE - progressionScreen.showProgress(progressionManager, xpGained, newRewards) + progressionScreen.applyTheme(currentTheme) + progressionScreen.showProgress(progressionManager, xpGained, newRewards, currentTheme) // Override the continue button behavior if high score needs to be shown val originalOnContinue = progressionScreen.onContinue - // Check if this is a high score - if (highScoreManager.isHighScore(score)) { - showingHighScore = true - - // Set a special onContinue that launches high score entry - progressionScreen.onContinue = { - val intent = Intent(this, HighScoreEntryActivity::class.java).apply { - putExtra("score", score) - putExtra("level", currentLevel) - } - // Use the launcher instead of startActivity - highScoreEntryLauncher.launch(intent) + progressionScreen.onContinue = { + // If this is a high score, show high score entry screen + if (highScoreManager.isHighScore(score)) { + showingHighScore = true + showHighScoreEntry(score) + } else { + // Just show game over screen normally + progressionScreen.visibility = View.GONE + binding.gameOverContainer.visibility = View.VISIBLE - // Restore original onContinue for next time - progressionScreen.onContinue = originalOnContinue + // Update theme selector if new themes were unlocked + if (newRewards.any { it.contains("Theme") }) { + updateThemeSelector() + } } } @@ -349,6 +349,18 @@ class MainActivity : AppCompatActivity() { vibrate(VibrationEffect.EFFECT_DOUBLE_CLICK) } + /** + * Show high score entry screen + */ + private fun showHighScoreEntry(score: Int) { + val intent = Intent(this, HighScoreEntryActivity::class.java).apply { + putExtra("score", score) + putExtra("level", currentLevel) + } + // Use the launcher instead of startActivity + highScoreEntryLauncher.launch(intent) + } + /** * Hide game over screen */ @@ -365,6 +377,10 @@ class MainActivity : AppCompatActivity() { binding.pauseStartButton.visibility = View.VISIBLE binding.resumeButton.visibility = View.GONE + // Update level badge + binding.pauseLevelBadge.setLevel(progressionManager.getPlayerLevel()) + binding.pauseLevelBadge.setThemeColor(getThemeColor(currentTheme)) + // Update theme selector updateThemeSelector() } @@ -490,8 +506,8 @@ class MainActivity : AppCompatActivity() { */ private fun updateThemeSelector() { binding.themeSelector.updateThemes( - progressionManager.getUnlockedThemes(), - currentTheme + unlockedThemes = progressionManager.getUnlockedThemes(), + currentTheme = currentTheme ) } @@ -540,6 +556,11 @@ class MainActivity : AppCompatActivity() { } } + // Apply theme to progression screen if it's visible and initialized + if (::progressionScreen.isInitialized && progressionScreen.visibility == View.VISIBLE) { + progressionScreen.applyTheme(themeId) + } + // Update the game view to apply theme gameView.invalidate() } @@ -559,4 +580,19 @@ class MainActivity : AppCompatActivity() { val prefs = getSharedPreferences("mintris_settings", Context.MODE_PRIVATE) return prefs.getString("selected_theme", PlayerProgressionManager.THEME_CLASSIC) ?: PlayerProgressionManager.THEME_CLASSIC } + + /** + * Get the appropriate color for the current theme + */ + private fun getThemeColor(themeId: String): Int { + return 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 + } + } } \ No newline at end of file diff --git a/app/src/main/java/com/mintris/ui/LevelBadge.kt b/app/src/main/java/com/mintris/ui/LevelBadge.kt new file mode 100644 index 0000000..67665e4 --- /dev/null +++ b/app/src/main/java/com/mintris/ui/LevelBadge.kt @@ -0,0 +1,67 @@ +package com.mintris.ui + +import android.content.Context +import android.graphics.Canvas +import android.graphics.Color +import android.graphics.Paint +import android.util.AttributeSet +import android.view.View + +/** + * Custom view for displaying the player's level in a fancy badge style + */ +class LevelBadge @JvmOverloads constructor( + context: Context, + attrs: AttributeSet? = null, + defStyleAttr: Int = 0 +) : View(context, attrs, defStyleAttr) { + + private val badgePaint = Paint().apply { + color = Color.WHITE + isAntiAlias = true + } + + private val textPaint = Paint().apply { + color = Color.BLACK + isAntiAlias = true + textAlign = Paint.Align.CENTER + textSize = 48f + isFakeBoldText = true + } + + private var level = 1 + private var themeColor = Color.WHITE + + fun setLevel(newLevel: Int) { + level = newLevel + invalidate() + } + + fun setThemeColor(color: Int) { + themeColor = color + badgePaint.color = color + invalidate() + } + + override fun onSizeChanged(w: Int, h: Int, oldw: Int, oldh: Int) { + super.onSizeChanged(w, h, oldw, oldh) + // Adjust text size based on view size + textPaint.textSize = h * 0.6f + } + + override fun onDraw(canvas: Canvas) { + super.onDraw(canvas) + + // Draw badge circle + val radius = (width.coerceAtMost(height) / 2f) * 0.9f + canvas.drawCircle(width / 2f, height / 2f, radius, badgePaint) + + // Draw level text + canvas.drawText( + level.toString(), + width / 2f, + height / 2f + (textPaint.textSize / 3), + textPaint + ) + } +} \ No newline at end of file diff --git a/app/src/main/java/com/mintris/ui/XPProgressBar.kt b/app/src/main/java/com/mintris/ui/XPProgressBar.kt index 33d4546..c50ab6d 100644 --- a/app/src/main/java/com/mintris/ui/XPProgressBar.kt +++ b/app/src/main/java/com/mintris/ui/XPProgressBar.kt @@ -23,21 +23,15 @@ class XPProgressBar @JvmOverloads constructor( // Paints for drawing private val backgroundPaint = Paint().apply { - color = Color.parseColor("#383838") + color = Color.BLACK isAntiAlias = true } private val progressPaint = Paint().apply { - color = Color.parseColor("#50C878") // Emerald green + color = Color.WHITE isAntiAlias = true } - private val progressGlowPaint = Paint().apply { - color = Color.parseColor("#70F098") // Lighter emerald for glow - isAntiAlias = true - setShadowLayer(10f, 0f, 0f, Color.parseColor("#50C878")) - } - private val textPaint = Paint().apply { color = Color.WHITE isAntiAlias = true @@ -46,7 +40,7 @@ class XPProgressBar @JvmOverloads constructor( } private val levelBadgePaint = Paint().apply { - color = Color.parseColor("#FFD700") // Gold color for level badge + color = Color.WHITE isAntiAlias = true } @@ -77,6 +71,9 @@ class XPProgressBar @JvmOverloads constructor( private var isLevelingUp = false private var levelUpAnimator: ValueAnimator? = null private var levelBadgeScale = 1f + + // Theme-related properties + private var themeColor = Color.WHITE /** * Set the player's current level and XP values @@ -96,6 +93,15 @@ class XPProgressBar @JvmOverloads constructor( invalidate() } + + /** + * Set theme color for elements + */ + fun setThemeColor(color: Int) { + themeColor = color + levelBadgePaint.color = color + invalidate() + } /** * Animate adding XP to the bar @@ -173,8 +179,9 @@ class XPProgressBar @JvmOverloads constructor( // Update progress bar dimensions based on view size val verticalPadding = h * 0.2f + // Increase left margin to prevent level badge from being cut off backgroundRect.set( - h * 0.5f, // Left margin = height/2 (for level badge) + h * 0.6f, // Increased from 0.5f to 0.6f for more space verticalPadding, w - paddingRight.toFloat(), h - verticalPadding @@ -188,9 +195,9 @@ class XPProgressBar @JvmOverloads constructor( override fun onDraw(canvas: Canvas) { super.onDraw(canvas) - // Draw level badge + // Draw level badge with adjusted position val badgeRadius = height * 0.3f * levelBadgeScale - val badgeCenterX = height * 0.25f + val badgeCenterX = height * 0.35f // Adjusted from 0.25f to 0.35f to match new position val badgeCenterY = height * 0.5f canvas.drawCircle(badgeCenterX, badgeCenterY, badgeRadius, levelBadgePaint) @@ -214,9 +221,6 @@ class XPProgressBar @JvmOverloads constructor( // Only draw if there is progress to show if (progressRect.width() > 0) { - // Draw glow effect first - canvas.drawRoundRect(progressRect, cornerRadius, cornerRadius, progressGlowPaint) - // Draw actual progress bar canvas.drawRoundRect(progressRect, cornerRadius, cornerRadius, progressPaint) } diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml index 0c9a1ef..e978405 100644 --- a/app/src/main/res/layout/activity_main.xml +++ b/app/src/main/res/layout/activity_main.xml @@ -255,14 +255,28 @@ android:orientation="vertical" android:visibility="gone"> - + android:orientation="horizontal" + android:gravity="center" + android:layout_marginBottom="32dp"> + + + + + +