Enhance block skin unlock logic and ensure default skin is always present. Update UI component checks for selection confirmation in BlockSkinSelector and ThemeSelector with added logging for better debugging.

This commit is contained in:
cmclark00 2025-03-31 20:17:40 -04:00
parent 915e207aca
commit 6958a864c1
3 changed files with 39 additions and 20 deletions

View file

@ -52,10 +52,11 @@ class PlayerProgressionManager(context: Context) {
unlockedThemes.add(THEME_CLASSIC) unlockedThemes.add(THEME_CLASSIC)
} }
// Add default block skin if nothing is unlocked // Always ensure default block skin is present (Level 1)
if (unlockedBlocks.isEmpty()) { unlockedBlocks.add("block_skin_1")
unlockedBlocks.add("block_skin_1")
} // Explicitly check and save all unlocks for the current level on load
checkAllUnlocksForCurrentLevel()
} }
/** /**
@ -182,11 +183,27 @@ class PlayerProgressionManager(context: Context) {
} }
} }
// Check for block skin unlocks // Check for block skin unlocks (start from skin 2 at level 7)
if (level % 7 == 0 && level <= 35) { when (level) {
val blockSkin = "block_skin_${level / 7}" 7 -> {
if (unlockedBlocks.add(blockSkin)) { if (unlockedBlocks.add("block_skin_2")) {
newRewards.add("Unlocked New Block Skin!") newRewards.add("Unlocked Neon Block Skin!")
}
}
14 -> {
if (unlockedBlocks.add("block_skin_3")) {
newRewards.add("Unlocked Retro Block Skin!")
}
}
21 -> {
if (unlockedBlocks.add("block_skin_4")) {
newRewards.add("Unlocked Minimalist Block Skin!")
}
}
28 -> {
if (unlockedBlocks.add("block_skin_5")) {
newRewards.add("Unlocked Galaxy Block Skin!")
}
} }
} }
@ -205,13 +222,12 @@ class PlayerProgressionManager(context: Context) {
if (playerLevel >= 20) unlockedThemes.add(THEME_MINIMALIST) if (playerLevel >= 20) unlockedThemes.add(THEME_MINIMALIST)
if (playerLevel >= 25) unlockedThemes.add(THEME_GALAXY) if (playerLevel >= 25) unlockedThemes.add(THEME_GALAXY)
// Check block skin unlocks // Check block skin unlocks (start from skin 2 at level 7)
for (i in 1..5) { // Skin 1 is default (added in loadProgress)
val requiredLevel = i * 7 if (playerLevel >= 7) unlockedBlocks.add("block_skin_2")
if (playerLevel >= requiredLevel) { if (playerLevel >= 14) unlockedBlocks.add("block_skin_3")
unlockedBlocks.add("block_skin_$i") if (playerLevel >= 21) unlockedBlocks.add("block_skin_4")
} if (playerLevel >= 28) unlockedBlocks.add("block_skin_5")
}
// Save any newly unlocked items // Save any newly unlocked items
saveProgress() saveProgress()
@ -269,7 +285,7 @@ class PlayerProgressionManager(context: Context) {
// Add default theme // Add default theme
unlockedThemes.add(THEME_CLASSIC) unlockedThemes.add(THEME_CLASSIC)
// Add default block skin // Add default block skin (Level 1)
unlockedBlocks.add("block_skin_1") unlockedBlocks.add("block_skin_1")
saveProgress() saveProgress()

View file

@ -311,7 +311,7 @@ class BlockSkinSelector @JvmOverloads constructor(
* Triggers the onBlockSkinSelected callback. * Triggers the onBlockSkinSelected callback.
*/ */
fun confirmSelection() { fun confirmSelection() {
if (!hasComponentFocus || focusedSkinId == null || focusedSkinId == selectedSkin) { if (focusedSkinId == null || focusedSkinId == selectedSkin) {
return // No change needed return // No change needed
} }

View file

@ -13,6 +13,7 @@ import com.mintris.R
import com.mintris.model.PlayerProgressionManager import com.mintris.model.PlayerProgressionManager
import android.animation.ValueAnimator import android.animation.ValueAnimator
import android.graphics.drawable.GradientDrawable import android.graphics.drawable.GradientDrawable
import android.util.Log
/** /**
* UI component for selecting game themes * UI component for selecting game themes
@ -213,6 +214,7 @@ class ThemeSelector @JvmOverloads constructor(
if (isUnlocked) { if (isUnlocked) {
card.setOnClickListener { card.setOnClickListener {
// Clicking directly selects the theme // Clicking directly selects the theme
Log.d("ThemeSelector", "Theme card clicked: $themeId (isUnlocked=$isUnlocked)")
focusedThemeId = themeId focusedThemeId = themeId
focusedIndex = themeIdList.indexOf(themeId) focusedIndex = themeIdList.indexOf(themeId)
confirmSelection() // Directly confirm click selection confirmSelection() // Directly confirm click selection
@ -320,8 +322,9 @@ class ThemeSelector @JvmOverloads constructor(
* Triggers the onThemeSelected callback. * Triggers the onThemeSelected callback.
*/ */
fun confirmSelection() { fun confirmSelection() {
if (!hasComponentFocus || focusedThemeId == null || focusedThemeId == selectedTheme) { Log.d("ThemeSelector", "confirmSelection called. Focused theme: $focusedThemeId")
// No change needed if component doesn't have focus, nothing is focused, if (focusedThemeId == null || focusedThemeId == selectedTheme) {
// No change needed if nothing is focused,
// or the focused item is already selected // or the focused item is already selected
return return
} }