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 0f775924f..ee5bb1ad5 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 @@ -213,7 +213,7 @@ abstract class MatteryScreen(menu: T, inventory: Inventory, tit if (menu.playerInventorySlots.isNotEmpty() && menu.autoCreateInventoryFrame) { val deviceControls: DeviceControls> - if (menu.player.matteryPlayer?.hasExopack != true) { + if (!menu.player.matteryPlayer.hasExopack) { inventoryFrame = FramePanel>(this, null, 0f, 0f, INVENTORY_FRAME_WIDTH, INVENTORY_FRAME_HEIGHT, inventory.displayName).also(this::addPanel) inventoryFrame!!.makeHelpButton().addSlotFiltersHelp() @@ -669,6 +669,13 @@ abstract class MatteryScreen(menu: T, inventory: Inventory, tit panels.forEach { it.tickHovered1() } panels.forEach { it.tickHovered2() } + // EMI workaround for not rendering itself properly, the way JEI does + graphics.pose().pushPose() + graphics.pose().translate(guiLeft.toFloat(), guiTop.toFloat(), 0f) + NeoForge.EVENT_BUS.post(ContainerScreenEvent.Render.Background(this, graphics, mouseX, mouseY)) + graphics.pose().popPose() + RenderSystem.disableDepthTest() + RenderSystem.defaultBlendFunc() RenderSystem.enableBlend() RenderSystem.enableDepthTest() @@ -683,11 +690,6 @@ abstract class MatteryScreen(menu: T, inventory: Inventory, tit panelsReversed.any { it.updateCursor1() } RenderSystem.depthFunc(GL11.GL_LESS) - graphics.pose().pushPose() - graphics.pose().translate(guiLeft.toFloat(), guiTop.toFloat(), 0f) - NeoForge.EVENT_BUS.post(ContainerScreenEvent.Render.Background(this, graphics, mouseX, mouseY)) - graphics.pose().popPose() - RenderSystem.disableDepthTest() // Screen.super.render for (widget in renderables) { @@ -696,6 +698,8 @@ abstract class MatteryScreen(menu: T, inventory: Inventory, tit // /Screen.super.render RenderSystem.disableDepthTest() + + // EMI workaround for not rendering itself properly, the way JEI does graphics.pose().pushPose() graphics.pose().translate(guiLeft.toFloat(), guiTop.toFloat(), 0f) NeoForge.EVENT_BUS.post(ContainerScreenEvent.Render.Foreground(this, graphics, mouseX, mouseY)) 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 39260fc3e..f12b165fe 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 @@ -20,6 +20,7 @@ import ru.dbotthepony.mc.otm.client.CursorType import ru.dbotthepony.mc.otm.client.render.MGUIGraphics import ru.dbotthepony.mc.otm.client.minecraft import ru.dbotthepony.mc.otm.client.moveMousePosScaled +import ru.dbotthepony.mc.otm.client.render.RenderGravity import ru.dbotthepony.mc.otm.client.render.currentScissorRect import ru.dbotthepony.mc.otm.client.render.popScissorRect import ru.dbotthepony.mc.otm.client.render.pushScissorRect @@ -320,14 +321,32 @@ open class EditablePanel( } } - // Позволяет смещать потомков на эту координату + /** + * Specifies how to offset ("scroll") children panels on X coordinate + */ var xOffset = 0f + + /** + * Specifies how to offset ("scroll") children panels on Y coordinate + */ var yOffset = 0f - // Обрезать отрисовку потомков? + /** + * Push scissor to scissor stack when rendering this panel? + * + * Useful for when panel calls rendering code which can exceed panel's bounds and this outcome is undesired + */ var scissor = false var scissorLock = false + + /** + * Extends or shrinks scissor bounds when [scissor] is true + */ var scissorPadding = DockProperty.EMPTY + + /** + * Automatic panel docking to one of sides + */ var dock = Dock.NONE set(value) { if (field != value) { @@ -335,6 +354,12 @@ open class EditablePanel( parent?.layoutInvalidated = true } } + + /** + * Allows to specify how to resize panel while docking + * + * If a side does not get resized, panel gets repositioned according to [dockGravity] + */ var dockResize = DockResizeMode.ALL set(value) { if (field != value) { @@ -342,6 +367,23 @@ open class EditablePanel( parent?.layoutInvalidated = true } } + + /** + * Specifies how to handle panel repositioning if there are gaps due to [dockResize] not being [DockResizeMode.ALL] + */ + var dockGravity = RenderGravity.CENTER_CENTER + set(value) { + if (field != value) { + field = value + + if (dockResize != DockResizeMode.ALL) + parent?.layoutInvalidated = true + } + } + + /** + * Positioning of this panel against docking edges + */ var dockMargin = DockProperty.EMPTY set(value) { if (field != value) { @@ -386,6 +428,9 @@ open class EditablePanel( } } + /** + * Positioning of children panels against this panel's edges + */ var dockPadding = DockProperty.EMPTY set(value) { if (field != value) { @@ -1219,7 +1264,7 @@ open class EditablePanel( if (child.dockResize.changeHeight) child.height = child.dockedHeight else if (child.height != child.dockedHeight) - child.y += (child.dockedHeight / 2f - child.height / 2f).roundToInt().toFloat() + child.y += dockGravity.repositionY(child.dockedHeight, child.height).roundToInt().toFloat() } Dock.RIGHT -> { @@ -1233,7 +1278,7 @@ open class EditablePanel( if (child.dockResize.changeHeight) child.height = child.dockedHeight else if (child.height != child.dockedHeight) - child.y += (child.dockedHeight / 2f - child.height / 2f).roundToInt().toFloat() + child.y += dockGravity.repositionY(child.dockedHeight, child.height).roundToInt().toFloat() } Dock.TOP -> { @@ -1261,7 +1306,7 @@ open class EditablePanel( if (child.dockResize.changeWidth) child.width = child.dockedWidth else if (child.width != child.dockedWidth) - child.x += (child.dockedWidth / 2f - child.width / 2f).roundToInt().toFloat() + child.x += dockGravity.repositionX(child.dockedWidth, child.width).roundToInt().toFloat() } } } @@ -1284,12 +1329,12 @@ open class EditablePanel( if (child.dockResize.changeHeight) child.height = child.dockedHeight else if (child.height != child.dockedHeight) - child.y += child.dockedHeight / 2f - child.height / 2f + child.y += dockGravity.repositionY(child.dockedHeight, child.height).roundToInt().toFloat() if (child.dockResize.changeWidth) child.width = child.dockedWidth else if (child.width != child.dockedWidth) - child.x += child.dockedWidth / 2f - child.width / 2f + child.x += dockGravity.repositionX(child.dockedWidth, child.width).roundToInt().toFloat() } }