Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
133 commits
Select commit Hold shift + click to select a range
f3757f6
Global toggle sounds
bladekt Aug 8, 2024
65751e3
Tickshift improvements
bladekt Aug 10, 2024
a35ffa0
Merge branch 'master' into feature/renderer
emyfops Aug 20, 2024
81a0c63
various performance tweaks (3x faster load time)
emyfops Aug 21, 2024
ea972be
todo: pixel buffer object
emyfops Aug 22, 2024
c6328ca
pixel n-buffer object
emyfops Aug 22, 2024
7f35a62
handle empty pbos
emyfops Aug 22, 2024
1bba654
test: streaming to pbo
emyfops Aug 23, 2024
06aba2d
added upload record time
emyfops Aug 24, 2024
68b24da
added debug gremedy labels
emyfops Aug 24, 2024
12e2045
better pbo
emyfops Aug 24, 2024
7cbfd14
better handling
emyfops Aug 24, 2024
a130c8c
removed videos
emyfops Aug 24, 2024
bbd705f
added documentation for pbo
emyfops Aug 24, 2024
4b96556
moved the fbo down one level
emyfops Aug 24, 2024
895a069
removed loader phase time measure
emyfops Aug 24, 2024
ca72b9a
Merge branch 'master' into feature/renderer
emyfops Aug 24, 2024
0644c69
Update build.gradle.kts
emyfops Aug 24, 2024
de3bb6e
TickEvent KDocs
Avanatiker Aug 25, 2024
b40b1ae
Smol refac
Avanatiker Aug 25, 2024
dcf244d
Better logging and remove texture settings
Avanatiker Aug 25, 2024
c97a29c
Introduce constants for texture options
Avanatiker Aug 25, 2024
8e9c89c
Layouts, dsl builders
bladekt Sep 14, 2024
1cf9550
Simple window, text fields
bladekt Sep 15, 2024
fc91a2d
Interaction passthrough changes
bladekt Sep 15, 2024
52483d3
UI Alignment
bladekt Sep 22, 2024
7fce97c
Merge branch 'master' into refactor/ui
emyfops Sep 22, 2024
48a180f
Window content layout
bladekt Sep 29, 2024
af6a2c9
Merge remote-tracking branch 'origin/refactor/ui' into refactor/ui
bladekt Sep 29, 2024
e93d9ca
Window resizing
bladekt Sep 29, 2024
82c931e
Cursor system
bladekt Sep 29, 2024
09fcdc6
Window minimization, api changes
bladekt Sep 30, 2024
14caf93
Corrected scissor usage
bladekt Sep 30, 2024
9eba76a
Titlebar changes, shadow under it
bladekt Sep 30, 2024
dbbe522
Windows design
bladekt Oct 1, 2024
b476148
Massive gc troll fix, rect/outline/font layouts, simple module buttons
bladekt Oct 1, 2024
9ba5a7a
Nullsafety on tag sets
Avanatiker Oct 2, 2024
a516060
many misc things
bladekt Oct 7, 2024
50a66c8
null safety
bladekt Oct 7, 2024
83880f4
Merge remote-tracking branch 'origin/refactor/ui' into refactor/ui
bladekt Oct 7, 2024
9ba36c9
Re-added tag null safety
bladekt Oct 7, 2024
43cd5a8
Merge remote-tracking branch 'origin/refactor/ui' into refactor/ui
bladekt Oct 7, 2024
393c5d6
misc changes
bladekt Oct 19, 2024
0fdcd76
added text alignment, simple boolean button
bladekt Nov 5, 2024
ed41aae
Abstract setting layout
bladekt Nov 6, 2024
2f333c3
fix: wrong refied type input
emyfops Nov 6, 2024
de0424a
Merge branch 'master' into refactor/ui
emyfops Nov 6, 2024
10cbcb6
copyright
emyfops Nov 6, 2024
bdd7453
copyright
emyfops Nov 6, 2024
779beca
Boolean button
bladekt Nov 12, 2024
cd9818c
feat: lambdamoji
emyfops Nov 15, 2024
7cccfbb
Merge remote-tracking branch 'origin/refactor/ui' into refactor/ui
bladekt Nov 27, 2024
1cc25eb
Merge branch 'master' into refactor/ui
emyfops Nov 27, 2024
ae7bd1f
fixed mouse utils
emyfops Nov 27, 2024
2d0e9b7
refactor: global texture atlas
emyfops Dec 6, 2024
378283e
example
emyfops Dec 6, 2024
0271784
Merge remote-tracking branch 'origin/refactor/ui' into refactor/ui
bladekt Dec 7, 2024
ca5066f
fixed wrong example
emyfops Dec 7, 2024
4d1823d
Merge remote-tracking branch 'origin/refactor/ui' into refactor/ui
bladekt Dec 8, 2024
f15eff5
better texture handlers and fixed slots
emyfops Dec 14, 2024
7fd8b99
renamed to TextureOwner
emyfops Dec 14, 2024
d227203
fix: order of execution
emyfops Dec 14, 2024
a030ec7
removed useless bind
emyfops Dec 14, 2024
e645ef2
ref: typealias LambdaResource
emyfops Dec 14, 2024
31b24f1
feat: gif renderer
emyfops Dec 15, 2024
80d41e3
ref: common buffer class
emyfops Dec 15, 2024
bc30ebc
fix: immutable storage GL_DYNAMIC_STORAGE_BIT bit
emyfops Dec 15, 2024
d24db09
IBuffer -> Buffer
emyfops Dec 15, 2024
8a10a94
Merge branch 'master' into refactor/ui
emyfops Dec 15, 2024
625ad4d
Update LambdaMoji.kt
emyfops Dec 15, 2024
519b96d
Update LambdaScreen.kt
emyfops Dec 15, 2024
0f8e2e4
RenderPipeline(raw)
blade1234567 Dec 20, 2024
a79cf40
Merge remote-tracking branch 'origin/refactor/ui' into refactor/ui
blade1234567 Dec 20, 2024
b2841ee
refactored animated texture
emyfops Dec 21, 2024
a2c6993
consistency flag and better texture documentation
emyfops Dec 21, 2024
46bc2d9
don't force texture consistency in gif
emyfops Dec 21, 2024
3884652
fixed incomplete merge conflicts
emyfops Dec 21, 2024
f915e46
support return lines
emyfops Dec 22, 2024
179d03e
make emojis fade with the text box
emyfops Dec 23, 2024
e58c0d2
quick fix
blade1234567 Dec 23, 2024
60907be
added checks and dimension properties
emyfops Dec 28, 2024
071d238
fixed the checks
emyfops Dec 28, 2024
2abd06a
make the pbo use the texture correctly
emyfops Dec 28, 2024
2aa6543
font sdf and shit (in progress)
blade1234567 Dec 30, 2024
2e3a883
ref: textures
emyfops Dec 31, 2024
1b856ec
better mipmap handling
emyfops Dec 31, 2024
26f72e9
pbo doc
emyfops Dec 31, 2024
b52727d
moved the texture options before the tex call
emyfops Dec 31, 2024
083a62e
removed bytearray upload to buffers
emyfops Jan 10, 2025
752bb58
ref: texture api
emyfops Jan 10, 2025
5a1d6c1
feat: map preview
emyfops Jan 10, 2025
9350f06
removed test pbo call
emyfops Jan 10, 2025
1c68158
map gl format to native format
emyfops Jan 10, 2025
bbee3b9
add luminance mapping
emyfops Jan 10, 2025
a5333d7
internal format texture api
emyfops Jan 11, 2025
0f6f0a3
removed handled screen mixin
emyfops Jan 11, 2025
4f4c374
feat: map preview
emyfops Jan 11, 2025
662dd8b
fixed map scale
emyfops Jan 11, 2025
f354999
ref: texture class
emyfops Jan 11, 2025
2c7c377
centered the map tooltip
emyfops Jan 11, 2025
876d902
Merge branch 'master' into refactor/ui
Avanatiker Jan 16, 2025
a30f575
Resolve merge conflicts
Avanatiker Jan 16, 2025
1445c38
Merge branch 'master' into refactor/ui
emyfops Jan 25, 2025
a0189f7
MapDownloader module
emyfops Jan 25, 2025
4bce875
Working immediate mode ui
blade1234567 Feb 11, 2025
218aa2d
Frogor to enable scissors back
blade1234567 Feb 11, 2025
31157fc
Fixed styled minecraft texts being blank
emyfops Feb 14, 2025
081b677
misc ui changes
Blade-kt Feb 18, 2025
de2490c
Fix: font renderer width issue
Blade-kt Feb 19, 2025
b513baf
Fancy design
Blade-kt Feb 21, 2025
a30839d
Various opengl related comments
emyfops Feb 22, 2025
150f419
opengl spam fix
Blade-kt Feb 22, 2025
8b555a1
Animatio & Refactio
Blade-kt Feb 28, 2025
8d3fa99
Enum setting
Blade-kt Feb 28, 2025
7730f6f
Optimized layout positioning
Blade-kt Feb 28, 2025
57a351b
Merge remote-tracking branch 'origin/refactor/ui' into refactor/ui
Blade-kt Feb 28, 2025
195086d
Removed texture compression
emyfops Mar 7, 2025
7591b93
Added function button
emyfops Mar 9, 2025
a63d0a1
Sliders & much stuff
Blade-kt Mar 9, 2025
6c25f50
Fix floating point errors for float settings
Avanatiker Mar 9, 2025
bb7ff6b
Remove unused functions
Avanatiker Mar 9, 2025
1fa3d04
SDF settings
Blade-kt Mar 10, 2025
645bc2b
Merge remote-tracking branch 'origin/refactor/ui' into refactor/ui
Blade-kt Mar 10, 2025
803e630
Show units for numeric settings
Avanatiker Mar 11, 2025
87ecb9c
Module List
Avanatiker Mar 11, 2025
20c4aac
Fixed sdf for emojis
Blade-kt Mar 11, 2025
f483efb
Merge remote-tracking branch 'origin/refactor/ui' into refactor/ui
Blade-kt Mar 11, 2025
db2166a
Merge remote-tracking branch 'origin/master' into refactor/ui
Avanatiker Mar 11, 2025
3b55820
Remove unused access widener
Avanatiker Mar 11, 2025
0083d0e
Disable chat verification toast
Avanatiker Mar 11, 2025
644e314
Close UI on keybind
Avanatiker Mar 11, 2025
8cb2c81
Add KeybindPicker
Avanatiker Mar 11, 2025
f1924cf
Keybind setting picker
Blade-kt Mar 12, 2025
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
Prev Previous commit
Next Next commit
UI Alignment
  • Loading branch information
