From 80d97bb0de46b1b0cefd8a5bd1ba22105ee08a50 Mon Sep 17 00:00:00 2001 From: Linnea Gräf Date: Mon, 28 Jul 2025 19:52:18 +0200 Subject: feat: update to new moulconfig version --- .../moulconfig/java/MCConfigEditorIntegration.kt | 33 +++++++++++++--------- .../moulconfig/java/ProcessedCategoryFirm.kt | 10 ++++--- .../moulconfig/java/ProcessedEditableOptionFirm.kt | 10 ++++--- .../firmament/compat/rei/recipes/SBKatRecipe.kt | 14 ++++----- 4 files changed, 38 insertions(+), 29 deletions(-) (limited to 'src/compat') diff --git a/src/compat/moulconfig/java/MCConfigEditorIntegration.kt b/src/compat/moulconfig/java/MCConfigEditorIntegration.kt index 874e58d..a568c19 100644 --- a/src/compat/moulconfig/java/MCConfigEditorIntegration.kt +++ b/src/compat/moulconfig/java/MCConfigEditorIntegration.kt @@ -7,8 +7,10 @@ import io.github.notenoughupdates.moulconfig.DescriptionRendereringBehaviour import io.github.notenoughupdates.moulconfig.Social import io.github.notenoughupdates.moulconfig.common.IMinecraft import io.github.notenoughupdates.moulconfig.common.MyResourceLocation +import io.github.notenoughupdates.moulconfig.common.text.StructuredText import io.github.notenoughupdates.moulconfig.gui.GuiComponent -import io.github.notenoughupdates.moulconfig.gui.GuiElementWrapper +import io.github.notenoughupdates.moulconfig.gui.GuiContext +import io.github.notenoughupdates.moulconfig.gui.GuiElementComponent import io.github.notenoughupdates.moulconfig.gui.GuiOptionEditor import io.github.notenoughupdates.moulconfig.gui.HorizontalAlign import io.github.notenoughupdates.moulconfig.gui.MoulConfigEditor @@ -25,6 +27,8 @@ import io.github.notenoughupdates.moulconfig.gui.editors.GuiOptionEditorColour import io.github.notenoughupdates.moulconfig.gui.editors.GuiOptionEditorDropdown import io.github.notenoughupdates.moulconfig.gui.editors.GuiOptionEditorText import io.github.notenoughupdates.moulconfig.observer.GetSetter +import io.github.notenoughupdates.moulconfig.platform.MoulConfigPlatform +import io.github.notenoughupdates.moulconfig.platform.MoulConfigScreenComponent import io.github.notenoughupdates.moulconfig.processor.ProcessedCategory import io.github.notenoughupdates.moulconfig.processor.ProcessedOption import java.lang.reflect.Type @@ -33,6 +37,7 @@ import kotlin.time.Duration import kotlin.time.Duration.Companion.seconds import kotlin.time.DurationUnit import net.minecraft.client.gui.screen.Screen +import net.minecraft.text.Text import net.minecraft.util.Identifier import net.minecraft.util.StringIdentifiable import net.minecraft.util.Util @@ -104,8 +109,8 @@ class MCConfigEditorIntegration : FirmamentConfigScreenProvider { RowComponent( AlignComponent( TextComponent( - IMinecraft.instance.defaultFontRenderer, - { formatter(setter.get()) }, + IMinecraft.INSTANCE.defaultFontRenderer, + { StructuredText.of(formatter(setter.get())) }, 25, TextComponent.TextAlignment.CENTER, false, false ), @@ -212,7 +217,7 @@ class MCConfigEditorIntegration : FirmamentConfigScreenProvider { register(ClickHandler::class.java) { handler, option, categoryAccordionId, configObject -> object : ProcessedEditableOptionFirm(option, categoryAccordionId, configObject) { override fun createEditor(): GuiOptionEditor { - return GuiOptionEditorButton(this, -1, "Click", configObject) + return GuiOptionEditorButton(this, -1, StructuredText.of("Click"), configObject) } override fun toT(any: Any?): Unit? { @@ -231,7 +236,7 @@ class MCConfigEditorIntegration : FirmamentConfigScreenProvider { register(HudMetaHandler::class.java) { handler, option, categoryAccordionId, configObject -> object : ProcessedEditableOptionFirm(option, categoryAccordionId, configObject) { override fun createEditor(): GuiOptionEditor { - return GuiOptionEditorButton(this, -1, "Edit HUD", configObject) + return GuiOptionEditorButton(this, -1, StructuredText.of("Edit HUD"), configObject) } override fun fromT(t: HudMeta): Any { @@ -337,8 +342,8 @@ class MCConfigEditorIntegration : FirmamentConfigScreenProvider { return true } - override fun getTitle(): String { - return "Firmament ${Firmament.version.friendlyString}" + override fun getTitle(): StructuredText { + return StructuredText.of("Firmament ${Firmament.version.friendlyString}") } @Deprecated("Deprecated in java") @@ -356,8 +361,8 @@ class MCConfigEditorIntegration : FirmamentConfigScreenProvider { Util.getOperatingSystem().open(URI(link)) } - override fun getTooltip(): List { - return listOf(name) + override fun getTooltip(): List { + return listOf(StructuredText.of(name)) } override fun getIcon(): MyResourceLocation { @@ -394,12 +399,12 @@ class MCConfigEditorIntegration : FirmamentConfigScreenProvider { return "FirmamentConfig:${config.name}" } - override fun getName(): String { - return config.labelText.string + override fun getName(): StructuredText { + return MoulConfigPlatform.wrap(config.labelText) } - override fun getDescription(): String { - return "Missing description" + override fun getDescription(): StructuredText { + return StructuredText.of("Missing description") } override fun get(): Any { @@ -432,7 +437,7 @@ class MCConfigEditorIntegration : FirmamentConfigScreenProvider { if (search != null) editor.search(search) editor.setWide(AllConfigsGui.ConfigConfig.enableWideMC) - return GuiElementWrapper(editor) // TODO : add parent support + return MoulConfigScreenComponent(Text.empty(), GuiContext(GuiElementComponent(editor)), parent) // TODO : add parent support } } diff --git a/src/compat/moulconfig/java/ProcessedCategoryFirm.kt b/src/compat/moulconfig/java/ProcessedCategoryFirm.kt index 5313441..38a613a 100644 --- a/src/compat/moulconfig/java/ProcessedCategoryFirm.kt +++ b/src/compat/moulconfig/java/ProcessedCategoryFirm.kt @@ -1,6 +1,8 @@ package moe.nea.firmament.compat.moulconfig +import io.github.notenoughupdates.moulconfig.common.text.StructuredText import io.github.notenoughupdates.moulconfig.gui.editors.GuiOptionEditorAccordion +import io.github.notenoughupdates.moulconfig.platform.MoulConfigPlatform import io.github.notenoughupdates.moulconfig.processor.ProcessedCategory import io.github.notenoughupdates.moulconfig.processor.ProcessedOption import moe.nea.firmament.gui.config.ManagedConfig @@ -21,12 +23,12 @@ class ProcessedCategoryFirm( return "FirmamentCategory.${category.name}" } - override fun getDisplayName(): String { - return category.labelText.string + override fun getDisplayName(): StructuredText { + return MoulConfigPlatform.wrap(category.labelText) } - override fun getDescription(): String { - return category.description.string + override fun getDescription(): StructuredText { + return MoulConfigPlatform.wrap(category.description) } override fun getIdentifier(): String { diff --git a/src/compat/moulconfig/java/ProcessedEditableOptionFirm.kt b/src/compat/moulconfig/java/ProcessedEditableOptionFirm.kt index f0e9aa4..ac23ec7 100644 --- a/src/compat/moulconfig/java/ProcessedEditableOptionFirm.kt +++ b/src/compat/moulconfig/java/ProcessedEditableOptionFirm.kt @@ -1,6 +1,8 @@ package moe.nea.firmament.compat.moulconfig import io.github.notenoughupdates.moulconfig.Config +import io.github.notenoughupdates.moulconfig.common.text.StructuredText +import io.github.notenoughupdates.moulconfig.platform.MoulConfigPlatform import moe.nea.firmament.gui.config.ManagedOption import moe.nea.firmament.util.ErrorUtil @@ -14,12 +16,12 @@ abstract class ProcessedEditableOptionFirm( return "FirmamentOption:${managedConfig.name}:${managedOption.propertyName}" } - override fun getName(): String { - return managedOption.labelText.string + override fun getName(): StructuredText { + return MoulConfigPlatform.wrap(managedOption.labelText) } - override fun getDescription(): String { - return managedOption.labelDescription.string + override fun getDescription(): StructuredText { + return MoulConfigPlatform.wrap(managedOption.labelDescription) } abstract fun fromT(t: T): Any diff --git a/src/compat/rei/java/moe/nea/firmament/compat/rei/recipes/SBKatRecipe.kt b/src/compat/rei/java/moe/nea/firmament/compat/rei/recipes/SBKatRecipe.kt index f77e9f5..cb7877d 100644 --- a/src/compat/rei/java/moe/nea/firmament/compat/rei/recipes/SBKatRecipe.kt +++ b/src/compat/rei/java/moe/nea/firmament/compat/rei/recipes/SBKatRecipe.kt @@ -8,7 +8,7 @@ import io.github.notenoughupdates.moulconfig.gui.MouseEvent import io.github.notenoughupdates.moulconfig.gui.component.SliderComponent import io.github.notenoughupdates.moulconfig.observer.GetSetter import io.github.notenoughupdates.moulconfig.observer.Property -import io.github.notenoughupdates.moulconfig.platform.ModernRenderContext +import io.github.notenoughupdates.moulconfig.platform.MoulConfigRenderContext import me.shedaniel.math.Point import me.shedaniel.math.Rectangle import me.shedaniel.rei.api.client.gui.Renderer @@ -148,7 +148,7 @@ fun wrapWidget(bounds: Rectangle, component: GuiComponent): Widget { context.matrices.translate(bounds.minX.toFloat(), bounds.minY.toFloat()) component.render( GuiImmediateContext( - ModernRenderContext(context), + MoulConfigRenderContext(context), bounds.minX, bounds.minY, bounds.width, bounds.height, mouseX - bounds.minX, mouseY - bounds.minY, @@ -165,7 +165,7 @@ fun wrapWidget(bounds: Rectangle, component: GuiComponent): Widget { component.mouseEvent( MouseEvent.Move(0F, 0F), GuiImmediateContext( - IMinecraft.instance.provideTopLevelRenderContext(), + IMinecraft.INSTANCE.provideTopLevelRenderContext(), bounds.minX, bounds.minY, bounds.width, bounds.height, mouseXInt - bounds.minX, mouseYInt - bounds.minY, @@ -181,7 +181,7 @@ fun wrapWidget(bounds: Rectangle, component: GuiComponent): Widget { return component.mouseEvent( MouseEvent.Click(button, true), GuiImmediateContext( - IMinecraft.instance.provideTopLevelRenderContext(), + IMinecraft.INSTANCE.provideTopLevelRenderContext(), bounds.minX, bounds.minY, bounds.width, bounds.height, mouseXInt - bounds.minX, mouseYInt - bounds.minY, @@ -197,7 +197,7 @@ fun wrapWidget(bounds: Rectangle, component: GuiComponent): Widget { return component.mouseEvent( MouseEvent.Click(button, false), GuiImmediateContext( - IMinecraft.instance.provideTopLevelRenderContext(), + IMinecraft.INSTANCE.provideTopLevelRenderContext(), bounds.minX, bounds.minY, bounds.width, bounds.height, mouseXInt - bounds.minX, mouseYInt - bounds.minY, @@ -219,7 +219,7 @@ fun wrapWidget(bounds: Rectangle, component: GuiComponent): Widget { return component.mouseEvent( MouseEvent.Move(deltaX.toFloat(), deltaY.toFloat()), GuiImmediateContext( - IMinecraft.instance.provideTopLevelRenderContext(), + IMinecraft.INSTANCE.provideTopLevelRenderContext(), bounds.minX, bounds.minY, bounds.width, bounds.height, mouseXInt - bounds.minX, mouseYInt - bounds.minY, @@ -241,7 +241,7 @@ fun wrapWidget(bounds: Rectangle, component: GuiComponent): Widget { return component.mouseEvent( MouseEvent.Scroll(verticalAmount.toFloat()), GuiImmediateContext( - IMinecraft.instance.provideTopLevelRenderContext(), + IMinecraft.INSTANCE.provideTopLevelRenderContext(), bounds.minX, bounds.minY, bounds.width, bounds.height, mouseXInt - bounds.minX, mouseYInt - bounds.minY, -- cgit