Arbitrary tooltips on panels support
This commit is contained in:
parent
abd52a64b1
commit
47816d6cb3
@ -6,6 +6,7 @@ import com.mojang.blaze3d.vertex.PoseStack
|
|||||||
import net.minecraft.client.Minecraft
|
import net.minecraft.client.Minecraft
|
||||||
import net.minecraft.client.gui.Font
|
import net.minecraft.client.gui.Font
|
||||||
import net.minecraft.client.gui.components.events.GuiEventListener
|
import net.minecraft.client.gui.components.events.GuiEventListener
|
||||||
|
import net.minecraft.network.chat.Component
|
||||||
import org.apache.logging.log4j.LogManager
|
import org.apache.logging.log4j.LogManager
|
||||||
import ru.dbotthepony.mc.otm.client.render.popScissorRect
|
import ru.dbotthepony.mc.otm.client.render.popScissorRect
|
||||||
import ru.dbotthepony.mc.otm.client.render.pushScissorRect
|
import ru.dbotthepony.mc.otm.client.render.pushScissorRect
|
||||||
@ -225,6 +226,24 @@ open class EditablePanel @JvmOverloads constructor(
|
|||||||
var acceptKeyboardInput = true
|
var acceptKeyboardInput = true
|
||||||
var trapMouseInput = false
|
var trapMouseInput = false
|
||||||
|
|
||||||
|
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
|
||||||
|
}
|
||||||
|
|
||||||
@JvmOverloads
|
@JvmOverloads
|
||||||
fun setDockMargin(left: Float = 0f, top: Float = 0f, right: Float = 0f, bottom: Float = 0f) {
|
fun setDockMargin(left: Float = 0f, top: Float = 0f, right: Float = 0f, bottom: Float = 0f) {
|
||||||
dockMargin = DockProperty(left, top, right, bottom)
|
dockMargin = DockProperty(left, top, right, bottom)
|
||||||
@ -421,12 +440,39 @@ open class EditablePanel @JvmOverloads constructor(
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (child in children) {
|
||||||
|
if (child.isVisible() && child.renderTooltips(stack, mouse_x, mouse_y, flag)) {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (innerRenderTooltips(stack, mouse_x, mouse_y, flag)) {
|
if (innerRenderTooltips(stack, mouse_x, mouse_y, flag)) {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
for (child in children) {
|
if (isHovered) {
|
||||||
if (child.isVisible() && child.renderTooltips(stack, mouse_x, mouse_y, flag)) {
|
val tooltip = tooltip
|
||||||
|
val tooltipList = tooltipList
|
||||||
|
|
||||||
|
if (tooltip != null) {
|
||||||
|
screen.renderComponentTooltip(
|
||||||
|
stack,
|
||||||
|
listOf(tooltip),
|
||||||
|
mouse_x.toInt(),
|
||||||
|
mouse_y.toInt(),
|
||||||
|
screen.font
|
||||||
|
)
|
||||||
|
|
||||||
|
return true
|
||||||
|
} else if (tooltipList != null) {
|
||||||
|
screen.renderComponentTooltip(
|
||||||
|
stack,
|
||||||
|
tooltipList,
|
||||||
|
mouse_x.toInt(),
|
||||||
|
mouse_y.toInt(),
|
||||||
|
screen.font
|
||||||
|
)
|
||||||
|
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user