diff --git a/common/src/main/kotlin/fr/username404/snowygui/config/ConfigScreen.kt b/common/src/main/kotlin/fr/username404/snowygui/config/ConfigScreen.kt index 54e20a0..c39ca17 100644 --- a/common/src/main/kotlin/fr/username404/snowygui/config/ConfigScreen.kt +++ b/common/src/main/kotlin/fr/username404/snowygui/config/ConfigScreen.kt @@ -32,6 +32,7 @@ val SnowyConfigScreen: Screen get() { } as ClickBox @Suppress("UNCHECKED_CAST") val macrosButtons = macrosBox.buttons as MutableSet + fun Collection.getTitleCommand(): MutableList = map { it.run { "$title: $command" } }.toMutableList() me.shedaniel.clothconfig2.api.ConfigBuilder.create().setParentScreen(configScreenParent).transparentBackground() .setShouldListSmoothScroll(true) .setTitle(translationComponent).apply { @@ -51,8 +52,8 @@ val SnowyConfigScreen: Screen get() { }.setTooltip(Component.nullToEmpty("WARNING: Do not use this on servers or you might get banned.")).build() ).addEntry(startStrList( TranslatableComponent(Category.MACROS.translationKey), - macrosButtons.map { it.run { "$title: $command" } } - ).setInsertInFront(false).setDefaultValue(Configuration.foundMacros.map { "${it.title}: ${it.command}" }).setErrorSupplier { list -> + macrosButtons.getTitleCommand() + ).setInsertInFront(false).setDefaultValue(Configuration.foundMacros.getTitleCommand()).setErrorSupplier { list -> supplyComponent(if (list.size > buttonsMax) "$confPrefix.general.macros.toomuchbuttons" else null) }.setCellErrorSupplier { with(it.split(":")) { diff --git a/common/src/main/kotlin/fr/username404/snowygui/gui/elements/ClickBox.kt b/common/src/main/kotlin/fr/username404/snowygui/gui/elements/ClickBox.kt index c0d28c4..24bb9e7 100644 --- a/common/src/main/kotlin/fr/username404/snowygui/gui/elements/ClickBox.kt +++ b/common/src/main/kotlin/fr/username404/snowygui/gui/elements/ClickBox.kt @@ -26,7 +26,7 @@ class ClickBox( val name: TranslatableComponent? = null ): ColoredElement(x, y, 80, 10, color, 0.5F) { fun isCategory(c: Category): Boolean = (name?.key == c.translationKey) - val buttons = if (sortAlphabetically) sortedSetOf(compareBy(String.CASE_INSENSITIVE_ORDER) { it.title }) else mutableSetOf() + val buttons: MutableSet = if (sortAlphabetically) sortedSetOf(compareBy(String.CASE_INSENSITIVE_ORDER) { it.title }) else mutableSetOf() override fun display(stack: PoseStack?) { hidden = buttons.isEmpty() || hidden super.display(stack)