Skip to content

Commit

Permalink
Changed the hexagon size to be adjustable
Browse files Browse the repository at this point in the history
  • Loading branch information
smilefx committed Jan 10, 2025
1 parent c96d621 commit 982b72b
Show file tree
Hide file tree
Showing 6 changed files with 736 additions and 718 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ package tools.aqua.bgw.application

internal object Config {
val USE_SOCKETS = true
val GENERATE_SAMPLES = true
val BGW_VERSION = "0.9-new_backend-81-064a1ee-SNAPSHOT"
val GENERATE_SAMPLES = false
val BGW_VERSION = "0.9-new_backend-82-c96d621-SNAPSHOT"
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@ internal object GameComponentContainerBuilder {
is LinearLayout -> buildLinearLayout(gameComponentContainer)
is Satchel -> buildSatchel(gameComponentContainer)
}
gameComponentContainer.components.forEach { ComponentViewBuilder.build(it) }
gameComponentContainer.components.forEach {
ComponentViewBuilder.build(it)
}
}

private fun buildArea(area: Area<out GameComponentView>) {}
Expand All @@ -47,7 +49,9 @@ internal object GameComponentContainerBuilder {
cardStack.alignmentProperty.guiListener = { _, _ -> Frontend.updateComponent(cardStack) }
}

private fun buildHexagonGrid(hexagonGrid: HexagonGrid<out HexagonView>) {}
private fun buildHexagonGrid(hexagonGrid: HexagonGrid<out HexagonView>) {

}

private fun buildLinearLayout(linearLayout: LinearLayout<out GameComponentView>) {
linearLayout.spacingProperty.guiListener = { _, _ -> Frontend.updateComponent(linearLayout) }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,11 @@ internal object GameComponentViewBuilder {
diceView.visuals.guiListener = { _, _ -> Frontend.updateComponent(diceView) }
}

private fun buildHexagonView(hexagonView: HexagonView) {}
private fun buildHexagonView(hexagonView: HexagonView) {
hexagonView.sizeProperty.guiListener = { _, _ ->
Frontend.updateComponent(hexagonView)
}
}

private fun buildTokenView(tokenView: TokenView) {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ package tools.aqua.bgw.components.gamecomponentviews

import tools.aqua.bgw.core.DEFAULT_HEXAGON_SIZE
import tools.aqua.bgw.core.HexOrientation
import tools.aqua.bgw.observable.properties.DoubleProperty
import tools.aqua.bgw.observable.properties.Property
import tools.aqua.bgw.visual.Visual

/**
Expand All @@ -28,8 +30,7 @@ import tools.aqua.bgw.visual.Visual
*
* @param posX Horizontal coordinate for this [HexagonView]. Default: 0.
* @param posY Vertical coordinate for this [HexagonView]. Default: 0.
* @param size Represents the radius of the outer circle of the [HexagonView] all six points lie on.
* Default: [DEFAULT_HEXAGON_SIZE].
* @param size Represents the distance to the outermost corner of the [HexagonView]. Default: [DEFAULT_HEXAGON_SIZE].
* @param visual Visual for this [HexagonView].
* @param orientation Orientation of the [HexagonView]. Default: [HexOrientation.POINTY_TOP].
*
Expand All @@ -41,7 +42,7 @@ import tools.aqua.bgw.visual.Visual
open class HexagonView(
posX: Number = 0,
posY: Number = 0,
val size: Number = DEFAULT_HEXAGON_SIZE,
size: Number = DEFAULT_HEXAGON_SIZE,
visual: Visual,

/**
Expand All @@ -58,4 +59,22 @@ open class HexagonView(
posY = posY,
width = 2 * size.toDouble(),
height = 2 * size.toDouble(),
visual = visual)
visual = visual
) {

/**
* [Property] for the size of the [HexagonView].
*/
internal val sizeProperty: DoubleProperty = DoubleProperty(size.toDouble())

/**
* Size of the [HexagonView]. For [HexOrientation.POINTY_TOP] this is the distance from the center
* to the top or bottom corner representing half the height of the container. For [HexOrientation.FLAT_TOP]
* this is the distance from the center to the left or right corner representing half the width of the container.
*/
var size: Double
get() = sizeProperty.value
set(value) {
sizeProperty.value = value
}
}
Loading

0 comments on commit 982b72b

Please sign in to comment.