Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
4ecda8b
Rendering Base
bladekt Mar 19, 2024
25907a3
Rect Renderer
bladekt Mar 19, 2024
b081b6c
Rect Renderer refactor
bladekt Mar 20, 2024
7ef4768
Merge branch 'master' into feature/renderer
bladekt Mar 20, 2024
967fdaf
Fixed merge conflicts
bladekt Mar 20, 2024
2436692
Font Renderer
bladekt Mar 23, 2024
8799dfb
Merge branch 'master' into feature/renderer
Avanatiker Mar 24, 2024
eded96a
Load more utf16 characters
emyfops Mar 25, 2024
0d5f46b
Useless null check
emyfops Mar 25, 2024
8d837d1
Merge branch 'master' into feature/renderer
Avanatiker Mar 25, 2024
e19065a
Resolve conflicts
Avanatiker Mar 25, 2024
8e8692a
Even more conflicts
Avanatiker Mar 25, 2024
7b0a315
Feature: Glyphs setting
emyfops Mar 25, 2024
ddfd3f0
Hot Font Renderer fix
bladekt Mar 27, 2024
4a45539
TestMe
bladekt Mar 30, 2024
3777597
Cleanup
bladekt Mar 30, 2024
766054f
Gui Basics
bladekt Mar 31, 2024
6116e2c
Use safe context
emyfops Mar 31, 2024
f383f95
one liner
emyfops Mar 31, 2024
728676f
Reverted safe context
emyfops Mar 31, 2024
d209c78
Adapted baseline offset
bladekt Apr 1, 2024
be335d5
Destroyable Renderers
bladekt Apr 1, 2024
5ca76a7
Load glyphs on startup
bladekt Apr 1, 2024
a574797
Shader transparency fix
bladekt Apr 6, 2024
b268015
Exp animation clamp
bladekt Apr 7, 2024
e768dce
Rect impl, Scissor utils, refactor
bladekt Apr 7, 2024
86c9386
Windows, Buttons and tests
bladekt Apr 7, 2024
6e2f721
Saving the config should be the last one
bladekt Apr 7, 2024
78789f6
AbstractGui rework, refactor
bladekt Apr 7, 2024
a936f9c
Setting visibility
bladekt Apr 7, 2024
fc59c12
Better animations and code structure
bladekt Apr 8, 2024
6d5d3bc
Merge remote-tracking branch 'origin/master' into feature/renderer
Avanatiker Apr 9, 2024
14fbebc
Allow using Keybinds in GUI screen
Avanatiker Apr 9, 2024
08545d7
Let various elements access their parents
bladekt Apr 9, 2024
c7464f3
Revert "Let various elements access their parents"
bladekt Apr 9, 2024
9efcebc
Color waving
bladekt Apr 9, 2024
1585326
Cleanup(merged settings, rect renderging features)
bladekt Apr 10, 2024
6dd4889
hot
bladekt Apr 10, 2024
391e9e5
1 more mistake
bladekt Apr 10, 2024
0b72461
Persistent GUI configuration
Avanatiker Apr 10, 2024
47ade72
Fix double storing in lambda.json
Avanatiker Apr 10, 2024
efb69ce
Revert mutable list setting
Avanatiker Apr 10, 2024
1bb782e
Forgor
Avanatiker Apr 10, 2024
b96c0b9
Test object loading
Avanatiker Apr 10, 2024
ee4e415
Tighter type constraint
Avanatiker Apr 10, 2024
db2070f
Fix type erasure for all collection settings
Avanatiker Apr 11, 2024
5f5c2db
Initialization obscurity
Avanatiker Apr 11, 2024
7b97530
Setting Refactor
bladekt Apr 11, 2024
06acbfe
revert: Multiple tag support
bladekt Apr 11, 2024
3559754
Better animations, refactor
bladekt Apr 11, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
package com.lambda.mixin.render;

import com.lambda.graphics.gl.GlStateUtils;
import com.mojang.blaze3d.platform.GlStateManager;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;

import static org.lwjgl.opengl.GL11.*;
import static org.lwjgl.opengl.GL11.GL_CULL_FACE;

