Skip to content

Commit

Permalink
Multiple fixes regarding satchels
Browse files Browse the repository at this point in the history
  • Loading branch information
smilefx committed Feb 2, 2025
1 parent de504fe commit a4ff681
Show file tree
Hide file tree
Showing 16 changed files with 320 additions and 77 deletions.
5 changes: 5 additions & 0 deletions bgw-gui/src/jsMain/kotlin/tools/aqua/bgw/elements/App.kt
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,11 @@ internal val App =
zIndex = important(integer(1000000))
}

"bgw_satchel bgw_contents *[aria-roledescription='draggable']:not([aria-pressed='true'])" {
width = important(100.pct)
height = important(100.pct)
}

"bgw_scroll::-webkit-scrollbar" { display = None.none }
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,11 @@ internal fun PropertiesBuilder.cssBuilderIntern(componentViewData: AreaData) {
internal val Area =
FC<AreaProps> { props ->
val draggable =
useDraggable(
object : DraggableOptions {
override var id: String = props.data.id
override var disabled = !props.data.isDraggable
})
useDraggable(
object : DraggableOptions {
override var id: String = props.data.id
override var disabled = !props.data.isDraggable
})

val droppable =
useDroppable(
Expand All @@ -68,8 +68,8 @@ internal val Area =
val style: PropertiesBuilder.() -> Unit = {
cssBuilderIntern(props.data)
translate =
"${draggable.transform?.x?.px ?: 0.px} ${draggable.transform?.y?.px ?: 0.px}".unsafeCast<
Translate>()
"${draggable.transform?.x?.px ?: 0.px} ${draggable.transform?.y?.px ?: 0.px}".unsafeCast<
Translate>()
cursor = if (props.data.isDraggable) Cursor.pointer else Cursor.default
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,11 @@ internal fun PropertiesBuilder.cssBuilderIntern(componentViewData: CardStackData
internal val CardStack =
FC<CardStackProps> { props ->
val draggable =
useDraggable(
object : DraggableOptions {
override var id: String = props.data.id
override var disabled = !props.data.isDraggable
})
useDraggable(
object : DraggableOptions {
override var id: String = props.data.id
override var disabled = !props.data.isDraggable
})

val droppable =
useDroppable(
Expand All @@ -67,8 +67,8 @@ internal val CardStack =
val style: PropertiesBuilder.() -> Unit = {
cssBuilderIntern(props.data)
translate =
"${draggable.transform?.x?.px ?: 0.px} ${draggable.transform?.y?.px ?: 0.px}".unsafeCast<
Translate>()
"${draggable.transform?.x?.px ?: 0.px} ${draggable.transform?.y?.px ?: 0.px}".unsafeCast<
Translate>()
cursor = if (props.data.isDraggable) Cursor.pointer else Cursor.default
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,11 @@ internal fun PropertiesBuilder.cssBuilderIntern(componentViewData: HexagonGridDa
internal val HexagonGrid =
FC<HexagonGridProps> { props ->
val draggable =
useDraggable(
object : DraggableOptions {
override var id: String = props.data.id
override var disabled = !props.data.isDraggable
})
useDraggable(
object : DraggableOptions {
override var id: String = props.data.id
override var disabled = !props.data.isDraggable
})

val droppable =
useDroppable(
Expand All @@ -71,8 +71,8 @@ internal val HexagonGrid =
val style: PropertiesBuilder.() -> Unit = {
cssBuilderIntern(props.data)
translate =
"${draggable.transform?.x?.px ?: 0.px} ${draggable.transform?.y?.px ?: 0.px}".unsafeCast<
Translate>()
"${draggable.transform?.x?.px ?: 0.px} ${draggable.transform?.y?.px ?: 0.px}".unsafeCast<
Translate>()
cursor = if (props.data.isDraggable) Cursor.pointer else Cursor.default
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,11 @@ internal fun PropertiesBuilder.cssBuilderIntern(componentViewData: LinearLayoutD
internal val LinearLayout =
FC<LinearLayoutProps> { props ->
val draggable =
useDraggable(
object : DraggableOptions {
override var id: String = props.data.id
override var disabled = !props.data.isDraggable
})
useDraggable(
object : DraggableOptions {
override var id: String = props.data.id
override var disabled = !props.data.isDraggable
})

val droppable =
useDroppable(
Expand All @@ -67,8 +67,8 @@ internal val LinearLayout =
val style: PropertiesBuilder.() -> Unit = {
cssBuilderIntern(props.data)
translate =
"${draggable.transform?.x?.px ?: 0.px} ${draggable.transform?.y?.px ?: 0.px}".unsafeCast<
Translate>()
"${draggable.transform?.x?.px ?: 0.px} ${draggable.transform?.y?.px ?: 0.px}".unsafeCast<
Translate>()
cursor = if (props.data.isDraggable) Cursor.pointer else Cursor.default
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,11 @@ internal fun PropertiesBuilder.cssBuilderIntern(componentViewData: SatchelData)
internal val Satchel =
FC<SatchelProps> { props ->
val draggable =
useDraggable(
object : DraggableOptions {
override var id: String = props.data.id
override var disabled = !props.data.isDraggable
})
useDraggable(
object : DraggableOptions {
override var id: String = props.data.id
override var disabled = !props.data.isDraggable
})

val droppable =
useDroppable(
Expand All @@ -66,8 +66,8 @@ internal val Satchel =
val style: PropertiesBuilder.() -> Unit = {
cssBuilderIntern(props.data)
translate =
"${draggable.transform?.x?.px ?: 0.px} ${draggable.transform?.y?.px ?: 0.px}".unsafeCast<
Translate>()
"${draggable.transform?.x?.px ?: 0.px} ${draggable.transform?.y?.px ?: 0.px}".unsafeCast<
Translate>()
cursor = if (props.data.isDraggable) Cursor.pointer else Cursor.default
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,10 @@ internal object JCEFEventDispatcher : EventDispatcher {

private fun initialize() {
js(
"window.bgwQuery = function(request) { window.cefQuery({request: request, persistent: false, onSuccess: function (response) {}, onFailure: function (error_code, error_message) {}}) }")
"window.bgwQuery = function(request) { if(window.cefQuery) window.cefQuery({request: request, persistent: false, onSuccess: function (response) {}, onFailure: function (error_code, error_message) {}}) }")
js(
"window.bgwAnimationQuery = function(request) { window.cefAnimationQuery({request: request, persistent: false, onSuccess: function (response) {}, onFailure: function (error_code, error_message) {}}) }")
"window.bgwAnimationQuery = function(request) { if(window.cefAnimationQuery) window.cefAnimationQuery({request: request, persistent: false, onSuccess: function (response) {}, onFailure: function (error_code, error_message) {}}) }")
js(
"window.bgwSceneQuery = function(request) { window.cefSceneQuery({request: request, persistent: false, onSuccess: function (response) {}, onFailure: function (error_code, error_message) {}}) }")
"window.bgwSceneQuery = function(request) { if(window.cefSceneQuery) window.cefSceneQuery({request: request, persistent: false, onSuccess: function (response) {}, onFailure: function (error_code, error_message) {}}) }")
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ internal object GameComponentContainerBuilder {
is Satchel -> buildSatchel(gameComponentContainer)
}
gameComponentContainer.components.forEach { ComponentViewBuilder.build(it) }

gameComponentContainer.isDraggableProperty.guiListener = { _, _ ->
Frontend.updateComponent(gameComponentContainer)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@ internal object GameComponentViewBuilder {
is TokenView -> buildTokenView(gameComponentView)
}

gameComponentView.isDraggableProperty.guiListener = { _, _ -> Frontend.updateComponent(gameComponentView) }
gameComponentView.isDraggableProperty.guiListener = { _, _ ->
Frontend.updateComponent(gameComponentView)
}
}

private fun buildCardView(cardView: CardView) {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,7 @@ import tools.aqua.bgw.components.gamecomponentviews.HexagonView
import tools.aqua.bgw.core.HexOrientation
import tools.aqua.bgw.visual.Visual

private typealias OffsetCoordinate = Pair<Int, Int>

private typealias AxialCoordinate = Pair<Int, Int>
private typealias HexCoordinate = Pair<Int, Int>

/**
* A class representing a grid of hexagons.
Expand Down Expand Up @@ -66,7 +64,7 @@ class HexagonGrid<T : HexagonView>(
posX = posX, posY = posY, width = width, height = height, visual = visual) {

/** A mutable map that stores the hexagons in the grid. */
internal val map: MutableMap<OffsetCoordinate, T> = mutableMapOf()
internal val map: MutableMap<HexCoordinate, T> = mutableMapOf()

init {
observableComponents.setInternalListenerAndInvoke(emptyList()) { _, _ ->
Expand Down Expand Up @@ -107,15 +105,15 @@ class HexagonGrid<T : HexagonView>(
}

/**
* Returns all hexagons in the grid as a map from [OffsetCoordinate] to [T].
* Returns all hexagons in the grid as a map from [HexCoordinate] to [T].
*
* @return A map from [OffsetCoordinate] to [T] containing all hexagons in the grid.
* @return A map from [HexCoordinate] to [T] containing all hexagons in the grid.
*
* @see components
*
* @since 0.10
*/
fun getCoordinateMap(): Map<OffsetCoordinate, T> {
fun getCoordinateMap(): Map<HexCoordinate, T> {
return map
}

Expand Down
Loading

0 comments on commit a4ff681

Please sign in to comment.