Skip to content

Commit 6a8e4a4

Browse files
committed
feat: (hud) Effects Modern mode draws a per-effect duration bar
The Modern potion widget showed name and remaining time as text only. It now renders an opt-in progress bar under each effect (toggle DurationBar), scaled against the highest duration seen for that potion so the bar depletes as the effect runs out.
1 parent 5ddea65 commit 6a8e4a4

1 file changed

Lines changed: 15 additions & 0 deletions

File tree

  • src/main/java/net/ccbluex/liquidbounce/ui/client/hud/element/elements

‎src/main/java/net/ccbluex/liquidbounce/ui/client/hud/element/elements/Effects.kt‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ class Effects(
4545
private val icon by boolean("Icon", true)
4646
private val effectName by boolean("Name", true)
4747
private val color by boolean("Color", false)
48+
private val durationBar by boolean("DurationBar", true) { mode == "Modern" }
4849

4950
private val textColorMode by choices(
5051
"Text-ColorMode",
@@ -60,6 +61,7 @@ class Effects(
6061
private val bgColorOption by color("Background-Color", Color(0, 0, 0, 120))
6162

6263
private val potionMap: MutableMap<Potion, PotionData> = HashMap()
64+
private val modernMaxDuration: MutableMap<Int, Int> = HashMap()
6365

6466
override fun drawElement(): Border {
6567
return when (mode) {
@@ -131,6 +133,19 @@ class Effects(
131133
val durationWidth = Fonts.InterMedium_13.stringWidth(durationText)
132134
Fonts.InterMedium_13.drawString(nameText, posX + padding, posY + 2, Color.WHITE.rgb)
133135
Fonts.InterMedium_13.drawString(durationText, posX + maxWidth - padding - durationWidth, posY + 2, Color.WHITE.rgb)
136+
137+
if (durationBar) {
138+
val prevMax = modernMaxDuration[effect.potionID] ?: 0
139+
val maxDur = maxOf(prevMax, effect.duration).coerceAtLeast(1)
140+
modernMaxDuration[effect.potionID] = maxDur
141+
val frac = (effect.duration.toFloat() / maxDur.toFloat()).coerceIn(0f, 1f)
142+
val barY = posY + Fonts.InterMedium_13.height.toFloat() + 1f
143+
val barLeft = posX + padding
144+
val barRight = posX + maxWidth - padding
145+
RenderPrimitives.drawRect(barLeft, barY, barRight, barY + 1.5f, Color(255, 255, 255, 60).rgb)
146+
RenderPrimitives.drawRect(barLeft, barY, barLeft + (barRight - barLeft) * frac, barY + 1.5f, getTextColor(0))
147+
}
148+
134149
posY += Fonts.InterMedium_13.height.toFloat() + padding
135150
}
136151

0 commit comments

Comments
 (0)