Skip to content

Commit

Permalink
[bgw-gui] Reimplement some features in preparation for 0.10
Browse files Browse the repository at this point in the history
  • Loading branch information
smilefx authored Feb 27, 2025
1 parent f46ee61 commit 54efa7c
Show file tree
Hide file tree
Showing 122 changed files with 1,434 additions and 494 deletions.
3 changes: 2 additions & 1 deletion bgw-docs/parser/.gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/node_modules/
/example/
/output/
/output/
package-lock.json
6 changes: 1 addition & 5 deletions bgw-docs/parser/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -811,9 +811,7 @@ function extractDetails(html, type, tree) {
function parseFileToJSON(tree) {
const content = fs.readFileSync(tree.path, "utf8");
let isClassGlobal = "none";
if (tree.path.includes("index")) {
console.log(tree);
}

if (tree.path.endsWith("\\index.html") || tree.path.endsWith("/index.html")) {
isClassGlobal = "global";
} else if (
Expand Down Expand Up @@ -861,7 +859,6 @@ function traverseTree(tree, file, rebuiltTree = {}) {
}

const directoryStructure = getDirectoryStructure(rootDir);
// console.log(JSON.stringify(traverseTree(directoryStructure), null, 2));

function removeNullValues(obj) {
if (!obj || typeof obj !== "object") return obj;
Expand Down Expand Up @@ -893,7 +890,6 @@ function removeNullValues(obj) {
}

const cleanedStructure = removeNullValues(traverseTree(directoryStructure));
// console.log(JSON.stringify(cleanedStructure, null, 2));

// Save the JSON to a file in ./output
fs.writeFileSync(
Expand Down
6 changes: 1 addition & 5 deletions bgw-docs/parser/package.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
{
"name": "bgw-doc-parser",
"version": "1.0.0",
"name": "bgw-docs-parser",
"main": "app.js",
"scripts": {
"build": "node app.js",
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "SmileFX",
"license": "Apache-2.0",
"description": "",
"dependencies": {
"cheerio": "^1.0.0",
"node-html-parser": "^6.1.13"
Expand Down
3 changes: 0 additions & 3 deletions bgw-docs/parser/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,18 +125,15 @@ function convertDashesToCaps(str) {

function pathToPackage(path, breadcrumbs) {
if (path.startsWith("http")) {
console.log("##############", path);
return path;
}

if (breadcrumbs.indexOf("ComponentView") !== -1) {
console.log("path", path);
}

path = path.replace(/\.html.+$/, "");

if (path.indexOf("/") === -1 && path !== "_index") {
console.log("breadcrumbs", breadcrumbs);
return [...breadcrumbs, path]
.join("/")
.replace(/(\/|_)?index/g, "")
Expand Down
30 changes: 0 additions & 30 deletions bgw-docs/website/README.md

This file was deleted.

3 changes: 1 addition & 2 deletions bgw-docs/website/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{
"name": "bgw-website",
"version": "1.0",
"name": "bgw-docs-website",
"type": "module",
"scripts": {
"dev": "vite --base=/bgw",
Expand Down
33 changes: 32 additions & 1 deletion bgw-docs/website/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2692,6 +2692,23 @@ hast-util-raw@^9.0.0:
web-namespaces "^2.0.0"
zwitch "^2.0.0"

hast-util-to-html@^9.0.0:
version "9.0.5"
resolved "https://registry.yarnpkg.com/hast-util-to-html/-/hast-util-to-html-9.0.5.tgz#ccc673a55bb8e85775b08ac28380f72d47167005"
integrity sha512-OguPdidb+fbHQSU4Q4ZiLKnzWo8Wwsf5bZfbvu7//a9oTYoqD/fWpe96NuHkoS9h0ccGOTe0C4NGXdtS0iObOw==
dependencies:
"@types/hast" "^3.0.0"
"@types/unist" "^3.0.0"
ccount "^2.0.0"
comma-separated-tokens "^2.0.0"
hast-util-whitespace "^3.0.0"
html-void-elements "^3.0.0"
mdast-util-to-hast "^13.0.0"
property-information "^7.0.0"
space-separated-tokens "^2.0.0"
stringify-entities "^4.0.0"
zwitch "^2.0.4"

hast-util-to-jsx-runtime@^2.0.0:
version "2.3.2"
resolved "https://registry.npmjs.org/hast-util-to-jsx-runtime/-/hast-util-to-jsx-runtime-2.3.2.tgz"
Expand Down Expand Up @@ -3927,6 +3944,11 @@ property-information@^6.0.0:
resolved "https://registry.npmjs.org/property-information/-/property-information-6.5.0.tgz"
integrity sha512-PgTgs/BlvHxOu8QuEN7wi5A0OmXaBcHpmCSTehcs6Uuu9IkDIEo13Hy7n898RHfrQ49vKCoGeWZSaAK01nwVig==

property-information@^7.0.0:
version "7.0.0"
resolved "https://registry.yarnpkg.com/property-information/-/property-information-7.0.0.tgz#3508a6d6b0b8eb3ca6eb2c6623b164d2ed2ab112"
integrity sha512-7D/qOz/+Y4X/rzSB6jKxKUsQnphO046ei8qxG59mtM3RG3DHgTK81HrxrmoDVINJb8NKT5ZsRbwHvQ6B68Iyhg==

punycode@^2.1.0:
version "2.3.1"
resolved "https://registry.npmjs.org/punycode/-/punycode-2.3.1.tgz"
Expand Down Expand Up @@ -4215,6 +4237,15 @@ rehype-raw@^7.0.0:
hast-util-raw "^9.0.0"
vfile "^6.0.0"

rehype-stringify@^10.0.1:
version "10.0.1"
resolved "https://registry.yarnpkg.com/rehype-stringify/-/rehype-stringify-10.0.1.tgz#2ec1ebc56c6aba07905d3b4470bdf0f684f30b75"
integrity sha512-k9ecfXHmIPuFVI61B9DeLPN0qFHfawM6RsuX48hoqlaKSF61RskNjSm1lI8PhBEM0MRdLxVVm4WmTqJQccH9mA==
dependencies:
"@types/hast" "^3.0.0"
hast-util-to-html "^9.0.0"
unified "^11.0.0"

remark-gfm@^4.0.0:
version "4.0.0"
resolved "https://registry.npmjs.org/remark-gfm/-/remark-gfm-4.0.0.tgz"
Expand Down Expand Up @@ -4875,7 +4906,7 @@ zustand@^5.0.2:
resolved "https://registry.npmjs.org/zustand/-/zustand-5.0.3.tgz"
integrity sha512-14fwWQtU3pH4dE0dOpdMiWjddcH+QzKIgk1cl8epwSE7yag43k/AD/m4L6+K7DytAOr9gGBe3/EXj9g7cdostg==

zwitch@^2.0.0:
zwitch@^2.0.0, zwitch@^2.0.4:
version "2.0.4"
resolved "https://registry.npmjs.org/zwitch/-/zwitch-2.0.4.tgz"
integrity sha512-bXE4cR/kVZhKZX/RjPEflHaKVhUVl85noU3v6b8apfQEc1x4A+zBxjZ4lN8LqGd6WZ3dl98pY4o717VFmoPp+A==
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ fun main() {
UIComponentExample()
}

class UIComponentExample : BoardGameApplication("UIComponent Example") {
class UIComponentExample : BoardGameApplication("UIComponent Example", width = 800, height = 1000) {
private val menuScene = MenuScene(width = 800).apply { this.opacity = 1.0 }

private val outputLabel =
Expand All @@ -39,7 +39,8 @@ class UIComponentExample : BoardGameApplication("UIComponent Example") {
width = 300,
text = "I am a Label.",
alignment = Alignment.CENTER,
isWrapText = true)
isWrapText = true,
visual = ColorVisual.GREEN)

init {
menuScene.addComponents(outputLabel)
Expand Down
18 changes: 11 additions & 7 deletions bgw-gui/src/commonMain/kotlin/Json.kt
Original file line number Diff line number Diff line change
Expand Up @@ -69,16 +69,16 @@ private val module = SerializersModule {
subclass(DialogData::class)
subclass(FileDialogData::class)
// ANIMATIONS
subclass(DelayAnimationData::class)
subclass(DiceAnimationData::class)
subclass(FadeAnimationData::class)
subclass(FlipAnimationData::class)
subclass(MovementAnimationData::class)
subclass(ParallelAnimationData::class)
subclass(RandomizeAnimationData::class)
subclass(RotationAnimationData::class)
subclass(ScaleAnimationData::class)
subclass(FlipAnimationData::class)
subclass(SequentialAnimationData::class)
subclass(ParallelAnimationData::class)
subclass(RandomizeAnimationData::class)
subclass(DiceAnimationData::class)
subclass(DelayAnimationData::class)
}
polymorphic(LayoutViewData::class) {
subclass(PaneData::class)
Expand Down Expand Up @@ -180,12 +180,16 @@ private val module = SerializersModule {
}
// ANIMATIONS
polymorphic(AnimationData::class) {
subclass(DelayAnimationData::class)
subclass(DiceAnimationData::class)
subclass(FadeAnimationData::class)
subclass(FlipAnimationData::class)
subclass(MovementAnimationData::class)
subclass(ParallelAnimationData::class)
subclass(RandomizeAnimationData::class)
subclass(RotationAnimationData::class)
subclass(ScaleAnimationData::class)
subclass(FlipAnimationData::class)
subclass(DelayAnimationData::class)
subclass(SequentialAnimationData::class)
}
}

Expand Down
6 changes: 5 additions & 1 deletion bgw-gui/src/commonMain/kotlin/PropData.kt
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ internal enum class ActionProp {
HIDE_GAME_SCENE,
UPDATE_COMPONENT,
UPDATE_VISUAL,
UPDATE_APP,
DRAG_START,
DRAG_END,
DRAG_DROP,
Expand All @@ -53,12 +54,15 @@ internal class AppData : Data() {
var fonts: List<Triple<String, String, Int>> = emptyList()
var width: Int = 0
var height: Int = 0
var background: VisualData? = null
var alignment: Pair<String, String> = Pair("", "")
var action: ActionProp = ActionProp.DEFAULT
}

@Serializable
internal class SceneData : Data() {
var id: ID = ""
var locked: Boolean = false
var width: Int = 0
var height: Int = 0
var background: VisualData? = null
Expand Down Expand Up @@ -313,7 +317,7 @@ internal class LinearLayoutData : GameComponentContainerData() {
internal sealed class SingleLayerVisualData(
var transparency: Double = 0.0,
var style: Map<String, String> = emptyMap(),
var filters: Map<String, String?> = emptyMap(),
var filters: Map<String, String> = emptyMap(),
var flipped: String = ""
) : VisualData()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,14 @@ const val DEFAULT_WINDOW_TITLE: String = "BoardGameWork Application"
*
* @since 0.2
*/
const val DEFAULT_WINDOW_WIDTH: Double = 1280.0
const val DEFAULT_WINDOW_WIDTH: Double = 1920.0

/**
* Default window height in non-maximized mode.
*
* @since 0.2
*/
const val DEFAULT_WINDOW_HEIGHT: Double = 747.0
const val DEFAULT_WINDOW_HEIGHT: Double = 1080.0

/**
* Default minimization factor of window.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ enum class WindowMode {
* [BoardGameApplication.isMaximized] as 'true'. Overrides [BoardGameApplication.isFullScreen] as
* 'false'.
*/
@Deprecated("WindowMode.MAXIMIZED is no longer used as of BGW 0.10.") MAXIMIZED,
MAXIMIZED,

/**
* Starts Application as maximized window. Overrides [BoardGameApplication.isFullScreen] as
Expand Down
10 changes: 10 additions & 0 deletions bgw-gui/src/jsMain/kotlin/tools/aqua/bgw/Animator.kt
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,11 @@ internal class Animator {
val animations = animation.animations

animations.forEach {
if (it is DelayAnimationData ||
it is SequentialAnimationData ||
it is ParallelAnimationData ||
it is SteppedComponentAnimationData)
return@forEach
val component = it as? ComponentAnimationData ?: return
val componentId = component.componentView?.id.toString()

Expand All @@ -132,6 +137,11 @@ internal class Animator {
val animations = animation.animations

animations.forEach {
if (it is DelayAnimationData ||
it is SequentialAnimationData ||
it is ParallelAnimationData ||
it is SteppedComponentAnimationData)
return@forEach
val component = it as? ComponentAnimationData ?: return
val componentId = component.componentView?.id.toString()

Expand Down
24 changes: 22 additions & 2 deletions bgw-gui/src/jsMain/kotlin/tools/aqua/bgw/elements/App.kt
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ import tools.aqua.bgw.builder.ReactConverters.toDragMoveEventData
import tools.aqua.bgw.builder.ReactConverters.toDragStartedEventData
import tools.aqua.bgw.builder.ReactConverters.toKeyEventData
import tools.aqua.bgw.builder.SceneBuilder
import tools.aqua.bgw.builder.VisualBuilder
import tools.aqua.bgw.core.DEFAULT_BLUR_RADIUS
import tools.aqua.bgw.core.DEFAULT_MENU_SCENE_OPACITY
import tools.aqua.bgw.event.JCEFEventDispatcher
Expand Down Expand Up @@ -516,8 +517,12 @@ internal val App =
width = 100.pct
height = 100.pct
display = Display.flex
justifyContent = JustifyContent.center
alignItems = AlignItems.center
alignmentBuilder(props.data)
}

bgwVisuals {
className = ClassName("visuals")
+VisualBuilder.build(props.data.background)
}

val menuScene = props.data.menuScene
Expand Down Expand Up @@ -549,6 +554,18 @@ internal val App =
}

val gameScene = props.data.gameScene
if (gameScene != undefined && gameScene.locked) {
bgwLock {
css {
position = Position.absolute
width = props.data.width.em
height = props.data.height.em
backgroundColor = rgb(0, 0, 0, 0.0)
zIndex = zIndex(998)
}
}
}

bgwGameScene {
css { position = Position.absolute }

Expand All @@ -572,6 +589,9 @@ internal inline val bgwMenuScene: IntrinsicType<HTMLAttributes<Element>>
internal inline val bgwBlur: IntrinsicType<HTMLAttributes<Element>>
get() = "bgw_blur".unsafeCast<IntrinsicType<HTMLAttributes<Element>>>()

internal inline val bgwLock: IntrinsicType<HTMLAttributes<Element>>
get() = "bgw_lock".unsafeCast<IntrinsicType<HTMLAttributes<Element>>>()

internal inline val bgwGameScene: IntrinsicType<HTMLAttributes<Element>>
get() = "bgw_game_scene".unsafeCast<IntrinsicType<HTMLAttributes<Element>>>()

Expand Down
Loading

0 comments on commit 54efa7c

Please sign in to comment.