|
|
|
@ -105,14 +105,6 @@ class ReplayerAnimator(var handHistory: HandHistory, var export: Boolean) { |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/*** |
|
|
|
|
|
|
|
* Returns if the animator has more steps to display |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
private val hasMoreSteps: Boolean |
|
|
|
|
|
|
|
get() { |
|
|
|
|
|
|
|
return this.currentStepIndex < this.steps.size - 1 |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*** |
|
|
|
/*** |
|
|
|
* Returns if the animator has more frame to show |
|
|
|
* Returns if the animator has more frame to show |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
@ -132,11 +124,6 @@ class ReplayerAnimator(var handHistory: HandHistory, var export: Boolean) { |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
private var steps: List<HandStep> = listOf() |
|
|
|
private var steps: List<HandStep> = listOf() |
|
|
|
|
|
|
|
|
|
|
|
/*** |
|
|
|
|
|
|
|
* The index of the last blind in the action list |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
// private var lastBlindIndex: Int = 0 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private var currentStepIndex: Int = 0 |
|
|
|
private var currentStepIndex: Int = 0 |
|
|
|
set(value) { |
|
|
|
set(value) { |
|
|
|
val backwards = value < field |
|
|
|
val backwards = value < field |
|
|
|
@ -168,12 +155,9 @@ class ReplayerAnimator(var handHistory: HandHistory, var export: Boolean) { |
|
|
|
* Let the animator know when a frame has been drawn |
|
|
|
* Let the animator know when a frame has been drawn |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
fun frameDrawn() { |
|
|
|
fun frameDrawn() { |
|
|
|
// Timber.d("a>frameDrawn: ${this.currentFrameIndex}, total: ${this.numberOfFramesForCurrentStep}") |
|
|
|
|
|
|
|
if (this.currentFrameIndex < this.numberOfFramesForCurrentStep - 1) { |
|
|
|
if (this.currentFrameIndex < this.numberOfFramesForCurrentStep - 1) { |
|
|
|
this.currentFrameIndex += 1 |
|
|
|
this.currentFrameIndex += 1 |
|
|
|
} |
|
|
|
} |
|
|
|
// Timber.d("b>frameDrawn: ${this.currentFrameIndex}") |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/*** |
|
|
|
/*** |
|
|
|
@ -272,9 +256,6 @@ class ReplayerAnimator(var handHistory: HandHistory, var export: Boolean) { |
|
|
|
this.tableCornerXRadius = this.tableRect.width() / 3 |
|
|
|
this.tableCornerXRadius = this.tableRect.width() / 3 |
|
|
|
this.tableCornerYRadius = this.tableRect.height() / 3 |
|
|
|
this.tableCornerYRadius = this.tableRect.height() / 3 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// this.tableCornerRadius = (if (portrait) width else height) / 8 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.tableStrokeWidth = tableHPadding / 5f |
|
|
|
this.tableStrokeWidth = tableHPadding / 5f |
|
|
|
this.playerStrokeWidth = this.tableStrokeWidth / 4f |
|
|
|
this.playerStrokeWidth = this.tableStrokeWidth / 4f |
|
|
|
this.cardStrokeWidth = this.tableStrokeWidth / 4f |
|
|
|
this.cardStrokeWidth = this.tableStrokeWidth / 4f |
|
|
|
@ -323,9 +304,6 @@ class ReplayerAnimator(var handHistory: HandHistory, var export: Boolean) { |
|
|
|
val pRect = RectF(left, top, right, bottom) |
|
|
|
val pRect = RectF(left, top, right, bottom) |
|
|
|
this.playerStackRects.add(pRect) |
|
|
|
this.playerStackRects.add(pRect) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// val chipCircleY = rectCenterY + chipYOffset - chipTextYOffsetCoef * chipRadius |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
val line = MathUtils.Line(point.x, point.y, tableRect.centerX(), tableRect.centerY()) |
|
|
|
val line = MathUtils.Line(point.x, point.y, tableRect.centerX(), tableRect.centerY()) |
|
|
|
val prp = line.intersects(pRect) ?: throw PAIllegalStateException("should not happen") |
|
|
|
val prp = line.intersects(pRect) ?: throw PAIllegalStateException("should not happen") |
|
|
|
|
|
|
|
|
|
|
|
@ -368,143 +346,6 @@ class ReplayerAnimator(var handHistory: HandHistory, var export: Boolean) { |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// number of players in this order: bottom / left / top / right |
|
|
|
|
|
|
|
// val repartition = when (playerCount) { |
|
|
|
|
|
|
|
// 2 -> mutableListOf(1, 0, 1, 0) |
|
|
|
|
|
|
|
// 3 -> mutableListOf(1, 1, 0, 1) |
|
|
|
|
|
|
|
// 4 -> mutableListOf(1, 1, 1, 1) |
|
|
|
|
|
|
|
// 5 -> mutableListOf(1, 1, 2, 1) |
|
|
|
|
|
|
|
// 6 -> mutableListOf(2, 1, 2, 1) |
|
|
|
|
|
|
|
// 7 -> mutableListOf(2, 1, 3, 1) |
|
|
|
|
|
|
|
// 8 -> mutableListOf(3, 1, 3, 1) |
|
|
|
|
|
|
|
// 9 -> mutableListOf(3, 1, 4, 1) |
|
|
|
|
|
|
|
// 10 -> mutableListOf(4, 1, 4, 1) |
|
|
|
|
|
|
|
// else -> throw PAIllegalStateException("can't happen") |
|
|
|
|
|
|
|
// } |
|
|
|
|
|
|
|
// if (repartition.sum() != playerCount) { |
|
|
|
|
|
|
|
// throw PAIllegalStateException("Problem in the $playerCount players repartition: $repartition") |
|
|
|
|
|
|
|
// } |
|
|
|
|
|
|
|
// if (portrait && playerCount > 4) { repartition.reverse() } // adjustment for portrait vs landscape |
|
|
|
|
|
|
|
// |
|
|
|
|
|
|
|
// val chipsVerticalOffsetFromStackCenter = this.playerItemsHeight * 0.9f |
|
|
|
|
|
|
|
// val chipsHorizontalOffsetFromStackCenter = this.tableHPadding * 1.2f |
|
|
|
|
|
|
|
// |
|
|
|
|
|
|
|
// var pIndex = -1 |
|
|
|
|
|
|
|
// repartition.forEachIndexed { index, count -> |
|
|
|
|
|
|
|
// |
|
|
|
|
|
|
|
// val xItemSpacing = width / (count + 1) |
|
|
|
|
|
|
|
// val yItemSpacing = height / (count + 1) |
|
|
|
|
|
|
|
// |
|
|
|
|
|
|
|
// var rectCenterX: Float |
|
|
|
|
|
|
|
// var rectCenterY: Float |
|
|
|
|
|
|
|
// var chipXOffset: Float |
|
|
|
|
|
|
|
// var chipYOffset: Float |
|
|
|
|
|
|
|
// var chipTextYOffsetCoef = 0f |
|
|
|
|
|
|
|
// var circleOffset = playerItemsHeight * 1.75f |
|
|
|
|
|
|
|
// |
|
|
|
|
|
|
|
// for (i in 1..count) { |
|
|
|
|
|
|
|
// |
|
|
|
|
|
|
|
// pIndex += 1 |
|
|
|
|
|
|
|
// Timber.d("Creating dimensions for player $pIndex") |
|
|
|
|
|
|
|
// |
|
|
|
|
|
|
|
// // when the position is in a corner, because we have 3/4 players |
|
|
|
|
|
|
|
// // we need an additional offset direction to display the chips |
|
|
|
|
|
|
|
// val cornerDirection = when { |
|
|
|
|
|
|
|
// count > 2 && i == 1 -> { 1 } |
|
|
|
|
|
|
|
// count > 2 && i == count -> { - 1 } |
|
|
|
|
|
|
|
// else -> { 0 } |
|
|
|
|
|
|
|
// } |
|
|
|
|
|
|
|
// |
|
|
|
|
|
|
|
// when (index) { |
|
|
|
|
|
|
|
// 0 -> { // bottom |
|
|
|
|
|
|
|
// rectCenterX = xItemSpacing * i |
|
|
|
|
|
|
|
// rectCenterY = height - this.tableVPadding |
|
|
|
|
|
|
|
// circleOffset *= -1 |
|
|
|
|
|
|
|
// chipXOffset = cornerDirection * chipsHorizontalOffsetFromStackCenter |
|
|
|
|
|
|
|
// chipYOffset = -1 * chipsVerticalOffsetFromStackCenter |
|
|
|
|
|
|
|
// chipTextYOffsetCoef = 1f |
|
|
|
|
|
|
|
// } |
|
|
|
|
|
|
|
// 1 -> { // left |
|
|
|
|
|
|
|
// rectCenterY = if (count == 4 && (i == 2 || i == 3)) { |
|
|
|
|
|
|
|
// height - yItemSpacing - this.playerItemsHeight * 1.2f - pzHeight * (i - 2) |
|
|
|
|
|
|
|
// } else { |
|
|
|
|
|
|
|
// height - yItemSpacing * i |
|
|
|
|
|
|
|
// } |
|
|
|
|
|
|
|
// rectCenterX = this.tableHPadding |
|
|
|
|
|
|
|
//// rectCenterY = height - yItemSpacing * i |
|
|
|
|
|
|
|
// chipXOffset = 1 * chipsHorizontalOffsetFromStackCenter |
|
|
|
|
|
|
|
// chipYOffset = cornerDirection * -1 * chipsVerticalOffsetFromStackCenter |
|
|
|
|
|
|
|
// chipTextYOffsetCoef = 1f * (i - 1) / count |
|
|
|
|
|
|
|
// |
|
|
|
|
|
|
|
// if (count == 4 && i == 1) { |
|
|
|
|
|
|
|
// circleOffset *= -1 |
|
|
|
|
|
|
|
// } else { |
|
|
|
|
|
|
|
// circleOffset = abs(circleOffset) |
|
|
|
|
|
|
|
// } |
|
|
|
|
|
|
|
// |
|
|
|
|
|
|
|
// } |
|
|
|
|
|
|
|
// 2 -> { // top |
|
|
|
|
|
|
|
// rectCenterX = xItemSpacing * i |
|
|
|
|
|
|
|
// rectCenterY = this.tableVPadding |
|
|
|
|
|
|
|
// chipXOffset = cornerDirection * -1 * chipsHorizontalOffsetFromStackCenter |
|
|
|
|
|
|
|
// chipYOffset = 1 * chipsVerticalOffsetFromStackCenter |
|
|
|
|
|
|
|
// } |
|
|
|
|
|
|
|
// 3 -> { // right |
|
|
|
|
|
|
|
// rectCenterX = width - this.tableHPadding |
|
|
|
|
|
|
|
// rectCenterY = yItemSpacing * i |
|
|
|
|
|
|
|
// chipXOffset = -1 * chipsHorizontalOffsetFromStackCenter |
|
|
|
|
|
|
|
// chipYOffset = cornerDirection * chipsVerticalOffsetFromStackCenter |
|
|
|
|
|
|
|
// chipTextYOffsetCoef = 1f * (count - i + 1) / count |
|
|
|
|
|
|
|
// } |
|
|
|
|
|
|
|
// else -> throw PAIllegalStateException("can't happen") |
|
|
|
|
|
|
|
// } |
|
|
|
|
|
|
|
// |
|
|
|
|
|
|
|
// val left = rectCenterX - this.playerItemsWidth / 2 |
|
|
|
|
|
|
|
// val top = rectCenterY - this.playerItemsHeight / 2 |
|
|
|
|
|
|
|
// val right = rectCenterX + this.playerItemsWidth / 2 |
|
|
|
|
|
|
|
// val bottom = rectCenterY + this.playerItemsHeight / 2 |
|
|
|
|
|
|
|
// this.playerStackRects.add(RectF(left, top, right, bottom)) |
|
|
|
|
|
|
|
// |
|
|
|
|
|
|
|
// |
|
|
|
|
|
|
|
// val chipCircleY = rectCenterY + chipYOffset - chipTextYOffsetCoef * chipRadius |
|
|
|
|
|
|
|
// |
|
|
|
|
|
|
|
// this.chipCircles.add(Circle(rectCenterX + chipXOffset, chipCircleY, chipRadius)) |
|
|
|
|
|
|
|
// |
|
|
|
|
|
|
|
// this.chipTextPoints.add(TextPoint(rectCenterX + chipXOffset, chipCircleY + 2 * chipTextSize, chipTextSize)) |
|
|
|
|
|
|
|
// |
|
|
|
|
|
|
|
// // we give each text zone 1/3rd of the box height, leaving 1/3 for space |
|
|
|
|
|
|
|
// // the y given is the bottom of the text rect, giving 1/18th as the offset |
|
|
|
|
|
|
|
// // 1 / (3_total_space * 3_each_space * 2_center) |
|
|
|
|
|
|
|
// |
|
|
|
|
|
|
|
// val bottomOffset = this.playerItemsHeight / (3 * 3 * 2) |
|
|
|
|
|
|
|
// val fontSize = this.playerItemsHeight / 3 |
|
|
|
|
|
|
|
// this.playerNamePoints.add(TextPoint(rectCenterX, rectCenterY - bottomOffset, fontSize)) |
|
|
|
|
|
|
|
// this.playerStackPoints.add(TextPoint(rectCenterX, rectCenterY + this.playerItemsHeight / 3, fontSize)) |
|
|
|
|
|
|
|
// this.playerActionPoints.add(TextPoint(rectCenterX, rectCenterY + this.playerItemsHeight / 9, fontSize)) |
|
|
|
|
|
|
|
// |
|
|
|
|
|
|
|
// this.playerCircles.add(Circle(rectCenterX, rectCenterY - circleOffset, this.playerItemsHeight / 2)) |
|
|
|
|
|
|
|
// |
|
|
|
|
|
|
|
// val cardsUsed = this.handHistory.playerSetupForPosition(pIndex)?.cards?.size ?: maxPlayerCards |
|
|
|
|
|
|
|
// val cardsRectangles = mutableListOf<RectF>() |
|
|
|
|
|
|
|
// if (cardsUsed > 0) { |
|
|
|
|
|
|
|
// val offSet = (cardsUsed / 2 - 0.5f) * cardWPaddingWidth |
|
|
|
|
|
|
|
// |
|
|
|
|
|
|
|
// val cardCenterY = rectCenterY - circleOffset / 2 |
|
|
|
|
|
|
|
// for (c in 0 until cardsUsed) { |
|
|
|
|
|
|
|
// |
|
|
|
|
|
|
|
// val cardCenterX = rectCenterX - offSet + c * cardWPaddingWidth |
|
|
|
|
|
|
|
// val cardRect = RectF(cardCenterX - cardSpecs.width / 2, cardCenterY - cardSpecs.height / 2, cardCenterX + cardSpecs.width / 2, cardCenterY + cardSpecs.height / 2) |
|
|
|
|
|
|
|
// cardsRectangles.add(cardRect) |
|
|
|
|
|
|
|
// } |
|
|
|
|
|
|
|
// } |
|
|
|
|
|
|
|
// this.playerCardRects.add(cardsRectangles) |
|
|
|
|
|
|
|
// |
|
|
|
|
|
|
|
// } |
|
|
|
|
|
|
|
// |
|
|
|
|
|
|
|
// } |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
fun stackRectForPlayer(positionIndex: Int): RectF { |
|
|
|
fun stackRectForPlayer(positionIndex: Int): RectF { |
|
|
|
|