aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2/skyhanni/utils/RenderUtils.kt
diff options
context:
space:
mode:
authorCalMWolfs <94038482+CalMWolfs@users.noreply.github.com>2024-09-23 23:54:16 +1000
committerGitHub <noreply@github.com>2024-09-23 15:54:16 +0200
commitd39f595b150aaa0eee32c7ebacb961ef48095924 (patch)
tree03725f81d7090e880df9ae7038e6e40307a2e341 /src/main/java/at/hannibal2/skyhanni/utils/RenderUtils.kt
parent74490dcdb619e6eadf1be7665871cdaba4d58ee8 (diff)
downloadskyhanni-d39f595b150aaa0eee32c7ebacb961ef48095924.tar.gz
skyhanni-d39f595b150aaa0eee32c7ebacb961ef48095924.tar.bz2
skyhanni-d39f595b150aaa0eee32c7ebacb961ef48095924.zip
Backend: Remove more neu code from SkyHanni (#2419)
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/utils/RenderUtils.kt')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/utils/RenderUtils.kt28
1 files changed, 16 insertions, 12 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/utils/RenderUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/RenderUtils.kt
index 08532e0c4..609ccebae 100644
--- a/src/main/java/at/hannibal2/skyhanni/utils/RenderUtils.kt
+++ b/src/main/java/at/hannibal2/skyhanni/utils/RenderUtils.kt
@@ -19,11 +19,11 @@ import at.hannibal2.skyhanni.utils.CollectionUtils.zipWithNext3
import at.hannibal2.skyhanni.utils.ColorUtils.getFirstColorCode
import at.hannibal2.skyhanni.utils.LorenzColor.Companion.toLorenzColor
import at.hannibal2.skyhanni.utils.LorenzUtils.getCorners
+import at.hannibal2.skyhanni.utils.compat.GuiScreenUtils
import at.hannibal2.skyhanni.utils.renderables.Renderable
import at.hannibal2.skyhanni.utils.renderables.RenderableUtils.renderXAligned
import at.hannibal2.skyhanni.utils.renderables.RenderableUtils.renderYAligned
import at.hannibal2.skyhanni.utils.shader.ShaderManager
-import io.github.moulberry.notenoughupdates.util.Utils
import io.github.notenoughupdates.moulconfig.internal.TextRenderUtils
import net.minecraft.client.Minecraft
import net.minecraft.client.gui.FontRenderer
@@ -41,6 +41,7 @@ import net.minecraft.item.ItemStack
import net.minecraft.util.AxisAlignedBB
import net.minecraft.util.MathHelper
import net.minecraft.util.ResourceLocation
+import org.lwjgl.input.Mouse
import org.lwjgl.opengl.GL11
import java.awt.Color
import java.nio.FloatBuffer
@@ -95,6 +96,15 @@ object RenderUtils {
highlight(color, x, y)
}
+ fun getMouseX(): Int {
+ return Mouse.getX() * GuiScreenUtils.scaledWindowWidth / Minecraft.getMinecraft().displayWidth
+ }
+
+ fun getMouseY(): Int {
+ val height = GuiScreenUtils.scaledWindowHeight
+ return height - Mouse.getY() * height / Minecraft.getMinecraft().displayHeight - 1
+ }
+
fun highlight(color: Color, x: Int, y: Int) {
GlStateManager.disableLighting()
GlStateManager.disableDepth()
@@ -504,8 +514,8 @@ object RenderUtils {
fun Position.transform(): Pair<Int, Int> {
GlStateManager.translate(getAbsX().toFloat(), getAbsY().toFloat(), 0F)
GlStateManager.scale(effectiveScale, effectiveScale, 1F)
- val x = ((Utils.getMouseX() - getAbsX()) / effectiveScale).toInt()
- val y = ((Utils.getMouseY() - getAbsY()) / effectiveScale).toInt()
+ val x = ((getMouseX() - getAbsX()) / effectiveScale).toInt()
+ val y = ((getMouseY() - getAbsY()) / effectiveScale).toInt()
return x to y
}
@@ -1712,7 +1722,7 @@ object RenderUtils {
fun drawRoundTexturedRect(x: Int, y: Int, width: Int, height: Int, filter: Int, radius: Int = 10, smoothness: Int = 1) {
// if radius is 0 then just draw a normal textured rect
if (radius <= 0) {
- Utils.drawTexturedRect(x.toFloat(), y.toFloat(), width.toFloat(), height.toFloat(), filter)
+ GuiRenderUtils.drawTexturedRect(x, y, width, height, filter = filter)
return
}
@@ -1731,7 +1741,7 @@ object RenderUtils {
GlStateManager.pushMatrix()
ShaderManager.enableShader(ShaderManager.Shaders.ROUNDED_TEXTURE)
- Utils.drawTexturedRect(x.toFloat(), y.toFloat(), width.toFloat(), height.toFloat(), filter)
+ GuiRenderUtils.drawTexturedRect(x, y, width, height, filter = filter)
ShaderManager.disableShader()
GlStateManager.popMatrix()
@@ -1832,6 +1842,7 @@ object RenderUtils {
GlStateManager.popMatrix()
}
+ // todo merge with the one in GuiRenderUtils
fun drawGradientRect(
left: Int,
top: Int,
@@ -1871,13 +1882,6 @@ object RenderUtils {
GlStateManager.enableTexture2D()
}
- // TODO move off of neu function
- fun drawTexturedRect(x: Float, y: Float) {
- with(ScaledResolution(Minecraft.getMinecraft())) {
- Utils.drawTexturedRect(x, y, scaledWidth.toFloat(), scaledHeight.toFloat(), GL11.GL_NEAREST)
- }
- }
-
fun getAlpha(): Float {
colorBuffer.clear()
GlStateManager.getFloat(GL11.GL_CURRENT_COLOR, colorBuffer)