diff --git a/.github/workflows/snapshot.yml b/.github/workflows/snapshot.yml index 479c34a..f543e81 100644 --- a/.github/workflows/snapshot.yml +++ b/.github/workflows/snapshot.yml @@ -18,4 +18,13 @@ jobs: with: repo_token: ${{ secrets.GITHUB_TOKEN }} file: lib/build/libs/MKUI.jar - tag: ${{ github.run_number }} \ No newline at end of file + tag: ${{ github.run_number }} + + - name: generate kotlin doc + run: ./gradlew dokkaHtml + + - name: upload kotlin doc + run: | + mv lib/build/dokka/html/* docs/ + git commit -am "[auto] upload kotlin docs" + git push \ No newline at end of file diff --git a/lib/build.gradle.kts b/lib/build.gradle.kts index cc0e419..658220f 100644 --- a/lib/build.gradle.kts +++ b/lib/build.gradle.kts @@ -1,5 +1,6 @@ plugins { - id("org.jetbrains.kotlin.jvm") version "1.6.0" + kotlin("jvm") version "1.6.10" + id("org.jetbrains.dokka") version "1.6.10" `java-library` //todo: why is this added `maven-publish` @@ -16,13 +17,7 @@ dependencies { compileOnly("com.github.Anuken.Arc:arc-core:$mindustryVersion") compileOnly("com.github.Anuken.Mindustry:core:$mindustryVersion") - compileOnly(platform("org.jetbrains.kotlin:kotlin-bom")) - compileOnly("org.jetbrains.kotlin:kotlin-stdlib-jdk8") - - testImplementation("org.jetbrains.kotlin:kotlin-test") - testImplementation("org.jetbrains.kotlin:kotlin-test-junit") - testImplementation("com.github.Anuken.Arc:arc-core:$mindustryVersion") - testImplementation("com.github.Anuken.Mindustry:core:$mindustryVersion") + compileOnly(kotlin("stdlib-jdk8")) } tasks.withType { diff --git a/lib/src/main/kotlin/com/github/mnemotechnician/mkui/ElementUtil.kt b/lib/src/main/kotlin/com/github/mnemotechnician/mkui/ElementUtil.kt index a2e1198..cc4d7e9 100644 --- a/lib/src/main/kotlin/com/github/mnemotechnician/mkui/ElementUtil.kt +++ b/lib/src/main/kotlin/com/github/mnemotechnician/mkui/ElementUtil.kt @@ -1,3 +1,4 @@ +/** A package containg utility functions for Elements and Cells */ package com.github.mnemotechnician.mkui import arc.scene.* @@ -5,4 +6,22 @@ import arc.scene.ui.* import arc.scene.ui.layout.* /** casts the element to the specified class or returns null if it's not an instance of this class */ -inline fun Element.asOrNull() = if (this is T) this else null; \ No newline at end of file +inline fun Element.asOrNull() = if (this is T) this else null; + +/** Returns the element inside a type-erased cell, casted to the providen class */ +inline fun Cell.getAs() = get() as T; + +/** Returns the element inside a type-erased cell, casted to the providen class, or null if it's not an instance of this class or if the cell is empty */ +inline fun Cell.getAsOrNull() = get()?.let { + if (this !is T) this else null +}; + +/** Changes the font size of the wrapped label and returns the cell */ +fun Cell