Skip to content

Commit

Permalink
make text not glitch out when hovering
Browse files Browse the repository at this point in the history
  • Loading branch information
Wyvest committed Nov 25, 2023
1 parent dc93417 commit f2430e1
Showing 1 changed file with 31 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import cc.polyfrost.oneconfig.libs.elementa.dsl.childOf
import cc.polyfrost.oneconfig.libs.elementa.dsl.constrain
import cc.polyfrost.oneconfig.libs.elementa.dsl.toConstraint
import cc.polyfrost.oneconfig.libs.universal.ChatColor
import cc.polyfrost.oneconfig.libs.universal.UMatrixStack
import mynameisjeff.skyblockclientupdater.SkyClientUpdater
import mynameisjeff.skyblockclientupdater.UpdateChecker
import mynameisjeff.skyblockclientupdater.data.UpdateMod
Expand All @@ -34,6 +35,14 @@ class ModUpdateComponent(
color = SkyClientUpdater.accentColor.toConstraint()
} childOf this

private var heldAction: (() -> Unit)? = null

override fun afterDraw(matrixStack: UMatrixStack) {
super.afterDraw(matrixStack)
heldAction?.invoke()
heldAction = null
}

init {
seperatorContainer.constrain {
width = seperatorText.constraints.width
Expand Down Expand Up @@ -68,27 +77,31 @@ class ModUpdateComponent(
}
}
}.onMouseEnter {
when (update.type) {
UpdateMod.Type.UPDATING -> {
newFileText.setText("${ChatColor.GREEN}${update.name} ${ChatColor.WHITE}(skip)")
}
UpdateMod.Type.TEMP_DISABLE -> {
newFileText.setText("${ChatColor.RED}${update.name} ${ChatColor.WHITE}(ignore)")
}
UpdateMod.Type.DISABLE -> {
newFileText.setText("${ChatColor.GREEN}${update.name}")
heldAction = {
when (update.type) {
UpdateMod.Type.UPDATING -> {
newFileText.setText("${ChatColor.GREEN}${ChatColor.STRIKETHROUGH}${update.name} ${ChatColor.WHITE}(skip)")
}
UpdateMod.Type.TEMP_DISABLE -> {
newFileText.setText("${ChatColor.RED}${ChatColor.STRIKETHROUGH}${update.name} ${ChatColor.WHITE}(ignore)")
}
UpdateMod.Type.DISABLE -> {
newFileText.setText("${ChatColor.GREEN}${ChatColor.STRIKETHROUGH}${update.name}")
}
}
}
}.onMouseLeave {
when (update.type) {
UpdateMod.Type.UPDATING -> {
newFileText.setText("${ChatColor.GREEN}${update.name}")
}
UpdateMod.Type.TEMP_DISABLE -> {
newFileText.setText("${ChatColor.GREEN}${ChatColor.STRIKETHROUGH}${update.name} ${ChatColor.WHITE}(skipping)")
}
UpdateMod.Type.DISABLE -> {
newFileText.setText("${ChatColor.RED}${ChatColor.STRIKETHROUGH}${update.name} ${ChatColor.WHITE}(ignored)")
heldAction = {
when (update.type) {
UpdateMod.Type.UPDATING -> {
newFileText.setText("${ChatColor.GREEN}${update.name}")
}
UpdateMod.Type.TEMP_DISABLE -> {
newFileText.setText("${ChatColor.GREEN}${ChatColor.STRIKETHROUGH}${update.name} ${ChatColor.WHITE}(skipping)")
}
UpdateMod.Type.DISABLE -> {
newFileText.setText("${ChatColor.RED}${ChatColor.STRIKETHROUGH}${update.name} ${ChatColor.WHITE}(ignored)")
}
}
}
}
Expand Down

0 comments on commit f2430e1

Please sign in to comment.