|
|
|
@ -22,7 +22,7 @@ class TableDrawer(bitmap: Bitmap) : Canvas(bitmap) { |
|
|
|
private const val playerStrokeWidth = 8f |
|
|
|
private const val playerStrokeWidth = 8f |
|
|
|
private const val cardStrokeWidth = 8f |
|
|
|
private const val cardStrokeWidth = 8f |
|
|
|
|
|
|
|
|
|
|
|
private val backgroundColor = R.color.green_darker |
|
|
|
private const val backgroundColor = R.color.green_darker |
|
|
|
private val backgroundPaint = Paint() |
|
|
|
private val backgroundPaint = Paint() |
|
|
|
private val strokePaint = Paint() |
|
|
|
private val strokePaint = Paint() |
|
|
|
private val fillPaint = Paint() |
|
|
|
private val fillPaint = Paint() |
|
|
|
@ -58,6 +58,7 @@ class TableDrawer(bitmap: Bitmap) : Canvas(bitmap) { |
|
|
|
textPaint.color = context.getColor(R.color.white) |
|
|
|
textPaint.color = context.getColor(R.color.white) |
|
|
|
textPaint.textAlign = Paint.Align.CENTER |
|
|
|
textPaint.textAlign = Paint.Align.CENTER |
|
|
|
textPaint.isAntiAlias = true |
|
|
|
textPaint.isAntiAlias = true |
|
|
|
|
|
|
|
textPaint.typeface = ResourcesCompat.getFont(context, R.font.roboto_bold) |
|
|
|
|
|
|
|
|
|
|
|
cardTextPaint.color = context.getColor(R.color.black) |
|
|
|
cardTextPaint.color = context.getColor(R.color.black) |
|
|
|
cardTextPaint.typeface = ResourcesCompat.getFont(context, R.font.roboto_bold) |
|
|
|
cardTextPaint.typeface = ResourcesCompat.getFont(context, R.font.roboto_bold) |
|
|
|
@ -80,6 +81,7 @@ class TableDrawer(bitmap: Bitmap) : Canvas(bitmap) { |
|
|
|
Timber.d("Getting player $i setup ") |
|
|
|
Timber.d("Getting player $i setup ") |
|
|
|
val playerSetup = hh.playerSetupForPosition(i) |
|
|
|
val playerSetup = hh.playerSetupForPosition(i) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// drawCards(i, config, canvas, context) |
|
|
|
drawPlayerRectangle(i,false, config, canvas, context) |
|
|
|
drawPlayerRectangle(i,false, config, canvas, context) |
|
|
|
drawPositionAndStack(i, playerSetup?.stack, config, canvas, context) |
|
|
|
drawPositionAndStack(i, playerSetup?.stack, config, canvas, context) |
|
|
|
|
|
|
|
|
|
|
|
@ -87,32 +89,15 @@ class TableDrawer(bitmap: Bitmap) : Canvas(bitmap) { |
|
|
|
|
|
|
|
|
|
|
|
drawDealerButton(config, canvas, context) |
|
|
|
drawDealerButton(config, canvas, context) |
|
|
|
|
|
|
|
|
|
|
|
drawCards(i, config, canvas, context) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 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) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// val blinds = config.actionList.filter { it.action.type?.isBlind ?: false } |
|
|
|
} |
|
|
|
config.initialActions.forEach { action -> |
|
|
|
|
|
|
|
action.action.amount?.let { amount -> |
|
|
|
|
|
|
|
drawChip(amount, action.positionIndex, config, canvas, context) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
val pot = config.actionList.potSizeForStreet(action.street) |
|
|
|
|
|
|
|
val totalPot = config.actionList.totalPotSize(action.action.index + 1) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
drawPot(pot, totalPot, config, canvas, context) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// drawAction(action, false, config, canvas, context) |
|
|
|
fun drawCards(indexes: List<Int>, config: ReplayerConfiguration, canvas: Canvas, context: Context) { |
|
|
|
|
|
|
|
// val hh = config.handHistory |
|
|
|
|
|
|
|
for (i in indexes) { |
|
|
|
|
|
|
|
drawCards(i, config, canvas, context) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private fun drawDealerButton(config: ReplayerConfiguration, canvas: Canvas, context: Context) { |
|
|
|
private fun drawDealerButton(config: ReplayerConfiguration, canvas: Canvas, context: Context) { |
|
|
|
@ -155,18 +140,18 @@ class TableDrawer(bitmap: Bitmap) : Canvas(bitmap) { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private fun clearText(textPoint: ReplayerConfiguration.TextPoint, canvas: Canvas) { |
|
|
|
private fun clearText(textPoint: ReplayerConfiguration.TextPoint, canvas: Canvas) { |
|
|
|
this.clearZone(textPoint.toRect(), canvas) |
|
|
|
this.clearRect(textPoint.toRect(), canvas) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private fun clearCircle(circle: ReplayerConfiguration.Circle, canvas: Canvas) { |
|
|
|
private fun clearCircle(circle: ReplayerConfiguration.Circle, canvas: Canvas) { |
|
|
|
this.clearZone(circle.toRect(), canvas) |
|
|
|
this.clearRect(circle.toRect(), canvas) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private fun clearZone(rect: RectF, canvas: Canvas) { |
|
|
|
private fun clearRect(rect: RectF, canvas: Canvas) { |
|
|
|
canvas.drawRect(rect, this.backgroundPaint) |
|
|
|
canvas.drawRect(rect, this.backgroundPaint) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private fun drawCards(playerIndex: Int, config: ReplayerConfiguration, canvas: Canvas, context: Context) { |
|
|
|
fun drawCards(playerIndex: Int, config: ReplayerConfiguration, canvas: Canvas, context: Context) { |
|
|
|
|
|
|
|
|
|
|
|
val playerSetup = config.handHistory.playerSetupForPosition(playerIndex) |
|
|
|
val playerSetup = config.handHistory.playerSetupForPosition(playerIndex) |
|
|
|
val cardRects = config.cardRects(playerIndex) |
|
|
|
val cardRects = config.cardRects(playerIndex) |
|
|
|
@ -188,6 +173,12 @@ class TableDrawer(bitmap: Bitmap) : Canvas(bitmap) { |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// private fun clearCards(playerIndex: Int, config: ReplayerConfiguration, canvas: Canvas, context: Context) { |
|
|
|
|
|
|
|
// config.cardRects(playerIndex).forEach { |
|
|
|
|
|
|
|
// clearRect(it, canvas) |
|
|
|
|
|
|
|
// } |
|
|
|
|
|
|
|
// } |
|
|
|
|
|
|
|
|
|
|
|
private fun drawCard(card: Card, cardRect: RectF, config: ReplayerConfiguration, canvas: Canvas, context: Context) { |
|
|
|
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) |
|
|
|
@ -204,17 +195,42 @@ class TableDrawer(bitmap: Bitmap) : Canvas(bitmap) { |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fun drawPlayerPositionAndStack(action: ComputedAction, config: ReplayerConfiguration, canvas: Canvas, context: Context) { |
|
|
|
|
|
|
|
drawPlayerRectangle(action.positionIndex,false, config, canvas, context) |
|
|
|
|
|
|
|
drawPositionAndStack(action.positionIndex, action.stackAfterActing, config, canvas, context) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
fun drawAction(action: ComputedAction, highlighted: Boolean = true, config: ReplayerConfiguration, canvas: Canvas, context: Context) { |
|
|
|
fun drawAction(action: ComputedAction, highlighted: Boolean = true, config: ReplayerConfiguration, canvas: Canvas, context: Context) { |
|
|
|
|
|
|
|
|
|
|
|
// show that action is on the player by highlighting |
|
|
|
// show that action is on the player by highlighting |
|
|
|
drawPlayerRectangle(action.positionIndex, highlighted, config, canvas, context) |
|
|
|
drawPlayerRectangle(action.positionIndex, highlighted, config, canvas, context) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// redraw previous player rectangle |
|
|
|
|
|
|
|
action.previousAction?.let { previousAction -> |
|
|
|
|
|
|
|
drawPlayerPositionAndStack(previousAction, config, canvas, context) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// show action name : call, bet, check... |
|
|
|
// show action name : call, bet, check... |
|
|
|
drawAction(action.positionIndex, action.action.type!!, config, canvas, context) |
|
|
|
drawAction(action.positionIndex, action.action.type!!, config, canvas, context) |
|
|
|
|
|
|
|
|
|
|
|
// show chips image + text, if applicable |
|
|
|
// show chips image + text, if applicable |
|
|
|
|
|
|
|
when { |
|
|
|
// show pot updates, if applicable |
|
|
|
action.action.type?.isSignificant == true -> { |
|
|
|
|
|
|
|
action.action.amount?.let { amount -> |
|
|
|
|
|
|
|
drawChip(amount, action.positionIndex, config, canvas, context) |
|
|
|
|
|
|
|
drawPot(action, config, canvas, context) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
action.action.type?.isCall == true -> { |
|
|
|
|
|
|
|
action.getStreetLastSignificantAction()?.action?.amount?.let { amount -> |
|
|
|
|
|
|
|
drawChip(amount, action.positionIndex, config, canvas, context) |
|
|
|
|
|
|
|
drawPot(action, config, canvas, context) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
// action.action.type == Action.Type.FOLD -> { |
|
|
|
|
|
|
|
// clearCards(action.positionIndex, config, canvas, context) |
|
|
|
|
|
|
|
// } |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@ -254,7 +270,7 @@ class TableDrawer(bitmap: Bitmap) : Canvas(bitmap) { |
|
|
|
val rect = config.stackRectForPlayer(i) |
|
|
|
val rect = config.stackRectForPlayer(i) |
|
|
|
val rectRadius = (rect.bottom - rect.top) / 4 |
|
|
|
val rectRadius = (rect.bottom - rect.top) / 4 |
|
|
|
|
|
|
|
|
|
|
|
val color = if (highlighted) R.color.green_diamond_dark else R.color.green_darker |
|
|
|
val color = if (highlighted) R.color.kaki else R.color.green_darker |
|
|
|
fillPaint.color = context.getColor(color) |
|
|
|
fillPaint.color = context.getColor(color) |
|
|
|
canvas.drawRoundRect(config.stackRectForPlayer(i), rectRadius, rectRadius, this.fillPaint) |
|
|
|
canvas.drawRoundRect(config.stackRectForPlayer(i), rectRadius, rectRadius, this.fillPaint) |
|
|
|
strokePaint.color = context.getColor(R.color.green) |
|
|
|
strokePaint.color = context.getColor(R.color.green) |
|
|
|
@ -286,7 +302,8 @@ class TableDrawer(bitmap: Bitmap) : Canvas(bitmap) { |
|
|
|
private fun drawAction(i: Int, type: Action.Type, config: ReplayerConfiguration, canvas: Canvas, context: Context) { |
|
|
|
private fun drawAction(i: Int, type: Action.Type, config: ReplayerConfiguration, canvas: Canvas, context: Context) { |
|
|
|
val pnPoint = config.pointForPlayerAction(i) |
|
|
|
val pnPoint = config.pointForPlayerAction(i) |
|
|
|
this.textPaint.textSize = pnPoint.fontSize |
|
|
|
this.textPaint.textSize = pnPoint.fontSize |
|
|
|
canvas.drawText(type.name, pnPoint.x, pnPoint.y, this.textPaint) |
|
|
|
val actionName = context.getString(type.resId) |
|
|
|
|
|
|
|
canvas.drawText(actionName, pnPoint.x, pnPoint.y, this.textPaint) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
fun drawStreet(street: Street, config: ReplayerConfiguration, canvas: Canvas, context: Context) { |
|
|
|
fun drawStreet(street: Street, config: ReplayerConfiguration, canvas: Canvas, context: Context) { |
|
|
|
@ -296,9 +313,26 @@ class TableDrawer(bitmap: Bitmap) : Canvas(bitmap) { |
|
|
|
drawCard(cards[index], rectF, config, canvas, context) |
|
|
|
drawCard(cards[index], rectF, config, canvas, context) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Clear all chips |
|
|
|
|
|
|
|
val hh = config.handHistory |
|
|
|
|
|
|
|
for (i in 0 until hh.numberOfPlayers) { |
|
|
|
|
|
|
|
val pc = config.chipCircle(i) |
|
|
|
|
|
|
|
clearCircle(pc, canvas) |
|
|
|
|
|
|
|
val pct = config.chipText(i) |
|
|
|
|
|
|
|
clearText(pct, canvas) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Clear last action before street |
|
|
|
|
|
|
|
config.lastActionBeforeStreet(street)?.let { action -> |
|
|
|
|
|
|
|
drawPlayerPositionAndStack(action, config, canvas, context) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private fun drawPot(pot: Double, totalPot: Double, config: ReplayerConfiguration, canvas: Canvas, context: Context) { |
|
|
|
private fun drawPot(action: ComputedAction, config: ReplayerConfiguration, canvas: Canvas, context: Context) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
val pot = config.actionList.potSizeForStreet(action.street) |
|
|
|
|
|
|
|
val totalPot = config.actionList.totalPotSize(action.action.index + 1) |
|
|
|
|
|
|
|
|
|
|
|
drawChip(pot, config.potTextPoint, config.potChipCircle, canvas, context) |
|
|
|
drawChip(pot, config.potTextPoint, config.potChipCircle, canvas, context) |
|
|
|
val tpTextPoint = config.totalPotTextPoint |
|
|
|
val tpTextPoint = config.totalPotTextPoint |
|
|
|
@ -310,14 +344,6 @@ class TableDrawer(bitmap: Bitmap) : Canvas(bitmap) { |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
fun undoAction(computedAction: ComputedAction, highlighted: Boolean, configuration: ReplayerConfiguration, canvas: Canvas, context: Context) { |
|
|
|
|
|
|
|
// TODO |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fun undoStreet(street: Street, configuration: ReplayerConfiguration, canvas: Canvas, context: Context) { |
|
|
|
|
|
|
|
// TODO |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |