Fixes for quick stack controls
This commit is contained in:
parent
2547478914
commit
07e0c73479
@ -24,7 +24,7 @@ class QuickStackControlsPanel<out S : Screen>(
|
|||||||
|
|
||||||
init {
|
init {
|
||||||
grid.dock = Dock.FILL
|
grid.dock = Dock.FILL
|
||||||
grid.layout = GridPanel.Layout.TOP_LEFT
|
grid.layout = GridPanel.Layout.TOP_RIGHT
|
||||||
}
|
}
|
||||||
|
|
||||||
private inner class MainButton : ButtonPanel<S>(screen, grid, width = 18f, height = 18f) {
|
private inner class MainButton : ButtonPanel<S>(screen, grid, width = 18f, height = 18f) {
|
||||||
@ -70,31 +70,7 @@ class QuickStackControlsPanel<out S : Screen>(
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun sizeToContents() {
|
private fun moveToDockedParent() {
|
||||||
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
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onParented(parent: EditablePanel<*>) {
|
|
||||||
super.onParented(parent)
|
|
||||||
|
|
||||||
dockNear = null
|
|
||||||
}
|
|
||||||
|
|
||||||
var dockNear: EditablePanel<*>? = null
|
|
||||||
|
|
||||||
override fun tickInner() {
|
|
||||||
super.tickInner()
|
|
||||||
|
|
||||||
val dockNear = dockNear
|
val dockNear = dockNear
|
||||||
|
|
||||||
if (dockNear != null && parent == null && dock != Dock.NONE && dock != Dock.FILL) {
|
if (dockNear != null && parent == null && dock != Dock.NONE && dock != Dock.FILL) {
|
||||||
@ -127,6 +103,41 @@ class QuickStackControlsPanel<out S : Screen>(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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()
|
||||||
|
}
|
||||||
|
|
||||||
init {
|
init {
|
||||||
for ((i, mode) in QuickMoveInput.Mode.entries.withIndex()) {
|
for ((i, mode) in QuickMoveInput.Mode.entries.withIndex()) {
|
||||||
val button = ButtonPanel.square18(
|
val button = ButtonPanel.square18(
|
||||||
@ -147,7 +158,7 @@ class QuickStackControlsPanel<out S : Screen>(
|
|||||||
mode.iconToStorage,
|
mode.iconToStorage,
|
||||||
onPress = IntConsumer { PacketDistributor.sendToServer(QuickStackPacket(mode, true)) })
|
onPress = IntConsumer { PacketDistributor.sendToServer(QuickStackPacket(mode, true)) })
|
||||||
|
|
||||||
button.childrenOrder = i + 1
|
button.childrenOrder = i
|
||||||
button.dockMargin = DockProperty.left(1f)
|
button.dockMargin = DockProperty.left(1f)
|
||||||
button.visible = false
|
button.visible = false
|
||||||
button.tooltips.add(mode.textToStorage)
|
button.tooltips.add(mode.textToStorage)
|
||||||
|
Loading…
Reference in New Issue
Block a user