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 69fefd36a..011b4ea92 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 @@ -440,6 +440,10 @@ open class EditablePanel @JvmOverloads constructor( } fun calculateAbsoluteRectangle(): Rect2f { + if (scissor) { + return Rect2f(absoluteX, absoluteY, width, height) + } + val x = if (childrenRectX < 0) childrenRectX + absoluteX else absoluteX val y = if (childrenRectY < 0) childrenRectY + absoluteY else absoluteY val width = if (childrenRectWidth > width) childrenRectWidth else width @@ -449,6 +453,10 @@ open class EditablePanel @JvmOverloads constructor( } fun calculateAbsoluteRectangles(): List { + if (scissor) { + return listOf(Rect2f(absoluteX, absoluteY, width, height)) + } + if (childrenRectX >= 0 && childrenRectY >= 0 && childrenRectWidth <= width && childrenRectHeight <= height) { return listOf(Rect2f(absoluteX, absoluteY, width, height)) } @@ -465,6 +473,41 @@ open class EditablePanel @JvmOverloads constructor( return result } + /** + * Whenever [calculateAbsoluteObstructingRectangle] and [calculateAbsoluteObstructingRectangles] treat + * *this* panel visible. Does not affect children. + */ + var isObstructing = true + protected set + + fun calculateAbsoluteObstructingRectangle(): Rect2f { + if (!isObstructing) { + return Rect2f(childrenRectX + absoluteX, childrenRectY + absoluteY, childrenRectWidth, childrenRectHeight) + } + + return calculateAbsoluteRectangle() + } + + fun calculateAbsoluteObstructingRectangles(): List { + if (childrenRectX >= 0 && childrenRectY >= 0 && childrenRectWidth <= width && childrenRectHeight <= height && isObstructing) { + return listOf(Rect2f(absoluteX, absoluteY, width, height)) + } + + val result = ArrayList() + + if (isObstructing) { + result.add(Rect2f(absoluteX, absoluteY, width, height)) + } + + for (children in children) { + if ((children.isOutsideOfParent || !isObstructing) && children.isVisible()) { + result.addAll(children.calculateAbsoluteObstructingRectangles()) + } + } + + return result + } + // Абсолютная координата, обновляется на отрисовке var absoluteX = 0f private set diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/EffectListPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/EffectListPanel.kt index 15ae3d4a7..e890f537d 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/EffectListPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/EffectListPanel.kt @@ -32,7 +32,11 @@ open class EffectListPanel @JvmOverloads constructor( gridWidth: Int = 2, gridHeight: Int = 2, ) : EditablePanel(screen, parent, x, y, gridWidth * (SQUARE_THIN.width + 2f), gridHeight * (SQUARE_THIN.height + 2f)) { - val scroll: DiscreteScrollBarPanel = DiscreteScrollBarPanel(screen, this, this::calculateMaxScroll, this::onScrolled, height = height) + val scroll: DiscreteScrollBarPanel = DiscreteScrollBarPanel(screen, this, this::calculateMaxScroll, this::onScrolled, height = height) + + init { + isObstructing = false + } var alignOnRight = true @@ -170,6 +174,10 @@ open class EffectListPanel @JvmOverloads constructor( } val canvas = object : EditablePanel(screen, this@EffectListPanel, 0f, 0f, width, height) { + init { + isObstructing = false + } + override fun performLayout() { super.performLayout() diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jei/JEIPlugin.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jei/JEIPlugin.kt index 5402515d7..de5b6390f 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jei/JEIPlugin.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jei/JEIPlugin.kt @@ -217,7 +217,15 @@ class JEIPlugin : IModPlugin { override fun registerGuiHandlers(registration: IGuiHandlerRegistration) { registration.addGenericGuiContainerHandler(MatteryScreen::class.java, object : IGuiContainerHandler> { override fun getGuiExtraAreas(containerScreen: MatteryScreen<*>): MutableList { - return containerScreen.panelsView.stream().map { it.performLayoutIfNeeded(); it.updateAbsoluteCoordinates(); it.calculateAbsoluteRectangles() }.flatMap { it.stream() }.map { it.toIntRect() }.collect(Collectors.toList()) + return containerScreen.panelsView.stream() + .map { + it.performLayoutIfNeeded() + it.updateAbsoluteCoordinates() + it.calculateAbsoluteObstructingRectangles() + } + .flatMap { it.stream() } + .map { it.toIntRect() } + .collect(Collectors.toList()) } override fun getIngredientUnderMouse(