Skip to content

Commit 1585326

Browse files
committed
Cleanup(merged settings, rect renderging features)
1 parent 9efcebc commit 1585326

File tree

10 files changed

+72
-72
lines changed

10 files changed

+72
-72
lines changed

common/src/main/kotlin/com/lambda/graphics/RenderMain.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import com.lambda.graphics.gl.GlStateUtils.setupGL
77
import com.lambda.graphics.gl.Matrices
88
import com.lambda.graphics.gl.Matrices.resetMatrix
99
import com.lambda.graphics.gl.Matrices.translate
10-
import com.lambda.module.modules.client.HUD
10+
import com.lambda.module.modules.client.GuiSettings
1111
import org.joml.Matrix4f
1212

1313
object RenderMain {
@@ -20,8 +20,8 @@ object RenderMain {
2020
translate(0.0, 0.0, -3000.0)
2121

2222
setupGL {
23-
rescale(HUD.scale)
24-
RenderEvent.GUI.Scaled(HUD.scale).post()
23+
rescale(GuiSettings.scale)
24+
RenderEvent.GUI.Scaled(GuiSettings.scale).post()
2525

2626
rescale(1.0)
2727
RenderEvent.GUI.Fixed().post()

common/src/main/kotlin/com/lambda/graphics/gl/Scissor.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package com.lambda.graphics.gl
22

33
import com.lambda.Lambda.mc
4-
import com.lambda.module.modules.client.HUD
4+
import com.lambda.module.modules.client.GuiSettings
55
import com.lambda.util.math.MathUtils.ceilToInt
66
import com.lambda.util.math.MathUtils.floorToInt
77
import com.lambda.util.math.Rect
@@ -35,8 +35,8 @@ object Scissor {
3535

3636
stack.add(entry)
3737

38-
val pos1 = entry.leftTop * HUD.scale
39-
val pos2 = entry.rightBottom * HUD.scale
38+
val pos1 = entry.leftTop * GuiSettings.scale
39+
val pos2 = entry.rightBottom * GuiSettings.scale
4040

4141
val width = max(pos2.x - pos1.x, 0.0)
4242
val height = max(pos2.y - pos1.y, 0.0)

common/src/main/kotlin/com/lambda/graphics/renderer/gui/rect/RectRenderer.kt

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,28 +3,35 @@ package com.lambda.graphics.renderer.gui.rect
33
import com.lambda.graphics.buffer.vao.vertex.VertexAttrib
44
import com.lambda.graphics.renderer.gui.AbstractGuiRenderer
55
import com.lambda.graphics.shader.Shader
6-
import com.lambda.module.modules.client.ClickGui
6+
import com.lambda.module.modules.client.GuiSettings
77
import com.lambda.util.math.Vec2d
8+
import com.mojang.blaze3d.systems.RenderSystem.blendFunc
9+
import com.mojang.blaze3d.systems.RenderSystem.defaultBlendFunc
810
import org.lwjgl.glfw.GLFW.glfwGetTime
11+
import org.lwjgl.opengl.GL11.GL_ONE
12+
import org.lwjgl.opengl.GL11.GL_SRC_ALPHA
913

1014
class RectRenderer : AbstractGuiRenderer<IRectEntry>(
1115
VertexAttrib.Group.RECT
1216
) {
1317
var shadeColor = false
18+
var fancyBlending = false
1419

1520
override fun render() {
1621
shader.use()
1722

1823
shader["u_Shade"] = shadeColor
1924

2025
if (shadeColor) {
21-
shader["u_Time"] = glfwGetTime() * ClickGui.colorSpeed * 3.0
22-
shader["u_Color1"] = ClickGui.shadeColor1
23-
shader["u_Color2"] = ClickGui.shadeColor2
24-
shader["u_Size"] = Vec2d.ONE / Vec2d(ClickGui.colorWidth, ClickGui.colorHeight)
26+
shader["u_Time"] = glfwGetTime() * GuiSettings.colorSpeed * 5.0
27+
shader["u_Color1"] = GuiSettings.shadeColor1
28+
shader["u_Color2"] = GuiSettings.shadeColor2
29+
shader["u_Size"] = Vec2d.ONE / Vec2d(GuiSettings.colorWidth, GuiSettings.colorHeight)
2530
}
2631

32+
if (fancyBlending) blendFunc(GL_SRC_ALPHA, GL_ONE)
2733
super.render()
34+
defaultBlendFunc()
2835
}
2936

3037
override fun build(block: IRectEntry.() -> Unit): IRectEntry {

common/src/main/kotlin/com/lambda/gui/api/component/WindowComponent.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import com.lambda.gui.api.component.core.list.IListComponent
99
import com.lambda.gui.api.component.core.list.ChildComponent
1010
import com.lambda.gui.api.layer.RenderLayer
1111
import com.lambda.module.modules.client.ClickGui
12+
import com.lambda.module.modules.client.GuiSettings
1213
import com.lambda.util.KeyCode
1314
import com.lambda.util.Mouse
1415
import com.lambda.util.math.MathUtils.toInt
@@ -47,7 +48,7 @@ abstract class WindowComponent <T : ChildComponent> : InteractiveComponent(), IL
4748
layer.rect.build {
4849
position = rect
4950
roundRadius = ClickGui.windowRadius
50-
color(ClickGui.backgroundColor)
51+
color(GuiSettings.backgroundColor)
5152
}
5253

5354
// Title

common/src/main/kotlin/com/lambda/gui/api/component/sub/ButtonComponent.kt

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import com.lambda.graphics.animation.AnimationTicker
55
import com.lambda.gui.api.component.WindowComponent
66
import com.lambda.gui.api.component.core.list.ChildComponent
77
import com.lambda.module.modules.client.ClickGui
8+
import com.lambda.module.modules.client.GuiSettings
89
import com.lambda.util.Mouse
910
import com.lambda.util.math.ColorUtils.multAlpha
1011
import com.lambda.util.math.MathUtils.lerp
@@ -40,7 +41,7 @@ abstract class ButtonComponent(final override val owner: WindowComponent<*>) : C
4041
// Active color
4142
layer.rect.build {
4243
position = rect.shrink(interactAnimation)
43-
color(ClickGui.mainColor.multAlpha(activeAnimation * 0.2))
44+
color(GuiSettings.mainColor.multAlpha(activeAnimation * 0.2))
4445
}
4546

4647
// Hover glint
@@ -49,7 +50,7 @@ abstract class ButtonComponent(final override val owner: WindowComponent<*>) : C
4950
position = hoverRect.shrink(interactAnimation)
5051

5152
val alpha = interactAnimation * 0.3
52-
color(ClickGui.mainColor.multAlpha(alpha))
53+
color(GuiSettings.mainColor.multAlpha(alpha))
5354
}
5455

5556
// Toggle fx
@@ -63,7 +64,7 @@ abstract class ButtonComponent(final override val owner: WindowComponent<*>) : C
6364

6465
// 0.0 .. 1.0 .. 0.0 animation
6566
val alpha = 1.0 - (abs(activeAnimation - 0.5) * 2.0)
66-
val color = ClickGui.mainColor.multAlpha(alpha * 0.8)
67+
val color = GuiSettings.mainColor.multAlpha(alpha * 0.8)
6768

6869
// "Tail" effect
6970
val leftColor = color.multAlpha(1.0 - active.toInt())
@@ -77,7 +78,7 @@ abstract class ButtonComponent(final override val owner: WindowComponent<*>) : C
7778
text = this@ButtonComponent.text
7879
scale = 1.0 - pressAnimation * 0.08
7980

80-
color = lerp(Color.WHITE, ClickGui.mainColor, activeAnimation)
81+
color = lerp(Color.WHITE, GuiSettings.mainColor, activeAnimation)
8182

8283
val x = rect.left + ClickGui.windowPadding + interactAnimation + hoverAnimation
8384
position = Vec2d(x, rect.center.y)

common/src/main/kotlin/com/lambda/gui/api/layer/RenderLayer.kt

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,7 @@ package com.lambda.gui.api.layer
22

33
import com.lambda.graphics.renderer.gui.font.FontRenderer
44
import com.lambda.graphics.renderer.gui.rect.RectRenderer
5-
import com.lambda.module.modules.client.ClickGui
6-
import com.mojang.blaze3d.systems.RenderSystem.blendFunc
7-
import com.mojang.blaze3d.systems.RenderSystem.defaultBlendFunc
8-
import org.lwjgl.opengl.GL11.GL_ONE
9-
import org.lwjgl.opengl.GL11.GL_SRC_ALPHA
5+
import com.lambda.module.modules.client.GuiSettings
106

117
class RenderLayer(private val allowEffects: Boolean = false) {
128
private val rectRenderer = RectRenderer()
@@ -18,8 +14,11 @@ class RenderLayer(private val allowEffects: Boolean = false) {
1814
rect.update()
1915
font.update()
2016

21-
rectRenderer.shadeColor = ClickGui.shade
22-
applyFancyBlending(rect::render)
17+
rectRenderer.apply {
18+
shadeColor = GuiSettings.shade && allowEffects
19+
fancyBlending = GuiSettings.glow && allowEffects
20+
render()
21+
}
2322

2423
font.render()
2524
}
@@ -28,12 +27,4 @@ class RenderLayer(private val allowEffects: Boolean = false) {
2827
rect.destroy()
2928
font.destroy()
3029
}
31-
32-
private fun applyFancyBlending(block: () -> Unit) {
33-
if (ClickGui.glow && allowEffects) {
34-
blendFunc(GL_SRC_ALPHA, GL_ONE)
35-
block()
36-
defaultBlendFunc()
37-
} else block()
38-
}
3930
}

common/src/main/kotlin/com/lambda/module/modules/client/ClickGui.kt

Lines changed: 4 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -13,33 +13,11 @@ object ClickGui : Module(
1313
description = "Sexy",
1414
defaultTags = setOf(ModuleTag.CLIENT)
1515
) {
16-
private val page by setting("Page", Page.Colors)
17-
1816
// General
19-
val windowRadius by setting("Window Radius", 2.0, 0.0..10.0, 0.1, visibility = { page == Page.General })
20-
val windowPadding by setting("Window Padding", 2.0, 0.0..10.0, 0.1, visibility = { page == Page.General })
21-
val buttonHeight by setting("Button Height", 11.0, 8.0..20.0, 0.1, visibility = { page == Page.General })
22-
val buttonStep by setting("Button Step", 1.0, 0.0..5.0, 0.1, visibility = { page == Page.General })
23-
24-
// Colors
25-
private val primaryColor by setting("Primary Color", Color(130, 200, 255), visibility = { page == Page.Colors })
26-
private val secondaryColor by setting("Secondary Color", Color(225, 130, 225), visibility = { page == Page.Colors && shade })
27-
val backgroundColor by setting("Background Color", Color(0, 0, 0, 80), visibility = { page == Page.Colors })
28-
val glow by setting("Glow", true, visibility = { page == Page.Colors })
29-
val shade by setting("Shade Color", true, visibility = { page == Page.Colors })
30-
val colorWidth by setting("Color Width", 40.0, 1.0..100.0, 1.0, visibility = { page == Page.Colors && shade })
31-
val colorHeight by setting("Color Height", 40.0, 1.0..100.0, 1.0, visibility = { page == Page.Colors && shade })
32-
val colorSpeed by setting("Color Speed", 1.0, 0.1..10.0, 0.1, visibility = { page == Page.Colors && shade })
33-
34-
val mainColor: Color get() = if (shade) Color.WHITE else primaryColor
35-
36-
val shadeColor1 get() = primaryColor
37-
val shadeColor2 get() = secondaryColor
38-
39-
enum class Page {
40-
General,
41-
Colors
42-
}
17+
val windowRadius by setting("Window Radius", 2.0, 0.0..10.0, 0.1)
18+
val windowPadding by setting("Window Padding", 2.0, 0.0..10.0, 0.1)
19+
val buttonHeight by setting("Button Height", 11.0, 8.0..20.0, 0.1)
20+
val buttonStep by setting("Button Step", 1.0, 0.0..5.0, 0.1)
4321

4422
private val gui by mainThread {
4523
LambdaClickGui()
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
package com.lambda.module.modules.client
2+
3+
import com.lambda.module.Module
4+
import com.lambda.module.tag.ModuleTag
5+
import java.awt.Color
6+
7+
object GuiSettings : Module(
8+
name = "HUD",
9+
description = "Visual behaviour configuration",
10+
defaultTags = setOf(ModuleTag.CLIENT)
11+
) {
12+
private val page by setting("Page", Page.General)
13+
14+
private val scaleSetting by setting("Scale", 1.0, 0.5..3.0, 0.01, visibility = { page == Page.General })
15+
16+
private val primaryColor by setting("Primary Color", Color(130, 200, 255), visibility = { page == Page.Colors })
17+
private val secondaryColor by setting("Secondary Color", Color(225, 130, 225), visibility = { page == Page.Colors && shade })
18+
val backgroundColor by setting("Background Color", Color(0, 0, 0, 80), visibility = { page == Page.Colors })
19+
val glow by setting("Glow", true, visibility = { page == Page.Colors })
20+
val shade by setting("Shade Color", true, visibility = { page == Page.Colors })
21+
val colorWidth by setting("Color Width", 40.0, 1.0..100.0, 1.0, visibility = { page == Page.Colors && shade })
22+
val colorHeight by setting("Color Height", 40.0, 1.0..100.0, 1.0, visibility = { page == Page.Colors && shade })
23+
val colorSpeed by setting("Color Speed", 1.0, 0.1..10.0, 0.1, visibility = { page == Page.Colors && shade })
24+
25+
val mainColor: Color get() = if (shade) Color.WHITE else primaryColor
26+
27+
val shadeColor1 get() = primaryColor
28+
val shadeColor2 get() = secondaryColor
29+
30+
31+
enum class Page {
32+
General,
33+
Colors
34+
}
35+
36+
val scale get() = scaleSetting * 2
37+
}

common/src/main/kotlin/com/lambda/module/modules/client/HUD.kt

Lines changed: 0 additions & 12 deletions
This file was deleted.

common/src/main/kotlin/com/lambda/util/text/TextDsl.kt

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,6 @@
1616

1717
package com.lambda.util.text
1818

19-
import com.lambda.module.modules.client.HUD
20-
import com.lambda.util.math.hsb
21-
import com.lambda.util.math.readHSB
2219
import net.minecraft.text.*
2320
import net.minecraft.util.Identifier
2421
import java.awt.Color

0 commit comments

Comments
 (0)