aboutsummaryrefslogtreecommitdiff
path: root/src/main/java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/data/GuiEditManager.kt9
-rw-r--r--src/main/java/at/hannibal2/skyhanni/utils/RenderUtils.kt4
-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
4 files changed, 30 insertions, 19 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/data/GuiEditManager.kt b/src/main/java/at/hannibal2/skyhanni/data/GuiEditManager.kt
index 16b41f6e6..d778be299 100644
--- a/src/main/java/at/hannibal2/skyhanni/data/GuiEditManager.kt
+++ b/src/main/java/at/hannibal2/skyhanni/data/GuiEditManager.kt
@@ -91,12 +91,9 @@ class GuiEditManager {
fun isInGui() = Minecraft.getMinecraft().currentScreen is GuiPositionEditor
fun Position.getDummySize(random: Boolean = false): Vector2i {
- if (random) {
- return Vector2i(5, 5)
- } else {
- val (x, y) = currentBorderSize[internalName] ?: return Vector2i(1, 1)
- return Vector2i((x * effectiveScale).toInt(), (y * effectiveScale).toInt())
- }
+ if (random) return Vector2i(5, 5)
+ val (x, y) = currentBorderSize[internalName] ?: return Vector2i(1, 1)
+ return Vector2i((x * effectiveScale).toInt(), (y * effectiveScale).toInt())
}
fun Position.getAbsX() = getAbsX0(getDummySize(true).x)
diff --git a/src/main/java/at/hannibal2/skyhanni/utils/RenderUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/RenderUtils.kt
index 57dfd0dc0..405dc1bb5 100644
--- a/src/main/java/at/hannibal2/skyhanni/utils/RenderUtils.kt
+++ b/src/main/java/at/hannibal2/skyhanni/utils/RenderUtils.kt
@@ -453,10 +453,10 @@ object RenderUtils {
private fun Position.renderLine(line: List<Any?>, offsetY: Int, itemScale: Double = 1.0): Int {
GlStateManager.pushMatrix()
- val mp = transform()
+ val (x, y) = transform()
GlStateManager.translate(0f, offsetY.toFloat(), 0F)
var offsetX = 0
- Renderable.withMousePosition(mp.first, mp.second) {
+ Renderable.withMousePosition(x, y) {
for (any in line) {
val renderable = Renderable.fromAny(any, itemScale = itemScale)
?: throw RuntimeException("Unknown render object: $any")
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
/**