diff options
author | hannibal2 <24389977+hannibal00212@users.noreply.github.com> | 2023-03-24 23:38:43 +0100 |
---|---|---|
committer | hannibal2 <24389977+hannibal00212@users.noreply.github.com> | 2023-03-24 23:38:43 +0100 |
commit | 5e45db646c7ee0942aab282643e94943a153f639 (patch) | |
tree | ea302afd5d43a03dd710e016a23ee1d1ecaa8824 /src/main/java/at/hannibal2/skyhanni/config | |
parent | 36aced79ed3aa9ec67b6c81534705475531220f5 (diff) | |
download | skyhanni-5e45db646c7ee0942aab282643e94943a153f639.tar.gz skyhanni-5e45db646c7ee0942aab282643e94943a153f639.tar.bz2 skyhanni-5e45db646c7ee0942aab282643e94943a153f639.zip |
Code cleanup
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/config')
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/config/core/config/gui/GuiPositionEditor.kt | 56 |
1 files changed, 32 insertions, 24 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/config/core/config/gui/GuiPositionEditor.kt b/src/main/java/at/hannibal2/skyhanni/config/core/config/gui/GuiPositionEditor.kt index 581198168..3dead0a26 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/core/config/gui/GuiPositionEditor.kt +++ b/src/main/java/at/hannibal2/skyhanni/config/core/config/gui/GuiPositionEditor.kt @@ -45,13 +45,43 @@ class GuiPositionEditor(private val positions: List<Position>, private val borde super.drawScreen(unusedX, unusedY, partialTicks) drawDefaultBackground() + val hoveredPos = renderRectangles() + + renderLabels(hoveredPos) + } + + private fun renderLabels(hoveredPos: Int) { Utils.drawStringCentered( "§cSkyHanni Position Editor", Minecraft.getMinecraft().fontRendererObj, (getScaledWidth() / 2).toFloat(), 8f, true, 0xffffff ) - var hoveredPos = -1 + var displayPos = -1 + if (clickedPos != -1) { + if (positions[clickedPos].clicked) { + displayPos = clickedPos + } + } + if (displayPos == -1) { + displayPos = hoveredPos + } + if (displayPos == -1) return + + val pos = positions[displayPos] + Utils.drawStringCentered( + "§b" + pos.internalName, + Minecraft.getMinecraft().fontRendererObj, (getScaledWidth() / 2).toFloat(), 18f, true, 0xffffff + ) + val location = "§7x: §e${pos.rawX}§7, y: §e${pos.rawY}" + Utils.drawStringCentered( + location, + Minecraft.getMinecraft().fontRendererObj, (getScaledWidth() / 2).toFloat(), 28f, true, 0xffffff + ) + } + + private fun renderRectangles(): Int { + var hoveredPos = -1 GlStateManager.pushMatrix() width = getScaledWidth() height = getScaledHeight() @@ -76,29 +106,7 @@ class GuiPositionEditor(private val positions: List<Position>, private val borde } } GlStateManager.popMatrix() - - var displayPos = -1 - if (clickedPos != -1) { - if (positions[clickedPos].clicked) { - displayPos = clickedPos - } - } - if (displayPos == -1) { - displayPos = hoveredPos - } - - if (displayPos != -1) { - val pos = positions[displayPos] - Utils.drawStringCentered( - "§b" + pos.internalName, - Minecraft.getMinecraft().fontRendererObj, (getScaledWidth() / 2).toFloat(), 18f, true, 0xffffff - ) - val location = "§7x: §e${pos.rawX}§7, y: §e${pos.rawY}" - Utils.drawStringCentered( - location, - Minecraft.getMinecraft().fontRendererObj, (getScaledWidth() / 2).toFloat(), 28f, true, 0xffffff - ) - } + return hoveredPos } private fun getScaledHeight() = ScaledResolution(Minecraft.getMinecraft()).scaledHeight |