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.enableBlend()
|
||||||
RenderSystem.enableDepthTest()
|
RenderSystem.enableDepthTest()
|
||||||
|
|
||||||
for (i in panels.indices.reversed()) {
|
for (panel in panels.asReversed()) {
|
||||||
val panel = panels[i]
|
|
||||||
RenderSystem.depthFunc(GL11.GL_ALWAYS)
|
RenderSystem.depthFunc(GL11.GL_ALWAYS)
|
||||||
RenderSystem.setShaderColor(1f, 1f, 1f, 1f)
|
RenderSystem.setShaderColor(1f, 1f, 1f, 1f)
|
||||||
panel.render(graphics, false, mouseXf, mouseYf, partialTick)
|
panel.render(graphics, 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)
|
RenderSystem.depthFunc(GL11.GL_LESS)
|
||||||
|
@ -422,8 +422,6 @@ open class EditablePanel<out S : Screen> @JvmOverloads constructor(
|
|||||||
var acceptKeyboardInput = true
|
var acceptKeyboardInput = true
|
||||||
var grabMouseInput = false
|
var grabMouseInput = false
|
||||||
|
|
||||||
open val needsPostRender: Boolean get() = false
|
|
||||||
|
|
||||||
fun tryToGrabMouseInput(): Boolean {
|
fun tryToGrabMouseInput(): Boolean {
|
||||||
if (grabMouseInput) {
|
if (grabMouseInput) {
|
||||||
return true
|
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 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 innerRenderPost(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float) {}
|
||||||
protected open fun innerRenderTooltips(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float): Boolean {
|
protected open fun innerRenderTooltips(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float): Boolean {
|
||||||
return false
|
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
|
once = true
|
||||||
|
|
||||||
if (!isVisible()) {
|
if (!isVisible()) {
|
||||||
@ -849,16 +848,13 @@ open class EditablePanel<out S : Screen> @JvmOverloads constructor(
|
|||||||
|
|
||||||
val poseStack = graphics.pose()
|
val poseStack = graphics.pose()
|
||||||
|
|
||||||
if (!post) {
|
|
||||||
performLayoutIfNeeded()
|
performLayoutIfNeeded()
|
||||||
|
|
||||||
val parent = this.parent
|
|
||||||
|
|
||||||
if (parent == null) {
|
if (parent == null) {
|
||||||
|
preRender(graphics, mouseX, mouseY, partialTick)
|
||||||
absoluteX = x
|
absoluteX = x
|
||||||
absoluteY = y
|
absoluteY = y
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
val scissor = this.scissor
|
val scissor = this.scissor
|
||||||
|
|
||||||
@ -877,16 +873,13 @@ open class EditablePanel<out S : Screen> @JvmOverloads constructor(
|
|||||||
|
|
||||||
val currentScissorRect = currentScissorRect
|
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
|
// do not render if we are getting cut off by screen scissor
|
||||||
clearDepth(graphics, absoluteX, absoluteY, width, height)
|
clearDepth(graphics, absoluteX, absoluteY, width, height)
|
||||||
poseStack.pushPose()
|
poseStack.pushPose()
|
||||||
poseStack.translate(absoluteX.toDouble(), absoluteY.toDouble(), 10.0)
|
poseStack.translate(absoluteX.toDouble(), absoluteY.toDouble(), 10.0)
|
||||||
RenderSystem.setShaderColor(1f, 1f, 1f, if (isFlashFrameRecursive) 0.5f else 1f)
|
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)
|
RenderSystem.setShaderColor(1f, 1f, 1f, 1f)
|
||||||
@ -894,10 +887,11 @@ open class EditablePanel<out S : Screen> @JvmOverloads constructor(
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (child in visibleChildrenInternal.asReversed()) {
|
for (child in visibleChildrenInternal.asReversed()) {
|
||||||
|
child.preRender(graphics, mouseX, mouseY, partialTick)
|
||||||
child.absoluteX = absoluteX + child.x + xOffset
|
child.absoluteX = absoluteX + child.x + xOffset
|
||||||
child.absoluteY = absoluteY + child.y + yOffset
|
child.absoluteY = absoluteY + child.y + yOffset
|
||||||
|
|
||||||
child.render(graphics, post, mouseX, mouseY, partialTick)
|
child.render(graphics, mouseX, mouseY, partialTick)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (scissor) {
|
if (scissor) {
|
||||||
|
@ -20,8 +20,7 @@ class Panel2Widget<out S: Screen, out P : EditablePanel<S>>(
|
|||||||
val yFloat = mouseY.toFloat()
|
val yFloat = mouseY.toFloat()
|
||||||
|
|
||||||
panel.tickHover(xFloat, yFloat)
|
panel.tickHover(xFloat, yFloat)
|
||||||
panel.render(graphics, false, xFloat, yFloat, partialTick)
|
panel.render(graphics, xFloat, yFloat, partialTick)
|
||||||
panel.render(graphics, true, xFloat, yFloat, partialTick)
|
|
||||||
panel.renderTooltips(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) {
|
override fun preRender(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float) {
|
||||||
if (parent is FramePanel<*>) {
|
|
||||||
x = parent!!.width + 3f
|
|
||||||
y = dockTop
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun tickInner() {
|
|
||||||
super.tickInner()
|
|
||||||
|
|
||||||
if (parent is FramePanel<*>) {
|
if (parent is FramePanel<*>) {
|
||||||
x = parent!!.width + 3f
|
x = parent!!.width + 3f
|
||||||
y = dockTop
|
y = dockTop
|
||||||
|
Loading…
Reference in New Issue
Block a user