diff --git a/README.md b/README.md index 9d1aa77..b18d2e8 100644 --- a/README.md +++ b/README.md @@ -14,6 +14,24 @@ In your `build.gradle` file: (it should already be here if you're using the official mod template) * add `implementation "com.github.mnemotechnician:MKUI:TAG"` (replace `TAG` with the the latest tag in this repo) to the `dependencies {}` block +example of a `build.gradle` file: +```groovy +//... some other code + +repositories { + mavenCentral() + maven { url("https://jitpack.io") } +} + +dependencies { + compileOnly "com.github.Anuken.Arc:arc-core:$mindustryVersion" //these two lines should + compileOnly "com.github.Anuken.Mindustry:core:$mindustryVersion" //already be here + implementation "com.github.mnemotechnician:mkui:snapshot-3" +} + +//... other code +``` + ## in case you're using kotlin dls: Ignore this paragraph if you're using the official kotlin mod template * use `maven("https://jitpack.io")` in the first step 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 77c1e73..e05af3d 100644 --- a/lib/src/main/kotlin/com/github/mnemotechnician/mkui/ElementUtil.kt +++ b/lib/src/main/kotlin/com/github/mnemotechnician/mkui/ElementUtil.kt @@ -4,4 +4,8 @@ import arc.scene.* import arc.scene.ui.* import arc.scene.ui.layout.* -//todo \ No newline at end of file +/** casts the element to the specified class */ +inline fun Element.to() = this as T; + +/** casts the element to the specified class or returns null if it's not an instance of this class */ +inline fun Element.toOrNull() = if (this is T) this else null; \ No newline at end of file diff --git a/lib/src/main/kotlin/com/github/mnemotechnician/mkui/Layout.kt b/lib/src/main/kotlin/com/github/mnemotechnician/mkui/Layout.kt index 03d9cb0..cf88d80 100644 --- a/lib/src/main/kotlin/com/github/mnemotechnician/mkui/Layout.kt +++ b/lib/src/main/kotlin/com/github/mnemotechnician/mkui/Layout.kt @@ -1,12 +1,19 @@ +/** + * Contains some utility layout construction functions + * Function names were made distinct in order to avoid ambiguity + */ package com.github.mnemotechnician.mkui import arc.scene.* import arc.scene.ui.* import arc.scene.ui.layout.* import arc.scene.style.* +import arc.struct.* import arc.graphics.* import mindustry.ui.* +private val tmpButtons = Seq