@Mixin(GlStateManager.class)
public class GlStateManagerMixin {
@Inject(method = "_enableDepthTest", at = @At("TAIL"), remap = false)
private static void depthTestEnable(CallbackInfo ci) {
GlStateUtils.capSet(GL_DEPTH_TEST, true);
}

@Inject(method = "_disableDepthTest", at = @At("TAIL"), remap = false)
private static void depthTestDisable(CallbackInfo ci) {
GlStateUtils.capSet(GL_DEPTH_TEST, false);
}

@Inject(method = "_depthMask", at = @At("TAIL"), remap = false)
private static void depthMask(boolean mask, CallbackInfo ci) {
GlStateUtils.capSet(GL_DEPTH, mask);
}

@Inject(method = "_enableBlend", at = @At("TAIL"), remap = false)
private static void blendEnable(CallbackInfo ci) {
GlStateUtils.capSet(GL_BLEND, true);
}

@Inject(method = "_disableBlend", at = @At("TAIL"), remap = false)
private static void blendDisable(CallbackInfo ci) {
GlStateUtils.capSet(GL_BLEND, false);
}

@Inject(method = "_enableCull", at = @At("TAIL"), remap = false)
private static void cullEnable(CallbackInfo ci) {
GlStateUtils.capSet(GL_CULL_FACE, true);
}

@Inject(method = "_disableCull", at = @At("TAIL"), remap = false)
private static void cullDisable(CallbackInfo ci) {
GlStateUtils.capSet(GL_CULL_FACE, false);
}
}
17 changes: 17 additions & 0 deletions common/src/main/java/com/lambda/mixin/render/InGameHudMixin.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package com.lambda.mixin.render;

import com.lambda.graphics.RenderMain;
import net.minecraft.client.gui.DrawContext;
import net.minecraft.client.gui.hud.InGameHud;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;

