From a6361f10f2a64f62fac4b3d1e99f2041a1967ab5 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Fri, 21 Mar 2025 18:35:25 +0700 Subject: [PATCH] Final improvements to quick stack controls --- .../client/screen/ExopackInventoryScreen.kt | 7 +- .../screen/panels/QuickStackControlsPanel.kt | 75 ++----------------- 2 files changed, 9 insertions(+), 73 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/ExopackInventoryScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/ExopackInventoryScreen.kt index e199b8e5b..56a368fc0 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/ExopackInventoryScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/ExopackInventoryScreen.kt @@ -286,12 +286,7 @@ class ExopackInventoryScreen(menu: ExopackInventoryMenu) : MatteryScreen( screen: S, parent: EditablePanel<*>? = null, -) : EditablePanel(screen, parent, 0f, 0f, 18f, 18f) { + x: Float = 0f, + y: Float = 0f +) : EditablePanel(screen, parent, x, y, 18f, 18f) { private val grid = GridPanel(screen, this, columns = 1, rows = 1) private val buttons = ArrayList>() init { grid.dock = Dock.FILL grid.layout = GridPanel.Layout.TOP_RIGHT + grid.columnMajorOrder = true } private inner class MainButton : ButtonPanel(screen, grid, width = 18f, height = 18f) { init { - dockMargin = DockProperty.left(1f) + dockMargin = DockProperty.bottom(1f) childrenOrder = -100 tooltips.add(QuickMoveInput.Mode.RESTOCK_WITH_MOVE.textToStorage) tooltips.add(TextComponent("")) @@ -70,72 +73,10 @@ class QuickStackControlsPanel( return false } - private fun moveToDockedParent() { - val dockNear = dockNear - - if (dockNear != null && parent == null && dock != Dock.NONE && dock != Dock.FILL) { - x = dockNear.absoluteX - y = dockNear.absoluteY - - when (dock) { - Dock.LEFT -> { - x -= width + dockMargin.right - y += dockMargin.top - } - - Dock.RIGHT -> { - x += width + dockMargin.left - y += dockMargin.top - } - - Dock.TOP -> { - y -= height + dockMargin.bottom - x += dockMargin.left - } - - Dock.BOTTOM -> { - y += height + dockMargin.top - x += dockMargin.left - } - - else -> throw RuntimeException("you w0t m8?") - } - } - } - override fun sizeToContents() { val oldWidth = width - val oldHeight = height super.sizeToContents() - - if (parent == null && dockNear == null) { - when (dock) { - Dock.LEFT -> x -= width - oldWidth - Dock.TOP -> y -= height - oldHeight - else -> {} // do nothing - } - } else { - moveToDockedParent() - } - } - - override fun onParented(parent: EditablePanel<*>) { - super.onParented(parent) - - dockNear = null - } - - var dockNear: EditablePanel<*>? = null - set(value) { - if (field != value) { - field = value - moveToDockedParent() - } - } - - override fun tickInner() { - super.tickInner() - moveToDockedParent() + x -= width - oldWidth } init { @@ -146,7 +87,7 @@ class QuickStackControlsPanel( onPress = IntConsumer { PacketDistributor.sendToServer(QuickStackPacket(mode, false)) }) button.childrenOrder = QuickMoveInput.Mode.entries.size + i - button.dockMargin = DockProperty.left(1f) + button.dockMargin = DockProperty.bottomRight(1f) button.visible = false button.tooltips.add(mode.textFromStorage) buttons.add(button) @@ -159,7 +100,7 @@ class QuickStackControlsPanel( onPress = IntConsumer { PacketDistributor.sendToServer(QuickStackPacket(mode, true)) }) button.childrenOrder = i - button.dockMargin = DockProperty.left(1f) + button.dockMargin = DockProperty.bottom(1f) button.visible = false button.tooltips.add(mode.textToStorage) buttons.add(button)