bladekt committed Sep 22, 2024
commit 52483d39be7713762565d3d21ff58abb3a2e5347
24 changes: 3 additions & 21 deletions common/src/main/kotlin/com/lambda/module/modules/client/NewCGui.kt
Original file line number Diff line number Diff line change
@@ -1,44 +1,26 @@
package com.lambda.module.modules.client

import com.lambda.Lambda.mc
import com.lambda.module.Module
import com.lambda.module.tag.ModuleTag
import com.lambda.newgui.LambdaScreen.Companion.gui
import com.lambda.newgui.LambdaScreen.Companion.toScreen
import com.lambda.newgui.component.HAlign
import com.lambda.newgui.component.core.TextField.Companion.textField
import com.lambda.newgui.component.window.Window
import com.lambda.newgui.component.window.Window.Companion.window
import com.lambda.util.math.Vec2d
import java.awt.Color

object NewCGui : Module(
name = "NewCGui",
description = "ggs",
defaultTags = setOf(ModuleTag.CLIENT)
) {
val titleBarHeight by setting("Title Bar Height", 4.0, 0.0..10.0, 0.1)
val padding by setting("Padding", 2.0, 0.0..6.0, 0.1)

private val clickGuiLayout =
gui {
window(position = Vec2d.ONE * 20.0, title = "Test window") {
titleBar.textField.apply {
text = "Overriding the title"
content.window(Vec2d.ONE * 5.0, Vec2d.ONE * 60.0) {

// Making it align the left corner and have 3px offset from the left side
alignment = HAlign.LEFT
offset = 3.0
}

textField("Text field over the window")

content.textField("Text field inside of the content region") {
alignment = HAlign.CENTER
scale = 0.5

onTick {
// Dynamically updating states
color = if (mc.player?.isDead == true) Color.RED else Color.GREEN
}
}
}
}
Expand Down
4 changes: 3 additions & 1 deletion common/src/main/kotlin/com/lambda/newgui/LambdaScreen.kt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import com.lambda.event.events.TickEvent
import com.lambda.event.listener.SafeListener.Companion.listener
import com.lambda.graphics.RenderMain
import com.lambda.gui.api.GuiEvent
import com.lambda.newgui.component.layout.Layout
import com.lambda.newgui.component.core.UIBuilder
import com.lambda.util.KeyCode
import com.lambda.util.Mouse
import com.lambda.util.Nameable
Expand Down Expand Up @@ -119,7 +121,7 @@ class LambdaScreen(
Layout(owner = null, useBatching = false, batchChildren = true).apply {
var screenSize = Vec2d.ONE * 10000.0

rect {
rectUpdate {
Rect(Vec2d.ZERO, screenSize)
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package com.lambda.newgui.component.core

interface IListEntry {
var heightOffset: Double
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
package com.lambda.newgui.component.core

import com.lambda.newgui.Layout
import com.lambda.newgui.UIBuilder
import com.lambda.newgui.component.HAlign
import com.lambda.newgui.component.VAlign
import com.lambda.newgui.component.layout.Layout
import com.lambda.util.math.MathUtils.lerp
import com.lambda.util.math.Rect
import com.lambda.util.math.Vec2d
import java.awt.Color

Expand All @@ -14,34 +12,42 @@ class TextField(
initialColor: Color = Color.WHITE,
initialScale: Double = 1.0,
initialShadow: Boolean = true,
initialAlignment: HAlign = HAlign.LEFT,
initialOffset: Double = 0.0,
) : Layout(owner, true, true) {
var text = initialText
var color = initialColor
var scale = initialScale
var shadow = initialShadow

var alignment = initialAlignment
var offset = initialOffset

// Let user interact through the text
override val interactionPassthrough = true

init {
rect {
// Completely fill parent component by default
Rect(Vec2d.ZERO, owner.rect.size)
}
verticalAlignment = VAlign.CENTER
rectUpdate(owner::rect)

onRender {
val w = font.getWidth(text, scale)
val h = font.getHeight(scale)

val x = lerp(
rect.left,
rect.right - font.getWidth(text, scale),
alignment.multiplier
) - offset * alignment.offset
rect.right - w,
horizontalAlignment.multiplier
) - offset * horizontalAlignment.offset

val y = when {
verticalAlignment == VAlign.CENTER || rect.size.y <= h -> rect.center.y
else -> lerp(
rect.top + h * 0.5,
rect.bottom - h * 0.5,
verticalAlignment.multiplier
)
}

font.build(text, Vec2d(x, rect.center.y), color, scale, shadow)
font.build(text, Vec2d(x, y), color, scale, shadow)
}
}

Expand All @@ -52,9 +58,8 @@ class TextField(
color: Color = Color.WHITE,
scale: Double = 1.0,
shadow: Boolean = true,
alignment: HAlign = HAlign.LEFT,
offset: Double = 0.0,
block: TextField.() -> Unit = {}
) = TextField(this, text, color, scale, shadow, alignment, offset).apply(children::add).apply(block)
) = TextField(this, text, color, scale, shadow, offset).apply(children::add).apply(block)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package com.lambda.newgui.component.core

@DslMarker
annotation class UIBuilder
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
package com.lambda.newgui
package com.lambda.newgui.component.layout

import com.lambda.graphics.RenderMain
import com.lambda.graphics.animation.AnimationTicker
import com.lambda.graphics.gl.Scissor.scissor
import com.lambda.gui.api.GuiEvent
import com.lambda.gui.api.RenderLayer
import com.lambda.newgui.component.HAlign
import com.lambda.newgui.component.VAlign
import com.lambda.newgui.component.core.UIBuilder
import com.lambda.util.KeyCode
import com.lambda.util.Mouse
import com.lambda.util.math.MathUtils.coerceIn
import com.lambda.util.math.Rect
import com.lambda.util.math.Vec2d

Expand All @@ -30,12 +35,65 @@ import com.lambda.util.math.Vec2d
* ```
*/
open class Layout(
private val owner: Layout?,
val owner: Layout?,
useBatching: Boolean,
private val batchChildren: Boolean
private val batchChildren: Boolean,
) {
// Rectangle of the component
open val rect: Rect get() = rectUpdate() + (owner?.rect?.leftTop ?: Vec2d.ZERO)
/**
* The rectangle of this component
*/
val rect get() = Rect.basedOn(position, size)

/**
* The size of this component
*/
open var size = Vec2d.ZERO

/**
* Horizontal alignment
*/
var horizontalAlignment = HAlign.LEFT; set(to) {
val from = field
field = to

val delta = to.multiplier - from.multiplier
relativePos += Vec2d.RIGHT * delta * (size.x - ownerRect.size.x)
}

/**
* Vertical alignment
*/
var verticalAlignment = VAlign.TOP; set(to) {
val from = field
field = to

val delta = to.multiplier - from.multiplier
relativePos += Vec2d.BOTTOM * delta * (size.y - ownerRect.size.y)
}

/**
* Relative position of the component
*/
var relativePos = Vec2d.ZERO

/**
* Absolute(drawn) position of the component
*/
var position: Vec2d
get() = ownerRect.leftTop + relativeToAbs(relativePos).let {
if (!clampPosition) it
else it.coerceIn(
0.0, ownerRect.size.x - size.x,
0.0, ownerRect.size.y - size.y
)
}; set(value) { relativePos = absToRelative(value - ownerRect.leftTop) }

// Rect-related properties
private var screenSize = Vec2d.ZERO
private val ownerRect get() = owner?.rect ?: Rect(Vec2d.ZERO, screenSize)
private val dockingOffset get() = (ownerRect.size - size) * Vec2d(horizontalAlignment.multiplier, verticalAlignment.multiplier)
private fun relativeToAbs(posIn: Vec2d) = posIn + dockingOffset
private fun absToRelative(posIn: Vec2d) = posIn - dockingOffset

// Structure
val children = mutableListOf<Layout>()
Expand All @@ -61,7 +119,9 @@ open class Layout(
}

private var owningRenderer = false

protected open val interactionPassthrough = false
protected open val clampPosition = false

// Actions
private var showActions = mutableListOf<() -> Unit>()
Expand All @@ -73,7 +133,7 @@ open class Layout(
private var mouseClickActions = mutableListOf<(button: Mouse.Button, action: Mouse.Action) -> Unit>()
private var mouseMoveActions = mutableListOf<(mouse: Vec2d) -> Unit>()
private var mouseScrollActions = mutableListOf<(delta: Double) -> Unit>()
private var rectUpdate = { Rect.ZERO }
private var rectUpdate: (() -> Rect)? = null

/**
* Sets the action to be performed when the element gets shown.
Expand Down Expand Up @@ -157,13 +217,22 @@ open class Layout(
}

/**
* Sets the rectangle of this component.
* Sets the rect of the element
*/
fun rect(block: () -> Rect) {
fun rectUpdate(block: () -> Rect) {
rectUpdate = block
}

fun onEvent(e: GuiEvent) {
if (e is GuiEvent.Render) {
screenSize = RenderMain.screenSize

rectUpdate?.invoke()?.let {
position = it.leftTop
size = it.size
}
}

// Select an element that's on foreground
selectedChild = if (isHovered) children.lastOrNull {
!it.interactionPassthrough && mousePosition in it.rect
Expand Down Expand Up @@ -192,23 +261,31 @@ open class Layout(
is GuiEvent.KeyPress -> { keyPressActions.forEach { it(e.key) } }
is GuiEvent.CharTyped -> { charTypedActions.forEach { it((e.char)) } }
is GuiEvent.MouseMove -> { mousePosition = e.mouse; mouseMoveActions.forEach { it(e.mouse) } }
is GuiEvent.MouseScroll -> { mousePosition = e.mouse; mouseScrollActions.forEach { it(e.delta) } }
is GuiEvent.MouseScroll -> {
mousePosition = e.mouse

if (isHovered) {
mouseScrollActions.forEach { it(e.delta) }
}
}
is GuiEvent.MouseClick -> {
mousePosition = e.mouse
val action = if (isHovered) e.action else Mouse.Action.Release
mouseClickActions.forEach { it(e.button, action) }
}
is GuiEvent.Render -> scissor(rect) {
is GuiEvent.Render -> {
val (pre, post) = children.partition { !it.owningRenderer }

pre.forEach { it.onEvent(e) }
renderActions.forEach { it(renderer) }

if (owningRenderer) {
scissor(rect, renderer::render)
renderer.render()
}

post.forEach { it.onEvent(e) }
scissor(rect) { // ToDo: merge to ListLayout
post.forEach { it.onEvent(e) }
}
}
}
}
Expand All @@ -217,21 +294,20 @@ open class Layout(
/**
* Creates an empty [Layout]
*
* @param useBatching Increases performance by using parent's renderer instead of creating a new one.
* @param useBatching Whether to use parent's renderer
*
* @param batchChildren Whether allow children to use the renderer of this layout
*
* @param block Actions to perform within this component
*
* Check [Layout] description for more info about batching
*/
@UIBuilder
fun Layout.layout(
useBatching: Boolean = false,
batchChildren: Boolean = false,
block: Layout.() -> Unit,
block: Layout.() -> Unit = {},
) = Layout(this, useBatching, batchChildren)
.apply(children::add).apply(block)
}
}

@DslMarker
annotation class UIBuilder
Loading