From 1127de6e997b08408c2094cf1cc0d510b89d7b3b Mon Sep 17 00:00:00 2001 From: inglettronald Date: Fri, 9 Jun 2023 00:17:24 -0500 Subject: Some stuff visually works now --- .../kotlin/com/dulkirfabric/config/DulkirConfig.kt | 49 +++++++++++----------- 1 file changed, 24 insertions(+), 25 deletions(-) diff --git a/src/main/kotlin/com/dulkirfabric/config/DulkirConfig.kt b/src/main/kotlin/com/dulkirfabric/config/DulkirConfig.kt index 2855a17..4f3c328 100644 --- a/src/main/kotlin/com/dulkirfabric/config/DulkirConfig.kt +++ b/src/main/kotlin/com/dulkirfabric/config/DulkirConfig.kt @@ -14,7 +14,10 @@ package com.dulkirfabric.config import com.dulkirfabric.DulkirModFabric.mc +import com.dulkirfabric.config.ListHelper.mkIntField +import com.dulkirfabric.config.ListHelper.mkStringField import com.google.gson.Gson +import kotlinx.serialization.Serializable import me.shedaniel.cloth.clothconfig.shadowed.blue.endless.jankson.annotation.SerializedName import me.shedaniel.clothconfig2.api.ConfigBuilder import net.minecraft.client.gui.screen.Screen @@ -25,8 +28,6 @@ import net.minecraft.util.Formatting import net.minecraft.util.Identifier import java.io.File import java.util.* -import java.util.function.Consumer -import java.util.function.Supplier class DulkirConfig { @@ -55,34 +56,26 @@ class DulkirConfig { .setSaveConsumer { newValue -> inventoryScale = newValue } .build() ) - val shortcuts = builder.getOrCreateCategory(Text.literal("Key Shortcuts")) - /** public NestedListListEntry(Text fieldName, - * List value, - * boolean defaultExpanded, - * Supplier> tooltipSupplier, - * Consumer> saveConsumer, - * Supplier> defaultValue, - * Text resetButtonKey, - * boolean deleteButtonEnabled, - * boolean insertInFront, - * BiFunction, INNER> createNewCell) { - */ - val fieldName = Text.literal("Chat Macros") - val defaultExpanded = false - val tooltipSupplier: Optional = Optional.empty() - val saveConsumer: Consumer>> = Consumer { list -> value = list } - val defaultValue: Supplier>> = Supplier { listOf(Pair(1, 2), Pair(3, 4)) } - val resetButtonKey = Text.literal("Reset Macros") - val deleteButtonEnabled = true - val insertInFront = true - //val createNewCell: BiFunction, NestedListListEntry, INNER>, INNER>> - //TODO + val shortcuts = builder.getOrCreateCategory(Text.literal("Shortcuts")) + shortcuts.addEntry( + ListHelper.mkConfigList( + Text.literal("Macros"), + ListHelper.Holder::macros, + { Macro(-2, "") }, + Text.literal("Macro"), + { value -> + listOf( + entryBuilder.mkStringField(Text.literal("Command"), value::command), + entryBuilder.mkIntField(Text.literal("KeyBinding"), value::keyBinding) + ) + } + ) + ) builder.transparentBackground() screen = builder.build() } - data class ConfigOptions( @SerializedName("testOption") val invScaleBool: Boolean, @@ -91,6 +84,12 @@ class DulkirConfig { val inventoryScale: Float ) + @Serializable + data class Macro( + var keyBinding: Int, + var command: String, + ) + /** * Object for storing all the actual config values that will be used in doing useful stuff with the config */ -- cgit