@Mixin(InGameHud.class)
public class InGameHudMixin {
@Inject(method = "render", at = @At("TAIL"))
private void onRender(DrawContext context, float tickDelta, CallbackInfo ci) {
RenderMain.render2D();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package com.lambda.mixin.render;

import com.lambda.graphics.gl.VaoUtils;
import com.mojang.blaze3d.systems.RenderSystem;
import net.minecraft.client.gl.VertexBuffer;
import net.minecraft.client.render.BufferBuilder;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;

import java.nio.ByteBuffer;

@Mixin(VertexBuffer.class)
public class VertexBufferMixin {
@Shadow
private int indexBufferId;

@Inject(method = "uploadIndexBuffer", at = @At("RETURN"))
private void onConfigureIndexBuffer(BufferBuilder.DrawParameters parameters, ByteBuffer vertexBuffer, CallbackInfoReturnable<RenderSystem.ShapeIndexBuffer> cir) {
RenderSystem.ShapeIndexBuffer value = cir.getReturnValue();
VaoUtils.lastIbo = value == null ? this.indexBufferId : value.id;
}
}
4 changes: 4 additions & 0 deletions common/src/main/kotlin/com/lambda/Lambda.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@ package com.lambda
import com.google.gson.Gson
import com.google.gson.GsonBuilder
import com.lambda.config.serializer.*
import com.lambda.config.serializer.gui.ModuleTagSerializer
import com.lambda.config.serializer.gui.TagWindowSerializer
import com.lambda.core.Loader
import com.lambda.gui.impl.clickgui.windows.TagWindow
import com.lambda.module.tag.ModuleTag
import com.lambda.util.KeyCode
import net.minecraft.block.Block
Expand All @@ -24,6 +27,7 @@ object Lambda {
val gson: Gson = GsonBuilder()
.setPrettyPrinting()
.registerTypeAdapter(ModuleTag::class.java, ModuleTagSerializer)
.registerTypeAdapter(TagWindow::class.java, TagWindowSerializer)
.registerTypeAdapter(KeyCode::class.java, KeyCodeSerializer)
.registerTypeAdapter(Color::class.java, ColorSerializer)
.registerTypeAdapter(BlockPos::class.java, BlockPosSerializer)
Expand Down
3 changes: 2 additions & 1 deletion common/src/main/kotlin/com/lambda/command/CommandManager.kt
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import org.reflections.Reflections
import org.reflections.scanners.Scanners
import org.reflections.util.ClasspathHelper
import org.reflections.util.ConfigurationBuilder
import java.awt.Color
import kotlin.math.max
import kotlin.math.min

Expand Down Expand Up @@ -95,7 +96,7 @@ object CommandManager : Configurable(LambdaConfig), Loadable {
val position = min(syntax.input.length, syntax.cursor)
player.sendMessage(buildText {
clickEvent(suggestCommand("$prefix${reader.string}")) {
color(Color.GREY) {
color(Color.GRAY) {
if (position > ERROR_PADDING) {
literal("...")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import com.lambda.util.Communication.warn
import com.lambda.util.StringUtils
import com.lambda.util.text.*
import com.lambda.util.text.ClickEvents.suggestCommand
import java.awt.Color

object ModuleCommand : LambdaCommand {
override val name = "module"
Expand All @@ -36,7 +37,7 @@ object ModuleCommand : LambdaCommand {
}

this@ModuleCommand.info(buildText {
styled(Color.GREY) {
styled(Color.GRAY) {
literal("Enabled Modules: ")
}
enabled.forEachIndexed { index, module ->
Expand Down Expand Up @@ -70,7 +71,7 @@ object ModuleCommand : LambdaCommand {
} ?: return@executeWithResult failure(buildText {
styled(Color.RED) {
literal("Module ")
styled(Color.GREY) {
styled(Color.GRAY) {
literal("$name ")
}
literal("not found!")
Expand All @@ -88,7 +89,7 @@ object ModuleCommand : LambdaCommand {
literal(", ")
}
clickEvent(suggestCommand("$prefix${input.replace(name, s)}")) {
styled(Color.GREY) {
styled(Color.GRAY) {
literal(s)
}
}
Expand All @@ -102,7 +103,7 @@ object ModuleCommand : LambdaCommand {
} else {
if (enable().value() == module.isEnabled) {
this@ModuleCommand.warn(buildText {
styled(Color.GREY) {
styled(Color.GRAY) {
literal("$name already ")
literal(if (module.isEnabled) "enabled" else "disabled")
}
Expand All @@ -117,7 +118,7 @@ object ModuleCommand : LambdaCommand {
}
}
this@ModuleCommand.info(buildText {
styled(Color.GREY) {
styled(Color.GRAY) {
literal("$name ")
}
styled(if (module.isEnabled) Color.GREEN else Color.RED) {
Expand Down
8 changes: 5 additions & 3 deletions common/src/main/kotlin/com/lambda/config/Configurable.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package com.lambda.config

import com.google.gson.JsonElement
import com.google.gson.JsonObject
import com.google.gson.reflect.TypeToken
import com.lambda.Lambda
import com.lambda.Lambda.LOG
import com.lambda.config.settings.CharSetting
Expand All @@ -21,6 +22,7 @@ import com.lambda.util.Nameable
import net.minecraft.block.Block
import net.minecraft.util.math.BlockPos
import java.awt.Color
import java.lang.reflect.Type

/**
* Represents a set of [AbstractSetting]s that are associated with the [name] of the [Configurable].
Expand Down Expand Up @@ -165,7 +167,7 @@ abstract class Configurable(configuration: Configuration) : Jsonable, Nameable {
defaultValue: List<T>,
description: String = "",
noinline visibility: () -> Boolean = { true },
) = ListSetting(name, defaultValue, description, visibility).also {
) = ListSetting(name, defaultValue, object : TypeToken<List<T>>() {}.type, description, visibility).also {
settings.add(it)
}

Expand All @@ -191,7 +193,7 @@ abstract class Configurable(configuration: Configuration) : Jsonable, Nameable {
defaultValue: Map<K, V>,
description: String = "",
noinline visibility: () -> Boolean = { true },
) = MapSetting(name, defaultValue, description, visibility).also {
) = MapSetting(name, defaultValue, object : TypeToken<Map<K, V>>() {}.type, description, visibility).also {
settings.add(it)
}

Expand All @@ -217,7 +219,7 @@ abstract class Configurable(configuration: Configuration) : Jsonable, Nameable {
defaultValue: Set<T>,
description: String = "",
noinline visibility: () -> Boolean = { true },
) = SetSetting(name, defaultValue, description, visibility).also {
) = SetSetting(name, defaultValue, object : TypeToken<Set<T>>() {}.type, description, visibility).also {
settings.add(it)
}

Expand Down
4 changes: 2 additions & 2 deletions common/src/main/kotlin/com/lambda/config/Configuration.kt
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ abstract class Configuration : Jsonable {
init {
unsafeListener<ClientEvent.Startup> { tryLoad() }

unsafeListener<ClientEvent.Shutdown> { trySave() }
unsafeListener<ClientEvent.Shutdown>(Int.MIN_VALUE) { trySave() }

configurations.add(this)
}
Expand Down Expand Up @@ -90,7 +90,7 @@ abstract class Configuration : Jsonable {
}
.onFailure {
val message = "Failed to load ${configName.capitalize()} config, loading backup"
LOG.error(message)
LOG.error(message, it)
this@Configuration.logError(message)
runCatching { load(backup) }
.onSuccess {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package com.lambda.config.configurations

import com.lambda.config.Configuration
import com.lambda.util.FolderRegister

object GuiConfig : Configuration() {
override val configName = "gui"
override val primary = FolderRegister.config.resolve("$configName.json")
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.lambda.config.serializer
package com.lambda.config.serializer.gui

import com.google.gson.*
import com.lambda.module.tag.ModuleTag
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
package com.lambda.config.serializer.gui

import com.google.gson.*
import com.lambda.gui.impl.clickgui.windows.TagWindow
import com.lambda.module.tag.ModuleTag
import com.lambda.util.math.Vec2d
import java.lang.reflect.Type

object TagWindowSerializer : JsonSerializer<TagWindow>, JsonDeserializer<TagWindow> {
override fun serialize(
src: TagWindow?,
typeOfSrc: Type?,
context: JsonSerializationContext?,
): JsonElement = src?.let {
JsonObject().apply {
addProperty("title", it.title)
add("tags", JsonArray().apply {
it.tags.forEach { tag ->
add(tag.name)
}
})
addProperty("width", it.width)
addProperty("height", it.height)
addProperty("isOpen", it.isOpen)
add("position", JsonArray().apply {
add(it.position.x)
add(it.position.y)
})
}
} ?: JsonNull.INSTANCE

override fun deserialize(
json: JsonElement?,
typeOfT: Type?,
context: JsonDeserializationContext?,
) = json?.asJsonObject?.let {
TagWindow(
tags = it["tags"].asJsonArray.map { tag ->
ModuleTag(tag.asString)
}.toSet(),
title = it["title"].asString,
width = it["width"].asDouble,
height = it["height"].asDouble
).apply {
isOpen = it["isOpen"].asBoolean
position = Vec2d(
it["position"].asJsonArray[0].asDouble,
it["position"].asJsonArray[1].asDouble
)
}
} ?: throw JsonParseException("Invalid window data")
}
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
package com.lambda.config.settings.collections

import com.google.gson.JsonElement
import com.google.gson.reflect.TypeToken
import com.lambda.Lambda.gson
import com.lambda.config.AbstractSetting
import java.lang.reflect.Type

class ListSetting<T>(
class ListSetting<T : Any>(
override val name: String,
defaultValue: List<T>,
private val type: Type,
description: String,
visibility: () -> Boolean,
) : AbstractSetting<List<T>>(
Expand All @@ -16,7 +17,6 @@ class ListSetting<T>(
visibility
) {
override fun loadFromJson(serialized: JsonElement) {
val listType = object : TypeToken<List<T>>() {}.type
value = gson.fromJson(serialized, listType)
value = gson.fromJson(serialized, type)
}
}
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
package com.lambda.config.settings.collections

import com.google.common.reflect.TypeToken
import com.google.gson.JsonElement
import com.lambda.Lambda.gson
import com.lambda.config.AbstractSetting
import java.lang.reflect.Type

class MapSetting<K, V>(
override val name: String,
defaultValue: Map<K, V>,
private val type: Type,
description: String,
visibility: () -> Boolean,
) : AbstractSetting<Map<K, V>>(
Expand All @@ -16,7 +17,6 @@ class MapSetting<K, V>(
visibility
) {
override fun loadFromJson(serialized: JsonElement) {
val mapType = object : TypeToken<Map<K, V>>() {}.type
value = gson.fromJson(serialized, mapType)
value = gson.fromJson(serialized, type)
}
}
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
package com.lambda.config.settings.collections

import com.google.gson.JsonElement
import com.google.gson.reflect.TypeToken
import com.lambda.Lambda.gson
import com.lambda.config.AbstractSetting
import java.lang.reflect.Type

class SetSetting<T : Any>(
override val name: String,
defaultValue: Set<T>,
private val type: Type,
description: String,
visibility: () -> Boolean,
) : AbstractSetting<Set<T>>(
Expand All @@ -16,7 +17,6 @@ class SetSetting<T : Any>(
visibility
) {
override fun loadFromJson(serialized: JsonElement) {
val setType = object : TypeToken<Set<T>>() {}.type
value = gson.fromJson(serialized, setType)
value = gson.fromJson(serialized, type)
}
}
Loading