|
|
|
@ -4,24 +4,28 @@ import android.content.Context |
|
|
|
import android.graphics.Bitmap |
|
|
|
import android.graphics.Bitmap |
|
|
|
import android.graphics.Canvas |
|
|
|
import android.graphics.Canvas |
|
|
|
import android.graphics.Paint |
|
|
|
import android.graphics.Paint |
|
|
|
|
|
|
|
import androidx.core.content.res.ResourcesCompat |
|
|
|
import net.pokeranalytics.android.R |
|
|
|
import net.pokeranalytics.android.R |
|
|
|
import net.pokeranalytics.android.model.handhistory.Position |
|
|
|
import net.pokeranalytics.android.model.handhistory.Position |
|
|
|
import net.pokeranalytics.android.model.handhistory.Street |
|
|
|
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.ui.modules.handhistory.model.ComputedAction |
|
|
|
import net.pokeranalytics.android.util.extensions.formatted |
|
|
|
import net.pokeranalytics.android.util.extensions.formatted |
|
|
|
|
|
|
|
import timber.log.Timber |
|
|
|
|
|
|
|
|
|
|
|
class TableDrawer(bitmap: Bitmap) : Canvas(bitmap) { |
|
|
|
class TableDrawer(bitmap: Bitmap) : Canvas(bitmap) { |
|
|
|
|
|
|
|
|
|
|
|
companion object { |
|
|
|
companion object { |
|
|
|
|
|
|
|
|
|
|
|
const val tableStrokeWidth = 30f |
|
|
|
private const val tableStrokeWidth = 30f |
|
|
|
const val playerStrokeWidth = 8f |
|
|
|
private const val playerStrokeWidth = 8f |
|
|
|
|
|
|
|
|
|
|
|
private val strokePaint = Paint() |
|
|
|
private val strokePaint = Paint() |
|
|
|
private val fillPaint = Paint() |
|
|
|
private val fillPaint = Paint() |
|
|
|
|
|
|
|
|
|
|
|
private val tablePaint = Paint() |
|
|
|
private val tablePaint = Paint() |
|
|
|
private val textPaint = Paint() |
|
|
|
private val textPaint = Paint() |
|
|
|
|
|
|
|
private val cardTextPaint = Paint() |
|
|
|
|
|
|
|
|
|
|
|
fun configurePaints(context: Context) { |
|
|
|
fun configurePaints(context: Context) { |
|
|
|
tablePaint.isAntiAlias = true |
|
|
|
tablePaint.isAntiAlias = true |
|
|
|
@ -39,6 +43,10 @@ class TableDrawer(bitmap: Bitmap) : Canvas(bitmap) { |
|
|
|
textPaint.textAlign = Paint.Align.CENTER |
|
|
|
textPaint.textAlign = Paint.Align.CENTER |
|
|
|
textPaint.isAntiAlias = true |
|
|
|
textPaint.isAntiAlias = true |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
cardTextPaint.color = context.getColor(R.color.black) |
|
|
|
|
|
|
|
cardTextPaint.typeface = ResourcesCompat.getFont(context, R.font.roboto_bold) |
|
|
|
|
|
|
|
cardTextPaint.textAlign = Paint.Align.CENTER |
|
|
|
|
|
|
|
cardTextPaint.isAntiAlias = true |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/*** |
|
|
|
/*** |
|
|
|
@ -47,10 +55,12 @@ class TableDrawer(bitmap: Bitmap) : Canvas(bitmap) { |
|
|
|
fun initializeTable(config: ReplayerConfiguration, canvas: Canvas, context: Context) { |
|
|
|
fun initializeTable(config: ReplayerConfiguration, canvas: Canvas, context: Context) { |
|
|
|
|
|
|
|
|
|
|
|
canvas.drawRoundRect(config.tableRect, config.tableCornerRadius, config.tableCornerRadius, this.tablePaint) |
|
|
|
canvas.drawRoundRect(config.tableRect, config.tableCornerRadius, config.tableCornerRadius, this.tablePaint) |
|
|
|
|
|
|
|
cardTextPaint.textSize = config.cardSpecs.height * .38f |
|
|
|
|
|
|
|
|
|
|
|
val hh = config.handHistory |
|
|
|
val hh = config.handHistory |
|
|
|
val positions = Position.positionsPerPlayers(hh.numberOfPlayers) |
|
|
|
val positions = Position.positionsPerPlayers(hh.numberOfPlayers) |
|
|
|
for (i in 0 until hh.numberOfPlayers) { |
|
|
|
for (i in 0 until hh.numberOfPlayers) { |
|
|
|
|
|
|
|
Timber.d("Getting player $i setup ") |
|
|
|
val playerSetup = hh.playerSetupForPosition(i) |
|
|
|
val playerSetup = hh.playerSetupForPosition(i) |
|
|
|
|
|
|
|
|
|
|
|
// Stack zone |
|
|
|
// Stack zone |
|
|
|
@ -88,12 +98,20 @@ class TableDrawer(bitmap: Bitmap) : Canvas(bitmap) { |
|
|
|
canvas.drawCircle(dealerCircle.x, dealerCircle.y, dealerCircle.radius, strokePaint) |
|
|
|
canvas.drawCircle(dealerCircle.x, dealerCircle.y, dealerCircle.radius, strokePaint) |
|
|
|
canvas.drawText("D", dealerCircle.x, dealerCircle.y + this.textPaint.textSize / 3, this.textPaint) |
|
|
|
canvas.drawText("D", dealerCircle.x, dealerCircle.y + this.textPaint.textSize / 3, this.textPaint) |
|
|
|
|
|
|
|
|
|
|
|
playerSetup?.cards?.let { cards -> |
|
|
|
val cardRects = config.cardRects(i) |
|
|
|
val cardRects = config.cardRects(i) |
|
|
|
playerSetup?.cards?.forEachIndexed { j, card -> |
|
|
|
for (cardRect in cardRects) { |
|
|
|
val cardRect = cardRects[j] |
|
|
|
fillPaint.color = context.getColor(R.color.white) |
|
|
|
fillPaint.color = context.getColor(R.color.white) |
|
|
|
canvas.drawRoundRect(cardRect, config.cardRadius, config.cardRadius, fillPaint) |
|
|
|
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) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|