BackgroundPanel and better power bar position in item monitor

This commit is contained in:
DBotThePony 2022-09-05 00:31:46 +07:00
parent 72a4d14159
commit 4babe703c7
Signed by: DBot
GPG Key ID: DCC23B5715498507
4 changed files with 71 additions and 8 deletions

View File

@ -15,6 +15,7 @@ import ru.dbotthepony.mc.otm.client.render.Widgets8
import ru.dbotthepony.mc.otm.client.screen.panels.* import ru.dbotthepony.mc.otm.client.screen.panels.*
import ru.dbotthepony.mc.otm.client.screen.widget.ProgressGaugePanel import ru.dbotthepony.mc.otm.client.screen.widget.ProgressGaugePanel
import ru.dbotthepony.mc.otm.client.screen.widget.TallHorizontalPowerGaugePanel import ru.dbotthepony.mc.otm.client.screen.widget.TallHorizontalPowerGaugePanel
import ru.dbotthepony.mc.otm.client.screen.widget.WidePowerGaugePanel
import ru.dbotthepony.mc.otm.core.maxScrollDivision import ru.dbotthepony.mc.otm.core.maxScrollDivision
import ru.dbotthepony.mc.otm.core.formatReadableNumber import ru.dbotthepony.mc.otm.core.formatReadableNumber
import ru.dbotthepony.mc.otm.core.formatSiComponent import ru.dbotthepony.mc.otm.core.formatSiComponent
@ -187,19 +188,24 @@ class ItemMonitorScreen(menu: ItemMonitorMenu, inventory: Inventory, title: Comp
} }
} }
val bottomStrip = EditablePanel(this, frame, height = AbstractSlotPanel.SIZE) val leftStrip = BackgroundPanel.padded(this, frame, width = AbstractSlotPanel.SIZE, height = 1f)
bottomStrip.dock = Dock.BOTTOM
BatterySlotPanel(this, bottomStrip, menu.batterySlot).also { BatterySlotPanel(this, leftStrip, menu.batterySlot).also {
it.dock = Dock.LEFT it.dock = Dock.BOTTOM
it.dockRight = 3f leftStrip.height += it.height
} }
TallHorizontalPowerGaugePanel(this, bottomStrip, menu.powerWidget).also { WidePowerGaugePanel(this, leftStrip, menu.powerWidget).also {
it.dock = Dock.FILL it.dock = Dock.FILL
it.dockResize = DockResizeMode.NONE it.dockResize = DockResizeMode.NONE
leftStrip.height += it.height
} }
leftStrip.height += 3f
leftStrip.x = -leftStrip.width - 2f
leftStrip.y = frame.height - leftStrip.height
return frame return frame
} }

View File

@ -0,0 +1,57 @@
package ru.dbotthepony.mc.otm.client.screen.panels
import com.mojang.blaze3d.vertex.PoseStack
import ru.dbotthepony.mc.otm.client.render.StretchingRectangleElement
import ru.dbotthepony.mc.otm.client.render.WidgetLocation
import ru.dbotthepony.mc.otm.client.render.element
import ru.dbotthepony.mc.otm.client.screen.MatteryScreen
open class BackgroundPanel(
screen: MatteryScreen<*>,
parent: EditablePanel?,
x: Float = 0f,
y: Float = 0f,
width: Float = 10f,
height: Float = 10f,
) : EditablePanel(screen, parent, x, y, width, height) {
init {
dockPadding = DockProperty(3f, 3f, 3f, 3f)
}
override fun innerRender(stack: PoseStack, mouseX: Float, mouseY: Float, partialTick: Float) {
RECTANGLE.render(stack, width = width, height = height)
}
companion object {
fun padded(
screen: MatteryScreen<*>,
parent: EditablePanel?,
x: Float = 0f,
y: Float = 0f,
width: Float = 10f,
height: Float = 10f,
) = BackgroundPanel(screen, parent, x, y, width + 6f, height + 6f)
fun paddedCenter(
screen: MatteryScreen<*>,
parent: EditablePanel?,
x: Float = 0f,
y: Float = 0f,
width: Float = 10f,
height: Float = 10f,
) = BackgroundPanel(screen, parent, x - 3f, y - 3f, width + 6f, height + 6f)
val RECTANGLE = StretchingRectangleElement(
topLeft = WidgetLocation.WIDGETS.element(18f, 24f, 3f, 3f),
topRight = WidgetLocation.WIDGETS.element(27f, 24f, 3f, 3f),
bottomLeft = WidgetLocation.WIDGETS.element(18f, 33f, 3f, 3f),
bottomRight = WidgetLocation.WIDGETS.element(27f, 33f, 3f, 3f),
top = WidgetLocation.WIDGETS.element(21f, 24f, 6f, 2f),
bottom = WidgetLocation.WIDGETS.element(21f, 34f, 6f, 2f),
left = WidgetLocation.WIDGETS.element(18f, 27f, 2f, 6f),
right = WidgetLocation.WIDGETS.element(28f, 27f, 2f, 6f),
middle = WidgetLocation.WIDGETS.element(30f, 12f, 6f, 6f),
padding = DockProperty(-1f, -1f, -1f, -1f)
)
}
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.0 KiB

After

Width:  |  Height:  |  Size: 3.1 KiB