Improve power supplier menu
This commit is contained in:
parent
8df7cf76a8
commit
bc68b9b9ef
@ -53,6 +53,8 @@ private fun misc(provider: MatteryLanguageProvider) {
|
||||
|
||||
gui("exosuit.already_activated", "You already have exosuit following you")
|
||||
|
||||
gui("power_supplier.active_nodes", "Currently demanding nodes: %s")
|
||||
|
||||
misc("battery.single_use", "Single use battery, can not be recharged.")
|
||||
|
||||
misc("exosuit.granted1", "As you keep pressing fingerprint reader, you are getting hurt in finger.")
|
||||
|
@ -4,7 +4,7 @@ import net.minecraft.network.chat.Component
|
||||
import net.minecraft.world.entity.player.Inventory
|
||||
import ru.dbotthepony.mc.otm.core.TranslatableComponent
|
||||
import ru.dbotthepony.mc.otm.client.screen.panels.*
|
||||
import ru.dbotthepony.mc.otm.client.screen.widget.WidePowerGaugePanel
|
||||
import ru.dbotthepony.mc.otm.client.screen.widget.HorizontalPowerGaugePanel
|
||||
import ru.dbotthepony.mc.otm.core.formatPower
|
||||
|
||||
import ru.dbotthepony.mc.otm.menu.StoragePowerSupplierMenu
|
||||
@ -12,12 +12,32 @@ import ru.dbotthepony.mc.otm.menu.StoragePowerSupplierMenu
|
||||
class StoragePowerSupplierScreen(menu: StoragePowerSupplierMenu, inventory: Inventory, title: Component) :
|
||||
MatteryScreen<StoragePowerSupplierMenu>(menu, inventory, title) {
|
||||
override fun makeMainFrame(): FramePanel {
|
||||
val frame = super.makeMainFrame()!!
|
||||
val frame = FramePanel(this, width = 200f, height = 60f, title)
|
||||
|
||||
WidePowerGaugePanel(this, frame, menu.powerWidget, LEFT_MARGIN, GAUGE_TOP_WITH_SLOT)
|
||||
BatterySlotPanel(this, frame, menu.batterySlot, LEFT_MARGIN, SLOT_TOP_UNDER_GAUGE)
|
||||
HorizontalPowerGaugePanel(this, frame, menu.powerWidget).also {
|
||||
it.dock = Dock.BOTTOM
|
||||
it.dockResize = DockResizeMode.NONE
|
||||
}
|
||||
|
||||
val topStrip = EditablePanel(this, frame, height = AbstractSlotPanel.SIZE)
|
||||
|
||||
topStrip.dock = Dock.TOP
|
||||
topStrip.dockTop = 3f
|
||||
|
||||
BatterySlotPanel(this, topStrip, menu.batterySlot).also {
|
||||
it.dock = Dock.LEFT
|
||||
it.dockRight = 3f
|
||||
}
|
||||
|
||||
val labels = EditablePanel(this, topStrip)
|
||||
|
||||
labels.dock = Dock.FILL
|
||||
|
||||
object : Label(this@StoragePowerSupplierScreen, labels) {
|
||||
init {
|
||||
dock = Dock.TOP
|
||||
}
|
||||
|
||||
object : Label(this@StoragePowerSupplierScreen, frame, 28f, 17f, width = 140f) {
|
||||
override fun tick() {
|
||||
super.tick()
|
||||
|
||||
@ -28,6 +48,21 @@ class StoragePowerSupplierScreen(menu: StoragePowerSupplierMenu, inventory: Inve
|
||||
}
|
||||
}
|
||||
|
||||
object : Label(this@StoragePowerSupplierScreen, labels) {
|
||||
init {
|
||||
dock = Dock.TOP
|
||||
}
|
||||
|
||||
override fun tick() {
|
||||
super.tick()
|
||||
|
||||
text = TranslatableComponent(
|
||||
"otm.gui.power_supplier.active_nodes",
|
||||
menu.activeNodes
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
return frame
|
||||
}
|
||||
}
|
||||
|
@ -116,7 +116,7 @@ open class FramePanel(
|
||||
onClose?.run()
|
||||
}
|
||||
|
||||
override fun mouseClickedInner(x: Double, y: Double, flag: Int): Boolean {
|
||||
override fun mouseClickedInner(x: Double, y: Double, button: Int): Boolean {
|
||||
if (isActive) {
|
||||
return true
|
||||
}
|
||||
|
@ -0,0 +1,66 @@
|
||||
package ru.dbotthepony.mc.otm.client.screen.widget
|
||||
|
||||
import com.mojang.blaze3d.vertex.PoseStack
|
||||
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.MatteryScreen
|
||||
import ru.dbotthepony.mc.otm.client.screen.panels.EditablePanel
|
||||
import ru.dbotthepony.mc.otm.menu.widget.LevelGaugeWidget
|
||||
|
||||
open class HorizontalPowerGaugePanel(
|
||||
screen: MatteryScreen<*>,
|
||||
parent: EditablePanel? = null,
|
||||
widget: LevelGaugeWidget,
|
||||
x: Float = 0f,
|
||||
y: Float = 0f,
|
||||
width: Float = GAUGE_BACKGROUND.w,
|
||||
height: Float = GAUGE_BACKGROUND.h
|
||||
) : PowerGaugePanel(screen, parent, widget, x, y, width, height) {
|
||||
var flop = false
|
||||
|
||||
override fun innerRender(stack: PoseStack, mouseX: Float, mouseY: Float, partialTick: Float) {
|
||||
if (height >= 18f) {
|
||||
if (flop) {
|
||||
GAUGE_BACKGROUND_TALL.render(stack, height = height, width = this.width, winding = UVWindingOrder.U1_V0_U0_V1)
|
||||
val width = this.width * widget.percentage()
|
||||
GAUGE_FOREGROUND_TALL.renderPartial(stack, x = this.width - width, height = height, width = width, winding = UVWindingOrder.U1_V0_U0_V1)
|
||||
} else {
|
||||
GAUGE_BACKGROUND_TALL.render(stack, height = height, width = this.width)
|
||||
val width = this.width * widget.percentage()
|
||||
GAUGE_FOREGROUND_TALL.renderPartial(stack, height = height, width = width)
|
||||
}
|
||||
} else {
|
||||
if (flop) {
|
||||
GAUGE_BACKGROUND.render(stack, height = height, width = this.width, winding = UVWindingOrder.U1_V0_U0_V1)
|
||||
val width = this.width * widget.percentage()
|
||||
GAUGE_FOREGROUND.renderPartial(stack, x = this.width - width, height = height, width = width, winding = UVWindingOrder.U1_V0_U0_V1)
|
||||
} else {
|
||||
GAUGE_BACKGROUND.render(stack, height = height, width = this.width)
|
||||
val width = this.width * widget.percentage()
|
||||
GAUGE_FOREGROUND.renderPartial(stack, height = height, width = width)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
companion object {
|
||||
val GAUGE_BACKGROUND = WidgetLocation.WIDGETS.element(x = 160f, y = 238f, w = 96f, h = 9f)
|
||||
val GAUGE_FOREGROUND = WidgetLocation.WIDGETS.element(x = 160f, y = 247f, w = 96f, h = 9f)
|
||||
|
||||
val GAUGE_BACKGROUND_TALL = WidgetLocation.WIDGETS.element(x = 160f, y = 202f, w = 96f, h = 18f)
|
||||
val GAUGE_FOREGROUND_TALL = WidgetLocation.WIDGETS.element(x = 160f, y = 220f, w = 96f, h = 18f)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Shortcut to [HorizontalPowerGaugePanel] with doubled height
|
||||
*/
|
||||
fun TallHorizontalPowerGaugePanel(
|
||||
screen: MatteryScreen<*>,
|
||||
parent: EditablePanel? = null,
|
||||
widget: LevelGaugeWidget,
|
||||
x: Float = 0f,
|
||||
y: Float = 0f,
|
||||
width: Float = HorizontalPowerGaugePanel.GAUGE_BACKGROUND_TALL.w,
|
||||
height: Float = HorizontalPowerGaugePanel.GAUGE_BACKGROUND_TALL.h
|
||||
) = HorizontalPowerGaugePanel(screen, parent, widget, x, y, width, height)
|
@ -15,8 +15,8 @@ open class PowerGaugePanel(
|
||||
val widget: LevelGaugeWidget,
|
||||
x: Float = 0f,
|
||||
y: Float = 0f,
|
||||
width: Float = 9f,
|
||||
height: Float = 48f
|
||||
width: Float = GAUGE_BACKGROUND.w,
|
||||
height: Float = GAUGE_BACKGROUND.h
|
||||
) : EditablePanel(screen, parent, x, y, width, height) {
|
||||
init {
|
||||
scissor = true
|
||||
|
@ -54,13 +54,13 @@ open class ProgressGaugePanel(
|
||||
}
|
||||
|
||||
if (flop) {
|
||||
GAUGE_BACKGROUND.render(stack, winding = UVWindingOrder.U1_V0_U0_V1)
|
||||
GAUGE_BACKGROUND.render(stack, height = height, width = this.width, winding = UVWindingOrder.U1_V0_U0_V1)
|
||||
val width = this.width * widget.percentage()
|
||||
GAUGE_FOREGROUND.renderPartial(stack, x = this.width - width, width = width, winding = UVWindingOrder.U1_V0_U0_V1)
|
||||
GAUGE_FOREGROUND.renderPartial(stack, x = this.width - width, height = height, width = width, winding = UVWindingOrder.U1_V0_U0_V1)
|
||||
} else {
|
||||
GAUGE_BACKGROUND.render(stack)
|
||||
GAUGE_BACKGROUND.render(stack, height = height, width = this.width)
|
||||
val width = this.width * widget.percentage()
|
||||
GAUGE_FOREGROUND.renderPartial(stack, width = width)
|
||||
GAUGE_FOREGROUND.renderPartial(stack, height = height, width = width)
|
||||
}
|
||||
|
||||
if (widget.isStuck() && tick % 40 <= 20) {
|
||||
|
@ -9,10 +9,9 @@ class StoragePowerSupplierMenu @JvmOverloads constructor(
|
||||
p_38852_: Int,
|
||||
inventory: Inventory,
|
||||
tile: StoragePowerSupplierBlockEntity? = null
|
||||
) : MatteryPoweredMenu(
|
||||
MMenus.STORAGE_POWER_SUPPLIER, p_38852_, inventory, tile
|
||||
) {
|
||||
) : MatteryPoweredMenu(MMenus.STORAGE_POWER_SUPPLIER, p_38852_, inventory, tile) {
|
||||
var totalTransferred by mSynchronizer.fraction()
|
||||
var activeNodes by mSynchronizer.int()
|
||||
|
||||
init {
|
||||
addInventorySlots()
|
||||
@ -21,6 +20,7 @@ class StoragePowerSupplierMenu @JvmOverloads constructor(
|
||||
override fun broadcastChanges() {
|
||||
if (tile is StoragePowerSupplierBlockEntity) {
|
||||
totalTransferred = tile.powerSupplied
|
||||
activeNodes = tile.cell.storageGraph?.powerDemandingNodes?.size ?: 0
|
||||
}
|
||||
|
||||
super.broadcastChanges()
|
||||
|
Loading…
Reference in New Issue
Block a user