diff --git a/bgw-gui/src/jsMain/kotlin/tools/aqua/bgw/event/EventHandlers.kt b/bgw-gui/src/jsMain/kotlin/tools/aqua/bgw/event/EventHandlers.kt index 739017271..44ab50812 100644 --- a/bgw-gui/src/jsMain/kotlin/tools/aqua/bgw/event/EventHandlers.kt +++ b/bgw-gui/src/jsMain/kotlin/tools/aqua/bgw/event/EventHandlers.kt @@ -29,10 +29,10 @@ import tools.aqua.bgw.builder.ReactConverters.toMouseReleasedEventData import web.dom.Element internal fun HTMLAttributes.applyCommonEventHandlers(props: ComponentViewData) { - onContextMenu = { + /*onContextMenu = { it.preventDefault() JCEFEventDispatcher.dispatchEvent(it.toMouseEventData(props.id)) - } + }*/ onClick = { JCEFEventDispatcher.dispatchEvent(it.toMouseEventData(props.id)) } onMouseDown = { JCEFEventDispatcher.dispatchEvent(it.toMousePressedEventData(props.id)) } onMouseUp = { JCEFEventDispatcher.dispatchEvent(it.toMouseReleasedEventData(props.id)) } diff --git a/bgw-gui/src/jvmMain/kotlin/tools/aqua/bgw/binding/KtorApplication.kt b/bgw-gui/src/jvmMain/kotlin/tools/aqua/bgw/binding/KtorApplication.kt index 3227da6f0..eea549029 100644 --- a/bgw-gui/src/jvmMain/kotlin/tools/aqua/bgw/binding/KtorApplication.kt +++ b/bgw-gui/src/jvmMain/kotlin/tools/aqua/bgw/binding/KtorApplication.kt @@ -34,6 +34,11 @@ import kotlinx.html.* import kotlinx.serialization.encodeToString import tools.aqua.bgw.application.JCEFApplication import tools.aqua.bgw.core.Frontend +import java.io.ByteArrayOutputStream +import java.util.Base64 +import java.util.zip.GZIPInputStream +import java.util.zip.GZIPOutputStream +import kotlin.text.Charsets.UTF_8 internal val componentChannel: Channel = Channel("/ws").apply { @@ -108,6 +113,17 @@ internal fun CoroutineScope.launchPeriodicAsync(repeatMillis: Long, action: (sus } } + + +internal fun gzip(content: String): String { + val bos = ByteArrayOutputStream() + GZIPOutputStream(bos).bufferedWriter(UTF_8).use { it.write(content) } + return Base64.getEncoder().encodeToString(bos.toByteArray()) +} + +internal fun ungzip(content: ByteArray): String = + GZIPInputStream(content.inputStream()).bufferedReader(UTF_8).use { it.readText() } + internal var uiJob = CoroutineScope(Dispatchers.IO).launchPeriodicAsync(10) { if ((Frontend.applicationEngine as JCEFApplication).getTitle() !== diff --git a/bgw-gui/src/jvmMain/kotlin/tools/aqua/bgw/components/container/HexagonGrid.kt b/bgw-gui/src/jvmMain/kotlin/tools/aqua/bgw/components/container/HexagonGrid.kt index b55aae9f5..903abf2be 100644 --- a/bgw-gui/src/jvmMain/kotlin/tools/aqua/bgw/components/container/HexagonGrid.kt +++ b/bgw-gui/src/jvmMain/kotlin/tools/aqua/bgw/components/container/HexagonGrid.kt @@ -40,6 +40,10 @@ private typealias AxialCoordinate = Pair * @param orientation The orientation of the hexagons in the grid. Default is * [HexOrientation.POINTY_TOP]. * + * @see CoordinateSystem + * @see HexOrientation + * @see HexagonView + * * @since 0.8 */ class HexagonGrid( diff --git a/bgw-gui/src/jvmMain/kotlin/tools/aqua/bgw/components/gamecomponentviews/CardView.kt b/bgw-gui/src/jvmMain/kotlin/tools/aqua/bgw/components/gamecomponentviews/CardView.kt index 85058e368..c0de1ac47 100644 --- a/bgw-gui/src/jvmMain/kotlin/tools/aqua/bgw/components/gamecomponentviews/CardView.kt +++ b/bgw-gui/src/jvmMain/kotlin/tools/aqua/bgw/components/gamecomponentviews/CardView.kt @@ -19,6 +19,7 @@ package tools.aqua.bgw.components.gamecomponentviews +import tools.aqua.bgw.components.gamecomponentviews.CardView.CardSide import tools.aqua.bgw.components.gamecomponentviews.CardView.CardSide.BACK import tools.aqua.bgw.components.gamecomponentviews.CardView.CardSide.FRONT import tools.aqua.bgw.core.DEFAULT_CARD_HEIGHT @@ -44,6 +45,10 @@ import tools.aqua.bgw.visual.Visual * @param height Height for this [CardView]. Default: [DEFAULT_CARD_HEIGHT]. * @param front Visual to represent the front side of the card. * @param back Visual to represent the back side of the card. Default: same [Visual] as front. + * + * @see CardSide + * + * @since 0.1 */ open class CardView( posX: Number = 0, @@ -60,6 +65,7 @@ open class CardView( * * @see showFront * @see showBack + * @see flip */ var currentSide: CardSide = FRONT set(value) { @@ -70,7 +76,7 @@ open class CardView( } } - /** Front [Visual] for this [CardView]. */ + /** Front [Visual] for this [CardView] to be displayed for [CardSide.FRONT]. */ var frontVisual: Visual = Visual.EMPTY /** Sets front [Visual] for this [CardView] as a copy of given [value]. */ set(value) { @@ -79,7 +85,7 @@ open class CardView( if (currentSide == FRONT) super.visual = field } - /** Back [Visual] for this [CardView]. */ + /** Back [Visual] for this [CardView] to be displayed for [CardSide.BACK]. */ var backVisual: Visual = Visual.EMPTY /** Sets back [Visual] for this [CardView] as a copy of given [value]. */ set(value) { @@ -117,7 +123,11 @@ open class CardView( currentSide = side } - /** Flips the [CardView] by seting the [currentSide] to the other value. */ + /** + * Flips the [CardView] by seting the [currentSide] to the other value. + * + * @since 0.7.1 + */ fun flip() { currentSide = if (currentSide == BACK) FRONT else BACK } diff --git a/bgw-gui/src/jvmMain/kotlin/tools/aqua/bgw/components/gamecomponentviews/DiceView.kt b/bgw-gui/src/jvmMain/kotlin/tools/aqua/bgw/components/gamecomponentviews/DiceView.kt index f34e68a48..16e439829 100644 --- a/bgw-gui/src/jvmMain/kotlin/tools/aqua/bgw/components/gamecomponentviews/DiceView.kt +++ b/bgw-gui/src/jvmMain/kotlin/tools/aqua/bgw/components/gamecomponentviews/DiceView.kt @@ -25,7 +25,7 @@ import tools.aqua.bgw.observable.lists.ObservableArrayList import tools.aqua.bgw.visual.Visual /** - * A [DiceView] may be used to visualize a dice. + * A [DiceView] may be used to visualize a die. * * Visualization: * @@ -38,6 +38,8 @@ import tools.aqua.bgw.visual.Visual * @param width Width for this [DiceView]. Default: [DEFAULT_DICE_WIDTH]. * @param height Height for this [DiceView]. Default: [DEFAULT_DICE_HEIGHT]. * @param visuals List of visuals to represent the sides of the die. + * + * @since 0.1 */ open class DiceView( posX: Number = 0, diff --git a/bgw-gui/src/jvmMain/kotlin/tools/aqua/bgw/components/gamecomponentviews/GameComponentView.kt b/bgw-gui/src/jvmMain/kotlin/tools/aqua/bgw/components/gamecomponentviews/GameComponentView.kt index 88bab18b0..b77dbef23 100644 --- a/bgw-gui/src/jvmMain/kotlin/tools/aqua/bgw/components/gamecomponentviews/GameComponentView.kt +++ b/bgw-gui/src/jvmMain/kotlin/tools/aqua/bgw/components/gamecomponentviews/GameComponentView.kt @@ -45,6 +45,7 @@ sealed class GameComponentView( ) : DynamicComponentView( posX = posX, posY = posY, width = width, height = height, visual = visual) { + /** @throws UnsupportedOperationException [GameComponentView] does not support children. */ override fun removeChild(component: ComponentView) { throw UnsupportedOperationException("This $this component has no children.") diff --git a/bgw-gui/src/jvmMain/kotlin/tools/aqua/bgw/components/gamecomponentviews/HexagonView.kt b/bgw-gui/src/jvmMain/kotlin/tools/aqua/bgw/components/gamecomponentviews/HexagonView.kt index f4368a755..d302dbd8e 100644 --- a/bgw-gui/src/jvmMain/kotlin/tools/aqua/bgw/components/gamecomponentviews/HexagonView.kt +++ b/bgw-gui/src/jvmMain/kotlin/tools/aqua/bgw/components/gamecomponentviews/HexagonView.kt @@ -32,12 +32,25 @@ import tools.aqua.bgw.visual.Visual * Default: [DEFAULT_HEXAGON_SIZE]. * @param visual Visual for this [HexagonView]. * @param orientation Orientation of the [HexagonView]. Default: [HexOrientation.POINTY_TOP]. + * + * @see HexOrientation + * @see HexagonView + * + * @since 0.8 */ open class HexagonView( posX: Number = 0, posY: Number = 0, val size: Number = DEFAULT_HEXAGON_SIZE, visual: Visual, + + /** + * Orientation of the [HexagonView]. + * + * @see HexOrientation + * + * @since 1.0 + */ var orientation: HexOrientation = HexOrientation.POINTY_TOP ) : GameComponentView( diff --git a/bgw-gui/src/jvmMain/kotlin/tools/aqua/bgw/components/gamecomponentviews/TokenView.kt b/bgw-gui/src/jvmMain/kotlin/tools/aqua/bgw/components/gamecomponentviews/TokenView.kt index f8ed980eb..503300080 100644 --- a/bgw-gui/src/jvmMain/kotlin/tools/aqua/bgw/components/gamecomponentviews/TokenView.kt +++ b/bgw-gui/src/jvmMain/kotlin/tools/aqua/bgw/components/gamecomponentviews/TokenView.kt @@ -37,6 +37,8 @@ import tools.aqua.bgw.visual.Visual * @param width Width for this TokenView. Default: [DEFAULT_TOKEN_WIDTH]. * @param height Height for this TokenView. Default: [DEFAULT_TOKEN_HEIGHT]. * @param visual Visual for this TokenView. + * + * @since 0.1 */ open class TokenView( posX: Number = 0, diff --git a/bgw-gui/src/jvmMain/kotlin/tools/aqua/bgw/visual/ImageVisual.kt b/bgw-gui/src/jvmMain/kotlin/tools/aqua/bgw/visual/ImageVisual.kt index 733f0e437..423620ece 100644 --- a/bgw-gui/src/jvmMain/kotlin/tools/aqua/bgw/visual/ImageVisual.kt +++ b/bgw-gui/src/jvmMain/kotlin/tools/aqua/bgw/visual/ImageVisual.kt @@ -42,8 +42,8 @@ import tools.aqua.bgw.observable.properties.StringProperty * @property offsetX Left bound of sub-image. Default: 0. * @property offsetY Top bound of sub-image. Default: 0. * - * @throws IllegalArgumentException If [path] is not a valid path or empty. - * @exception IllegalArgumentException If [path] was not found in resources. + * @throws IllegalArgumentException If [path] is not a valid path or empty or if [path] was not + * found in resources. * * @since 1.0 */ diff --git a/buildSrc/src/main/kotlin/tools.aqua.bgw.multiplatform-conventions.gradle.kts b/buildSrc/src/main/kotlin/tools.aqua.bgw.multiplatform-conventions.gradle.kts index d21e47d27..0b62b8710 100644 --- a/buildSrc/src/main/kotlin/tools.aqua.bgw.multiplatform-conventions.gradle.kts +++ b/buildSrc/src/main/kotlin/tools.aqua.bgw.multiplatform-conventions.gradle.kts @@ -217,12 +217,15 @@ publishing { } } -spotless { - kotlin { - target("src/*/kotlin/**/*.kt") - defaultFormat(rootProject) - } -} +//spotless { +// kotlin { +// target(rootProject.fileTree("bgw-gui/src") { +// include("**/*.kt") +// exclude("**/Config.kt") +// }) +// defaultFormat(rootProject) +// } +//} // Ignore yarn.lock mismatches rootProject.plugins.withType(org.jetbrains.kotlin.gradle.targets.js.yarn.YarnPlugin::class.java) {