radom untracked changes

This commit is contained in:
cmclark00 2025-03-27 22:28:47 -04:00
parent 3e22d1c863
commit 4812c99ae3
7 changed files with 197 additions and 33 deletions

View file

@ -9,10 +9,15 @@ import com.mintris.R
class GameMusic(private val context: Context) { class GameMusic(private val context: Context) {
private var mediaPlayer: MediaPlayer? = null private var mediaPlayer: MediaPlayer? = null
private var isEnabled = false private var isEnabled = true
private var isPrepared = false
init { init {
setupMediaPlayer() try {
setupMediaPlayer()
} catch (e: Exception) {
Log.e("GameMusic", "Error initializing: ${e.message}")
}
} }
private fun setupMediaPlayer() { private fun setupMediaPlayer() {
@ -31,42 +36,47 @@ class GameMusic(private val context: Context) {
.build() .build()
) )
} }
isPrepared = true
} }
Log.d("GameMusic", "MediaPlayer setup complete") Log.d("GameMusic", "MediaPlayer setup complete")
} catch (e: Exception) { } catch (e: Exception) {
Log.e("GameMusic", "Error setting up MediaPlayer", e) Log.e("GameMusic", "Error setting up MediaPlayer", e)
mediaPlayer = null
isPrepared = false
} }
} }
fun start() { fun start() {
try { if (isEnabled && mediaPlayer != null && isPrepared) {
Log.d("GameMusic", "Starting music playback, isEnabled: $isEnabled") try {
if (isEnabled && mediaPlayer?.isPlaying != true) { Log.d("GameMusic", "Starting music playback, isEnabled: $isEnabled")
mediaPlayer?.start() mediaPlayer?.start()
Log.d("GameMusic", "Music playback started") 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() { fun pause() {
try { try {
Log.d("GameMusic", "Pausing music playback") Log.d("GameMusic", "Pausing music playback")
mediaPlayer?.pause() if (mediaPlayer?.isPlaying == true) {
mediaPlayer?.pause()
}
} catch (e: Exception) { } catch (e: Exception) {
Log.e("GameMusic", "Error pausing music", e) Log.e("GameMusic", "Error pausing music: ${e.message}")
} }
} }
fun resume() { fun resume() {
try { if (isEnabled && mediaPlayer != null && isPrepared) {
Log.d("GameMusic", "Resuming music playback") try {
if (isEnabled && mediaPlayer?.isPlaying != true) { Log.d("GameMusic", "Resuming music playback")
mediaPlayer?.start() 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) { fun setEnabled(enabled: Boolean) {
Log.d("GameMusic", "Setting music enabled: $enabled") Log.d("GameMusic", "Setting music enabled: $enabled")
isEnabled = enabled isEnabled = enabled
if (enabled) {
start() if (!enabled && mediaPlayer?.isPlaying == true) {
} else {
pause() pause()
} else if (enabled && mediaPlayer != null && isPrepared) {
start()
} }
} }
@ -97,8 +108,9 @@ class GameMusic(private val context: Context) {
Log.d("GameMusic", "Releasing MediaPlayer") Log.d("GameMusic", "Releasing MediaPlayer")
mediaPlayer?.release() mediaPlayer?.release()
mediaPlayer = null mediaPlayer = null
isPrepared = false
} catch (e: Exception) { } catch (e: Exception) {
Log.e("GameMusic", "Error releasing MediaPlayer", e) Log.e("GameMusic", "Error releasing music: ${e.message}")
} }
} }
} }

View file

@ -286,8 +286,8 @@ class PlayerProgressionManager(context: Context) {
private const val KEY_UNLOCKED_BADGES = "unlocked_badges" private const val KEY_UNLOCKED_BADGES = "unlocked_badges"
// XP curve parameters // XP curve parameters
private const val BASE_XP = 2500.0 // Base XP for level 1 (increased from 1000) private const val BASE_XP = 5000.0 // Base XP for level 1 (increased from 2500)
private const val XP_CURVE_FACTOR = 2.0 // Exponential factor for XP curve (increased from 1.5) private const val XP_CURVE_FACTOR = 2.2 // Exponential factor for XP curve (increased from 2.0)
// XP calculation constants // XP calculation constants
private const val LEVEL_MULTIPLIER = 0.1 // 10% bonus per level private const val LEVEL_MULTIPLIER = 0.1 // 10% bonus per level

View file

@ -9,7 +9,6 @@ import android.view.LayoutInflater
import android.view.View import android.view.View
import android.view.animation.AccelerateDecelerateInterpolator import android.view.animation.AccelerateDecelerateInterpolator
import android.view.animation.OvershootInterpolator import android.view.animation.OvershootInterpolator
import android.widget.Button
import android.widget.LinearLayout import android.widget.LinearLayout
import android.widget.TextView import android.widget.TextView
import androidx.cardview.widget.CardView import androidx.cardview.widget.CardView
@ -30,7 +29,7 @@ class ProgressionScreen @JvmOverloads constructor(
private val xpGainText: TextView private val xpGainText: TextView
private val playerLevelText: TextView private val playerLevelText: TextView
private val rewardsContainer: LinearLayout private val rewardsContainer: LinearLayout
private val continueButton: Button private val continueButton: TextView
// Callback for when the player dismisses the screen // Callback for when the player dismisses the screen
var onContinue: (() -> Unit)? = null var onContinue: (() -> Unit)? = null
@ -60,7 +59,8 @@ class ProgressionScreen @JvmOverloads constructor(
fun showProgress( fun showProgress(
progressionManager: PlayerProgressionManager, progressionManager: PlayerProgressionManager,
xpGained: Long, xpGained: Long,
newRewards: List<String> newRewards: List<String>,
themeId: String = PlayerProgressionManager.THEME_CLASSIC
) { ) {
// Hide rewards container initially if there are no new rewards // Hide rewards container initially if there are no new rewards
rewardsContainer.visibility = if (newRewards.isEmpty()) View.GONE else View.INVISIBLE rewardsContainer.visibility = if (newRewards.isEmpty()) View.GONE else View.INVISIBLE
@ -96,6 +96,9 @@ class ProgressionScreen @JvmOverloads constructor(
rewardsContainer.addView(rewardCard) rewardsContainer.addView(rewardCard)
} }
// Apply theme to newly created reward cards
updateRewardCardColors(themeId)
// Show rewards with animation after XP bar animation // Show rewards with animation after XP bar animation
postDelayed({ postDelayed({
rewardsContainer.visibility = View.VISIBLE rewardsContainer.visibility = View.VISIBLE
@ -130,10 +133,12 @@ class ProgressionScreen @JvmOverloads constructor(
*/ */
private fun createRewardCard(rewardText: String): CardView { private fun createRewardCard(rewardText: String): CardView {
val card = CardView(context).apply { val card = CardView(context).apply {
radius = 0f radius = 8f
cardElevation = 0f cardElevation = 4f
useCompatPadding = true useCompatPadding = true
setCardBackgroundColor(Color.TRANSPARENT)
// Default background color - will be adjusted based on theme
setCardBackgroundColor(Color.BLACK)
layoutParams = LinearLayout.LayoutParams( layoutParams = LinearLayout.LayoutParams(
LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT,
@ -148,11 +153,145 @@ class ProgressionScreen @JvmOverloads constructor(
text = rewardText text = rewardText
setTextColor(Color.WHITE) setTextColor(Color.WHITE)
textSize = 18f textSize = 18f
setPadding(16, 12, 16, 12) setPadding(16, 16, 16, 16)
textAlignment = View.TEXT_ALIGNMENT_CENTER textAlignment = View.TEXT_ALIGNMENT_CENTER
// Add some visual styling
typeface = android.graphics.Typeface.DEFAULT_BOLD
} }
card.addView(textView) card.addView(textView)
return card return card
} }
/**
* Apply the current theme to the progression screen
*/
fun applyTheme(themeId: String) {
// Get reference to the title text
val progressionTitle = findViewById<TextView>(R.id.progression_title)
val rewardsTitle = findViewById<TextView>(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)
}
}
}
}
} }

View file

@ -156,6 +156,9 @@ class ThemeSelector @JvmOverloads constructor(
).apply { ).apply {
gravity = android.view.Gravity.CENTER 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 // Add a lock icon if the theme is locked

View file

@ -2,10 +2,12 @@
<shape xmlns:android="http://schemas.android.com/apk/res/android" <shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle"> android:shape="rectangle">
<solid android:color="#3366FF" /> <solid android:color="#444444" />
<corners android:radius="8dp" /> <corners android:radius="8dp" />
<stroke android:width="1dp" android:color="#666666" />
<padding <padding
android:left="16dp" android:left="16dp"
android:right="16dp" android:right="16dp"

View file

@ -10,7 +10,7 @@
android:id="@+id/progression_title" android:id="@+id/progression_title"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="LEVEL PROGRESS" android:text="LEVEL UP"
android:textSize="24sp" android:textSize="24sp"
android:textStyle="bold" android:textStyle="bold"
android:textColor="@color/white" android:textColor="@color/white"
@ -72,16 +72,16 @@
</ScrollView> </ScrollView>
<Button <TextView
android:id="@+id/continue_button" android:id="@+id/continue_button"
android:layout_width="200dp" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="CONTINUE" android:text="CONTINUE"
android:textSize="18sp" android:textSize="18sp"
android:layout_gravity="center" android:layout_gravity="center"
android:layout_marginTop="16dp" android:layout_marginTop="16dp"
android:layout_marginBottom="16dp" android:layout_marginBottom="16dp"
android:background="@color/transparent" android:textColor="@color/white"
android:textColor="@color/white" /> android:padding="16dp" />
</LinearLayout> </LinearLayout>

8
tatus Normal file
View file

@ -0,0 +1,8 @@
app/src/main/java/com/mintris/MainActivity.kt
app/src/main/java/com/mintris/audio/GameMusic.kt
app/src/main/java/com/mintris/model/PlayerProgressionManager.kt
app/src/main/java/com/mintris/ui/ProgressionScreen.kt
app/src/main/java/com/mintris/ui/ThemeSelector.kt
app/src/main/java/com/mintris/ui/XPProgressBar.kt
app/src/main/res/drawable/rounded_button.xml
app/src/main/res/layout/progression_screen.xml