From 3e92c5272dd85f0826bfe29a90a1f900beb51316 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Fri, 21 Mar 2025 13:52:00 +0700 Subject: [PATCH] Move panels additional types to separate file --- .../otm/client/screen/panels/EditablePanel.kt | 115 ------------------ .../mc/otm/client/screen/panels/Types.kt | 115 ++++++++++++++++++ 2 files changed, 115 insertions(+), 115 deletions(-) create mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/Types.kt 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 1b3c0da7f..e2be32ce9 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 @@ -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( val screen: S, parent: EditablePanel<*>?, diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/Types.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/Types.kt new file mode 100644 index 000000000..7d498d8f6 --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/Types.kt @@ -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()) + } +}