Skip to content

Commit 35b8ef9

Browse files
committed
Describable enum settings and some cleanup
1 parent 8734884 commit 35b8ef9

File tree

23 files changed

+311
-197
lines changed

23 files changed

+311
-197
lines changed

src/main/kotlin/com/lambda/config/groups/BreakSettings.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ class BreakSettings(
4242
// General
4343
override val breakMode by c.setting("Break Mode", BreakMode.Packet, visibility = vis).group(groupPath, Group.General)
4444
override val sorter by c.setting("Sorter", SortMode.Closest, "The order in which breaks are performed", visibility = vis).group(groupPath, Group.General)
45-
override val reBreak by c.setting("ReBreak", true, "Re-breaks blocks after they've been broken once", visibility = vis).group(groupPath, Group.General)
45+
override val rebreak by c.setting("Rebreak", true, "Re-breaks blocks after they've been broken once", visibility = vis).group(groupPath, Group.General)
4646

4747
// Double break
4848
override val doubleBreak by c.setting("Double Break", true, "Allows breaking two blocks at once", visibility = vis).group(groupPath, Group.General)

src/main/kotlin/com/lambda/config/groups/BuildConfig.kt

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@
1717

1818
package com.lambda.config.groups
1919

20+
import com.lambda.util.Describable
21+
import com.lambda.util.NamedEnum
22+
2023
interface BuildConfig {
2124
// General
2225
val pathing: Boolean
@@ -35,9 +38,12 @@ interface BuildConfig {
3538
// Interacting
3639
val interacting: InteractSettings
3740

38-
enum class SwingType {
39-
Vanilla,
40-
Server,
41-
Client
41+
enum class SwingType(
42+
override val displayName: String,
43+
override val description: String
44+
) : NamedEnum, Describable {
45+
Vanilla("Vanilla", "Play the hand swing locally and also notify the server (default, looks and works as expected)."),
46+
Server("Server", "Only notify the server to swing; local animation may not play unless the server echoes it."),
47+
Client("Client", "Only play the local swing animation; does not notify the server (purely visual).")
4248
}
4349
}

src/main/kotlin/com/lambda/config/groups/BuildSettings.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,5 +54,5 @@ class BuildSettings(
5454
vis() && (placing.placeConfirmationMode != PlaceConfig.PlaceConfirmationMode.None
5555
|| breaking.breakConfirmation != BreakConfirmationMode.None
5656
|| interacting.interactConfirmationMode != InteractionConfig.InteractConfirmationMode.None)
57-
}.group(*groupPath, Group.Break).group(*groupPath, Group.Place).group(*groupPath, Group.Interact)
57+
}.group(*groupPath, Group.Break, BreakSettings.Group.General).group(*groupPath, Group.Place).group(*groupPath, Group.Interact)
5858
}

src/main/kotlin/com/lambda/config/groups/InteractionConfig.kt

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
package com.lambda.config.groups
1919

2020
import com.lambda.interaction.request.rotating.visibilty.PointSelection
21+
import com.lambda.util.Describable
22+
import com.lambda.util.NamedEnum
2123

2224
interface InteractionConfig {
2325
/**
@@ -59,9 +61,12 @@ interface InteractionConfig {
5961
*/
6062
val pointSelection: PointSelection
6163

62-
enum class InteractConfirmationMode {
63-
None,
64-
InteractThenAwait,
65-
AwaitThenInteract
64+
enum class InteractConfirmationMode(
65+
override val displayName: String,
66+
override val description: String
67+
): NamedEnum, Describable {
68+
None("No confirmation", "Send the interaction and don’t wait for the server. Lowest latency, but effects may briefly appear if the server rejects it."),
69+
InteractThenAwait("Interact now, confirm later", "Show interaction effects immediately, then wait for the server to confirm. Feels instant while still verifying the result."),
70+
AwaitThenInteract("Confirm first, then interact", "Wait for the server response before showing any effects. Most accurate and safe, but adds a short delay.")
6671
}
6772
}

src/main/kotlin/com/lambda/config/groups/RotationSettings.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ class RotationSettings(
3333
baseGroup: NamedEnum,
3434
vis: () -> Boolean = { true }
3535
) : RotationConfig {
36-
override var rotationMode by c.setting("Mode", RotationMode.Sync, "SILENT - server-side rotation, SYNC - server-side rotation; client-side movement, LOCK - Lock camera, NONE - No rotation", vis).group(baseGroup)
36+
override var rotationMode by c.setting("Mode", RotationMode.Sync, "How the player is being rotated on interaction", vis).group(baseGroup)
3737

3838
/** How many ticks to keep the rotation before resetting */
3939
override val keepTicks by c.setting("Keep Rotation", 1, 1..10, 1, "Ticks to keep rotation", " ticks") { rotate && vis() }.group(baseGroup)

src/main/kotlin/com/lambda/config/settings/comparable/BooleanSetting.kt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,9 @@ class BooleanSetting(
4444
override fun ImGuiBuilder.buildLayout() {
4545
checkbox(name, ::value)
4646

47-
sameLine()
48-
helpMarker(description)
47+
if (description.isNotEmpty()) {
48+
lambdaTooltip(description)
49+
}
4950
}
5051

5152
override fun CommandBuilder.buildCommand(registry: CommandRegistryAccess) {

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

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import com.lambda.brigadier.executeWithResult
2626
import com.lambda.brigadier.required
2727
import com.lambda.config.AbstractSetting
2828
import com.lambda.gui.dsl.ImGuiBuilder
29+
import com.lambda.util.Describable
2930
import com.lambda.util.NamedEnum
3031
import com.lambda.util.StringUtils.capitalize
3132
import com.lambda.util.extension.CommandBuilder
@@ -57,14 +58,28 @@ class EnumSetting<T : Enum<T>>(
5758
}
5859

5960
override fun ImGuiBuilder.buildLayout() {
60-
text(name)
61+
val values = value.enumValues
62+
val preview = value.displayValue
6163

62-
sameLine()
63-
helpMarker(description)
64+
combo("##$name", preview = preview) {
65+
values.forEachIndexed { idx, v ->
66+
val isSelected = idx == index
67+
68+
selectable(v.displayValue, isSelected) {
69+
if (!isSelected) index = idx
70+
}
6471

65-
combo("##$name", ::index, value.enumValues.map { it.displayValue }.toTypedArray())
72+
(v as? Describable)?.let { lambdaTooltip(it.description) }
73+
}
74+
}
75+
76+
(value as? Describable)?.let { lambdaTooltip(it.description) }
77+
sameLine()
78+
text(name)
79+
if (description.isNotBlank()) lambdaTooltip(description)
6680
}
6781

82+
6883
override fun CommandBuilder.buildCommand(registry: CommandRegistryAccess) {
6984
required(word(name)) { parameter ->
7085
suggests { _, builder ->

src/main/kotlin/com/lambda/interaction/construction/blueprint/Blueprint.kt

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -57,22 +57,11 @@ abstract class Blueprint {
5757
companion object {
5858
fun emptyStructure(): Structure = emptyMap()
5959

60-
fun Box.toStructure(targetState: TargetState): Structure =
61-
BlockPos.stream(this)
62-
.toList()
63-
.associateWith { targetState }
64-
6560
fun BlockBox.toStructure(targetState: TargetState): Structure =
66-
BlockPos.stream(this)
67-
.toList()
68-
.associateWith { targetState }
61+
BlockPos.stream(this).toList().associateWith { targetState }
6962

7063
fun BlockPos.toStructure(targetState: TargetState): Structure =
71-
setOf(this)
72-
.associateWith { targetState }
73-
74-
// fun Schematic.fromSchematic() =
75-
// this.blockMap.map { it.key to TargetState.BlockState(it.value) }.toMap()
64+
setOf(this).associateWith { targetState }
7665

7766
fun StructureTemplate.toStructure(): Structure =
7867
blockInfoLists

src/main/kotlin/com/lambda/interaction/construction/processing/PreProcessingInfo.kt

Lines changed: 0 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -17,52 +17,10 @@
1717

1818
package com.lambda.interaction.construction.processing
1919

20-
import com.lambda.interaction.construction.processing.ProcessorRegistry.postProcessedProperties
2120
import com.lambda.interaction.construction.verify.SurfaceScan
2221
import net.minecraft.state.property.Property
2322
import net.minecraft.util.math.Direction
2423

25-
@DslMarker
26-
private annotation class InfoAccumulator
27-
28-
@InfoAccumulator
29-
class PreProcessingInfoAccumulator(
30-
override var surfaceScan: SurfaceScan = SurfaceScan.DEFAULT,
31-
override val ignore: MutableSet<Property<*>> = postProcessedProperties.toMutableSet(),
32-
override val sides: MutableSet<Direction> = Direction.entries.toMutableSet(),
33-
override var shouldBeOmitted: Boolean = false
34-
) : PreProcessingInfo {
35-
@InfoAccumulator
36-
fun offerSurfaceScan(scan: SurfaceScan) {
37-
if (scan.mode.priority > surfaceScan.mode.priority) {
38-
surfaceScan = scan
39-
}
40-
}
41-
42-
@InfoAccumulator
43-
fun addIgnores(vararg properties: Property<*>) {
44-
ignore.addAll(properties)
45-
}
46-
47-
@InfoAccumulator
48-
fun retainSides(predicate: (Direction) -> Boolean) {
49-
this.sides.retainAll(predicate)
50-
}
51-
52-
@InfoAccumulator
53-
fun retainSides(vararg sides: Direction) {
54-
this.sides.retainAll(sides.toSet())
55-
}
56-
57-
@InfoAccumulator
58-
fun omitPlacement() {
59-
shouldBeOmitted = true
60-
}
61-
62-
@InfoAccumulator
63-
fun complete() = this as PreProcessingInfo
64-
}
65-
6624
interface PreProcessingInfo {
6725
val surfaceScan: SurfaceScan
6826
val ignore: Set<Property<*>>
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
/*
2+
* Copyright 2025 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.interaction.construction.processing
19+
20+
import com.lambda.interaction.construction.verify.SurfaceScan
21+
import net.minecraft.state.property.Property
22+
import net.minecraft.util.math.Direction
23+
24+
class PreProcessingInfoAccumulator(
25+
override var surfaceScan: SurfaceScan = SurfaceScan.DEFAULT,
26+
override val ignore: MutableSet<Property<*>> = ProcessorRegistry.postProcessedProperties.toMutableSet(),
27+
override val sides: MutableSet<Direction> = Direction.entries.toMutableSet(),
28+
override var shouldBeOmitted: Boolean = false
29+
) : PreProcessingInfo {
30+
@InfoAccumulator
31+
fun offerSurfaceScan(scan: SurfaceScan) {
32+
if (scan.mode.priority > surfaceScan.mode.priority) {
33+
surfaceScan = scan
34+
}
35+
}
36+
37+
@InfoAccumulator
38+
fun addIgnores(vararg properties: Property<*>) {
39+
ignore.addAll(properties)
40+
}
41+
42+
@InfoAccumulator
43+
fun retainSides(predicate: (Direction) -> Boolean) {
44+
sides.retainAll(predicate)
45+
}
46+
47+
@InfoAccumulator
48+
fun retainSides(vararg sides: Direction) {
49+
this.sides.retainAll(sides.toSet())
50+
}
51+
52+
@InfoAccumulator
53+
fun omitPlacement() {
54+
shouldBeOmitted = true
55+
}
56+
57+
@InfoAccumulator
58+
fun complete() = this as PreProcessingInfo
59+
60+
companion object {
61+
@DslMarker
62+
private annotation class InfoAccumulator
63+
}
64+
}

0 commit comments

Comments
 (0)