diff options
Diffstat (limited to 'src/main/kotlin/util')
-rw-r--r-- | src/main/kotlin/util/render/DrawContextExt.kt | 1 | ||||
-rw-r--r-- | src/main/kotlin/util/textutil.kt | 26 |
2 files changed, 26 insertions, 1 deletions
diff --git a/src/main/kotlin/util/render/DrawContextExt.kt b/src/main/kotlin/util/render/DrawContextExt.kt index 3e086b8..fc38aa6 100644 --- a/src/main/kotlin/util/render/DrawContextExt.kt +++ b/src/main/kotlin/util/render/DrawContextExt.kt @@ -12,6 +12,7 @@ fun DrawContext.isUntranslatedGuiDrawContext(): Boolean { fun DrawContext.drawLine(fromX: Int, fromY: Int, toX: Int, toY: Int, color: Color) { // TODO: push scissors + // TODO: use matrix translations and a different render layer if (toY < fromY) { drawLine(toX, toY, fromX, fromY, color) return diff --git a/src/main/kotlin/util/textutil.kt b/src/main/kotlin/util/textutil.kt index 252f708..a6a7e87 100644 --- a/src/main/kotlin/util/textutil.kt +++ b/src/main/kotlin/util/textutil.kt @@ -1,5 +1,6 @@ package moe.nea.firmament.util +import net.minecraft.text.ClickEvent import net.minecraft.text.MutableText import net.minecraft.text.PlainTextContent import net.minecraft.text.Text @@ -119,7 +120,30 @@ fun Text.iterator(): Sequence<Text> { fun Text.allSiblings(): List<Text> = listOf(this) + siblings.flatMap { it.allSiblings() } -fun MutableText.withColor(formatting: Formatting) = this.styled { it.withColor(formatting).withItalic(false) } +fun MutableText.withColor(formatting: Formatting): MutableText = this.styled { + it.withColor(formatting) + .withItalic(false) + .withBold(false) +} + +fun MutableText.blue() = withColor(Formatting.BLUE) +fun MutableText.aqua() = withColor(Formatting.AQUA) +fun MutableText.lime() = withColor(Formatting.GREEN) +fun MutableText.darkGreen() = withColor(Formatting.DARK_GREEN) +fun MutableText.yellow() = withColor(Formatting.YELLOW) +fun MutableText.grey() = withColor(Formatting.GRAY) +fun MutableText.red() = withColor(Formatting.RED) +fun MutableText.white() = withColor(Formatting.WHITE) +fun MutableText.bold(): MutableText = styled { it.withBold(true) } + + +fun MutableText.clickCommand(command: String): MutableText { + require(command.startsWith("/")) + return this.styled { + it.withClickEvent(ClickEvent(ClickEvent.Action.RUN_COMMAND, + "/firm disablereiwarning")) + } +} fun Text.transformEachRecursively(function: (Text) -> Text): Text { val c = this.content |