mirror of
https://github.com/cmclark00/mintris.git
synced 2025-05-18 17:35:21 +01:00
Fix: Correct namespace and applicationId in app build.gradle
This commit is contained in:
parent
5cf8aec02a
commit
5ace9d7fc5
25 changed files with 4 additions and 4 deletions
67
app/src/main/java/com/pixelmintdrop/ui/LevelBadge.kt
Normal file
67
app/src/main/java/com/pixelmintdrop/ui/LevelBadge.kt
Normal file
|
@ -0,0 +1,67 @@
|
|||
package com.mintris.ui
|
||||
|
||||
import android.content.Context
|
||||
import android.graphics.Canvas
|
||||
import android.graphics.Color
|
||||
import android.graphics.Paint
|
||||
import android.util.AttributeSet
|
||||
import android.view.View
|
||||
|
||||
/**
|
||||
* Custom view for displaying the player's level in a fancy badge style
|
||||
*/
|
||||
class LevelBadge @JvmOverloads constructor(
|
||||
context: Context,
|
||||
attrs: AttributeSet? = null,
|
||||
defStyleAttr: Int = 0
|
||||
) : View(context, attrs, defStyleAttr) {
|
||||
|
||||
private val badgePaint = Paint().apply {
|
||||
color = Color.WHITE
|
||||
isAntiAlias = true
|
||||
}
|
||||
|
||||
private val textPaint = Paint().apply {
|
||||
color = Color.BLACK
|
||||
isAntiAlias = true
|
||||
textAlign = Paint.Align.CENTER
|
||||
textSize = 48f
|
||||
isFakeBoldText = true
|
||||
}
|
||||
|
||||
private var level = 1
|
||||
private var themeColor = Color.WHITE
|
||||
|
||||
fun setLevel(newLevel: Int) {
|
||||
level = newLevel
|
||||
invalidate()
|
||||
}
|
||||
|
||||
fun setThemeColor(color: Int) {
|
||||
themeColor = color
|
||||
badgePaint.color = color
|
||||
invalidate()
|
||||
}
|
||||
|
||||
override fun onSizeChanged(w: Int, h: Int, oldw: Int, oldh: Int) {
|
||||
super.onSizeChanged(w, h, oldw, oldh)
|
||||
// Adjust text size based on view size
|
||||
textPaint.textSize = h * 0.6f
|
||||
}
|
||||
|
||||
override fun onDraw(canvas: Canvas) {
|
||||
super.onDraw(canvas)
|
||||
|
||||
// Draw badge circle
|
||||
val radius = (width.coerceAtMost(height) / 2f) * 0.9f
|
||||
canvas.drawCircle(width / 2f, height / 2f, radius, badgePaint)
|
||||
|
||||
// Draw level text
|
||||
canvas.drawText(
|
||||
level.toString(),
|
||||
width / 2f,
|
||||
height / 2f + (textPaint.textSize / 3),
|
||||
textPaint
|
||||
)
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue