aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2/skyhanni/utils/renderables
diff options
context:
space:
mode:
authorhannibal2 <24389977+hannibal00212@users.noreply.github.com>2023-09-15 10:00:42 +0200
committerhannibal2 <24389977+hannibal00212@users.noreply.github.com>2023-09-15 10:00:42 +0200
commit1de75a04d3751f4b99e64d9487c194e7d388a391 (patch)
treecad1845611995fcaa8d6fbc753ca51d3053982ea /src/main/java/at/hannibal2/skyhanni/utils/renderables
parent5527101322d1be9f62796e8a59b8c5de5dda0d0d (diff)
downloadskyhanni-1de75a04d3751f4b99e64d9487c194e7d388a391.tar.gz
skyhanni-1de75a04d3751f4b99e64d9487c194e7d388a391.tar.bz2
skyhanni-1de75a04d3751f4b99e64d9487c194e7d388a391.zip
code cleanup
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/utils/renderables')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/utils/renderables/RenderLineTooltips.kt30
-rw-r--r--src/main/java/at/hannibal2/skyhanni/utils/renderables/Renderable.kt6
2 files changed, 25 insertions, 11 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/utils/renderables/RenderLineTooltips.kt b/src/main/java/at/hannibal2/skyhanni/utils/renderables/RenderLineTooltips.kt
index 22675039e..68aebd04e 100644
--- a/src/main/java/at/hannibal2/skyhanni/utils/renderables/RenderLineTooltips.kt
+++ b/src/main/java/at/hannibal2/skyhanni/utils/renderables/RenderLineTooltips.kt
@@ -13,9 +13,11 @@ import java.awt.Color
object RenderLineTooltips {
- fun drawHoveringText(posX: Int, posY: Int, tips: List<String?>, stack: ItemStack? = null,
- mouseX: Int = Utils.getMouseX(),
- mouseY: Int = Utils.getMouseY()) {
+ fun drawHoveringText(
+ posX: Int, posY: Int, tips: List<String?>, stack: ItemStack? = null,
+ mouseX: Int = Utils.getMouseX(),
+ mouseY: Int = Utils.getMouseY()
+ ) {
if (tips.isNotEmpty()) {
var textLines = tips
val x = mouseX + 12 - posX
@@ -189,7 +191,15 @@ object RenderLineTooltips {
GlStateManager.disableLighting()
}
- private fun drawGradientRect(zLevel: Int, left: Int, top: Int, right: Int, bottom: Int, startColor: Int, endColor: Int) {
+ private fun drawGradientRect(
+ zLevel: Int,
+ left: Int,
+ top: Int,
+ right: Int,
+ bottom: Int,
+ startColor: Int,
+ endColor: Int
+ ) {
val startAlpha = (startColor shr 24 and 255).toFloat() / 255.0f
val startRed = (startColor shr 16 and 255).toFloat() / 255.0f
val startGreen = (startColor shr 8 and 255).toFloat() / 255.0f
@@ -206,10 +216,14 @@ object RenderLineTooltips {
val tessellator = Tessellator.getInstance()
val worldrenderer = tessellator.worldRenderer
worldrenderer.begin(7, DefaultVertexFormats.POSITION_COLOR)
- worldrenderer.pos(right.toDouble(), top.toDouble(), zLevel.toDouble()).color(startRed, startGreen, startBlue, startAlpha).endVertex()
- worldrenderer.pos(left.toDouble(), top.toDouble(), zLevel.toDouble()).color(startRed, startGreen, startBlue, startAlpha).endVertex()
- worldrenderer.pos(left.toDouble(), bottom.toDouble(), zLevel.toDouble()).color(endRed, endGreen, endBlue, endAlpha).endVertex()
- worldrenderer.pos(right.toDouble(), bottom.toDouble(), zLevel.toDouble()).color(endRed, endGreen, endBlue, endAlpha).endVertex()
+ worldrenderer.pos(right.toDouble(), top.toDouble(), zLevel.toDouble())
+ .color(startRed, startGreen, startBlue, startAlpha).endVertex()
+ worldrenderer.pos(left.toDouble(), top.toDouble(), zLevel.toDouble())
+ .color(startRed, startGreen, startBlue, startAlpha).endVertex()
+ worldrenderer.pos(left.toDouble(), bottom.toDouble(), zLevel.toDouble())
+ .color(endRed, endGreen, endBlue, endAlpha).endVertex()
+ worldrenderer.pos(right.toDouble(), bottom.toDouble(), zLevel.toDouble())
+ .color(endRed, endGreen, endBlue, endAlpha).endVertex()
tessellator.draw()
GlStateManager.shadeModel(7424)
GlStateManager.disableBlend()
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 ed3aa9cfd..b3ba7f906 100644
--- a/src/main/java/at/hannibal2/skyhanni/utils/renderables/Renderable.kt
+++ b/src/main/java/at/hannibal2/skyhanni/utils/renderables/Renderable.kt
@@ -18,9 +18,9 @@ import kotlin.math.max
interface Renderable {
val width: Int
val height: Int
- fun isHovered(posX: Int, posY: Int) = currentRenderPassMousePosition?.let { mp ->
- mp.first in (posX..posX + width)
- && mp.second in (posY..posY + height) // TODO: adjust for variable height?
+ fun isHovered(posX: Int, posY: Int) = currentRenderPassMousePosition?.let { (x, y) ->
+ x in (posX..posX + width)
+ && y in (posY..posY + height) // TODO: adjust for variable height?
} ?: false
/**