11package sc.gui.view
22
3- import io.github.oshai.kotlinlogging.KotlinLogging
43import javafx.animation.Animation
54import javafx.animation.KeyFrame
65import javafx.beans.value.ObservableDoubleValue
@@ -15,8 +14,6 @@ import tornadofx.*
1514import java.lang.ref.WeakReference
1615import kotlin.random.Random
1716
18- private val logger = KotlinLogging .logger { }
19-
2017val animationDuration = Duration .seconds(0.1 )
2118val transitionDuration = animationDuration.multiply(8.0 )
2219val animationInterval = timeline {
@@ -46,7 +43,7 @@ class ResizableImageView(sizeProperty: ObservableValue<Number>): ImageView() {
4643 override fun isResizable (): Boolean = true
4744
4845 override fun toString (): String =
49- " ${styleClass.joinToString(" ." )} @${Integer .toHexString(hashCode())}${pseudoClassStates.joinToString(" " ) { " :$it " }} "
46+ " ${styleClass.joinToString(" ." )} @${Integer .toHexString(hashCode())}${pseudoClassStates.joinToString(" " ) { " :$it " }} "
5047}
5148
5249/* * Holds a potentially animated piece on a position on the board.
@@ -70,14 +67,19 @@ class PieceImage(private val sizeProperty: ObservableDoubleValue, val content: S
7067 frame = nextFrame()
7168 }
7269
73- fun nextFrame (prefix : String = "idle", oldFrame : Int = frame, randomize : Boolean = true, remove : Boolean = false): Int {
70+ fun nextFrame (
71+ prefix : String = "idle",
72+ oldFrame : Int = frame,
73+ randomize : Boolean = true,
74+ remove : Boolean = false,
75+ ): Int {
7476 val img = children.lastOrNull()
7577 img?.removePseudoClass(" $prefix$oldFrame " )
7678 return if (! remove)
7779 (oldFrame.inc() + if (randomize) Random .nextInt(1 , 5 ).div(5 ) else 0 )
78- .mod(frameCount).also { newFrame ->
79- img?.addPseudoClass(" $prefix$newFrame " )
80- }
80+ .mod(frameCount).also { newFrame ->
81+ img?.addPseudoClass(" $prefix$newFrame " )
82+ }
8183 else - 1
8284 }
8385
@@ -93,9 +95,9 @@ class PieceImage(private val sizeProperty: ObservableDoubleValue, val content: S
9395 }
9496
9597 override fun toString (): String =
96- " $content @${Integer .toHexString(hashCode())} " +
97- pseudoClassStates.joinToString(" " ) { " :$it " } +
98- children
98+ " $content @${Integer .toHexString(hashCode())} " +
99+ pseudoClassStates.joinToString(" " ) { " :$it " } +
100+ children
99101
100102}
101103
0 commit comments