Add preRender protected hook to panels, and remove unused postrender hook
This commit is contained in:
parent
2766a444d6
commit
8e962f69ff
@ -665,18 +665,10 @@ abstract class MatteryScreen<T : MatteryMenu>(menu: T, inventory: Inventory, tit
|
||||
RenderSystem.enableBlend()
|
||||
RenderSystem.enableDepthTest()
|
||||
|
||||
for (i in panels.indices.reversed()) {
|
||||
val panel = panels[i]
|
||||
for (panel in panels.asReversed()) {
|
||||
RenderSystem.depthFunc(GL11.GL_ALWAYS)
|
||||
RenderSystem.setShaderColor(1f, 1f, 1f, 1f)
|
||||
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)
|
||||
panel.render(graphics, mouseXf, mouseYf, partialTick)
|
||||
}
|
||||
|
||||
RenderSystem.depthFunc(GL11.GL_LESS)
|
||||
|
@ -422,8 +422,6 @@ 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
|
||||
@ -788,6 +786,7 @@ open class EditablePanel<out S : Screen> @JvmOverloads constructor(
|
||||
}
|
||||
|
||||
protected open fun innerRender(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float) {}
|
||||
protected open fun preRender(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
|
||||
@ -840,7 +839,7 @@ open class EditablePanel<out S : Screen> @JvmOverloads constructor(
|
||||
}
|
||||
}
|
||||
|
||||
fun render(graphics: GuiGraphics, post: Boolean, mouseX: Float, mouseY: Float, partialTick: Float) {
|
||||
fun render(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float) {
|
||||
once = true
|
||||
|
||||
if (!isVisible()) {
|
||||
@ -849,15 +848,12 @@ open class EditablePanel<out S : Screen> @JvmOverloads constructor(
|
||||
|
||||
val poseStack = graphics.pose()
|
||||
|
||||
if (!post) {
|
||||
performLayoutIfNeeded()
|
||||
performLayoutIfNeeded()
|
||||
|
||||
val parent = this.parent
|
||||
|
||||
if (parent == null) {
|
||||
absoluteX = x
|
||||
absoluteY = y
|
||||
}
|
||||
if (parent == null) {
|
||||
preRender(graphics, mouseX, mouseY, partialTick)
|
||||
absoluteX = x
|
||||
absoluteY = y
|
||||
}
|
||||
|
||||
val scissor = this.scissor
|
||||
@ -877,27 +873,25 @@ open class EditablePanel<out S : Screen> @JvmOverloads constructor(
|
||||
|
||||
val currentScissorRect = currentScissorRect
|
||||
|
||||
if ((!post || needsPostRender) && (currentScissorRect == null || currentScissorRect.crossScaled(absoluteX, absoluteY, width, height))) {
|
||||
if (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)
|
||||
|
||||
if (post)
|
||||
innerRenderPost(graphics, mouseX, mouseY, partialTick)
|
||||
else
|
||||
innerRender(graphics, mouseX, mouseY, partialTick)
|
||||
innerRender(graphics, mouseX, mouseY, partialTick)
|
||||
|
||||
RenderSystem.setShaderColor(1f, 1f, 1f, 1f)
|
||||
poseStack.popPose()
|
||||
}
|
||||
|
||||
for (child in visibleChildrenInternal.asReversed()) {
|
||||
child.preRender(graphics, mouseX, mouseY, partialTick)
|
||||
child.absoluteX = absoluteX + child.x + xOffset
|
||||
child.absoluteY = absoluteY + child.y + yOffset
|
||||
|
||||
child.render(graphics, post, mouseX, mouseY, partialTick)
|
||||
child.render(graphics, mouseX, mouseY, partialTick)
|
||||
}
|
||||
|
||||
if (scissor) {
|
||||
|
@ -20,8 +20,7 @@ class Panel2Widget<out S: Screen, out P : EditablePanel<S>>(
|
||||
val yFloat = mouseY.toFloat()
|
||||
|
||||
panel.tickHover(xFloat, yFloat)
|
||||
panel.render(graphics, false, xFloat, yFloat, partialTick)
|
||||
panel.render(graphics, true, xFloat, yFloat, partialTick)
|
||||
panel.render(graphics, xFloat, yFloat, partialTick)
|
||||
panel.renderTooltips(graphics, xFloat, yFloat, partialTick)
|
||||
}
|
||||
|
||||
|
@ -624,16 +624,7 @@ class DeviceControls<out S : MatteryScreen<*>>(
|
||||
}
|
||||
}
|
||||
|
||||
override fun innerRender(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float) {
|
||||
if (parent is FramePanel<*>) {
|
||||
x = parent!!.width + 3f
|
||||
y = dockTop
|
||||
}
|
||||
}
|
||||
|
||||
override fun tickInner() {
|
||||
super.tickInner()
|
||||
|
||||
override fun preRender(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float) {
|
||||
if (parent is FramePanel<*>) {
|
||||
x = parent!!.width + 3f
|
||||
y = dockTop
|
||||
|
Loading…
Reference in New Issue
Block a user