Skip to content

Commit c638418

Browse files
committed
Brought back collection selection events
1 parent 47e8110 commit c638418

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

src/main/kotlin/com/lambda/config/settings/collections/CollectionSetting.kt

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import com.lambda.config.SettingEditorDsl
2525
import com.lambda.config.SettingGroupEditor
2626
import com.lambda.context.SafeContext
2727
import com.lambda.gui.dsl.ImGuiBuilder
28+
import com.lambda.threading.runSafe
2829
import com.lambda.util.StringUtils.levenshteinDistance
2930
import imgui.ImGuiListClipper
3031
import imgui.flag.ImGuiChildFlags
@@ -96,8 +97,13 @@ open class CollectionSetting<T : Any>(
9697
selected = selected,
9798
flags = DontClosePopups
9899
) {
99-
if (selected) value.remove(v)
100-
else value.add(v)
100+
if (selected) {
101+
value.remove(v)
102+
runSafe { deselectListeners.forEach { f -> f(v) } }
103+
} else {
104+
value.add(v)
105+
runSafe { selectListeners.forEach { f -> f(v) } }
106+
}
101107
}
102108
}
103109
}

src/main/kotlin/com/lambda/module/modules/render/BlockESP.kt

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,11 @@ object BlockESP : Module(
4141
description = "Render block ESP",
4242
tag = ModuleTag.RENDER,
4343
) {
44-
// ToDo: Toggle searching, solve memory leak
4544
private val searchBlocks by setting("Search Blocks", true, "Search for blocks around the player")
46-
private val blocks by setting("Blocks", setOf(Blocks.BEDROCK), description = "Render blocks") { searchBlocks }.onValueChange(::rebuildMesh)
45+
private val blocks by setting("Blocks", setOf(Blocks.BEDROCK), description = "Render blocks") { searchBlocks }
46+
.onSelect { rebuildMesh(this, null, null) }
47+
.onDeselect { rebuildMesh(this, null, null) }
48+
4749
private var drawFaces: Boolean by setting("Draw Faces", true, "Draw faces of blocks") { searchBlocks }.onValueChange(::rebuildMesh).onValueChange { _, to -> if (!to) drawOutlines = true }
4850
private var drawOutlines: Boolean by setting("Draw Outlines", true, "Draw outlines of blocks") { searchBlocks }.onValueChange(::rebuildMesh).onValueChange { _, to -> if (!to) drawFaces = true }
4951
private val mesh by setting("Mesh", true, "Connect similar adjacent blocks") { searchBlocks }.onValueChange(::rebuildMesh)
@@ -88,5 +90,5 @@ object BlockESP : Module(
8890
if (drawOutlines) outline(pos, state, if (useBlockColor) blockColor else outlineColor, sides, outlineMode)
8991
}
9092

91-
private fun rebuildMesh(ctx: SafeContext, from: Any, to: Any): Unit = esp.rebuild()
93+
private fun rebuildMesh(ctx: SafeContext, from: Any?, to: Any?): Unit = esp.rebuild()
9294
}

0 commit comments

Comments
 (0)