parent
d26660c917
commit
9a218de5e7
@ -440,6 +440,10 @@ open class EditablePanel<out S : Screen> @JvmOverloads constructor(
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun calculateAbsoluteRectangle(): Rect2f {
|
fun calculateAbsoluteRectangle(): Rect2f {
|
||||||
|
if (scissor) {
|
||||||
|
return Rect2f(absoluteX, absoluteY, width, height)
|
||||||
|
}
|
||||||
|
|
||||||
val x = if (childrenRectX < 0) childrenRectX + absoluteX else absoluteX
|
val x = if (childrenRectX < 0) childrenRectX + absoluteX else absoluteX
|
||||||
val y = if (childrenRectY < 0) childrenRectY + absoluteY else absoluteY
|
val y = if (childrenRectY < 0) childrenRectY + absoluteY else absoluteY
|
||||||
val width = if (childrenRectWidth > width) childrenRectWidth else width
|
val width = if (childrenRectWidth > width) childrenRectWidth else width
|
||||||
@ -449,6 +453,10 @@ open class EditablePanel<out S : Screen> @JvmOverloads constructor(
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun calculateAbsoluteRectangles(): List<Rect2f> {
|
fun calculateAbsoluteRectangles(): List<Rect2f> {
|
||||||
|
if (scissor) {
|
||||||
|
return listOf(Rect2f(absoluteX, absoluteY, width, height))
|
||||||
|
}
|
||||||
|
|
||||||
if (childrenRectX >= 0 && childrenRectY >= 0 && childrenRectWidth <= width && childrenRectHeight <= height) {
|
if (childrenRectX >= 0 && childrenRectY >= 0 && childrenRectWidth <= width && childrenRectHeight <= height) {
|
||||||
return listOf(Rect2f(absoluteX, absoluteY, width, height))
|
return listOf(Rect2f(absoluteX, absoluteY, width, height))
|
||||||
}
|
}
|
||||||
@ -465,6 +473,41 @@ open class EditablePanel<out S : Screen> @JvmOverloads constructor(
|
|||||||
return result
|
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<Rect2f> {
|
||||||
|
if (childrenRectX >= 0 && childrenRectY >= 0 && childrenRectWidth <= width && childrenRectHeight <= height && isObstructing) {
|
||||||
|
return listOf(Rect2f(absoluteX, absoluteY, width, height))
|
||||||
|
}
|
||||||
|
|
||||||
|
val result = ArrayList<Rect2f>()
|
||||||
|
|
||||||
|
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
|
var absoluteX = 0f
|
||||||
private set
|
private set
|
||||||
|
@ -32,7 +32,11 @@ open class EffectListPanel<out S : Screen> @JvmOverloads constructor(
|
|||||||
gridWidth: Int = 2,
|
gridWidth: Int = 2,
|
||||||
gridHeight: Int = 2,
|
gridHeight: Int = 2,
|
||||||
) : EditablePanel<S>(screen, parent, x, y, gridWidth * (SQUARE_THIN.width + 2f), gridHeight * (SQUARE_THIN.height + 2f)) {
|
) : EditablePanel<S>(screen, parent, x, y, gridWidth * (SQUARE_THIN.width + 2f), gridHeight * (SQUARE_THIN.height + 2f)) {
|
||||||
val scroll: DiscreteScrollBarPanel<out S> = DiscreteScrollBarPanel(screen, this, this::calculateMaxScroll, this::onScrolled, height = height)
|
val scroll: DiscreteScrollBarPanel<S> = DiscreteScrollBarPanel(screen, this, this::calculateMaxScroll, this::onScrolled, height = height)
|
||||||
|
|
||||||
|
init {
|
||||||
|
isObstructing = false
|
||||||
|
}
|
||||||
|
|
||||||
var alignOnRight = true
|
var alignOnRight = true
|
||||||
|
|
||||||
@ -170,6 +174,10 @@ open class EffectListPanel<out S : Screen> @JvmOverloads constructor(
|
|||||||
}
|
}
|
||||||
|
|
||||||
val canvas = object : EditablePanel<S>(screen, this@EffectListPanel, 0f, 0f, width, height) {
|
val canvas = object : EditablePanel<S>(screen, this@EffectListPanel, 0f, 0f, width, height) {
|
||||||
|
init {
|
||||||
|
isObstructing = false
|
||||||
|
}
|
||||||
|
|
||||||
override fun performLayout() {
|
override fun performLayout() {
|
||||||
super.performLayout()
|
super.performLayout()
|
||||||
|
|
||||||
|
@ -217,7 +217,15 @@ class JEIPlugin : IModPlugin {
|
|||||||
override fun registerGuiHandlers(registration: IGuiHandlerRegistration) {
|
override fun registerGuiHandlers(registration: IGuiHandlerRegistration) {
|
||||||
registration.addGenericGuiContainerHandler(MatteryScreen::class.java, object : IGuiContainerHandler<MatteryScreen<*>> {
|
registration.addGenericGuiContainerHandler(MatteryScreen::class.java, object : IGuiContainerHandler<MatteryScreen<*>> {
|
||||||
override fun getGuiExtraAreas(containerScreen: MatteryScreen<*>): MutableList<Rect2i> {
|
override fun getGuiExtraAreas(containerScreen: MatteryScreen<*>): MutableList<Rect2i> {
|
||||||
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(
|
override fun getIngredientUnderMouse(
|
||||||
|
Loading…
Reference in New Issue
Block a user