|
|
|
@ -8,7 +8,6 @@ import net.pokeranalytics.android.R |
|
|
|
import net.pokeranalytics.android.exceptions.PAIllegalStateException |
|
|
|
import net.pokeranalytics.android.exceptions.PAIllegalStateException |
|
|
|
import net.pokeranalytics.android.model.handhistory.Position |
|
|
|
import net.pokeranalytics.android.model.handhistory.Position |
|
|
|
import net.pokeranalytics.android.model.handhistory.Street |
|
|
|
import net.pokeranalytics.android.model.handhistory.Street |
|
|
|
import net.pokeranalytics.android.model.realm.handhistory.Action |
|
|
|
|
|
|
|
import net.pokeranalytics.android.model.realm.handhistory.Card |
|
|
|
import net.pokeranalytics.android.model.realm.handhistory.Card |
|
|
|
import net.pokeranalytics.android.ui.modules.handhistory.model.ComputedAction |
|
|
|
import net.pokeranalytics.android.ui.modules.handhistory.model.ComputedAction |
|
|
|
import net.pokeranalytics.android.util.RANDOM_PLAYER |
|
|
|
import net.pokeranalytics.android.util.RANDOM_PLAYER |
|
|
|
@ -77,31 +76,31 @@ class TableDrawer(bitmap: Bitmap) : Canvas(bitmap) { |
|
|
|
initializeTable(config, canvas, context) |
|
|
|
initializeTable(config, canvas, context) |
|
|
|
|
|
|
|
|
|
|
|
val step = config.currentStep |
|
|
|
val step = config.currentStep |
|
|
|
val street: Street |
|
|
|
|
|
|
|
var computedAction: ComputedAction? = null |
|
|
|
var computedAction: ComputedAction? = null |
|
|
|
when (step) { |
|
|
|
val street = when (step) { |
|
|
|
is Street -> { |
|
|
|
is Street -> step |
|
|
|
street = step |
|
|
|
|
|
|
|
config.lastActionBeforeStreet(street)?.let { |
|
|
|
|
|
|
|
drawPot(it, config, canvas, context) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
is ComputedAction -> { |
|
|
|
is ComputedAction -> { |
|
|
|
street = step.street |
|
|
|
|
|
|
|
computedAction = step |
|
|
|
computedAction = step |
|
|
|
drawPot(step, config, canvas, context) |
|
|
|
step.street |
|
|
|
} |
|
|
|
} |
|
|
|
else -> throw PAIllegalStateException("Step unmanaged: $step") |
|
|
|
else -> throw PAIllegalStateException("Step unmanaged: $step") |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// draw pot |
|
|
|
|
|
|
|
val potAction = computedAction ?: config.lastActionBeforeStreet(street) |
|
|
|
|
|
|
|
potAction?.let { drawPot(potAction, config, canvas, context) } |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// draw board |
|
|
|
drawBoardCards(street, config, canvas, context) |
|
|
|
drawBoardCards(street, config, canvas, context) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// draw player shapes and chips |
|
|
|
val hh = config.handHistory |
|
|
|
val hh = config.handHistory |
|
|
|
for (i in 0 until hh.numberOfPlayers) { |
|
|
|
for (i in 0 until hh.numberOfPlayers) { |
|
|
|
drawPlayerShapes(i, computedAction, config, canvas, context) |
|
|
|
drawPlayerShapes(i, computedAction, config, canvas, context) |
|
|
|
drawPlayerChips(i, config, canvas, context) |
|
|
|
drawPlayerChips(i, config, canvas, context) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// show player cards |
|
|
|
// draw player cards |
|
|
|
config.activePositions.forEach { |
|
|
|
config.activePositions.forEach { |
|
|
|
drawCards(it, config, canvas, context) |
|
|
|
drawCards(it, config, canvas, context) |
|
|
|
} |
|
|
|
} |
|
|
|
@ -111,10 +110,9 @@ class TableDrawer(bitmap: Bitmap) : Canvas(bitmap) { |
|
|
|
private fun drawPlayerShapes(i: Int, computedAction: ComputedAction?, config: ReplayerConfiguration, canvas: Canvas, context: Context) { |
|
|
|
private fun drawPlayerShapes(i: Int, computedAction: ComputedAction?, config: ReplayerConfiguration, canvas: Canvas, context: Context) { |
|
|
|
|
|
|
|
|
|
|
|
// draw player rectangles with action or name + stack |
|
|
|
// draw player rectangles with action or name + stack |
|
|
|
val actionType = computedAction?.action?.type |
|
|
|
if (computedAction?.positionIndex == i) { |
|
|
|
if (computedAction?.positionIndex == i && actionType != null) { |
|
|
|
|
|
|
|
drawPlayerRectangle(i, true, config, canvas, context) |
|
|
|
drawPlayerRectangle(i, true, config, canvas, context) |
|
|
|
drawAction(i, actionType, config, canvas, context) |
|
|
|
drawAction(i, computedAction, config, canvas, context) |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
val remainingStack = config.playerRemainingStack(i) |
|
|
|
val remainingStack = config.playerRemainingStack(i) |
|
|
|
drawPlayerRectangle(i, false, config, canvas, context) |
|
|
|
drawPlayerRectangle(i, false, config, canvas, context) |
|
|
|
@ -341,11 +339,26 @@ 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, action: ComputedAction, config: ReplayerConfiguration, canvas: Canvas, context: Context) { |
|
|
|
val pnPoint = config.pointForPlayerAction(i) |
|
|
|
|
|
|
|
this.textPaint.textSize = pnPoint.fontSize |
|
|
|
action.action.type?.let { type -> |
|
|
|
val actionName = context.getString(type.resId) |
|
|
|
val actionName = context.getString(type.resId) |
|
|
|
canvas.drawText(actionName, pnPoint.x, pnPoint.y, this.textPaint) |
|
|
|
val actionPoint: ReplayerConfiguration.TextPoint |
|
|
|
|
|
|
|
if (!type.isPassive) { // show action + amount |
|
|
|
|
|
|
|
actionPoint = config.pointForPlayerName(i) |
|
|
|
|
|
|
|
action.action.displayedAmount?.let { amount -> |
|
|
|
|
|
|
|
val amountPoint = config.pointForPlayerStack(i) |
|
|
|
|
|
|
|
this.textPaint.textSize = amountPoint.fontSize |
|
|
|
|
|
|
|
canvas.drawText(amount.formatted, amountPoint.x, amountPoint.y, this.textPaint) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} else { // show action name only |
|
|
|
|
|
|
|
actionPoint = config.pointForPlayerAction(i) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
this.textPaint.textSize = actionPoint.fontSize |
|
|
|
|
|
|
|
canvas.drawText(actionName, actionPoint.x, actionPoint.y, this.textPaint) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private fun drawBoardCards(street: Street, config: ReplayerConfiguration, canvas: Canvas, context: Context) { |
|
|
|
private fun drawBoardCards(street: Street, config: ReplayerConfiguration, canvas: Canvas, context: Context) { |
|
|
|
|