From 9ecac993ad666a7587d16fbb97e5a0758e4d255b Mon Sep 17 00:00:00 2001 From: soywiz Date: Mon, 2 Oct 2023 17:59:47 +0200 Subject: [PATCH] Bump KorGE to 5.0.2 --- build.gradle.kts | 14 +----------- gradle/libs.versions.toml | 3 +++ gradle/wrapper/gradle-wrapper.properties | 2 +- .../korlibs/korge/ldtk/view/LDTKView.kt | 8 +++---- settings.gradle.kts | 22 +++++++++++++------ 5 files changed, 24 insertions(+), 25 deletions(-) create mode 100644 gradle/libs.versions.toml diff --git a/build.gradle.kts b/build.gradle.kts index 94d4cda..673712a 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,26 +1,14 @@ import korlibs.korge.gradle.* plugins { - //alias(libs.plugins.korge) - id("com.soywiz.korge") version "4.0.3" + alias(libs.plugins.korge) } korge { id = "org.korge.samples.demoldtk" -// To enable all targets at once - - //targetAll() - -// To enable targets based on properties/environment variables - //targetDefault() - -// To selectively enable targets - targetJvm() targetJs() - targetDesktop() - //targetDesktopCross() targetIos() targetAndroid() diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml new file mode 100644 index 0000000..9e07fb5 --- /dev/null +++ b/gradle/libs.versions.toml @@ -0,0 +1,3 @@ +[plugins] +korge = { id = "com.soywiz.korge", version = "5.0.2" } +#korge = { id = "com.soywiz.korge", version = "999.0.0.999" } diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 5083229..c30b486 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.1-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.3-bin.zip networkTimeout=10000 zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/korge-ldtk/src/commonMain/kotlin/korlibs/korge/ldtk/view/LDTKView.kt b/korge-ldtk/src/commonMain/kotlin/korlibs/korge/ldtk/view/LDTKView.kt index f1a0c51..8cd3b79 100644 --- a/korge-ldtk/src/commonMain/kotlin/korlibs/korge/ldtk/view/LDTKView.kt +++ b/korge-ldtk/src/commonMain/kotlin/korlibs/korge/ldtk/view/LDTKView.kt @@ -19,8 +19,8 @@ private fun IStackedIntArray2.getFirst(pos: PointInt): Int = getFirst(pos.x, pos private fun IStackedIntArray2.getLast(pos: PointInt): Int = getLast(pos.x, pos.y) class LDTKCollisions(val world: LDTKWorld, val stack: IStackedIntArray2) { - fun tileToPixel(tilePos: PointInt): PointInt = (tilePos.toFloat() * world.ldtk.defaultGridSize).toIntFloor() - fun pixelToTile(pixelPos: PointInt): PointInt = (pixelPos.toFloat() / world.ldtk.defaultGridSize).toIntFloor() + fun tileToPixel(tilePos: PointInt): PointInt = (tilePos.toDouble() * world.ldtk.defaultGridSize).toIntFloor() + fun pixelToTile(pixelPos: PointInt): PointInt = (pixelPos.toDouble() / world.ldtk.defaultGridSize).toIntFloor() fun getTile(tilePos: PointInt): Int = stack.getLast(tilePos) fun getPixel(pixelPos: PointInt): Int = getTile(pixelToTile(pixelPos)) @@ -64,7 +64,7 @@ class LDTKEntityView( } val anchor = entity.pivotAnchor - val gridSize = llayer.layer.gridSize.toFloat() + val gridSize = llayer.layer.gridSize.toDouble() val tile: TilesetRectangle? = entity.tile val tileset = llayer.world.tilesetDefsById[tile?.tilesetUid] val utileset = tileset?.unextrudedTileSet @@ -79,7 +79,7 @@ class LDTKEntityView( //view.anchor(anchor) } init { - val pos = entity.gridPos.toFloat() * gridSize + anchor.toVector() * gridSize + val pos = entity.gridPos.toDouble() * gridSize + anchor.toVector() * gridSize view .size(entity.width, entity.height) (view as? Anchorable)?.anchor(anchor) diff --git a/settings.gradle.kts b/settings.gradle.kts index dabd850..81c4131 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -1,10 +1,18 @@ -pluginManagement { repositories { mavenLocal(); mavenCentral(); google(); gradlePluginPortal() } } - -plugins { - //id("com.soywiz.kproject.settings") version "0.0.1-SNAPSHOT" - id("com.soywiz.kproject.settings") version "0.3.1" +pluginManagement { + repositories { mavenLocal(); mavenCentral(); google(); gradlePluginPortal() } } -rootProject.name = "${rootDir.name}-example" +// @TODO: Why can't we just use libs here? We can't even use a TOML parser since it is gradle internal, and we cannot load a library in a reasonably way here. +plugins { + val libsTomlFile = File("gradle/libs.versions.toml").readText() + var plugins = false + var version = "" + for (line in libsTomlFile.lines().map { it.trim() }) { + if (line.startsWith("#")) continue + if (line.startsWith("[plugins]")) plugins = true + if (plugins && line.startsWith("korge") && Regex("^korge\\s*=.*").containsMatchIn(line)) version = Regex("version\\s*=\\s*\"(.*?)\"").find(line)?.groupValues?.get(1) ?: error("Can't find korge version") + } + if (version.isEmpty()) error("Can't find korge version in $libsTomlFile") -kproject("./deps") + id("com.soywiz.korge.settings") version version +}