diff options
Diffstat (limited to 'src/main/kotlin/features/macros')
| -rw-r--r-- | src/main/kotlin/features/macros/ComboProcessor.kt | 22 | ||||
| -rw-r--r-- | src/main/kotlin/features/macros/HotkeyAction.kt | 8 | ||||
| -rw-r--r-- | src/main/kotlin/features/macros/KeyComboTrie.kt | 10 | ||||
| -rw-r--r-- | src/main/kotlin/features/macros/MacroUI.kt | 8 | ||||
| -rw-r--r-- | src/main/kotlin/features/macros/RadialMenu.kt | 14 |
5 files changed, 31 insertions, 31 deletions
diff --git a/src/main/kotlin/features/macros/ComboProcessor.kt b/src/main/kotlin/features/macros/ComboProcessor.kt index a01f8b7..9dadb80 100644 --- a/src/main/kotlin/features/macros/ComboProcessor.kt +++ b/src/main/kotlin/features/macros/ComboProcessor.kt @@ -1,7 +1,7 @@ package moe.nea.firmament.features.macros import kotlin.time.Duration.Companion.seconds -import net.minecraft.text.Text +import net.minecraft.network.chat.Component import moe.nea.firmament.annotations.Subscribe import moe.nea.firmament.events.HudRenderEvent import moe.nea.firmament.events.TickEvent @@ -46,14 +46,14 @@ object ComboProcessor { fun onRender(event: HudRenderEvent) { if (!isInputting) return if (!event.isRenderingHud) return - event.context.matrices.pushMatrix() + event.context.pose().pushMatrix() val width = 120 - event.context.matrices.translate( - (MC.window.scaledWidth - width) / 2F, - (MC.window.scaledHeight) / 2F + 8 + event.context.pose().translate( + (MC.window.guiScaledWidth - width) / 2F, + (MC.window.guiScaledHeight) / 2F + 8 ) val breadCrumbText = breadCrumbs.joinToString(" > ") - event.context.drawText( + event.context.drawString( MC.font, tr("firmament.combo.active", "Current Combo: ").append(breadCrumbText), 0, @@ -61,19 +61,19 @@ object ComboProcessor { -1, true ) - event.context.matrices.translate(0F, MC.font.fontHeight + 2F) + event.context.pose().translate(0F, MC.font.lineHeight + 2F) for ((key, value) in activeTrie.nodes) { - event.context.drawText( + event.context.drawString( MC.font, - Text.literal("$breadCrumbText > $key: ").append(value.label), + Component.literal("$breadCrumbText > $key: ").append(value.label), 0, 0, -1, true ) - event.context.matrices.translate(0F, MC.font.fontHeight + 1F) + event.context.pose().translate(0F, MC.font.lineHeight + 1F) } - event.context.matrices.popMatrix() + event.context.pose().popMatrix() } @Subscribe diff --git a/src/main/kotlin/features/macros/HotkeyAction.kt b/src/main/kotlin/features/macros/HotkeyAction.kt index 011f797..18c95bc 100644 --- a/src/main/kotlin/features/macros/HotkeyAction.kt +++ b/src/main/kotlin/features/macros/HotkeyAction.kt @@ -2,21 +2,21 @@ package moe.nea.firmament.features.macros import kotlinx.serialization.SerialName import kotlinx.serialization.Serializable -import net.minecraft.text.Text +import net.minecraft.network.chat.Component import moe.nea.firmament.util.MC @Serializable sealed interface HotkeyAction { // TODO: execute - val label: Text + val label: Component fun execute() } @Serializable @SerialName("command") data class CommandAction(val command: String) : HotkeyAction { - override val label: Text - get() = Text.literal("/$command") + override val label: Component + get() = Component.literal("/$command") override fun execute() { MC.sendCommand(command) diff --git a/src/main/kotlin/features/macros/KeyComboTrie.kt b/src/main/kotlin/features/macros/KeyComboTrie.kt index 1983b2e..2701ac1 100644 --- a/src/main/kotlin/features/macros/KeyComboTrie.kt +++ b/src/main/kotlin/features/macros/KeyComboTrie.kt @@ -1,12 +1,12 @@ package moe.nea.firmament.features.macros import kotlinx.serialization.Serializable -import net.minecraft.text.Text +import net.minecraft.network.chat.Component import moe.nea.firmament.keybindings.SavedKeyBinding import moe.nea.firmament.util.ErrorUtil sealed interface KeyComboTrie { - val label: Text + val label: Component companion object { fun fromComboList( @@ -57,7 +57,7 @@ data class ComboKeyAction( ) data class Leaf(val action: HotkeyAction) : KeyComboTrie { - override val label: Text + override val label: Component get() = action.label fun execute() { @@ -68,6 +68,6 @@ data class Leaf(val action: HotkeyAction) : KeyComboTrie { data class Branch( val nodes: Map<SavedKeyBinding, KeyComboTrie> ) : KeyComboTrie { - override val label: Text - get() = Text.literal("...") // TODO: better labels + override val label: Component + get() = Component.literal("...") // TODO: better labels } diff --git a/src/main/kotlin/features/macros/MacroUI.kt b/src/main/kotlin/features/macros/MacroUI.kt index 869466d..e73f076 100644 --- a/src/main/kotlin/features/macros/MacroUI.kt +++ b/src/main/kotlin/features/macros/MacroUI.kt @@ -55,7 +55,7 @@ class MacroUI { fun discard() { dontSave = true - MC.screen?.close() + MC.screen?.onClose() } class Command( @@ -102,7 +102,7 @@ class MacroUI { @Bind fun back() { - MC.screen?.close() + MC.screen?.onClose() } @Bind @@ -169,7 +169,7 @@ class MacroUI { fun saveAndClose() { save() - MC.screen?.close() + MC.screen?.onClose() } inner class Combos { @@ -268,7 +268,7 @@ class MacroUI { @Bind fun back() { - MC.screen?.close() + MC.screen?.onClose() } @Bind diff --git a/src/main/kotlin/features/macros/RadialMenu.kt b/src/main/kotlin/features/macros/RadialMenu.kt index 43e65a7..2519123 100644 --- a/src/main/kotlin/features/macros/RadialMenu.kt +++ b/src/main/kotlin/features/macros/RadialMenu.kt @@ -7,7 +7,7 @@ import kotlin.math.atan2 import kotlin.math.cos import kotlin.math.sin import kotlin.math.sqrt -import net.minecraft.client.gui.DrawContext +import net.minecraft.client.gui.GuiGraphics import moe.nea.firmament.annotations.Subscribe import moe.nea.firmament.events.HudRenderEvent import moe.nea.firmament.events.TickEvent @@ -32,7 +32,7 @@ object RadialMenuViewer { interface RadialMenuOption { val isEnabled: Boolean fun resolve() - fun renderSlice(drawContext: DrawContext) + fun renderSlice(drawContext: GuiGraphics) } var activeMenu: RadialMenu? = null @@ -63,11 +63,11 @@ object RadialMenuViewer { @Subscribe fun onRender(event: HudRenderEvent) { val menu = activeMenu ?: return - val mat = event.context.matrices + val mat = event.context.pose() mat.pushMatrix() mat.translate( - (MC.window.scaledWidth) / 2F, - (MC.window.scaledHeight) / 2F, + (MC.window.guiScaledWidth) / 2F, + (MC.window.guiScaledHeight) / 2F, ) val sliceWidth = (τ / menu.options.size).toFloat() var selectedAngle = wrapAngle(atan2(delta.y, delta.x)) @@ -137,8 +137,8 @@ object RadialMacros { action.execute() } - override fun renderSlice(drawContext: DrawContext) { - drawContext.drawCenteredTextWithShadow(MC.font, action.label, 0, 0, -1) + override fun renderSlice(drawContext: GuiGraphics) { + drawContext.drawCenteredString(MC.font, action.label, 0, 0, -1) } } RadialMenuViewer.activeMenu = object : RadialMenu { |
