aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/compat/moulconfig/java/MCConfigEditorIntegration.kt33
-rw-r--r--src/compat/moulconfig/java/ProcessedCategoryFirm.kt10
-rw-r--r--src/compat/moulconfig/java/ProcessedEditableOptionFirm.kt10
-rw-r--r--src/compat/rei/java/moe/nea/firmament/compat/rei/recipes/SBKatRecipe.kt14
-rw-r--r--src/main/kotlin/features/debug/itemeditor/PromptScreen.kt15
-rw-r--r--src/main/kotlin/features/events/carnival/MinesweeperHelper.kt6
-rw-r--r--src/main/kotlin/features/inventory/buttons/InventoryButtonEditor.kt8
-rw-r--r--src/main/kotlin/features/inventory/storageoverlay/StorageOverlayScreen.kt6
-rw-r--r--src/main/kotlin/features/mining/MiningBlockInfoUi.kt4
-rw-r--r--src/main/kotlin/gui/BarComponent.kt5
-rw-r--r--src/main/kotlin/gui/CheckboxComponent.kt4
-rw-r--r--src/main/kotlin/gui/FirmHoverComponent.kt4
-rw-r--r--src/main/kotlin/gui/config/DurationHandler.kt5
-rw-r--r--src/main/kotlin/gui/config/IntegerHandler.kt5
-rw-r--r--src/main/kotlin/gui/config/KeyBindingStateManager.kt5
-rw-r--r--src/main/kotlin/gui/config/ManagedConfig.kt21
-rw-r--r--src/main/kotlin/gui/hud/MoulConfigHud.kt90
-rw-r--r--src/main/kotlin/util/FragmentGuiScreen.kt2
-rw-r--r--src/main/kotlin/util/MC.kt4
-rw-r--r--src/main/kotlin/util/MoulConfigFragment.kt69
-rw-r--r--src/main/kotlin/util/MoulConfigUtils.kt16
-rw-r--r--src/main/kotlin/util/render/FacingThePlayerContext.kt17
-rw-r--r--src/main/kotlin/util/render/RenderCircleProgress.kt35
-rw-r--r--src/main/kotlin/util/render/RenderInWorldContext.kt9
24 files changed, 199 insertions, 198 deletions
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<Unit>(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<HudMeta>(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<String> {
- return listOf(name)
+ override fun getTooltip(): List<StructuredText> {
+ 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<T : Any>(
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,
diff --git a/src/main/kotlin/features/debug/itemeditor/PromptScreen.kt b/src/main/kotlin/features/debug/itemeditor/PromptScreen.kt
deleted file mode 100644
index 187b70b..0000000
--- a/src/main/kotlin/features/debug/itemeditor/PromptScreen.kt
+++ /dev/null
@@ -1,15 +0,0 @@
-package moe.nea.firmament.features.debug.itemeditor
-
-import io.github.notenoughupdates.moulconfig.gui.CloseEventListener
-import io.github.notenoughupdates.moulconfig.gui.GuiComponentWrapper
-import io.github.notenoughupdates.moulconfig.gui.GuiContext
-import io.github.notenoughupdates.moulconfig.gui.component.CenterComponent
-import io.github.notenoughupdates.moulconfig.gui.component.ColumnComponent
-import io.github.notenoughupdates.moulconfig.gui.component.PanelComponent
-import io.github.notenoughupdates.moulconfig.gui.component.TextComponent
-import io.github.notenoughupdates.moulconfig.gui.component.TextFieldComponent
-import io.github.notenoughupdates.moulconfig.observer.GetSetter
-import kotlin.reflect.KMutableProperty0
-import moe.nea.firmament.gui.FirmButtonComponent
-import moe.nea.firmament.util.MoulConfigUtils
-
diff --git a/src/main/kotlin/features/events/carnival/MinesweeperHelper.kt b/src/main/kotlin/features/events/carnival/MinesweeperHelper.kt
index cfc05cc..3baf5a5 100644
--- a/src/main/kotlin/features/events/carnival/MinesweeperHelper.kt
+++ b/src/main/kotlin/features/events/carnival/MinesweeperHelper.kt
@@ -2,7 +2,7 @@
package moe.nea.firmament.features.events.carnival
import io.github.notenoughupdates.moulconfig.observer.ObservableList
-import io.github.notenoughupdates.moulconfig.platform.ModernItemStack
+import io.github.notenoughupdates.moulconfig.platform.MoulConfigPlatform
import io.github.notenoughupdates.moulconfig.xml.Bind
import java.util.UUID
import net.minecraft.block.Blocks
@@ -120,7 +120,7 @@ object MinesweeperHelper {
.setSkyBlockFirmamentUiId("MINESWEEPER_$name")
@Bind
- fun getIcon() = ModernItemStack.of(itemStack)
+ fun getIcon() = MoulConfigPlatform.wrap(itemStack)
@Bind
fun pieceLabel() = fruitColor.formattingCode + fruitName
@@ -158,7 +158,7 @@ object MinesweeperHelper {
;
@Bind("itemType")
- fun getItemStack() = ModernItemStack.of(ItemStack(itemType))
+ fun getItemStack() = MoulConfigPlatform.wrap(ItemStack(itemType))
companion object {
val id = SkyblockId("CARNIVAL_SHOVEL")
diff --git a/src/main/kotlin/features/inventory/buttons/InventoryButtonEditor.kt b/src/main/kotlin/features/inventory/buttons/InventoryButtonEditor.kt
index 1e4f6a3..7334c82 100644
--- a/src/main/kotlin/features/inventory/buttons/InventoryButtonEditor.kt
+++ b/src/main/kotlin/features/inventory/buttons/InventoryButtonEditor.kt
@@ -2,8 +2,8 @@ package moe.nea.firmament.features.inventory.buttons
import io.github.notenoughupdates.moulconfig.common.IItemStack
import io.github.notenoughupdates.moulconfig.gui.component.PanelComponent
-import io.github.notenoughupdates.moulconfig.platform.ModernItemStack
-import io.github.notenoughupdates.moulconfig.platform.ModernRenderContext
+import io.github.notenoughupdates.moulconfig.platform.MoulConfigPlatform
+import io.github.notenoughupdates.moulconfig.platform.MoulConfigRenderContext
import io.github.notenoughupdates.moulconfig.xml.Bind
import me.shedaniel.math.Point
import me.shedaniel.math.Rectangle
@@ -35,7 +35,7 @@ class InventoryButtonEditor(
@Bind
fun getItemIcon(): IItemStack {
save()
- return ModernItemStack.of(InventoryButton.getItemForName(icon))
+ return MoulConfigPlatform.wrap(InventoryButton.getItemForName(icon))
}
@Bind
@@ -197,7 +197,7 @@ class InventoryButtonEditor(
context.matrices.pushMatrix()
PanelComponent.DefaultBackgroundRenderer.VANILLA
.render(
- ModernRenderContext(context),
+ MoulConfigRenderContext(context),
lastGuiRect.minX, lastGuiRect.minY,
lastGuiRect.width, lastGuiRect.height,
)
diff --git a/src/main/kotlin/features/inventory/storageoverlay/StorageOverlayScreen.kt b/src/main/kotlin/features/inventory/storageoverlay/StorageOverlayScreen.kt
index 0baa099..a023ce6 100644
--- a/src/main/kotlin/features/inventory/storageoverlay/StorageOverlayScreen.kt
+++ b/src/main/kotlin/features/inventory/storageoverlay/StorageOverlayScreen.kt
@@ -181,7 +181,7 @@ class StorageOverlayScreen : Screen(Text.literal("")) {
val searchField = TextFieldComponent(
searchText, 100, GetSetter.constant(true),
tr("firmament.storage-overlay.search.suggestion", "Search...").string,
- IMinecraft.instance.defaultFontRenderer
+ IMinecraft.INSTANCE.defaultFontRenderer
)
val controlComponent = PanelComponent(
ColumnComponent(
@@ -383,7 +383,7 @@ class StorageOverlayScreen : Screen(Text.literal("")) {
controlComponent,
measurements.controlX, measurements.controlY,
CONTROL_WIDTH, CONTROL_HEIGHT,
- KeyboardEvent.KeyPressed(keyCode, false)
+ KeyboardEvent.KeyPressed(keyCode, scanCode, false)
)
) {
return true
@@ -400,7 +400,7 @@ class StorageOverlayScreen : Screen(Text.literal("")) {
controlComponent,
measurements.controlX, measurements.controlY,
CONTROL_WIDTH, CONTROL_HEIGHT,
- KeyboardEvent.KeyPressed(keyCode, true)
+ KeyboardEvent.KeyPressed(keyCode, scanCode, true)
)
) {
return true
diff --git a/src/main/kotlin/features/mining/MiningBlockInfoUi.kt b/src/main/kotlin/features/mining/MiningBlockInfoUi.kt
index e8ea4f4..5b58d4f 100644
--- a/src/main/kotlin/features/mining/MiningBlockInfoUi.kt
+++ b/src/main/kotlin/features/mining/MiningBlockInfoUi.kt
@@ -2,7 +2,7 @@ package moe.nea.firmament.features.mining
import io.github.notenoughupdates.moulconfig.observer.ObservableList
import io.github.notenoughupdates.moulconfig.observer.Property
-import io.github.notenoughupdates.moulconfig.platform.ModernItemStack
+import io.github.notenoughupdates.moulconfig.platform.MoulConfigPlatform
import io.github.notenoughupdates.moulconfig.xml.Bind
import net.minecraft.client.gui.screen.Screen
import net.minecraft.item.ItemStack
@@ -31,7 +31,7 @@ object MiningBlockInfoUi {
class BlockInfo(val block: MiningRepoData.Block189, val info: MiningInfo) {
@get:Bind("item")
- val item = ModernItemStack.of(block.block?.let { ItemStack(it) } ?: ItemStack.EMPTY)
+ val item = MoulConfigPlatform.wrap(block.block?.let { ItemStack(it) } ?: ItemStack.EMPTY)
@get:Bind("isSelected")
val isSelected get() = info.search.let { block.isActiveIn(SkyBlockIsland.forMode(it)) }
diff --git a/src/main/kotlin/gui/BarComponent.kt b/src/main/kotlin/gui/BarComponent.kt
index 563e159..751ea39 100644
--- a/src/main/kotlin/gui/BarComponent.kt
+++ b/src/main/kotlin/gui/BarComponent.kt
@@ -6,7 +6,8 @@ import io.github.notenoughupdates.moulconfig.common.RenderContext
import io.github.notenoughupdates.moulconfig.gui.GuiComponent
import io.github.notenoughupdates.moulconfig.gui.GuiImmediateContext
import io.github.notenoughupdates.moulconfig.observer.GetSetter
-import io.github.notenoughupdates.moulconfig.platform.ModernRenderContext
+import io.github.notenoughupdates.moulconfig.platform.MoulConfigPlatform
+import io.github.notenoughupdates.moulconfig.platform.MoulConfigRenderContext
import me.shedaniel.math.Color
import net.minecraft.client.gl.RenderPipelines
import net.minecraft.client.gui.DrawContext
@@ -82,7 +83,7 @@ class BarComponent(
}
override fun render(context: GuiImmediateContext) {
- val renderContext = (context.renderContext as ModernRenderContext).drawContext
+ val renderContext = (context.renderContext as MoulConfigRenderContext).drawContext
var i = 0
val x = 0
val y = 0
diff --git a/src/main/kotlin/gui/CheckboxComponent.kt b/src/main/kotlin/gui/CheckboxComponent.kt
index 9baf720..7a9f2ef 100644
--- a/src/main/kotlin/gui/CheckboxComponent.kt
+++ b/src/main/kotlin/gui/CheckboxComponent.kt
@@ -4,7 +4,7 @@ import io.github.notenoughupdates.moulconfig.gui.GuiComponent
import io.github.notenoughupdates.moulconfig.gui.GuiImmediateContext
import io.github.notenoughupdates.moulconfig.gui.MouseEvent
import io.github.notenoughupdates.moulconfig.observer.GetSetter
-import io.github.notenoughupdates.moulconfig.platform.ModernRenderContext
+import io.github.notenoughupdates.moulconfig.platform.MoulConfigRenderContext
import net.minecraft.client.gl.RenderPipelines
import net.minecraft.client.render.RenderLayer
import moe.nea.firmament.Firmament
@@ -26,7 +26,7 @@ class CheckboxComponent<T>(
}
override fun render(context: GuiImmediateContext) {
- val ctx = (context.renderContext as ModernRenderContext).drawContext
+ val ctx = (context.renderContext as MoulConfigRenderContext).drawContext
ctx.drawGuiTexture(
RenderPipelines.GUI_TEXTURED,
if (isEnabled()) Firmament.identifier("widget/checkbox_checked")
diff --git a/src/main/kotlin/gui/FirmHoverComponent.kt b/src/main/kotlin/gui/FirmHoverComponent.kt
index e38582a..eed795a 100644
--- a/src/main/kotlin/gui/FirmHoverComponent.kt
+++ b/src/main/kotlin/gui/FirmHoverComponent.kt
@@ -1,5 +1,6 @@
package moe.nea.firmament.gui
+import io.github.notenoughupdates.moulconfig.common.text.StructuredText
import io.github.notenoughupdates.moulconfig.gui.GuiComponent
import io.github.notenoughupdates.moulconfig.gui.GuiImmediateContext
import io.github.notenoughupdates.moulconfig.gui.KeyboardEvent
@@ -31,7 +32,8 @@ class FirmHoverComponent(
override fun render(context: GuiImmediateContext) {
if (context.isHovered && (permaHover || lastMouseMove.passedTime() > hoverDelay)) {
- context.renderContext.scheduleDrawTooltip(context.mouseX, context.mouseY, hoverLines.get())
+ context.renderContext.scheduleDrawTooltip(context.mouseX, context.mouseY, hoverLines.get()
+ .map { it -> StructuredText.of(it) })
permaHover = true
} else {
permaHover = false
diff --git a/src/main/kotlin/gui/config/DurationHandler.kt b/src/main/kotlin/gui/config/DurationHandler.kt
index 8d485b1..32bec25 100644
--- a/src/main/kotlin/gui/config/DurationHandler.kt
+++ b/src/main/kotlin/gui/config/DurationHandler.kt
@@ -3,6 +3,7 @@
package moe.nea.firmament.gui.config
import io.github.notenoughupdates.moulconfig.common.IMinecraft
+import io.github.notenoughupdates.moulconfig.common.text.StructuredText
import io.github.notenoughupdates.moulconfig.gui.component.RowComponent
import io.github.notenoughupdates.moulconfig.gui.component.SliderComponent
import io.github.notenoughupdates.moulconfig.gui.component.TextComponent
@@ -31,8 +32,8 @@ class DurationHandler(val config: ManagedConfig, val min: Duration, val max: Dur
guiAppender.appendLabeledRow(
opt.labelText,
RowComponent(
- TextComponent(IMinecraft.instance.defaultFontRenderer,
- { FirmFormatters.formatTimespan(opt.value) },
+ TextComponent(IMinecraft.INSTANCE.defaultFontRenderer,
+ { StructuredText.of(FirmFormatters.formatTimespan(opt.value)) },
40,
TextComponent.TextAlignment.CENTER,
true,
diff --git a/src/main/kotlin/gui/config/IntegerHandler.kt b/src/main/kotlin/gui/config/IntegerHandler.kt
index 31ce90f..fd10447 100644
--- a/src/main/kotlin/gui/config/IntegerHandler.kt
+++ b/src/main/kotlin/gui/config/IntegerHandler.kt
@@ -3,6 +3,7 @@
package moe.nea.firmament.gui.config
import io.github.notenoughupdates.moulconfig.common.IMinecraft
+import io.github.notenoughupdates.moulconfig.common.text.StructuredText
import io.github.notenoughupdates.moulconfig.gui.component.RowComponent
import io.github.notenoughupdates.moulconfig.gui.component.SliderComponent
import io.github.notenoughupdates.moulconfig.gui.component.TextComponent
@@ -26,8 +27,8 @@ class IntegerHandler(val config: ManagedConfig, val min: Int, val max: Int) : Ma
guiAppender.appendLabeledRow(
opt.labelText,
RowComponent(
- TextComponent(IMinecraft.instance.defaultFontRenderer,
- { FirmFormatters.formatCommas(opt.value, 0) },
+ TextComponent(IMinecraft.INSTANCE.defaultFontRenderer,
+ { StructuredText.of(FirmFormatters.formatCommas(opt.value, 0)) },
40,
TextComponent.TextAlignment.CENTER,
true,
diff --git a/src/main/kotlin/gui/config/KeyBindingStateManager.kt b/src/main/kotlin/gui/config/KeyBindingStateManager.kt
index 1528ac4..49a4465 100644
--- a/src/main/kotlin/gui/config/KeyBindingStateManager.kt
+++ b/src/main/kotlin/gui/config/KeyBindingStateManager.kt
@@ -6,6 +6,7 @@ import io.github.notenoughupdates.moulconfig.deps.libninepatch.NinePatch
import io.github.notenoughupdates.moulconfig.gui.GuiImmediateContext
import io.github.notenoughupdates.moulconfig.gui.KeyboardEvent
import io.github.notenoughupdates.moulconfig.gui.component.TextComponent
+import io.github.notenoughupdates.moulconfig.platform.MoulConfigPlatform
import org.lwjgl.glfw.GLFW
import net.minecraft.text.Text
import net.minecraft.util.Formatting
@@ -116,8 +117,8 @@ class KeyBindingStateManager(
fun createButton(): FirmButtonComponent {
return object : FirmButtonComponent(
TextComponent(
- IMinecraft.instance.defaultFontRenderer,
- { this@KeyBindingStateManager.label.string },
+ IMinecraft.INSTANCE.defaultFontRenderer,
+ { MoulConfigPlatform.wrap(this@KeyBindingStateManager.label) },
130,
TextComponent.TextAlignment.LEFT,
false,
diff --git a/src/main/kotlin/gui/config/ManagedConfig.kt b/src/main/kotlin/gui/config/ManagedConfig.kt
index 71d8c66..2f4144c 100644
--- a/src/main/kotlin/gui/config/ManagedConfig.kt
+++ b/src/main/kotlin/gui/config/ManagedConfig.kt
@@ -3,7 +3,6 @@ package moe.nea.firmament.gui.config
import com.mojang.serialization.Codec
import io.github.notenoughupdates.moulconfig.ChromaColour
import io.github.notenoughupdates.moulconfig.gui.CloseEventListener
-import io.github.notenoughupdates.moulconfig.gui.GuiComponentWrapper
import io.github.notenoughupdates.moulconfig.gui.GuiContext
import io.github.notenoughupdates.moulconfig.gui.component.CenterComponent
import io.github.notenoughupdates.moulconfig.gui.component.ColumnComponent
@@ -11,6 +10,7 @@ import io.github.notenoughupdates.moulconfig.gui.component.PanelComponent
import io.github.notenoughupdates.moulconfig.gui.component.RowComponent
import io.github.notenoughupdates.moulconfig.gui.component.ScrollPanelComponent
import io.github.notenoughupdates.moulconfig.gui.component.TextComponent
+import io.github.notenoughupdates.moulconfig.platform.MoulConfigScreenComponent
import moe.nea.jarvis.api.Point
import org.joml.Vector2i
import org.lwjgl.glfw.GLFW
@@ -120,7 +120,7 @@ abstract class ManagedConfig(
return option(propertyName, default, BooleanHandler(this))
}
- protected fun colour(propertyName: String, default: ()-> ChromaColour) : ManagedOption<ChromaColour> {
+ protected fun colour(propertyName: String, default: () -> ChromaColour): ManagedOption<ChromaColour> {
return option(propertyName, default, ColourHandler(this))
}
@@ -229,7 +229,8 @@ abstract class ManagedConfig(
var screen: Screen? = null
val guiapp = GuiAppender(400) { requireNotNull(screen) { "Screen Accessor called too early" } }
latestGuiAppender = guiapp
- guiapp.appendFullRow(RowComponent(
+ guiapp.appendFullRow(
+ RowComponent(
FirmButtonComponent(TextComponent("←")) {
if (parent != null) {
save()
@@ -241,12 +242,16 @@ abstract class ManagedConfig(
))
sortedOptions.forEach { it.appendToGui(guiapp) }
guiapp.reloadables.forEach { it() }
- val component = CenterComponent(PanelComponent(ScrollPanelComponent(400, 300, ColumnComponent(guiapp.panel)),
- 10,
- PanelComponent.DefaultBackgroundRenderer.VANILLA))
- screen = object : GuiComponentWrapper(GuiContext(component)) {
+ val component = CenterComponent(
+ PanelComponent(
+ ScrollPanelComponent(400, 300, ColumnComponent(guiapp.panel)),
+ 10,
+ PanelComponent.DefaultBackgroundRenderer.VANILLA
+ )
+ )
+ screen = object : MoulConfigScreenComponent(Text.empty(), GuiContext(component), parent) {
override fun close() {
- if (context.onBeforeClose() == CloseEventListener.CloseAction.NO_OBJECTIONS_TO_CLOSE) {
+ if (guiContext.onBeforeClose() == CloseEventListener.CloseAction.NO_OBJECTIONS_TO_CLOSE) {
client!!.setScreen(parent)
}
}
diff --git a/src/main/kotlin/gui/hud/MoulConfigHud.kt b/src/main/kotlin/gui/hud/MoulConfigHud.kt
index 14b7232..8259ebe 100644
--- a/src/main/kotlin/gui/hud/MoulConfigHud.kt
+++ b/src/main/kotlin/gui/hud/MoulConfigHud.kt
@@ -1,11 +1,11 @@
-
package moe.nea.firmament.gui.hud
-import io.github.notenoughupdates.moulconfig.gui.GuiComponentWrapper
import io.github.notenoughupdates.moulconfig.gui.GuiContext
import io.github.notenoughupdates.moulconfig.gui.component.TextComponent
+import io.github.notenoughupdates.moulconfig.platform.MoulConfigScreenComponent
import net.minecraft.resource.ResourceManager
import net.minecraft.resource.SynchronousResourceReloader
+import net.minecraft.text.Text
import moe.nea.firmament.events.FinalizeResourceManagerEvent
import moe.nea.firmament.events.HudRenderEvent
import moe.nea.firmament.gui.config.HudMeta
@@ -14,55 +14,55 @@ import moe.nea.firmament.util.MC
import moe.nea.firmament.util.MoulConfigUtils
abstract class MoulConfigHud(
- val name: String,
- val hudMeta: HudMeta,
+ val name: String,
+ val hudMeta: HudMeta,
) {
- companion object {
- private val componentWrapper by lazy {
- object : GuiComponentWrapper(GuiContext(TextComponent("§cERROR"))) {
- init {
- this.client = MC.instance
- }
- }
- }
- }
+ companion object {
+ private val componentWrapper by lazy {
+ object : MoulConfigScreenComponent(Text.empty(), GuiContext(TextComponent("§cERROR")), null) {
+ init {
+ this.client = MC.instance
+ }
+ }
+ }
+ }
- private var fragment: GuiContext? = null
+ private var fragment: GuiContext? = null
- fun forceInit() {
- }
+ fun forceInit() {
+ }
- open fun shouldRender(): Boolean {
- return true
- }
+ open fun shouldRender(): Boolean {
+ return true
+ }
- init {
- require(name.matches("^[a-z_/]+$".toRegex()))
- HudRenderEvent.subscribe("MoulConfigHud:render") {
- if (!shouldRender()) return@subscribe
- val renderContext = componentWrapper.createContext(it.context)
- if (fragment == null)
- loadFragment()
- it.context.matrices.pushMatrix()
- hudMeta.applyTransformations(it.context.matrices)
- val pos = hudMeta.getEffectivePosition(JarvisIntegration.jarvis)
+ init {
+ require(name.matches("^[a-z_/]+$".toRegex()))
+ HudRenderEvent.subscribe("MoulConfigHud:render") {
+ if (!shouldRender()) return@subscribe
+ val renderContext = componentWrapper.createContext(it.context)
+ if (fragment == null)
+ loadFragment()
+ it.context.matrices.pushMatrix()
+ hudMeta.applyTransformations(it.context.matrices)
+ val pos = hudMeta.getEffectivePosition(JarvisIntegration.jarvis)
val renderContextTranslated =
- renderContext.translated(pos.x(), pos.y(), hudMeta.effectiveWidth, hudMeta.effectiveHeight)
- .scaled(hudMeta.scale)
- fragment!!.root.render(renderContextTranslated)
- it.context.matrices.popMatrix()
- }
- FinalizeResourceManagerEvent.subscribe("MoulConfigHud:finalizeResourceManager") {
- MC.resourceManager.registerReloader(object : SynchronousResourceReloader {
- override fun reload(manager: ResourceManager?) {
- fragment = null
- }
- })
- }
- }
+ renderContext.translated(pos.x(), pos.y(), hudMeta.effectiveWidth, hudMeta.effectiveHeight)
+ .scaled(hudMeta.scale)
+ fragment!!.root.render(renderContextTranslated)
+ it.context.matrices.popMatrix()
+ }
+ FinalizeResourceManagerEvent.subscribe("MoulConfigHud:finalizeResourceManager") {
+ MC.resourceManager.registerReloader(object : SynchronousResourceReloader {
+ override fun reload(manager: ResourceManager?) {
+ fragment = null
+ }
+ })
+ }
+ }
- fun loadFragment() {
- fragment = MoulConfigUtils.loadGui(name, this)
- }
+ fun loadFragment() {
+ fragment = MoulConfigUtils.loadGui(name, this)
+ }
}
diff --git a/src/main/kotlin/util/FragmentGuiScreen.kt b/src/main/kotlin/util/FragmentGuiScreen.kt
index c4d9ac0..de53ac0 100644
--- a/src/main/kotlin/util/FragmentGuiScreen.kt
+++ b/src/main/kotlin/util/FragmentGuiScreen.kt
@@ -61,7 +61,7 @@ abstract class FragmentGuiScreen(
return ifPopup {
if (!Rectangle(
it.position,
- Dimension(it.context.root.width, it.context.root.height)
+ Dimension(it.guiContext.root.width, it.guiContext.root.height)
).contains(Point(mouseX, mouseY))
&& dismissOnOutOfBounds
) {
diff --git a/src/main/kotlin/util/MC.kt b/src/main/kotlin/util/MC.kt
index d597beb..7ab0cbb 100644
--- a/src/main/kotlin/util/MC.kt
+++ b/src/main/kotlin/util/MC.kt
@@ -1,7 +1,7 @@
package moe.nea.firmament.util
import io.github.moulberry.repo.data.Coordinate
-import io.github.notenoughupdates.moulconfig.gui.GuiComponentWrapper
+import io.github.notenoughupdates.moulconfig.platform.MoulConfigScreenComponent
import java.util.concurrent.ConcurrentLinkedQueue
import kotlin.jvm.optionals.getOrNull
import net.minecraft.client.MinecraftClient
@@ -131,7 +131,7 @@ object MC {
private set
val currentMoulConfigContext
- get() = (screen as? GuiComponentWrapper)?.context
+ get() = (screen as? MoulConfigScreenComponent)?.guiContext
fun openUrl(uri: String) {
Util.getOperatingSystem().open(uri)
diff --git a/src/main/kotlin/util/MoulConfigFragment.kt b/src/main/kotlin/util/MoulConfigFragment.kt
index 1aaea0a..7e7f5db 100644
--- a/src/main/kotlin/util/MoulConfigFragment.kt
+++ b/src/main/kotlin/util/MoulConfigFragment.kt
@@ -1,44 +1,43 @@
-
-
package moe.nea.firmament.util
-import io.github.notenoughupdates.moulconfig.gui.GuiComponentWrapper
import io.github.notenoughupdates.moulconfig.gui.GuiContext
import io.github.notenoughupdates.moulconfig.gui.GuiImmediateContext
+import io.github.notenoughupdates.moulconfig.platform.MoulConfigScreenComponent
import me.shedaniel.math.Point
import net.minecraft.client.gui.DrawContext
+import net.minecraft.text.Text
class MoulConfigFragment(
- context: GuiContext,
- val position: Point,
- val dismiss: () -> Unit
-) : GuiComponentWrapper(context) {
- init {
- this.init(MC.instance, MC.screen!!.width, MC.screen!!.height)
- }
-
- override fun createContext(drawContext: DrawContext?): GuiImmediateContext {
- val oldContext = super.createContext(drawContext)
- return oldContext.translated(
- position.x,
- position.y,
- context.root.width,
- context.root.height,
- )
- }
-
-
- override fun render(drawContext: DrawContext?, i: Int, j: Int, f: Float) {
- val ctx = createContext(drawContext)
- val m = drawContext!!.matrices
- m.pushMatrix()
- m.translate(position.x.toFloat(), position.y.toFloat())
- context.root.render(ctx)
- m.popMatrix()
- ctx.renderContext.renderExtraLayers()
- }
-
- override fun close() {
- dismiss()
- }
+ context: GuiContext,
+ val position: Point,
+ val dismiss: () -> Unit
+) : MoulConfigScreenComponent(Text.empty(), context, null) {
+ init {
+ this.init(MC.instance, MC.screen!!.width, MC.screen!!.height)
+ }
+
+ override fun createContext(drawContext: DrawContext?): GuiImmediateContext {
+ val oldContext = super.createContext(drawContext)
+ return oldContext.translated(
+ position.x,
+ position.y,
+ guiContext.root.width,
+ guiContext.root.height,
+ )
+ }
+
+
+ override fun render(drawContext: DrawContext, i: Int, j: Int, f: Float) {
+ val ctx = createContext(drawContext)
+ val m = drawContext.matrices
+ m.pushMatrix()
+ m.translate(position.x.toFloat(), position.y.toFloat())
+ guiContext.root.render(ctx)
+ m.popMatrix()
+ ctx.renderContext.renderExtraLayers()
+ }
+
+ override fun close() {
+ dismiss()
+ }
}
diff --git a/src/main/kotlin/util/MoulConfigUtils.kt b/src/main/kotlin/util/MoulConfigUtils.kt
index 90cfb3a..2f2fd5c 100644
--- a/src/main/kotlin/util/MoulConfigUtils.kt
+++ b/src/main/kotlin/util/MoulConfigUtils.kt
@@ -4,13 +4,14 @@ import io.github.notenoughupdates.moulconfig.common.IMinecraft
import io.github.notenoughupdates.moulconfig.common.MyResourceLocation
import io.github.notenoughupdates.moulconfig.gui.CloseEventListener
import io.github.notenoughupdates.moulconfig.gui.GuiComponent
-import io.github.notenoughupdates.moulconfig.gui.GuiComponentWrapper
import io.github.notenoughupdates.moulconfig.gui.GuiContext
import io.github.notenoughupdates.moulconfig.gui.GuiImmediateContext
import io.github.notenoughupdates.moulconfig.gui.KeyboardEvent
import io.github.notenoughupdates.moulconfig.gui.MouseEvent
import io.github.notenoughupdates.moulconfig.observer.GetSetter
-import io.github.notenoughupdates.moulconfig.platform.ModernRenderContext
+import io.github.notenoughupdates.moulconfig.platform.MoulConfigPlatform
+import io.github.notenoughupdates.moulconfig.platform.MoulConfigRenderContext
+import io.github.notenoughupdates.moulconfig.platform.MoulConfigScreenComponent
import io.github.notenoughupdates.moulconfig.xml.ChildCount
import io.github.notenoughupdates.moulconfig.xml.XMLContext
import io.github.notenoughupdates.moulconfig.xml.XMLGuiLoader
@@ -26,6 +27,7 @@ import kotlin.time.Duration.Companion.seconds
import net.minecraft.client.gui.DrawContext
import net.minecraft.client.gui.screen.Screen
import net.minecraft.client.util.InputUtil
+import net.minecraft.text.Text
import moe.nea.firmament.gui.BarComponent
import moe.nea.firmament.gui.FirmButtonComponent
import moe.nea.firmament.gui.FirmHoverComponent
@@ -226,9 +228,9 @@ object MoulConfigUtils {
}
fun wrapScreen(guiContext: GuiContext, parent: Screen?, onClose: () -> Unit = {}): Screen {
- return object : GuiComponentWrapper(guiContext) {
+ return object : MoulConfigScreenComponent(Text.empty(), guiContext, null) {
override fun close() {
- if (context.onBeforeClose() == CloseEventListener.CloseAction.NO_OBJECTIONS_TO_CLOSE) {
+ if (guiContext.onBeforeClose() == CloseEventListener.CloseAction.NO_OBJECTIONS_TO_CLOSE) {
client!!.setScreen(parent)
onClose()
}
@@ -264,7 +266,7 @@ object MoulConfigUtils {
h: Int,
keyboardEvent: KeyboardEvent
): Boolean {
- val immContext = createInPlaceFullContext(null, IMinecraft.instance.mouseX, IMinecraft.instance.mouseY)
+ val immContext = createInPlaceFullContext(null, IMinecraft.INSTANCE.mouseX, IMinecraft.INSTANCE.mouseY)
if (component.keyboardEvent(keyboardEvent, immContext.translated(x, y, w, h)))
return true
if (component.context.getFocusedElement() != null) {
@@ -296,8 +298,8 @@ object MoulConfigUtils {
"created moulconfig context with pre-existing translations.",
drawContext?.isUntranslatedGuiDrawContext() != false
)
- val context = drawContext?.let(::ModernRenderContext)
- ?: IMinecraft.instance.provideTopLevelRenderContext()
+ val context = drawContext?.let(::MoulConfigRenderContext)
+ ?: IMinecraft.INSTANCE.provideTopLevelRenderContext()
val immContext = GuiImmediateContext(
context,
0, 0, 0, 0,
diff --git a/src/main/kotlin/util/render/FacingThePlayerContext.kt b/src/main/kotlin/util/render/FacingThePlayerContext.kt
index 0e5788a..76270c5 100644
--- a/src/main/kotlin/util/render/FacingThePlayerContext.kt
+++ b/src/main/kotlin/util/render/FacingThePlayerContext.kt
@@ -1,7 +1,6 @@
package moe.nea.firmament.util.render
-import io.github.notenoughupdates.moulconfig.platform.next
import org.joml.Matrix4f
import util.render.CustomRenderLayers
import net.minecraft.client.font.TextRenderer
@@ -41,14 +40,14 @@ class FacingThePlayerContext(val worldContext: RenderInWorldContext) {
worldContext.vertexConsumers.getBuffer(RenderLayer.getTextBackgroundSeeThrough())
val matrix4f = worldContext.matrixStack.peek().positionMatrix
vertexConsumer.vertex(matrix4f, -1.0f, -1.0f, 0.0f).color(background)
- .light(LightmapTextureManager.MAX_BLOCK_LIGHT_COORDINATE).next()
+ .light(LightmapTextureManager.MAX_BLOCK_LIGHT_COORDINATE)
vertexConsumer.vertex(matrix4f, -1.0f, MC.font.fontHeight.toFloat(), 0.0f).color(background)
- .light(LightmapTextureManager.MAX_BLOCK_LIGHT_COORDINATE).next()
+ .light(LightmapTextureManager.MAX_BLOCK_LIGHT_COORDINATE)
vertexConsumer.vertex(matrix4f, width.toFloat(), MC.font.fontHeight.toFloat(), 0.0f)
.color(background)
- .light(LightmapTextureManager.MAX_BLOCK_LIGHT_COORDINATE).next()
+ .light(LightmapTextureManager.MAX_BLOCK_LIGHT_COORDINATE)
vertexConsumer.vertex(matrix4f, width.toFloat(), -1.0f, 0.0f).color(background)
- .light(LightmapTextureManager.MAX_BLOCK_LIGHT_COORDINATE).next()
+ .light(LightmapTextureManager.MAX_BLOCK_LIGHT_COORDINATE)
worldContext.matrixStack.translate(0F, 0F, 0.01F)
MC.font.draw(
@@ -79,16 +78,16 @@ class FacingThePlayerContext(val worldContext: RenderInWorldContext) {
val matrix4f: Matrix4f = worldContext.matrixStack.peek().positionMatrix
buf.vertex(matrix4f, -hw, -hh, 0F)
.color(-1)
- .texture(u1, v1).next()
+ .texture(u1, v1)
buf.vertex(matrix4f, -hw, +hh, 0F)
.color(-1)
- .texture(u1, v2).next()
+ .texture(u1, v2)
buf.vertex(matrix4f, +hw, +hh, 0F)
.color(-1)
- .texture(u2, v2).next()
+ .texture(u2, v2)
buf.vertex(matrix4f, +hw, -hh, 0F)
.color(-1)
- .texture(u2, v1).next()
+ .texture(u2, v1)
worldContext.vertexConsumers.draw()
}
diff --git a/src/main/kotlin/util/render/RenderCircleProgress.kt b/src/main/kotlin/util/render/RenderCircleProgress.kt
index 2c875f8..efd99fe 100644
--- a/src/main/kotlin/util/render/RenderCircleProgress.kt
+++ b/src/main/kotlin/util/render/RenderCircleProgress.kt
@@ -1,9 +1,6 @@
package moe.nea.firmament.util.render
-import com.mojang.blaze3d.systems.RenderSystem
import com.mojang.blaze3d.vertex.VertexFormat
-import io.github.notenoughupdates.moulconfig.platform.next
-import java.util.OptionalInt
import org.joml.Matrix3x2f
import util.render.CustomRenderLayers
import net.minecraft.client.gui.DrawContext
@@ -14,6 +11,7 @@ import net.minecraft.util.Identifier
import moe.nea.firmament.util.MC
import moe.nea.firmament.util.collections.nonNegligibleSubSectionsAlignedWith
import moe.nea.firmament.util.math.Projections
+import moe.nea.firmament.util.mc.CustomRenderPassHelper
object RenderCircleProgress {
@@ -27,7 +25,7 @@ object RenderCircleProgress {
angleRadians: ClosedFloatingPointRange<Float>,
color: Int = -1,
innerCutoutRadius: Float = 0F
- ) {
+ ) { // TODO: this is fixed by adding a special gui element renderer
val sections = angleRadians.nonNegligibleSubSectionsAlignedWith((τ / 8f).toFloat())
.zipWithNext().toList()
BufferAllocator(layer.vertexFormat.vertexSize * sections.size * 3).use { allocator ->
@@ -45,38 +43,37 @@ object RenderCircleProgress {
.vertex(matrix, secondPoint.x, secondPoint.y, 0F)
.texture(lerp(u1, u2, ilerp(secondPoint.x)), lerp(v1, v2, ilerp(secondPoint.y)))
.color(color)
- .next()
+
bufferBuilder
.vertex(matrix, firstPoint.x, firstPoint.y, 0F)
.texture(lerp(u1, u2, ilerp(firstPoint.x)), lerp(v1, v2, ilerp(firstPoint.y)))
.color(color)
- .next()
+
bufferBuilder
.vertex(matrix, 0F, 0F, 0F)
.texture(lerp(u1, u2, ilerp(0F)), lerp(v1, v2, ilerp(0F)))
.color(color)
- .next()
+
}
bufferBuilder.end().use { buffer ->
- // TODO: write a better utility to pass uniforms :sob: ill even take a mixin at this point
if (innerCutoutRadius <= 0) {
layer.draw(buffer)
return
}
- val vertexBuffer = layer.vertexFormat.uploadImmediateVertexBuffer(buffer.buffer)
- val indexBufferConstructor = RenderSystem.getSequentialBuffer(VertexFormat.DrawMode.TRIANGLES)
- val indexBuffer = indexBufferConstructor.getIndexBuffer(buffer.drawParameters.indexCount)
- RenderSystem.getDevice().createCommandEncoder().createRenderPass(
- { "Firmament Circle Renderer" },
- MC.instance.framebuffer.colorAttachmentView,
- OptionalInt.empty(),
+ CustomRenderPassHelper(
+ { "RenderCircleProgress" },
+ VertexFormat.DrawMode.TRIANGLES,
+ layer.vertexFormat,
+ MC.instance.framebuffer,
+ false,
).use { renderPass ->
+ renderPass.uploadVertices(buffer)
renderPass.setPipeline(layer.pipeline)
-// renderPass.setUniform("InnerCutoutRadius", innerCutoutRadius)
- renderPass.setIndexBuffer(indexBuffer, indexBufferConstructor.indexType)
- renderPass.setVertexBuffer(0, vertexBuffer)
- renderPass.drawIndexed(0, 0, buffer.drawParameters.indexCount, 1)
+ renderPass.setUniform("InnerCutoutRadius", 4) {
+ it.putFloat(innerCutoutRadius)
+ }
+ renderPass.draw()
}
}
}
diff --git a/src/main/kotlin/util/render/RenderInWorldContext.kt b/src/main/kotlin/util/render/RenderInWorldContext.kt
index 29a387b..1077060 100644
--- a/src/main/kotlin/util/render/RenderInWorldContext.kt
+++ b/src/main/kotlin/util/render/RenderInWorldContext.kt
@@ -1,7 +1,6 @@
package moe.nea.firmament.util.render
import com.mojang.blaze3d.systems.RenderSystem
-import io.github.notenoughupdates.moulconfig.platform.next
import java.lang.Math.pow
import org.joml.Matrix4f
import org.joml.Vector3f
@@ -146,11 +145,11 @@ class RenderInWorldContext private constructor(
buffer.vertex(matrix.positionMatrix, a.x.toFloat(), a.y.toFloat(), a.z.toFloat())
.color(-1)
.normal(matrix, lastNormal0.x, lastNormal0.y, lastNormal0.z)
- .next()
+
buffer.vertex(matrix.positionMatrix, b.x.toFloat(), b.y.toFloat(), b.z.toFloat())
.color(-1)
.normal(matrix, normal.x, normal.y, normal.z)
- .next()
+
}
}
@@ -173,11 +172,11 @@ class RenderInWorldContext private constructor(
buf.vertex(matrix.positionMatrix, i, j, k)
.normal(matrix, normal.x, normal.y, normal.z)
.color(-1)
- .next()
+
buf.vertex(matrix.positionMatrix, x, y, z)
.normal(matrix, normal.x, normal.y, normal.z)
.color(-1)
- .next()
+
}