diff --git a/app/src/main/java/net/pokeranalytics/android/ui/modules/handhistory/replayer/ReplayerConfiguration.kt b/app/src/main/java/net/pokeranalytics/android/ui/modules/handhistory/replayer/ReplayerConfiguration.kt index 390ae17d..ff44e613 100644 --- a/app/src/main/java/net/pokeranalytics/android/ui/modules/handhistory/replayer/ReplayerConfiguration.kt +++ b/app/src/main/java/net/pokeranalytics/android/ui/modules/handhistory/replayer/ReplayerConfiguration.kt @@ -22,10 +22,11 @@ class ReplayerConfiguration(var handHistory: HandHistory) { private val maxCards = 5 var width = 100f - val centerX: Float - get() { return this.width / 2f } var height = 100f - val centerY: Float + + private val centerX: Float + get() { return this.width / 2f } + private val centerY: Float get() { return this.height / 2f } var tableRect = RectF() @@ -53,6 +54,7 @@ class ReplayerConfiguration(var handHistory: HandHistory) { private var playerItemsHeight = 10f private var playerItemsWidth = 10f + var chipRadius = 10f private var paddingPercentage = 0.8f private var cardsPaddingPercentage = 0.9f @@ -62,6 +64,10 @@ class ReplayerConfiguration(var handHistory: HandHistory) { val speed: Double = 1.0 val showVillainHands: Boolean = true + var potTextPoint = TextPoint(0f, 0f, 0f) + var totalPotTextPoint = TextPoint(0f, 0f, 0f) + var potChipCircle = Circle(0f, 0f, 0f) + /*** * Calculates the position of all elements to draw */ @@ -84,10 +90,11 @@ class ReplayerConfiguration(var handHistory: HandHistory) { // pz for Player Zone val pzHeight = height / playerPerColumn - val pzWidth = width / playerPerRow +// val pzWidth = width / playerPerRow this.playerItemsHeight = pzHeight / 3 this.playerItemsWidth = this.tableHPadding * 2 * this.paddingPercentage + this.chipRadius = this.playerItemsHeight / 4 val cardWPaddingWidth = this.playerItemsWidth * 1.2f / this.maxCards val cardWidth = cardWPaddingWidth * this.cardsPaddingPercentage @@ -104,6 +111,11 @@ class ReplayerConfiguration(var handHistory: HandHistory) { this.boardCardRects.add(RectF(bcLeft, bcTop, bcRight, bcBottom)) } + val chipTextSize = this.chipRadius + this.potChipCircle = Circle(centerX, centerY - 5f * chipTextSize, this.chipRadius) + this.potTextPoint = TextPoint(centerX, centerY - 3f * chipTextSize, chipTextSize) + this.totalPotTextPoint = TextPoint(centerX, centerY - 2f * chipTextSize, chipTextSize) + val playerCount = this.handHistory.numberOfPlayers // number of players in this order: bottom / left / top / right val repartition = when (playerCount) { @@ -190,12 +202,10 @@ class ReplayerConfiguration(var handHistory: HandHistory) { val bottom = rectCenterY + this.playerItemsHeight / 2 this.playerStackRects.add(RectF(left, top, right, bottom)) - val chipRadius = this.playerItemsHeight / 4 val chipCircleY = rectCenterY + chipYOffset - chipTextYOffsetCoef * chipRadius this.chipCircles.add(Circle(rectCenterX + chipXOffset, chipCircleY, chipRadius)) - val chipTextSize = chipRadius this.chipTextPoints.add(TextPoint(rectCenterX + chipXOffset, chipCircleY + 2 * chipTextSize, chipTextSize)) diff --git a/app/src/main/java/net/pokeranalytics/android/ui/modules/handhistory/replayer/TableDrawer.kt b/app/src/main/java/net/pokeranalytics/android/ui/modules/handhistory/replayer/TableDrawer.kt index 49b6f872..d4d3495f 100644 --- a/app/src/main/java/net/pokeranalytics/android/ui/modules/handhistory/replayer/TableDrawer.kt +++ b/app/src/main/java/net/pokeranalytics/android/ui/modules/handhistory/replayer/TableDrawer.kt @@ -112,26 +112,34 @@ class TableDrawer(bitmap: Bitmap) : Canvas(bitmap) { // } val chipCircle = config.chipCircle(i) - this.fillPaint.color = context.getColor(R.color.green) - 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) - this.textPaint.textSize = chipText.fontSize - this.textPaint.color = context.getColor(R.color.white) - canvas.drawText("2000", chipText.x, chipText.y, this.textPaint) + drawChip(2000.0, chipText, chipCircle, canvas, context) drawStreet(Street.RIVER, config, canvas, context) + drawPot(100.0, 200.0, config, canvas, context) + } } + private fun drawChip(amount: Double, chipText: ReplayerConfiguration.TextPoint, chipCircle: ReplayerConfiguration.Circle, canvas: Canvas, context: Context) { + + this.fillPaint.color = context.getColor(R.color.green) + 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) + + this.textPaint.textSize = chipText.fontSize + this.textPaint.color = context.getColor(R.color.white) + canvas.drawText(amount.formatted, chipText.x, chipText.y, this.textPaint) + + } + private fun drawCards(playerIndex: Int, config: ReplayerConfiguration, canvas: Canvas, context: Context) { val playerSetup = config.handHistory.playerSetupForPosition(playerIndex) @@ -235,8 +243,13 @@ class TableDrawer(bitmap: Bitmap) : Canvas(bitmap) { } - //////// - fun setPot(pot: Double, totalPot: Double) { + fun drawPot(pot: Double, totalPot: Double, config: ReplayerConfiguration, canvas: Canvas, context: Context) { + + drawChip(pot, config.potTextPoint, config.potChipCircle, canvas, context) + val tpTextPoint = config.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) } diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml index fed595f4..ec778a17 100644 --- a/app/src/main/res/values/colors.xml +++ b/app/src/main/res/values/colors.xml @@ -34,7 +34,7 @@ #283227 #1E231E - #6BA379 + #37533E #53775C #FF5F57