Skip to content

Commit

Permalink
feat(legacy): Shrink Target-HUD padding (#5675)
Browse files Browse the repository at this point in the history
  • Loading branch information
RtxOP authored Feb 22, 2025
1 parent c303c8d commit fc2b82a
Showing 1 changed file with 36 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ class Target : Element("Target") {
private val healthBarColor1 by color("HealthBar-Gradient1", Color(3, 65, 252))
private val healthBarColor2 by color("HealthBar-Gradient2", Color(3, 252, 236))

private val roundHealthBarShape by boolean("RoundHealthBarShape", true)

private val borderMode by choices("Border-ColorMode", arrayOf("Custom", "Rainbow"), "Custom")
private val borderColor by color("Border-Color", Color.BLACK) { borderMode == "Custom" }

Expand Down Expand Up @@ -130,12 +132,12 @@ class Target : Element("Target") {
width = AnimationUtil.base(width.toDouble(), targetWidth.toDouble(), animationSpeed.toDouble())
.toFloat().coerceAtLeast(0f)

val targetHeight = if (shouldRender) 40f else if (delayCounter >= vanishDelay) 0f else height
val targetHeight = if (shouldRender) 36f else if (delayCounter >= vanishDelay) 0f else height
height = AnimationUtil.base(height.toDouble(), targetHeight.toDouble(), animationSpeed.toDouble())
.toFloat().coerceAtLeast(0f)
} else {
width = stringWidth
height = 40f
height = 36f

val targetText =
if (shouldRender) textColor.alpha else if (delayCounter >= vanishDelay) 0f else alphaText
Expand Down Expand Up @@ -200,32 +202,42 @@ class Target : Element("Target") {
)
}

val healthBarTop = 26F
val healthBarTop = 24F
val healthBarHeight = 8F
val healthBarStart = 38F
val healthBarTotal = (width - 41F).coerceAtLeast(0F)
val healthBarStart = 36F
val healthBarTotal = (width - 39F).coerceAtLeast(0F)
val currentWidth = (easingHealth / maxHealth).coerceIn(0F, 1F) * healthBarTotal

// background bar
drawRoundedRect(
healthBarStart,
healthBarTop,
healthBarStart + healthBarTotal,
healthBarTop + healthBarHeight,
Color.BLACK.rgb,
6F,
)

// main bar
withClipping(main = {
val backgroundBar = {
drawRoundedRect(
healthBarStart,
healthBarTop,
healthBarStart + currentWidth,
healthBarStart + healthBarTotal,
healthBarTop + healthBarHeight,
0,
6F
Color.BLACK.rgb,
6F,
)
}

if (roundHealthBarShape) {
backgroundBar()
}

// main bar
withClipping(main = {
if (roundHealthBarShape) {
drawRoundedRect(
healthBarStart,
healthBarTop,
healthBarStart + currentWidth,
healthBarTop + healthBarHeight,
0,
6F
)
} else {
backgroundBar()
}
}, toClip = {
drawGradientRect(
healthBarStart.toInt(),
Expand Down Expand Up @@ -260,34 +272,26 @@ class Target : Element("Target") {
val f1 = (0.7F..1F).lerpWith(scale) * this.scale
val color = ColorUtils.interpolateColor(Color.RED, Color.WHITE, scale)
val centerX1 = (4..32).lerpWith(0.5F)
val midY = (6f..32f).lerpWith(0.5F)
val midY = (4f..28f).lerpWith(0.5F)

glTranslatef(centerX1, midY, 0f)
glScalef(f1, f1, f1)
glTranslatef(-centerX1, -midY, 0f)

if (entityTexture != null) {
withClipping(main = {
drawRoundedRect(6f, 6f, 34f, 34f, 0, roundedRectRadius)
drawRoundedRect(4f, 4f, 32f, 32f, 0, roundedRectRadius)
}, toClip = {
drawHead(
entityTexture,
6,
6,
8f, 8f, 8, 8,
28,
28,
64F,
64F,
color
entityTexture, 4, 4, 8f, 8f, 8, 8, 28, 28, 64F, 64F, color
)
})
}
glPopMatrix()
}

target.name?.let {
titleFont.drawString(it, healthBarStart, 8F, textCustomColor, textShadow)
titleFont.drawString(it, healthBarStart, 6F, textCustomColor, textShadow)
}
}
}
Expand All @@ -297,6 +301,6 @@ class Target : Element("Target") {
}

lastTarget = target
return Border(0F, 0F, stringWidth, 40F)
return Border(0F, 0F, stringWidth, 36F)
}
}

0 comments on commit fc2b82a

Please sign in to comment.