diff options
author | hannibal2 <24389977+hannibal00212@users.noreply.github.com> | 2023-03-24 19:37:10 +0100 |
---|---|---|
committer | hannibal2 <24389977+hannibal00212@users.noreply.github.com> | 2023-03-24 19:37:10 +0100 |
commit | 7d7b2aaf85592840da824c6ce29c992cd669c84c (patch) | |
tree | a0b48ac677694de385a7435cee4fb0602dbdfc9b | |
parent | bb35657f6c5869f04c4ce633446a1809a07a0c07 (diff) | |
download | skyhanni-7d7b2aaf85592840da824c6ce29c992cd669c84c.tar.gz skyhanni-7d7b2aaf85592840da824c6ce29c992cd669c84c.tar.bz2 skyhanni-7d7b2aaf85592840da824c6ce29c992cd669c84c.zip |
Added support for editing gui elements what are only visible white in an inv
3 files changed, 23 insertions, 26 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 d09fcbc25..a2eea8f3a 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 @@ -35,11 +35,9 @@ import java.io.IOException class GuiPositionEditor( overlayPositions: LinkedHashMap<Position, Position>, - closedCallback: Runnable, ) : GuiScreen() { private val positions: ArrayList<Position> private val originalPositions: ArrayList<Position> - private val closedCallback: Runnable private var grabbedX = 0 private var grabbedY = 0 private var clickedPos = -1 @@ -54,12 +52,10 @@ class GuiPositionEditor( } positions = pos originalPositions = ogPos - this.closedCallback = closedCallback } override fun onGuiClosed() { super.onGuiClosed() - closedCallback.run() clickedPos = -1 } @@ -85,9 +81,8 @@ class GuiPositionEditor( } drawDefaultBackground() - val text = "§cSkyHanni Position Editor" Utils.drawStringCentered( - text, Minecraft.getMinecraft().fontRendererObj, + "§cSkyHanni Position Editor", Minecraft.getMinecraft().fontRendererObj, (scaledResolution.scaledWidth / 2).toFloat(), 8f, true, 0xffffff ) @@ -112,17 +107,18 @@ class GuiPositionEditor( elementHeight = position.getDummySize().y.toInt() drawRect(x - border, y - border, x + elementWidth + border * 2, y + elementHeight + border * 2, -0x7fbfbfc0) + + if (hoveredPos == -1) { + hoveredPos = clickedPos + } + if (hoveredPos != -1) { val pos = positions[hoveredPos] - Utils.drawStringCentered( - "§b" + pos.internalName, Minecraft.getMinecraft().fontRendererObj, - (scaledResolution.scaledWidth / 2).toFloat(), 18f, true, 0xffffff - ) + Utils.drawStringCentered("§b" + pos.internalName, Minecraft.getMinecraft().fontRendererObj, + (scaledResolution.scaledWidth / 2).toFloat(), 18f, true, 0xffffff) val location = "§7x: §e${pos.rawX}§7, y: §e${pos.rawY}" - Utils.drawStringCentered( - location, Minecraft.getMinecraft().fontRendererObj, - (scaledResolution.scaledWidth / 2).toFloat(), 28f, true, 0xffffff - ) + Utils.drawStringCentered(location, Minecraft.getMinecraft().fontRendererObj, + (scaledResolution.scaledWidth / 2).toFloat(), 28f, true, 0xffffff) } } GlStateManager.popMatrix() diff --git a/src/main/java/at/hannibal2/skyhanni/data/GuiEditManager.kt b/src/main/java/at/hannibal2/skyhanni/data/GuiEditManager.kt index 058eb92a3..d20605a6c 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/GuiEditManager.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/GuiEditManager.kt @@ -5,13 +5,14 @@ import at.hannibal2.skyhanni.config.core.config.Position import at.hannibal2.skyhanni.config.core.config.gui.GuiPositionEditor import at.hannibal2.skyhanni.events.GuiRenderEvent import at.hannibal2.skyhanni.utils.LorenzUtils -import io.github.moulberry.notenoughupdates.NotEnoughUpdates import net.minecraft.client.Minecraft import net.minecraft.client.gui.ScaledResolution +import net.minecraft.client.gui.inventory.GuiChest +import net.minecraft.client.gui.inventory.GuiInventory import net.minecraft.client.renderer.GlStateManager import net.minecraftforge.fml.common.eventhandler.EventPriority import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -import net.minecraftforge.fml.common.gameevent.InputEvent +import net.minecraftforge.fml.common.gameevent.TickEvent import org.lwjgl.input.Keyboard import org.lwjgl.util.vector.Vector2f import java.util.* @@ -20,9 +21,14 @@ class GuiEditManager { // TODO Make utils method for this @SubscribeEvent - fun onKeyBindPressed(event: InputEvent.KeyInputEvent) { + fun onTick(event: TickEvent.ClientTickEvent) { if (!LorenzUtils.inSkyBlock) return + Minecraft.getMinecraft().currentScreen?.let { + if (it !is GuiInventory && it !is GuiChest) return + } + + if (!Keyboard.getEventKeyState()) return val key = if (Keyboard.getEventKey() == 0) Keyboard.getEventCharacter().code + 256 else Keyboard.getEventKey() if (SkyHanniMod.feature.gui.keyBindOpen == key) { @@ -32,7 +38,7 @@ class GuiEditManager { } @SubscribeEvent(priority = EventPriority.LOWEST) - fun onRenderOverlay(event: GuiRenderEvent) { + fun onRenderOverlay(event: GuiRenderEvent.GameOverlayRenderEvent) { latestPositions = currentPositions.toMap() currentPositions.clear() } @@ -51,23 +57,18 @@ class GuiEditManager { } if (!currentPositions.containsKey(name)) { currentPositions[name] = position - - currentBorderSize[posLabel] = Pair(x, y) } } @JvmStatic fun openGuiEditor() { - val savedGui = Minecraft.getMinecraft().currentScreen - val help = LinkedHashMap<Position, Position>() for (position in latestPositions.values) { help[position] = position } - val guiPositionEditor = GuiPositionEditor(help) { NotEnoughUpdates.INSTANCE.openGui = savedGui } - SkyHanniMod.screenToOpen = guiPositionEditor + SkyHanniMod.screenToOpen = GuiPositionEditor(help) } @JvmStatic diff --git a/src/main/java/at/hannibal2/skyhanni/features/event/diana/BurrowWarpHelper.kt b/src/main/java/at/hannibal2/skyhanni/features/event/diana/BurrowWarpHelper.kt index ef1cc5cec..a75060476 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/event/diana/BurrowWarpHelper.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/event/diana/BurrowWarpHelper.kt @@ -18,9 +18,9 @@ class BurrowWarpHelper { private var lastWarp: WarpPoint? = null @SubscribeEvent - fun onKeyBindPressed(event: KeyInputEvent?) { + fun onKeyBindPressed(event: KeyInputEvent) { if (!LorenzUtils.inSkyBlock) return - if(LorenzUtils.skyBlockIsland != IslandType.HUB) return + if (LorenzUtils.skyBlockIsland != IslandType.HUB) return if (!SkyHanniMod.feature.diana.burrowNearestWarp) return if (!Keyboard.getEventKeyState()) return |