From 344364520d900849e9be351e9c472e25b90532be Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sun, 9 Jul 2023 11:38:11 +0700 Subject: [PATCH] Frame panel help button, panel post render, more straightforward tooltips --- .../mc/otm/datagen/lang/English.kt | 2 + .../mc/otm/datagen/lang/Russian.kt | 2 + .../mc/otm/client/ClientEventHandler.kt | 2 +- .../client/screen/ExoPackInventoryScreen.kt | 8 +- .../mc/otm/client/screen/MatteryScreen.kt | 9 +- .../screen/decorative/CargoCrateScreen.kt | 1 + .../screen/decorative/HoloSignScreen.kt | 2 +- .../client/screen/matter/MatterPanelScreen.kt | 4 +- .../otm/client/screen/panels/EditablePanel.kt | 111 ++++++------------ .../screen/panels/EntityRendererPanel.kt | 2 +- .../mc/otm/client/screen/panels/FramePanel.kt | 80 ++++++++++++- .../otm/client/screen/panels/Panel2Widget.kt | 3 +- .../panels/button/AbstractButtonPanel.kt | 7 +- .../button/BooleanRectangleButtonPanel.kt | 15 +-- .../client/screen/panels/button/Buttons.kt | 44 +++---- .../panels/button/EnumRectangleButtonPanel.kt | 15 +-- .../screen/storage/ItemMonitorScreen.kt | 6 +- .../screen/tech/EssenceStorageScreen.kt | 22 ++-- .../textures/gui/widgets/misc.png | Bin 1327 -> 1397 bytes 19 files changed, 187 insertions(+), 148 deletions(-) diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt index ac240e091..bd6ba264a 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/English.kt @@ -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") diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt index 4faf716dd..ee2336182 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/lang/Russian.kt @@ -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", "Заблокировать содержимое") diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/ClientEventHandler.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/ClientEventHandler.kt index b8e68d950..0375aca37 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/ClientEventHandler.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/ClientEventHandler.kt @@ -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) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/ExoPackInventoryScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/ExoPackInventoryScreen.kt index 2c2a19585..7f4b2051c 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/ExoPackInventoryScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/ExoPackInventoryScreen.kt @@ -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> { 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 frame.y += movePixels diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/MatteryScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/MatteryScreen.kt index 468a71ba5..ab786302b 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/MatteryScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/MatteryScreen.kt @@ -523,7 +523,14 @@ abstract class MatteryScreen(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) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/decorative/CargoCrateScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/decorative/CargoCrateScreen.kt index bd81403cf..6aeaa70e4 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/decorative/CargoCrateScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/decorative/CargoCrateScreen.kt @@ -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) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/decorative/HoloSignScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/decorative/HoloSignScreen.kt index 059286d25..0e041f81e 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/decorative/HoloSignScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/decorative/HoloSignScreen.kt @@ -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) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/matter/MatterPanelScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/matter/MatterPanelScreen.kt index 38bc40dcb..38b61c58e 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/matter/MatterPanelScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/matter/MatterPanelScreen.kt @@ -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(this@MatterPanelScreen, frame, width = GRID_WIDTH * AbstractSlotPanel.SIZE) { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/EditablePanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/EditablePanel.kt index add7aa7cb..357b78fa6 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/EditablePanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/EditablePanel.kt @@ -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 @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 @JvmOverloads constructor( return true } - var tooltip: Component? = null - set(value) { - if (value != null) { - tooltipList = null - } - - field = value - } - - var tooltipList: List? = 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() var blockingWindow: EditablePanel<*>? = null get() { @@ -738,10 +703,15 @@ open class EditablePanel @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 @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 @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 @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 @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 @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 } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/EntityRendererPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/EntityRendererPanel.kt index 06734b95c..def0e809d 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/EntityRendererPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/EntityRendererPanel.kt @@ -81,7 +81,7 @@ class EntityRendererPanel @JvmOverloads constructor( } ) - exosuitButton.tooltip = TranslatableComponent("otm.gui.exopack.toggle_visibility") + exosuitButton.tooltips.add(TranslatableComponent("otm.gui.exopack.toggle_visibility")) } else { exosuitButton = null } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/FramePanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/FramePanel.kt index bd149b4e9..9372a505d 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/FramePanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/FramePanel.kt @@ -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( screen: S, @@ -141,6 +141,58 @@ open class FramePanel( } } + inner class HelpButton : EditablePanel(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 = ArrayList() override fun performLayout() { @@ -150,18 +202,38 @@ open class FramePanel( } 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): HelpButton { + if (helpButton == null) { + helpButton = HelpButton() + helpButton!!.tooltips.addAll(tooltips) + } + + return helpButton!! } /** @@ -315,6 +387,10 @@ open class FramePanel( 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 diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/Panel2Widget.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/Panel2Widget.kt index 7610be9bd..65ce9462e 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/Panel2Widget.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/Panel2Widget.kt @@ -20,7 +20,8 @@ class Panel2Widget>( 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) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/AbstractButtonPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/AbstractButtonPanel.kt index 15f224659..1fbefa244 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/AbstractButtonPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/AbstractButtonPanel.kt @@ -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( @@ -65,4 +64,8 @@ abstract class AbstractButtonPanel( return true } + + override fun shouldRenderTooltips(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float): Boolean { + return super.shouldRenderTooltips(graphics, mouseX, mouseY, partialTick) || isPressed + } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/BooleanRectangleButtonPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/BooleanRectangleButtonPanel.kt index 4fda37f4d..d6000d0a5 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/BooleanRectangleButtonPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/BooleanRectangleButtonPanel.kt @@ -36,19 +36,12 @@ abstract class BooleanRectangleButtonPanel( 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(2) + if (tooltipActive != null || tooltipInactive != null || tooltips.isNotEmpty()) { + val tooltips = ArrayList(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) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/Buttons.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/Buttons.kt index 96d5ae994..cf0be7ad5 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/Buttons.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/Buttons.kt @@ -81,12 +81,12 @@ private class PullPushButton, T : Enum>( val pushProp: BooleanInputWithFeedback ) : LargeEnumRectangleButtonPanel(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>( skinElement = Widgets18.UPGRADES ) { init { - tooltip = TranslatableComponent("otm.gui.upgrades") + tooltips.add(TranslatableComponent("otm.gui.upgrades")) } - override fun tickInner() { - super.tickInner() - - tooltipList = ArrayList().also { + override fun innerRenderTooltips(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float): Boolean { + graphics.renderComponentTooltip(font, ArrayList().also { it.add(TranslatableComponent("otm.gui.upgrades")) it.add(TextComponent("")) @@ -372,7 +370,9 @@ class DeviceControls>( 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>( 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>( if (itemConfig != null) { itemConfigButton = addButton(object : LargeRectangleButtonPanel(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>( if (energyConfig != null) { energyConfigButton = addButton(object : LargeRectangleButtonPanel(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>( if (fluidConfig != null) { fluidConfigButton = addButton(object : LargeRectangleButtonPanel(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) { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/EnumRectangleButtonPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/EnumRectangleButtonPanel.kt index 84571b6e8..c7332ec61 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/EnumRectangleButtonPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/EnumRectangleButtonPanel.kt @@ -151,23 +151,14 @@ abstract class EnumRectangleButtonPanel>( } 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() - 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) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/storage/ItemMonitorScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/storage/ItemMonitorScreen.kt index 965518f7c..f139c43da 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/storage/ItemMonitorScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/storage/ItemMonitorScreen.kt @@ -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) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/EssenceStorageScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/EssenceStorageScreen.kt index 896c8513d..0853c201c 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/EssenceStorageScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/EssenceStorageScreen.kt @@ -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(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(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(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(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(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(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(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(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(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) } diff --git a/src/main/resources/assets/overdrive_that_matters/textures/gui/widgets/misc.png b/src/main/resources/assets/overdrive_that_matters/textures/gui/widgets/misc.png index bc3b614b3dd43b4cce917a916ff7fc140deec3db..defe0ff4e3e1ee706b645d29f6c32f68b0348c7c 100644 GIT binary patch delta 929 zcmV;S177^E3iS%G;{ksO1Rw~M>lRD^00VMKL_t(|+U=UZOB_KI$KN}yzapgaKQL(o zSwRV;N~eX~>OT;RErlIpkv|~u1PLTA#MHvwfd~mUslA13Bt?YSgam|;L*W|Rm%`h1 zz3lwho!PxTnGY;F>)W~czIkuv?VPx=5v{vv-Ha9x)G0J`1o?L&0? z7$RcIbJ}C%jiVk3(82e8V2q7)@W+aXl>Bg2M1AH`pBP8YV80|AXs_2RVm33A97nyV z4@nDU*LBHtUFdeZlx23qFf=;0y}dn%#!)Lvd>WljCv)GP=f#)IPSn1)226s@&CSd+ z>v#Ny z0pItz6(b_z($bQ0-^V|GD%m}H*HW^3w!a^j!bT&&ah!kn-2f4BWo0Eb5_tE^B3NAo z@92mC01K-Fh=@cL;r8~nvJ*PL21<5sE-sYpzFb|wtGPLNdv->JZi7Ya2H)96e2G{d z42128SAu!PKWQCs+etn@ehkZl!M&fU4rn%;q6Mo`@Wk?vi3b3vGsdFB4Bc?gy0xLn zXyB!RGy;DB0M^#lw8ZCmtu0HuEE1%PV7uLhcDp@wsW2{<7XdYy__W`vuo#w73a_uP zYrPqn+6E6_IRD-ImU8bfM=6Y8=#aA2YTesSRFB0}cz^O$X^c-leo*S~`SEe=gc=cn ziHk9YBVeSRIM>8^JwG3f?=}T?cXzcqOw7FWXgq(7QV5sN+;4q>Cw$i55criN)|ysb?3krR00V+TyjyFgkr$kIUOgsD6h&mw+29a1A8 zI>~>@OTXW*Tq=yuc*`l><|%%2*NPruJ&X96oFN6rqBUd zQed?Gk?dTcO5$S&80qM4|CjZLRZ6G2?(A1xpwjE`w4Dfi6a5hNeC+j{;M3^fZhQSQO0M~U{z-o!!`+08Y z_lJpJ#xzY~dtrYMSO?8!le}VKVGw78UatqHX)ZiB$^fI$NJ>1#6XL{Yy$R;Rve>vV z;6{idHxJ->KMiNYA#HaL5g+FXSsDNlk$IjcB{nOT#YTle)**nEN=4XVR{7zkgw!fR z0E2m6REB0vobe+|;jCj^(=@OwE3#rlM66b;nH%8G=_!Ay--q+_c`2N!2WXl$|29BG ztkr6vo)GnWZu`T@37D6c3;=LtS%5LdL=|DH)ymum?;jsY{eC?^!`FiY_M%lJ!#6qJi;K( z2t@#ZdcA)xHBj2m+C0R^c|zqn@ZDgL zxD-Z^Jf!5b+wFyHB6+->ir>e_BrPAWuI5HSmh@Cou;RQ3q*{Mn1{gd&!MEF6n3uwx zPDg6sz{$%a{L=IoGJulSAWw5lJwt3g1;D2-Bc!Xl#uEcG<-h3WY+UP$(1% kg+ifFC=?2XLZSH2KWe9D*)zAxga7~l07*qoM6N<$f|DPbn*aa+