mirror of
https://github.com/cmclark00/mintris.git
synced 2025-05-17 21:05:20 +01:00
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:
parent
915e207aca
commit
6958a864c1
3 changed files with 39 additions and 20 deletions
|
@ -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()
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue