diff --git a/app/src/main/java/com/mintris/audio/GameMusic.kt b/app/src/main/java/com/mintris/audio/GameMusic.kt index b455666..fbb8abf 100644 --- a/app/src/main/java/com/mintris/audio/GameMusic.kt +++ b/app/src/main/java/com/mintris/audio/GameMusic.kt @@ -9,10 +9,15 @@ import com.mintris.R class GameMusic(private val context: Context) { private var mediaPlayer: MediaPlayer? = null - private var isEnabled = false + private var isEnabled = true + private var isPrepared = false init { - setupMediaPlayer() + try { + setupMediaPlayer() + } catch (e: Exception) { + Log.e("GameMusic", "Error initializing: ${e.message}") + } } private fun setupMediaPlayer() { @@ -31,42 +36,47 @@ class GameMusic(private val context: Context) { .build() ) } + isPrepared = true } Log.d("GameMusic", "MediaPlayer setup complete") } catch (e: Exception) { Log.e("GameMusic", "Error setting up MediaPlayer", e) + mediaPlayer = null + isPrepared = false } } fun start() { - try { - Log.d("GameMusic", "Starting music playback, isEnabled: $isEnabled") - if (isEnabled && mediaPlayer?.isPlaying != true) { + if (isEnabled && mediaPlayer != null && isPrepared) { + try { + Log.d("GameMusic", "Starting music playback, isEnabled: $isEnabled") mediaPlayer?.start() Log.d("GameMusic", "Music playback started") + } catch (e: Exception) { + Log.e("GameMusic", "Error starting music: ${e.message}") } - } catch (e: Exception) { - Log.e("GameMusic", "Error starting music", e) } } fun pause() { try { Log.d("GameMusic", "Pausing music playback") - mediaPlayer?.pause() + if (mediaPlayer?.isPlaying == true) { + mediaPlayer?.pause() + } } catch (e: Exception) { - Log.e("GameMusic", "Error pausing music", e) + Log.e("GameMusic", "Error pausing music: ${e.message}") } } fun resume() { - try { - Log.d("GameMusic", "Resuming music playback") - if (isEnabled && mediaPlayer?.isPlaying != true) { + if (isEnabled && mediaPlayer != null && isPrepared) { + try { + Log.d("GameMusic", "Resuming music playback") mediaPlayer?.start() + } catch (e: Exception) { + Log.e("GameMusic", "Error resuming music: ${e.message}") } - } catch (e: Exception) { - Log.e("GameMusic", "Error resuming music", e) } } @@ -83,10 +93,11 @@ class GameMusic(private val context: Context) { fun setEnabled(enabled: Boolean) { Log.d("GameMusic", "Setting music enabled: $enabled") isEnabled = enabled - if (enabled) { - start() - } else { + + if (!enabled && mediaPlayer?.isPlaying == true) { pause() + } else if (enabled && mediaPlayer != null && isPrepared) { + start() } } @@ -97,8 +108,9 @@ class GameMusic(private val context: Context) { Log.d("GameMusic", "Releasing MediaPlayer") mediaPlayer?.release() mediaPlayer = null + isPrepared = false } catch (e: Exception) { - Log.e("GameMusic", "Error releasing MediaPlayer", e) + Log.e("GameMusic", "Error releasing music: ${e.message}") } } } \ No newline at end of file diff --git a/app/src/main/java/com/mintris/model/PlayerProgressionManager.kt b/app/src/main/java/com/mintris/model/PlayerProgressionManager.kt index 23921f2..d25e9fd 100644 --- a/app/src/main/java/com/mintris/model/PlayerProgressionManager.kt +++ b/app/src/main/java/com/mintris/model/PlayerProgressionManager.kt @@ -286,8 +286,8 @@ class PlayerProgressionManager(context: Context) { private const val KEY_UNLOCKED_BADGES = "unlocked_badges" // XP curve parameters - private const val BASE_XP = 2500.0 // Base XP for level 1 (increased from 1000) - private const val XP_CURVE_FACTOR = 2.0 // Exponential factor for XP curve (increased from 1.5) + private const val BASE_XP = 5000.0 // Base XP for level 1 (increased from 2500) + private const val XP_CURVE_FACTOR = 2.2 // Exponential factor for XP curve (increased from 2.0) // XP calculation constants private const val LEVEL_MULTIPLIER = 0.1 // 10% bonus per level diff --git a/app/src/main/java/com/mintris/ui/ProgressionScreen.kt b/app/src/main/java/com/mintris/ui/ProgressionScreen.kt index c10ac84..bc67809 100644 --- a/app/src/main/java/com/mintris/ui/ProgressionScreen.kt +++ b/app/src/main/java/com/mintris/ui/ProgressionScreen.kt @@ -9,7 +9,6 @@ import android.view.LayoutInflater import android.view.View import android.view.animation.AccelerateDecelerateInterpolator import android.view.animation.OvershootInterpolator -import android.widget.Button import android.widget.LinearLayout import android.widget.TextView import androidx.cardview.widget.CardView @@ -30,7 +29,7 @@ class ProgressionScreen @JvmOverloads constructor( private val xpGainText: TextView private val playerLevelText: TextView private val rewardsContainer: LinearLayout - private val continueButton: Button + private val continueButton: TextView // Callback for when the player dismisses the screen var onContinue: (() -> Unit)? = null @@ -60,7 +59,8 @@ class ProgressionScreen @JvmOverloads constructor( fun showProgress( progressionManager: PlayerProgressionManager, xpGained: Long, - newRewards: List + newRewards: List, + themeId: String = PlayerProgressionManager.THEME_CLASSIC ) { // Hide rewards container initially if there are no new rewards rewardsContainer.visibility = if (newRewards.isEmpty()) View.GONE else View.INVISIBLE @@ -96,6 +96,9 @@ class ProgressionScreen @JvmOverloads constructor( rewardsContainer.addView(rewardCard) } + // Apply theme to newly created reward cards + updateRewardCardColors(themeId) + // Show rewards with animation after XP bar animation postDelayed({ rewardsContainer.visibility = View.VISIBLE @@ -130,10 +133,12 @@ class ProgressionScreen @JvmOverloads constructor( */ private fun createRewardCard(rewardText: String): CardView { val card = CardView(context).apply { - radius = 0f - cardElevation = 0f + radius = 8f + cardElevation = 4f useCompatPadding = true - setCardBackgroundColor(Color.TRANSPARENT) + + // Default background color - will be adjusted based on theme + setCardBackgroundColor(Color.BLACK) layoutParams = LinearLayout.LayoutParams( LinearLayout.LayoutParams.MATCH_PARENT, @@ -148,11 +153,145 @@ class ProgressionScreen @JvmOverloads constructor( text = rewardText setTextColor(Color.WHITE) textSize = 18f - setPadding(16, 12, 16, 12) + setPadding(16, 16, 16, 16) textAlignment = View.TEXT_ALIGNMENT_CENTER + // Add some visual styling + typeface = android.graphics.Typeface.DEFAULT_BOLD } card.addView(textView) return card } + + /** + * Apply the current theme to the progression screen + */ + fun applyTheme(themeId: String) { + // Get reference to the title text + val progressionTitle = findViewById(R.id.progression_title) + val rewardsTitle = findViewById(R.id.rewards_title) + + // Theme color for XP progress bar level badge + val xpThemeColor: Int + + // Apply theme colors based on theme ID + when (themeId) { + PlayerProgressionManager.THEME_CLASSIC -> { + // Default black theme + setBackgroundColor(Color.BLACK) + progressionTitle.setTextColor(Color.WHITE) + playerLevelText.setTextColor(Color.WHITE) + xpGainText.setTextColor(Color.WHITE) + continueButton.setTextColor(Color.WHITE) + rewardsTitle.setTextColor(Color.WHITE) + xpThemeColor = Color.WHITE + } + PlayerProgressionManager.THEME_NEON -> { + // Neon theme with dark purple background + setBackgroundColor(Color.parseColor("#0D0221")) + progressionTitle.setTextColor(Color.parseColor("#FF00FF")) + playerLevelText.setTextColor(Color.parseColor("#FF00FF")) + xpGainText.setTextColor(Color.WHITE) + continueButton.setTextColor(Color.parseColor("#FF00FF")) + rewardsTitle.setTextColor(Color.WHITE) + xpThemeColor = Color.parseColor("#FF00FF") + } + PlayerProgressionManager.THEME_MONOCHROME -> { + // Monochrome dark gray + setBackgroundColor(Color.parseColor("#1A1A1A")) + progressionTitle.setTextColor(Color.LTGRAY) + playerLevelText.setTextColor(Color.LTGRAY) + xpGainText.setTextColor(Color.WHITE) + continueButton.setTextColor(Color.LTGRAY) + rewardsTitle.setTextColor(Color.WHITE) + xpThemeColor = Color.LTGRAY + } + PlayerProgressionManager.THEME_RETRO -> { + // Retro arcade theme + setBackgroundColor(Color.parseColor("#3F2832")) + progressionTitle.setTextColor(Color.parseColor("#FF5A5F")) + playerLevelText.setTextColor(Color.parseColor("#FF5A5F")) + xpGainText.setTextColor(Color.WHITE) + continueButton.setTextColor(Color.parseColor("#FF5A5F")) + rewardsTitle.setTextColor(Color.WHITE) + xpThemeColor = Color.parseColor("#FF5A5F") + } + PlayerProgressionManager.THEME_MINIMALIST -> { + // Minimalist white theme + setBackgroundColor(Color.WHITE) + progressionTitle.setTextColor(Color.BLACK) + playerLevelText.setTextColor(Color.BLACK) + xpGainText.setTextColor(Color.BLACK) + continueButton.setTextColor(Color.BLACK) + rewardsTitle.setTextColor(Color.BLACK) + xpThemeColor = Color.BLACK + } + PlayerProgressionManager.THEME_GALAXY -> { + // Galaxy dark blue theme + setBackgroundColor(Color.parseColor("#0B0C10")) + progressionTitle.setTextColor(Color.parseColor("#66FCF1")) + playerLevelText.setTextColor(Color.parseColor("#66FCF1")) + xpGainText.setTextColor(Color.WHITE) + continueButton.setTextColor(Color.parseColor("#66FCF1")) + rewardsTitle.setTextColor(Color.WHITE) + xpThemeColor = Color.parseColor("#66FCF1") + } + else -> { + // Default fallback + setBackgroundColor(Color.BLACK) + progressionTitle.setTextColor(Color.WHITE) + playerLevelText.setTextColor(Color.WHITE) + xpGainText.setTextColor(Color.WHITE) + continueButton.setTextColor(Color.WHITE) + rewardsTitle.setTextColor(Color.WHITE) + xpThemeColor = Color.WHITE + } + } + + // Set theme color on XP progress bar + xpProgressBar.setThemeColor(xpThemeColor) + + // Update card colors for any existing reward cards + updateRewardCardColors(themeId) + } + + /** + * Update colors of existing reward cards to match the theme + */ + private fun updateRewardCardColors(themeId: String) { + // Color for card backgrounds based on theme + val cardBackgroundColor = 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 + } + + // Text color for rewards based on theme + val rewardTextColor = 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 each card in the rewards container + for (i in 0 until rewardsContainer.childCount) { + val card = rewardsContainer.getChildAt(i) as? CardView + card?.let { + it.setCardBackgroundColor(cardBackgroundColor) + + // Update text color in the card + if (it.childCount > 0 && it.getChildAt(0) is TextView) { + (it.getChildAt(0) as TextView).setTextColor(rewardTextColor) + } + } + } + } } \ No newline at end of file diff --git a/app/src/main/java/com/mintris/ui/ThemeSelector.kt b/app/src/main/java/com/mintris/ui/ThemeSelector.kt index 0803524..bb5a831 100644 --- a/app/src/main/java/com/mintris/ui/ThemeSelector.kt +++ b/app/src/main/java/com/mintris/ui/ThemeSelector.kt @@ -156,6 +156,9 @@ class ThemeSelector @JvmOverloads constructor( ).apply { gravity = android.view.Gravity.CENTER } + // Make text bold and more visible for better readability + typeface = android.graphics.Typeface.DEFAULT_BOLD + setShadowLayer(3f, 1f, 1f, Color.BLACK) } // Add a lock icon if the theme is locked diff --git a/app/src/main/res/drawable/rounded_button.xml b/app/src/main/res/drawable/rounded_button.xml index 4c016aa..9553581 100644 --- a/app/src/main/res/drawable/rounded_button.xml +++ b/app/src/main/res/drawable/rounded_button.xml @@ -2,10 +2,12 @@ - + + + -