Skip to content

Commit

Permalink
feat: watermark element
Browse files Browse the repository at this point in the history
  • Loading branch information
opZywl committed Feb 1, 2025
1 parent 8788fe0 commit f0b935a
Show file tree
Hide file tree
Showing 3 changed files with 228 additions and 189 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,8 @@ import net.ccbluex.liquidbounce.FDPClient.hud
import net.ccbluex.liquidbounce.event.*
import net.ccbluex.liquidbounce.features.module.Category
import net.ccbluex.liquidbounce.features.module.Module
import net.ccbluex.liquidbounce.features.module.modules.visual.NameProtect
import net.ccbluex.liquidbounce.ui.client.hud.designer.GuiHudDesigner
import net.ccbluex.liquidbounce.ui.client.hud.element.Element.Companion.MAX_GRADIENT_COLORS
import net.ccbluex.liquidbounce.ui.font.Fonts
import net.ccbluex.liquidbounce.utils.client.ClientThemesUtils
import net.ccbluex.liquidbounce.utils.render.*
import net.ccbluex.liquidbounce.utils.render.RenderUtils.drawRectWithBorder
Expand Down Expand Up @@ -59,9 +57,6 @@ object HUDModule : Module("HUD", Category.CLIENT) {
// CROSSHAIR
val csgoCrosshairValue by boolean("CSGO-Crosshair", true)

// WATERMARK
private val waterMark by choices("Watemark", arrayOf("Default", "Normal", "None"), "Default")

// UI EFFECT
val uiEffectValue by boolean("UIEffect", true)
val buttonShadowValue by boolean("ShadowButton", true){ uiEffectValue }
Expand All @@ -88,14 +83,6 @@ object HUDModule : Module("HUD", Category.CLIENT) {
ClientThemesUtils.getColor().rgb
}

private fun getProtectedName(): String {
return if (NameProtect.state) {
ColorUtils.stripColor(NameProtect.handleTextMessage(mc.thePlayer.name))
} else {
mc.thePlayer.name
}
}

private var tickCount = 0
private var lastSecond = System.currentTimeMillis()
private val tpsSamples = ArrayDeque<Int>(5)
Expand Down Expand Up @@ -131,182 +118,6 @@ object HUDModule : Module("HUD", Category.CLIENT) {
drawNormalCrosshair(screenWidth, screenHeight)
}
}
when (waterMark) {
"Normal" -> {
val shouldChange = ColorUtils.COLOR_PATTERN.matcher(CLIENT_NAME).find()
val text = if (shouldChange) {
"§r$CLIENT_NAME"
} else {
"${CLIENT_NAME.first()}§r§f${CLIENT_NAME.substring(1)}§7[§f${Minecraft.getDebugFPS()} FPS§7]§r "
}

val color = ClientThemesUtils.getColor().rgb

mc.fontRendererObj.drawStringWithShadow(text, 2.0f, 2.0f, color)
}
"Default" -> {
val posX = 4.0f
val posY = 4.0f
val iconSize = 5.0f
val rectWidth = 10.0f
val title = "FDP"
val titleWidth = Fonts.InterMedium_15.stringWidth(title)

val bgColorRGB = ClientThemesUtils.getBackgroundColor(0, 120).rgb

RenderUtils.drawCustomShapeWithRadius(
posX,
posY,
rectWidth + iconSize * 2.5f + titleWidth,
rectWidth + iconSize * 2.0f,
4.0f,
Color(bgColorRGB, true)
)
Fonts.Nursultan18.drawString(
"S",
posX + iconSize,
posY + 2 + iconSize - 1.0f + 2f,
ClientThemesUtils.getColor().rgb
)
Fonts.InterMedium_15.drawString(
title,
posX + rectWidth + iconSize * 1.5f,
posY + rectWidth / 2.0f + 1.5f + 2f,
ClientThemesUtils.getColor().rgb
)
val playerName = getProtectedName()
val playerNameWidth = Fonts.InterMedium_15.stringWidth(playerName)
val playerNameX = posX + rectWidth + iconSize * 2.5f + titleWidth + iconSize

RenderUtils.drawCustomShapeWithRadius(
playerNameX,
posY,
rectWidth + iconSize * 2.5f + playerNameWidth,
rectWidth + iconSize * 2.0f,
4.0f,
Color(bgColorRGB, true)
)
Fonts.InterMedium_15.drawString(
"W",
playerNameX + iconSize,
posY + 1 + iconSize + 2f,
ClientThemesUtils.getColor().rgb
)
Fonts.InterMedium_15.drawString(
playerName,
playerNameX + iconSize * 1.5f + rectWidth,
posY + rectWidth / 2.0f + 1.5f + 2f,
-1
)

val fps = Minecraft.getDebugFPS()
val fpsText = "$fps FPS"
val fpsTextWidth = Fonts.InterMedium_15.stringWidth(fpsText)
val fpsX = playerNameX + rectWidth + iconSize * 2.5f + playerNameWidth + iconSize

RenderUtils.drawCustomShapeWithRadius(
fpsX,
posY,
rectWidth + iconSize * 2.5f + fpsTextWidth,
rectWidth + iconSize * 2.0f,
4.0f,
Color(bgColorRGB, true)
)
Fonts.Nursultan18.drawString(
"X",
fpsX + iconSize,
posY + 1 + iconSize + 2f,
ClientThemesUtils.getColor().rgb
)
Fonts.InterMedium_15.drawString(
fpsText,
fpsX + iconSize * 1.5f + rectWidth,
posY + rectWidth / 2.0f + 1.5f + 2f,
-1
)

val playerPosition = "${mc.thePlayer.posX.toInt()} ${mc.thePlayer.posY.toInt()} ${mc.thePlayer.posZ.toInt()}"
val positionTextWidth = Fonts.InterMedium_15.stringWidth(playerPosition)
val positionY = posY + rectWidth + iconSize * 2.0f + iconSize

RenderUtils.drawCustomShapeWithRadius(
posX,
positionY,
rectWidth + iconSize * 2.5f + positionTextWidth,
rectWidth + iconSize * 2.0f,
4.0f,
Color(bgColorRGB, true)
)
Fonts.Nursultan18.drawString(
"F",
posX + iconSize,
positionY + 1.5f + iconSize + 2f,
ClientThemesUtils.getColor().rgb
)
Fonts.InterMedium_15.drawString(
playerPosition,
posX + iconSize * 1.5f + rectWidth,
positionY + rectWidth / 2.0f + 1.5f + 2f,
-1
)

val ping = try {
mc.netHandler.getPlayerInfo(mc.thePlayer.uniqueID).responseTime
} catch (e: Exception) {
0
}
val pingText = "$ping Ping"
val pingTextWidth = Fonts.InterMedium_15.stringWidth(pingText)
val pingX = posX + rectWidth + iconSize * 2.5f + positionTextWidth + iconSize

RenderUtils.drawCustomShapeWithRadius(
pingX,
positionY,
rectWidth + iconSize * 2.5f + pingTextWidth,
rectWidth + iconSize * 2.0f,
4.0f,
Color(bgColorRGB, true)
)
Fonts.Nursultan18.drawString(
"Q",
pingX + iconSize,
positionY + 1 + iconSize + 2f,
ClientThemesUtils.getColor().rgb
)
Fonts.InterMedium_15.drawString(
pingText,
pingX + iconSize * 1.5f + rectWidth,
positionY + rectWidth / 2.0f + 1.5f + 2f,
-1
)

val tpsText = "TPS: %.2f".format(tps)
val tpsIcon = "C"
val tpsX = posX
val tpsY = positionY + rectWidth + iconSize * 2.0f + 5f

RenderUtils.drawCustomShapeWithRadius(
tpsX,
tpsY,
rectWidth + iconSize * 2.5f + Fonts.InterMedium_15.stringWidth(tpsText),
rectWidth + iconSize * 2.0f,
4.0f,
Color(bgColorRGB, true)
)
Fonts.Nursultan18.drawString(
tpsIcon,
tpsX + iconSize,
tpsY + 1.5f + iconSize + 2f,
ClientThemesUtils.getColor().rgb
)
Fonts.InterMedium_15.drawString(
tpsText,
tpsX + iconSize * 1.5f + rectWidth,
tpsY + rectWidth / 2.0f + 1.5f + 2f,
-1
)
}
}
}

private fun drawSprintingCrosshair(screenWidth: Int, screenHeight: Int) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ object HUD : MinecraftInstance {
fun setDefault() {
elements.clear()

addElement(Watermark())
addElement(TabGUI())
addElement(Arraylist())
addElement(ScoreboardElement())
Expand Down
Loading

0 comments on commit f0b935a

Please sign in to comment.