Rename children properties
This commit is contained in:
parent
44da2c4b11
commit
d403fca482
@ -3,7 +3,6 @@ package ru.dbotthepony.mc.otm.client.screen.panels
|
||||
import com.google.common.collect.ImmutableList
|
||||
import com.mojang.blaze3d.systems.RenderSystem
|
||||
import com.mojang.blaze3d.vertex.PoseStack
|
||||
import it.unimi.dsi.fastutil.objects.ObjectArraySet
|
||||
import it.unimi.dsi.fastutil.objects.ReferenceArraySet
|
||||
import net.minecraft.client.gui.Font
|
||||
import net.minecraft.client.gui.components.events.GuiEventListener
|
||||
@ -20,7 +19,6 @@ import ru.dbotthepony.mc.otm.client.render.currentScissorRect
|
||||
import ru.dbotthepony.mc.otm.client.render.popScissorRect
|
||||
import ru.dbotthepony.mc.otm.client.render.pushScissorRect
|
||||
import ru.dbotthepony.mc.otm.client.screen.MatteryScreen
|
||||
import ru.dbotthepony.mc.otm.nanoTime
|
||||
import java.util.*
|
||||
import kotlin.collections.ArrayList
|
||||
import kotlin.math.roundToInt
|
||||
@ -170,9 +168,10 @@ open class EditablePanel<out S : Screen> @JvmOverloads constructor(
|
||||
var dockedHeight: Float = 0f
|
||||
private set
|
||||
|
||||
private val children = ArrayList<EditablePanel<*>>()
|
||||
private val visibleChildren = ArrayList<EditablePanel<*>>()
|
||||
val childrenView: List<EditablePanel<*>> = Collections.unmodifiableList(children)
|
||||
private val childrenInternal = ArrayList<EditablePanel<*>>()
|
||||
private val visibleChildrenInternal = ArrayList<EditablePanel<*>>()
|
||||
val children: List<EditablePanel<*>> = Collections.unmodifiableList(childrenInternal)
|
||||
val visibleChildren: List<EditablePanel<*>> = Collections.unmodifiableList(visibleChildrenInternal)
|
||||
|
||||
var layoutInvalidated = true
|
||||
private set
|
||||
@ -191,7 +190,7 @@ open class EditablePanel<out S : Screen> @JvmOverloads constructor(
|
||||
|
||||
if (old != new) {
|
||||
visibilityChanges(new, old)
|
||||
val visibleChildrenParent = parent?.visibleChildren
|
||||
val visibleChildrenParent = parent?.visibleChildrenInternal
|
||||
|
||||
if (new) {
|
||||
killFocus()
|
||||
@ -384,7 +383,7 @@ open class EditablePanel<out S : Screen> @JvmOverloads constructor(
|
||||
return true
|
||||
}
|
||||
|
||||
for (children in children) {
|
||||
for (children in childrenInternal) {
|
||||
if (children.flashAnyBlockerInner(doFlash)) {
|
||||
return true
|
||||
}
|
||||
@ -477,7 +476,7 @@ open class EditablePanel<out S : Screen> @JvmOverloads constructor(
|
||||
val result = ArrayList<Rect2f>()
|
||||
result.add(Rect2f(absoluteX, absoluteY, width, height))
|
||||
|
||||
for (children in children) {
|
||||
for (children in childrenInternal) {
|
||||
if (children.isOutsideOfParent && children.isVisible()) {
|
||||
result.addAll(children.calculateAbsoluteRectangles())
|
||||
}
|
||||
@ -517,7 +516,7 @@ open class EditablePanel<out S : Screen> @JvmOverloads constructor(
|
||||
result.add(Rect2f(absoluteX, absoluteY, width, height))
|
||||
}
|
||||
|
||||
for (children in visibleChildren) {
|
||||
for (children in visibleChildrenInternal) {
|
||||
if (children.isOutsideOfParent || !isObstructing) {
|
||||
result.addAll(children.calculateAbsoluteObstructingRectangles())
|
||||
}
|
||||
@ -547,7 +546,7 @@ open class EditablePanel<out S : Screen> @JvmOverloads constructor(
|
||||
fun unsetHovered() {
|
||||
isHovered = false
|
||||
|
||||
for (child in children) {
|
||||
for (child in childrenInternal) {
|
||||
child.unsetHovered()
|
||||
}
|
||||
}
|
||||
@ -594,11 +593,11 @@ open class EditablePanel<out S : Screen> @JvmOverloads constructor(
|
||||
}
|
||||
|
||||
private fun onParent(child: EditablePanel<*>) {
|
||||
if (children.contains(child)) throw IllegalStateException("Already containing $child")
|
||||
children.add(child)
|
||||
if (childrenInternal.contains(child)) throw IllegalStateException("Already containing $child")
|
||||
childrenInternal.add(child)
|
||||
|
||||
if (child.visible) {
|
||||
visibleChildren.add(child)
|
||||
visibleChildrenInternal.add(child)
|
||||
layoutInvalidated = true
|
||||
}
|
||||
|
||||
@ -608,12 +607,12 @@ open class EditablePanel<out S : Screen> @JvmOverloads constructor(
|
||||
}
|
||||
|
||||
private fun onUnParent(child: EditablePanel<*>) {
|
||||
val indexOf = children.indexOf(child)
|
||||
val indexOf = childrenInternal.indexOf(child)
|
||||
if (indexOf == -1) throw IllegalStateException("Already not containing $child")
|
||||
children.removeAt(indexOf)
|
||||
childrenInternal.removeAt(indexOf)
|
||||
|
||||
if (child.visible) {
|
||||
visibleChildren.remove(child)
|
||||
visibleChildrenInternal.remove(child)
|
||||
layoutInvalidated = true
|
||||
}
|
||||
|
||||
@ -659,7 +658,7 @@ open class EditablePanel<out S : Screen> @JvmOverloads constructor(
|
||||
absoluteY = y
|
||||
}
|
||||
|
||||
for (child in visibleChildren) {
|
||||
for (child in visibleChildrenInternal) {
|
||||
child.absoluteX = absoluteX + child.x + xOffset
|
||||
child.absoluteY = absoluteY + child.y + yOffset
|
||||
|
||||
@ -719,7 +718,7 @@ open class EditablePanel<out S : Screen> @JvmOverloads constructor(
|
||||
poseStack.popPose()
|
||||
}
|
||||
|
||||
for (child in visibleChildren) {
|
||||
for (child in visibleChildrenInternal) {
|
||||
child.absoluteX = absoluteX + child.x + xOffset
|
||||
child.absoluteY = absoluteY + child.y + yOffset
|
||||
|
||||
@ -739,7 +738,7 @@ open class EditablePanel<out S : Screen> @JvmOverloads constructor(
|
||||
if ((childrenRectHeight > height || childrenRectWidth > width || childrenRectX < 0 || childrenRectY < 0) && parent == null) {
|
||||
var hit = false
|
||||
|
||||
for (child in children) {
|
||||
for (child in childrenInternal) {
|
||||
if (child.tickHover(mouseX, mouseY)) {
|
||||
hit = true
|
||||
}
|
||||
@ -778,7 +777,7 @@ open class EditablePanel<out S : Screen> @JvmOverloads constructor(
|
||||
return true to this.slot
|
||||
}
|
||||
|
||||
for (child in visibleChildren) {
|
||||
for (child in visibleChildrenInternal) {
|
||||
val (status, slot) = child.findSlot(mouseX, mouseY)
|
||||
|
||||
if (status) {
|
||||
@ -818,7 +817,7 @@ open class EditablePanel<out S : Screen> @JvmOverloads constructor(
|
||||
return true to this.itemStack
|
||||
}
|
||||
|
||||
for (child in visibleChildren) {
|
||||
for (child in visibleChildrenInternal) {
|
||||
val (status, itemStack) = child.findItemStack(mouseX, mouseY, ignoreMouseInputLock)
|
||||
|
||||
if (status) {
|
||||
@ -853,7 +852,7 @@ open class EditablePanel<out S : Screen> @JvmOverloads constructor(
|
||||
return false
|
||||
}
|
||||
|
||||
for (child in visibleChildren) {
|
||||
for (child in visibleChildrenInternal) {
|
||||
if (child.renderTooltips(stack, mouseX, mouseY, partialTick)) {
|
||||
return true
|
||||
}
|
||||
@ -950,7 +949,7 @@ open class EditablePanel<out S : Screen> @JvmOverloads constructor(
|
||||
var top = dockPadding.top
|
||||
var bottom = dockPadding.bottom
|
||||
|
||||
for (child in visibleChildren) {
|
||||
for (child in visibleChildrenInternal) {
|
||||
when (child.dock) {
|
||||
Dock.NONE -> {}
|
||||
Dock.FILL -> {}
|
||||
@ -1013,7 +1012,7 @@ open class EditablePanel<out S : Screen> @JvmOverloads constructor(
|
||||
}
|
||||
}
|
||||
|
||||
for (child in visibleChildren) {
|
||||
for (child in visibleChildrenInternal) {
|
||||
if (child.dock == Dock.FILL) {
|
||||
val w = width - child.dockMargin.left - child.dockMargin.right - right - left
|
||||
val h = height - child.dockMargin.bottom - child.dockMargin.top - bottom - top
|
||||
@ -1051,7 +1050,7 @@ open class EditablePanel<out S : Screen> @JvmOverloads constructor(
|
||||
childrenRectWidth = 0f
|
||||
childrenRectHeight = 0f
|
||||
|
||||
for (child in visibleChildren) {
|
||||
for (child in visibleChildrenInternal) {
|
||||
childrenRectX = childrenRectX.coerceAtMost(child.x)
|
||||
childrenRectY = childrenRectY.coerceAtMost(child.y)
|
||||
childrenRectWidth = childrenRectWidth.coerceAtLeast(child.x + child.width)
|
||||
@ -1077,7 +1076,7 @@ open class EditablePanel<out S : Screen> @JvmOverloads constructor(
|
||||
var width = 1f
|
||||
var height = 1f
|
||||
|
||||
for (child in visibleChildren) {
|
||||
for (child in visibleChildrenInternal) {
|
||||
width = width.coerceAtLeast(child.x + child.width)
|
||||
height = height.coerceAtLeast(child.y + child.height)
|
||||
}
|
||||
@ -1097,7 +1096,7 @@ open class EditablePanel<out S : Screen> @JvmOverloads constructor(
|
||||
private fun updateVisible() {
|
||||
val isVisible = isVisible()
|
||||
|
||||
for (child in children) {
|
||||
for (child in childrenInternal) {
|
||||
val old = child.isVisible()
|
||||
child.visibleAsChildren = isVisible
|
||||
val new = child.isVisible()
|
||||
@ -1111,7 +1110,7 @@ open class EditablePanel<out S : Screen> @JvmOverloads constructor(
|
||||
}
|
||||
|
||||
private fun killFocusInternal() {
|
||||
for (child in children) {
|
||||
for (child in childrenInternal) {
|
||||
child.killFocusInternal()
|
||||
}
|
||||
|
||||
@ -1132,7 +1131,7 @@ open class EditablePanel<out S : Screen> @JvmOverloads constructor(
|
||||
return this
|
||||
}
|
||||
|
||||
for (child in children) {
|
||||
for (child in childrenInternal) {
|
||||
val focus = child.findHierarchicalFocus()
|
||||
|
||||
if (focus != null) {
|
||||
@ -1163,7 +1162,7 @@ open class EditablePanel<out S : Screen> @JvmOverloads constructor(
|
||||
onHierarchicalFocusChanged(focusedAsParent, old)
|
||||
}
|
||||
|
||||
for (child in children) {
|
||||
for (child in childrenInternal) {
|
||||
child.updateFocus()
|
||||
}
|
||||
}
|
||||
@ -1225,13 +1224,13 @@ open class EditablePanel<out S : Screen> @JvmOverloads constructor(
|
||||
}
|
||||
|
||||
fun fetchChildren(): List<EditablePanel<*>> {
|
||||
return ImmutableList.copyOf(children)
|
||||
return ImmutableList.copyOf(childrenInternal)
|
||||
}
|
||||
|
||||
fun getUndockedChildren(): List<EditablePanel<*>> {
|
||||
val list = LinkedList<EditablePanel<*>>()
|
||||
|
||||
for (child in children) {
|
||||
for (child in childrenInternal) {
|
||||
if (child.dock == Dock.NONE) {
|
||||
list.add(child)
|
||||
}
|
||||
@ -1241,8 +1240,8 @@ open class EditablePanel<out S : Screen> @JvmOverloads constructor(
|
||||
}
|
||||
|
||||
operator fun get(index: Int): EditablePanel<*>? {
|
||||
if (index < 0 || index >= children.size) return null
|
||||
return children[index]
|
||||
if (index < 0 || index >= childrenInternal.size) return null
|
||||
return childrenInternal[index]
|
||||
}
|
||||
|
||||
fun isGrabbingMouseInput(): Boolean {
|
||||
@ -1250,7 +1249,7 @@ open class EditablePanel<out S : Screen> @JvmOverloads constructor(
|
||||
return true
|
||||
}
|
||||
|
||||
for (child in children) {
|
||||
for (child in childrenInternal) {
|
||||
if (child.isGrabbingMouseInput()) {
|
||||
return true
|
||||
}
|
||||
@ -1281,7 +1280,7 @@ open class EditablePanel<out S : Screen> @JvmOverloads constructor(
|
||||
}
|
||||
|
||||
fun killFocusForEverythingExcept(except: EditablePanel<*>) {
|
||||
for (child in children) {
|
||||
for (child in childrenInternal) {
|
||||
if (child !== except) {
|
||||
child.killFocusForEverythingExceptInner()
|
||||
}
|
||||
@ -1289,7 +1288,7 @@ open class EditablePanel<out S : Screen> @JvmOverloads constructor(
|
||||
}
|
||||
|
||||
fun killFocusForEverythingExceptInner() {
|
||||
for (child in children) {
|
||||
for (child in childrenInternal) {
|
||||
child.killFocusForEverythingExceptInner()
|
||||
}
|
||||
|
||||
@ -1307,14 +1306,14 @@ open class EditablePanel<out S : Screen> @JvmOverloads constructor(
|
||||
|
||||
if (grabMouseInput) return mouseClickedInner(x, y, button)
|
||||
|
||||
for (child in visibleChildren) {
|
||||
for (child in visibleChildrenInternal) {
|
||||
if (child.isGrabbingMouseInput() && child.mouseClickedChecked(x, y, button)) {
|
||||
killFocusForEverythingExcept(child)
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
for (child in visibleChildren) {
|
||||
for (child in visibleChildrenInternal) {
|
||||
if (child.mouseClickedChecked(x, y, button)) {
|
||||
killFocusForEverythingExcept(child)
|
||||
return true
|
||||
@ -1331,7 +1330,7 @@ open class EditablePanel<out S : Screen> @JvmOverloads constructor(
|
||||
if (acceptMouseInput && parent == null) popup()
|
||||
return mouseClicked(x, y, button)
|
||||
} else if (withinExtendedBounds(x, y)) {
|
||||
for (child in visibleChildren) {
|
||||
for (child in visibleChildrenInternal) {
|
||||
if (child.mouseClickedChecked(x, y, button)) {
|
||||
killFocusForEverythingExcept(child)
|
||||
return true
|
||||
@ -1359,13 +1358,13 @@ open class EditablePanel<out S : Screen> @JvmOverloads constructor(
|
||||
|
||||
if (grabMouseInput) return mouseReleasedInner(x, y, button)
|
||||
|
||||
for (child in visibleChildren) {
|
||||
for (child in visibleChildrenInternal) {
|
||||
if (child.isGrabbingMouseInput() && child.mouseReleasedChecked(x, y, button)) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
for (child in visibleChildren) {
|
||||
for (child in visibleChildrenInternal) {
|
||||
if (child.mouseReleasedChecked(x, y, button)) {
|
||||
return true
|
||||
}
|
||||
@ -1380,7 +1379,7 @@ open class EditablePanel<out S : Screen> @JvmOverloads constructor(
|
||||
if (isGrabbingMouseInput() || withinBounds(x, y)) {
|
||||
return mouseReleased(x, y, button)
|
||||
} else if (withinExtendedBounds(x, y)) {
|
||||
for (child in visibleChildren) {
|
||||
for (child in visibleChildrenInternal) {
|
||||
if (child.mouseReleasedChecked(x, y, button)) {
|
||||
return true
|
||||
}
|
||||
@ -1403,13 +1402,13 @@ open class EditablePanel<out S : Screen> @JvmOverloads constructor(
|
||||
|
||||
if (grabMouseInput) return mouseDraggedInner(x, y, button, xDelta, yDelta)
|
||||
|
||||
for (child in visibleChildren) {
|
||||
for (child in visibleChildrenInternal) {
|
||||
if (child.isGrabbingMouseInput() && child.mouseDraggedChecked(x, y, button, xDelta, yDelta)) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
for (child in visibleChildren) {
|
||||
for (child in visibleChildrenInternal) {
|
||||
if (child.mouseDraggedChecked(x, y, button, xDelta, yDelta)) {
|
||||
return true
|
||||
}
|
||||
@ -1424,7 +1423,7 @@ open class EditablePanel<out S : Screen> @JvmOverloads constructor(
|
||||
if (isGrabbingMouseInput() || withinBounds(x, y)) {
|
||||
return mouseDragged(x, y, button, xDelta, yDelta)
|
||||
} else if (withinExtendedBounds(x, y)) {
|
||||
for (child in visibleChildren) {
|
||||
for (child in visibleChildrenInternal) {
|
||||
if (child.mouseDraggedChecked(x, y, button, xDelta, yDelta)) {
|
||||
return true
|
||||
}
|
||||
@ -1448,13 +1447,13 @@ open class EditablePanel<out S : Screen> @JvmOverloads constructor(
|
||||
|
||||
if (grabMouseInput) return mouseScrolledInner(x, y, scroll)
|
||||
|
||||
for (child in visibleChildren) {
|
||||
for (child in visibleChildrenInternal) {
|
||||
if (child.isGrabbingMouseInput() && child.mouseScrolledChecked(x, y, scroll)) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
for (child in visibleChildren) {
|
||||
for (child in visibleChildrenInternal) {
|
||||
if (child.mouseScrolledChecked(x, y, scroll)) {
|
||||
return true
|
||||
}
|
||||
@ -1469,7 +1468,7 @@ open class EditablePanel<out S : Screen> @JvmOverloads constructor(
|
||||
if (isGrabbingMouseInput() || withinBounds(x, y)) {
|
||||
return mouseScrolled(x, y, scroll)
|
||||
} else if (withinExtendedBounds(x, y)) {
|
||||
for (child in visibleChildren) {
|
||||
for (child in visibleChildrenInternal) {
|
||||
if (child.mouseScrolledChecked(x, y, scroll)) {
|
||||
return true
|
||||
}
|
||||
@ -1493,7 +1492,7 @@ open class EditablePanel<out S : Screen> @JvmOverloads constructor(
|
||||
|
||||
if (isFocused) return keyPressedInternal(key, scancode, mods)
|
||||
|
||||
for (child in visibleChildren) {
|
||||
for (child in visibleChildrenInternal) {
|
||||
if (child.keyPressed(key, scancode, mods)) {
|
||||
return true
|
||||
}
|
||||
@ -1516,7 +1515,7 @@ open class EditablePanel<out S : Screen> @JvmOverloads constructor(
|
||||
|
||||
if (isFocused) return keyReleasedInternal(key, scancode, mods)
|
||||
|
||||
for (child in visibleChildren) {
|
||||
for (child in visibleChildrenInternal) {
|
||||
if (child.keyReleased(key, scancode, mods)) {
|
||||
return true
|
||||
}
|
||||
@ -1539,7 +1538,7 @@ open class EditablePanel<out S : Screen> @JvmOverloads constructor(
|
||||
|
||||
if (isFocused) return charTypedInternal(codepoint, mods)
|
||||
|
||||
for (child in visibleChildren) {
|
||||
for (child in visibleChildrenInternal) {
|
||||
if (child.charTyped(codepoint, mods)) {
|
||||
return true
|
||||
}
|
||||
@ -1565,7 +1564,7 @@ open class EditablePanel<out S : Screen> @JvmOverloads constructor(
|
||||
open fun tick() {
|
||||
tick++
|
||||
|
||||
for (child in Array(children.size) { children[it] }) {
|
||||
for (child in Array(childrenInternal.size) { childrenInternal[it] }) {
|
||||
child.tick()
|
||||
}
|
||||
}
|
||||
@ -1588,7 +1587,7 @@ open class EditablePanel<out S : Screen> @JvmOverloads constructor(
|
||||
screen.removePanel(this as EditablePanel<MatteryScreen<*>>)
|
||||
}
|
||||
|
||||
for (child in Array(children.size) { children[it] }) {
|
||||
for (child in Array(childrenInternal.size) { childrenInternal[it] }) {
|
||||
child.remove()
|
||||
}
|
||||
|
||||
|
@ -180,7 +180,7 @@ open class EffectListPanel<out S : Screen> @JvmOverloads constructor(
|
||||
override fun performLayout() {
|
||||
super.performLayout()
|
||||
|
||||
val sorted = childrenView.stream().filter { it is EffectSquare }.collect(Collectors.toList()) as MutableList<EffectListPanel<S>.EffectSquare>
|
||||
val sorted = children.stream().filter { it is EffectSquare }.collect(Collectors.toList()) as MutableList<EffectListPanel<S>.EffectSquare>
|
||||
|
||||
sorted.sortWith { a, b ->
|
||||
a.effect.duration.compareTo(b.effect.duration)
|
||||
|
@ -61,7 +61,7 @@ open class QueryUserPanel<out S: Screen>(
|
||||
}
|
||||
}
|
||||
|
||||
this.width = maxWidth.coerceAtLeast(bottom.childrenView.stream().mapToDouble { it.width.toDouble() }.sum().toFloat() + 2f) + PADDING * 2f
|
||||
this.width = maxWidth.coerceAtLeast(bottom.children.stream().mapToDouble { it.width.toDouble() }.sum().toFloat() + 2f) + PADDING * 2f
|
||||
|
||||
toScreenCenter()
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user