|
|
|
@ -208,11 +208,21 @@ class ReplayerAnimator(var handHistory: HandHistory, var export: Boolean) { |
|
|
|
private var chipTextPoints = mutableListOf<TextPoint>() |
|
|
|
private var chipTextPoints = mutableListOf<TextPoint>() |
|
|
|
var boardCardRects = mutableListOf<RectF>() |
|
|
|
var boardCardRects = mutableListOf<RectF>() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var dealerBottomOriented = true |
|
|
|
val dealerCircle: Circle |
|
|
|
val dealerCircle: Circle |
|
|
|
get() { |
|
|
|
get() { |
|
|
|
val rect = this.playerStackRects.last() |
|
|
|
val rect = this.playerStackRects.last() |
|
|
|
val radius = (rect.bottom - rect.top) / 4 |
|
|
|
val radius = (rect.bottom - rect.top) / 4 |
|
|
|
return Circle(rect.left, rect.bottom, radius) |
|
|
|
val width = rect.right - rect.left |
|
|
|
|
|
|
|
val x: Float; val y: Float |
|
|
|
|
|
|
|
if (this.dealerBottomOriented) { |
|
|
|
|
|
|
|
x = rect.left |
|
|
|
|
|
|
|
y = (rect.top + rect.bottom) / 2f |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
x = rect.left + width / 6.0f |
|
|
|
|
|
|
|
y = rect.bottom |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return Circle(x, y, radius) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private var playerItemsHeight = 10f |
|
|
|
private var playerItemsHeight = 10f |
|
|
|
@ -250,15 +260,21 @@ class ReplayerAnimator(var handHistory: HandHistory, var export: Boolean) { |
|
|
|
this.height = height |
|
|
|
this.height = height |
|
|
|
|
|
|
|
|
|
|
|
val maxPlayerCards = this.handHistory.maxPlayerCards |
|
|
|
val maxPlayerCards = this.handHistory.maxPlayerCards |
|
|
|
|
|
|
|
val hwRatio = 1.3f |
|
|
|
|
|
|
|
val portrait = height > width |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
val base = 3.3f + this.handHistory.numberOfPlayers / 20.0f |
|
|
|
|
|
|
|
val playerPerColumn = if (portrait) base * hwRatio else base |
|
|
|
|
|
|
|
val playerPerRow = if (portrait) base else base * hwRatio |
|
|
|
|
|
|
|
|
|
|
|
val grid = when (this.handHistory.numberOfPlayers) { |
|
|
|
val grid = when (this.handHistory.numberOfPlayers) { |
|
|
|
9, 10 -> Pair(4f, 5f) |
|
|
|
9, 10 -> Pair(4f, 5f) |
|
|
|
else -> Pair(3.7f, 4.7f) |
|
|
|
else -> Pair(3.7f, 4.7f) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
val portrait = height > width |
|
|
|
Timber.d("playerPerRow = $playerPerRow, playerPerColumn = $playerPerColumn") |
|
|
|
|
|
|
|
// val playerPerColumn = if (portrait) grid.second else grid.first |
|
|
|
val playerPerColumn = if (portrait) grid.second else grid.first |
|
|
|
// val playerPerRow = if (portrait) grid.first else grid.second |
|
|
|
val playerPerRow = if (portrait) grid.first else grid.second |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
val padding = if (portrait) 0.8f else 0.95f |
|
|
|
val padding = if (portrait) 0.8f else 0.95f |
|
|
|
this.tableHPadding = width / playerPerRow / 2 * padding |
|
|
|
this.tableHPadding = width / playerPerRow / 2 * padding |
|
|
|
@ -280,14 +296,15 @@ class ReplayerAnimator(var handHistory: HandHistory, var export: Boolean) { |
|
|
|
this.playerItemsWidth = this.tableHPadding * 2 * this.paddingPercentage |
|
|
|
this.playerItemsWidth = this.tableHPadding * 2 * this.paddingPercentage |
|
|
|
this.chipRadius = this.playerItemsHeight / 4 |
|
|
|
this.chipRadius = this.playerItemsHeight / 4 |
|
|
|
|
|
|
|
|
|
|
|
val cardWPaddingWidth = this.playerItemsWidth * 1.5f / this.maxCards |
|
|
|
val cardWPaddingWidth = this.playerItemsWidth * 1.4f / this.maxCards |
|
|
|
val cardWidth = cardWPaddingWidth * this.cardsPaddingPercentage |
|
|
|
val cardWidth = cardWPaddingWidth * this.cardsPaddingPercentage |
|
|
|
this.cardSpecs = Size(cardWidth, cardWidth * 1.75f) |
|
|
|
this.cardSpecs = Size(cardWidth, cardWidth * 1.75f) |
|
|
|
this.cardRadius = cardWidth / 4 |
|
|
|
this.cardRadius = cardWidth / 4 |
|
|
|
|
|
|
|
|
|
|
|
// Board cards rectangles |
|
|
|
// Board cards rectangles |
|
|
|
val bcTop = centerY - cardSpecs.height / 2 |
|
|
|
val bcCenterY = centerY + cardSpecs.height / 2 |
|
|
|
val bcBottom = centerY + cardSpecs.height / 2 |
|
|
|
val bcTop = bcCenterY - cardSpecs.height / 2 |
|
|
|
|
|
|
|
val bcBottom = bcCenterY + cardSpecs.height / 2 |
|
|
|
val boardCards = 5 |
|
|
|
val boardCards = 5 |
|
|
|
for (i in 0 until boardCards) { |
|
|
|
for (i in 0 until boardCards) { |
|
|
|
val bcLeft = centerX - (boardCards / 2f - i) * cardWPaddingWidth |
|
|
|
val bcLeft = centerX - (boardCards / 2f - i) * cardWPaddingWidth |
|
|
|
@ -296,9 +313,9 @@ class ReplayerAnimator(var handHistory: HandHistory, var export: Boolean) { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
val chipTextSize = this.chipRadius |
|
|
|
val chipTextSize = this.chipRadius |
|
|
|
this.potChipCircle = Circle(centerX, centerY - 5.2f * chipTextSize, this.chipRadius) |
|
|
|
this.potChipCircle = Circle(centerX, bcTop - 3.7f * chipTextSize, this.chipRadius) |
|
|
|
this.potTextPoint = TextPoint(centerX, centerY - 3.2f * chipTextSize, chipTextSize) |
|
|
|
this.potTextPoint = TextPoint(centerX, bcTop - 1.6f * chipTextSize, chipTextSize) |
|
|
|
this.totalPotTextPoint = TextPoint(centerX, centerY - 2.2f * chipTextSize, chipTextSize) |
|
|
|
this.totalPotTextPoint = TextPoint(centerX, bcTop - 0.5f * chipTextSize, chipTextSize) |
|
|
|
|
|
|
|
|
|
|
|
val playerCount = this.handHistory.numberOfPlayers |
|
|
|
val playerCount = this.handHistory.numberOfPlayers |
|
|
|
|
|
|
|
|
|
|
|
@ -307,6 +324,8 @@ class ReplayerAnimator(var handHistory: HandHistory, var export: Boolean) { |
|
|
|
|
|
|
|
|
|
|
|
val point = positions[i].first |
|
|
|
val point = positions[i].first |
|
|
|
val bottomOriented = positions[i].second |
|
|
|
val bottomOriented = positions[i].second |
|
|
|
|
|
|
|
if (i == positions.size - 1) { dealerBottomOriented = bottomOriented } |
|
|
|
|
|
|
|
|
|
|
|
val rectCenterX = point.x |
|
|
|
val rectCenterX = point.x |
|
|
|
val rectCenterY = point.y |
|
|
|
val rectCenterY = point.y |
|
|
|
|
|
|
|
|
|
|
|
@ -321,7 +340,7 @@ class ReplayerAnimator(var handHistory: HandHistory, var export: Boolean) { |
|
|
|
val prp = line.intersects(pRect) ?: throw PAIllegalStateException("should not happen") |
|
|
|
val prp = line.intersects(pRect) ?: throw PAIllegalStateException("should not happen") |
|
|
|
|
|
|
|
|
|
|
|
val boxToCenterLine = MathUtils.Line(prp.x, prp.y, tableRect.centerX(), tableRect.centerY()) |
|
|
|
val boxToCenterLine = MathUtils.Line(prp.x, prp.y, tableRect.centerX(), tableRect.centerY()) |
|
|
|
val boxToChipDistance = if (bottomOriented) 3.3f * chipRadius else 2 * chipRadius // because the chip text needs space |
|
|
|
val boxToChipDistance = if (bottomOriented) 3f * chipRadius else 2f * chipRadius // because the chip text needs space |
|
|
|
val chipPoint = boxToCenterLine.pointForDistance(boxToChipDistance) |
|
|
|
val chipPoint = boxToCenterLine.pointForDistance(boxToChipDistance) |
|
|
|
|
|
|
|
|
|
|
|
this.chipCircles.add(Circle(chipPoint.x, chipPoint.y, chipRadius)) |
|
|
|
this.chipCircles.add(Circle(chipPoint.x, chipPoint.y, chipRadius)) |
|
|
|
@ -356,10 +375,10 @@ class ReplayerAnimator(var handHistory: HandHistory, var export: Boolean) { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
this.playerCardRects.add(cardsRectangles) |
|
|
|
this.playerCardRects.add(cardsRectangles) |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
fun drawTable(canvas: Canvas, context: Context) { |
|
|
|
fun drawTable(canvas: Canvas, context: Context) { |
|
|
|
this.drawer.drawTable(canvas, context) |
|
|
|
this.drawer.drawTable(canvas, context) |
|
|
|
} |
|
|
|
} |
|
|
|
|