diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/SkinElement.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/SkinElement.kt index d19f37b97..5d90523d8 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/SkinElement.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/SkinElement.kt @@ -5,6 +5,7 @@ import com.mojang.blaze3d.vertex.PoseStack import net.minecraft.resources.ResourceLocation import ru.dbotthepony.mc.otm.client.screen.panels.DockProperty +@Suppress("unused") class SkinGrid( val texture: ResourceLocation, val width: Float, @@ -71,6 +72,23 @@ fun ResourceLocation.pixel( textureHeight: Float = 256f ) = SkinElement(this, x, y, 1f, 1f, textureWidth, textureHeight) +fun ResourceLocation.hLine( + x: Float, + y: Float, + width: Float, + textureWidth: Float = 256f, + textureHeight: Float = 256f +) = SkinElement(this, x, y, width, 1f, textureWidth, textureHeight) + +fun ResourceLocation.vLine( + x: Float, + y: Float, + height: Float, + textureWidth: Float = 256f, + textureHeight: Float = 256f +) = SkinElement(this, x, y, 1f, height, textureWidth, textureHeight) + +@Suppress("unused") class SkinElement @JvmOverloads constructor( val texture: ResourceLocation, val x: Float, @@ -80,6 +98,15 @@ class SkinElement @JvmOverloads constructor( val imageWidth: Float = 256f, val imageHeight: Float = 256f ) { + init { + require(x >= 0f) { "Invalid x $x" } + require(y >= 0f) { "Invalid y $y" } + require(w > 0f) { "Invalid width $w" } + require(h > 0f) { "Invalid height $h" } + require(imageWidth > 0f) { "Invalid image width $imageWidth" } + require(imageHeight > 0f) { "Invalid image height $imageHeight" } + } + @JvmOverloads fun render( stack: PoseStack, diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/AndroidStationScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/AndroidStationScreen.kt index 67aaa490b..46231a05f 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/AndroidStationScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/AndroidStationScreen.kt @@ -23,6 +23,7 @@ import ru.dbotthepony.mc.otm.client.render.drawLine import ru.dbotthepony.mc.otm.client.render.drawRect import ru.dbotthepony.mc.otm.client.screen.panels.* import ru.dbotthepony.mc.otm.client.screen.widget.PowerGaugePanel +import ru.dbotthepony.mc.otm.client.screen.widget.WidePowerGaugePanel import ru.dbotthepony.mc.otm.core.RGBAColor import ru.dbotthepony.mc.otm.ifPresentK import ru.dbotthepony.mc.otm.menu.AndroidStationMenu @@ -477,7 +478,7 @@ class AndroidStationScreen constructor(p_97741_: AndroidStationMenu, p_97742_: I override fun makeMainFrame(): FramePanel { val frame = super.makeMainFrame()!! - PowerGaugePanel(this, frame, menu.powerWidget, LEFT_MARGIN, GAUGE_TOP_WITH_SLOT) + WidePowerGaugePanel(this, frame, menu.powerWidget, LEFT_MARGIN, GAUGE_TOP_WITH_SLOT) SlotPanel(this, frame, menu.batterySlot, LEFT_MARGIN, SLOT_TOP_UNDER_GAUGE) SlotPanel(this, frame, menu.androidBattery, 38f, 17f) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/BatteryBankScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/BatteryBankScreen.kt index 54ca80a92..6ea0a912f 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/BatteryBankScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/BatteryBankScreen.kt @@ -6,6 +6,7 @@ import net.minecraft.world.entity.player.Inventory import ru.dbotthepony.mc.otm.client.screen.panels.FramePanel import ru.dbotthepony.mc.otm.client.screen.panels.SlotPanel import ru.dbotthepony.mc.otm.client.screen.widget.PowerGaugePanel +import ru.dbotthepony.mc.otm.client.screen.widget.WidePowerGaugePanel class BatteryBankScreen(menu: BatteryBankMenu, p_97742_: Inventory, p_97743_: Component) : MatteryScreen(menu, p_97742_, p_97743_) { @@ -13,7 +14,7 @@ class BatteryBankScreen(menu: BatteryBankMenu, p_97742_: Inventory, p_97743_: Co override fun makeMainFrame(): FramePanel{ val frame = super.makeMainFrame()!! - PowerGaugePanel(this, frame, menu.powerLevel, LEFT_MARGIN, GAUGE_TOP_WITHOUT_SLOT) + WidePowerGaugePanel(this, frame, menu.powerLevel, LEFT_MARGIN, GAUGE_TOP_WITHOUT_SLOT) for (i in 0 .. 5) SlotPanel(this, frame, menu.storageSlots[i], 44f + 18 * i, 32f) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/ChemicalGeneratorScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/ChemicalGeneratorScreen.kt index 0583d109f..a07cda9fc 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/ChemicalGeneratorScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/ChemicalGeneratorScreen.kt @@ -6,13 +6,14 @@ import ru.dbotthepony.mc.otm.TranslatableComponent import ru.dbotthepony.mc.otm.client.screen.panels.* import ru.dbotthepony.mc.otm.client.screen.widget.PowerGaugePanel import ru.dbotthepony.mc.otm.client.screen.widget.ProgressGaugePanel +import ru.dbotthepony.mc.otm.client.screen.widget.WidePowerGaugePanel import ru.dbotthepony.mc.otm.menu.ChemicalGeneratorMenu class ChemicalGeneratorScreen(menu: ChemicalGeneratorMenu, inventory: Inventory, title: Component) : MatteryScreen(menu, inventory, title) { override fun makeMainFrame(): FramePanel { val frame = super.makeMainFrame()!! - PowerGaugePanel(this, frame, menu.energy, LEFT_MARGIN, GAUGE_TOP_WITH_SLOT) + WidePowerGaugePanel(this, frame, menu.energy, LEFT_MARGIN, GAUGE_TOP_WITH_SLOT) SlotPanel(this, frame, menu.batterySlot, LEFT_MARGIN, SLOT_TOP_UNDER_GAUGE) val self = this diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/DriveRackScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/DriveRackScreen.kt index 3607e856c..b36a6a69c 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/DriveRackScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/DriveRackScreen.kt @@ -6,6 +6,7 @@ import net.minecraft.world.entity.player.Inventory import ru.dbotthepony.mc.otm.client.screen.panels.FramePanel import ru.dbotthepony.mc.otm.client.screen.panels.SlotPanel import ru.dbotthepony.mc.otm.client.screen.widget.PowerGaugePanel +import ru.dbotthepony.mc.otm.client.screen.widget.WidePowerGaugePanel class DriveRackScreen(menu: DriveRackMenu, inventory: Inventory, title: Component) : MatteryScreen(menu, inventory, title) { @@ -13,7 +14,7 @@ class DriveRackScreen(menu: DriveRackMenu, inventory: Inventory, title: Componen override fun makeMainFrame(): FramePanel { val frame = super.makeMainFrame()!! - PowerGaugePanel(this, frame, menu.powerWidget, LEFT_MARGIN, GAUGE_TOP_WITH_SLOT) + WidePowerGaugePanel(this, frame, menu.powerWidget, LEFT_MARGIN, GAUGE_TOP_WITH_SLOT) SlotPanel(this, frame, menu.batterySlot, LEFT_MARGIN, SLOT_TOP_UNDER_GAUGE) SlotPanel(this, frame, menu.storageSlots[0], 71f, 32f) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/PlatePressScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/PlatePressScreen.kt index cf3fb4d4c..1ba015646 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/PlatePressScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/PlatePressScreen.kt @@ -6,6 +6,7 @@ import ru.dbotthepony.mc.otm.client.screen.panels.FramePanel import ru.dbotthepony.mc.otm.client.screen.panels.SlotPanel import ru.dbotthepony.mc.otm.client.screen.widget.PowerGaugePanel import ru.dbotthepony.mc.otm.client.screen.widget.ProgressGaugePanel +import ru.dbotthepony.mc.otm.client.screen.widget.WidePowerGaugePanel import ru.dbotthepony.mc.otm.menu.PlatePressMenu class PlatePressScreen(menu: PlatePressMenu, inventory: Inventory, title: Component) : @@ -13,7 +14,7 @@ class PlatePressScreen(menu: PlatePressMenu, inventory: Inventory, title: Compon override fun makeMainFrame(): FramePanel { val frame = super.makeMainFrame()!! - PowerGaugePanel(this, frame, menu.powerWidget, LEFT_MARGIN, GAUGE_TOP_WITH_SLOT) + WidePowerGaugePanel(this, frame, menu.powerWidget, LEFT_MARGIN, GAUGE_TOP_WITH_SLOT) SlotPanel(this, frame, menu.batterySlot, LEFT_MARGIN, SLOT_TOP_UNDER_GAUGE) SlotPanel(this, frame, menu.inputSlot, 56f, PROGRESS_SLOT_TOP) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/StorageBusScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/StorageBusScreen.kt index 7a15af8f4..845d3d43a 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/StorageBusScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/StorageBusScreen.kt @@ -8,6 +8,7 @@ import ru.dbotthepony.mc.otm.client.screen.panels.FilterSlotPanel import ru.dbotthepony.mc.otm.client.screen.panels.FramePanel import ru.dbotthepony.mc.otm.client.screen.panels.SlotPanel import ru.dbotthepony.mc.otm.client.screen.widget.PowerGaugePanel +import ru.dbotthepony.mc.otm.client.screen.widget.WidePowerGaugePanel import ru.dbotthepony.mc.otm.menu.StorageBusMenu @@ -16,7 +17,7 @@ class StorageBusScreen(menu: StorageBusMenu, inventory: Inventory, title: Compon override fun makeMainFrame(): FramePanel { val frame = super.makeMainFrame()!! - PowerGaugePanel(this, frame, menu.powerWidget, LEFT_MARGIN, GAUGE_TOP_WITH_SLOT) + WidePowerGaugePanel(this, frame, menu.powerWidget, LEFT_MARGIN, GAUGE_TOP_WITH_SLOT) SlotPanel(this, frame, menu.batterySlot, LEFT_MARGIN, SLOT_TOP_UNDER_GAUGE) for (row in 0 .. 2) { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/StorageExporterScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/StorageExporterScreen.kt index d6db6c394..fc5b57dd1 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/StorageExporterScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/StorageExporterScreen.kt @@ -8,6 +8,7 @@ import ru.dbotthepony.mc.otm.client.screen.panels.FilterSlotPanel import ru.dbotthepony.mc.otm.client.screen.panels.FramePanel import ru.dbotthepony.mc.otm.client.screen.panels.SlotPanel import ru.dbotthepony.mc.otm.client.screen.widget.PowerGaugePanel +import ru.dbotthepony.mc.otm.client.screen.widget.WidePowerGaugePanel import ru.dbotthepony.mc.otm.menu.StorageExporterMenu @@ -16,7 +17,7 @@ class StorageExporterScreen(menu: StorageExporterMenu, inventory: Inventory, tit override fun makeMainFrame(): FramePanel { val frame = super.makeMainFrame()!! - PowerGaugePanel(this, frame, menu.powerWidget, LEFT_MARGIN, GAUGE_TOP_WITH_SLOT) + WidePowerGaugePanel(this, frame, menu.powerWidget, LEFT_MARGIN, GAUGE_TOP_WITH_SLOT) SlotPanel(this, frame, menu.batterySlot, LEFT_MARGIN, SLOT_TOP_UNDER_GAUGE) for (row in 0 .. 2) { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/StorageImporterScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/StorageImporterScreen.kt index ffd545cfd..997156713 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/StorageImporterScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/StorageImporterScreen.kt @@ -8,6 +8,7 @@ import ru.dbotthepony.mc.otm.client.screen.panels.FilterSlotPanel import ru.dbotthepony.mc.otm.client.screen.panels.FramePanel import ru.dbotthepony.mc.otm.client.screen.panels.SlotPanel import ru.dbotthepony.mc.otm.client.screen.widget.PowerGaugePanel +import ru.dbotthepony.mc.otm.client.screen.widget.WidePowerGaugePanel import ru.dbotthepony.mc.otm.menu.StorageImporterMenu @@ -16,7 +17,7 @@ class StorageImporterScreen(menu: StorageImporterMenu, inventory: Inventory, tit override fun makeMainFrame(): FramePanel { val frame = super.makeMainFrame()!! - PowerGaugePanel(this, frame, menu.powerWidget, LEFT_MARGIN, GAUGE_TOP_WITH_SLOT) + WidePowerGaugePanel(this, frame, menu.powerWidget, LEFT_MARGIN, GAUGE_TOP_WITH_SLOT) SlotPanel(this, frame, menu.batterySlot, LEFT_MARGIN, SLOT_TOP_UNDER_GAUGE) for (row in 0 .. 2) { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/StoragePowerSupplierScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/StoragePowerSupplierScreen.kt index fbd4b9d60..057811411 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/StoragePowerSupplierScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/StoragePowerSupplierScreen.kt @@ -5,6 +5,7 @@ import net.minecraft.world.entity.player.Inventory import ru.dbotthepony.mc.otm.TranslatableComponent import ru.dbotthepony.mc.otm.client.screen.panels.* import ru.dbotthepony.mc.otm.client.screen.widget.PowerGaugePanel +import ru.dbotthepony.mc.otm.client.screen.widget.WidePowerGaugePanel import ru.dbotthepony.mc.otm.core.formatPower import ru.dbotthepony.mc.otm.menu.StoragePowerSupplierMenu @@ -14,7 +15,7 @@ class StoragePowerSupplierScreen(menu: StoragePowerSupplierMenu, inventory: Inve override fun makeMainFrame(): FramePanel { val frame = super.makeMainFrame()!! - PowerGaugePanel(this, frame, menu.powerWidget, LEFT_MARGIN, GAUGE_TOP_WITH_SLOT) + WidePowerGaugePanel(this, frame, menu.powerWidget, LEFT_MARGIN, GAUGE_TOP_WITH_SLOT) SlotPanel(this, frame, menu.batterySlot, LEFT_MARGIN, SLOT_TOP_UNDER_GAUGE) object : Label(this@StoragePowerSupplierScreen, frame, 28f, 17f, width = 140f) { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/EditablePanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/EditablePanel.kt index e1e0a4597..3938703bf 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/EditablePanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/EditablePanel.kt @@ -17,6 +17,8 @@ data class ScreenPos(val x: Float, val y: Float) @JvmRecord data class DockProperty @JvmOverloads constructor(val left: Float = 0f, val top: Float = 0f, val right: Float = 0f, val bottom: Float = 0f) { + val isEmpty get() = left == 0f && right == 0f && top == 0f && bottom == 0f + companion object { val EMPTY = DockProperty() } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/widget/Gauges.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/widget/Gauges.kt index fc7901bce..649ccb3b1 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/widget/Gauges.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/widget/Gauges.kt @@ -5,11 +5,8 @@ import com.mojang.blaze3d.vertex.PoseStack import net.minecraft.ChatFormatting import net.minecraft.network.chat.Component import ru.dbotthepony.mc.otm.TranslatableComponent -import ru.dbotthepony.mc.otm.client.render.SkinElement +import ru.dbotthepony.mc.otm.client.render.* import ru.dbotthepony.mc.otm.client.screen.MatteryScreen -import ru.dbotthepony.mc.otm.client.render.UVWindingOrder -import ru.dbotthepony.mc.otm.client.render.WidgetLocation -import ru.dbotthepony.mc.otm.client.render.element import ru.dbotthepony.mc.otm.client.screen.panels.EditablePanel import ru.dbotthepony.mc.otm.core.formatMatterLevel import ru.dbotthepony.mc.otm.core.formatPowerLevel @@ -21,8 +18,10 @@ open class PowerGaugePanel @JvmOverloads constructor( parent: EditablePanel? = null, val widget: LevelGaugeWidget, x: Float = 0f, - y: Float = 0f -): EditablePanel(screen, parent, x, y, width = GAUGE_BACKGROUND.w, height = GAUGE_BACKGROUND.h) { + y: Float = 0f, + width: Float = 9f, + height: Float = 48f +) : EditablePanel(screen, parent, x, y, width, height) { init { scissor = true } @@ -35,9 +34,25 @@ open class PowerGaugePanel @JvmOverloads constructor( } override fun innerRender(stack: PoseStack, mouseX: Float, mouseY: Float, partialTick: Float) { - GAUGE_BACKGROUND.render(stack) val height = this.height * widget.percentage() - GAUGE_FOREGROUND.renderPartial(stack, y = this.height - height, height = height, winding = UVWindingOrder.U0_V1_U1_V0) + + if (width >= 18f) { + GAUGE_BACKGROUND_WIDE.render(stack, width = width, height = this.height) + GAUGE_FOREGROUND_WIDE.renderPartial( + stack, + y = this.height - height, + height = height, + width = width, + winding = UVWindingOrder.U0_V1_U1_V0) + } else { + GAUGE_BACKGROUND.render(stack, width = width, height = this.height) + GAUGE_FOREGROUND.renderPartial( + stack, + y = this.height - height, + height = height, + width = width, + winding = UVWindingOrder.U0_V1_U1_V0) + } } override fun innerRenderTooltips(stack: PoseStack, mouse_x: Float, mouse_y: Float, flag: Float): Boolean { @@ -52,9 +67,25 @@ open class PowerGaugePanel @JvmOverloads constructor( companion object { val GAUGE_BACKGROUND = WidgetLocation.WIDGETS.element(x = 0f, y = 48f, w = 9f, h = 48f) val GAUGE_FOREGROUND = WidgetLocation.WIDGETS.element(x = 9f, y = 48f, w = 9f, h = 48f) + + val GAUGE_BACKGROUND_WIDE = WidgetLocation.WIDGETS.element(x = 238f, y = 0f, w = 18f, h = 48f) + val GAUGE_FOREGROUND_WIDE = WidgetLocation.WIDGETS.element(x = 220f, y = 0f, w = 18f, h = 48f) } } +/** + * Shortcut to [PowerGaugePanel] with doubled width + */ +fun WidePowerGaugePanel( + screen: MatteryScreen<*>, + parent: EditablePanel? = null, + widget: LevelGaugeWidget, + x: Float = 0f, + y: Float = 0f, + width: Float = 18f, + height: Float = 48f +) = PowerGaugePanel(screen, parent, widget, x, y, width, height) + open class MatterGaugePanel @JvmOverloads constructor( screen: MatteryScreen<*>, parent: EditablePanel? = null, diff --git a/src/main/resources/assets/overdrive_that_matters/textures/gui/widgets.png b/src/main/resources/assets/overdrive_that_matters/textures/gui/widgets.png index 18d0611f3..8401ea750 100644 Binary files a/src/main/resources/assets/overdrive_that_matters/textures/gui/widgets.png and b/src/main/resources/assets/overdrive_that_matters/textures/gui/widgets.png differ diff --git a/src/main/resources/assets/overdrive_that_matters/textures/gui/widgets.xcf b/src/main/resources/assets/overdrive_that_matters/textures/gui/widgets.xcf index 2c1e1ad14..a2d1f7936 100644 --- a/src/main/resources/assets/overdrive_that_matters/textures/gui/widgets.xcf +++ b/src/main/resources/assets/overdrive_that_matters/textures/gui/widgets.xcf @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:38fa3dd76b920593331a25e47779cee7a1d3716b57881c3082c7e9f85f16482c -size 45416 +oid sha256:23dae5bfdcdfdd4937f3b107a5553773a0f0c2dc99819e6c07892a0b7a3358df +size 48490