Skip to content

Commit

Permalink
Add more themes
Browse files Browse the repository at this point in the history
  • Loading branch information
lucasnlm committed Dec 14, 2023
1 parent a797ceb commit 0c2f1ae
Show file tree
Hide file tree
Showing 14 changed files with 64 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ open class GameRenderFragment : AndroidFragmentApplication() {
navigationBarHeight = dimensionRepository.navigationBarHeight().toFloat(),
appBarWithStatusHeight = dimensionRepository.actionBarSizeWithStatus().toFloat(),
appBarHeight = appBarHeight(context),
joinAreas = themeRepository.getSkin().hasPadding,
joinAreas = themeRepository.getSkin().joinAreas,
appSkin = themeRepository.getSkin(),
)
}
Expand Down
Binary file modified gdx/src/main/assets/glass.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added gdx/src/main/assets/oldschool.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added gdx/src/main/assets/oldschool2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,8 @@ class GameApplicationListener(

minefieldStage.run {
val currentTheme = gameRenderingContext.theme
currentTheme.palette.background.run {
val backgroundColor = gameRenderingContext.appSkin.forceBackground ?: currentTheme.palette.background
backgroundColor.run {
Gdx.gl.glClearColor(red(), green(), blue(), 1f)
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT)
}
Expand Down
10 changes: 7 additions & 3 deletions gdx/src/main/java/dev/lucasnlm/antimine/gdx/GameContext.kt
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,14 @@ object GameContext {
fun refreshColors(theme: AppTheme) {
GameContext.apply {
backgroundColor =
if (theme.isDarkTheme && canTintAreas) {
theme.palette.covered.toGdxColor(0.035f * zoomLevelAlpha)
if (canTintAreas) {
if (theme.isDarkTheme) {
theme.palette.covered.toGdxColor(0.035f * zoomLevelAlpha)
} else {
theme.palette.background.toInverseBackOrWhite(0.1f * zoomLevelAlpha)
}
} else {
theme.palette.background.toInverseBackOrWhite(0.1f * zoomLevelAlpha)
Color.WHITE
}
coveredAreaColor = theme.palette.covered.toGdxColor(1.0f)
coveredMarkedAreaColor = theme.palette.covered.toGdxColor(1.0f).dim(0.6f)
Expand Down
12 changes: 9 additions & 3 deletions gdx/src/main/java/dev/lucasnlm/antimine/gdx/actors/AreaActor.kt
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,9 @@ class AreaActor(
isOdd: Boolean,
) {
val area = this.area ?: return
val backgroundOnAll = gameRenderingContext.appSkin.backgroundOnAll

if (!isOdd && !area.isCovered && GameContext.zoomLevelAlpha > 0.0f) {
if ((backgroundOnAll || !isOdd) && !area.isCovered && GameContext.zoomLevelAlpha > 0.0f) {
GameContext.gameTextures?.areaBackground?.let {
batch.drawRegion(
texture = it,
Expand Down Expand Up @@ -264,11 +265,16 @@ class AreaActor(
},
)
} else if (area.hasMine) {
val color = gameRenderingContext.theme.palette.uncovered
val color =
if (gameRenderingContext.appSkin.canTint) {
gameRenderingContext.theme.palette.covered.toInverseBackOrWhite(1.0f)
} else {
Color.WHITE
}
drawAsset(
batch = batch,
texture = it.mine,
color = color.toInverseBackOrWhite(1.0f),
color = color,
scale = BASE_ICON_SCALE,
)
}
Expand Down
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ mockk = "1.13.5"
multidex = "2.0.1"
okhttp = "4.10.0"
orchestrator = "1.4.2"
playServicesAds = "22.5.0"
playServicesAds = "22.6.0"
playServicesAuth = "20.7.0"
playServicesGames = "23.1.0"
playServicesInstantapps = "18.0.1"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ class ThemeActivity : ThemedActivity() {
if (size.widthPixels > size.heightPixels) {
2
} else {
5
4
}

val themeAdapter =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ class SkinAdapter(
} else {
setColorFilter(Color.WHITE, PorterDuff.Mode.MULTIPLY)
}
if (!skin.hasPadding) {
if (!skin.joinAreas) {
setPadding(0, 0, 0, 0)
} else {
setPadding(paddingValue, paddingValue, paddingValue, paddingValue)
Expand Down
7 changes: 5 additions & 2 deletions ui/src/main/java/dev/lucasnlm/antimine/ui/model/AppSkin.kt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package dev.lucasnlm.antimine.ui.model

import androidx.annotation.ColorInt
import androidx.annotation.DrawableRes

/**
Expand All @@ -9,7 +10,7 @@ import androidx.annotation.DrawableRes
* @property thumbnailImageRes The resource id of the skin.
* @property canTint Whether the skin can be tinted.
* @property isPremium Whether the skin is premium.
* @property hasPadding Whether the skin has padding.
* @property joinAreas Whether the skin has padding.
* @property background The background of the skin.
* @property showPadding Whether the skin should show padding.
*/
Expand All @@ -19,7 +20,9 @@ data class AppSkin(
@DrawableRes val thumbnailImageRes: Int,
val canTint: Boolean,
val isPremium: Boolean,
val hasPadding: Boolean,
val joinAreas: Boolean,
val background: Int = 0,
val showPadding: Boolean = true,
val backgroundOnAll: Boolean = false,
@ColorInt val forceBackground: Int? = null,
)
47 changes: 37 additions & 10 deletions ui/src/main/java/dev/lucasnlm/antimine/ui/repository/Skins.kt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ object Skins {
file = "standard.png",
canTint = true,
isPremium = false,
hasPadding = true,
joinAreas = true,
thumbnailImageRes = R.drawable.skin_standard,
)

Expand All @@ -20,7 +20,7 @@ object Skins {
file = "square.png",
canTint = true,
isPremium = true,
hasPadding = true,
joinAreas = true,
thumbnailImageRes = R.drawable.skin_square,
)

Expand All @@ -30,7 +30,7 @@ object Skins {
file = "square-2.png",
canTint = true,
isPremium = true,
hasPadding = true,
joinAreas = true,
thumbnailImageRes = R.drawable.skin_square_2,
)

Expand All @@ -40,7 +40,7 @@ object Skins {
file = "square-3.png",
canTint = true,
isPremium = true,
hasPadding = false,
joinAreas = false,
thumbnailImageRes = R.drawable.skin_square_3,
showPadding = false,
)
Expand All @@ -51,7 +51,7 @@ object Skins {
file = "classic.png",
canTint = true,
isPremium = true,
hasPadding = true,
joinAreas = true,
thumbnailImageRes = R.drawable.skin_classic,
background = 4,
)
Expand All @@ -62,7 +62,7 @@ object Skins {
file = "classic.png",
canTint = false,
isPremium = true,
hasPadding = true,
joinAreas = true,
thumbnailImageRes = R.drawable.skin_classic,
background = 4,
)
Expand All @@ -73,7 +73,7 @@ object Skins {
file = "glass.png",
canTint = true,
isPremium = true,
hasPadding = true,
joinAreas = true,
thumbnailImageRes = R.drawable.skin_glass_2,
)

Expand All @@ -83,7 +83,7 @@ object Skins {
file = "stone.png",
canTint = false,
isPremium = true,
hasPadding = true,
joinAreas = true,
thumbnailImageRes = R.drawable.skin_stone,
background = 4,
)
Expand All @@ -94,7 +94,7 @@ object Skins {
file = "stone-2.png",
canTint = true,
isPremium = true,
hasPadding = true,
joinAreas = true,
thumbnailImageRes = R.drawable.skin_stone_2,
background = 4,
)
Expand All @@ -105,11 +105,36 @@ object Skins {
file = "standard.png",
canTint = true,
isPremium = true,
hasPadding = false,
joinAreas = false,
thumbnailImageRes = R.drawable.skin_standard_no_connection,
showPadding = false,
)

private fun oldschool() =
AppSkin(
id = 10,
file = "oldschool.png",
canTint = true,
isPremium = true,
joinAreas = false,
backgroundOnAll = true,
thumbnailImageRes = R.drawable.oldschool,
showPadding = true,
)

private fun oldschool2() =
AppSkin(
id = 11,
file = "oldschool2.png",
canTint = false,
isPremium = true,
joinAreas = false,
backgroundOnAll = true,
thumbnailImageRes = R.drawable.oldschool2,
forceBackground = 0x7f8773,
showPadding = true,
)

fun getAllSkins() =
listOf(
default(),
Expand All @@ -122,5 +147,7 @@ object Skins {
square3(),
stone2(),
defaultNoJoin(),
oldschool(),
oldschool2(),
)
}
Binary file added ui/src/main/res/drawable/oldschool.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added ui/src/main/res/drawable/oldschool2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 0c2f1ae

Please sign in to comment.