Compare commits
2 Commits
56e2e70a5c
...
cdfa529d7b
Author | SHA1 | Date | |
---|---|---|---|
cdfa529d7b | |||
868cd753d5 |
@ -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)
|
||||
|
@ -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,
|
||||
|
@ -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.
|
||||
@ -213,7 +214,7 @@ abstract class MatteryScreen<T : MatteryMenu>(menu: T, inventory: Inventory, tit
|
||||
if (menu.playerInventorySlots.isNotEmpty() && menu.autoCreateInventoryFrame) {
|
||||
val deviceControls: DeviceControls<MatteryScreen<*>>
|
||||
|
||||
if (menu.player.matteryPlayer?.hasExopack != true) {
|
||||
if (!menu.player.matteryPlayer.hasExopack) {
|
||||
inventoryFrame = FramePanel<MatteryScreen<*>>(this, null, 0f, 0f, INVENTORY_FRAME_WIDTH, INVENTORY_FRAME_HEIGHT, inventory.displayName).also(this::addPanel)
|
||||
inventoryFrame!!.makeHelpButton().addSlotFiltersHelp()
|
||||
|
||||
@ -493,12 +494,12 @@ abstract class MatteryScreen<T : MatteryMenu>(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()
|
||||
}
|
||||
}
|
||||
@ -669,6 +670,13 @@ abstract class MatteryScreen<T : MatteryMenu>(menu: T, inventory: Inventory, tit
|
||||
panels.forEach { it.tickHovered1() }
|
||||
panels.forEach { it.tickHovered2() }
|
||||
|
||||
// EMI workaround for not rendering itself properly, the way JEI does
|
||||
graphics.pose().pushPose()
|
||||
graphics.pose().translate(guiLeft.toFloat(), guiTop.toFloat(), 0f)
|
||||
NeoForge.EVENT_BUS.post(ContainerScreenEvent.Render.Background(this, graphics, mouseX, mouseY))
|
||||
graphics.pose().popPose()
|
||||
RenderSystem.disableDepthTest()
|
||||
|
||||
RenderSystem.defaultBlendFunc()
|
||||
RenderSystem.enableBlend()
|
||||
RenderSystem.enableDepthTest()
|
||||
@ -683,11 +691,6 @@ abstract class MatteryScreen<T : MatteryMenu>(menu: T, inventory: Inventory, tit
|
||||
panelsReversed.any { it.updateCursor1() }
|
||||
|
||||
RenderSystem.depthFunc(GL11.GL_LESS)
|
||||
graphics.pose().pushPose()
|
||||
graphics.pose().translate(guiLeft.toFloat(), guiTop.toFloat(), 0f)
|
||||
NeoForge.EVENT_BUS.post(ContainerScreenEvent.Render.Background(this, graphics, mouseX, mouseY))
|
||||
graphics.pose().popPose()
|
||||
RenderSystem.disableDepthTest()
|
||||
|
||||
// Screen.super.render
|
||||
for (widget in renderables) {
|
||||
@ -696,6 +699,8 @@ abstract class MatteryScreen<T : MatteryMenu>(menu: T, inventory: Inventory, tit
|
||||
// /Screen.super.render
|
||||
|
||||
RenderSystem.disableDepthTest()
|
||||
|
||||
// EMI workaround for not rendering itself properly, the way JEI does
|
||||
graphics.pose().pushPose()
|
||||
graphics.pose().translate(guiLeft.toFloat(), guiTop.toFloat(), 0f)
|
||||
NeoForge.EVENT_BUS.post(ContainerScreenEvent.Render.Foreground(this, graphics, mouseX, mouseY))
|
||||
|
@ -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)
|
||||
|
@ -20,6 +20,7 @@ import ru.dbotthepony.mc.otm.client.CursorType
|
||||
import ru.dbotthepony.mc.otm.client.render.MGUIGraphics
|
||||
import ru.dbotthepony.mc.otm.client.minecraft
|
||||
import ru.dbotthepony.mc.otm.client.moveMousePosScaled
|
||||
import ru.dbotthepony.mc.otm.client.render.RenderGravity
|
||||
import ru.dbotthepony.mc.otm.client.render.currentScissorRect
|
||||
import ru.dbotthepony.mc.otm.client.render.popScissorRect
|
||||
import ru.dbotthepony.mc.otm.client.render.pushScissorRect
|
||||
@ -320,14 +321,32 @@ open class EditablePanel<out S : Screen>(
|
||||
}
|
||||
}
|
||||
|
||||
// Позволяет смещать потомков на эту координату
|
||||
/**
|
||||
* Specifies how to offset ("scroll") children panels on X coordinate
|
||||
*/
|
||||
var xOffset = 0f
|
||||
|
||||
/**
|
||||
* Specifies how to offset ("scroll") children panels on Y coordinate
|
||||
*/
|
||||
var yOffset = 0f
|
||||
|
||||
// Обрезать отрисовку потомков?
|
||||
/**
|
||||
* Push scissor to scissor stack when rendering this panel?
|
||||
*
|
||||
* Useful for when panel calls rendering code which can exceed panel's bounds and this outcome is undesired
|
||||
*/
|
||||
var scissor = false
|
||||
var scissorLock = false
|
||||
|
||||
/**
|
||||
* Extends or shrinks scissor bounds when [scissor] is true
|
||||
*/
|
||||
var scissorPadding = DockProperty.EMPTY
|
||||
|
||||
/**
|
||||
* Automatic panel docking to one of sides
|
||||
*/
|
||||
var dock = Dock.NONE
|
||||
set(value) {
|
||||
if (field != value) {
|
||||
@ -335,6 +354,12 @@ open class EditablePanel<out S : Screen>(
|
||||
parent?.layoutInvalidated = true
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Allows to specify how to resize panel while docking
|
||||
*
|
||||
* If a side does not get resized, panel gets repositioned according to [dockGravity]
|
||||
*/
|
||||
var dockResize = DockResizeMode.ALL
|
||||
set(value) {
|
||||
if (field != value) {
|
||||
@ -342,6 +367,23 @@ open class EditablePanel<out S : Screen>(
|
||||
parent?.layoutInvalidated = true
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Specifies how to handle panel repositioning if there are gaps due to [dockResize] not being [DockResizeMode.ALL]
|
||||
*/
|
||||
var dockGravity = RenderGravity.CENTER_CENTER
|
||||
set(value) {
|
||||
if (field != value) {
|
||||
field = value
|
||||
|
||||
if (dockResize != DockResizeMode.ALL)
|
||||
parent?.layoutInvalidated = true
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Positioning of this panel against docking edges
|
||||
*/
|
||||
var dockMargin = DockProperty.EMPTY
|
||||
set(value) {
|
||||
if (field != value) {
|
||||
@ -386,6 +428,9 @@ open class EditablePanel<out S : Screen>(
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Positioning of children panels against this panel's edges
|
||||
*/
|
||||
var dockPadding = DockProperty.EMPTY
|
||||
set(value) {
|
||||
if (field != value) {
|
||||
@ -1219,7 +1264,7 @@ open class EditablePanel<out S : Screen>(
|
||||
if (child.dockResize.changeHeight)
|
||||
child.height = child.dockedHeight
|
||||
else if (child.height != child.dockedHeight)
|
||||
child.y += (child.dockedHeight / 2f - child.height / 2f).roundToInt().toFloat()
|
||||
child.y += dockGravity.repositionY(child.dockedHeight, child.height).roundToInt().toFloat()
|
||||
}
|
||||
|
||||
Dock.RIGHT -> {
|
||||
@ -1233,7 +1278,7 @@ open class EditablePanel<out S : Screen>(
|
||||
if (child.dockResize.changeHeight)
|
||||
child.height = child.dockedHeight
|
||||
else if (child.height != child.dockedHeight)
|
||||
child.y += (child.dockedHeight / 2f - child.height / 2f).roundToInt().toFloat()
|
||||
child.y += dockGravity.repositionY(child.dockedHeight, child.height).roundToInt().toFloat()
|
||||
}
|
||||
|
||||
Dock.TOP -> {
|
||||
@ -1261,7 +1306,7 @@ open class EditablePanel<out S : Screen>(
|
||||
if (child.dockResize.changeWidth)
|
||||
child.width = child.dockedWidth
|
||||
else if (child.width != child.dockedWidth)
|
||||
child.x += (child.dockedWidth / 2f - child.width / 2f).roundToInt().toFloat()
|
||||
child.x += dockGravity.repositionX(child.dockedWidth, child.width).roundToInt().toFloat()
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1284,12 +1329,12 @@ open class EditablePanel<out S : Screen>(
|
||||
if (child.dockResize.changeHeight)
|
||||
child.height = child.dockedHeight
|
||||
else if (child.height != child.dockedHeight)
|
||||
child.y += child.dockedHeight / 2f - child.height / 2f
|
||||
child.y += dockGravity.repositionY(child.dockedHeight, child.height).roundToInt().toFloat()
|
||||
|
||||
if (child.dockResize.changeWidth)
|
||||
child.width = child.dockedWidth
|
||||
else if (child.width != child.dockedWidth)
|
||||
child.x += child.dockedWidth / 2f - child.width / 2f
|
||||
child.x += dockGravity.repositionX(child.dockedWidth, child.width).roundToInt().toFloat()
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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<BlackHoleGeneratorMenu>(menu, inventory, title) {
|
||||
override fun makeMainFrame(): FramePanel<MatteryScreen<*>> {
|
||||
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
|
||||
}
|
||||
|
@ -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<EnergyHatchMenu>(menu, inventory, title) {
|
||||
override fun makeMainFrame(): FramePanel<MatteryScreen<*>> {
|
||||
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)
|
||||
|
||||
|
@ -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<MatterHatchMenu>(menu, inventory, title) {
|
||||
override fun makeMainFrame(): FramePanel<MatteryScreen<*>> {
|
||||
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)
|
||||
|
||||
|
@ -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<out S : Screen>(
|
||||
screen: S,
|
||||
parent: EditablePanel<*>? = null,
|
||||
widget: LevelGaugeWidget,
|
||||
x: Float = 0f,
|
||||
y: Float = 0f,
|
||||
width: Float = GAUGE_BACKGROUND.width,
|
||||
height: Float = GAUGE_BACKGROUND.height
|
||||
) : MatterGaugePanel<S>(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 <S : Screen> 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<out S : Screen>(
|
||||
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<S>(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 <S : Screen> 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)
|
@ -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) {
|
||||
|
@ -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<out S : Screen> @JvmOverloads constructor(
|
||||
open class MatterGaugePanel<out S : Screen>(
|
||||
screen: S,
|
||||
parent: EditablePanel<*>? = null,
|
||||
val widget: LevelGaugeWidget,
|
||||
x: Float = 0f,
|
||||
y: Float = 0f
|
||||
): EditablePanel<S>(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<S>(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<out S : Screen> @JvmOverloads constructor(
|
||||
|
||||
protected open fun makeTooltip(): MutableList<Either<FormattedText, TooltipComponent>> {
|
||||
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<out S : Screen> @JvmOverloads constructor(
|
||||
open class ProfiledMatterGaugePanel<out S : Screen>(
|
||||
screen: S,
|
||||
parent: EditablePanel<*>? = null,
|
||||
val profiledWidget: ProfiledLevelGaugeWidget<*>,
|
||||
val profiledWidget: IProfiledLevelGaugeWidget,
|
||||
x: Float = 0f,
|
||||
y: Float = 0f
|
||||
): MatterGaugePanel<S>(screen, parent, profiledWidget.gauge, x, y) {
|
||||
y: Float = 0f,
|
||||
width: Float = GAUGE_BACKGROUND.width,
|
||||
height: Float = GAUGE_BACKGROUND.height
|
||||
): MatterGaugePanel<S>(screen, parent, profiledWidget.gauge, x, y, width, height) {
|
||||
override fun makeTooltip(): MutableList<Either<FormattedText, TooltipComponent>> {
|
||||
return super.makeTooltip().also {
|
||||
formatHistory(
|
||||
|
@ -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<out S : Screen>(
|
||||
screen: S,
|
||||
@ -26,7 +25,9 @@ open class PowerGaugePanel<out S : Screen>(
|
||||
height: Float = GAUGE_BACKGROUND.height
|
||||
) : EditablePanel<S>(screen, parent, x, y, width, height) {
|
||||
init {
|
||||
scissor = true
|
||||
// scissor = true
|
||||
dockGravity = RenderGravity.TOP_CENTER
|
||||
dockResize = DockResizeMode.NONE
|
||||
}
|
||||
|
||||
protected open fun makeTooltip(): MutableList<Either<FormattedText, TooltipComponent>> {
|
||||
@ -45,16 +46,16 @@ open class PowerGaugePanel<out S : Screen>(
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
Binary file not shown.
Before Width: | Height: | Size: 234 B After Width: | Height: | Size: 657 B |
Binary file not shown.
Binary file not shown.
Before Width: | Height: | Size: 326 B After Width: | Height: | Size: 1.9 KiB |
Binary file not shown.
Binary file not shown.
Before Width: | Height: | Size: 887 B After Width: | Height: | Size: 1.7 KiB |
Binary file not shown.
Loading…
Reference in New Issue
Block a user