From d478eecf4732daefaa4df720d3dc69ef448add55 Mon Sep 17 00:00:00 2001 From: Erusel Date: Wed, 4 Sep 2024 04:07:31 +0000 Subject: [PATCH] Fix NavigationButton hover --- .../cobblemon/mod/common/client/gui/pc/NavigationButton.kt | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/common/src/main/kotlin/com/cobblemon/mod/common/client/gui/pc/NavigationButton.kt b/common/src/main/kotlin/com/cobblemon/mod/common/client/gui/pc/NavigationButton.kt index 8cc37d0cc2..c1fdb7dd8d 100644 --- a/common/src/main/kotlin/com/cobblemon/mod/common/client/gui/pc/NavigationButton.kt +++ b/common/src/main/kotlin/com/cobblemon/mod/common/client/gui/pc/NavigationButton.kt @@ -32,7 +32,6 @@ class NavigationButton( } override fun renderWidget(context: GuiGraphics, pMouseX: Int, pMouseY: Int, pPartialTicks: Float) { - val hovered = (isHovered(pMouseX.toDouble(), pMouseY.toDouble())) blitk( matrixStack = context.pose(), x = x / SCALE, @@ -40,7 +39,7 @@ class NavigationButton( texture = if (forward) forwardButtonResource else backwardsButtonResource, width = WIDTH, height = HEIGHT, - vOffset = if (hovered) HEIGHT else 0, + vOffset = if (isHovered()) HEIGHT else 0, textureHeight = HEIGHT * 2, scale = SCALE ) @@ -49,6 +48,4 @@ class NavigationButton( override fun playDownSound(soundManager: SoundManager) { soundManager.play(SimpleSoundInstance.forUI(CobblemonSounds.PC_CLICK, 1.0F)) } - - fun isHovered(mouseX: Double, mouseY: Double) = mouseX.toFloat() in (x.toFloat()..(x.toFloat() + (WIDTH * SCALE))) && mouseY.toFloat() in (y.toFloat()..(y.toFloat() + (HEIGHT * SCALE))) -} \ No newline at end of file +}