|
|
|
|
@ -42,10 +42,6 @@ class TableDrawer(bitmap: Bitmap) : Canvas(bitmap) { |
|
|
|
|
|
|
|
|
|
companion object { |
|
|
|
|
|
|
|
|
|
private const val tableStrokeWidth = 30f |
|
|
|
|
private const val playerStrokeWidth = 8f |
|
|
|
|
private const val cardStrokeWidth = 8f |
|
|
|
|
|
|
|
|
|
private const val backgroundColor = R.color.green_darker |
|
|
|
|
private val backgroundPaint = Paint() |
|
|
|
|
private val strokePaint = Paint() |
|
|
|
|
@ -59,7 +55,7 @@ class TableDrawer(bitmap: Bitmap) : Canvas(bitmap) { |
|
|
|
|
|
|
|
|
|
private val colorsByAmount = hashMapOf<Double, ChipColor>() |
|
|
|
|
|
|
|
|
|
fun configurePaints(context: Context) { |
|
|
|
|
fun configurePaints(context: Context, animator: ReplayerAnimator) { |
|
|
|
|
|
|
|
|
|
this.colorsByAmount.clear() |
|
|
|
|
|
|
|
|
|
@ -67,16 +63,16 @@ class TableDrawer(bitmap: Bitmap) : Canvas(bitmap) { |
|
|
|
|
|
|
|
|
|
tablePaint.isAntiAlias = true |
|
|
|
|
tablePaint.style = Paint.Style.STROKE |
|
|
|
|
tablePaint.strokeWidth = tableStrokeWidth |
|
|
|
|
tablePaint.strokeWidth = animator.tableStrokeWidth |
|
|
|
|
tablePaint.color = context.getColor(R.color.green) |
|
|
|
|
|
|
|
|
|
strokePaint.isAntiAlias = true |
|
|
|
|
strokePaint.style = Paint.Style.STROKE |
|
|
|
|
strokePaint.strokeWidth = playerStrokeWidth |
|
|
|
|
strokePaint.strokeWidth = animator.playerStrokeWidth |
|
|
|
|
|
|
|
|
|
cardStrokePaint.isAntiAlias = true |
|
|
|
|
cardStrokePaint.style = Paint.Style.STROKE |
|
|
|
|
cardStrokePaint.strokeWidth = cardStrokeWidth |
|
|
|
|
cardStrokePaint.strokeWidth = animator.cardStrokeWidth |
|
|
|
|
|
|
|
|
|
chipBorderPaint.isAntiAlias = true |
|
|
|
|
chipBorderPaint.style = Paint.Style.STROKE |
|
|
|
|
@ -94,56 +90,56 @@ class TableDrawer(bitmap: Bitmap) : Canvas(bitmap) { |
|
|
|
|
cardTextPaint.isAntiAlias = true |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
fun drawTable(config: ReplayerConfiguration, canvas: Canvas, context: Context) { |
|
|
|
|
drawTableItems(config, canvas, context) |
|
|
|
|
config.frameDrawn() |
|
|
|
|
fun drawTable(animator: ReplayerAnimator, canvas: Canvas, context: Context) { |
|
|
|
|
drawTableItems(animator, canvas, context) |
|
|
|
|
animator.frameDrawn() |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private fun drawTableItems(config: ReplayerConfiguration, canvas: Canvas, context: Context) { |
|
|
|
|
private fun drawTableItems(animator: ReplayerAnimator, canvas: Canvas, context: Context) { |
|
|
|
|
|
|
|
|
|
// base |
|
|
|
|
initializeTable(config, canvas, context) |
|
|
|
|
initializeTable(animator, canvas, context) |
|
|
|
|
|
|
|
|
|
val step = config.currentStep |
|
|
|
|
val step = animator.currentStep |
|
|
|
|
val street = step.street |
|
|
|
|
|
|
|
|
|
val computedAction = step as? ComputedAction? |
|
|
|
|
|
|
|
|
|
// draw pot |
|
|
|
|
drawPot(street, computedAction, config, canvas, context) |
|
|
|
|
drawPot(street, computedAction, animator, canvas, context) |
|
|
|
|
|
|
|
|
|
// draw board |
|
|
|
|
drawBoardCards(street, config, canvas, context) |
|
|
|
|
drawBoardCards(street, animator, canvas, context) |
|
|
|
|
|
|
|
|
|
// draw player shapes and chips |
|
|
|
|
val hh = config.handHistory |
|
|
|
|
val hh = animator.handHistory |
|
|
|
|
for (i in 0 until hh.numberOfPlayers) { |
|
|
|
|
drawPlayerShapes(i, computedAction, config, canvas, context) |
|
|
|
|
drawPlayerChips(i, config, canvas, context) |
|
|
|
|
drawPlayerShapes(i, computedAction, animator, canvas, context) |
|
|
|
|
drawPlayerChips(i, animator, canvas, context) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// draw player cards |
|
|
|
|
config.activePositions.forEach { |
|
|
|
|
drawCards(it, config, canvas, context) |
|
|
|
|
animator.activePositions.forEach { |
|
|
|
|
drawCards(it, animator, canvas, context) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private fun drawPlayerShapes(i: Int, computedAction: ComputedAction?, config: ReplayerConfiguration, canvas: Canvas, context: Context) { |
|
|
|
|
private fun drawPlayerShapes(i: Int, computedAction: ComputedAction?, animator: ReplayerAnimator, canvas: Canvas, context: Context) { |
|
|
|
|
|
|
|
|
|
// draw player rectangles with action or name + stack |
|
|
|
|
if (computedAction?.positionIndex == i) { |
|
|
|
|
drawPlayerRectangle(i, true, config, canvas, context) |
|
|
|
|
drawAction(i, computedAction, config, canvas, context) |
|
|
|
|
drawPlayerRectangle(i, true, animator, canvas, context) |
|
|
|
|
drawAction(i, computedAction, animator, canvas, context) |
|
|
|
|
} else { |
|
|
|
|
val info = if (config.isPlayerAllin(i)) { |
|
|
|
|
val info = if (animator.isPlayerAllin(i)) { |
|
|
|
|
context.getString(R.string.allin) |
|
|
|
|
} else { |
|
|
|
|
val remainingStack = config.playerRemainingStack(i) |
|
|
|
|
val remainingStack = animator.playerRemainingStack(i) |
|
|
|
|
remainingStack?.formatted |
|
|
|
|
} |
|
|
|
|
drawPlayerRectangle(i, false, config, canvas, context) |
|
|
|
|
drawPositionAndInfo(i, info, config, canvas) |
|
|
|
|
drawPlayerRectangle(i, false, animator, canvas, context) |
|
|
|
|
drawPositionAndInfo(i, info, animator, canvas) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
@ -152,57 +148,57 @@ class TableDrawer(bitmap: Bitmap) : Canvas(bitmap) { |
|
|
|
|
* Draw chips |
|
|
|
|
* A chip should appears when the player has put some money during the current street |
|
|
|
|
*/ |
|
|
|
|
private fun drawPlayerChips(i: Int, config: ReplayerConfiguration, canvas: Canvas, context: Context) { |
|
|
|
|
private fun drawPlayerChips(i: Int, animator: ReplayerAnimator, canvas: Canvas, context: Context) { |
|
|
|
|
|
|
|
|
|
when (config.currentStep) { |
|
|
|
|
when (animator.currentStep) { |
|
|
|
|
is Street -> { |
|
|
|
|
when (config.frameType) { |
|
|
|
|
ReplayerConfiguration.FrameType.STATE -> { |
|
|
|
|
if (config.currentStep == Street.SUMMARY) { |
|
|
|
|
when (animator.frameType) { |
|
|
|
|
ReplayerAnimator.FrameType.STATE -> { |
|
|
|
|
if (animator.currentStep == Street.SUMMARY) { |
|
|
|
|
|
|
|
|
|
val winnerPots = config.handHistory.winnerPots.firstOrNull { it.position == i } |
|
|
|
|
val winnerPots = animator.handHistory.winnerPots.firstOrNull { it.position == i } |
|
|
|
|
winnerPots?.let { pot -> |
|
|
|
|
val color = colorForAmount(pot.amount) |
|
|
|
|
val circle = config.animatedChipCircleFromPot(i) |
|
|
|
|
val circle = animator.animatedChipCircleFromPot(i) |
|
|
|
|
drawChipCircle(circle, color, canvas, context) |
|
|
|
|
drawChipText(pot.amount, config.chipText(i), canvas, context) |
|
|
|
|
drawChipText(pot.amount, animator.chipText(i), canvas, context) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
ReplayerConfiguration.FrameType.GATHER_ANIMATION -> { |
|
|
|
|
lastCommittedAmount(i, config)?.let { amount -> |
|
|
|
|
ReplayerAnimator.FrameType.GATHER_ANIMATION -> { |
|
|
|
|
lastCommittedAmount(i, animator)?.let { amount -> |
|
|
|
|
val color = colorForAmount(amount) |
|
|
|
|
val circle = config.animatedChipCircleToPot(i) |
|
|
|
|
val circle = animator.animatedChipCircleToPot(i) |
|
|
|
|
drawChipCircle(circle, color, canvas, context) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
ReplayerConfiguration.FrameType.DISTRIBUTION_ANIMATION -> { |
|
|
|
|
ReplayerAnimator.FrameType.DISTRIBUTION_ANIMATION -> { |
|
|
|
|
|
|
|
|
|
val winnerPots = config.handHistory.winnerPots.firstOrNull { it.position == i } |
|
|
|
|
val winnerPots = animator.handHistory.winnerPots.firstOrNull { it.position == i } |
|
|
|
|
winnerPots?.let { pot -> |
|
|
|
|
val color = colorForAmount(pot.amount) |
|
|
|
|
val circle = config.animatedChipCircleFromPot(i) |
|
|
|
|
val circle = animator.animatedChipCircleFromPot(i) |
|
|
|
|
drawChipCircle(circle, color, canvas, context) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
is ComputedAction -> { |
|
|
|
|
drawChipForAction(i, config, canvas, context) |
|
|
|
|
drawChipForAction(i, animator, canvas, context) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private fun drawChipForAction(i: Int, config: ReplayerConfiguration, canvas: Canvas, context: Context) { |
|
|
|
|
lastCommittedAmount(i, config)?.let { amount -> |
|
|
|
|
drawChip(amount, i, config, canvas, context) |
|
|
|
|
private fun drawChipForAction(i: Int, animator: ReplayerAnimator, canvas: Canvas, context: Context) { |
|
|
|
|
lastCommittedAmount(i, animator)?.let { amount -> |
|
|
|
|
drawChip(amount, i, animator, canvas, context) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private fun lastCommittedAmount(i: Int, config: ReplayerConfiguration): Double? { |
|
|
|
|
var committingAction = config.lastChipCommittingActionOfPlayer(i) |
|
|
|
|
private fun lastCommittedAmount(i: Int, animator: ReplayerAnimator): Double? { |
|
|
|
|
var committingAction = animator.lastChipCommittingActionOfPlayer(i) |
|
|
|
|
if (committingAction?.action?.type?.isCall == true) { |
|
|
|
|
committingAction = committingAction.getStreetLastSignificantAction() |
|
|
|
|
} |
|
|
|
|
@ -212,26 +208,26 @@ class TableDrawer(bitmap: Bitmap) : Canvas(bitmap) { |
|
|
|
|
/*** |
|
|
|
|
* WARNING: Avoid instancing objects here, as it's called from onDraw method |
|
|
|
|
*/ |
|
|
|
|
private fun initializeTable(config: ReplayerConfiguration, canvas: Canvas, context: Context) { |
|
|
|
|
private fun initializeTable(animator: ReplayerAnimator, canvas: Canvas, context: Context) { |
|
|
|
|
|
|
|
|
|
canvas.drawColor(context.getColor(backgroundColor)) |
|
|
|
|
|
|
|
|
|
canvas.drawRoundRect(config.tableRect, config.tableCornerRadius, config.tableCornerRadius, this.tablePaint) |
|
|
|
|
this.cardTextPaint.textSize = config.cardSpecs.height * .38f |
|
|
|
|
canvas.drawRoundRect(animator.tableRect, animator.tableCornerRadius, animator.tableCornerRadius, this.tablePaint) |
|
|
|
|
this.cardTextPaint.textSize = animator.cardSpecs.height * .38f |
|
|
|
|
|
|
|
|
|
val hh = config.handHistory |
|
|
|
|
val hh = animator.handHistory |
|
|
|
|
for (i in 0 until hh.numberOfPlayers) { |
|
|
|
|
drawPlayerRectangle(i,false, config, canvas, context) |
|
|
|
|
drawPlayerCircle(i, config, canvas, context) |
|
|
|
|
drawDealerButton(config, canvas, context) |
|
|
|
|
drawPlayerRectangle(i,false, animator, canvas, context) |
|
|
|
|
drawPlayerCircle(i, animator, canvas, context) |
|
|
|
|
drawDealerButton(animator, canvas, context) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private fun drawDealerButton(config: ReplayerConfiguration, canvas: Canvas, context: Context) { |
|
|
|
|
private fun drawDealerButton(animator: ReplayerAnimator, canvas: Canvas, context: Context) { |
|
|
|
|
|
|
|
|
|
// Dealer button |
|
|
|
|
val dealerCircle = config.dealerCircle |
|
|
|
|
val dealerCircle = animator.dealerCircle |
|
|
|
|
this.fillPaint.color = context.getColor(R.color.red) |
|
|
|
|
canvas.drawCircle(dealerCircle.x, dealerCircle.y, dealerCircle.radius, fillPaint) |
|
|
|
|
this.strokePaint.color = context.getColor(R.color.white) |
|
|
|
|
@ -241,19 +237,19 @@ class TableDrawer(bitmap: Bitmap) : Canvas(bitmap) { |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private fun drawChip(amount: Double, playerIndex: Int, config: ReplayerConfiguration, canvas: Canvas, context: Context) { |
|
|
|
|
val circle = config.chipCircle(playerIndex) |
|
|
|
|
val text = config.chipText(playerIndex) |
|
|
|
|
private fun drawChip(amount: Double, playerIndex: Int, animator: ReplayerAnimator, canvas: Canvas, context: Context) { |
|
|
|
|
val circle = animator.chipCircle(playerIndex) |
|
|
|
|
val text = animator.chipText(playerIndex) |
|
|
|
|
drawChip(amount, text, circle, canvas, context) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private fun drawChip(amount: Double, chipText: ReplayerConfiguration.TextPoint, chipCircle: ReplayerConfiguration.Circle, canvas: Canvas, context: Context) { |
|
|
|
|
private fun drawChip(amount: Double, chipText: ReplayerAnimator.TextPoint, chipCircle: ReplayerAnimator.Circle, canvas: Canvas, context: Context) { |
|
|
|
|
val color = colorForAmount(amount) |
|
|
|
|
drawChipCircle(chipCircle, color, canvas, context) |
|
|
|
|
drawChipText(amount, chipText, canvas, context) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private fun drawChipText(amount: Double, chipText: ReplayerConfiguration.TextPoint, canvas: Canvas, context: Context) { |
|
|
|
|
private fun drawChipText(amount: Double, chipText: ReplayerAnimator.TextPoint, canvas: Canvas, context: Context) { |
|
|
|
|
this.textPaint.textSize = chipText.fontSize |
|
|
|
|
this.textPaint.color = context.getColor(R.color.white) |
|
|
|
|
canvas.drawText(amount.formatted, chipText.x, chipText.y, this.textPaint) |
|
|
|
|
@ -269,7 +265,7 @@ class TableDrawer(bitmap: Bitmap) : Canvas(bitmap) { |
|
|
|
|
return color |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private fun drawChipCircle(chipCircle: ReplayerConfiguration.Circle, chipColor: ChipColor, canvas: Canvas, context: Context) { |
|
|
|
|
private fun drawChipCircle(chipCircle: ReplayerAnimator.Circle, chipColor: ChipColor, canvas: Canvas, context: Context) { |
|
|
|
|
|
|
|
|
|
this.fillPaint.color = context.getColor(chipColor.fillColor) |
|
|
|
|
canvas.drawCircle(chipCircle.x, chipCircle.y, chipCircle.radius, this.fillPaint) |
|
|
|
|
@ -282,50 +278,50 @@ class TableDrawer(bitmap: Bitmap) : Canvas(bitmap) { |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private fun drawCards(playerIndex: Int, config: ReplayerConfiguration, canvas: Canvas, context: Context) { |
|
|
|
|
private fun drawCards(playerIndex: Int, animator: ReplayerAnimator, canvas: Canvas, context: Context) { |
|
|
|
|
|
|
|
|
|
val playerSetup = config.handHistory.playerSetupForPosition(playerIndex) |
|
|
|
|
val cardRects = config.cardRects(playerIndex) |
|
|
|
|
val playerSetup = animator.handHistory.playerSetupForPosition(playerIndex) |
|
|
|
|
val cardRects = animator.cardRects(playerIndex) |
|
|
|
|
val cards = playerSetup?.cards |
|
|
|
|
val isHero = (config.handHistory.heroIndex == playerIndex) |
|
|
|
|
val isHero = (animator.handHistory.heroIndex == playerIndex) |
|
|
|
|
cardRects.forEachIndexed { j, cardRect -> |
|
|
|
|
|
|
|
|
|
if (j < cards?.size ?: 0 && (config.showVillainHands || isHero)) { // show card |
|
|
|
|
if (j < cards?.size ?: 0 && (animator.showVillainHands || isHero)) { // show card |
|
|
|
|
val card = cards?.get(j)!! // tested line before |
|
|
|
|
drawCard(card, cardRect, config, canvas, context) |
|
|
|
|
drawCard(card, cardRect, animator, canvas, context) |
|
|
|
|
} else { // show hidden cards |
|
|
|
|
fillPaint.color = context.getColor(R.color.card_fill) |
|
|
|
|
canvas.drawRoundRect(cardRect, config.cardRadius, config.cardRadius, fillPaint) |
|
|
|
|
canvas.drawRoundRect(cardRect, animator.cardRadius, animator.cardRadius, fillPaint) |
|
|
|
|
cardStrokePaint.color = context.getColor(R.color.card_border) |
|
|
|
|
canvas.drawRoundRect(cardRect, config.cardRadius, config.cardRadius, cardStrokePaint) |
|
|
|
|
canvas.drawRoundRect(cardRect, animator.cardRadius, animator.cardRadius, cardStrokePaint) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private fun drawCard(card: Card, cardRect: RectF, config: ReplayerConfiguration, canvas: Canvas, context: Context) { |
|
|
|
|
private fun drawCard(card: Card, cardRect: RectF, animator: ReplayerAnimator, canvas: Canvas, context: Context) { |
|
|
|
|
|
|
|
|
|
fillPaint.color = context.getColor(R.color.white) |
|
|
|
|
canvas.drawRoundRect(cardRect, config.cardRadius, config.cardRadius, fillPaint) |
|
|
|
|
canvas.drawRoundRect(cardRect, animator.cardRadius, animator.cardRadius, fillPaint) |
|
|
|
|
|
|
|
|
|
cardTextPaint.color = context.getColor(R.color.black) |
|
|
|
|
val valueY = cardRect.top + config.cardSpecs.height * 0.44f |
|
|
|
|
val valueY = cardRect.top + animator.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 |
|
|
|
|
val suitY = cardRect.top + animator.cardSpecs.height * 0.88f |
|
|
|
|
canvas.drawText(suit.value, cardRect.centerX(), suitY, cardTextPaint) |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private fun drawPlayerCircle(i: Int, config: ReplayerConfiguration, canvas: Canvas, context: Context) { |
|
|
|
|
private fun drawPlayerCircle(i: Int, animator: ReplayerAnimator, canvas: Canvas, context: Context) { |
|
|
|
|
|
|
|
|
|
val playerSetup = config.handHistory.playerSetupForPosition(i) |
|
|
|
|
val playerSetup = animator.handHistory.playerSetupForPosition(i) |
|
|
|
|
|
|
|
|
|
// Player portrait zone |
|
|
|
|
val circle = config.circleForPlayer(i) |
|
|
|
|
val circle = animator.circleForPlayer(i) |
|
|
|
|
val radius = circle.radius |
|
|
|
|
this.fillPaint.color = context.getColor(R.color.green_darker) |
|
|
|
|
canvas.drawCircle(circle.x, circle.y, radius, this.fillPaint) |
|
|
|
|
@ -351,65 +347,65 @@ class TableDrawer(bitmap: Bitmap) : Canvas(bitmap) { |
|
|
|
|
/*** |
|
|
|
|
* [i] is the player position in the hand |
|
|
|
|
*/ |
|
|
|
|
private fun drawPlayerRectangle(i: Int, highlighted: Boolean, config: ReplayerConfiguration, canvas: Canvas, context: Context) { |
|
|
|
|
private fun drawPlayerRectangle(i: Int, highlighted: Boolean, animator: ReplayerAnimator, canvas: Canvas, context: Context) { |
|
|
|
|
|
|
|
|
|
val rect = config.stackRectForPlayer(i) |
|
|
|
|
val rect = animator.stackRectForPlayer(i) |
|
|
|
|
val rectRadius = (rect.bottom - rect.top) / 4 |
|
|
|
|
|
|
|
|
|
val color = if (highlighted) R.color.kaki else R.color.green_darker |
|
|
|
|
fillPaint.color = context.getColor(color) |
|
|
|
|
canvas.drawRoundRect( |
|
|
|
|
config.stackRectForPlayer(i), |
|
|
|
|
animator.stackRectForPlayer(i), |
|
|
|
|
rectRadius, |
|
|
|
|
rectRadius, |
|
|
|
|
this.fillPaint |
|
|
|
|
) |
|
|
|
|
strokePaint.color = context.getColor(R.color.green) |
|
|
|
|
canvas.drawRoundRect( |
|
|
|
|
config.stackRectForPlayer(i), |
|
|
|
|
animator.stackRectForPlayer(i), |
|
|
|
|
rectRadius, |
|
|
|
|
rectRadius, |
|
|
|
|
this.strokePaint |
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
if (i == config.handHistory.heroIndex) { // refresh dealer button |
|
|
|
|
drawDealerButton(config, canvas, context) |
|
|
|
|
if (i == animator.handHistory.heroIndex) { // refresh dealer button |
|
|
|
|
drawDealerButton(animator, canvas, context) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private fun drawPositionAndInfo(i: Int, secondLine: String?, config: ReplayerConfiguration, canvas: Canvas) { |
|
|
|
|
private fun drawPositionAndInfo(i: Int, secondLine: String?, animator: ReplayerAnimator, canvas: Canvas) { |
|
|
|
|
|
|
|
|
|
val hh = config.handHistory |
|
|
|
|
val hh = animator.handHistory |
|
|
|
|
// Player position |
|
|
|
|
val positions = Position.positionsPerPlayers(hh.numberOfPlayers) |
|
|
|
|
val name = positions.elementAt(i).value |
|
|
|
|
val pnPoint = config.pointForPlayerName(i) |
|
|
|
|
val pnPoint = animator.pointForPlayerName(i) |
|
|
|
|
this.textPaint.textSize = pnPoint.fontSize |
|
|
|
|
canvas.drawText(name, pnPoint.x, pnPoint.y, this.textPaint) |
|
|
|
|
|
|
|
|
|
// Player stack |
|
|
|
|
secondLine?.let { |
|
|
|
|
val psPoint = config.pointForPlayerStack(i) |
|
|
|
|
val psPoint = animator.pointForPlayerStack(i) |
|
|
|
|
this.textPaint.textSize = psPoint.fontSize |
|
|
|
|
canvas.drawText(it, psPoint.x, psPoint.y, this.textPaint) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private fun drawAction(i: Int, action: ComputedAction, config: ReplayerConfiguration, canvas: Canvas, context: Context) { |
|
|
|
|
private fun drawAction(i: Int, action: ComputedAction, animator: ReplayerAnimator, canvas: Canvas, context: Context) { |
|
|
|
|
|
|
|
|
|
action.action.type?.let { type -> |
|
|
|
|
val actionName = context.getString(type.resId) |
|
|
|
|
val actionPoint: ReplayerConfiguration.TextPoint |
|
|
|
|
val actionPoint: ReplayerAnimator.TextPoint |
|
|
|
|
if (!type.isPassive) { // show action + amount |
|
|
|
|
actionPoint = config.pointForPlayerName(i) |
|
|
|
|
actionPoint = animator.pointForPlayerName(i) |
|
|
|
|
action.action.displayedAmount?.let { amount -> |
|
|
|
|
val amountPoint = config.pointForPlayerStack(i) |
|
|
|
|
val amountPoint = animator.pointForPlayerStack(i) |
|
|
|
|
this.textPaint.textSize = amountPoint.fontSize |
|
|
|
|
canvas.drawText(amount.formatted, amountPoint.x, amountPoint.y, this.textPaint) |
|
|
|
|
} |
|
|
|
|
} else { // show action name only |
|
|
|
|
actionPoint = config.pointForPlayerAction(i) |
|
|
|
|
actionPoint = animator.pointForPlayerAction(i) |
|
|
|
|
} |
|
|
|
|
this.textPaint.textSize = actionPoint.fontSize |
|
|
|
|
canvas.drawText(actionName, actionPoint.x, actionPoint.y, this.textPaint) |
|
|
|
|
@ -418,36 +414,36 @@ class TableDrawer(bitmap: Bitmap) : Canvas(bitmap) { |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private fun drawBoardCards(street: Street, config: ReplayerConfiguration, canvas: Canvas, context: Context) { |
|
|
|
|
private fun drawBoardCards(street: Street, animator: ReplayerAnimator, canvas: Canvas, context: Context) { |
|
|
|
|
|
|
|
|
|
val cards = config.handHistory.cardsForStreet(street) |
|
|
|
|
config.boardCardRects.take(street.totalBoardCards).forEachIndexed { index, rectF -> |
|
|
|
|
drawCard(cards[index], rectF, config, canvas, context) |
|
|
|
|
val cards = animator.handHistory.cardsForStreet(street) |
|
|
|
|
animator.boardCardRects.take(street.totalBoardCards).forEachIndexed { index, rectF -> |
|
|
|
|
drawCard(cards[index], rectF, animator, canvas, context) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private fun drawPot(street: Street, computedAction: ComputedAction?, config: ReplayerConfiguration, canvas: Canvas, context: Context) { |
|
|
|
|
private fun drawPot(street: Street, computedAction: ComputedAction?, animator: ReplayerAnimator, canvas: Canvas, context: Context) { |
|
|
|
|
|
|
|
|
|
if (street == Street.SUMMARY && config.frameType != ReplayerConfiguration.FrameType.GATHER_ANIMATION) { |
|
|
|
|
if (street == Street.SUMMARY && animator.frameType != ReplayerAnimator.FrameType.GATHER_ANIMATION) { |
|
|
|
|
return |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
val pot = config.actionList.potSizeForStreet(street) |
|
|
|
|
val pot = animator.actionList.potSizeForStreet(street) |
|
|
|
|
|
|
|
|
|
val action = computedAction ?: config.lastActionBeforeStreet(street) |
|
|
|
|
val action = computedAction ?: animator.lastActionBeforeStreet(street) |
|
|
|
|
val totalPot = action?.let { |
|
|
|
|
config.actionList.totalPotSize(it.action.index + 1) |
|
|
|
|
animator.actionList.totalPotSize(it.action.index + 1) |
|
|
|
|
} ?: run { |
|
|
|
|
pot |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
drawChip(pot, config.potTextPoint, config.potChipCircle, canvas, context) |
|
|
|
|
val tpTextPoint = config.totalPotTextPoint |
|
|
|
|
drawChip(pot, animator.potTextPoint, animator.potChipCircle, canvas, context) |
|
|
|
|
val tpTextPoint = animator.totalPotTextPoint |
|
|
|
|
this.textPaint.textSize = tpTextPoint.fontSize |
|
|
|
|
this.textPaint.color = context.getColor(R.color.white) |
|
|
|
|
|
|
|
|
|
canvas.drawText(totalPot.formatted, config.totalPotTextPoint.x, config.totalPotTextPoint.y, this.textPaint) |
|
|
|
|
canvas.drawText(totalPot.formatted, animator.totalPotTextPoint.x, animator.totalPotTextPoint.y, this.textPaint) |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|