From 304aa419337697a4268e5cea0648a69547371b1b Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Date: Thu, 27 Apr 2023 13:50:47 +0200 Subject: Added logging to renderable link clicking --- .../skyhanni/utils/renderables/Renderable.kt | 33 +++++++++++++++++----- 1 file changed, 26 insertions(+), 7 deletions(-) (limited to 'src/main/java/at/hannibal2/skyhanni') 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 a4e6b4347..4d8351083 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/renderables/Renderable.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/renderables/Renderable.kt @@ -2,6 +2,7 @@ package at.hannibal2.skyhanni.utils.renderables import at.hannibal2.skyhanni.config.core.config.gui.GuiPositionEditor import at.hannibal2.skyhanni.data.ToolTipData +import at.hannibal2.skyhanni.utils.LorenzLogger import at.hannibal2.skyhanni.utils.NEUItems.renderOnScreen import io.github.moulberry.moulconfig.gui.GuiScreenElementWrapper import io.github.moulberry.notenoughupdates.util.Utils @@ -26,6 +27,8 @@ interface Renderable { fun render(posX: Int, posY: Int) companion object { + val logger = LorenzLogger("debug/renderable") + fun fromAny(any: Any?, itemScale: Double = 1.0): Renderable? = when (any) { null -> placeholder(12) is Renderable -> any @@ -52,7 +55,7 @@ interface Renderable { override fun render(posX: Int, posY: Int) { val isDown = Mouse.isButtonDown(button) if (isDown > wasDown && isHovered(posX, posY)) { - if (condition() && shouldAllowLink()) { + if (condition() && shouldAllowLink(true)) { onClick() } } @@ -62,14 +65,30 @@ interface Renderable { } - private fun shouldAllowLink(): Boolean { - val a = Minecraft.getMinecraft().currentScreen != null - val b = Minecraft.getMinecraft().currentScreen !is GuiPositionEditor - val c = if (Minecraft.getMinecraft().currentScreen !is GuiEditSign) { + private fun shouldAllowLink(debug: Boolean = false): Boolean { + val isGuiScreen = Minecraft.getMinecraft().currentScreen != null + val isGuiPositionEditor = Minecraft.getMinecraft().currentScreen !is GuiPositionEditor + val isNotInSignAndOnSlot = if (Minecraft.getMinecraft().currentScreen !is GuiEditSign) { ToolTipData.lastSlot == null } else true - val d = Minecraft.getMinecraft().currentScreen !is GuiScreenElementWrapper - return a && b && c && d + val isConfigScreen = Minecraft.getMinecraft().currentScreen !is GuiScreenElementWrapper + val result = isGuiScreen && isGuiPositionEditor && isNotInSignAndOnSlot && isConfigScreen + + if (debug) { + if (!result) { + logger.log("") + logger.log("blocked link because:") + if (!isGuiScreen) logger.log("isGuiScreen") + if (!isGuiPositionEditor) logger.log("isGuiPositionEditor") + if (!isNotInSignAndOnSlot) logger.log("isNotInSignAndOnSlot") + if (!isConfigScreen) logger.log("isConfigScreen") + logger.log("") + } else { + logger.log("allowed click") + } + } + + return result } fun underlined(renderable: Renderable) = object : Renderable { -- cgit