|
|
|
@ -1,10 +1,7 @@ |
|
|
|
package net.pokeranalytics.android.ui.modules.handhistory.replayer |
|
|
|
package net.pokeranalytics.android.ui.modules.handhistory.replayer |
|
|
|
|
|
|
|
|
|
|
|
import android.content.Context |
|
|
|
import android.content.Context |
|
|
|
import android.graphics.Bitmap |
|
|
|
import android.graphics.* |
|
|
|
import android.graphics.Canvas |
|
|
|
|
|
|
|
import android.graphics.Paint |
|
|
|
|
|
|
|
import android.graphics.RectF |
|
|
|
|
|
|
|
import androidx.core.content.res.ResourcesCompat |
|
|
|
import androidx.core.content.res.ResourcesCompat |
|
|
|
import androidx.core.graphics.drawable.RoundedBitmapDrawableFactory |
|
|
|
import androidx.core.graphics.drawable.RoundedBitmapDrawableFactory |
|
|
|
import net.pokeranalytics.android.R |
|
|
|
import net.pokeranalytics.android.R |
|
|
|
@ -32,6 +29,7 @@ class TableDrawer(bitmap: Bitmap) : Canvas(bitmap) { |
|
|
|
private val textPaint = Paint() |
|
|
|
private val textPaint = Paint() |
|
|
|
private val cardTextPaint = Paint() |
|
|
|
private val cardTextPaint = Paint() |
|
|
|
private val cardStrokePaint = Paint() |
|
|
|
private val cardStrokePaint = Paint() |
|
|
|
|
|
|
|
private val chipBorderPaint = Paint() |
|
|
|
|
|
|
|
|
|
|
|
fun configurePaints(context: Context) { |
|
|
|
fun configurePaints(context: Context) { |
|
|
|
tablePaint.isAntiAlias = true |
|
|
|
tablePaint.isAntiAlias = true |
|
|
|
@ -47,6 +45,9 @@ class TableDrawer(bitmap: Bitmap) : Canvas(bitmap) { |
|
|
|
cardStrokePaint.style = Paint.Style.STROKE |
|
|
|
cardStrokePaint.style = Paint.Style.STROKE |
|
|
|
cardStrokePaint.strokeWidth = cardStrokeWidth |
|
|
|
cardStrokePaint.strokeWidth = cardStrokeWidth |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
chipBorderPaint.isAntiAlias = true |
|
|
|
|
|
|
|
chipBorderPaint.style = Paint.Style.STROKE |
|
|
|
|
|
|
|
|
|
|
|
fillPaint.isAntiAlias = true |
|
|
|
fillPaint.isAntiAlias = true |
|
|
|
|
|
|
|
|
|
|
|
textPaint.color = context.getColor(R.color.white) |
|
|
|
textPaint.color = context.getColor(R.color.white) |
|
|
|
@ -113,12 +114,20 @@ class TableDrawer(bitmap: Bitmap) : Canvas(bitmap) { |
|
|
|
val chipCircle = config.chipCircle(i) |
|
|
|
val chipCircle = config.chipCircle(i) |
|
|
|
this.fillPaint.color = context.getColor(R.color.green) |
|
|
|
this.fillPaint.color = context.getColor(R.color.green) |
|
|
|
canvas.drawCircle(chipCircle.x, chipCircle.y, chipCircle.radius, this.fillPaint) |
|
|
|
canvas.drawCircle(chipCircle.x, chipCircle.y, chipCircle.radius, this.fillPaint) |
|
|
|
|
|
|
|
this.chipBorderPaint.color = context.getColor(R.color.white) |
|
|
|
|
|
|
|
val chipBorderStrokeWidth = chipCircle.radius / 3f |
|
|
|
|
|
|
|
this.chipBorderPaint.strokeWidth = chipBorderStrokeWidth |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
chipBorderPaint.pathEffect = DashPathEffect(floatArrayOf(chipCircle.radius * 0.6f, chipCircle.radius * 0.44f), 0f) |
|
|
|
|
|
|
|
canvas.drawCircle(chipCircle.x, chipCircle.y, chipCircle.radius - chipBorderStrokeWidth / 2, this.chipBorderPaint) |
|
|
|
|
|
|
|
|
|
|
|
val chipText = config.chipText(i) |
|
|
|
val chipText = config.chipText(i) |
|
|
|
this.textPaint.textSize = chipText.fontSize |
|
|
|
this.textPaint.textSize = chipText.fontSize |
|
|
|
this.textPaint.color = context.getColor(R.color.white) |
|
|
|
this.textPaint.color = context.getColor(R.color.white) |
|
|
|
canvas.drawText("2000", chipText.x, chipText.y, this.textPaint) |
|
|
|
canvas.drawText("2000", chipText.x, chipText.y, this.textPaint) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
drawStreet(Street.RIVER, config, canvas, context) |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
@ -133,6 +142,20 @@ class TableDrawer(bitmap: Bitmap) : Canvas(bitmap) { |
|
|
|
|
|
|
|
|
|
|
|
if (j < cards?.size ?: 0 && (config.showVillainHands || isHero)) { // show card |
|
|
|
if (j < cards?.size ?: 0 && (config.showVillainHands || isHero)) { // show card |
|
|
|
val card = cards?.get(j)!! // tested line before |
|
|
|
val card = cards?.get(j)!! // tested line before |
|
|
|
|
|
|
|
drawCard(card, cardRect, config, canvas, context) |
|
|
|
|
|
|
|
} 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) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private fun drawCard(card: Card, cardRect: RectF, config: ReplayerConfiguration, canvas: Canvas, context: Context) { |
|
|
|
|
|
|
|
|
|
|
|
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) |
|
|
|
|
|
|
|
|
|
|
|
@ -145,15 +168,6 @@ class TableDrawer(bitmap: Bitmap) : Canvas(bitmap) { |
|
|
|
val suitY = cardRect.top + config.cardSpecs.height * 0.88f |
|
|
|
val suitY = cardRect.top + config.cardSpecs.height * 0.88f |
|
|
|
canvas.drawText(suit.value, cardRect.centerX(), suitY, cardTextPaint) |
|
|
|
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) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
fun drawAction(i: Int, action: ComputedAction, config: ReplayerConfiguration, canvas: Canvas, context: Context) { |
|
|
|
fun drawAction(i: Int, action: ComputedAction, config: ReplayerConfiguration, canvas: Canvas, context: Context) { |
|
|
|
@ -214,6 +228,11 @@ class TableDrawer(bitmap: Bitmap) : Canvas(bitmap) { |
|
|
|
|
|
|
|
|
|
|
|
fun drawStreet(street: Street, config: ReplayerConfiguration, canvas: Canvas, context: Context) { |
|
|
|
fun drawStreet(street: Street, config: ReplayerConfiguration, 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) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//////// |
|
|
|
//////// |
|
|
|
|