Updated gauge design, horizontal matter gauge, added missing gauges to menus

This commit is contained in:
DBotThePony 2024-11-05 22:03:11 +07:00
parent 868cd753d5
commit cdfa529d7b
Signed by: DBot
GPG Key ID: DCC23B5715498507
20 changed files with 210 additions and 61 deletions

View File

@ -17,7 +17,7 @@ object WidgetLocation {
val CHECKBOX = MatteryAtlas(ResourceLocation(OverdriveThatMatters.MOD_ID, "textures/gui/widgets/checkbox.png"), 30f, 60f) 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 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 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 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) val SIDE_CONTROLS = MatteryAtlas(ResourceLocation(OverdriveThatMatters.MOD_ID, "textures/gui/widgets/side_controls.png"), 144f, 72f)

View File

@ -90,12 +90,35 @@ sealed class AbstractMatterySprite : IGUIRenderable, IUVCoords {
width: Float = this.width, width: Float = this.width,
height: Float = this.height, height: Float = this.height,
winding: UVWindingOrder = this.winding, 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 u0: Float
val v1 = v0 + linearInterpolation(height / this.height, 0f, v1 - v0) 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( renderTexturedRect(
stack.last().pose(), stack.last().pose(),
@ -113,8 +136,10 @@ sealed class AbstractMatterySprite : IGUIRenderable, IUVCoords {
width: Float = this.width, width: Float = this.width,
height: Float = this.height, height: Float = this.height,
winding: UVWindingOrder = this.winding, winding: UVWindingOrder = this.winding,
color: RGBAColor = RGBAColor.WHITE color: RGBAColor = RGBAColor.WHITE,
) = renderPartial(graphics.pose, x, y, width, height, winding, color) topDown: Boolean = true,
leftRight: Boolean = true,
) = renderPartial(graphics.pose, x, y, width, height, winding, color, topDown, leftRight)
protected fun uploadOnto( protected fun uploadOnto(
pose: PoseStack, pose: PoseStack,

View File

@ -58,6 +58,7 @@ import kotlin.collections.List
import kotlin.collections.MutableSet import kotlin.collections.MutableSet
import kotlin.collections.isNotEmpty import kotlin.collections.isNotEmpty
import kotlin.collections.withIndex import kotlin.collections.withIndex
import kotlin.math.roundToInt
/** /**
* This class encapsulate most of logic for handling EditablePanel and it's children. * This class encapsulate most of logic for handling EditablePanel and it's children.
@ -493,12 +494,12 @@ abstract class MatteryScreen<T : MatteryMenu>(menu: T, inventory: Inventory, tit
} }
if (mainFrame != null) { 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() top += (mainFrame.height + mainFrame.dockMargin.bottom).toInt()
} }
if (inventoryFrame != null) { 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() top += (inventoryFrame.height + inventoryFrame.dockMargin.bottom).toInt()
} }
} }

View File

@ -15,7 +15,7 @@ class MatterCapacitorBankScreen(p_97741_: MatterCapacitorBankMenu, p_97742_: Inv
val frame = super.makeMainFrame()!! val frame = super.makeMainFrame()!!
val m = MatterGaugePanel(this, frame, menu.matterGauge, LEFT_MARGIN, GAUGE_TOP_WITHOUT_SLOT) 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) for (i in 0 .. 5)
MatterCapacitorSlotPanel(this, frame, menu.storageSlots[i], 44f + 18 * i, 32f) MatterCapacitorSlotPanel(this, frame, menu.storageSlots[i], 44f + 18 * i, 32f)

View File

@ -2,11 +2,14 @@ package ru.dbotthepony.mc.otm.client.screen.tech
import net.minecraft.network.chat.Component import net.minecraft.network.chat.Component
import net.minecraft.world.entity.player.Inventory 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.MatteryScreen
import ru.dbotthepony.mc.otm.client.screen.panels.Dock 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.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.panels.FramePanel
import ru.dbotthepony.mc.otm.client.screen.widget.ProfiledMatterGaugePanel 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.TallHorizontalProfiledPowerGaugePanel
import ru.dbotthepony.mc.otm.client.screen.widget.WideProfiledPowerGaugePanel import ru.dbotthepony.mc.otm.client.screen.widget.WideProfiledPowerGaugePanel
import ru.dbotthepony.mc.otm.menu.tech.BlackHoleGeneratorMenu 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) { class BlackHoleGeneratorScreen(menu: BlackHoleGeneratorMenu, inventory: Inventory, title: Component) : MatteryScreen<BlackHoleGeneratorMenu>(menu, inventory, title) {
override fun makeMainFrame(): FramePanel<MatteryScreen<*>> { 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 left = EditablePanel(this, frame)
//val matter = ProfiledMatterGaugePanel
energy.dock = Dock.TOP val energy = ProfiledPowerGaugePanel(this, frame, menu.energy)
energy.dockTop = 4f val matter = ProfiledMatterGaugePanel(this, frame, menu.matter)
energy.dockResize = DockResizeMode.NONE
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 return frame
} }

View File

@ -2,7 +2,6 @@ package ru.dbotthepony.mc.otm.client.screen.tech
import net.minecraft.network.chat.Component import net.minecraft.network.chat.Component
import net.minecraft.world.entity.player.Inventory 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.MatteryScreen
import ru.dbotthepony.mc.otm.client.screen.panels.Dock 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.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.button.DeviceControls
import ru.dbotthepony.mc.otm.client.screen.panels.slot.AbstractSlotPanel 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.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.ProgressGaugePanel
import ru.dbotthepony.mc.otm.client.screen.widget.TallHorizontalProfiledPowerGaugePanel
import ru.dbotthepony.mc.otm.menu.tech.EnergyHatchMenu import ru.dbotthepony.mc.otm.menu.tech.EnergyHatchMenu
class EnergyHatchScreen(menu: EnergyHatchMenu, inventory: Inventory, title: Component) : MatteryScreen<EnergyHatchMenu>(menu, inventory, title) { class EnergyHatchScreen(menu: EnergyHatchMenu, inventory: Inventory, title: Component) : MatteryScreen<EnergyHatchMenu>(menu, inventory, title) {
override fun makeMainFrame(): FramePanel<MatteryScreen<*>> { 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.makeCloseButton()
frame.onClose { onClose() } frame.onClose { onClose() }
for (slot in menu.inputSlots) { val slots = menu.inputSlots.map { slot ->
val panel = BatterySlotPanel(this, frame, slot) val panel = BatterySlotPanel(this, frame, slot)
panel.dock = Dock.LEFT panel.dock = Dock.LEFT
panel.dockResize = DockResizeMode.NONE panel.dockResize = DockResizeMode.NONE
panel
} }
val gauge = TallHorizontalProfiledPowerGaugePanel(this, frame, menu.gauge)
gauge.dock = Dock.RIGHT
val arrow = SpritePanel(this, frame, ProgressGaugePanel.GAUGE_BACKGROUND) val arrow = SpritePanel(this, frame, ProgressGaugePanel.GAUGE_BACKGROUND)
arrow.dockLeft = 20f arrow.dock = Dock.RIGHT
arrow.dockRight = 2f arrow.dockRight = 5f
arrow.dock = Dock.LEFT arrow.dockLeft = 5f
arrow.dockBottom = 1f
arrow.dockResize = DockResizeMode.NONE arrow.dockResize = DockResizeMode.NONE
if (!menu.isInput) if (!menu.isInput) {
arrow.winding = UVWindingOrder.FLOP slots.forEach { it.dock = Dock.RIGHT }
arrow.dock = Dock.LEFT
val gauge = HorizontalProfiledPowerGaugePanel(this, frame, menu.gauge) gauge.dock = Dock.LEFT
gauge.dock = Dock.RIGHT }
DeviceControls(this, frame, redstoneConfig = menu.redstone) DeviceControls(this, frame, redstoneConfig = menu.redstone)

View File

@ -2,7 +2,6 @@ package ru.dbotthepony.mc.otm.client.screen.tech
import net.minecraft.network.chat.Component import net.minecraft.network.chat.Component
import net.minecraft.world.entity.player.Inventory 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.MatteryScreen
import ru.dbotthepony.mc.otm.client.screen.panels.Dock 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.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.button.DeviceControls
import ru.dbotthepony.mc.otm.client.screen.panels.slot.AbstractSlotPanel 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.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.ProgressGaugePanel
import ru.dbotthepony.mc.otm.client.screen.widget.TallHorizontalProfiledMatterGaugePanel
import ru.dbotthepony.mc.otm.menu.tech.MatterHatchMenu import ru.dbotthepony.mc.otm.menu.tech.MatterHatchMenu
class MatterHatchScreen(menu: MatterHatchMenu, inventory: Inventory, title: Component) : MatteryScreen<MatterHatchMenu>(menu, inventory, title) { class MatterHatchScreen(menu: MatterHatchMenu, inventory: Inventory, title: Component) : MatteryScreen<MatterHatchMenu>(menu, inventory, title) {
override fun makeMainFrame(): FramePanel<MatteryScreen<*>> { 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.makeCloseButton()
frame.onClose { onClose() } frame.onClose { onClose() }
for (slot in menu.inputSlots) { val slots = menu.inputSlots.map { slot ->
val panel = MatterCapacitorSlotPanel(this, frame, slot) val panel = MatterCapacitorSlotPanel(this, frame, slot)
panel.dock = Dock.LEFT panel.dock = Dock.LEFT
panel.dockResize = DockResizeMode.NONE panel.dockResize = DockResizeMode.NONE
panel
} }
val gauge = TallHorizontalProfiledMatterGaugePanel(this, frame, menu.gauge)
gauge.dock = Dock.RIGHT
val arrow = SpritePanel(this, frame, ProgressGaugePanel.GAUGE_BACKGROUND) val arrow = SpritePanel(this, frame, ProgressGaugePanel.GAUGE_BACKGROUND)
arrow.dockLeft = 20f arrow.dock = Dock.RIGHT
arrow.dockRight = 2f arrow.dockRight = 5f
arrow.dock = Dock.LEFT arrow.dockLeft = 5f
arrow.dockBottom = 1f
arrow.dockResize = DockResizeMode.NONE arrow.dockResize = DockResizeMode.NONE
if (!menu.isInput) if (!menu.isInput) {
arrow.winding = UVWindingOrder.FLOP slots.forEach { it.dock = Dock.RIGHT }
arrow.dock = Dock.LEFT
gauge.dock = Dock.LEFT
}
DeviceControls(this, frame, redstoneConfig = menu.redstone) DeviceControls(this, frame, redstoneConfig = menu.redstone)

View File

@ -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)

View File

@ -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.client.screen.panels.EditablePanel
import ru.dbotthepony.mc.otm.menu.widget.IProfiledLevelGaugeWidget import ru.dbotthepony.mc.otm.menu.widget.IProfiledLevelGaugeWidget
import ru.dbotthepony.mc.otm.menu.widget.LevelGaugeWidget 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) { private fun PowerGaugePanel<*>.doRender(graphics: MGUIGraphics, mouseX: Float, mouseY: Float, partialTick: Float, flop: Boolean) {
if (height >= 18f) { if (height >= 18f) {

View File

@ -12,14 +12,17 @@ import net.minecraft.world.inventory.tooltip.TooltipComponent
import org.lwjgl.opengl.GL11 import org.lwjgl.opengl.GL11
import ru.dbotthepony.mc.otm.client.ShiftPressedCond import ru.dbotthepony.mc.otm.client.ShiftPressedCond
import ru.dbotthepony.mc.otm.client.render.MGUIGraphics 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.WidgetLocation
import ru.dbotthepony.mc.otm.client.render.tesselator import ru.dbotthepony.mc.otm.client.render.tesselator
import ru.dbotthepony.mc.otm.client.render.uv import ru.dbotthepony.mc.otm.client.render.uv
import ru.dbotthepony.mc.otm.client.render.vertex 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.client.screen.panels.EditablePanel
import ru.dbotthepony.mc.otm.core.TranslatableComponent import ru.dbotthepony.mc.otm.core.TranslatableComponent
import ru.dbotthepony.mc.otm.core.util.formatHistory import ru.dbotthepony.mc.otm.core.util.formatHistory
import ru.dbotthepony.mc.otm.core.util.formatMatterLevel 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.LevelGaugeWidget
import ru.dbotthepony.mc.otm.menu.widget.ProfiledLevelGaugeWidget import ru.dbotthepony.mc.otm.menu.widget.ProfiledLevelGaugeWidget
import ru.dbotthepony.mc.otm.nanoTime import ru.dbotthepony.mc.otm.nanoTime
@ -28,15 +31,19 @@ import kotlin.math.cos
import kotlin.math.pow import kotlin.math.pow
import kotlin.math.sin import kotlin.math.sin
open class MatterGaugePanel<out S : Screen> @JvmOverloads constructor( open class MatterGaugePanel<out S : Screen>(
screen: S, screen: S,
parent: EditablePanel<*>? = null, parent: EditablePanel<*>? = null,
val widget: LevelGaugeWidget, val widget: LevelGaugeWidget,
x: Float = 0f, x: Float = 0f,
y: Float = 0f y: Float = 0f,
): EditablePanel<S>(screen, parent, x, y, width = GAUGE_BACKGROUND.width, height = GAUGE_BACKGROUND.height) { width: Float = GAUGE_BACKGROUND.width,
height: Float = GAUGE_BACKGROUND.height
): EditablePanel<S>(screen, parent, x, y, width = width, height = height) {
init { init {
scissor = true scissor = true
dockGravity = RenderGravity.TOP_CENTER
dockResize = DockResizeMode.NONE
} }
private var wavesStrength = 0.5f 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>> { protected open fun makeTooltip(): MutableList<Either<FormattedText, TooltipComponent>> {
return mutableListOf( return mutableListOf(
Either.left( Either.left(TranslatableComponent("otm.gui.matter.percentage_level", String.format("%.2f", widget.percentage * 100.0))),
TranslatableComponent(
"otm.gui.matter.percentage_level",
String.format("%.2f", widget.percentage * 100.0)
)
),
Either.left(formatMatterLevel(widget.level, widget.maxLevel, formatAsReadable = ShiftPressedCond)) 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>( open class ProfiledMatterGaugePanel<out S : Screen>(
screen: S, screen: S,
parent: EditablePanel<*>? = null, parent: EditablePanel<*>? = null,
val profiledWidget: ProfiledLevelGaugeWidget<*>, val profiledWidget: IProfiledLevelGaugeWidget,
x: Float = 0f, x: Float = 0f,
y: Float = 0f y: Float = 0f,
): MatterGaugePanel<S>(screen, parent, profiledWidget.gauge, x, y) { 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>> { override fun makeTooltip(): MutableList<Either<FormattedText, TooltipComponent>> {
return super.makeTooltip().also { return super.makeTooltip().also {
formatHistory( formatHistory(

View File

@ -2,19 +2,18 @@ package ru.dbotthepony.mc.otm.client.screen.widget
import com.mojang.datafixers.util.Either import com.mojang.datafixers.util.Either
import net.minecraft.client.gui.screens.Screen import net.minecraft.client.gui.screens.Screen
import net.minecraft.network.chat.Component
import net.minecraft.network.chat.FormattedText import net.minecraft.network.chat.FormattedText
import net.minecraft.world.inventory.tooltip.TooltipComponent import net.minecraft.world.inventory.tooltip.TooltipComponent
import ru.dbotthepony.mc.otm.client.render.MGUIGraphics import ru.dbotthepony.mc.otm.client.render.MGUIGraphics
import ru.dbotthepony.mc.otm.client.ShiftPressedCond import ru.dbotthepony.mc.otm.client.ShiftPressedCond
import ru.dbotthepony.mc.otm.core.TranslatableComponent import ru.dbotthepony.mc.otm.core.TranslatableComponent
import ru.dbotthepony.mc.otm.client.render.* 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.client.screen.panels.EditablePanel
import ru.dbotthepony.mc.otm.core.util.formatHistory import ru.dbotthepony.mc.otm.core.util.formatHistory
import ru.dbotthepony.mc.otm.core.util.formatPowerLevel import ru.dbotthepony.mc.otm.core.util.formatPowerLevel
import ru.dbotthepony.mc.otm.menu.widget.IProfiledLevelGaugeWidget import ru.dbotthepony.mc.otm.menu.widget.IProfiledLevelGaugeWidget
import ru.dbotthepony.mc.otm.menu.widget.LevelGaugeWidget import ru.dbotthepony.mc.otm.menu.widget.LevelGaugeWidget
import ru.dbotthepony.mc.otm.menu.widget.ProfiledLevelGaugeWidget
open class PowerGaugePanel<out S : Screen>( open class PowerGaugePanel<out S : Screen>(
screen: S, screen: S,
@ -26,7 +25,9 @@ open class PowerGaugePanel<out S : Screen>(
height: Float = GAUGE_BACKGROUND.height height: Float = GAUGE_BACKGROUND.height
) : EditablePanel<S>(screen, parent, x, y, width, height) { ) : EditablePanel<S>(screen, parent, x, y, width, height) {
init { init {
scissor = true // scissor = true
dockGravity = RenderGravity.TOP_CENTER
dockResize = DockResizeMode.NONE
} }
protected open fun makeTooltip(): MutableList<Either<FormattedText, TooltipComponent>> { protected open fun makeTooltip(): MutableList<Either<FormattedText, TooltipComponent>> {
@ -45,16 +46,16 @@ open class PowerGaugePanel<out S : Screen>(
graphics, graphics,
y = this.height - height, y = this.height - height,
height = height, height = height,
width = width, topDown = false,
winding = UVWindingOrder.U0_V1_U1_V0) width = width,)
} else { } else {
GAUGE_BACKGROUND.render(graphics, canvasWidth = width, canvasHeight = this.height) GAUGE_BACKGROUND.render(graphics, canvasWidth = width, canvasHeight = this.height)
GAUGE_FOREGROUND.renderPartial( GAUGE_FOREGROUND.renderPartial(
graphics, graphics,
y = this.height - height, y = this.height - height,
height = height, height = height,
width = width, topDown = false,
winding = UVWindingOrder.U0_V1_U1_V0) width = width)
} }
} }

View File

@ -1,7 +1,6 @@
package ru.dbotthepony.mc.otm.compat.jei package ru.dbotthepony.mc.otm.compat.jei
import mezz.jei.api.gui.builder.ITooltipBuilder 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.render.MGUIGraphics
import ru.dbotthepony.mc.otm.client.ShiftPressedCond import ru.dbotthepony.mc.otm.client.ShiftPressedCond
import ru.dbotthepony.mc.otm.client.screen.widget.MatterGaugePanel import ru.dbotthepony.mc.otm.client.screen.widget.MatterGaugePanel

View File

@ -9,12 +9,10 @@ import mezz.jei.api.recipe.RecipeType
import mezz.jei.api.recipe.category.IRecipeCategory import mezz.jei.api.recipe.category.IRecipeCategory
import net.minecraft.client.gui.GuiGraphics import net.minecraft.client.gui.GuiGraphics
import net.minecraft.network.chat.Component import net.minecraft.network.chat.Component
import net.minecraft.resources.ResourceLocation
import net.minecraft.world.item.ItemStack import net.minecraft.world.item.ItemStack
import net.minecraft.world.item.crafting.Ingredient import net.minecraft.world.item.crafting.Ingredient
import ru.dbotthepony.mc.otm.OverdriveThatMatters import ru.dbotthepony.mc.otm.OverdriveThatMatters
import ru.dbotthepony.mc.otm.client.render.MGUIGraphics 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.render.RenderGravity
import ru.dbotthepony.mc.otm.client.screen.panels.slot.AbstractSlotPanel import ru.dbotthepony.mc.otm.client.screen.panels.slot.AbstractSlotPanel
import ru.dbotthepony.mc.otm.client.screen.widget.ProgressGaugePanel import ru.dbotthepony.mc.otm.client.screen.widget.ProgressGaugePanel

View File

@ -9,12 +9,10 @@ import mezz.jei.api.recipe.RecipeType
import mezz.jei.api.recipe.category.IRecipeCategory import mezz.jei.api.recipe.category.IRecipeCategory
import net.minecraft.client.gui.GuiGraphics import net.minecraft.client.gui.GuiGraphics
import net.minecraft.network.chat.Component import net.minecraft.network.chat.Component
import net.minecraft.resources.ResourceLocation
import net.minecraft.world.item.ItemStack import net.minecraft.world.item.ItemStack
import net.minecraft.world.item.crafting.Ingredient import net.minecraft.world.item.crafting.Ingredient
import ru.dbotthepony.mc.otm.OverdriveThatMatters import ru.dbotthepony.mc.otm.OverdriveThatMatters
import ru.dbotthepony.mc.otm.client.render.MGUIGraphics 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.render.RenderGravity
import ru.dbotthepony.mc.otm.client.screen.panels.slot.AbstractSlotPanel import ru.dbotthepony.mc.otm.client.screen.panels.slot.AbstractSlotPanel
import ru.dbotthepony.mc.otm.client.screen.widget.ProgressGaugePanel 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.

Before

Width:  |  Height:  |  Size: 326 B

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 887 B

After

Width:  |  Height:  |  Size: 1.7 KiB