hh
Laurent 5 years ago
parent 62837f2323
commit 3ab853c693
  1. 22
      app/src/main/java/net/pokeranalytics/android/ui/modules/handhistory/replayer/ReplayerConfiguration.kt
  2. 29
      app/src/main/java/net/pokeranalytics/android/ui/modules/handhistory/replayer/TableDrawer.kt
  3. 2
      app/src/main/res/values/colors.xml

@ -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))

@ -112,6 +112,19 @@ class TableDrawer(bitmap: Bitmap) : Canvas(bitmap) {
// }
val chipCircle = config.chipCircle(i)
val chipText = config.chipText(i)
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)
@ -121,14 +134,9 @@ class TableDrawer(bitmap: Bitmap) : Canvas(bitmap) {
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)
drawStreet(Street.RIVER, config, canvas, context)
}
canvas.drawText(amount.formatted, chipText.x, chipText.y, this.textPaint)
}
@ -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)
}

@ -34,7 +34,7 @@
<color name="kaki_darker">#283227</color>
<color name="kaki_darkest">#1E231E</color>
<color name="card_border">#6BA379</color>
<color name="card_border">#37533E</color>
<color name="card_fill">#53775C</color>
<color name="red">#FF5F57</color>

Loading…
Cancel
Save