|
|
|
|
@ -10,6 +10,7 @@ import net.pokeranalytics.android.model.handhistory.Position |
|
|
|
|
import net.pokeranalytics.android.model.handhistory.Street |
|
|
|
|
import net.pokeranalytics.android.model.realm.handhistory.Card |
|
|
|
|
import net.pokeranalytics.android.ui.modules.handhistory.model.ComputedAction |
|
|
|
|
import net.pokeranalytics.android.util.RANDOM_PLAYER |
|
|
|
|
import net.pokeranalytics.android.util.extensions.formatted |
|
|
|
|
import timber.log.Timber |
|
|
|
|
|
|
|
|
|
@ -19,6 +20,7 @@ class TableDrawer(bitmap: Bitmap) : Canvas(bitmap) { |
|
|
|
|
|
|
|
|
|
private const val tableStrokeWidth = 30f |
|
|
|
|
private const val playerStrokeWidth = 8f |
|
|
|
|
private const val cardStrokeWidth = 6f |
|
|
|
|
|
|
|
|
|
private val strokePaint = Paint() |
|
|
|
|
private val fillPaint = Paint() |
|
|
|
|
@ -26,6 +28,7 @@ class TableDrawer(bitmap: Bitmap) : Canvas(bitmap) { |
|
|
|
|
private val tablePaint = Paint() |
|
|
|
|
private val textPaint = Paint() |
|
|
|
|
private val cardTextPaint = Paint() |
|
|
|
|
private val cardStrokePaint = Paint() |
|
|
|
|
|
|
|
|
|
fun configurePaints(context: Context) { |
|
|
|
|
tablePaint.isAntiAlias = true |
|
|
|
|
@ -37,6 +40,10 @@ class TableDrawer(bitmap: Bitmap) : Canvas(bitmap) { |
|
|
|
|
strokePaint.style = Paint.Style.STROKE |
|
|
|
|
strokePaint.strokeWidth = playerStrokeWidth |
|
|
|
|
|
|
|
|
|
cardStrokePaint.isAntiAlias = true |
|
|
|
|
cardStrokePaint.style = Paint.Style.STROKE |
|
|
|
|
cardStrokePaint.strokeWidth = cardStrokeWidth |
|
|
|
|
|
|
|
|
|
fillPaint.isAntiAlias = true |
|
|
|
|
|
|
|
|
|
textPaint.color = context.getColor(R.color.white) |
|
|
|
|
@ -60,6 +67,7 @@ class TableDrawer(bitmap: Bitmap) : Canvas(bitmap) { |
|
|
|
|
val hh = config.handHistory |
|
|
|
|
val positions = Position.positionsPerPlayers(hh.numberOfPlayers) |
|
|
|
|
for (i in 0 until hh.numberOfPlayers) { |
|
|
|
|
val isHero = (hh.heroIndex == i) |
|
|
|
|
Timber.d("Getting player $i setup ") |
|
|
|
|
val playerSetup = hh.playerSetupForPosition(i) |
|
|
|
|
|
|
|
|
|
@ -76,6 +84,9 @@ class TableDrawer(bitmap: Bitmap) : Canvas(bitmap) { |
|
|
|
|
val circle = config.circleForPlayer(i) |
|
|
|
|
canvas.drawCircle(circle.x, circle.y, circle.radius, this.fillPaint) |
|
|
|
|
canvas.drawCircle(circle.x, circle.y, circle.radius, this.strokePaint) |
|
|
|
|
val playerInitials = playerSetup?.player?.initials ?: RANDOM_PLAYER |
|
|
|
|
this.textPaint.textSize = circle.radius |
|
|
|
|
canvas.drawText(playerInitials, circle.x, circle.y + circle.radius * 0.4f, this.textPaint) |
|
|
|
|
|
|
|
|
|
// Player name |
|
|
|
|
val name = playerSetup?.player?.name ?: positions.elementAt(i).value |
|
|
|
|
@ -92,26 +103,37 @@ class TableDrawer(bitmap: Bitmap) : Canvas(bitmap) { |
|
|
|
|
|
|
|
|
|
// Dealer button |
|
|
|
|
val dealerCircle = config.dealerCircle |
|
|
|
|
fillPaint.color = context.getColor(R.color.red) |
|
|
|
|
this.fillPaint.color = context.getColor(R.color.red) |
|
|
|
|
canvas.drawCircle(dealerCircle.x, dealerCircle.y, dealerCircle.radius, fillPaint) |
|
|
|
|
strokePaint.color = context.getColor(R.color.white) |
|
|
|
|
this.strokePaint.color = context.getColor(R.color.white) |
|
|
|
|
canvas.drawCircle(dealerCircle.x, dealerCircle.y, dealerCircle.radius, strokePaint) |
|
|
|
|
canvas.drawText("D", dealerCircle.x, dealerCircle.y + this.textPaint.textSize / 3, this.textPaint) |
|
|
|
|
|
|
|
|
|
val cardRects = config.cardRects(i) |
|
|
|
|
playerSetup?.cards?.forEachIndexed { j, card -> |
|
|
|
|
val cardRect = cardRects[j] |
|
|
|
|
fillPaint.color = context.getColor(R.color.white) |
|
|
|
|
canvas.drawRoundRect(cardRect, config.cardRadius, config.cardRadius, fillPaint) |
|
|
|
|
|
|
|
|
|
cardTextPaint.color = context.getColor(R.color.black) |
|
|
|
|
val valueY = cardRect.top + config.cardSpecs.height * 0.44f |
|
|
|
|
canvas.drawText(card.formattedValue, cardRect.centerX(), valueY, cardTextPaint) |
|
|
|
|
|
|
|
|
|
val suit = card.suit ?: Card.Suit.UNDEFINED |
|
|
|
|
cardTextPaint.color = context.getColor(suit.color) |
|
|
|
|
val suitY = cardRect.top + config.cardSpecs.height * 0.88f |
|
|
|
|
canvas.drawText(suit.value, cardRect.centerX(), suitY, cardTextPaint) |
|
|
|
|
val cards = playerSetup?.cards |
|
|
|
|
cardRects.forEachIndexed { j, cardRect -> |
|
|
|
|
|
|
|
|
|
if (j < cards?.size ?: 0 && (config.showVillainHands || isHero)) { // show card |
|
|
|
|
val card = cards?.get(j)!! // tested line before |
|
|
|
|
fillPaint.color = context.getColor(R.color.white) |
|
|
|
|
canvas.drawRoundRect(cardRect, config.cardRadius, config.cardRadius, fillPaint) |
|
|
|
|
|
|
|
|
|
cardTextPaint.color = context.getColor(R.color.black) |
|
|
|
|
val valueY = cardRect.top + config.cardSpecs.height * 0.44f |
|
|
|
|
canvas.drawText(card.formattedValue, cardRect.centerX(), valueY, cardTextPaint) |
|
|
|
|
|
|
|
|
|
val suit = card.suit ?: Card.Suit.UNDEFINED |
|
|
|
|
cardTextPaint.color = context.getColor(suit.color) |
|
|
|
|
val suitY = cardRect.top + config.cardSpecs.height * 0.88f |
|
|
|
|
canvas.drawText(suit.value, cardRect.centerX(), suitY, cardTextPaint) |
|
|
|
|
|
|
|
|
|
} else { // show hidden cards |
|
|
|
|
fillPaint.color = context.getColor(R.color.card_fill) |
|
|
|
|
canvas.drawRoundRect(cardRect, config.cardRadius, config.cardRadius, fillPaint) |
|
|
|
|
cardStrokePaint.color = context.getColor(R.color.card_border) |
|
|
|
|
canvas.drawRoundRect(cardRect, config.cardRadius, config.cardRadius, cardStrokePaint) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|