From 6958a864c131c938d6aefb0d1f09856f56fdcd6c Mon Sep 17 00:00:00 2001 From: cmclark00 Date: Mon, 31 Mar 2025 20:17:40 -0400 Subject: [PATCH] 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. --- .../mintris/model/PlayerProgressionManager.kt | 50 ++++++++++++------- .../java/com/mintris/ui/BlockSkinSelector.kt | 2 +- .../main/java/com/mintris/ui/ThemeSelector.kt | 7 ++- 3 files changed, 39 insertions(+), 20 deletions(-) diff --git a/app/src/main/java/com/mintris/model/PlayerProgressionManager.kt b/app/src/main/java/com/mintris/model/PlayerProgressionManager.kt index 0ddc2a7..a395bb7 100644 --- a/app/src/main/java/com/mintris/model/PlayerProgressionManager.kt +++ b/app/src/main/java/com/mintris/model/PlayerProgressionManager.kt @@ -52,10 +52,11 @@ class PlayerProgressionManager(context: Context) { unlockedThemes.add(THEME_CLASSIC) } - // Add default block skin if nothing is unlocked - if (unlockedBlocks.isEmpty()) { - unlockedBlocks.add("block_skin_1") - } + // Always ensure default block skin is present (Level 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 - if (level % 7 == 0 && level <= 35) { - val blockSkin = "block_skin_${level / 7}" - if (unlockedBlocks.add(blockSkin)) { - newRewards.add("Unlocked New Block Skin!") + // Check for block skin unlocks (start from skin 2 at level 7) + when (level) { + 7 -> { + if (unlockedBlocks.add("block_skin_2")) { + 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 >= 25) unlockedThemes.add(THEME_GALAXY) - // Check block skin unlocks - for (i in 1..5) { - val requiredLevel = i * 7 - if (playerLevel >= requiredLevel) { - unlockedBlocks.add("block_skin_$i") - } - } + // Check block skin unlocks (start from skin 2 at level 7) + // Skin 1 is default (added in loadProgress) + if (playerLevel >= 7) unlockedBlocks.add("block_skin_2") + if (playerLevel >= 14) unlockedBlocks.add("block_skin_3") + if (playerLevel >= 21) unlockedBlocks.add("block_skin_4") + if (playerLevel >= 28) unlockedBlocks.add("block_skin_5") // Save any newly unlocked items saveProgress() @@ -269,7 +285,7 @@ class PlayerProgressionManager(context: Context) { // Add default theme unlockedThemes.add(THEME_CLASSIC) - // Add default block skin + // Add default block skin (Level 1) unlockedBlocks.add("block_skin_1") saveProgress() diff --git a/app/src/main/java/com/mintris/ui/BlockSkinSelector.kt b/app/src/main/java/com/mintris/ui/BlockSkinSelector.kt index cf3bb9e..d2c7d35 100644 --- a/app/src/main/java/com/mintris/ui/BlockSkinSelector.kt +++ b/app/src/main/java/com/mintris/ui/BlockSkinSelector.kt @@ -311,7 +311,7 @@ class BlockSkinSelector @JvmOverloads constructor( * Triggers the onBlockSkinSelected callback. */ fun confirmSelection() { - if (!hasComponentFocus || focusedSkinId == null || focusedSkinId == selectedSkin) { + if (focusedSkinId == null || focusedSkinId == selectedSkin) { return // No change needed } diff --git a/app/src/main/java/com/mintris/ui/ThemeSelector.kt b/app/src/main/java/com/mintris/ui/ThemeSelector.kt index 81fe9b0..ece7cd4 100644 --- a/app/src/main/java/com/mintris/ui/ThemeSelector.kt +++ b/app/src/main/java/com/mintris/ui/ThemeSelector.kt @@ -13,6 +13,7 @@ import com.mintris.R import com.mintris.model.PlayerProgressionManager import android.animation.ValueAnimator import android.graphics.drawable.GradientDrawable +import android.util.Log /** * UI component for selecting game themes @@ -213,6 +214,7 @@ class ThemeSelector @JvmOverloads constructor( if (isUnlocked) { card.setOnClickListener { // Clicking directly selects the theme + Log.d("ThemeSelector", "Theme card clicked: $themeId (isUnlocked=$isUnlocked)") focusedThemeId = themeId focusedIndex = themeIdList.indexOf(themeId) confirmSelection() // Directly confirm click selection @@ -320,8 +322,9 @@ class ThemeSelector @JvmOverloads constructor( * Triggers the onThemeSelected callback. */ fun confirmSelection() { - if (!hasComponentFocus || focusedThemeId == null || focusedThemeId == selectedTheme) { - // No change needed if component doesn't have focus, nothing is focused, + Log.d("ThemeSelector", "confirmSelection called. Focused theme: $focusedThemeId") + if (focusedThemeId == null || focusedThemeId == selectedTheme) { + // No change needed if nothing is focused, // or the focused item is already selected return }