aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at
diff options
context:
space:
mode:
authorThunderblade73 <85900443+Thunderblade73@users.noreply.github.com>2024-01-15 21:12:30 +0100
committerGitHub <noreply@github.com>2024-01-15 21:12:30 +0100
commit844775c7d5a4f97d074596698c7269ed0e9d0ae7 (patch)
treecde0bf543fe3f4b6dedb52ad060e6cfe5f49ed0c /src/main/java/at
parent996424847ec9afbba9f4f8ec0e8bdc2e7d67ebb8 (diff)
downloadskyhanni-844775c7d5a4f97d074596698c7269ed0e9d0ae7.tar.gz
skyhanni-844775c7d5a4f97d074596698c7269ed0e9d0ae7.tar.bz2
skyhanni-844775c7d5a4f97d074596698c7269ed0e9d0ae7.zip
Fix: GuiEditor Key working in NEUs PV textboxes (#924)
Fixed GUI Editor hotkey working while inside a NEU PV text box. #924
Diffstat (limited to 'src/main/java/at')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/data/GuiEditManager.kt12
-rw-r--r--src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt13
2 files changed, 22 insertions, 3 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/data/GuiEditManager.kt b/src/main/java/at/hannibal2/skyhanni/data/GuiEditManager.kt
index b7901d078..0f1da835b 100644
--- a/src/main/java/at/hannibal2/skyhanni/data/GuiEditManager.kt
+++ b/src/main/java/at/hannibal2/skyhanni/data/GuiEditManager.kt
@@ -7,9 +7,11 @@ import at.hannibal2.skyhanni.events.GuiRenderEvent
import at.hannibal2.skyhanni.events.LorenzKeyPressEvent
import at.hannibal2.skyhanni.test.SkyHanniDebugsAndTests
import at.hannibal2.skyhanni.utils.LorenzUtils
+import at.hannibal2.skyhanni.utils.LorenzUtils.getPropertiesWithType
import at.hannibal2.skyhanni.utils.LorenzUtils.isRancherSign
import at.hannibal2.skyhanni.utils.NEUItems
import at.hannibal2.skyhanni.utils.SimpleTimeMark
+import io.github.moulberry.notenoughupdates.itemeditor.GuiElementTextField
import io.github.moulberry.notenoughupdates.profileviewer.GuiProfileViewer
import net.minecraft.client.Minecraft
import net.minecraft.client.gui.inventory.GuiChest
@@ -33,7 +35,7 @@ class GuiEditManager {
if (isInGui()) return
Minecraft.getMinecraft().currentScreen?.let {
- if (it !is GuiInventory && it !is GuiChest && it !is GuiEditSign && it !is GuiProfileViewer) return
+ if (it !is GuiInventory && it !is GuiChest && it !is GuiEditSign && !(it is GuiProfileViewer && !it.anyTextBoxFocused())) return
if (it is GuiEditSign && !it.isRancherSign()) return
}
@@ -51,6 +53,7 @@ class GuiEditManager {
}
companion object {
+
var currentPositions = mutableMapOf<String, Position>()
private var latestPositions = mapOf<String, Position>()
private var currentBorderSize = mutableMapOf<String, Pair<Int, Int>>()
@@ -77,8 +80,8 @@ class GuiEditManager {
lastHotkeyReminded = SimpleTimeMark.now()
LorenzUtils.chat(
"§eTo edit hidden GUI elements:\n" +
- " §7- §e1. Set a key in /sh edit.\n" +
- " §7- §e2. Click that key while the GUI element is visible."
+ " §7- §e1. Set a key in /sh edit.\n" +
+ " §7- §e2. Click that key while the GUI element is visible."
)
}
}
@@ -111,6 +114,9 @@ class GuiEditManager {
fun Position.getAbsX() = getAbsX0(getDummySize(true).x)
fun Position.getAbsY() = getAbsY0(getDummySize(true).y)
+
+ fun GuiProfileViewer.anyTextBoxFocused() =
+ this.getPropertiesWithType<GuiElementTextField>().any{it.focus}
}
}
diff --git a/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt
index bec3af2f1..aa1b8e95d 100644
--- a/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt
+++ b/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt
@@ -42,6 +42,11 @@ import kotlin.properties.ReadWriteProperty
import kotlin.reflect.KMutableProperty1
import kotlin.reflect.KProperty
import kotlin.reflect.KProperty0
+import kotlin.reflect.KProperty1
+import kotlin.reflect.full.isSubtypeOf
+import kotlin.reflect.full.memberProperties
+import kotlin.reflect.full.starProjectedType
+import kotlin.reflect.jvm.isAccessible
import kotlin.time.Duration
import kotlin.time.Duration.Companion.seconds
@@ -501,6 +506,14 @@ object LorenzUtils {
}
}
+ inline fun <reified T : Any> Any.getPropertiesWithType() =
+ this::class.memberProperties
+ .filter { it.returnType.isSubtypeOf(T::class.starProjectedType) }
+ .map {
+ it.isAccessible = true
+ (it as KProperty1<Any, T>).get(this)
+ }
+
fun List<String>.nextAfter(after: String, skip: Int = 1) = nextAfter({ it == after }, skip)
fun List<String>.nextAfter(after: (String) -> Boolean, skip: Int = 1): String? {