diff options
author | Roman / Linnea Gräf <nea@nea.moe> | 2023-04-13 03:05:28 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-04-13 03:05:28 +0200 |
commit | 127a719e84e866a15a626a39f261da26946aa6fb (patch) | |
tree | dea21814f5fd2a7e2cf33af678dba35a3e93d561 /src/main/java/at/hannibal2 | |
parent | 62750a1406e6db477c2fbc41b81b05efc802a66f (diff) | |
download | skyhanni-127a719e84e866a15a626a39f261da26946aa6fb.tar.gz skyhanni-127a719e84e866a15a626a39f261da26946aa6fb.tar.bz2 skyhanni-127a719e84e866a15a626a39f261da26946aa6fb.zip |
Better underline (#42)
Diffstat (limited to 'src/main/java/at/hannibal2')
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/utils/renderables/Renderable.kt | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/utils/renderables/Renderable.kt b/src/main/java/at/hannibal2/skyhanni/utils/renderables/Renderable.kt index 73bba5686..415cc0f2e 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/renderables/Renderable.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/renderables/Renderable.kt @@ -3,6 +3,8 @@ package at.hannibal2.skyhanni.utils.renderables import at.hannibal2.skyhanni.utils.NEUItems.renderOnScreen import io.github.moulberry.notenoughupdates.util.Utils import net.minecraft.client.Minecraft +import net.minecraft.client.gui.Gui +import net.minecraft.client.renderer.GlStateManager import net.minecraft.item.ItemStack import org.lwjgl.input.Mouse import kotlin.math.max @@ -30,8 +32,9 @@ interface Renderable { } } - fun link(text: String, onClick: () -> Unit): Renderable { - return clickable(hoverable(string("§n$text"), string(text)), onClick) + fun link(text: String, onClick: () -> Unit): Renderable = link(string(text), onClick) + fun link(renderable: Renderable, onClick: () -> Unit): Renderable { + return clickable(hoverable(underlined(renderable), renderable), onClick) } fun clickable(render: Renderable, onClick: () -> Unit, button: Int = 0): Renderable { @@ -39,7 +42,7 @@ interface Renderable { override val width: Int get() = render.width - var wasDown = false + private var wasDown = false override fun render(posX: Int, posY: Int) { val isDown = Mouse.isButtonDown(button) @@ -53,6 +56,19 @@ interface Renderable { } } + fun underlined(renderable: Renderable): Renderable { + return object : Renderable { + override val width: Int + get() = renderable.width + + override fun render(posX: Int, posY: Int) { + Gui.drawRect(0, 10, width, 11, 0xFFFFFFFF.toInt()) + GlStateManager.color(1F, 1F, 1F, 1F) + renderable.render(posX, posY) + } + } + } + fun hoverable(hovered: Renderable, unhovered: Renderable): Renderable { return object : Renderable { override val width: Int |