Frame panel help button, panel post render, more straightforward tooltips
This commit is contained in:
parent
a3c794271f
commit
344364520d
@ -117,6 +117,8 @@ private fun sounds(provider: MatteryLanguageProvider) {
|
||||
|
||||
private fun misc(provider: MatteryLanguageProvider) {
|
||||
with(provider.english) {
|
||||
gui("help.slot_filters", "Hold CTRL to setup slot filters")
|
||||
|
||||
misc("needs_no_power", "Requires no power to operate")
|
||||
|
||||
gui("lock_holo_screen", "Lock contents")
|
||||
|
@ -125,6 +125,8 @@ private fun sounds(provider: MatteryLanguageProvider) {
|
||||
|
||||
private fun misc(provider: MatteryLanguageProvider) {
|
||||
with(provider.russian) {
|
||||
gui("help.slot_filters", "Удерживайте CTRL для настройки фильтрации слотов")
|
||||
|
||||
misc("needs_no_power", "Не требует энергии для работы")
|
||||
|
||||
gui("lock_holo_screen", "Заблокировать содержимое")
|
||||
|
@ -98,7 +98,7 @@ private fun inventoryLogic(event: ScreenEvent.Init.Post) {
|
||||
minecraft.setScreen(ExoPackInventoryScreen(player.exoPackMenu))
|
||||
|
||||
InputConstants.grabOrReleaseMouse(minecraft.window.window, 212993, mouseX, mouseY)
|
||||
}).also { it.tooltip = TranslatableComponent("otm.gui.exopack.go_in") })
|
||||
}).also { it.tooltips.add(TranslatableComponent("otm.gui.exopack.go_in")) })
|
||||
|
||||
event.addListener(widget)
|
||||
|
||||
|
@ -1,6 +1,5 @@
|
||||
package ru.dbotthepony.mc.otm.client.screen
|
||||
|
||||
import net.minecraft.client.gui.GuiGraphics
|
||||
import net.minecraft.client.gui.screens.inventory.InventoryScreen
|
||||
import net.minecraft.world.item.ItemStack
|
||||
import net.minecraft.world.item.Items
|
||||
@ -19,15 +18,12 @@ import ru.dbotthepony.mc.otm.client.screen.panels.slot.SlotPanel
|
||||
import ru.dbotthepony.mc.otm.client.screen.panels.util.BackgroundPanel
|
||||
import ru.dbotthepony.mc.otm.client.screen.panels.util.DiscreteScrollBarPanel
|
||||
import ru.dbotthepony.mc.otm.client.screen.widget.HorizontalPowerGaugePanel
|
||||
import ru.dbotthepony.mc.otm.client.screen.widget.PowerGaugePanel
|
||||
import ru.dbotthepony.mc.otm.client.screen.widget.ProgressGaugePanel
|
||||
import ru.dbotthepony.mc.otm.client.screen.widget.TallHorizontalProfiledPowerGaugePanel
|
||||
import ru.dbotthepony.mc.otm.client.screen.widget.WideProfiledPowerGaugePanel
|
||||
import ru.dbotthepony.mc.otm.client.setMousePos
|
||||
import ru.dbotthepony.mc.otm.client.shouldOpenVanillaInventory
|
||||
import ru.dbotthepony.mc.otm.core.math.integerDivisionDown
|
||||
import ru.dbotthepony.mc.otm.menu.ExoPackInventoryMenu
|
||||
import ru.dbotthepony.mc.otm.menu.widget.ProgressGaugeWidget
|
||||
import ru.dbotthepony.mc.otm.network.ExoPackMenuOpen
|
||||
import ru.dbotthepony.mc.otm.network.MatteryPlayerNetworkChannel
|
||||
import yalter.mousetweaks.api.MouseTweaksDisableWheelTweak
|
||||
@ -59,6 +55,8 @@ class ExoPackInventoryScreen(menu: ExoPackInventoryMenu) : MatteryScreen<ExoPack
|
||||
override fun makeMainFrame(): FramePanel<MatteryScreen<*>> {
|
||||
val frame = FramePanel(this, width = 200f, height = FRAME_BASE_HEIGHT + inventoryRows * AbstractSlotPanel.SIZE, title = this.title)
|
||||
|
||||
frame.makeHelpButton().addSlotFiltersHelp()
|
||||
|
||||
val hotbarStrip = EditablePanel(this, frame, height = 18f)
|
||||
hotbarStrip.dock = Dock.BOTTOM
|
||||
|
||||
@ -236,7 +234,7 @@ class ExoPackInventoryScreen(menu: ExoPackInventoryMenu) : MatteryScreen<ExoPack
|
||||
minecraft.setScreen(InventoryScreen(minecraft.player!!))
|
||||
|
||||
setMousePos(mouseX, mouseY)
|
||||
}).also { it.tooltip = TranslatableComponent("otm.gui.exopack.go_back") }
|
||||
}).also { it.tooltips.add(TranslatableComponent("otm.gui.exopack.go_back")) }
|
||||
|
||||
makeInventoryRowsControls(frame, frame.width + 2f, frame.height.coerceAtMost(95f)) { movePixels ->
|
||||
frame.y += movePixels
|
||||
|
@ -523,7 +523,14 @@ abstract class MatteryScreen<T : MatteryMenu>(menu: T, inventory: Inventory, tit
|
||||
val panel = panels[i]
|
||||
RenderSystem.depthFunc(GL11.GL_ALWAYS)
|
||||
RenderSystem.setShaderColor(1f, 1f, 1f, 1f)
|
||||
panel.render(graphics, mouseXf, mouseYf, partialTick)
|
||||
panel.render(graphics, false, mouseXf, mouseYf, partialTick)
|
||||
}
|
||||
|
||||
for (i in panels.indices.reversed()) {
|
||||
val panel = panels[i]
|
||||
RenderSystem.depthFunc(GL11.GL_ALWAYS)
|
||||
RenderSystem.setShaderColor(1f, 1f, 1f, 1f)
|
||||
panel.render(graphics, true, mouseXf, mouseYf, partialTick)
|
||||
}
|
||||
|
||||
RenderSystem.depthFunc(GL11.GL_LESS)
|
||||
|
@ -15,6 +15,7 @@ class CargoCrateScreen(menu: CargoCrateMenu, inventory: Inventory, title: Compon
|
||||
|
||||
frame.makeCloseButton()
|
||||
frame.onClose { onClose() }
|
||||
frame.makeHelpButton().addSlotFiltersHelp()
|
||||
|
||||
val grid = GridPanel(this, frame, 8f, 18f, 9f * 18f, 6f * 18f, 9, 6)
|
||||
|
||||
|
@ -26,7 +26,7 @@ class HoloSignScreen(menu: HoloSignMenu, inventory: Inventory, title: Component)
|
||||
val lock = CheckBoxLabelInputPanel(this, frame, menu.locked, TranslatableComponent("otm.gui.lock_holo_screen"))
|
||||
lock.dock = Dock.BOTTOM
|
||||
lock.dockMargin = DockProperty(2f, 2f, 2f, 2f)
|
||||
lock.tooltip = TranslatableComponent("otm.gui.lock_holo_screen.tip")
|
||||
lock.tooltips.add(TranslatableComponent("otm.gui.lock_holo_screen.tip"))
|
||||
|
||||
makeDeviceControls(this, frame, redstoneConfig = menu.redstone)
|
||||
|
||||
|
@ -110,11 +110,11 @@ class MatterPanelScreen(
|
||||
scrollBar.dock = Dock.RIGHT
|
||||
|
||||
frame.Tab(onOpen = { isPatternView = true; scrollBar.scroll = scrollPatterns }, activeIcon = PATTERN_LIST_ACTIVE, inactiveIcon = PATTERN_LIST_INACTIVE).also {
|
||||
it.tooltip = TranslatableComponent("otm.gui.matter_panel.patterns")
|
||||
it.tooltips.add(TranslatableComponent("otm.gui.matter_panel.patterns"))
|
||||
}
|
||||
|
||||
frame.Tab(onOpen = { isPatternView = false; scrollBar.scroll = scrollTasks }, activeIcon = TASK_LIST_ACTIVE, inactiveIcon = TASK_LIST_INACTIVE).also {
|
||||
it.tooltip = TranslatableComponent("otm.gui.matter_panel.tasks")
|
||||
it.tooltips.add(TranslatableComponent("otm.gui.matter_panel.tasks"))
|
||||
}
|
||||
|
||||
val canvas = object : EditablePanel<MatterPanelScreen>(this@MatterPanelScreen, frame, width = GRID_WIDTH * AbstractSlotPanel.SIZE) {
|
||||
|
@ -24,7 +24,6 @@ import ru.dbotthepony.mc.otm.client.render.currentScissorRect
|
||||
import ru.dbotthepony.mc.otm.client.render.popScissorRect
|
||||
import ru.dbotthepony.mc.otm.client.render.pushScissorRect
|
||||
import ru.dbotthepony.mc.otm.client.screen.MatteryScreen
|
||||
import ru.dbotthepony.mc.otm.client.screen.panels.button.AbstractButtonPanel
|
||||
import ru.dbotthepony.mc.otm.client.screen.panels.input.QueryUserPanel
|
||||
import java.util.*
|
||||
import kotlin.collections.ArrayList
|
||||
@ -357,6 +356,8 @@ open class EditablePanel<out S : Screen> @JvmOverloads constructor(
|
||||
var acceptKeyboardInput = true
|
||||
var grabMouseInput = false
|
||||
|
||||
open val needsPostRender: Boolean get() = false
|
||||
|
||||
fun tryToGrabMouseInput(): Boolean {
|
||||
if (grabMouseInput) {
|
||||
return true
|
||||
@ -375,43 +376,7 @@ open class EditablePanel<out S : Screen> @JvmOverloads constructor(
|
||||
return true
|
||||
}
|
||||
|
||||
var tooltip: Component? = null
|
||||
set(value) {
|
||||
if (value != null) {
|
||||
tooltipList = null
|
||||
}
|
||||
|
||||
field = value
|
||||
}
|
||||
|
||||
var tooltipList: List<Component>? = null
|
||||
set(value) {
|
||||
if (value != null) {
|
||||
tooltip = null
|
||||
}
|
||||
|
||||
field = value
|
||||
}
|
||||
|
||||
fun prependTooltip(text: Component) {
|
||||
if (tooltip == null && tooltipList == null) {
|
||||
tooltip = text
|
||||
} else if (tooltip != null) {
|
||||
tooltipList = listOf(text, tooltip!!)
|
||||
} else {
|
||||
tooltipList = tooltipList!!.toMutableList().also { it.add(0, text) }
|
||||
}
|
||||
}
|
||||
|
||||
fun appendTooltip(text: Component) {
|
||||
if (tooltip == null && tooltipList == null) {
|
||||
tooltip = text
|
||||
} else if (tooltip != null) {
|
||||
tooltipList = listOf(text, tooltip!!)
|
||||
} else {
|
||||
tooltipList = tooltipList!!.toMutableList().also { it.add(text) }
|
||||
}
|
||||
}
|
||||
val tooltips = ArrayList<Component>()
|
||||
|
||||
var blockingWindow: EditablePanel<*>? = null
|
||||
get() {
|
||||
@ -738,10 +703,15 @@ open class EditablePanel<out S : Screen> @JvmOverloads constructor(
|
||||
}
|
||||
|
||||
protected open fun innerRender(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float) {}
|
||||
protected open fun innerRenderPost(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float) {}
|
||||
protected open fun innerRenderTooltips(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float): Boolean {
|
||||
return false
|
||||
}
|
||||
|
||||
protected open fun shouldRenderTooltips(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float): Boolean {
|
||||
return isHovered || isGrabbingMouseInput()
|
||||
}
|
||||
|
||||
fun isVisible(): Boolean {
|
||||
return visible && visibleAsChildren && !isRemoved
|
||||
}
|
||||
@ -782,7 +752,7 @@ open class EditablePanel<out S : Screen> @JvmOverloads constructor(
|
||||
}
|
||||
}
|
||||
|
||||
fun render(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float) {
|
||||
fun render(graphics: GuiGraphics, post: Boolean, mouseX: Float, mouseY: Float, partialTick: Float) {
|
||||
once = true
|
||||
|
||||
if (!isVisible()) {
|
||||
@ -791,22 +761,24 @@ open class EditablePanel<out S : Screen> @JvmOverloads constructor(
|
||||
|
||||
val poseStack = graphics.pose()
|
||||
|
||||
performLayoutIfNeeded()
|
||||
if (!post) {
|
||||
performLayoutIfNeeded()
|
||||
|
||||
val parent = this.parent
|
||||
val parent = this.parent
|
||||
|
||||
if (parent == null) {
|
||||
absoluteX = x
|
||||
absoluteY = y
|
||||
} else {
|
||||
if ((x < 0f || y < 0f || x + width > parent.width || y + height > parent.height) && parent.parent == null) {
|
||||
// no op - we updated ourselves in tickHover
|
||||
if (parent == null) {
|
||||
absoluteX = x
|
||||
absoluteY = y
|
||||
} else {
|
||||
isHovered = parent.isHovered &&
|
||||
mouseX >= absoluteX &&
|
||||
mouseX < absoluteX + width &&
|
||||
mouseY >= absoluteY &&
|
||||
mouseY < absoluteY + height
|
||||
if ((x < 0f || y < 0f || x + width > parent.width || y + height > parent.height) && parent.parent == null) {
|
||||
// no op - we updated ourselves in tickHover
|
||||
} else {
|
||||
isHovered = parent.isHovered &&
|
||||
mouseX >= absoluteX &&
|
||||
mouseX < absoluteX + width &&
|
||||
mouseY >= absoluteY &&
|
||||
mouseY < absoluteY + height
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -827,13 +799,18 @@ open class EditablePanel<out S : Screen> @JvmOverloads constructor(
|
||||
|
||||
val currentScissorRect = currentScissorRect
|
||||
|
||||
if (currentScissorRect == null || currentScissorRect.crossScaled(absoluteX, absoluteY, width, height)) {
|
||||
if ((!post || needsPostRender) && (currentScissorRect == null || currentScissorRect.crossScaled(absoluteX, absoluteY, width, height))) {
|
||||
// do not render if we are getting cut off by screen scissor
|
||||
clearDepth(graphics, absoluteX, absoluteY, width, height)
|
||||
poseStack.pushPose()
|
||||
poseStack.translate(absoluteX.toDouble(), absoluteY.toDouble(), 10.0)
|
||||
RenderSystem.setShaderColor(1f, 1f, 1f, if (isFlashFrameRecursive) 0.5f else 1f)
|
||||
innerRender(graphics, mouseX, mouseY, partialTick)
|
||||
|
||||
if (post)
|
||||
innerRenderPost(graphics, mouseX, mouseY, partialTick)
|
||||
else
|
||||
innerRender(graphics, mouseX, mouseY, partialTick)
|
||||
|
||||
RenderSystem.setShaderColor(1f, 1f, 1f, 1f)
|
||||
poseStack.popPose()
|
||||
}
|
||||
@ -842,7 +819,7 @@ open class EditablePanel<out S : Screen> @JvmOverloads constructor(
|
||||
child.absoluteX = absoluteX + child.x + xOffset
|
||||
child.absoluteY = absoluteY + child.y + yOffset
|
||||
|
||||
child.render(graphics, mouseX, mouseY, partialTick)
|
||||
child.render(graphics, post, mouseX, mouseY, partialTick)
|
||||
}
|
||||
|
||||
if (scissor) {
|
||||
@ -982,31 +959,19 @@ open class EditablePanel<out S : Screen> @JvmOverloads constructor(
|
||||
}
|
||||
}
|
||||
|
||||
if (innerRenderTooltips(graphics, mouseX, mouseY, partialTick)) {
|
||||
return true
|
||||
}
|
||||
if (shouldRenderTooltips(graphics, mouseX, mouseY, partialTick)) {
|
||||
if (innerRenderTooltips(graphics, mouseX, mouseY, partialTick)) {
|
||||
return true
|
||||
}
|
||||
|
||||
if (isHovered || this is AbstractButtonPanel<*> && isPressed) {
|
||||
val tooltip = tooltip
|
||||
val tooltipList = tooltipList
|
||||
|
||||
if (tooltip != null) {
|
||||
if (tooltips.isNotEmpty()) {
|
||||
graphics.renderComponentTooltip(
|
||||
font,
|
||||
listOf(tooltip),
|
||||
tooltips,
|
||||
mouseX.toInt(),
|
||||
mouseY.toInt()
|
||||
)
|
||||
|
||||
return true
|
||||
} else if (tooltipList != null) {
|
||||
graphics.renderComponentTooltip(
|
||||
font,
|
||||
tooltipList,
|
||||
mouseX.toInt(),
|
||||
mouseY.toInt(),
|
||||
)
|
||||
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
@ -81,7 +81,7 @@ class EntityRendererPanel<out S : Screen> @JvmOverloads constructor(
|
||||
}
|
||||
)
|
||||
|
||||
exosuitButton.tooltip = TranslatableComponent("otm.gui.exopack.toggle_visibility")
|
||||
exosuitButton.tooltips.add(TranslatableComponent("otm.gui.exopack.toggle_visibility"))
|
||||
} else {
|
||||
exosuitButton = null
|
||||
}
|
||||
|
@ -9,9 +9,9 @@ import net.minecraft.client.gui.narration.NarrationElementOutput
|
||||
import net.minecraft.client.gui.screens.Screen
|
||||
import net.minecraft.network.chat.Component
|
||||
import org.lwjgl.opengl.GL30
|
||||
import ru.dbotthepony.mc.otm.client.playGuiClickSound
|
||||
import ru.dbotthepony.mc.otm.client.render.*
|
||||
import ru.dbotthepony.mc.otm.client.screen.panels.button.AbstractButtonPanel
|
||||
import ru.dbotthepony.mc.otm.core.TranslatableComponent
|
||||
|
||||
open class FramePanel<out S : Screen>(
|
||||
screen: S,
|
||||
@ -141,6 +141,58 @@ open class FramePanel<out S : Screen>(
|
||||
}
|
||||
}
|
||||
|
||||
inner class HelpButton : EditablePanel<S>(screen, this@FramePanel, this@FramePanel.width - HELP_BUTTON.width - CLOSE_BUTTON.width, 0f, HELP_BUTTON.width, HELP_BUTTON.height) {
|
||||
// var isActive = false
|
||||
|
||||
/*override fun onClick(mouseButton: Int) {
|
||||
isActive = !isActive
|
||||
}*/
|
||||
|
||||
override fun innerRender(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float) {
|
||||
/*if (isPressed) {
|
||||
HELP_BUTTON_PRESSED.render(graphics, 0f, 0f, width, height)
|
||||
} else*/ if (isHovered /*|| isActive */) {
|
||||
HELP_BUTTON_HOVERED.render(graphics, 0f, 0f, width, height)
|
||||
} else {
|
||||
HELP_BUTTON.render(graphics, 0f, 0f, width, height)
|
||||
}
|
||||
}
|
||||
|
||||
/*override val needsPostRender: Boolean
|
||||
get() = isActive
|
||||
|
||||
override fun innerRenderPost(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float) {
|
||||
val tooltip = tooltip
|
||||
val tooltipList = tooltipList
|
||||
|
||||
val list = tooltipList ?: tooltip?.let { listOf(it) } ?: listOf()
|
||||
|
||||
if (list.isNotEmpty()) {
|
||||
graphics.renderComponentTooltip(
|
||||
font, list,
|
||||
mouseX.toInt(), mouseY.toInt()
|
||||
)
|
||||
}
|
||||
}*/
|
||||
|
||||
/*override fun shouldRenderTooltips(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float): Boolean {
|
||||
return super.shouldRenderTooltips(graphics, mouseX, mouseY, partialTick) && !isActive
|
||||
}*/
|
||||
|
||||
fun addSlotFiltersHelp(): HelpButton {
|
||||
tooltips.add(TranslatableComponent("otm.gui.help.slot_filters"))
|
||||
return this
|
||||
}
|
||||
|
||||
override fun onRemoved() {
|
||||
super.onRemoved()
|
||||
|
||||
if (helpButton == this) {
|
||||
helpButton = null
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected val tabs: java.util.ArrayList<Tab> = ArrayList()
|
||||
|
||||
override fun performLayout() {
|
||||
@ -150,18 +202,38 @@ open class FramePanel<out S : Screen>(
|
||||
}
|
||||
|
||||
closeButton?.setPos(width - CLOSE_BUTTON.width, 0f)
|
||||
helpButton?.setPos(width - HELP_BUTTON.width - CLOSE_BUTTON.width, 0f)
|
||||
|
||||
super.performLayout()
|
||||
}
|
||||
|
||||
protected var dragging = false
|
||||
protected var closeButton: CloseButton? = null
|
||||
protected var helpButton: HelpButton? = null
|
||||
|
||||
var closeOnEscape = false
|
||||
|
||||
fun makeCloseButton() {
|
||||
fun makeCloseButton(): CloseButton {
|
||||
if (closeButton == null)
|
||||
closeButton = CloseButton()
|
||||
|
||||
return closeButton!!
|
||||
}
|
||||
|
||||
fun makeHelpButton(): HelpButton {
|
||||
if (helpButton == null)
|
||||
helpButton = HelpButton()
|
||||
|
||||
return helpButton!!
|
||||
}
|
||||
|
||||
fun makeHelpButton(tooltips: Collection<Component>): HelpButton {
|
||||
if (helpButton == null) {
|
||||
helpButton = HelpButton()
|
||||
helpButton!!.tooltips.addAll(tooltips)
|
||||
}
|
||||
|
||||
return helpButton!!
|
||||
}
|
||||
|
||||
/**
|
||||
@ -315,6 +387,10 @@ open class FramePanel<out S : Screen>(
|
||||
val CLOSE_BUTTON_HOVERED = WidgetLocation.MISC.sprite(x = 51f, y = 11f, width = 13f, height = 11f)
|
||||
val CLOSE_BUTTON_PRESSED = WidgetLocation.MISC.sprite(x = 51f, y = 22f, width = 13f, height = 11f)
|
||||
|
||||
val HELP_BUTTON = WidgetLocation.MISC.sprite(x = 41f, y = 0f, width = 10f, height = 11f)
|
||||
val HELP_BUTTON_HOVERED = WidgetLocation.MISC.sprite(x = 41f, y = 11f, width = 10f, height = 11f)
|
||||
val HELP_BUTTON_PRESSED = WidgetLocation.MISC.sprite(x = 41f, y = 22f, width = 10f, height = 11f)
|
||||
|
||||
const val TAB_HEIGHT = 28f
|
||||
const val TAB_WIDTH = 28f
|
||||
const val TAB_HEIGHT_ACTIVE = 32f
|
||||
|
@ -20,7 +20,8 @@ class Panel2Widget<out S: Screen, out P : EditablePanel<S>>(
|
||||
val yFloat = mouseY.toFloat()
|
||||
|
||||
panel.tickHover(xFloat, yFloat)
|
||||
panel.render(graphics, xFloat, yFloat, partialTick)
|
||||
panel.render(graphics, false, xFloat, yFloat, partialTick)
|
||||
panel.render(graphics, true, xFloat, yFloat, partialTick)
|
||||
panel.renderTooltips(graphics, xFloat, yFloat, partialTick)
|
||||
}
|
||||
|
||||
|
@ -1,11 +1,10 @@
|
||||
package ru.dbotthepony.mc.otm.client.screen.panels.button
|
||||
|
||||
import com.mojang.blaze3d.platform.InputConstants
|
||||
import net.minecraft.client.gui.GuiGraphics
|
||||
import net.minecraft.client.gui.screens.Screen
|
||||
import net.minecraft.network.chat.Component
|
||||
import ru.dbotthepony.mc.otm.client.playGuiClickSound
|
||||
import ru.dbotthepony.mc.otm.client.screen.panels.EditablePanel
|
||||
import java.util.function.IntConsumer
|
||||
import java.util.function.IntPredicate
|
||||
|
||||
abstract class AbstractButtonPanel<out S : Screen>(
|
||||
@ -65,4 +64,8 @@ abstract class AbstractButtonPanel<out S : Screen>(
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
override fun shouldRenderTooltips(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float): Boolean {
|
||||
return super.shouldRenderTooltips(graphics, mouseX, mouseY, partialTick) || isPressed
|
||||
}
|
||||
}
|
||||
|
@ -36,19 +36,12 @@ abstract class BooleanRectangleButtonPanel<out S : Screen>(
|
||||
if (isHovered) {
|
||||
val tooltipActive = tooltipActive
|
||||
val tooltipInactive = tooltipInactive
|
||||
val tooltipList = tooltipList
|
||||
val tooltip = tooltip
|
||||
|
||||
if (tooltipActive != null || tooltipInactive != null || tooltipList != null || tooltip != null) {
|
||||
val tooltips = ArrayList<Component>(2)
|
||||
if (tooltipActive != null || tooltipInactive != null || tooltips.isNotEmpty()) {
|
||||
val tooltips = ArrayList<Component>(2 + this.tooltips.size)
|
||||
|
||||
if (tooltipList != null) {
|
||||
tooltips.addAll(tooltipList)
|
||||
|
||||
if (tooltipActive != null || tooltipInactive != null)
|
||||
tooltips.add(SPACE)
|
||||
} else if (tooltip != null) {
|
||||
tooltips.add(tooltip)
|
||||
if (this.tooltips.isNotEmpty()) {
|
||||
tooltips.addAll(this.tooltips)
|
||||
|
||||
if (tooltipActive != null || tooltipInactive != null)
|
||||
tooltips.add(SPACE)
|
||||
|
@ -81,12 +81,12 @@ private class PullPushButton<out S : MatteryScreen<*>, T : Enum<T>>(
|
||||
val pushProp: BooleanInputWithFeedback
|
||||
) : LargeEnumRectangleButtonPanel<S, T>(screen, parent, x = x, y = y, enum = enum, prop = prop, defaultValue = defaultValue) {
|
||||
init {
|
||||
if (pullProp.test(minecraft.player) && pushProp.test(minecraft.player)) {
|
||||
tooltipList = listOf(TranslatableComponent("otm.gui.sides.pull_help").withStyle(ChatFormatting.GRAY), TranslatableComponent("otm.gui.sides.push_help").withStyle(ChatFormatting.GRAY))
|
||||
} else if (pullProp.test(minecraft.player)) {
|
||||
tooltip = TranslatableComponent("otm.gui.sides.pull_help").withStyle(ChatFormatting.GRAY)
|
||||
} else if (pushProp.test(minecraft.player)) {
|
||||
tooltip = TranslatableComponent("otm.gui.sides.push_help").withStyle(ChatFormatting.GRAY)
|
||||
if (pullProp.test(minecraft.player)) {
|
||||
tooltips.add(TranslatableComponent("otm.gui.sides.pull_help").withStyle(ChatFormatting.GRAY))
|
||||
}
|
||||
|
||||
if (pushProp.test(minecraft.player)) {
|
||||
tooltips.add(TranslatableComponent("otm.gui.sides.push_help").withStyle(ChatFormatting.GRAY))
|
||||
}
|
||||
}
|
||||
|
||||
@ -183,12 +183,12 @@ private fun moveButtons(
|
||||
top: EditablePanel<*>,
|
||||
bottom: EditablePanel<*>,
|
||||
) {
|
||||
top.prependTooltip(TranslatableComponent("otm.gui.sides.top"))
|
||||
bottom.prependTooltip(TranslatableComponent("otm.gui.sides.bottom"))
|
||||
back.prependTooltip(TranslatableComponent("otm.gui.sides.back"))
|
||||
front.prependTooltip(TranslatableComponent("otm.gui.sides.front"))
|
||||
left.prependTooltip(TranslatableComponent("otm.gui.sides.left"))
|
||||
right.prependTooltip(TranslatableComponent("otm.gui.sides.right"))
|
||||
top.tooltips.add(0, TranslatableComponent("otm.gui.sides.top"))
|
||||
bottom.tooltips.add(0, TranslatableComponent("otm.gui.sides.bottom"))
|
||||
back.tooltips.add(0, TranslatableComponent("otm.gui.sides.back"))
|
||||
front.tooltips.add(0, TranslatableComponent("otm.gui.sides.front"))
|
||||
left.tooltips.add(0, TranslatableComponent("otm.gui.sides.left"))
|
||||
right.tooltips.add(0, TranslatableComponent("otm.gui.sides.right"))
|
||||
|
||||
top.x = 30f
|
||||
top.y = 14f
|
||||
@ -345,13 +345,11 @@ class DeviceControls<out S : MatteryScreen<*>>(
|
||||
skinElement = Widgets18.UPGRADES
|
||||
) {
|
||||
init {
|
||||
tooltip = TranslatableComponent("otm.gui.upgrades")
|
||||
tooltips.add(TranslatableComponent("otm.gui.upgrades"))
|
||||
}
|
||||
|
||||
override fun tickInner() {
|
||||
super.tickInner()
|
||||
|
||||
tooltipList = ArrayList<Component>().also {
|
||||
override fun innerRenderTooltips(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float): Boolean {
|
||||
graphics.renderComponentTooltip(font, ArrayList<Component>().also {
|
||||
it.add(TranslatableComponent("otm.gui.upgrades"))
|
||||
it.add(TextComponent(""))
|
||||
|
||||
@ -372,7 +370,9 @@ class DeviceControls<out S : MatteryScreen<*>>(
|
||||
it.add(i, TranslatableComponent("otm.gui.upgrades.current").withStyle(ChatFormatting.GRAY))
|
||||
it.add(i, TextComponent(""))
|
||||
}
|
||||
}
|
||||
}, mouseX.toInt(), mouseY.toInt())
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
override fun onClick(mouseButton: Int) {
|
||||
@ -421,7 +421,7 @@ class DeviceControls<out S : MatteryScreen<*>>(
|
||||
prop = balanceInputs,
|
||||
skinElementActive = Widgets18.BALANCING_ENABLED,
|
||||
skinElementInactive = Widgets18.BALANCING_DISABLED).also {
|
||||
it.tooltip = TranslatableComponent("otm.gui.balance_inputs")
|
||||
it.tooltips.add(TranslatableComponent("otm.gui.balance_inputs"))
|
||||
})
|
||||
} else {
|
||||
balanceInputsButton = null
|
||||
@ -430,7 +430,7 @@ class DeviceControls<out S : MatteryScreen<*>>(
|
||||
if (itemConfig != null) {
|
||||
itemConfigButton = addButton(object : LargeRectangleButtonPanel<S>(screen, this@DeviceControls, skinElement = Widgets18.ITEMS_CONFIGURATION) {
|
||||
init {
|
||||
tooltip = TranslatableComponent("otm.gui.sides.item_config")
|
||||
tooltips.add(TranslatableComponent("otm.gui.sides.item_config"))
|
||||
}
|
||||
|
||||
override fun onClick(mouseButton: Int) {
|
||||
@ -449,7 +449,7 @@ class DeviceControls<out S : MatteryScreen<*>>(
|
||||
if (energyConfig != null) {
|
||||
energyConfigButton = addButton(object : LargeRectangleButtonPanel<S>(screen, this@DeviceControls, y = nextY, skinElement = Widgets18.ENERGY_CONFIGURATION) {
|
||||
init {
|
||||
tooltip = TranslatableComponent("otm.gui.sides.energy_config")
|
||||
tooltips.add(TranslatableComponent("otm.gui.sides.energy_config"))
|
||||
}
|
||||
|
||||
override fun onClick(mouseButton: Int) {
|
||||
@ -468,7 +468,7 @@ class DeviceControls<out S : MatteryScreen<*>>(
|
||||
if (fluidConfig != null) {
|
||||
fluidConfigButton = addButton(object : LargeRectangleButtonPanel<S>(screen, this@DeviceControls, y = nextY, skinElement = Widgets18.FLUID_CONFIGURATION) {
|
||||
init {
|
||||
tooltip = TranslatableComponent("otm.gui.sides.fluid_config")
|
||||
tooltips.add(TranslatableComponent("otm.gui.sides.fluid_config"))
|
||||
}
|
||||
|
||||
override fun onClick(mouseButton: Int) {
|
||||
|
@ -151,23 +151,14 @@ abstract class EnumRectangleButtonPanel<out S : Screen, T : Enum<T>>(
|
||||
}
|
||||
|
||||
override fun innerRenderTooltips(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float): Boolean {
|
||||
if (!isHovered && !isGrabbingMouseInput()) {
|
||||
return super.innerRenderTooltips(graphics, mouseX, mouseY, partialTick)
|
||||
}
|
||||
|
||||
if (tooltip == null && tooltipList == null && enumMapping.entries.none { predicate.test(it.key) && it.value.tooltip != null }) {
|
||||
if (tooltips.isEmpty() && enumMapping.entries.none { predicate.test(it.key) && it.value.tooltip != null }) {
|
||||
return super.innerRenderTooltips(graphics, mouseX, mouseY, partialTick)
|
||||
}
|
||||
|
||||
val listing = ArrayList<Component>()
|
||||
val tooltipList = tooltipList
|
||||
val tooltip = tooltip
|
||||
|
||||
if (tooltipList != null) {
|
||||
listing.addAll(tooltipList)
|
||||
listing.add(SPACE)
|
||||
} else if (tooltip != null) {
|
||||
listing.add(tooltip)
|
||||
if (tooltips.isNotEmpty()) {
|
||||
listing.addAll(tooltips)
|
||||
listing.add(SPACE)
|
||||
}
|
||||
|
||||
|
@ -147,7 +147,7 @@ class ItemMonitorScreen(menu: ItemMonitorMenu, inventory: Inventory, title: Comp
|
||||
prop = menu.settings::ingredientPriority.asGetterSetter(watch = { _, _ -> menu.sendSettingsToServer() }),
|
||||
defaultValue = ItemMonitorPlayerSettings.IngredientPriority.SYSTEM)
|
||||
|
||||
refillPriority.tooltip = TranslatableComponent("otm.gui.item_monitor.refill_source.desc")
|
||||
refillPriority.tooltips.add(TranslatableComponent("otm.gui.item_monitor.refill_source.desc"))
|
||||
refillPriority.add(ItemMonitorPlayerSettings.IngredientPriority.SYSTEM, tooltip = ItemMonitorPlayerSettings.IngredientPriority.SYSTEM.component, skinElement = Widgets8.WHITE_ARROW_DOWN, winding = UVWindingOrder.FLIP)
|
||||
refillPriority.add(ItemMonitorPlayerSettings.IngredientPriority.INVENTORY, tooltip = ItemMonitorPlayerSettings.IngredientPriority.INVENTORY.component, skinElement = Widgets8.WHITE_ARROW_DOWN)
|
||||
refillPriority.add(ItemMonitorPlayerSettings.IngredientPriority.INVENTORY_FIRST, tooltip = ItemMonitorPlayerSettings.IngredientPriority.INVENTORY_FIRST.component, skinElement = Widgets8.ARROW_SIDEWAYS, winding = UVWindingOrder.FLIP)
|
||||
@ -168,7 +168,7 @@ class ItemMonitorScreen(menu: ItemMonitorMenu, inventory: Inventory, title: Comp
|
||||
prop = menu.settings::resultTarget.asGetterSetter(watch = { _, _ -> menu.sendSettingsToServer() }),
|
||||
defaultValue = ItemMonitorPlayerSettings.ResultTarget.MIXED)
|
||||
|
||||
resultTarget.tooltip = TranslatableComponent("otm.gui.item_monitor.result_target.desc")
|
||||
resultTarget.tooltips.add(TranslatableComponent("otm.gui.item_monitor.result_target.desc"))
|
||||
resultTarget.add(ItemMonitorPlayerSettings.ResultTarget.MIXED, tooltip = ItemMonitorPlayerSettings.ResultTarget.MIXED.component, skinElement = Widgets8.ARROW_SIDEWAYS)
|
||||
resultTarget.add(ItemMonitorPlayerSettings.ResultTarget.ALL_INVENTORY, tooltip = ItemMonitorPlayerSettings.ResultTarget.ALL_INVENTORY.component, skinElement = Widgets8.ARROW_PAINTED_UP, winding = UVWindingOrder.FLIP)
|
||||
resultTarget.add(ItemMonitorPlayerSettings.ResultTarget.ALL_SYSTEM, tooltip = ItemMonitorPlayerSettings.ResultTarget.ALL_SYSTEM.component, skinElement = Widgets8.ARROW_PAINTED_UP)
|
||||
@ -178,7 +178,7 @@ class ItemMonitorScreen(menu: ItemMonitorMenu, inventory: Inventory, title: Comp
|
||||
prop = menu.settings::craftingAmount.asGetterSetter(watch = { _, _ -> menu.sendSettingsToServer() }),
|
||||
defaultValue = ItemMonitorPlayerSettings.Amount.STACK)
|
||||
|
||||
craftingAmount.tooltip = TranslatableComponent("otm.gui.item_monitor.amount.desc")
|
||||
craftingAmount.tooltips.add(TranslatableComponent("otm.gui.item_monitor.amount.desc"))
|
||||
craftingAmount.add(ItemMonitorPlayerSettings.Amount.ONE, tooltip = ItemMonitorPlayerSettings.Amount.ONE.component, skinElement = Widgets8.ONE)
|
||||
craftingAmount.add(ItemMonitorPlayerSettings.Amount.STACK, tooltip = ItemMonitorPlayerSettings.Amount.STACK.component, skinElement = Widgets8.S)
|
||||
craftingAmount.add(ItemMonitorPlayerSettings.Amount.FULL, tooltip = ItemMonitorPlayerSettings.Amount.FULL.component, skinElement = Widgets8.F)
|
||||
|
@ -42,7 +42,7 @@ class EssenceStorageScreen(menu: EssenceStorageMenu, inventory: Inventory, title
|
||||
|
||||
SlotPanel(this, inputs, menu.capsuleSlot).also {
|
||||
it.dock = Dock.RIGHT
|
||||
it.tooltip = MItems.ESSENCE_CAPSULE.description.copy().withStyle(ChatFormatting.GRAY)
|
||||
it.tooltips.add(MItems.ESSENCE_CAPSULE.description.copy().withStyle(ChatFormatting.GRAY))
|
||||
}
|
||||
|
||||
HorizontalStripPanel(this, frame, height = 18f).also {
|
||||
@ -65,7 +65,7 @@ class EssenceStorageScreen(menu: EssenceStorageMenu, inventory: Inventory, title
|
||||
|
||||
SlotPanel(this, it, menu.servoSlot).also {
|
||||
it.dock = Dock.RIGHT
|
||||
it.tooltip = MItems.ESSENCE_SERVO.description.copy().withStyle(ChatFormatting.GRAY)
|
||||
it.tooltips.add(MItems.ESSENCE_SERVO.description.copy().withStyle(ChatFormatting.GRAY))
|
||||
}
|
||||
}
|
||||
|
||||
@ -95,7 +95,7 @@ class EssenceStorageScreen(menu: EssenceStorageMenu, inventory: Inventory, title
|
||||
object : LargeRectangleButtonPanel<EssenceStorageScreen>(this@EssenceStorageScreen, inputs, skinElement = STORE_1) {
|
||||
init {
|
||||
dockRight = 3f
|
||||
tooltip = TranslatableComponent("otm.gui.experience.store", 1)
|
||||
tooltips.add(TranslatableComponent("otm.gui.experience.store", 1))
|
||||
}
|
||||
|
||||
override fun onClick(mouseButton: Int) {
|
||||
@ -110,7 +110,7 @@ class EssenceStorageScreen(menu: EssenceStorageMenu, inventory: Inventory, title
|
||||
object : LargeRectangleButtonPanel<EssenceStorageScreen>(this@EssenceStorageScreen, inputs, skinElement = STORE_10) {
|
||||
init {
|
||||
dockRight = 3f
|
||||
tooltip = TranslatableComponent("otm.gui.experience.store", 10)
|
||||
tooltips.add(TranslatableComponent("otm.gui.experience.store", 10))
|
||||
}
|
||||
|
||||
override fun onClick(mouseButton: Int) {
|
||||
@ -125,7 +125,7 @@ class EssenceStorageScreen(menu: EssenceStorageMenu, inventory: Inventory, title
|
||||
object : LargeRectangleButtonPanel<EssenceStorageScreen>(this@EssenceStorageScreen, inputs, skinElement = STORE_ALL) {
|
||||
init {
|
||||
dockRight = 3f
|
||||
tooltip = TranslatableComponent("otm.gui.experience.store_all")
|
||||
tooltips.add(TranslatableComponent("otm.gui.experience.store_all"))
|
||||
}
|
||||
|
||||
override fun onClick(mouseButton: Int) {
|
||||
@ -140,7 +140,7 @@ class EssenceStorageScreen(menu: EssenceStorageMenu, inventory: Inventory, title
|
||||
object : LargeRectangleButtonPanel<EssenceStorageScreen>(this@EssenceStorageScreen, outputs, skinElement = DISPENSE_1) {
|
||||
init {
|
||||
dockRight = 3f
|
||||
tooltip = TranslatableComponent("otm.gui.experience.dispense", 1)
|
||||
tooltips.add(TranslatableComponent("otm.gui.experience.dispense", 1))
|
||||
}
|
||||
|
||||
override fun onClick(mouseButton: Int) {
|
||||
@ -155,7 +155,7 @@ class EssenceStorageScreen(menu: EssenceStorageMenu, inventory: Inventory, title
|
||||
object : LargeRectangleButtonPanel<EssenceStorageScreen>(this@EssenceStorageScreen, outputs, skinElement = DISPENSE_10) {
|
||||
init {
|
||||
dockRight = 3f
|
||||
tooltip = TranslatableComponent("otm.gui.experience.dispense", 10)
|
||||
tooltips.add(TranslatableComponent("otm.gui.experience.dispense", 10))
|
||||
}
|
||||
|
||||
override fun onClick(mouseButton: Int) {
|
||||
@ -170,7 +170,7 @@ class EssenceStorageScreen(menu: EssenceStorageMenu, inventory: Inventory, title
|
||||
object : LargeRectangleButtonPanel<EssenceStorageScreen>(this@EssenceStorageScreen, outputs, skinElement = DISPENSE_ALL) {
|
||||
init {
|
||||
dockRight = 3f
|
||||
tooltip = TranslatableComponent("otm.gui.experience.dispense_all")
|
||||
tooltips.add(TranslatableComponent("otm.gui.experience.dispense_all"))
|
||||
}
|
||||
|
||||
override fun onClick(mouseButton: Int) {
|
||||
@ -187,7 +187,7 @@ class EssenceStorageScreen(menu: EssenceStorageMenu, inventory: Inventory, title
|
||||
|
||||
object : LargeRectangleButtonPanel<EssenceStorageScreen>(this@EssenceStorageScreen, customBar, skinElement = STORE_CUSTOM) {
|
||||
init {
|
||||
tooltip = TranslatableComponent("otm.gui.experience.store", customDispense)
|
||||
tooltips.add(TranslatableComponent("otm.gui.experience.store", customDispense))
|
||||
}
|
||||
|
||||
override fun onClick(mouseButton: Int) {
|
||||
@ -212,7 +212,7 @@ class EssenceStorageScreen(menu: EssenceStorageMenu, inventory: Inventory, title
|
||||
|
||||
object : LargeRectangleButtonPanel<EssenceStorageScreen>(this@EssenceStorageScreen, customBar, skinElement = DISPENSE_CUSTOM) {
|
||||
init {
|
||||
tooltip = TranslatableComponent("otm.gui.experience.dispense", customDispense)
|
||||
tooltips.add(TranslatableComponent("otm.gui.experience.dispense", customDispense))
|
||||
}
|
||||
|
||||
override fun onClick(mouseButton: Int) {
|
||||
@ -226,7 +226,7 @@ class EssenceStorageScreen(menu: EssenceStorageMenu, inventory: Inventory, title
|
||||
|
||||
object : LargeRectangleButtonPanel<EssenceStorageScreen>(this@EssenceStorageScreen, customBar, skinElement = SET_EXACT) {
|
||||
init {
|
||||
tooltip = TranslatableComponent("otm.gui.experience.set_exact", customDispense)
|
||||
tooltips.add(TranslatableComponent("otm.gui.experience.set_exact", customDispense))
|
||||
dock = Dock.RIGHT
|
||||
dockMargin = DockProperty(right = 4f)
|
||||
}
|
||||
|
Binary file not shown.
Before Width: | Height: | Size: 1.3 KiB After Width: | Height: | Size: 1.4 KiB |
Loading…
Reference in New Issue
Block a user