Skip to content

Commit 1a1b0c7

Browse files
AvanatikerBlade-ktemyfops
authored
Refactored UI and Improved Rendering Capabilities (#112)
### Description This pull request includes significant updates and refinements to the UI system and rendering pipeline. Key highlights are: - Refactored UI components for modularity and flexibility. - Added `SDF Rect renderer` and enhancements like `Preview color outline`. - Addressed rendering issues such as `Fixed ESP rendering` and improvements for emojis like `Aligned emojis vertically` and `Fixed sdf for emojis`. - Introduced `Buffer API modifications`, persistent buffers for `VertexPipeline`, and better management of PBO and mipmap handling. - Improved usability with independent UI settings, keybind pickers, and pop-up windows. - Miscellaneous optimizations for layout positioning, float setting accuracy, and texture handling. These updates aim to enhance UI responsiveness, rendering performance, and overall user experience while resolving previous rendering and UI bugs. --------- Co-authored-by: blade.kt <kurtasanoff@gmail.com> Co-authored-by: Edouard127 <46357922+Edouard127@users.noreply.github.com>
1 parent 8605116 commit 1a1b0c7

File tree

123 files changed

+3617
-2208
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

123 files changed

+3617
-2208
lines changed

common/src/main/java/com/lambda/mixin/render/ChatInputSuggestorMixin.java

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
import org.spongepowered.asm.mixin.injection.Redirect;
4141
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
4242

43+
import java.util.Map;
4344
import java.util.concurrent.CompletableFuture;
4445
import java.util.regex.Matcher;
4546
import java.util.regex.Pattern;
@@ -87,10 +88,22 @@ private void refreshEmojiSuggestion(CallbackInfo ci) {
8788
int start = neoLambda$getLastColon(textToCursor);
8889
if (start == -1) return;
8990

90-
String emojiString = typing.substring(start + 1);
91+
Matcher emojiMatcher = EMOJI_PATTERN.matcher(textToCursor);
92+
Map<String, ?> emojiKeys = LambdaAtlas.INSTANCE.getKeys(RenderSettings.INSTANCE.getEmojiFont());
93+
while (emojiMatcher.find()) {
94+
int openingColon = emojiMatcher.start(1);
95+
String key = emojiMatcher.group(2);
96+
int closingColon = emojiMatcher.end(3);
97+
98+
if (emojiKeys.containsKey(key) && start >= openingColon && start < closingColon) {
99+
// If the colon is part of a previous valid emoji, return
100+
return;
101+
}
102+
}
103+
104+
String emojiString = textToCursor.substring(start + 1);
91105

92-
Stream<String> results = LambdaAtlas.INSTANCE.getKeys(RenderSettings.INSTANCE.getEmojiFont())
93-
.keySet().stream()
106+
Stream<String> results = emojiKeys.keySet().stream()
94107
.filter(s -> s.startsWith(emojiString))
95108
.map(s -> s + ":");
96109

@@ -105,6 +118,9 @@ private void refreshEmojiSuggestion(CallbackInfo ci) {
105118
@Unique
106119
private static final Pattern COLON_PATTERN = Pattern.compile("(:[a-zA-Z0-9_]+)");
107120

121+
@Unique
122+
private static final Pattern EMOJI_PATTERN = Pattern.compile("(:)([a-zA-Z0-9_]+)(:)");
123+
108124
@Unique
109125
private int neoLambda$getLastColon(String input) {
110126
if (Strings.isNullOrEmpty(input)) return -1;

common/src/main/java/com/lambda/mixin/render/VertexBufferMixin.java

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

1818
package com.lambda.mixin.render;
1919

20-
import com.lambda.graphics.buffer.vertex.ElementBuffer;
20+
import com.lambda.graphics.buffer.Buffer;
2121
import com.mojang.blaze3d.systems.RenderSystem;
2222
import net.minecraft.client.gl.VertexBuffer;
2323
import net.minecraft.client.render.BufferBuilder;
@@ -37,6 +37,6 @@ public class VertexBufferMixin {
3737
@Inject(method = "uploadIndexBuffer", at = @At("RETURN"))
3838
private void onConfigureIndexBuffer(BufferBuilder.DrawParameters parameters, ByteBuffer vertexBuffer, CallbackInfoReturnable<RenderSystem.ShapeIndexBuffer> cir) {
3939
RenderSystem.ShapeIndexBuffer value = cir.getReturnValue();
40-
ElementBuffer.lastIbo = value == null ? this.indexBufferId : value.id;
40+
Buffer.lastIbo = value == null ? this.indexBufferId : value.id;
4141
}
4242
}

common/src/main/kotlin/com/lambda/config/Configurable.kt

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ import com.lambda.util.KeyCode
3737
import com.lambda.util.Nameable
3838
import net.minecraft.block.Block
3939
import net.minecraft.util.math.BlockPos
40+
import net.minecraft.util.math.Vec3d
4041
import java.awt.Color
4142

4243
/**
@@ -387,6 +388,40 @@ abstract class Configurable(
387388
visibility: () -> Boolean = { true },
388389
) = ColorSetting(name, defaultValue, description, visibility).register()
389390

391+
/**
392+
* Creates a [Vec3dSetting] with the provided parameters and adds it to the [settings].
393+
*
394+
* @param name The unique identifier for the setting.
395+
* @param defaultValue The default [Vec3d] value of the setting.
396+
* @param description A brief explanation of the setting's purpose and behavior.
397+
* @param visibility A lambda expression that determines the visibility status of the setting.
398+
*
399+
* @return The created [Vec3dSetting].
400+
*/
401+
fun setting(
402+
name: String,
403+
defaultValue: Vec3d,
404+
description: String = "",
405+
visibility: () -> Boolean = { true },
406+
) = Vec3dSetting(name, defaultValue, description, visibility).register()
407+
408+
/**
409+
* Creates a [BlockPosSetting] with the provided parameters and adds it to the [settings].
410+
*
411+
* @param name The unique identifier for the setting.
412+
* @param defaultValue The default [BlockPos.Mutable] value of the setting.
413+
* @param description A brief explanation of the setting's purpose and behavior.
414+
* @param visibility A lambda expression that determines the visibility status of the setting.
415+
*
416+
* @return The created [BlockPosSetting].
417+
*/
418+
fun setting(
419+
name: String,
420+
defaultValue: BlockPos.Mutable,
421+
description: String = "",
422+
visibility: () -> Boolean = { true },
423+
) = BlockPosSetting(name, defaultValue, description, visibility).register()
424+
390425
/**
391426
* Creates a [BlockPosSetting] with the provided parameters and adds it to the [settings].
392427
*

common/src/main/kotlin/com/lambda/config/settings/comparable/EnumSetting.kt

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,24 +43,27 @@ class EnumSetting<T : Enum<T>>(
4343
description,
4444
visibility,
4545
) {
46-
val enumValues: Array<T> = defaultValue.declaringJavaClass.enumConstants
47-
4846
fun next() {
49-
value = enumValues[((value.ordinal + 1) % enumValues.size)]
47+
value = value.enumValues[((value.ordinal + 1) % value.enumValues.size)]
5048
}
5149

5250
override fun CommandBuilder.buildCommand(registry: CommandRegistryAccess) {
5351
required(word(name)) { parameter ->
5452
suggests { _, builder ->
55-
enumValues.forEach { builder.suggest(it.name.capitalize()) }
53+
value.enumValues.forEach { builder.suggest(it.name.capitalize()) }
5654
builder.buildFuture()
5755
}
5856
executeWithResult {
59-
val newValue = enumValues.find { it.name.equals(parameter().value(), true) }
57+
val newValue = value.enumValues.find { it.name.equals(parameter().value(), true) }
6058
?: return@executeWithResult failure("Invalid value")
6159
trySetValue(newValue)
6260
return@executeWithResult success()
6361
}
6462
}
6563
}
64+
65+
companion object {
66+
val <T : Enum<T>> T.enumValues: Array<T> get() =
67+
declaringJavaClass.enumConstants
68+
}
6669
}
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
/*
2+
* Copyright 2024 Lambda
3+
*
4+
* This program is free software: you can redistribute it and/or modify
5+
* it under the terms of the GNU General Public License as published by
6+
* the Free Software Foundation, either version 3 of the License, or
7+
* (at your option) any later version.
8+
*
9+
* This program is distributed in the hope that it will be useful,
10+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
* GNU General Public License for more details.
13+
*
14+
* You should have received a copy of the GNU General Public License
15+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
16+
*/
17+
18+
package com.lambda.config.settings.complex
19+
20+
import com.google.gson.reflect.TypeToken
21+
import com.lambda.brigadier.argument.double
22+
import com.lambda.brigadier.argument.integer
23+
import com.lambda.brigadier.argument.value
24+
import com.lambda.brigadier.execute
25+
import com.lambda.brigadier.required
26+
import com.lambda.config.AbstractSetting
27+
import com.lambda.util.extension.CommandBuilder
28+
import net.minecraft.command.CommandRegistryAccess
29+
import net.minecraft.util.math.BlockPos
30+
import net.minecraft.util.math.Vec3d
31+
32+
class Vec3dSetting(
33+
override val name: String,
34+
defaultValue: Vec3d,
35+
description: String,
36+
visibility: () -> Boolean,
37+
) : AbstractSetting<Vec3d>(
38+
defaultValue,
39+
TypeToken.get(Vec3d::class.java).type,
40+
description,
41+
visibility
42+
) {
43+
override fun CommandBuilder.buildCommand(registry: CommandRegistryAccess) {
44+
required(double("X", -30000000.0, 30000000.0)) { x ->
45+
required(double("Y", -64.0, 255.0)) { y ->
46+
required(double("Z", -30000000.0, 30000000.0)) { z ->
47+
execute {
48+
trySetValue(Vec3d(x().value(), y().value(), z().value()))
49+
}
50+
}
51+
}
52+
}
53+
}
54+
}

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

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,15 @@ package com.lambda.graphics
2020
import com.lambda.Lambda.mc
2121
import com.lambda.event.EventFlow.post
2222
import com.lambda.event.events.RenderEvent
23+
import com.lambda.event.events.TickEvent
24+
import com.lambda.event.listener.SafeListener.Companion.listen
2325
import com.lambda.graphics.gl.GlStateUtils.setupGL
2426
import com.lambda.graphics.gl.Matrices
2527
import com.lambda.graphics.gl.Matrices.resetMatrices
28+
import com.lambda.graphics.renderer.esp.global.DynamicESP
29+
import com.lambda.graphics.renderer.esp.global.StaticESP
2630
import com.lambda.module.modules.client.GuiSettings
31+
import com.lambda.util.Communication.info
2732
import com.lambda.util.math.Vec2d
2833
import com.mojang.blaze3d.systems.RenderSystem.getProjectionMatrix
2934
import org.joml.Matrix4f
@@ -57,6 +62,20 @@ object RenderMain {
5762

5863
setupGL {
5964
RenderEvent.World().post()
65+
StaticESP.render()
66+
DynamicESP.render()
67+
}
68+
}
69+
70+
init {
71+
listen<TickEvent.Post> {
72+
StaticESP.clear()
73+
RenderEvent.StaticESP().post()
74+
StaticESP.upload()
75+
76+
DynamicESP.clear()
77+
RenderEvent.DynamicESP().post()
78+
DynamicESP.upload()
6079
}
6180
}
6281

0 commit comments

Comments
 (0)