diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/WidgetLocation.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/WidgetLocation.kt index 17a21e0be..de5df4aeb 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/WidgetLocation.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/WidgetLocation.kt @@ -17,7 +17,7 @@ object WidgetLocation { val CHECKBOX = MatteryAtlas(ResourceLocation(OverdriveThatMatters.MOD_ID, "textures/gui/widgets/checkbox.png"), 30f, 60f) val PROGRESS_ARROWS = MatteryAtlas(ResourceLocation(OverdriveThatMatters.MOD_ID, "textures/gui/widgets/progress_arrows.png"), 22f, 31f) - val HORIZONTAL_GAUGES = MatteryAtlas(ResourceLocation(OverdriveThatMatters.MOD_ID, "textures/gui/widgets/horizontal_gauges.png"), 96f, 54f) + val HORIZONTAL_GAUGES = MatteryAtlas(ResourceLocation(OverdriveThatMatters.MOD_ID, "textures/gui/widgets/horizontal_gauges.png"), 96f, 108f) val VERTICAL_GAUGES = MatteryAtlas(ResourceLocation(OverdriveThatMatters.MOD_ID, "textures/gui/widgets/vertical_gauges.png"), 90f, 48f) val REDSTONE_CONTROLS = MatteryAtlas(ResourceLocation(OverdriveThatMatters.MOD_ID, "textures/gui/widgets/redstone.png"), 54f, 18f) val SIDE_CONTROLS = MatteryAtlas(ResourceLocation(OverdriveThatMatters.MOD_ID, "textures/gui/widgets/side_controls.png"), 144f, 72f) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/sprites/AbstractMatterySprite.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/sprites/AbstractMatterySprite.kt index 3837d5ea6..7ea13e8be 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/sprites/AbstractMatterySprite.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/sprites/AbstractMatterySprite.kt @@ -90,12 +90,35 @@ sealed class AbstractMatterySprite : IGUIRenderable, IUVCoords { width: Float = this.width, height: Float = this.height, winding: UVWindingOrder = this.winding, - color: RGBAColor = RGBAColor.WHITE + color: RGBAColor = RGBAColor.WHITE, + topDown: Boolean = true, + leftRight: Boolean = true, ) { - val u1 = u0 + linearInterpolation(width / this.width, 0f, u1 - u0) - val v1 = v0 + linearInterpolation(height / this.height, 0f, v1 - v0) + val u0: Float + val v0: Float + val u1: Float + val v1: Float - val winded = winding.translate(u0, v0, u1.coerceIn(0f, 1f), v1.coerceIn(0f, 1f)) + val diffV = linearInterpolation((height / this.height).coerceIn(0f, 1f), 0f, this.v1 - this.v0) + val diffU = linearInterpolation((width / this.width).coerceIn(0f, 1f), 0f, this.u1 - this.u0) + + if (topDown) { + v0 = this.v0 + v1 = this.v0 + diffV + } else { + v0 = this.v1 - diffV + v1 = this.v1 + } + + if (leftRight) { + u0 = this.u0 + u1 = this.u0 + diffU + } else { + u0 = this.u1 - diffU + u1 = this.u1 + } + + val winded = winding.translate(u0, v0, u1, v1) renderTexturedRect( stack.last().pose(), @@ -113,8 +136,10 @@ sealed class AbstractMatterySprite : IGUIRenderable, IUVCoords { width: Float = this.width, height: Float = this.height, winding: UVWindingOrder = this.winding, - color: RGBAColor = RGBAColor.WHITE - ) = renderPartial(graphics.pose, x, y, width, height, winding, color) + color: RGBAColor = RGBAColor.WHITE, + topDown: Boolean = true, + leftRight: Boolean = true, + ) = renderPartial(graphics.pose, x, y, width, height, winding, color, topDown, leftRight) protected fun uploadOnto( pose: PoseStack, diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/MatteryScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/MatteryScreen.kt index ee5bb1ad5..ed499337f 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/MatteryScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/MatteryScreen.kt @@ -58,6 +58,7 @@ import kotlin.collections.List import kotlin.collections.MutableSet import kotlin.collections.isNotEmpty import kotlin.collections.withIndex +import kotlin.math.roundToInt /** * This class encapsulate most of logic for handling EditablePanel and it's children. @@ -493,12 +494,12 @@ abstract class MatteryScreen(menu: T, inventory: Inventory, tit } if (mainFrame != null) { - mainFrame.setPos(width / 2 - (mainFrame.width + mainFrame.dockMargin.horizontal) / 2, top.toFloat() + mainFrame.dockMargin.top) + mainFrame.setPos((width / 2 - (mainFrame.width + mainFrame.dockMargin.horizontal) / 2).roundToInt().toFloat(), (top.toFloat() + mainFrame.dockMargin.top).roundToInt().toFloat()) top += (mainFrame.height + mainFrame.dockMargin.bottom).toInt() } if (inventoryFrame != null) { - inventoryFrame.setPos(width / 2 - (inventoryFrame.width + inventoryFrame.dockMargin.horizontal) / 2, top.toFloat() + inventoryFrame.dockMargin.top) + inventoryFrame.setPos((width / 2 - (inventoryFrame.width + inventoryFrame.dockMargin.horizontal) / 2).roundToInt().toFloat(), (top.toFloat() + inventoryFrame.dockMargin.top).roundToInt().toFloat()) top += (inventoryFrame.height + inventoryFrame.dockMargin.bottom).toInt() } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/matter/MatterCapacitorBankScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/matter/MatterCapacitorBankScreen.kt index 0cfb538d2..ce9a0079e 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/matter/MatterCapacitorBankScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/matter/MatterCapacitorBankScreen.kt @@ -15,7 +15,7 @@ class MatterCapacitorBankScreen(p_97741_: MatterCapacitorBankMenu, p_97742_: Inv val frame = super.makeMainFrame()!! val m = MatterGaugePanel(this, frame, menu.matterGauge, LEFT_MARGIN, GAUGE_TOP_WITHOUT_SLOT) - MatterGaugePanel(this, frame, menu.totalMatterGauge, LEFT_MARGIN + m.width, GAUGE_TOP_WITHOUT_SLOT) + MatterGaugePanel(this, frame, menu.totalMatterGauge, LEFT_MARGIN + m.width + 1f, GAUGE_TOP_WITHOUT_SLOT) for (i in 0 .. 5) MatterCapacitorSlotPanel(this, frame, menu.storageSlots[i], 44f + 18 * i, 32f) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/BlackHoleGeneratorScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/BlackHoleGeneratorScreen.kt index 2694b7cff..04fad457e 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/BlackHoleGeneratorScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/BlackHoleGeneratorScreen.kt @@ -2,11 +2,14 @@ package ru.dbotthepony.mc.otm.client.screen.tech import net.minecraft.network.chat.Component import net.minecraft.world.entity.player.Inventory +import ru.dbotthepony.mc.otm.client.render.RenderGravity import ru.dbotthepony.mc.otm.client.screen.MatteryScreen import ru.dbotthepony.mc.otm.client.screen.panels.Dock import ru.dbotthepony.mc.otm.client.screen.panels.DockResizeMode +import ru.dbotthepony.mc.otm.client.screen.panels.EditablePanel import ru.dbotthepony.mc.otm.client.screen.panels.FramePanel import ru.dbotthepony.mc.otm.client.screen.widget.ProfiledMatterGaugePanel +import ru.dbotthepony.mc.otm.client.screen.widget.ProfiledPowerGaugePanel import ru.dbotthepony.mc.otm.client.screen.widget.TallHorizontalProfiledPowerGaugePanel import ru.dbotthepony.mc.otm.client.screen.widget.WideProfiledPowerGaugePanel import ru.dbotthepony.mc.otm.menu.tech.BlackHoleGeneratorMenu @@ -14,14 +17,20 @@ import ru.dbotthepony.mc.otm.menu.tech.CobblerMenu class BlackHoleGeneratorScreen(menu: BlackHoleGeneratorMenu, inventory: Inventory, title: Component) : MatteryScreen(menu, inventory, title) { override fun makeMainFrame(): FramePanel> { - val frame = super.makeMainFrame()!! + val frame = FramePanel.padded(this, 200f, 60f, title) - val energy = TallHorizontalProfiledPowerGaugePanel(this, frame, menu.energy) - //val matter = ProfiledMatterGaugePanel + val left = EditablePanel(this, frame) - energy.dock = Dock.TOP - energy.dockTop = 4f - energy.dockResize = DockResizeMode.NONE + val energy = ProfiledPowerGaugePanel(this, frame, menu.energy) + val matter = ProfiledMatterGaugePanel(this, frame, menu.matter) + + left.width = energy.width + matter.width + 1f + energy.parent = left + matter.parent = left + matter.dockLeft = 1f + left.dock = Dock.LEFT + energy.dock = Dock.LEFT + matter.dock = Dock.LEFT return frame } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/EnergyHatchScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/EnergyHatchScreen.kt index f5af14ae3..fa893117e 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/EnergyHatchScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/EnergyHatchScreen.kt @@ -2,7 +2,6 @@ package ru.dbotthepony.mc.otm.client.screen.tech import net.minecraft.network.chat.Component import net.minecraft.world.entity.player.Inventory -import ru.dbotthepony.mc.otm.client.render.UVWindingOrder import ru.dbotthepony.mc.otm.client.screen.MatteryScreen import ru.dbotthepony.mc.otm.client.screen.panels.Dock import ru.dbotthepony.mc.otm.client.screen.panels.DockResizeMode @@ -11,34 +10,40 @@ import ru.dbotthepony.mc.otm.client.screen.panels.SpritePanel import ru.dbotthepony.mc.otm.client.screen.panels.button.DeviceControls import ru.dbotthepony.mc.otm.client.screen.panels.slot.AbstractSlotPanel import ru.dbotthepony.mc.otm.client.screen.panels.slot.BatterySlotPanel -import ru.dbotthepony.mc.otm.client.screen.widget.HorizontalProfiledPowerGaugePanel +import ru.dbotthepony.mc.otm.client.screen.widget.HorizontalPowerGaugePanel import ru.dbotthepony.mc.otm.client.screen.widget.ProgressGaugePanel +import ru.dbotthepony.mc.otm.client.screen.widget.TallHorizontalProfiledPowerGaugePanel import ru.dbotthepony.mc.otm.menu.tech.EnergyHatchMenu class EnergyHatchScreen(menu: EnergyHatchMenu, inventory: Inventory, title: Component) : MatteryScreen(menu, inventory, title) { override fun makeMainFrame(): FramePanel> { - val frame = FramePanel.padded(this, null, INVENTORY_FRAME_WIDTH, AbstractSlotPanel.SIZE, getTitle()) + val frame = FramePanel.padded(this, null, ProgressGaugePanel.GAUGE_BACKGROUND.width + 10f + HorizontalPowerGaugePanel.GAUGE_BACKGROUND_TALL.width + menu.inputSlots.size * AbstractSlotPanel.SIZE, AbstractSlotPanel.SIZE, getTitle()) frame.makeCloseButton() frame.onClose { onClose() } - for (slot in menu.inputSlots) { + val slots = menu.inputSlots.map { slot -> val panel = BatterySlotPanel(this, frame, slot) panel.dock = Dock.LEFT panel.dockResize = DockResizeMode.NONE + panel } + val gauge = TallHorizontalProfiledPowerGaugePanel(this, frame, menu.gauge) + gauge.dock = Dock.RIGHT + val arrow = SpritePanel(this, frame, ProgressGaugePanel.GAUGE_BACKGROUND) - arrow.dockLeft = 20f - arrow.dockRight = 2f - arrow.dock = Dock.LEFT + arrow.dock = Dock.RIGHT + arrow.dockRight = 5f + arrow.dockLeft = 5f + arrow.dockBottom = 1f arrow.dockResize = DockResizeMode.NONE - if (!menu.isInput) - arrow.winding = UVWindingOrder.FLOP - - val gauge = HorizontalProfiledPowerGaugePanel(this, frame, menu.gauge) - gauge.dock = Dock.RIGHT + if (!menu.isInput) { + slots.forEach { it.dock = Dock.RIGHT } + arrow.dock = Dock.LEFT + gauge.dock = Dock.LEFT + } DeviceControls(this, frame, redstoneConfig = menu.redstone) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/MatterHatchScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/MatterHatchScreen.kt index 9811a2e03..7b5a8bfa6 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/MatterHatchScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/MatterHatchScreen.kt @@ -2,7 +2,6 @@ package ru.dbotthepony.mc.otm.client.screen.tech import net.minecraft.network.chat.Component import net.minecraft.world.entity.player.Inventory -import ru.dbotthepony.mc.otm.client.render.UVWindingOrder import ru.dbotthepony.mc.otm.client.screen.MatteryScreen import ru.dbotthepony.mc.otm.client.screen.panels.Dock import ru.dbotthepony.mc.otm.client.screen.panels.DockResizeMode @@ -11,30 +10,40 @@ import ru.dbotthepony.mc.otm.client.screen.panels.SpritePanel import ru.dbotthepony.mc.otm.client.screen.panels.button.DeviceControls import ru.dbotthepony.mc.otm.client.screen.panels.slot.AbstractSlotPanel import ru.dbotthepony.mc.otm.client.screen.panels.slot.MatterCapacitorSlotPanel +import ru.dbotthepony.mc.otm.client.screen.widget.HorizontalMatterGaugePanel import ru.dbotthepony.mc.otm.client.screen.widget.ProgressGaugePanel +import ru.dbotthepony.mc.otm.client.screen.widget.TallHorizontalProfiledMatterGaugePanel import ru.dbotthepony.mc.otm.menu.tech.MatterHatchMenu class MatterHatchScreen(menu: MatterHatchMenu, inventory: Inventory, title: Component) : MatteryScreen(menu, inventory, title) { override fun makeMainFrame(): FramePanel> { - val frame = FramePanel.padded(this, null, INVENTORY_FRAME_WIDTH, AbstractSlotPanel.SIZE, getTitle()) + val frame = FramePanel.padded(this, null, ProgressGaugePanel.GAUGE_BACKGROUND.width + 10f + HorizontalMatterGaugePanel.GAUGE_BACKGROUND_TALL.width + menu.inputSlots.size * AbstractSlotPanel.SIZE, AbstractSlotPanel.SIZE, getTitle()) frame.makeCloseButton() frame.onClose { onClose() } - for (slot in menu.inputSlots) { + val slots = menu.inputSlots.map { slot -> val panel = MatterCapacitorSlotPanel(this, frame, slot) panel.dock = Dock.LEFT panel.dockResize = DockResizeMode.NONE + panel } + val gauge = TallHorizontalProfiledMatterGaugePanel(this, frame, menu.gauge) + gauge.dock = Dock.RIGHT + val arrow = SpritePanel(this, frame, ProgressGaugePanel.GAUGE_BACKGROUND) - arrow.dockLeft = 20f - arrow.dockRight = 2f - arrow.dock = Dock.LEFT + arrow.dock = Dock.RIGHT + arrow.dockRight = 5f + arrow.dockLeft = 5f + arrow.dockBottom = 1f arrow.dockResize = DockResizeMode.NONE - if (!menu.isInput) - arrow.winding = UVWindingOrder.FLOP + if (!menu.isInput) { + slots.forEach { it.dock = Dock.RIGHT } + arrow.dock = Dock.LEFT + gauge.dock = Dock.LEFT + } DeviceControls(this, frame, redstoneConfig = menu.redstone) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/widget/HorizontalMatterGaugePanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/widget/HorizontalMatterGaugePanel.kt new file mode 100644 index 000000000..3b4e33c75 --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/widget/HorizontalMatterGaugePanel.kt @@ -0,0 +1,101 @@ +package ru.dbotthepony.mc.otm.client.screen.widget + +import net.minecraft.client.gui.screens.Screen +import ru.dbotthepony.mc.otm.client.render.MGUIGraphics +import ru.dbotthepony.mc.otm.client.render.UVWindingOrder +import ru.dbotthepony.mc.otm.client.render.WidgetLocation +import ru.dbotthepony.mc.otm.client.screen.panels.EditablePanel +import ru.dbotthepony.mc.otm.menu.widget.IProfiledLevelGaugeWidget +import ru.dbotthepony.mc.otm.menu.widget.LevelGaugeWidget + +private fun MatterGaugePanel<*>.doRender(graphics: MGUIGraphics, mouseX: Float, mouseY: Float, partialTick: Float, flop: Boolean) { + if (height >= 18f) { + if (flop) { + HorizontalMatterGaugePanel.GAUGE_BACKGROUND_TALL.render(graphics, canvasHeight = height, canvasWidth = this.width, winding = UVWindingOrder.U1_V0_U0_V1) + val width = this.width * widget.percentage + HorizontalMatterGaugePanel.GAUGE_FOREGROUND_TALL.renderPartial(graphics, x = this.width - width, height = height, width = width, winding = UVWindingOrder.U1_V0_U0_V1) + } else { + HorizontalMatterGaugePanel.GAUGE_BACKGROUND_TALL.render(graphics, canvasHeight = height, canvasWidth = this.width) + val width = this.width * widget.percentage + HorizontalMatterGaugePanel.GAUGE_FOREGROUND_TALL.renderPartial(graphics, height = height, width = width) + } + } else { + if (flop) { + HorizontalMatterGaugePanel.GAUGE_BACKGROUND.render(graphics, canvasHeight = height, canvasWidth = this.width, winding = UVWindingOrder.U1_V0_U0_V1) + val width = this.width * widget.percentage + HorizontalMatterGaugePanel.GAUGE_FOREGROUND.renderPartial(graphics, x = this.width - width, height = height, width = width, winding = UVWindingOrder.U1_V0_U0_V1) + } else { + HorizontalMatterGaugePanel.GAUGE_BACKGROUND.render(graphics, canvasHeight = height, canvasWidth = this.width) + val width = this.width * widget.percentage + HorizontalMatterGaugePanel.GAUGE_FOREGROUND.renderPartial(graphics, height = height, width = width) + } + } +} + +open class HorizontalMatterGaugePanel( + screen: S, + parent: EditablePanel<*>? = null, + widget: LevelGaugeWidget, + x: Float = 0f, + y: Float = 0f, + width: Float = GAUGE_BACKGROUND.width, + height: Float = GAUGE_BACKGROUND.height +) : MatterGaugePanel(screen, parent, widget, x, y, width, height) { + var flop = false + + override fun innerRender(graphics: MGUIGraphics, mouseX: Float, mouseY: Float, partialTick: Float) { + doRender(graphics, mouseX, mouseY, partialTick, flop) + } + + companion object { + val GAUGE_BACKGROUND_TALL = WidgetLocation.HORIZONTAL_GAUGES.sprite(width = 96f, height = 18f, y = 54f) + val GAUGE_FOREGROUND_TALL = WidgetLocation.HORIZONTAL_GAUGES.sprite(y = 18f + 54f, width = 96f, height = 18f) + + val GAUGE_BACKGROUND = WidgetLocation.HORIZONTAL_GAUGES.sprite(y = 36f + 54f, width = 96f, height = 9f) + val GAUGE_FOREGROUND = WidgetLocation.HORIZONTAL_GAUGES.sprite(y = 45f + 54f, width = 96f, height = 9f) + } +} + +/** + * Shortcut to [HorizontalMatterGaugePanel] with doubled height + */ +@Suppress("FunctionName") +fun TallHorizontalMatterGaugePanel( + screen: S, + parent: EditablePanel<*>? = null, + widget: LevelGaugeWidget, + x: Float = 0f, + y: Float = 0f, + width: Float = HorizontalMatterGaugePanel.GAUGE_BACKGROUND_TALL.width, + height: Float = HorizontalMatterGaugePanel.GAUGE_BACKGROUND_TALL.height +) = HorizontalMatterGaugePanel(screen, parent, widget, x, y, width, height) + +open class HorizontalProfiledMatterGaugePanel( + screen: S, + parent: EditablePanel<*>? = null, + widget: IProfiledLevelGaugeWidget, + x: Float = 0f, + y: Float = 0f, + width: Float = HorizontalMatterGaugePanel.GAUGE_BACKGROUND.width, + height: Float = HorizontalMatterGaugePanel.GAUGE_BACKGROUND.height +) : ProfiledMatterGaugePanel(screen, parent, widget, x, y, width, height) { + var flop = false + + override fun innerRender(graphics: MGUIGraphics, mouseX: Float, mouseY: Float, partialTick: Float) { + doRender(graphics, mouseX, mouseY, partialTick, flop) + } +} + +/** + * Shortcut to [HorizontalProfiledPowerGaugePanel] with doubled height + */ +@Suppress("FunctionName") +fun TallHorizontalProfiledMatterGaugePanel( + screen: S, + parent: EditablePanel<*>? = null, + widget: IProfiledLevelGaugeWidget, + x: Float = 0f, + y: Float = 0f, + width: Float = HorizontalMatterGaugePanel.GAUGE_BACKGROUND_TALL.width, + height: Float = HorizontalMatterGaugePanel.GAUGE_BACKGROUND_TALL.height +) = HorizontalProfiledMatterGaugePanel(screen, parent, widget, x, y, width, height) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/widget/HorizontalPowerGaugePanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/widget/HorizontalPowerGaugePanel.kt index cc5919e01..ba74f7558 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/widget/HorizontalPowerGaugePanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/widget/HorizontalPowerGaugePanel.kt @@ -7,7 +7,6 @@ import ru.dbotthepony.mc.otm.client.render.WidgetLocation import ru.dbotthepony.mc.otm.client.screen.panels.EditablePanel import ru.dbotthepony.mc.otm.menu.widget.IProfiledLevelGaugeWidget import ru.dbotthepony.mc.otm.menu.widget.LevelGaugeWidget -import ru.dbotthepony.mc.otm.menu.widget.ProfiledLevelGaugeWidget private fun PowerGaugePanel<*>.doRender(graphics: MGUIGraphics, mouseX: Float, mouseY: Float, partialTick: Float, flop: Boolean) { if (height >= 18f) { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/widget/MatterGaugePanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/widget/MatterGaugePanel.kt index cdaa08d57..8fbf9b855 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/widget/MatterGaugePanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/widget/MatterGaugePanel.kt @@ -12,14 +12,17 @@ import net.minecraft.world.inventory.tooltip.TooltipComponent import org.lwjgl.opengl.GL11 import ru.dbotthepony.mc.otm.client.ShiftPressedCond import ru.dbotthepony.mc.otm.client.render.MGUIGraphics +import ru.dbotthepony.mc.otm.client.render.RenderGravity import ru.dbotthepony.mc.otm.client.render.WidgetLocation import ru.dbotthepony.mc.otm.client.render.tesselator import ru.dbotthepony.mc.otm.client.render.uv import ru.dbotthepony.mc.otm.client.render.vertex +import ru.dbotthepony.mc.otm.client.screen.panels.DockResizeMode import ru.dbotthepony.mc.otm.client.screen.panels.EditablePanel import ru.dbotthepony.mc.otm.core.TranslatableComponent import ru.dbotthepony.mc.otm.core.util.formatHistory import ru.dbotthepony.mc.otm.core.util.formatMatterLevel +import ru.dbotthepony.mc.otm.menu.widget.IProfiledLevelGaugeWidget import ru.dbotthepony.mc.otm.menu.widget.LevelGaugeWidget import ru.dbotthepony.mc.otm.menu.widget.ProfiledLevelGaugeWidget import ru.dbotthepony.mc.otm.nanoTime @@ -28,15 +31,19 @@ import kotlin.math.cos import kotlin.math.pow import kotlin.math.sin -open class MatterGaugePanel @JvmOverloads constructor( +open class MatterGaugePanel( screen: S, parent: EditablePanel<*>? = null, val widget: LevelGaugeWidget, x: Float = 0f, - y: Float = 0f -): EditablePanel(screen, parent, x, y, width = GAUGE_BACKGROUND.width, height = GAUGE_BACKGROUND.height) { + y: Float = 0f, + width: Float = GAUGE_BACKGROUND.width, + height: Float = GAUGE_BACKGROUND.height +): EditablePanel(screen, parent, x, y, width = width, height = height) { init { scissor = true + dockGravity = RenderGravity.TOP_CENTER + dockResize = DockResizeMode.NONE } private var wavesStrength = 0.5f @@ -47,12 +54,7 @@ open class MatterGaugePanel @JvmOverloads constructor( protected open fun makeTooltip(): MutableList> { return mutableListOf( - Either.left( - TranslatableComponent( - "otm.gui.matter.percentage_level", - String.format("%.2f", widget.percentage * 100.0) - ) - ), + Either.left(TranslatableComponent("otm.gui.matter.percentage_level", String.format("%.2f", widget.percentage * 100.0))), Either.left(formatMatterLevel(widget.level, widget.maxLevel, formatAsReadable = ShiftPressedCond)) ) } @@ -136,10 +138,12 @@ open class MatterGaugePanel @JvmOverloads constructor( open class ProfiledMatterGaugePanel( screen: S, parent: EditablePanel<*>? = null, - val profiledWidget: ProfiledLevelGaugeWidget<*>, + val profiledWidget: IProfiledLevelGaugeWidget, x: Float = 0f, - y: Float = 0f -): MatterGaugePanel(screen, parent, profiledWidget.gauge, x, y) { + y: Float = 0f, + width: Float = GAUGE_BACKGROUND.width, + height: Float = GAUGE_BACKGROUND.height +): MatterGaugePanel(screen, parent, profiledWidget.gauge, x, y, width, height) { override fun makeTooltip(): MutableList> { return super.makeTooltip().also { formatHistory( diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/widget/PowerGaugePanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/widget/PowerGaugePanel.kt index 817e2a8d0..62d314624 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/widget/PowerGaugePanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/widget/PowerGaugePanel.kt @@ -2,19 +2,18 @@ package ru.dbotthepony.mc.otm.client.screen.widget import com.mojang.datafixers.util.Either import net.minecraft.client.gui.screens.Screen -import net.minecraft.network.chat.Component import net.minecraft.network.chat.FormattedText import net.minecraft.world.inventory.tooltip.TooltipComponent import ru.dbotthepony.mc.otm.client.render.MGUIGraphics import ru.dbotthepony.mc.otm.client.ShiftPressedCond import ru.dbotthepony.mc.otm.core.TranslatableComponent import ru.dbotthepony.mc.otm.client.render.* +import ru.dbotthepony.mc.otm.client.screen.panels.DockResizeMode import ru.dbotthepony.mc.otm.client.screen.panels.EditablePanel import ru.dbotthepony.mc.otm.core.util.formatHistory import ru.dbotthepony.mc.otm.core.util.formatPowerLevel import ru.dbotthepony.mc.otm.menu.widget.IProfiledLevelGaugeWidget import ru.dbotthepony.mc.otm.menu.widget.LevelGaugeWidget -import ru.dbotthepony.mc.otm.menu.widget.ProfiledLevelGaugeWidget open class PowerGaugePanel( screen: S, @@ -26,7 +25,9 @@ open class PowerGaugePanel( height: Float = GAUGE_BACKGROUND.height ) : EditablePanel(screen, parent, x, y, width, height) { init { - scissor = true + // scissor = true + dockGravity = RenderGravity.TOP_CENTER + dockResize = DockResizeMode.NONE } protected open fun makeTooltip(): MutableList> { @@ -45,16 +46,16 @@ open class PowerGaugePanel( graphics, y = this.height - height, height = height, - width = width, - winding = UVWindingOrder.U0_V1_U1_V0) + topDown = false, + width = width,) } else { GAUGE_BACKGROUND.render(graphics, canvasWidth = width, canvasHeight = this.height) GAUGE_FOREGROUND.renderPartial( graphics, y = this.height - height, height = height, - width = width, - winding = UVWindingOrder.U0_V1_U1_V0) + topDown = false, + width = width) } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jei/Gauges.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jei/Gauges.kt index fe82ac6a7..8adf016ca 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jei/Gauges.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jei/Gauges.kt @@ -1,7 +1,6 @@ package ru.dbotthepony.mc.otm.compat.jei import mezz.jei.api.gui.builder.ITooltipBuilder -import net.minecraft.network.chat.Component import ru.dbotthepony.mc.otm.client.render.MGUIGraphics import ru.dbotthepony.mc.otm.client.ShiftPressedCond import ru.dbotthepony.mc.otm.client.screen.widget.MatterGaugePanel diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jei/MicrowaveRecipeCategory.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jei/MicrowaveRecipeCategory.kt index 6cd4b88c7..3f85185ac 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jei/MicrowaveRecipeCategory.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jei/MicrowaveRecipeCategory.kt @@ -9,12 +9,10 @@ import mezz.jei.api.recipe.RecipeType import mezz.jei.api.recipe.category.IRecipeCategory import net.minecraft.client.gui.GuiGraphics import net.minecraft.network.chat.Component -import net.minecraft.resources.ResourceLocation import net.minecraft.world.item.ItemStack import net.minecraft.world.item.crafting.Ingredient import ru.dbotthepony.mc.otm.OverdriveThatMatters import ru.dbotthepony.mc.otm.client.render.MGUIGraphics -import ru.dbotthepony.mc.otm.client.minecraft import ru.dbotthepony.mc.otm.client.render.RenderGravity import ru.dbotthepony.mc.otm.client.screen.panels.slot.AbstractSlotPanel import ru.dbotthepony.mc.otm.client.screen.widget.ProgressGaugePanel diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jei/PlatePressRecipeCategory.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jei/PlatePressRecipeCategory.kt index 32613840e..21a57cb2d 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jei/PlatePressRecipeCategory.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jei/PlatePressRecipeCategory.kt @@ -9,12 +9,10 @@ import mezz.jei.api.recipe.RecipeType import mezz.jei.api.recipe.category.IRecipeCategory import net.minecraft.client.gui.GuiGraphics import net.minecraft.network.chat.Component -import net.minecraft.resources.ResourceLocation import net.minecraft.world.item.ItemStack import net.minecraft.world.item.crafting.Ingredient import ru.dbotthepony.mc.otm.OverdriveThatMatters import ru.dbotthepony.mc.otm.client.render.MGUIGraphics -import ru.dbotthepony.mc.otm.client.minecraft import ru.dbotthepony.mc.otm.client.render.RenderGravity import ru.dbotthepony.mc.otm.client.screen.panels.slot.AbstractSlotPanel import ru.dbotthepony.mc.otm.client.screen.widget.ProgressGaugePanel diff --git a/src/main/resources/assets/overdrive_that_matters/textures/gui/player_bars.png b/src/main/resources/assets/overdrive_that_matters/textures/gui/player_bars.png index bd9894af7..f5a48258f 100644 Binary files a/src/main/resources/assets/overdrive_that_matters/textures/gui/player_bars.png and b/src/main/resources/assets/overdrive_that_matters/textures/gui/player_bars.png differ diff --git a/src/main/resources/assets/overdrive_that_matters/textures/gui/player_bars.xcf b/src/main/resources/assets/overdrive_that_matters/textures/gui/player_bars.xcf new file mode 100644 index 000000000..8455c0916 Binary files /dev/null and b/src/main/resources/assets/overdrive_that_matters/textures/gui/player_bars.xcf differ diff --git a/src/main/resources/assets/overdrive_that_matters/textures/gui/widgets/horizontal_gauges.png b/src/main/resources/assets/overdrive_that_matters/textures/gui/widgets/horizontal_gauges.png index 699161318..d46b418e8 100644 Binary files a/src/main/resources/assets/overdrive_that_matters/textures/gui/widgets/horizontal_gauges.png and b/src/main/resources/assets/overdrive_that_matters/textures/gui/widgets/horizontal_gauges.png differ diff --git a/src/main/resources/assets/overdrive_that_matters/textures/gui/widgets/horizontal_gauges.xcf b/src/main/resources/assets/overdrive_that_matters/textures/gui/widgets/horizontal_gauges.xcf new file mode 100644 index 000000000..1f388e517 Binary files /dev/null and b/src/main/resources/assets/overdrive_that_matters/textures/gui/widgets/horizontal_gauges.xcf differ diff --git a/src/main/resources/assets/overdrive_that_matters/textures/gui/widgets/vertical_gauges.png b/src/main/resources/assets/overdrive_that_matters/textures/gui/widgets/vertical_gauges.png index c981a8143..d8239e949 100644 Binary files a/src/main/resources/assets/overdrive_that_matters/textures/gui/widgets/vertical_gauges.png and b/src/main/resources/assets/overdrive_that_matters/textures/gui/widgets/vertical_gauges.png differ diff --git a/src/main/resources/assets/overdrive_that_matters/textures/gui/widgets/vertical_gauges.xcf b/src/main/resources/assets/overdrive_that_matters/textures/gui/widgets/vertical_gauges.xcf new file mode 100644 index 000000000..93ae3d208 Binary files /dev/null and b/src/main/resources/assets/overdrive_that_matters/textures/gui/widgets/vertical_gauges.xcf differ