aboutsummaryrefslogtreecommitdiff
path: root/src
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
parent5527101322d1be9f62796e8a59b8c5de5dda0d0d (diff)
downloadskyhanni-1de75a04d3751f4b99e64d9487c194e7d388a391.tar.gz
skyhanni-1de75a04d3751f4b99e64d9487c194e7d388a391.tar.bz2
skyhanni-1de75a04d3751f4b99e64d9487c194e7d388a391.zip
code cleanup
Diffstat (limited to 'src')
-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
/**