Skip to content

Commit d3724ee

Browse files
committed
Fixed hud modules width and height
1 parent b4fa5e5 commit d3724ee

File tree

3 files changed

+12
-11
lines changed

3 files changed

+12
-11
lines changed

common/src/main/kotlin/com/lambda/graphics/renderer/gui/font/FontRenderer.kt

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import com.lambda.graphics.renderer.gui.font.core.LambdaAtlas.get
2525
import com.lambda.graphics.renderer.gui.font.core.LambdaAtlas.height
2626
import com.lambda.graphics.shader.Shader.Companion.shader
2727
import com.lambda.graphics.texture.TextureOwner.bind
28+
import com.lambda.module.modules.client.ClickGui
2829
import com.lambda.module.modules.client.LambdaMoji
2930
import com.lambda.module.modules.client.RenderSettings
3031
import com.lambda.util.math.MathUtils.toInt
@@ -59,7 +60,7 @@ object FontRenderer : AbstractGUIRenderer(VertexAttrib.Group.FONT, shader("font/
5960
text: String,
6061
position: Vec2d = Vec2d.ZERO,
6162
color: Color = Color.WHITE,
62-
scale: Double = 1.0,
63+
scale: Double = ClickGui.fontScale,
6364
shadow: Boolean = true,
6465
parseEmoji: Boolean = LambdaMoji.isEnabled
6566
) = render {
@@ -87,7 +88,7 @@ object FontRenderer : AbstractGUIRenderer(VertexAttrib.Group.FONT, shader("font/
8788
glyph: GlyphInfo,
8889
position: Vec2d,
8990
color: Color = Color.WHITE,
90-
scale: Double = 1.0
91+
scale: Double = ClickGui.fontScale,
9192
) = render {
9293
shader["u_FontTexture"] = 0
9394
shader["u_EmojiTexture"] = 1
@@ -147,7 +148,7 @@ object FontRenderer : AbstractGUIRenderer(VertexAttrib.Group.FONT, shader("font/
147148
*/
148149
fun getWidth(
149150
text: String,
150-
scale: Double = 1.0,
151+
scale: Double = ClickGui.fontScale,
151152
parseEmoji: Boolean = LambdaMoji.isEnabled,
152153
): Double {
153154
var width = 0.0

common/src/main/kotlin/com/lambda/module/hud/Coordinates.kt

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
package com.lambda.module.hud
1919

2020
import com.lambda.context.SafeContext
21+
import com.lambda.graphics.renderer.gui.font.FontRenderer
2122
import com.lambda.graphics.renderer.gui.font.FontRenderer.drawString
2223
import com.lambda.module.HudModule
2324
import com.lambda.module.tag.ModuleTag
@@ -37,13 +38,11 @@ object Coordinates : HudModule(
3738
private val showDimension by setting("Show Dimension", true)
3839
private val decimals by setting("Decimals", 2, 0..4, 1)
3940

40-
private val SafeContext.text: String
41-
get() = "XYZ ${if (showDimension) dimensionName else ""} ${positionForDimension()}"
41+
private val text: String
42+
get() = runSafe { "XYZ ${if (showDimension) dimensionName else ""} ${positionForDimension()}" } ?: ""
4243

43-
// TODO: Replace by LambdaAtlas height cache and actually build a proper text with highlighted parameters
44-
45-
override val height: Double get() = 20.0
46-
override val width: Double get() = 50.0
44+
override val height: Double get() = FontRenderer.getHeight()
45+
override val width: Double get() = FontRenderer.getWidth(text)
4746

4847
init {
4948
onRender {

common/src/main/kotlin/com/lambda/module/hud/TPS.kt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
package com.lambda.module.hud
1919

20+
import com.lambda.graphics.renderer.gui.font.FontRenderer
2021
import com.lambda.graphics.renderer.gui.font.FontRenderer.drawString
2122
import com.lambda.module.HudModule
2223
import com.lambda.module.tag.ModuleTag
@@ -35,8 +36,8 @@ object TPS : HudModule(
3536

3637
// TODO: Replace by LambdaAtlas height cache and actually build a proper text with highlighted parameters
3738

38-
override val height: Double get() = 20.0
39-
override val width: Double get() = 50.0
39+
override val height: Double get() = FontRenderer.getHeight()
40+
override val width: Double get() = FontRenderer.getWidth(text)
4041

4142
init {
4243
onRender {

0 commit comments

Comments
 (0)