Skip to content

Commit

Permalink
KTX 1.9.14-b2 release. libktx#357
Browse files Browse the repository at this point in the history
  • Loading branch information
czyzby committed Apr 12, 2021
2 parents c67da29 + fdcac8f commit da2e2bd
Show file tree
Hide file tree
Showing 83 changed files with 2,668 additions and 2,157 deletions.
2 changes: 2 additions & 0 deletions .github/CONTRIBUTORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ Project contributors listed chronologically.
* Updated the sources documentation generator to Dokka 1.4.
* [@deveth0](https://github.com/deveth0)
* Contributed utilities to the [graphics module](../graphics).
* [@auraxangelic](https://github.com/auraxangelic)
* Tested KTX on iOS and documented RoboVM issue with Kotlin coroutines.

### Metrics

Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/publish-documentation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ jobs:
- name: Execution permission for Gradle wrapper
run: chmod +x gradlew
- name: Dokka
run: ./gradlew dokkaHtmlCollector
run: ./gradlew dokkaHtmlMultiModule
- name: Publish GitHub pages
uses: JamesIves/github-pages-deploy-action@releases/v3
with:
ACCESS_TOKEN: ${{ secrets.accessToken }}
BRANCH: gh-pages
FOLDER: build/dokka/htmlCollector
FOLDER: build/dokka/htmlMultiModule
REPOSITORY_NAME: libktx/docs
2 changes: 1 addition & 1 deletion .github/workflows/upload-snapshot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
env:
TEST_PROFILE: ci
- name: Upload snapshot to Maven Central
run: ./gradlew build uploadSnapshot
run: ./gradlew build uploadSnapshot -x dokkaHtml
env:
ORG_GRADLE_PROJECT_ossrhUsername: ${{ secrets.ossrhUsername }}
ORG_GRADLE_PROJECT_ossrhPassword: ${{ secrets.ossrhPassword }}
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,19 @@
_See also: [the official LibGDX changelog](https://github.com/libgdx/libgdx/blob/master/CHANGES)._

#### 1.9.14-b2

- **[UPDATE]** Updated to Ashley 1.7.4.
- **[UPDATE]** Updated to Kotlin 1.4.32.
- **[UPDATE]** Updated to Kotlin Coroutines 1.4.3.
- **[UPDATE]** Updated to Gradle 6.8.3.
- **[UPDATE]** Updated to Dokka 1.4.30.
- **[MISC]** Due to the newly added support for multimodule projects in Dokka, published documentation URLs will change.
- **[FEATURE]** (`ktx-tiled`) Added `isEmpty` and `isNotEmpty` extension function for `MapLayers` and `MapObjects` collections.
- **[FEATURE]** (`ktx-tiled`) Added `forEachLayer` extension function for `TiledMap` to iterate over an exact type
of `MapLayer` instances of a specific map.
- **[FIX]** (`ktx-vis`) `visScrollPane` and `visSplitPane` now define the correct types for `this` in theis `init` lambdas,
adding support for Scene2D and VisUI DSL.

#### 1.9.14-b1

- **[UPDATE]** Updated to LibGDX 1.9.14.
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[![GitHub Build](https://github.com/libktx/ktx/workflows/build/badge.svg)](https://github.com/libktx/ktx/actions?query=workflow%3Abuild)
[![Kotlin](https://img.shields.io/badge/kotlin-1.4.30-orange.svg)](http://kotlinlang.org/)
[![Kotlin](https://img.shields.io/badge/kotlin-1.4.32-orange.svg)](http://kotlinlang.org/)
[![LibGDX](https://img.shields.io/badge/libgdx-1.9.14-red.svg)](https://libgdx.com/)
[![Maven Central](https://img.shields.io/maven-central/v/io.github.libktx/ktx-async.svg)](https://search.maven.org/#search%7Cga%7C1%7Cg%3A%22io.github.libktx%22)

Expand Down Expand Up @@ -75,7 +75,7 @@ in your `build.gradle` file:
```Groovy
ext {
// Update this version to match the latest KTX release:
ktxVersion = '1.9.14-b1'
ktxVersion = '1.9.14-b2'
}
dependencies {
Expand Down
2 changes: 1 addition & 1 deletion actors/src/test/kotlin/ktx/actors/StagesTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ import com.nhaarman.mockitokotlin2.any
import com.nhaarman.mockitokotlin2.doAnswer
import com.nhaarman.mockitokotlin2.doReturn
import com.nhaarman.mockitokotlin2.mock
import java.nio.IntBuffer
import org.junit.After
import org.junit.Assert.assertEquals
import org.junit.Assert.assertSame
import org.junit.Before
import org.junit.Test
import java.nio.IntBuffer

class StagesTest {
@Before
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/kotlin/ktx/app/game.kt
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ open class KtxGame<ScreenType : Screen>(
*/
@Suppress("UNCHECKED_CAST")
open fun <Type : ScreenType> getScreen(type: Class<Type>): Type =
screens[type] as Type? ?: throw GdxRuntimeException("Missing screen instance of type: $type.")
screens[type] as Type? ?: throw GdxRuntimeException("Missing screen instance of type: $type.")

/**
* Removes cached instance of [Screen] of the selected type. Note that this method does not dispose of the screen and
Expand Down
7 changes: 5 additions & 2 deletions app/src/main/kotlin/ktx/app/profiling.kt
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,11 @@ fun PerformanceCounter.prettyPrint(decimalFormat: String = "%.6fs") {
val minimum: Float
val maximum: Float
if (mean != null && mean.hasEnoughData()) {
Gdx.app.log(name, "Average OP time: ${decimalFormat.format(mean.mean)} " +
"± ${decimalFormat.format(mean.standardDeviation())}")
Gdx.app.log(
name,
"Average OP time: ${decimalFormat.format(mean.mean)} " +
"± ${decimalFormat.format(mean.standardDeviation())}"
)
minimum = mean.lowest
maximum = mean.highest
} else {
Expand Down
2 changes: 1 addition & 1 deletion ashley/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[![Ashley](https://img.shields.io/badge/ashley-1.7.3-red.svg)](https://libgdx.badlogicgames.com/)
[![Ashley](https://img.shields.io/badge/ashley-1.7.4-red.svg)](https://github.com/libgdx/ashley)
[![Maven Central](https://img.shields.io/maven-central/v/io.github.libktx/ktx-ashley.svg)](https://search.maven.org/artifact/io.github.libktx/ktx-ashley)

# KTX: `Ashley` entity component system utilities
Expand Down
2 changes: 1 addition & 1 deletion ashley/src/main/kotlin/ktx/ashley/entities.kt
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ operator fun <T : Component> Entity.contains(mapper: ComponentMapper<T>): Boolea
* @return the removed [Component] instance (if was present and matched the specified type) or null.
* @see Entity.remove
*/
inline fun <reified T : Component> Entity.remove(): Component? = remove(T::class.java) as? T
inline fun <reified T : Component> Entity.remove(): Component? = remove(T::class.java)

/**
* Adds a constructed [Component] to this [Entity]. If a [Component] of the same type exists, it will be replaced.
Expand Down
2 changes: 1 addition & 1 deletion ashley/src/main/kotlin/ktx/ashley/families.kt
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,4 @@ fun Builder.allOf(vararg components: KClass<out Component>): Builder = all(*toJa
fun Builder.exclude(vararg components: KClass<out Component>): Builder = exclude(*toJavaClassArray(components))

private fun toJavaClassArray(components: Array<out KClass<out Component>>): Array<Class<out Component>> =
Array(components.size) { index -> components[index].java }
Array(components.size) { index -> components[index].java }
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ import com.badlogic.gdx.assets.AssetLoaderParameters
import com.badlogic.gdx.assets.AssetManager
import com.badlogic.gdx.assets.loaders.AssetLoader
import com.badlogic.gdx.assets.loaders.FileHandleResolver
import com.badlogic.gdx.utils.Array as GdxArray
import com.badlogic.gdx.utils.Logger
import kotlinx.coroutines.launch
import ktx.async.KtxAsync
import com.badlogic.gdx.utils.Array as GdxArray

/**
* Extends [AssetManager], delegating all of its asset-related method calls to [assetStorage].
Expand All @@ -35,8 +35,10 @@ internal class AssetManagerWrapper(

override fun clear() = dispose()

@Deprecated("This operation is non-blocking. Assets might still be loaded after this call.",
replaceWith = ReplaceWith("AssetStorage.dispose"))
@Deprecated(
"This operation is non-blocking. Assets might still be loaded after this call.",
replaceWith = ReplaceWith("AssetStorage.dispose")
)
override fun dispose() {
if (initiated) {
logger.error("Not fully supported AssetManagerWrapper.dispose called by AssetLoader.")
Expand All @@ -48,14 +50,18 @@ internal class AssetManagerWrapper(
}
}

@Deprecated("Not supported by AssetStorage.",
replaceWith = ReplaceWith("contains(fileName, type)"))
@Deprecated(
"Not supported by AssetStorage.",
replaceWith = ReplaceWith("contains(fileName, type)")
)
override fun contains(fileName: String): Boolean = false
override fun contains(fileName: String, type: Class<*>?): Boolean =
assetStorage.contains(AssetDescriptor(fileName, type))

@Deprecated("This operation is non-blocking. Assets might not be available in storage after call.",
replaceWith = ReplaceWith("AssetStorage.add"))
@Deprecated(
"This operation is non-blocking. Assets might not be available in storage after call.",
replaceWith = ReplaceWith("AssetStorage.add")
)
override fun <T : Any> addAsset(fileName: String, type: Class<T>, asset: T) {
logger.error("Not fully supported AssetManagerWrapper.addAsset called by AssetLoader.")
KtxAsync.launch {
Expand Down Expand Up @@ -93,9 +99,11 @@ internal class AssetManagerWrapper(
@Deprecated("Not supported by AssetStorage.", replaceWith = ReplaceWith("Nothing"))
override fun getAssetNames(): GdxArray<String> = throw UnsupportedMethodException("getAssetNames")

@Deprecated("Multiple assets with different types can be listed under the same path.",
replaceWith = ReplaceWith("Nothing"))
override fun getAssetType(fileName: String): Class<*>? = throw UnsupportedMethodException("getAssetType")
@Deprecated(
"Multiple assets with different types can be listed under the same path.",
replaceWith = ReplaceWith("Nothing")
)
override fun getAssetType(fileName: String): Class<*> = throw UnsupportedMethodException("getAssetType")

@Deprecated("Not supported by AssetStorage.", replaceWith = ReplaceWith("Nothing"))
override fun <Asset : Any> getAll(type: Class<Asset>, out: GdxArray<Asset>): GdxArray<Asset> =
Expand All @@ -121,14 +129,18 @@ internal class AssetManagerWrapper(
override fun isLoaded(assetDesc: AssetDescriptor<*>): Boolean = assetStorage.isLoaded(assetDesc)
override fun isLoaded(fileName: String, type: Class<*>): Boolean = isLoaded(AssetDescriptor(fileName, type))

@Deprecated("Not supported by AssetStorage.",
replaceWith = ReplaceWith("isLoaded(fileName, type)"))
@Deprecated(
"Not supported by AssetStorage.",
replaceWith = ReplaceWith("isLoaded(fileName, type)")
)
override fun isLoaded(fileName: String): Boolean = false.also {
logger.error("Not supported AssetManagerWrapper.addAsset called by AssetLoader.")
}

@Deprecated("AssetStorage requires type of asset to unload.",
replaceWith = ReplaceWith("AssetStorage.unload"))
@Deprecated(
"AssetStorage requires type of asset to unload.",
replaceWith = ReplaceWith("AssetStorage.unload")
)
override fun unload(fileName: String) {
logger.error("Not supported AssetManagerWrapper.unload called by AssetLoader.")
}
Expand All @@ -143,15 +155,19 @@ internal class AssetManagerWrapper(
}
}

@Deprecated("AssetLoader instances can be mutable." +
"AssetStorage requires functional providers of loaders rather than singular instances.",
replaceWith = ReplaceWith("AssetStorage.setLoader"))
@Deprecated(
"AssetLoader instances can be mutable." +
"AssetStorage requires functional providers of loaders rather than singular instances.",
replaceWith = ReplaceWith("AssetStorage.setLoader")
)
override fun <T : Any?, P : AssetLoaderParameters<T>?> setLoader(type: Class<T>, loader: AssetLoader<T, P>) =
setLoader(type, null, loader)

@Deprecated("AssetLoader instances can be mutable." +
"AssetStorage requires functional providers of loaders rather than singular instances.",
replaceWith = ReplaceWith("AssetStorage.setLoader"))
@Deprecated(
"AssetLoader instances can be mutable." +
"AssetStorage requires functional providers of loaders rather than singular instances.",
replaceWith = ReplaceWith("AssetStorage.setLoader")
)
override fun <T : Any?, P : AssetLoaderParameters<T>?> setLoader(
type: Class<T>,
suffix: String?,
Expand All @@ -164,14 +180,18 @@ internal class AssetManagerWrapper(
}
}

@Deprecated("AssetStorage requires type to find dependencies.",
replaceWith = ReplaceWith("AssetStorage.getDependencies"))
@Deprecated(
"AssetStorage requires type to find dependencies.",
replaceWith = ReplaceWith("AssetStorage.getDependencies")
)
override fun getDependencies(fileName: String): GdxArray<String> = GdxArray.with<String>().also {
logger.error("Not supported AssetManagerWrapper.getDependencies called by AssetLoader.")
}

@Deprecated("AssetStorage requires type to find reference count.",
replaceWith = ReplaceWith("AssetStorage.getReferenceCount"))
@Deprecated(
"AssetStorage requires type to find reference count.",
replaceWith = ReplaceWith("AssetStorage.getReferenceCount")
)
override fun getReferenceCount(fileName: String): Int = 0.also {
logger.error("Not supported AssetManagerWrapper.getReferenceCount called by AssetLoader.")
}
Expand Down
26 changes: 13 additions & 13 deletions assets-async/src/main/kotlin/ktx/assets/async/loaders.kt
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import com.badlogic.gdx.assets.loaders.AsynchronousAssetLoader
import com.badlogic.gdx.assets.loaders.SynchronousAssetLoader
import com.badlogic.gdx.assets.loaders.resolvers.AbsoluteFileHandleResolver
import com.badlogic.gdx.files.FileHandle
import com.badlogic.gdx.utils.Array as GdxArray
import com.badlogic.gdx.utils.ObjectMap
import com.badlogic.gdx.utils.Array as GdxArray

/**
* Stores [AssetLoader] instances mapped by loaded asset type. Internal [AssetStorage] utility.
Expand Down Expand Up @@ -116,19 +116,19 @@ private val <Asset> AssetDescriptor<Asset>.parameters: AssetLoaderParameters<Ass
* with [AssetDescriptor] instances. Null if here are no dependencies.
*/
fun Loader<*>.getDependencies(assetDescriptor: AssetDescriptor<*>): GdxArray<AssetDescriptor<*>> =
@Suppress("UNCHECKED_CAST")
(this as AssetLoader<*, AssetLoaderParameters<*>>)
.getDependencies(assetDescriptor.fileName, assetDescriptor.file, assetDescriptor.parameters) ?: GdxArray(0)
@Suppress("UNCHECKED_CAST")
(this as AssetLoader<*, AssetLoaderParameters<*>>)
.getDependencies(assetDescriptor.fileName, assetDescriptor.file, assetDescriptor.parameters) ?: GdxArray(0)

/**
* Allows to use [SynchronousAssetLoader.load] method with [AssetDescriptor].
* [assetManager] provides asset dependencies for the loader.
* [assetDescriptor] contains asset data. Returns fully loaded [Asset] instance.
*/
fun <Asset> SynchronousLoader<Asset>.load(assetManager: AssetManager, assetDescriptor: AssetDescriptor<Asset>): Asset =
@Suppress("UNCHECKED_CAST")
(this as SynchronousAssetLoader<Asset, AssetLoaderParameters<Asset>>)
.load(assetManager, assetDescriptor.fileName, assetDescriptor.file, assetDescriptor.parameters)
@Suppress("UNCHECKED_CAST")
(this as SynchronousAssetLoader<Asset, AssetLoaderParameters<Asset>>)
.load(assetManager, assetDescriptor.fileName, assetDescriptor.file, assetDescriptor.parameters)

/**
* Allows to use [AsynchronousAssetLoader.loadAsync] method with [AssetDescriptor].
Expand All @@ -137,9 +137,9 @@ fun <Asset> SynchronousLoader<Asset>.load(assetManager: AssetManager, assetDescr
* [assetDescriptor] contains asset data.
*/
fun <Asset> AsynchronousLoader<Asset>.loadAsync(assetManager: AssetManager, assetDescriptor: AssetDescriptor<Asset>) =
@Suppress("UNCHECKED_CAST")
(this as AsynchronousAssetLoader<Asset, AssetLoaderParameters<Asset>>)
.loadAsync(assetManager, assetDescriptor.fileName, assetDescriptor.file, assetDescriptor.parameters)
@Suppress("UNCHECKED_CAST")
(this as AsynchronousAssetLoader<Asset, AssetLoaderParameters<Asset>>)
.loadAsync(assetManager, assetDescriptor.fileName, assetDescriptor.file, assetDescriptor.parameters)

/**
* Allows to use [AsynchronousAssetLoader.loadSync] method with [AssetDescriptor].
Expand All @@ -148,9 +148,9 @@ fun <Asset> AsynchronousLoader<Asset>.loadAsync(assetManager: AssetManager, asse
* [assetDescriptor] contains asset data. Returns fully loaded [Asset] instance.
*/
fun <Asset> AsynchronousLoader<Asset>.loadSync(assetManager: AssetManager, assetDescriptor: AssetDescriptor<Asset>): Asset =
@Suppress("UNCHECKED_CAST")
(this as AsynchronousAssetLoader<Asset, AssetLoaderParameters<Asset>>)
.loadSync(assetManager, assetDescriptor.fileName, assetDescriptor.file, assetDescriptor.parameters)
@Suppress("UNCHECKED_CAST")
(this as AsynchronousAssetLoader<Asset, AssetLoaderParameters<Asset>>)
.loadSync(assetManager, assetDescriptor.fileName, assetDescriptor.file, assetDescriptor.parameters)

/** Required for [ManualLoader] by LibGDX API. */
internal class ManualLoadingParameters : AssetLoaderParameters<Any>()
Expand Down
Loading

0 comments on commit da2e2bd

Please sign in to comment.