From 1de75a04d3751f4b99e64d9487c194e7d388a391 Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Date: Fri, 15 Sep 2023 10:00:42 +0200 Subject: code cleanup --- .../utils/renderables/RenderLineTooltips.kt | 30 ++++++++++++++++------ .../skyhanni/utils/renderables/Renderable.kt | 6 ++--- 2 files changed, 25 insertions(+), 11 deletions(-) (limited to 'src/main/java/at/hannibal2/skyhanni/utils/renderables') 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, stack: ItemStack? = null, - mouseX: Int = Utils.getMouseX(), - mouseY: Int = Utils.getMouseY()) { + fun drawHoveringText( + posX: Int, posY: Int, tips: List, 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 /** -- cgit