diff options
| author | hannibal2 <24389977+hannibal002@users.noreply.github.com> | 2024-04-15 18:53:53 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-04-15 18:53:53 +0200 |
| commit | c78914d5e8bfca12eef8f6c9ff976aed26269345 (patch) | |
| tree | 7aa494224edff67087b01570e866a817418e0caf /src/main/java/at/hannibal2/skyhanni/utils/renderables | |
| parent | 53f2cfd71a6e97fe59e2ced18045e8eed0434f4e (diff) | |
| download | skyhanni-c78914d5e8bfca12eef8f6c9ff976aed26269345.tar.gz skyhanni-c78914d5e8bfca12eef8f6c9ff976aed26269345.tar.bz2 skyhanni-c78914d5e8bfca12eef8f6c9ff976aed26269345.zip | |
Improvement: Sack Display Update (#1381)
Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com>
Co-authored-by: Cal <cwolfson58@gmail.com>
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/utils/renderables')
| -rw-r--r-- | src/main/java/at/hannibal2/skyhanni/utils/renderables/Renderable.kt | 24 | ||||
| -rw-r--r-- | src/main/java/at/hannibal2/skyhanni/utils/renderables/RenderableUtils.kt | 1 |
2 files changed, 17 insertions, 8 deletions
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 f3961660d..128cd4482 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/renderables/Renderable.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/renderables/Renderable.kt @@ -81,17 +81,23 @@ interface Renderable { text: String, onClick: () -> Unit, bypassChecks: Boolean = false, + highlightsOnHoverSlots: List<Int> = emptyList(), condition: () -> Boolean = { true }, - ): Renderable = link(string(text), onClick, bypassChecks, condition) + ): Renderable = link(string(text), onClick, bypassChecks, highlightsOnHoverSlots = highlightsOnHoverSlots, condition) fun link( renderable: Renderable, onClick: () -> Unit, bypassChecks: Boolean = false, + highlightsOnHoverSlots: List<Int> = emptyList(), condition: () -> Boolean = { true }, ): Renderable { return clickable( - hoverable(underlined(renderable), renderable, bypassChecks, condition = condition), + hoverable( + underlined(renderable), renderable, bypassChecks, + condition = condition, + highlightsOnHoverSlots = highlightsOnHoverSlots + ), onClick, 0, bypassChecks, @@ -245,6 +251,7 @@ interface Renderable { unhovered: Renderable, bypassChecks: Boolean = false, condition: () -> Boolean = { true }, + highlightsOnHoverSlots: List<Int> = emptyList(), ) = object : Renderable { override val width: Int get() = max(hovered.width, unhovered.width) @@ -255,11 +262,14 @@ interface Renderable { var isHovered = false override fun render(posX: Int, posY: Int) { - isHovered = if (isHovered(posX, posY) && condition() && shouldAllowLink(true, bypassChecks)) { - hovered.render(posX, posY) - true - } else { - unhovered.render(posX, posY) + val pair = Pair(posX, posY) + isHovered = if (isHovered(posX, posY) && condition() && shouldAllowLink(true, bypassChecks)) { + hovered.render(posX, posY) + HighlightOnHoverSlot.currentSlots[pair] = highlightsOnHoverSlots + true + } else { + unhovered.render(posX, posY) + HighlightOnHoverSlot.currentSlots.remove(pair) false } } diff --git a/src/main/java/at/hannibal2/skyhanni/utils/renderables/RenderableUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/renderables/RenderableUtils.kt index 70969d8fd..4af54b09f 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/renderables/RenderableUtils.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/renderables/RenderableUtils.kt @@ -64,5 +64,4 @@ internal object RenderableUtils { this.render(posX, posY + yOffset) GlStateManager.translate(0f, -yOffset.toFloat(), 0f) } - } |
