Move panels additional types to separate file
This commit is contained in:
parent
f9821aa552
commit
3e92c5272d
@ -11,9 +11,7 @@ import net.minecraft.client.gui.components.events.GuiEventListener
|
||||
import net.minecraft.client.gui.navigation.FocusNavigationEvent
|
||||
import net.minecraft.client.gui.navigation.ScreenRectangle
|
||||
import net.minecraft.client.gui.screens.Screen
|
||||
import net.minecraft.client.renderer.Rect2i
|
||||
import net.minecraft.network.chat.Component
|
||||
import net.minecraft.util.RandomSource
|
||||
import org.apache.logging.log4j.LogManager
|
||||
import ru.dbotthepony.mc.otm.SystemTime
|
||||
import ru.dbotthepony.mc.otm.client.CursorType
|
||||
@ -26,129 +24,16 @@ 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.client.screen.panels.input.QueryUserPanel
|
||||
import ru.dbotthepony.mc.otm.core.RandomSource2Generator
|
||||
import ru.dbotthepony.mc.otm.core.collect.concatIterators
|
||||
import ru.dbotthepony.mc.otm.core.collect.flatMap
|
||||
import ru.dbotthepony.mc.otm.core.util.GJRAND64RandomSource
|
||||
import java.util.*
|
||||
import java.util.concurrent.CopyOnWriteArrayList
|
||||
import java.util.function.Predicate
|
||||
import java.util.random.RandomGenerator
|
||||
import kotlin.collections.ArrayList
|
||||
import kotlin.math.max
|
||||
import kotlin.math.roundToInt
|
||||
|
||||
data class ScreenPos(val x: Float, val y: Float)
|
||||
|
||||
data class DockProperty(val left: Float = 0f, val top: Float = 0f, val right: Float = 0f, val bottom: Float = 0f) {
|
||||
val isEmpty get() = left == 0f && right == 0f && top == 0f && bottom == 0f
|
||||
val horizontal get() = left + right
|
||||
val vertical get() = top + bottom
|
||||
|
||||
operator fun plus(other: DockProperty): DockProperty {
|
||||
return DockProperty(
|
||||
left + other.left,
|
||||
top + other.top,
|
||||
right + other.right,
|
||||
bottom + other.bottom
|
||||
)
|
||||
}
|
||||
|
||||
operator fun minus(other: DockProperty): DockProperty {
|
||||
return DockProperty(
|
||||
left - other.left,
|
||||
top - other.top,
|
||||
right - other.right,
|
||||
bottom - other.bottom
|
||||
)
|
||||
}
|
||||
|
||||
operator fun plus(other: Float): DockProperty {
|
||||
return DockProperty(
|
||||
left + other,
|
||||
top + other,
|
||||
right + other,
|
||||
bottom + other
|
||||
)
|
||||
}
|
||||
|
||||
operator fun minus(other: Float): DockProperty {
|
||||
return DockProperty(
|
||||
left - other,
|
||||
top - other,
|
||||
right - other,
|
||||
bottom - other
|
||||
)
|
||||
}
|
||||
|
||||
companion object {
|
||||
val EMPTY = DockProperty()
|
||||
|
||||
@JvmStatic
|
||||
fun all(value: Float): DockProperty {
|
||||
return DockProperty(value, value, value, value)
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
@JvmOverloads
|
||||
fun topLeft(top: Float, left: Float = top): DockProperty {
|
||||
return DockProperty(left = left, top = top)
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun left(value: Float): DockProperty {
|
||||
return DockProperty(left = value)
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
@JvmOverloads
|
||||
fun topRight(top: Float, right: Float = top): DockProperty {
|
||||
return DockProperty(right = right, top = top)
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun right(value: Float): DockProperty {
|
||||
return DockProperty(right = value)
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun top(value: Float): DockProperty {
|
||||
return DockProperty(top = value)
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
@JvmOverloads
|
||||
fun bottomLeft(bottom: Float, left: Float = bottom): DockProperty {
|
||||
return DockProperty(left = left, bottom = bottom)
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
@JvmOverloads
|
||||
fun bottomRight(bottom: Float, right: Float = bottom): DockProperty {
|
||||
return DockProperty(right = right, bottom = bottom)
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun bottom(value: Float): DockProperty {
|
||||
return DockProperty(bottom = value)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
enum class Dock {
|
||||
NONE, LEFT, RIGHT, TOP, BOTTOM, FILL
|
||||
}
|
||||
|
||||
enum class DockResizeMode(val changeWidth: Boolean, val changeHeight: Boolean) {
|
||||
ALL(true, true), NONE(false, false), WIDTH(true, false), HEIGHT(false, true)
|
||||
}
|
||||
|
||||
data class Rect2f(val x: Float, val y: Float, val width: Float, val height: Float) {
|
||||
fun toIntRect(): Rect2i {
|
||||
return Rect2i(x.roundToInt(), y.roundToInt(), width.roundToInt(), height.roundToInt())
|
||||
}
|
||||
}
|
||||
|
||||
open class EditablePanel<out S : Screen>(
|
||||
val screen: S,
|
||||
parent: EditablePanel<*>?,
|
||||
|
@ -0,0 +1,115 @@
|
||||
package ru.dbotthepony.mc.otm.client.screen.panels
|
||||
|
||||
import net.minecraft.client.renderer.Rect2i
|
||||
import kotlin.math.roundToInt
|
||||
|
||||
data class ScreenPos(val x: Float, val y: Float)
|
||||
|
||||
data class DockProperty(val left: Float = 0f, val top: Float = 0f, val right: Float = 0f, val bottom: Float = 0f) {
|
||||
val isEmpty get() = left == 0f && right == 0f && top == 0f && bottom == 0f
|
||||
val horizontal get() = left + right
|
||||
val vertical get() = top + bottom
|
||||
|
||||
operator fun plus(other: DockProperty): DockProperty {
|
||||
return DockProperty(
|
||||
left + other.left,
|
||||
top + other.top,
|
||||
right + other.right,
|
||||
bottom + other.bottom
|
||||
)
|
||||
}
|
||||
|
||||
operator fun minus(other: DockProperty): DockProperty {
|
||||
return DockProperty(
|
||||
left - other.left,
|
||||
top - other.top,
|
||||
right - other.right,
|
||||
bottom - other.bottom
|
||||
)
|
||||
}
|
||||
|
||||
operator fun plus(other: Float): DockProperty {
|
||||
return DockProperty(
|
||||
left + other,
|
||||
top + other,
|
||||
right + other,
|
||||
bottom + other
|
||||
)
|
||||
}
|
||||
|
||||
operator fun minus(other: Float): DockProperty {
|
||||
return DockProperty(
|
||||
left - other,
|
||||
top - other,
|
||||
right - other,
|
||||
bottom - other
|
||||
)
|
||||
}
|
||||
|
||||
companion object {
|
||||
val EMPTY = DockProperty()
|
||||
|
||||
@JvmStatic
|
||||
fun all(value: Float): DockProperty {
|
||||
return DockProperty(value, value, value, value)
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
@JvmOverloads
|
||||
fun topLeft(top: Float, left: Float = top): DockProperty {
|
||||
return DockProperty(left = left, top = top)
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun left(value: Float): DockProperty {
|
||||
return DockProperty(left = value)
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
@JvmOverloads
|
||||
fun topRight(top: Float, right: Float = top): DockProperty {
|
||||
return DockProperty(right = right, top = top)
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun right(value: Float): DockProperty {
|
||||
return DockProperty(right = value)
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun top(value: Float): DockProperty {
|
||||
return DockProperty(top = value)
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
@JvmOverloads
|
||||
fun bottomLeft(bottom: Float, left: Float = bottom): DockProperty {
|
||||
return DockProperty(left = left, bottom = bottom)
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
@JvmOverloads
|
||||
fun bottomRight(bottom: Float, right: Float = bottom): DockProperty {
|
||||
return DockProperty(right = right, bottom = bottom)
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun bottom(value: Float): DockProperty {
|
||||
return DockProperty(bottom = value)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
enum class Dock {
|
||||
NONE, LEFT, RIGHT, TOP, BOTTOM, FILL
|
||||
}
|
||||
|
||||
enum class DockResizeMode(val changeWidth: Boolean, val changeHeight: Boolean) {
|
||||
ALL(true, true), NONE(false, false), WIDTH(true, false), HEIGHT(false, true)
|
||||
}
|
||||
|
||||
data class Rect2f(val x: Float, val y: Float, val width: Float, val height: Float) {
|
||||
fun toIntRect(): Rect2i {
|
||||
return Rect2i(x.roundToInt(), y.roundToInt(), width.roundToInt(), height.roundToInt())
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user