Open fraction classes, put burn time into progress gauge
This commit is contained in:
parent
1f026fd2e1
commit
1ea2361777
@ -1,5 +1,6 @@
|
||||
package ru.dbotthepony.mc.otm.client.screen
|
||||
|
||||
import com.mojang.blaze3d.vertex.PoseStack
|
||||
import net.minecraft.network.chat.Component
|
||||
import net.minecraft.network.chat.TextComponent
|
||||
import net.minecraft.network.chat.TranslatableComponent
|
||||
@ -10,23 +11,26 @@ import ru.dbotthepony.mc.otm.client.screen.widget.ProgressGaugePanel
|
||||
import ru.dbotthepony.mc.otm.menu.ChemicalGeneratorMenu
|
||||
|
||||
class ChemicalGeneratorScreen(menu: ChemicalGeneratorMenu, inventory: Inventory, title: Component) : MatteryScreen<ChemicalGeneratorMenu>(menu, inventory, title) {
|
||||
val burn_time = Label(this, null, TextComponent("GabeN"))
|
||||
|
||||
override fun makeMainFrame(): FramePanel? {
|
||||
val frame = super.makeMainFrame()
|
||||
|
||||
PowerGaugePanel(this, frame, menu.energy, LEFT_MARGIN, GAUGE_TOP_WITH_SLOT)
|
||||
SlotPanel(this, frame, menu.batterySlot, LEFT_MARGIN, SLOT_TOP_UNDER_GAUGE)
|
||||
|
||||
ProgressGaugePanel(this, frame, menu.progress, 63f, PROGRESS_ARROW_TOP).flop = true
|
||||
val self = this
|
||||
val progress = object : ProgressGaugePanel(self, frame, menu.progress, 63f, PROGRESS_ARROW_TOP) {
|
||||
override fun makeTooltip(): MutableList<Component> {
|
||||
val list = super.makeTooltip()
|
||||
|
||||
list.add(TranslatableComponent("otm.gui.power.burn_time", menu.burn_time.value))
|
||||
|
||||
return list
|
||||
}
|
||||
}
|
||||
|
||||
progress.flop = true
|
||||
SlotPanel(this, frame, menu.fuelSlot, 93f, PROGRESS_SLOT_TOP)
|
||||
|
||||
return frame
|
||||
}
|
||||
|
||||
override fun containerTick() {
|
||||
super.containerTick()
|
||||
|
||||
burn_time.text = TranslatableComponent("otm.gui.power.burn_time", menu.burn_time.value)
|
||||
}
|
||||
}
|
||||
|
@ -12,7 +12,7 @@ import ru.dbotthepony.mc.otm.menu.FormattingHelper
|
||||
import ru.dbotthepony.mc.otm.menu.widget.LevelGaugeWidget
|
||||
import ru.dbotthepony.mc.otm.menu.widget.ProgressGaugeWidget
|
||||
|
||||
class PowerGaugePanel @JvmOverloads constructor(
|
||||
open class PowerGaugePanel @JvmOverloads constructor(
|
||||
screen: MatteryScreen<*>,
|
||||
parent: EditablePanel? = null,
|
||||
val widget: LevelGaugeWidget,
|
||||
@ -23,6 +23,13 @@ class PowerGaugePanel @JvmOverloads constructor(
|
||||
scissor = true
|
||||
}
|
||||
|
||||
protected open fun makeTooltip(): MutableList<Component> {
|
||||
return mutableListOf(
|
||||
TranslatableComponent("otm.gui.power.percentage_level", String.format("%.2f", widget.percentage() * 100.0)),
|
||||
FormattingHelper.formatPowerLevel(widget.level(), widget.maxLevel())
|
||||
)
|
||||
}
|
||||
|
||||
override fun innerRender(stack: PoseStack, mouse_x: Float, mouse_y: Float, flag: Float) {
|
||||
GAUGE_BACKGROUND.render(stack)
|
||||
val height = this.height * widget.percentage()
|
||||
@ -31,13 +38,7 @@ class PowerGaugePanel @JvmOverloads constructor(
|
||||
|
||||
override fun innerRenderTooltips(stack: PoseStack, mouse_x: Float, mouse_y: Float, flag: Float): Boolean {
|
||||
if (isHovered) {
|
||||
val tooltip = listOf(
|
||||
TranslatableComponent("otm.gui.power.percentage_level", String.format("%.2f", widget.percentage() * 100.0)),
|
||||
FormattingHelper.formatPowerLevel(widget.level(), widget.maxLevel())
|
||||
)
|
||||
|
||||
screen.renderComponentTooltip(stack, tooltip, mouse_x.toInt(), mouse_y.toInt())
|
||||
|
||||
screen.renderComponentTooltip(stack, makeTooltip(), mouse_x.toInt(), mouse_y.toInt())
|
||||
return true
|
||||
}
|
||||
|
||||
@ -50,7 +51,7 @@ class PowerGaugePanel @JvmOverloads constructor(
|
||||
}
|
||||
}
|
||||
|
||||
class MatterGaugePanel @JvmOverloads constructor(
|
||||
open class MatterGaugePanel @JvmOverloads constructor(
|
||||
screen: MatteryScreen<*>,
|
||||
parent: EditablePanel? = null,
|
||||
val widget: LevelGaugeWidget,
|
||||
@ -61,6 +62,13 @@ class MatterGaugePanel @JvmOverloads constructor(
|
||||
scissor = true
|
||||
}
|
||||
|
||||
protected open fun makeTooltip(): MutableList<Component> {
|
||||
return mutableListOf(
|
||||
TranslatableComponent("otm.gui.matter.percentage_level", String.format("%.2f", widget.percentage() * 100.0)),
|
||||
FormattingHelper.formatMatterLevel(widget.level(), widget.maxLevel())
|
||||
)
|
||||
}
|
||||
|
||||
override fun innerRender(stack: PoseStack, mouse_x: Float, mouse_y: Float, flag: Float) {
|
||||
GAUGE_BACKGROUND.render(stack)
|
||||
val height = this.height * widget.percentage()
|
||||
@ -69,13 +77,7 @@ class MatterGaugePanel @JvmOverloads constructor(
|
||||
|
||||
override fun innerRenderTooltips(stack: PoseStack, mouse_x: Float, mouse_y: Float, flag: Float): Boolean {
|
||||
if (isHovered) {
|
||||
val tooltip = listOf(
|
||||
TranslatableComponent("otm.gui.matter.percentage_level", String.format("%.2f", widget.percentage() * 100.0)),
|
||||
FormattingHelper.formatMatterLevel(widget.level(), widget.maxLevel())
|
||||
)
|
||||
|
||||
screen.renderComponentTooltip(stack, tooltip, mouse_x.toInt(), mouse_y.toInt())
|
||||
|
||||
screen.renderComponentTooltip(stack, makeTooltip(), mouse_x.toInt(), mouse_y.toInt())
|
||||
return true
|
||||
}
|
||||
|
||||
@ -83,12 +85,12 @@ class MatterGaugePanel @JvmOverloads constructor(
|
||||
}
|
||||
|
||||
companion object {
|
||||
val GAUGE_BACKGROUND = SkinElement(image_x = 0f, image_y = 48f, rect_w = 9f, rect_h = 48f)
|
||||
val GAUGE_FOREGROUND = SkinElement(image_x = 9f, image_y = 48f, rect_w = 9f, rect_h = 48f)
|
||||
val GAUGE_BACKGROUND = SkinElement(image_x = 0f, image_y = 0f, rect_w = 9f, rect_h = 48f)
|
||||
val GAUGE_FOREGROUND = SkinElement(image_x = 9f, image_y = 0f, rect_w = 9f, rect_h = 48f)
|
||||
}
|
||||
}
|
||||
|
||||
class PatternGaugePanel @JvmOverloads constructor(
|
||||
open class PatternGaugePanel @JvmOverloads constructor(
|
||||
screen: MatteryScreen<*>,
|
||||
parent: EditablePanel? = null,
|
||||
val widget: LevelGaugeWidget,
|
||||
@ -99,6 +101,13 @@ class PatternGaugePanel @JvmOverloads constructor(
|
||||
scissor = true
|
||||
}
|
||||
|
||||
protected open fun makeTooltip(): MutableList<Component> {
|
||||
return mutableListOf(
|
||||
TranslatableComponent("otm.gui.pattern.percentage_level", String.format("%.2f", widget.percentage() * 100.0)),
|
||||
TranslatableComponent("otm.gui.pattern.format", widget.level().decimalString(), widget.maxLevel().decimalString())
|
||||
)
|
||||
}
|
||||
|
||||
override fun innerRender(stack: PoseStack, mouse_x: Float, mouse_y: Float, flag: Float) {
|
||||
GAUGE_BACKGROUND.render(stack)
|
||||
val height = this.height * widget.percentage()
|
||||
@ -107,13 +116,7 @@ class PatternGaugePanel @JvmOverloads constructor(
|
||||
|
||||
override fun innerRenderTooltips(stack: PoseStack, mouse_x: Float, mouse_y: Float, flag: Float): Boolean {
|
||||
if (isHovered) {
|
||||
val tooltip = listOf(
|
||||
TranslatableComponent("otm.gui.pattern.percentage_level", String.format("%.2f", widget.percentage() * 100.0)),
|
||||
TranslatableComponent("otm.gui.pattern.format", widget.level().decimalString(), widget.maxLevel().decimalString())
|
||||
)
|
||||
|
||||
screen.renderComponentTooltip(stack, tooltip, mouse_x.toInt(), mouse_y.toInt())
|
||||
|
||||
screen.renderComponentTooltip(stack, makeTooltip(), mouse_x.toInt(), mouse_y.toInt())
|
||||
return true
|
||||
}
|
||||
|
||||
@ -126,7 +129,7 @@ class PatternGaugePanel @JvmOverloads constructor(
|
||||
}
|
||||
}
|
||||
|
||||
class ProgressGaugePanel @JvmOverloads constructor(
|
||||
open class ProgressGaugePanel @JvmOverloads constructor(
|
||||
screen: MatteryScreen<*>,
|
||||
parent: EditablePanel? = null,
|
||||
val widget: ProgressGaugeWidget,
|
||||
@ -139,6 +142,29 @@ class ProgressGaugePanel @JvmOverloads constructor(
|
||||
|
||||
var flop = false
|
||||
|
||||
protected open fun makeTooltip(): MutableList<Component> {
|
||||
val tooltip: MutableList<Component>
|
||||
|
||||
if (widget.isStuck()) {
|
||||
tooltip = mutableListOf(
|
||||
TranslatableComponent(
|
||||
"otm.gui.progress_widget",
|
||||
String.format("%.2f", widget.percentage() * 100f)
|
||||
),
|
||||
TranslatableComponent("otm.gui.progress_widget_stuck").withStyle(ChatFormatting.DARK_RED)
|
||||
)
|
||||
} else {
|
||||
tooltip = mutableListOf(
|
||||
TranslatableComponent(
|
||||
"otm.gui.progress_widget",
|
||||
String.format("%.2f", widget.percentage() * 100f)
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
return tooltip
|
||||
}
|
||||
|
||||
override fun innerRender(stack: PoseStack, mouse_x: Float, mouse_y: Float, flag: Float) {
|
||||
if (flop) {
|
||||
GAUGE_BACKGROUND.render(stack, winding = UVWindingOrder.U1_V0_U0_V1)
|
||||
@ -153,27 +179,7 @@ class ProgressGaugePanel @JvmOverloads constructor(
|
||||
|
||||
override fun innerRenderTooltips(stack: PoseStack, mouse_x: Float, mouse_y: Float, flag: Float): Boolean {
|
||||
if (isHovered) {
|
||||
val tooltip: List<Component>
|
||||
|
||||
if (widget.isStuck()) {
|
||||
tooltip = listOf(
|
||||
TranslatableComponent(
|
||||
"otm.gui.progress_widget",
|
||||
String.format("%.2f", widget.percentage() * 100f)
|
||||
),
|
||||
TranslatableComponent("otm.gui.progress_widget_stuck").withStyle(ChatFormatting.DARK_RED)
|
||||
)
|
||||
} else {
|
||||
tooltip = listOf(
|
||||
TranslatableComponent(
|
||||
"otm.gui.progress_widget",
|
||||
String.format("%.2f", widget.percentage() * 100f)
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
screen.renderComponentTooltip(stack, tooltip, mouse_x.toInt(), mouse_y.toInt())
|
||||
|
||||
screen.renderComponentTooltip(stack, makeTooltip(), mouse_x.toInt(), mouse_y.toInt())
|
||||
return true
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user